FFmpeg
libjxldec.c
Go to the documentation of this file.
1 /*
2  * JPEG XL decoding support via libjxl
3  * Copyright (c) 2021 Leo Izen <leo.izen@gmail.com>
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 XL decoder using libjxl
25  */
26 
27 #include "libavutil/avassert.h"
28 #include "libavutil/buffer.h"
29 #include "libavutil/common.h"
30 #include "libavutil/csp.h"
31 #include "libavutil/error.h"
32 #include "libavutil/intreadwrite.h"
33 #include "libavutil/mem.h"
34 #include "libavutil/pixdesc.h"
35 #include "libavutil/pixfmt.h"
36 #include "libavutil/frame.h"
37 
38 #include "avcodec.h"
39 #include "codec_internal.h"
40 #include "decode.h"
41 #include "exif_internal.h"
42 #include "internal.h"
43 
44 #include <jxl/decode.h>
45 #include <jxl/thread_parallel_runner.h>
46 #include "libjxl.h"
47 
48 typedef struct LibJxlDecodeContext {
49  void *runner;
50  JxlDecoder *decoder;
51  JxlBasicInfo basic_info;
52  JxlPixelFormat jxl_pixfmt;
53 #if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0)
54  JxlBitDepth jxl_bit_depth;
55 #endif
56  JxlDecoderStatus events;
65  size_t exif_pos;
67 
69 {
71 
72  ctx->events = JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE
73  | JXL_DEC_COLOR_ENCODING | JXL_DEC_FRAME
74  | JXL_DEC_BOX | JXL_DEC_BOX_COMPLETE;
75  if (JxlDecoderSubscribeEvents(ctx->decoder, ctx->events) != JXL_DEC_SUCCESS) {
76  av_log(avctx, AV_LOG_ERROR, "Error subscribing to JXL events\n");
77  return AVERROR_EXTERNAL;
78  }
79 
80  if (JxlDecoderSetDecompressBoxes(ctx->decoder, JXL_TRUE) != JXL_DEC_SUCCESS) {
81  av_log(avctx, AV_LOG_ERROR, "Error setting compress box mode\n");
82  return AVERROR_EXTERNAL;
83  }
84 
85  if (JxlDecoderSetParallelRunner(ctx->decoder, JxlThreadParallelRunner, ctx->runner) != JXL_DEC_SUCCESS) {
86  av_log(avctx, AV_LOG_ERROR, "Failed to set JxlThreadParallelRunner\n");
87  return AVERROR_EXTERNAL;
88  }
89 
90  av_buffer_unref(&ctx->exif);
91  memset(&ctx->basic_info, 0, sizeof(JxlBasicInfo));
92  memset(&ctx->jxl_pixfmt, 0, sizeof(JxlPixelFormat));
93  ctx->prev_is_last = 1;
94 
95  return 0;
96 }
97 
99 {
101  JxlMemoryManager manager;
102 
104  ctx->decoder = JxlDecoderCreate(&manager);
105  if (!ctx->decoder) {
106  av_log(avctx, AV_LOG_ERROR, "Failed to create JxlDecoder\n");
107  return AVERROR_EXTERNAL;
108  }
109 
110  ctx->runner = JxlThreadParallelRunnerCreate(&manager, ff_libjxl_get_threadcount(avctx->thread_count));
111  if (!ctx->runner) {
112  av_log(avctx, AV_LOG_ERROR, "Failed to create JxlThreadParallelRunner\n");
113  return AVERROR_EXTERNAL;
114  }
115 
116  ctx->avpkt = avctx->internal->in_pkt;
117  ctx->frame = av_frame_alloc();
118  if (!ctx->frame)
119  return AVERROR(ENOMEM);
120 
121  return libjxl_init_jxl_decoder(avctx);
122 }
123 
125 {
126  const JxlBasicInfo *basic_info = &ctx->basic_info;
127  JxlPixelFormat *format = &ctx->jxl_pixfmt;
128  format->endianness = JXL_NATIVE_ENDIAN;
129  format->num_channels = basic_info->num_color_channels + (basic_info->alpha_bits > 0);
130 #if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0)
131  ctx->jxl_bit_depth.bits_per_sample = avctx->bits_per_raw_sample = basic_info->bits_per_sample;
132  ctx->jxl_bit_depth.type = JXL_BIT_DEPTH_FROM_PIXEL_FORMAT;
133  ctx->jxl_bit_depth.exponent_bits_per_sample = basic_info->exponent_bits_per_sample;
134 #endif
135  /* Gray */
136  if (basic_info->num_color_channels == 1) {
137  if (basic_info->bits_per_sample <= 8) {
138  format->data_type = JXL_TYPE_UINT8;
139  return basic_info->alpha_bits ? AV_PIX_FMT_YA8 : AV_PIX_FMT_GRAY8;
140  }
141  if (basic_info->exponent_bits_per_sample || basic_info->bits_per_sample > 16) {
142  if (!basic_info->alpha_bits) {
143  format->data_type = JXL_TYPE_FLOAT;
144  return AV_PIX_FMT_GRAYF32;
145  }
146  av_log(avctx, AV_LOG_WARNING, "Downsampling gray+alpha float to 16-bit integer via libjxl\n");
147  }
148  format->data_type = JXL_TYPE_UINT16;
149  return basic_info->alpha_bits ? AV_PIX_FMT_YA16 : AV_PIX_FMT_GRAY16;
150  }
151  /* rgb only */
152  /* libjxl only supports packed RGB and gray output at the moment */
153  if (basic_info->num_color_channels == 3) {
154  if (basic_info->bits_per_sample <= 8) {
155  format->data_type = JXL_TYPE_UINT8;
156  return basic_info->alpha_bits ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24;
157  }
158  if (basic_info->exponent_bits_per_sample || basic_info->bits_per_sample > 16) {
159  format->data_type = JXL_TYPE_FLOAT;
160  return basic_info->alpha_bits ? AV_PIX_FMT_RGBAF32 : AV_PIX_FMT_RGBF32;
161  }
162  format->data_type = JXL_TYPE_UINT16;
163  return basic_info->alpha_bits ? AV_PIX_FMT_RGBA64 : AV_PIX_FMT_RGB48;
164  }
165 
166  return AV_PIX_FMT_NONE;
167 }
168 
169 static enum AVColorPrimaries libjxl_get_primaries(void *avctx, const JxlColorEncoding *jxl_color)
170 {
172  enum AVColorPrimaries prim;
173 
174  /* libjxl populates these double values even if it uses an enum space */
175  desc.prim.r.x = av_d2q(jxl_color->primaries_red_xy[0], 300000);
176  desc.prim.r.y = av_d2q(jxl_color->primaries_red_xy[1], 300000);
177  desc.prim.g.x = av_d2q(jxl_color->primaries_green_xy[0], 300000);
178  desc.prim.g.y = av_d2q(jxl_color->primaries_green_xy[1], 300000);
179  desc.prim.b.x = av_d2q(jxl_color->primaries_blue_xy[0], 300000);
180  desc.prim.b.y = av_d2q(jxl_color->primaries_blue_xy[1], 300000);
181  desc.wp.x = av_d2q(jxl_color->white_point_xy[0], 300000);
182  desc.wp.y = av_d2q(jxl_color->white_point_xy[1], 300000);
183 
185  if (prim == AVCOL_PRI_UNSPECIFIED) {
186  /* try D65 with the same primaries */
187  /* BT.709 uses D65 white point */
189  av_log(avctx, AV_LOG_WARNING, "Changing unknown white point to D65\n");
191  }
192 
193  return prim;
194 }
195 
196 static enum AVColorTransferCharacteristic libjxl_get_trc(void *avctx, const JxlColorEncoding *jxl_color)
197 {
198  switch (jxl_color->transfer_function) {
199  case JXL_TRANSFER_FUNCTION_709: return AVCOL_TRC_BT709;
200  case JXL_TRANSFER_FUNCTION_LINEAR: return AVCOL_TRC_LINEAR;
201  case JXL_TRANSFER_FUNCTION_SRGB: return AVCOL_TRC_IEC61966_2_1;
202  case JXL_TRANSFER_FUNCTION_PQ: return AVCOL_TRC_SMPTE2084;
203  case JXL_TRANSFER_FUNCTION_DCI: return AVCOL_TRC_SMPTE428;
204  case JXL_TRANSFER_FUNCTION_HLG: return AVCOL_TRC_ARIB_STD_B67;
205  case JXL_TRANSFER_FUNCTION_GAMMA:
206  if (jxl_color->gamma > 0.45355 && jxl_color->gamma < 0.45555)
207  return AVCOL_TRC_GAMMA22;
208  else if (jxl_color->gamma > 0.35614 && jxl_color->gamma < 0.35814)
209  return AVCOL_TRC_GAMMA28;
210  else
211  av_log(avctx, AV_LOG_WARNING, "Unsupported gamma transfer: %f\n", jxl_color->gamma);
212  break;
213  default:
214  av_log(avctx, AV_LOG_WARNING, "Unknown transfer function: %d\n", jxl_color->transfer_function);
215  }
216 
217  return AVCOL_TRC_UNSPECIFIED;
218 }
219 
220 static int libjxl_get_icc(AVCodecContext *avctx)
221 {
223  size_t icc_len;
224  JxlDecoderStatus jret;
225  /* an ICC profile is present, and we can meaningfully get it,
226  * because the pixel data is not XYB-encoded */
227 #if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
228  jret = JxlDecoderGetICCProfileSize(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, &icc_len);
229 #else
230  jret = JxlDecoderGetICCProfileSize(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, &icc_len);
231 #endif
232  if (jret == JXL_DEC_SUCCESS && icc_len > 0) {
233  av_buffer_unref(&ctx->iccp);
234  ctx->iccp = av_buffer_alloc(icc_len);
235  if (!ctx->iccp)
236  return AVERROR(ENOMEM);
237 #if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
238  jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA,
239  ctx->iccp->data, icc_len);
240 #else
241  jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, ctx->iccp->data, icc_len);
242 #endif
243  if (jret != JXL_DEC_SUCCESS) {
244  av_log(avctx, AV_LOG_WARNING, "Unable to obtain ICC Profile\n");
245  av_buffer_unref(&ctx->iccp);
246  }
247  }
248 
249  return 0;
250 }
251 
252 /*
253  * There's generally four cases when it comes to decoding a libjxl image
254  * with regard to color encoding:
255  * (a) There is an embedded ICC profile in the image, and the image is XYB-encoded.
256  * (b) There is an embedded ICC profile in the image, and the image is not XYB-encoded.
257  * (c) There is no embedded ICC profile, and FFmpeg supports the tagged colorspace.
258  * (d) There is no embedded ICC profile, and FFmpeg does not support the tagged colorspace.
259  *
260  * In case (b), we forward the pixel data as is and forward the ICC Profile as-is.
261  * In case (c), we request the pixel data in the space it's tagged as,
262  * and tag the space accordingly.
263  * In case (a), libjxl does not support getting the pixel data in the space described by the ICC
264  * profile, so instead we request the pixel data in BT.2020/PQ as it is the widest
265  * space that FFmpeg supports.
266  * In case (d), we also request wide-gamut pixel data as a fallback since FFmpeg doesn't support
267  * the custom primaries tagged in the space.
268  */
270 {
272  JxlDecoderStatus jret;
273  int ret;
274  JxlColorEncoding jxl_color;
275  /* set this flag if we need to fall back on wide gamut */
276  int fallback = 0;
277 
278 #if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
279  jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, NULL, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color);
280 #else
281  jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color);
282 #endif
283  if (jret == JXL_DEC_SUCCESS) {
284  /* enum values describe the colors of this image */
285  jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color);
286  if (jret == JXL_DEC_SUCCESS)
287 #if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
288  jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, &ctx->jxl_pixfmt,
289  JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
290 #else
291  jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
292 #endif
293  /* if we couldn't successfully request the pixel data space, we fall back on wide gamut */
294  /* this code path is very unlikely to happen in practice */
295  if (jret != JXL_DEC_SUCCESS)
296  fallback = 1;
297  } else {
298  /* an ICC Profile is present in the stream */
299  if (ctx->basic_info.uses_original_profile) {
300  /* uses_original_profile is the same as !xyb_encoded */
301  av_log(avctx, AV_LOG_VERBOSE, "Using embedded ICC Profile\n");
302  if ((ret = libjxl_get_icc(avctx)) < 0)
303  return ret;
304  } else {
305  /*
306  * an XYB-encoded image with an embedded ICC profile can't always have the
307  * pixel data requested in the original space, so libjxl has no feature
308  * to allow this to happen, so we fall back on wide gamut
309  */
310  fallback = 1;
311  }
312  }
313 
314  avctx->color_range = frame->color_range = AVCOL_RANGE_JPEG;
315  if (ctx->basic_info.num_color_channels > 1)
316  avctx->colorspace = AVCOL_SPC_RGB;
319 
320  if (!ctx->iccp) {
321  /* checking enum values */
322  if (!fallback) {
323  if (avctx->colorspace == AVCOL_SPC_RGB)
324  avctx->color_primaries = libjxl_get_primaries(avctx, &jxl_color);
325  avctx->color_trc = libjxl_get_trc(avctx, &jxl_color);
326  }
327  /* fall back on wide gamut if enum values fail */
328  if (avctx->color_primaries == AVCOL_PRI_UNSPECIFIED) {
329  if (avctx->colorspace == AVCOL_SPC_RGB) {
330  av_log(avctx, AV_LOG_WARNING, "Falling back on wide gamut output\n");
331  jxl_color.primaries = JXL_PRIMARIES_2100;
333  }
334  /* libjxl requires this set even for grayscale */
335  jxl_color.white_point = JXL_WHITE_POINT_D65;
336  }
337  if (avctx->color_trc == AVCOL_TRC_UNSPECIFIED) {
338  if (ctx->jxl_pixfmt.data_type == JXL_TYPE_FLOAT
339  || ctx->jxl_pixfmt.data_type == JXL_TYPE_FLOAT16) {
340  av_log(avctx, AV_LOG_WARNING, "Falling back on Linear Light transfer\n");
341  jxl_color.transfer_function = JXL_TRANSFER_FUNCTION_LINEAR;
342  avctx->color_trc = AVCOL_TRC_LINEAR;
343  } else {
344  av_log(avctx, AV_LOG_WARNING, "Falling back on iec61966-2-1/sRGB transfer\n");
345  jxl_color.transfer_function = JXL_TRANSFER_FUNCTION_SRGB;
347  }
348  }
349  /* all colors will be in-gamut so we want accurate colors */
350  jxl_color.rendering_intent = JXL_RENDERING_INTENT_RELATIVE;
351  jxl_color.color_space = ctx->basic_info.num_color_channels > 1 ? JXL_COLOR_SPACE_RGB : JXL_COLOR_SPACE_GRAY;
352  jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color);
353  if (jret != JXL_DEC_SUCCESS) {
354  av_log(avctx, AV_LOG_WARNING, "Unable to set fallback color encoding\n");
355  /*
356  * This should only happen if there's a non-XYB encoded image with custom primaries
357  * embedded as enums and no embedded ICC Profile.
358  * In this case, libjxl will synthesize an ICC Profile for us.
359  */
362  if ((ret = libjxl_get_icc(avctx)) < 0)
363  return ret;
364  }
365  }
366 
367  frame->color_trc = avctx->color_trc;
368  frame->color_primaries = avctx->color_primaries;
369  frame->colorspace = avctx->colorspace;
370 
371  return 0;
372 }
373 
375 {
377  JxlDecoderStatus jret = JXL_DEC_SUCCESS;
378  int ret;
379  AVPacket *pkt = ctx->avpkt;
380 
381  while (1) {
382  size_t remaining;
383  JxlFrameHeader header;
384 
385  if (!pkt->size) {
387  ret = ff_decode_get_packet(avctx, pkt);
388  if (ret < 0 && ret != AVERROR_EOF)
389  return ret;
390  ctx->accumulated_pts = 0;
391  ctx->frame_duration = 0;
392  if (!pkt->size) {
393  /* jret set by the last iteration of the loop */
394  if (jret == JXL_DEC_NEED_MORE_INPUT) {
395  av_log(avctx, AV_LOG_ERROR, "Unexpected end of JXL codestream\n");
396  return AVERROR_INVALIDDATA;
397  } else {
398  return AVERROR_EOF;
399  }
400  }
401  }
402 
403  jret = JxlDecoderSetInput(ctx->decoder, pkt->data, pkt->size);
404  if (jret == JXL_DEC_ERROR) {
405  /* this should never happen here unless there's a bug in libjxl */
406  av_log(avctx, AV_LOG_ERROR, "Unknown libjxl decode error\n");
407  return AVERROR_EXTERNAL;
408  }
409 
410  jret = JxlDecoderProcessInput(ctx->decoder);
411  /*
412  * JxlDecoderReleaseInput returns the number
413  * of bytes remaining to be read, rather than
414  * the number of bytes that it did read
415  */
416  remaining = JxlDecoderReleaseInput(ctx->decoder);
417  pkt->data += pkt->size - remaining;
418  pkt->size = remaining;
419 
420  switch(jret) {
421  case JXL_DEC_ERROR:
422  av_log(avctx, AV_LOG_ERROR, "Unknown libjxl decode error\n");
423  return AVERROR_INVALIDDATA;
424  case JXL_DEC_NEED_MORE_INPUT:
425  av_log(avctx, AV_LOG_DEBUG, "NEED_MORE_INPUT event emitted\n");
426  continue;
427  case JXL_DEC_BASIC_INFO:
428  av_log(avctx, AV_LOG_DEBUG, "BASIC_INFO event emitted\n");
429  if (JxlDecoderGetBasicInfo(ctx->decoder, &ctx->basic_info) != JXL_DEC_SUCCESS) {
430  /*
431  * this should never happen
432  * if it does it is likely a libjxl decoder bug
433  */
434  av_log(avctx, AV_LOG_ERROR, "Bad libjxl basic info event\n");
435  return AVERROR_EXTERNAL;
436  }
437  avctx->pix_fmt = libjxl_get_pix_fmt(avctx, ctx);
438  if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
439  av_log(avctx, AV_LOG_ERROR, "Bad libjxl pixel format\n");
440  return AVERROR_EXTERNAL;
441  }
442  if ((ret = ff_set_dimensions(avctx, ctx->basic_info.xsize, ctx->basic_info.ysize)) < 0)
443  return ret;
444  if (ctx->basic_info.have_animation)
445  ctx->anim_timebase = av_make_q(ctx->basic_info.animation.tps_denominator,
446  ctx->basic_info.animation.tps_numerator);
447  continue;
448  case JXL_DEC_COLOR_ENCODING:
449  av_log(avctx, AV_LOG_DEBUG, "COLOR_ENCODING event emitted\n");
450  ret = libjxl_color_encoding_event(avctx, ctx->frame);
451  if (ret < 0)
452  return ret;
453  continue;
454  case JXL_DEC_NEED_IMAGE_OUT_BUFFER:
455  av_log(avctx, AV_LOG_DEBUG, "NEED_IMAGE_OUT_BUFFER event emitted\n");
456  ret = ff_get_buffer(avctx, ctx->frame, 0);
457  if (ret < 0)
458  return ret;
459  ctx->jxl_pixfmt.align = ctx->frame->linesize[0];
460  if (JxlDecoderSetImageOutBuffer(ctx->decoder, &ctx->jxl_pixfmt,
461  ctx->frame->data[0], ctx->frame->buf[0]->size)
462  != JXL_DEC_SUCCESS) {
463  av_log(avctx, AV_LOG_ERROR, "Bad libjxl dec need image out buffer event\n");
464  return AVERROR_EXTERNAL;
465  }
466 #if JPEGXL_NUMERIC_VERSION >= JPEGXL_COMPUTE_NUMERIC_VERSION(0, 8, 0)
467  if (JxlDecoderSetImageOutBitDepth(ctx->decoder, &ctx->jxl_bit_depth) != JXL_DEC_SUCCESS) {
468  av_log(avctx, AV_LOG_ERROR, "Error setting output bit depth\n");
469  return AVERROR_EXTERNAL;
470  }
471 #endif
472  continue;
473  case JXL_DEC_FRAME:
474  /* Frame here refers to the Frame bundle, not a decoded picture */
475  av_log(avctx, AV_LOG_DEBUG, "FRAME event emitted\n");
476  if (ctx->prev_is_last) {
477  /*
478  * The last frame sent was tagged as "is_last" which
479  * means this is a new image file altogether.
480  */
481  ctx->frame->pict_type = AV_PICTURE_TYPE_I;
482  ctx->frame->flags |= AV_FRAME_FLAG_KEY;
483  }
484  if (JxlDecoderGetFrameHeader(ctx->decoder, &header) != JXL_DEC_SUCCESS) {
485  av_log(avctx, AV_LOG_ERROR, "Bad libjxl dec frame event\n");
486  return AVERROR_EXTERNAL;
487  }
488  ctx->prev_is_last = header.is_last;
489  /* zero duration for animation means the frame is not presented */
490  if (ctx->basic_info.have_animation && header.duration)
491  ctx->frame_duration = header.duration;
492  continue;
493  case JXL_DEC_FULL_IMAGE:
494  /* full image is one frame, even if animated */
495  av_log(avctx, AV_LOG_DEBUG, "FULL_IMAGE event emitted\n");
496  if (ctx->iccp) {
498  if (ret < 0)
499  return ret;
500  }
501  if (ctx->exif) {
502  AVExifMetadata ifd = { 0 };
503  /* size may be larger than exif_pos due to the realloc loop */
504  ret = av_exif_parse_buffer(avctx, ctx->exif->data, ctx->exif_pos, &ifd, AV_EXIF_T_OFF);
505  av_buffer_unref(&ctx->exif);
506  if (ret < 0) {
507  av_log(avctx, AV_LOG_ERROR, "Unable to parse EXIF buffer\n");
508  continue;
509  }
510  /*
511  * JPEG XL Codestream orientation overrides EXIF orientation in all cases.
512  * As a result, we remove the EXIF Orientation tag rather than just zeroing it
513  * in order to prevent any ambiguity. libjxl autorotates the image for us so we
514  * do not need to worry about that.
515  */
516  ret = av_exif_remove_entry(avctx, &ifd, av_exif_get_tag_id("Orientation"), 0);
517  if (ret < 0)
518  av_log(avctx, AV_LOG_WARNING, "Unable to remove orientation from EXIF buffer\n");
519  ret = ff_decode_exif_attach_ifd(avctx, ctx->frame, &ifd);
520  if (ret < 0)
521  av_log(avctx, AV_LOG_ERROR, "Unable to attach EXIF ifd\n");
522  av_exif_free(&ifd);
523  }
524  if (ctx->basic_info.have_animation) {
525  ctx->frame->pts = av_rescale_q(ctx->accumulated_pts, ctx->anim_timebase, avctx->pkt_timebase);
526  ctx->frame->duration = av_rescale_q(ctx->frame_duration, ctx->anim_timebase, avctx->pkt_timebase);
527  } else {
528  ctx->frame->pts = 0;
529  ctx->frame->duration = pkt->duration;
530  }
531  if (pkt->pts != AV_NOPTS_VALUE)
532  ctx->frame->pts += pkt->pts;
533  ctx->accumulated_pts += ctx->frame_duration;
534  ctx->frame->pkt_dts = pkt->dts;
535  av_frame_move_ref(frame, ctx->frame);
536  return 0;
537  case JXL_DEC_SUCCESS:
538  av_log(avctx, AV_LOG_DEBUG, "SUCCESS event emitted\n");
539  /*
540  * this event will be fired when the zero-length EOF
541  * packet is sent to the decoder by the client,
542  * but it will also be fired when the next image of
543  * an image2pipe sequence is loaded up
544  */
545  JxlDecoderReset(ctx->decoder);
547  continue;
548  case JXL_DEC_BOX: {
549  char type[4];
550  av_log(avctx, AV_LOG_DEBUG, "BOX event emitted\n");
551  if (JxlDecoderGetBoxType(ctx->decoder, type, JXL_TRUE) != JXL_DEC_SUCCESS) {
552  av_log(avctx, AV_LOG_ERROR, "Error getting box type\n");
553  return AVERROR_EXTERNAL;
554  }
555  if (AV_RL32(type) != MKTAG('E','x','i','f'))
556  continue;
557  av_buffer_unref(&ctx->exif);
558  ctx->exif_pos = 0;
559  // 4k buffer should usually be enough
560  ret = av_buffer_realloc(&ctx->exif, 4096);
561  if (ret < 0)
562  return AVERROR(ENOMEM);
563  if (JxlDecoderSetBoxBuffer(ctx->decoder, ctx->exif->data, ctx->exif->size) != JXL_DEC_SUCCESS) {
564  av_log(avctx, AV_LOG_ERROR, "Error setting box buffer\n");
565  return AVERROR_EXTERNAL;
566  }
567  continue;
568  }
569  case JXL_DEC_BOX_NEED_MORE_OUTPUT: {
570  av_log(avctx, AV_LOG_DEBUG, "BOX_NEED_MORE_OUTPUT event emitted\n");
571  size_t remainder = JxlDecoderReleaseBoxBuffer(ctx->decoder);
572  ctx->exif_pos = ctx->exif->size - remainder;
573  size_t new_size = ctx->exif->size << 1;
574  ret = av_buffer_realloc(&ctx->exif, new_size);
575  if (ret < 0)
576  return AVERROR(ENOMEM);
577  if (JxlDecoderSetBoxBuffer(ctx->decoder, ctx->exif->data + ctx->exif_pos,
578  ctx->exif->size - ctx->exif_pos) != JXL_DEC_SUCCESS) {
579  av_log(avctx, AV_LOG_ERROR, "Error setting box buffer\n");
580  return AVERROR_EXTERNAL;
581  }
582  continue;
583  }
584  case JXL_DEC_BOX_COMPLETE: {
585  av_log(avctx, AV_LOG_DEBUG, "BOX_COMPLETE event emitted\n");
586  size_t remainder = JxlDecoderReleaseBoxBuffer(ctx->decoder);
587  ctx->exif_pos = ctx->exif->size - remainder;
588  continue;
589  }
590  default:
591  av_log(avctx, AV_LOG_ERROR, "Bad libjxl event: %d\n", jret);
592  return AVERROR_EXTERNAL;
593  }
594  }
595 }
596 
598 {
600 
601  if (ctx->runner)
602  JxlThreadParallelRunnerDestroy(ctx->runner);
603  ctx->runner = NULL;
604  if (ctx->decoder)
605  JxlDecoderDestroy(ctx->decoder);
606  ctx->decoder = NULL;
607  av_buffer_unref(&ctx->exif);
608  av_buffer_unref(&ctx->iccp);
609  av_frame_free(&ctx->frame);
610 
611  return 0;
612 }
613 
615  .p.name = "libjxl",
616  CODEC_LONG_NAME("libjxl JPEG XL"),
617  .p.type = AVMEDIA_TYPE_VIDEO,
618  .p.id = AV_CODEC_ID_JPEGXL,
619  .priv_data_size = sizeof(LibJxlDecodeContext),
622  .close = libjxl_decode_close,
623  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS,
624  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
627  .p.wrapper_name = "libjxl",
628 };
629 
631  .p.name = "libjxl_anim",
632  CODEC_LONG_NAME("libjxl JPEG XL animated"),
633  .p.type = AVMEDIA_TYPE_VIDEO,
634  .p.id = AV_CODEC_ID_JPEGXL_ANIM,
635  .priv_data_size = sizeof(LibJxlDecodeContext),
638  .close = libjxl_decode_close,
639  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS,
640  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
643  .p.wrapper_name = "libjxl",
644 };
AV_EXIF_T_OFF
@ AV_EXIF_T_OFF
The first four bytes point to the actual start, then it's AV_EXIF_TIFF_HEADER.
Definition: exif.h:69
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: packet.c:432
ff_decode_get_packet
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
Definition: decode.c:245
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
libjxl_init_jxl_decoder
static int libjxl_init_jxl_decoder(AVCodecContext *avctx)
Definition: libjxldec.c:68
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AV_CODEC_ID_JPEGXL_ANIM
@ AV_CODEC_ID_JPEGXL_ANIM
Definition: codec_id.h:331
ff_libjxl_get_threadcount
size_t ff_libjxl_get_threadcount(int threads)
Transform threadcount in ffmpeg to one used by libjxl.
Definition: libjxl.c:33
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AV_PIX_FMT_YA8
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:140
av_exif_parse_buffer
int av_exif_parse_buffer(void *logctx, const uint8_t *buf, size_t size, AVExifMetadata *ifd, enum AVExifHeaderMode header_mode)
Decodes the EXIF data provided in the buffer and writes it into the struct *ifd.
Definition: exif.c:757
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:659
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:661
AVColorPrimariesDesc::wp
AVWhitepointCoefficients wp
Definition: csp.h:79
AVExifMetadata
Definition: exif.h:76
AVColorPrimariesDesc
Struct that contains both white point location and primaries location, providing the complete descrip...
Definition: csp.h:78
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
LibJxlDecodeContext::decoder
JxlDecoder * decoder
Definition: libjxldec.c:50
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:670
int64_t
long long int64_t
Definition: coverity.c:34
LibJxlDecodeContext::avpkt
AVPacket * avpkt
Definition: libjxldec.c:58
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:63
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
pixdesc.h
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:652
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:767
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:552
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:664
libjxl_decode_init
static av_cold int libjxl_decode_init(AVCodecContext *avctx)
Definition: libjxldec.c:98
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
libjxl.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:691
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:570
LibJxlDecodeContext::exif
AVBufferRef * exif
Definition: libjxldec.c:64
LibJxlDecodeContext::accumulated_pts
int64_t accumulated_pts
Definition: libjxldec.c:59
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:636
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
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:675
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1561
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:667
libjxl_get_pix_fmt
static enum AVPixelFormat libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecodeContext *ctx)
Definition: libjxldec.c:124
av_exif_free
void av_exif_free(AVExifMetadata *ifd)
Frees all resources associated with the given EXIF metadata struct.
Definition: exif.c:602
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:522
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:666
ff_frame_new_side_data_from_buf
int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf)
Similar to ff_frame_new_side_data, but using an existing buffer ref.
Definition: decode.c:2068
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:51
avassert.h
LibJxlDecodeContext::events
JxlDecoderStatus events
Definition: libjxldec.c:56
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:645
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
av_cold
#define av_cold
Definition: attributes.h:90
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:642
intreadwrite.h
av_csp_primaries_desc_from_id
const AVColorPrimariesDesc * av_csp_primaries_desc_from_id(enum AVColorPrimaries prm)
Retrieves a complete gamut description from an enum constant describing the color primaries.
Definition: csp.c:90
AVFormatContext::flags
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1415
LibJxlDecodeContext::jxl_bit_depth
JxlBitDepth jxl_bit_depth
Definition: libjxldec.c:54
AV_CODEC_CAP_OTHER_THREADS
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition: codec.h:109
ff_libjxl_decoder
const FFCodec ff_libjxl_decoder
Definition: libjxldec.c:614
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1553
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
ctx
AVFormatContext * ctx
Definition: movenc.c:49
decode.h
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
av_csp_primaries_id_from_desc
enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm)
Detects which enum AVColorPrimaries constant corresponds to the given complete gamut description.
Definition: csp.c:110
libjxl_get_icc
static int libjxl_get_icc(AVCodecContext *avctx)
Definition: libjxldec.c:220
AV_PIX_FMT_RGBF32
#define AV_PIX_FMT_RGBF32
Definition: pixfmt.h:626
LibJxlDecodeContext::jxl_pixfmt
JxlPixelFormat jxl_pixfmt
Definition: libjxldec.c:52
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:582
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:639
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:326
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:529
av_exif_get_tag_id
int32_t av_exif_get_tag_id(const char *name)
Retrieves the tag ID associated with the provided tag string name.
Definition: exif.c:218
ff_decode_exif_attach_ifd
int ff_decode_exif_attach_ifd(AVCodecContext *avctx, AVFrame *frame, const AVExifMetadata *ifd)
Definition: decode.c:2331
NULL
#define NULL
Definition: coverity.c:32
exif_internal.h
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:669
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:466
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:638
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:278
AV_FRAME_DATA_ICC_PROFILE
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:144
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
av_exif_remove_entry
int av_exif_remove_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags)
Remove an entry from the provided EXIF metadata struct.
Definition: exif.c:1131
error.h
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:647
LibJxlDecodeContext::exif_pos
size_t exif_pos
Definition: libjxldec.c:65
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:678
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1636
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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:553
codec_internal.h
LibJxlDecodeContext::iccp
AVBufferRef * iccp
Definition: libjxldec.c:57
AVCodecContext::pkt_timebase
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
Definition: avcodec.h:542
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:525
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:247
frame.h
header
static const uint8_t header[24]
Definition: sdr2.c:68
buffer.h
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:551
csp.h
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
LibJxlDecodeContext::frame_duration
int64_t frame_duration
Definition: libjxldec.c:60
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
libjxl_get_primaries
static enum AVColorPrimaries libjxl_get_primaries(void *avctx, const JxlColorEncoding *jxl_color)
Definition: libjxldec.c:169
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:663
AV_PIX_FMT_YA16
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:524
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:545
common.h
AVCodecInternal::in_pkt
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
Definition: internal.h:83
LibJxlDecodeContext::anim_timebase
AVRational anim_timebase
Definition: libjxldec.c:62
AV_CODEC_ID_JPEGXL
@ AV_CODEC_ID_JPEGXL
Definition: codec_id.h:317
av_frame_move_ref
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:521
av_d2q
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Definition: rational.c:106
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:631
FF_CODEC_CAP_ICC_PROFILES
#define FF_CODEC_CAP_ICC_PROFILES
Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).
Definition: codec_internal.h:81
avcodec.h
ret
ret
Definition: filter_design.txt:187
pixfmt.h
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
libjxl_receive_frame
static int libjxl_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: libjxldec.c:374
AVCodecContext
main external API structure.
Definition: avcodec.h:431
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:682
FF_CODEC_RECEIVE_FRAME_CB
#define FF_CODEC_RECEIVE_FRAME_CB(func)
Definition: codec_internal.h:349
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_RGBAF32
#define AV_PIX_FMT_RGBAF32
Definition: pixfmt.h:627
AVFormatContext::duration
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1399
av_buffer_realloc
int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
Reallocate a given buffer.
Definition: buffer.c:183
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
FF_CODEC_CAP_AUTO_THREADS
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: codec_internal.h:72
LibJxlDecodeContext::frame
AVFrame * frame
Definition: libjxldec.c:63
LibJxlDecodeContext::runner
void * runner
Definition: libjxldec.c:49
libjxl_decode_close
static av_cold int libjxl_decode_close(AVCodecContext *avctx)
Definition: libjxldec.c:597
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
AVPacket
This structure stores compressed data.
Definition: packet.h:529
LibJxlDecodeContext
Definition: libjxldec.c:48
ff_libjxl_init_memory_manager
void ff_libjxl_init_memory_manager(JxlMemoryManager *manager)
Initialize and populate a JxlMemoryManager with av_malloc() and av_free() so libjxl will use these fu...
Definition: libjxl.c:65
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
AVCOL_TRC_SMPTE428
@ AVCOL_TRC_SMPTE428
SMPTE ST 428-1.
Definition: pixfmt.h:680
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
LibJxlDecodeContext::prev_is_last
int prev_is_last
Definition: libjxldec.c:61
ff_libjxl_anim_decoder
const FFCodec ff_libjxl_anim_decoder
Definition: libjxldec.c:630
LibJxlDecodeContext::basic_info
JxlBasicInfo basic_info
Definition: libjxldec.c:51
libjxl_get_trc
static enum AVColorTransferCharacteristic libjxl_get_trc(void *avctx, const JxlColorEncoding *jxl_color)
Definition: libjxldec.c:196
libjxl_color_encoding_event
static int libjxl_color_encoding_event(AVCodecContext *avctx, AVFrame *frame)
Definition: libjxldec.c:269