FFmpeg
libopenjpegdec.c
Go to the documentation of this file.
1 /*
2  * JPEG 2000 decoding support via OpenJPEG
3  * Copyright (c) 2009 Jaikrishnan Menon <realityman@gmx.net>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * JPEG 2000 decoder using libopenjpeg
25  */
26 
27 #include "libavutil/common.h"
28 #include "libavutil/imgutils.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/pixfmt.h"
32 
33 #include "avcodec.h"
34 #include "codec_internal.h"
35 #include "decode.h"
36 #include "thread.h"
37 
38 #include <openjpeg.h>
39 
40 #define JP2_SIG_TYPE 0x6A502020
41 #define JP2_SIG_VALUE 0x0D0A870A
42 
43 // pix_fmts with lower bpp have to be listed before
44 // similar pix_fmts with higher bpp.
45 #define RGB_PIXEL_FORMATS AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, \
46  AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64
47 
48 #define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8, AV_PIX_FMT_YA8, \
49  AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, \
50  AV_PIX_FMT_GRAY16, AV_PIX_FMT_YA16
51 
52 #define YUV_PIXEL_FORMATS AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUVA420P, \
53  AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA422P, \
54  AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, \
55  AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, \
56  AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, \
57  AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, \
58  AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10, \
59  AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, \
60  AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, \
61  AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, \
62  AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16
63 
64 #define XYZ_PIXEL_FORMATS AV_PIX_FMT_XYZ12
65 
66 static const enum AVPixelFormat libopenjpeg_rgb_pix_fmts[] = {
68 };
71 };
72 static const enum AVPixelFormat libopenjpeg_yuv_pix_fmts[] = {
74 };
75 static const enum AVPixelFormat libopenjpeg_all_pix_fmts[] = {
77 };
78 
79 typedef struct LibOpenJPEGContext {
80  AVClass *class;
81  opj_dparameters_t dec_params;
82  int lowqual;
84 
85 static void error_callback(const char *msg, void *data)
86 {
87  av_log(data, AV_LOG_ERROR, "%s", msg);
88 }
89 
90 static void warning_callback(const char *msg, void *data)
91 {
92  av_log(data, AV_LOG_WARNING, "%s", msg);
93 }
94 
95 static void info_callback(const char *msg, void *data)
96 {
97  av_log(data, AV_LOG_DEBUG, "%s", msg);
98 }
99 
100 typedef struct BufferReader {
101  int pos;
102  int size;
103  const uint8_t *buffer;
104 } BufferReader;
105 
106 static OPJ_SIZE_T stream_read(void *out_buffer, OPJ_SIZE_T nb_bytes, void *user_data)
107 {
108  BufferReader *reader = user_data;
109  int remaining;
110 
111  if (reader->pos == reader->size) {
112  return (OPJ_SIZE_T)-1;
113  }
114  remaining = reader->size - reader->pos;
115  if (nb_bytes > remaining) {
116  nb_bytes = remaining;
117  }
118  memcpy(out_buffer, reader->buffer + reader->pos, nb_bytes);
119  reader->pos += (int)nb_bytes;
120  return nb_bytes;
121 }
122 
123 static OPJ_OFF_T stream_skip(OPJ_OFF_T nb_bytes, void *user_data)
124 {
125  BufferReader *reader = user_data;
126  if (nb_bytes < 0) {
127  if (reader->pos == 0) {
128  return (OPJ_SIZE_T)-1;
129  }
130  if (nb_bytes + reader->pos < 0) {
131  nb_bytes = -reader->pos;
132  }
133  } else {
134  int remaining;
135 
136  if (reader->pos == reader->size) {
137  return (OPJ_SIZE_T)-1;
138  }
139  remaining = reader->size - reader->pos;
140  if (nb_bytes > remaining) {
141  nb_bytes = remaining;
142  }
143  }
144  reader->pos += (int)nb_bytes;
145  return nb_bytes;
146 }
147 
148 static OPJ_BOOL stream_seek(OPJ_OFF_T nb_bytes, void *user_data)
149 {
150  BufferReader *reader = user_data;
151  if (nb_bytes < 0 || nb_bytes > reader->size) {
152  return OPJ_FALSE;
153  }
154  reader->pos = (int)nb_bytes;
155  return OPJ_TRUE;
156 }
157 
158 static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVPixelFormat pix_fmt)
159 {
161  int match = 1;
162 
163  if (desc->nb_components != image->numcomps) {
164  return 0;
165  }
166 
167  switch (desc->nb_components) {
168  case 4:
169  match = match &&
170  desc->comp[3].depth >= image->comps[3].prec &&
171  1 == image->comps[3].dx &&
172  1 == image->comps[3].dy;
173  case 3:
174  match = match &&
175  desc->comp[2].depth >= image->comps[2].prec &&
176  1 << desc->log2_chroma_w == image->comps[2].dx &&
177  1 << desc->log2_chroma_h == image->comps[2].dy;
178  case 2:
179  match = match &&
180  desc->comp[1].depth >= image->comps[1].prec &&
181  1 << desc->log2_chroma_w == image->comps[1].dx &&
182  1 << desc->log2_chroma_h == image->comps[1].dy;
183  case 1:
184  match = match &&
185  desc->comp[0].depth >= image->comps[0].prec &&
186  1 == image->comps[0].dx &&
187  1 == image->comps[0].dy;
188  default:
189  break;
190  }
191 
192  return match;
193 }
194 
195 static inline enum AVPixelFormat libopenjpeg_guess_pix_fmt(const opj_image_t *image) {
196  int index;
197  const enum AVPixelFormat *possible_fmts = NULL;
198  int possible_fmts_nb = 0;
199 
200  switch (image->color_space) {
201  case OPJ_CLRSPC_SRGB:
202  possible_fmts = libopenjpeg_rgb_pix_fmts;
203  possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_rgb_pix_fmts);
204  break;
205  case OPJ_CLRSPC_GRAY:
206  possible_fmts = libopenjpeg_gray_pix_fmts;
207  possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_gray_pix_fmts);
208  break;
209  case OPJ_CLRSPC_SYCC:
210  possible_fmts = libopenjpeg_yuv_pix_fmts;
211  possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_yuv_pix_fmts);
212  break;
213  default:
214  possible_fmts = libopenjpeg_all_pix_fmts;
215  possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_all_pix_fmts);
216  break;
217  }
218 
219  for (index = 0; index < possible_fmts_nb; ++index)
220  if (libopenjpeg_matches_pix_fmt(image, possible_fmts[index])) {
221  return possible_fmts[index];
222  }
223 
224  return AV_PIX_FMT_NONE;
225 }
226 
228 {
230  int i, component_plane;
231 
232  if (pix_fmt == AV_PIX_FMT_GRAY16)
233  return 0;
234 
235  component_plane = desc->comp[0].plane;
236  for (i = 1; i < desc->nb_components; i++)
237  if (component_plane != desc->comp[i].plane)
238  return 0;
239  return 1;
240 }
241 
242 static inline void libopenjpeg_copy_to_packed8(AVFrame *picture, opj_image_t *image) {
243  uint8_t *img_ptr;
244  int index, x, y, c;
245  for (y = 0; y < picture->height; y++) {
246  index = y * picture->width;
247  img_ptr = picture->data[0] + y * picture->linesize[0];
248  for (x = 0; x < picture->width; x++, index++)
249  for (c = 0; c < image->numcomps; c++)
250  *img_ptr++ = 0x80 * image->comps[c].sgnd + image->comps[c].data[index];
251  }
252 }
253 
254 static inline void libopenjpeg_copy_to_packed16(AVFrame *picture, opj_image_t *image) {
255  uint16_t *img_ptr;
257  int index, x, y, c;
258  int adjust[4];
259  for (x = 0; x < image->numcomps; x++)
260  adjust[x] = FFMAX(FFMIN(desc->comp[x].depth - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
261 
262  for (y = 0; y < picture->height; y++) {
263  index = y * picture->width;
264  img_ptr = (uint16_t *) (picture->data[0] + y * picture->linesize[0]);
265  for (x = 0; x < picture->width; x++, index++)
266  for (c = 0; c < image->numcomps; c++)
267  *img_ptr++ = (1 << image->comps[c].prec - 1) * image->comps[c].sgnd +
268  (unsigned)image->comps[c].data[index] << adjust[c];
269  }
270 }
271 
272 static inline void libopenjpeg_copyto8(AVFrame *picture, opj_image_t *image) {
273  int *comp_data;
274  uint8_t *img_ptr;
275  int index, x, y;
276 
277  for (index = 0; index < image->numcomps; index++) {
278  comp_data = image->comps[index].data;
279  for (y = 0; y < image->comps[index].h; y++) {
280  img_ptr = picture->data[index] + y * picture->linesize[index];
281  for (x = 0; x < image->comps[index].w; x++) {
282  *img_ptr = 0x80 * image->comps[index].sgnd + *comp_data;
283  img_ptr++;
284  comp_data++;
285  }
286  }
287  }
288 }
289 
290 static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
291  int *comp_data;
292  uint16_t *img_ptr;
294  int index, x, y;
295  int adjust[4];
296  for (x = 0; x < image->numcomps; x++)
297  adjust[x] = FFMAX(FFMIN(desc->comp[x].depth - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
298 
299  for (index = 0; index < image->numcomps; index++) {
300  comp_data = image->comps[index].data;
301  for (y = 0; y < image->comps[index].h; y++) {
302  img_ptr = (uint16_t *)(picture->data[index] + y * picture->linesize[index]);
303  for (x = 0; x < image->comps[index].w; x++) {
304  *img_ptr = (1 << image->comps[index].prec - 1) * image->comps[index].sgnd +
305  (unsigned)*comp_data << adjust[index];
306  img_ptr++;
307  comp_data++;
308  }
309  }
310  }
311 }
312 
314 {
315  LibOpenJPEGContext *ctx = avctx->priv_data;
316 
317  opj_set_default_decoder_parameters(&ctx->dec_params);
318  return 0;
319 }
320 
321 static int libopenjpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
322  int *got_frame, AVPacket *avpkt)
323 {
324  const uint8_t *buf = avpkt->data;
325  int buf_size = avpkt->size;
326  LibOpenJPEGContext *ctx = avctx->priv_data;
327  const AVPixFmtDescriptor *desc;
328  int width, height, ret;
329  int pixel_size = 0;
330  int ispacked = 0;
331  int i;
332  opj_image_t *image = NULL;
333  BufferReader reader = {0, avpkt->size, avpkt->data};
334  opj_codec_t *dec = NULL;
335  opj_stream_t *stream = NULL;
336 
337  *got_frame = 0;
338 
339  // Check if input is a raw jpeg2k codestream or in jp2 wrapping
340  if ((AV_RB32(buf) == 12) &&
341  (AV_RB32(buf + 4) == JP2_SIG_TYPE) &&
342  (AV_RB32(buf + 8) == JP2_SIG_VALUE)) {
343  dec = opj_create_decompress(OPJ_CODEC_JP2);
344  } else {
345  /* If the AVPacket contains a jp2c box, then skip to
346  * the starting byte of the codestream. */
347  if (AV_RB32(buf + 4) == AV_RB32("jp2c"))
348  buf += 8;
349  dec = opj_create_decompress(OPJ_CODEC_J2K);
350  }
351 
352  if (!dec) {
353  av_log(avctx, AV_LOG_ERROR, "Error initializing decoder.\n");
355  goto done;
356  }
357 
358  if (!opj_set_error_handler(dec, error_callback, avctx) ||
359  !opj_set_warning_handler(dec, warning_callback, avctx) ||
360  !opj_set_info_handler(dec, info_callback, avctx)) {
361  av_log(avctx, AV_LOG_ERROR, "Error setting decoder handlers.\n");
363  goto done;
364  }
365 
366  ctx->dec_params.cp_layer = ctx->lowqual;
367  ctx->dec_params.cp_reduce = avctx->lowres;
368 
369  // Tie decoder with decoding parameters
370  opj_setup_decoder(dec, &ctx->dec_params);
371 
372  stream = opj_stream_default_create(OPJ_STREAM_READ);
373 
374  if (!stream) {
375  av_log(avctx, AV_LOG_ERROR,
376  "Codestream could not be opened for reading.\n");
378  goto done;
379  }
380 
381  opj_stream_set_read_function(stream, stream_read);
382  opj_stream_set_skip_function(stream, stream_skip);
383  opj_stream_set_seek_function(stream, stream_seek);
384  opj_stream_set_user_data(stream, &reader, NULL);
385  opj_stream_set_user_data_length(stream, avpkt->size);
386  // Decode the header only.
387  ret = !opj_read_header(stream, dec, &image);
388 
389  if (ret) {
390  av_log(avctx, AV_LOG_ERROR, "Error decoding codestream header.\n");
392  goto done;
393  }
394 
395  width = image->x1 - image->x0;
396  height = image->y1 - image->y0;
397 
398  ret = ff_set_dimensions(avctx, width, height);
399  if (ret < 0)
400  goto done;
401 
402  if (avctx->pix_fmt != AV_PIX_FMT_NONE)
403  if (!libopenjpeg_matches_pix_fmt(image, avctx->pix_fmt))
404  avctx->pix_fmt = AV_PIX_FMT_NONE;
405 
406  if (avctx->pix_fmt == AV_PIX_FMT_NONE)
407  avctx->pix_fmt = libopenjpeg_guess_pix_fmt(image);
408 
409  if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
410  av_log(avctx, AV_LOG_ERROR, "Unable to determine pixel format.\n");
412  goto done;
413  }
414  for (i = 0; i < image->numcomps; i++)
415  if (image->comps[i].prec > avctx->bits_per_raw_sample)
416  avctx->bits_per_raw_sample = image->comps[i].prec;
417 
418  if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
419  goto done;
420 
421  ret = !opj_decode(dec, stream, image);
422 
423  if (ret) {
424  av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
426  goto done;
427  }
428 
429  for (i = 0; i < image->numcomps; i++) {
430  if (!image->comps[i].data) {
431  av_log(avctx, AV_LOG_ERROR,
432  "Image component %d contains no data.\n", i);
434  goto done;
435  }
436  }
437 
438  desc = av_pix_fmt_desc_get(avctx->pix_fmt);
439  pixel_size = desc->comp[0].step;
440  ispacked = libopenjpeg_ispacked(avctx->pix_fmt);
441 
442  switch (pixel_size) {
443  case 1:
444  if (ispacked) {
445  libopenjpeg_copy_to_packed8(picture, image);
446  } else {
447  libopenjpeg_copyto8(picture, image);
448  }
449  break;
450  case 2:
451  if (ispacked) {
452  libopenjpeg_copy_to_packed8(picture, image);
453  } else {
454  libopenjpeg_copyto16(picture, image);
455  }
456  break;
457  case 3:
458  case 4:
459  if (ispacked) {
460  libopenjpeg_copy_to_packed8(picture, image);
461  }
462  break;
463  case 6:
464  case 8:
465  if (ispacked) {
466  libopenjpeg_copy_to_packed16(picture, image);
467  }
468  break;
469  default:
470  avpriv_report_missing_feature(avctx, "Pixel size %d", pixel_size);
472  goto done;
473  }
474 
475  *got_frame = 1;
476  picture->pict_type = AV_PICTURE_TYPE_I;
477  picture->key_frame = 1;
478  ret = buf_size;
479 
480 done:
481  opj_image_destroy(image);
482  opj_stream_destroy(stream);
483  opj_destroy_codec(dec);
484  return ret;
485 }
486 
487 #define OFFSET(x) offsetof(LibOpenJPEGContext, x)
488 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
489 
490 static const AVOption options[] = {
491  { "lowqual", "Limit the number of layers used for decoding",
492  OFFSET(lowqual), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VD },
493  { NULL },
494 };
495 
496 static const AVClass openjpeg_class = {
497  .class_name = "libopenjpeg",
498  .item_name = av_default_item_name,
499  .option = options,
500  .version = LIBAVUTIL_VERSION_INT,
501 };
502 
504  .p.name = "libopenjpeg",
505  CODEC_LONG_NAME("OpenJPEG JPEG 2000"),
506  .p.type = AVMEDIA_TYPE_VIDEO,
507  .p.id = AV_CODEC_ID_JPEG2000,
508  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
509  .p.max_lowres = 31,
510  .p.priv_class = &openjpeg_class,
511  .p.wrapper_name = "libopenjpeg",
512  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
513  .priv_data_size = sizeof(LibOpenJPEGContext),
516 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
opt.h
libopenjpeg_copy_to_packed8
static void libopenjpeg_copy_to_packed8(AVFrame *picture, opj_image_t *image)
Definition: libopenjpegdec.c:242
BufferReader::size
int size
Definition: libopenjpegdec.c:102
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2888
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
AVFrame::width
int width
Definition: frame.h:402
AVPacket::data
uint8_t * data
Definition: packet.h:374
AVOption
AVOption.
Definition: opt.h:251
libopenjpeg_yuv_pix_fmts
static enum AVPixelFormat libopenjpeg_yuv_pix_fmts[]
Definition: libopenjpegdec.c:72
BufferReader::buffer
const uint8_t * buffer
Definition: libopenjpegdec.c:103
data
const char data[16]
Definition: mxf.c:146
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:34
FFCodec
Definition: codec_internal.h:127
libopenjpeg_gray_pix_fmts
static enum AVPixelFormat libopenjpeg_gray_pix_fmts[]
Definition: libopenjpegdec.c:69
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:91
thread.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:351
XYZ_PIXEL_FORMATS
#define XYZ_PIXEL_FORMATS
Definition: libopenjpegdec.c:64
libopenjpeg_decode_init
static av_cold int libopenjpeg_decode_init(AVCodecContext *avctx)
Definition: libopenjpegdec.c:313
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
options
static const AVOption options[]
Definition: libopenjpegdec.c:490
ff_thread_get_buffer
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames. The frames must then be freed with ff_thread_release_buffer(). Otherwise decode directly into the user-supplied frames. Call ff_thread_report_progress() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
AVFrame::key_frame
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:422
warning_callback
static void warning_callback(const char *msg, void *data)
Definition: libopenjpegdec.c:90
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:443
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
width
#define width
stream_skip
static OPJ_OFF_T stream_skip(OPJ_OFF_T nb_bytes, void *user_data)
Definition: libopenjpegdec.c:123
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
intreadwrite.h
libopenjpeg_rgb_pix_fmts
static enum AVPixelFormat libopenjpeg_rgb_pix_fmts[]
Definition: libopenjpegdec.c:66
VD
#define VD
Definition: libopenjpegdec.c:488
adjust
static int adjust(int x, int size)
Definition: mobiclip.c:515
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1487
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
decode.h
libopenjpeg_ispacked
static int libopenjpeg_ispacked(enum AVPixelFormat pix_fmt)
Definition: libopenjpegdec.c:227
GRAY_PIXEL_FORMATS
#define GRAY_PIXEL_FORMATS
Definition: libopenjpegdec.c:48
info_callback
static void info_callback(const char *msg, void *data)
Definition: libopenjpegdec.c:95
RGB_PIXEL_FORMATS
#define RGB_PIXEL_FORMATS
Definition: libopenjpegdec.c:45
libopenjpeg_all_pix_fmts
static enum AVPixelFormat libopenjpeg_all_pix_fmts[]
Definition: libopenjpegdec.c:75
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:107
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
LibOpenJPEGContext::lowqual
int lowqual
Definition: libopenjpegdec.c:82
index
int index
Definition: gxfenc.c:89
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
LibOpenJPEGContext
Definition: libopenjpegdec.c:79
AVCodecContext::lowres
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
Definition: avcodec.h:1494
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:427
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:375
openjpeg_class
static const AVClass openjpeg_class
Definition: libopenjpegdec.c:496
codec_internal.h
stream_read
static OPJ_SIZE_T stream_read(void *out_buffer, OPJ_SIZE_T nb_bytes, void *user_data)
Definition: libopenjpegdec.c:106
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
avpriv_report_missing_feature
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
libopenjpeg_copy_to_packed16
static void libopenjpeg_copy_to_packed16(AVFrame *picture, opj_image_t *image)
Definition: libopenjpegdec.c:254
user_data
static int FUNC() user_data(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawUserData *current)
Definition: cbs_mpeg2_syntax_template.c:59
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:417
height
#define height
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
libopenjpeg_copyto8
static void libopenjpeg_copyto8(AVFrame *picture, opj_image_t *image)
Definition: libopenjpegdec.c:272
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
LibOpenJPEGContext::dec_params
opj_dparameters_t dec_params
Definition: libopenjpegdec.c:81
libopenjpeg_guess_pix_fmt
static enum AVPixelFormat libopenjpeg_guess_pix_fmt(const opj_image_t *image)
Definition: libopenjpegdec.c:195
common.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:191
AV_CODEC_ID_JPEG2000
@ AV_CODEC_ID_JPEG2000
Definition: codec_id.h:140
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:635
avcodec.h
ret
ret
Definition: filter_design.txt:187
pixfmt.h
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
BufferReader::pos
int pos
Definition: libopenjpegdec.c:101
AVCodecContext
main external API structure.
Definition: avcodec.h:426
AVFrame::height
int height
Definition: frame.h:402
JP2_SIG_TYPE
#define JP2_SIG_TYPE
Definition: libopenjpegdec.c:40
libopenjpeg_matches_pix_fmt
static int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVPixelFormat pix_fmt)
Definition: libopenjpegdec.c:158
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
ff_libopenjpeg_decoder
const FFCodec ff_libopenjpeg_decoder
Definition: libopenjpegdec.c:503
error_callback
static void error_callback(const char *msg, void *data)
Definition: libopenjpegdec.c:85
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AVPacket
This structure stores compressed data.
Definition: packet.h:351
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:453
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:375
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
BufferReader
Definition: libopenjpegdec.c:100
stream_seek
static OPJ_BOOL stream_seek(OPJ_OFF_T nb_bytes, void *user_data)
Definition: libopenjpegdec.c:148
OFFSET
#define OFFSET(x)
Definition: libopenjpegdec.c:487
int
int
Definition: ffmpeg_filter.c:156
YUV_PIXEL_FORMATS
#define YUV_PIXEL_FORMATS
Definition: libopenjpegdec.c:52
libopenjpeg_decode_frame
static int libopenjpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
Definition: libopenjpegdec.c:321
libopenjpeg_copyto16
static void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image)
Definition: libopenjpegdec.c:290
JP2_SIG_VALUE
#define JP2_SIG_VALUE
Definition: libopenjpegdec.c:41