34 #define JP2_SIG_TYPE 0x6A502020
35 #define JP2_SIG_VALUE 0x0D0A870A
44 return image->comps[0].dx == image->comps[1].dx &&
45 image->comps[1].dx == image->comps[2].dx &&
46 image->comps[0].dy == image->comps[1].dy &&
47 image->comps[1].dy == image->comps[2].dy &&
48 image->comps[0].prec == image->comps[1].prec &&
49 image->comps[1].prec == image->comps[2].prec;
56 opj_set_default_decoder_parameters(&ctx->
dec_params);
70 void *
data,
int *data_size,
73 uint8_t *buf = avpkt->
data;
74 int buf_size = avpkt->
size;
91 dec = opj_create_decompress(CODEC_JP2);
97 dec = opj_create_decompress(CODEC_J2K);
104 opj_set_event_mgr((opj_common_ptr)dec,
NULL,
NULL);
106 ctx->
dec_params.cp_limit_decoding = LIMIT_TO_MAIN_HEADER;
109 stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
112 opj_destroy_decompress(dec);
117 image = opj_decode_with_info(dec, stream,
NULL);
118 opj_cio_close(stream);
121 opj_destroy_decompress(dec);
124 width = image->x1 - image->x0;
125 height = image->y1 - image->y0;
132 switch(image->numcomps)
143 case 4: has_alpha = 1;
146 default:
av_log(avctx,
AV_LOG_ERROR,
"%d components unsupported.\n", image->numcomps);
160 ctx->
dec_params.cp_limit_decoding = NO_LIMITATION;
164 stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
167 opj_destroy_decompress(dec);
172 image = opj_decode_with_info(dec, stream,
NULL);
173 opj_cio_close(stream);
175 for(x = 0; x < image->numcomps; x++) {
176 adjust[x] =
FFMAX(image->comps[x].prec - 8, 0);
179 for(y = 0; y < avctx->
height; y++) {
180 index = y*avctx->
width;
182 for(x = 0; x < avctx->
width; x++, index++) {
183 *img_ptr++ = image->comps[0].data[
index] >> adjust[0];
185 *img_ptr++ = image->comps[1].data[
index] >> adjust[1];
186 *img_ptr++ = image->comps[2].data[
index] >> adjust[2];
188 *img_ptr++ = image->comps[3].data[
index] >> adjust[3];
193 *output = ctx->
image;
198 opj_image_destroy(image);
199 opj_destroy_decompress(dec);
214 .
name =
"libopenjpeg",
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
AV_WL32 AV_WL24 AV_WL16 AV_RB32
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
AVFrame * coded_frame
the picture in the bitstream
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
static int check_image_attributes(opj_image_t *image)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
static int libopenjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Multithreading support functions.
static av_cold int libopenjpeg_decode_init_thread_copy(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
struct AVPicture AVPicture
four components are given, that's all.
static av_cold int libopenjpeg_decode_close(AVCodecContext *avctx)
static av_cold int libopenjpeg_decode_init(AVCodecContext *avctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
packed RGB 8:8:8, 24bpp, RGBRGB...
opj_dparameters_t dec_params
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
AVCodec ff_libopenjpeg_decoder
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.