FFmpeg
Loading...
Searching...
No Matches
lcevcdec.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "libavutil/avassert.h"
20#include "libavutil/frame.h"
21#include "libavutil/imgutils.h"
22#include "libavutil/log.h"
23#include "libavutil/mem.h"
24#include "libavutil/opt.h"
25#include "libavutil/refstruct.h"
26
27#include "cbs.h"
28#include "cbs_lcevc.h"
29#include "decode.h"
30#include "lcevc_parse.h"
31#include "lcevcdec.h"
32#include "lcevctab.h"
33
34static LCEVC_ColorFormat map_format(int format)
35{
36 switch (format) {
38 return LCEVC_I420_8;
40 return LCEVC_I420_10_LE;
42 return LCEVC_I420_12_LE;
44 return LCEVC_I420_14_LE;
46 return LCEVC_I422_8;
48 return LCEVC_I422_10_LE;
50 return LCEVC_I422_12_LE;
52 return LCEVC_I422_14_LE;
54 return LCEVC_I444_8;
56 return LCEVC_I444_10_LE;
58 return LCEVC_I444_12_LE;
60 return LCEVC_I444_14_LE;
61 case AV_PIX_FMT_NV12:
62 return LCEVC_NV12_8;
63 case AV_PIX_FMT_NV21:
64 return LCEVC_NV21_8;
66 return LCEVC_GRAY_8;
68 return LCEVC_GRAY_10_LE;
70 return LCEVC_GRAY_12_LE;
72 return LCEVC_GRAY_14_LE;
73 }
74
75 return LCEVC_ColorFormat_Unknown;
76}
77
78static int alloc_base_frame(FFLCEVCContext *lcevc, const AVFrame *frame,
79 LCEVC_PictureDesc *desc, LCEVC_PictureHandle *picture)
80{
81 LCEVC_ColorFormat fmt = map_format(frame->format);
82 LCEVC_PicturePlaneDesc planes[AV_VIDEO_MAX_PLANES] = { 0 };
83 int width = frame->width - frame->crop_left - frame->crop_right;
84 int height = frame->height - frame->crop_top - frame->crop_bottom;
85 LCEVC_ReturnCode res;
86
87 res = LCEVC_DefaultPictureDesc(desc, fmt, width, height);
88 if (res != LCEVC_Success)
89 return AVERROR_EXTERNAL;
90
91 desc->cropTop = frame->crop_top;
92 desc->cropBottom = frame->crop_bottom;
93 desc->cropLeft = frame->crop_left;
94 desc->cropRight = frame->crop_right;
95 desc->sampleAspectRatioNum = frame->sample_aspect_ratio.num;
96 desc->sampleAspectRatioDen = frame->sample_aspect_ratio.den;
97 desc->colorRange = LCEVC_ColorRange_Unknown;
98 if (frame->color_range == AVCOL_RANGE_JPEG)
99 desc->colorRange = LCEVC_ColorRange_Full;
100 else if (frame->color_range == AVCOL_RANGE_MPEG)
101 desc->colorRange = LCEVC_ColorRange_Limited;
102 desc->colorPrimaries = (LCEVC_ColorPrimaries)frame->color_primaries;
103 desc->matrixCoefficients = (LCEVC_MatrixCoefficients)frame->colorspace;
104 desc->transferCharacteristics = (LCEVC_TransferCharacteristics)frame->color_trc;
105
106 for (int i = 0; i < AV_VIDEO_MAX_PLANES; i++) {
107 planes[i].firstSample = frame->data[i];
108 planes[i].rowByteStride = frame->linesize[i];
109 }
110
111 /* Allocate LCEVC Picture */
112 res = LCEVC_AllocPictureExternal(lcevc->decoder, desc, NULL, planes, picture);
113 if (res != LCEVC_Success) {
114 return AVERROR_EXTERNAL;
115 }
116
117 return 0;
118}
119
120static int alloc_enhanced_frame(FFLCEVCFrame *frame_ctx,
121 LCEVC_PictureHandle *picture)
122{
123 FFLCEVCContext *lcevc = frame_ctx->lcevc;
124 LCEVC_PictureDesc desc ;
125 LCEVC_ColorFormat fmt = map_format(frame_ctx->frame->format);
126 LCEVC_PicturePlaneDesc planes[4] = { 0 };
127 LCEVC_ReturnCode res;
128
129 res = LCEVC_DefaultPictureDesc(&desc, fmt, frame_ctx->frame->width, frame_ctx->frame->height);
130 if (res != LCEVC_Success)
131 return AVERROR_EXTERNAL;
132
133 /* Set plane description */
134 for (int i = 0; i < 4; i++) {
135 planes[i].firstSample = frame_ctx->frame->data[i];
136 planes[i].rowByteStride = frame_ctx->frame->linesize[i];
137 }
138
139 /* Allocate LCEVC Picture */
140 res = LCEVC_AllocPictureExternal(lcevc->decoder, &desc, NULL, planes, picture);
141 if (res != LCEVC_Success) {
142 return AVERROR_EXTERNAL;
143 }
144 return 0;
145}
146
148{
149 LCEVC_PictureHandle picture;
150 LCEVC_ReturnCode res;
151
152 while (1) {
153 AVFrame *base = NULL;
154 res = LCEVC_ReceiveDecoderBase (lcevc->decoder, &picture);
155 if (res != LCEVC_Success && res != LCEVC_Again)
156 return AVERROR_EXTERNAL;
157
158 if (res == LCEVC_Again)
159 break;
160
161 LCEVC_GetPictureUserData(lcevc->decoder, picture, (void **)&base);
163
164 res = LCEVC_FreePicture(lcevc->decoder, picture);
165 if (res != LCEVC_Success)
166 return AVERROR_EXTERNAL;
167 }
168
169 return 0;
170}
171
173{
174 if (!lcevc || lcevc->initialized != FF_LCEVCDEC_INIT)
175 return;
176
177 if (LCEVC_FlushDecoder(lcevc->decoder) != LCEVC_Success ||
178 LCEVC_SynchronizeDecoder(lcevc->decoder, 0) != LCEVC_Success ||
179 lcevc_flush_pictures(lcevc) < 0)
180 av_log(lcevc, AV_LOG_ERROR, "Failed to flush LCEVC decoder\n");
181}
182
183static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
184{
185 FFLCEVCContext *lcevc = frame_ctx->lcevc;
186 LCEVC_ColorFormat fmt = map_format(in->format);
188 AVFrame *opaque;
189 LCEVC_PictureHandle picture;
190 LCEVC_PictureDesc desc, base_desc;
191 LCEVC_ReturnCode res;
192 int ret;
193
194 if (!sd || fmt == LCEVC_ColorFormat_Unknown || lcevc->passthrough_mode == 1)
195 return 1;
196
197 res = LCEVC_SendDecoderEnhancementData(lcevc->decoder, lcevc->last_pts,
198 sd->data, sd->size);
199 if (res != LCEVC_Success) {
201 goto end;
202 }
203
204 ret = alloc_base_frame(lcevc, in, &base_desc, &picture);
205 if (ret < 0)
206 goto fail;
207
208 opaque = av_frame_clone(in);
209 if (!opaque) {
210 LCEVC_FreePicture(lcevc->decoder, picture);
211 ret = AVERROR(ENOMEM);
212 goto fail;
213 }
214
215 res = LCEVC_SetPictureUserData(lcevc->decoder, picture, opaque);
216 if (res != LCEVC_Success) {
217 LCEVC_FreePicture(lcevc->decoder, picture);
218 av_frame_free(&opaque);
220 goto fail;
221 }
222
223 res = LCEVC_SendDecoderBase(lcevc->decoder, lcevc->last_pts, picture, -1, opaque);
224 if (res != LCEVC_Success) {
225 LCEVC_FreePicture(lcevc->decoder, picture);
226 av_frame_free(&opaque);
228 goto fail;
229 }
230
231 res = LCEVC_PeekDecoderPictureDesc(lcevc->decoder, lcevc->last_pts, &desc);
232 if (res != LCEVC_Success ||
233 desc.width != frame_ctx->frame->width ||
234 desc.height != frame_ctx->frame->height ||
235 desc.colorFormat != map_format(frame_ctx->frame->format)) {
236 if (res == LCEVC_Success &&
237 desc.width == base_desc.width &&
238 desc.height == base_desc.height &&
239 desc.colorFormat == base_desc.colorFormat) {
240 av_log(lcevc, AV_LOG_VERBOSE, "Passing the base picture through\n");
241 ret = 1;
242 goto fail;
243 }
244 av_log(lcevc, AV_LOG_ERROR, "Output picture does not match the enhancement data\n");
246 goto fail;
247 }
248
249 memset(&picture, 0, sizeof(picture));
250 ret = alloc_enhanced_frame(frame_ctx, &picture);
251 if (ret < 0)
252 goto fail;
253
254 res = LCEVC_SendDecoderPicture(lcevc->decoder, picture);
255 if (res != LCEVC_Success) {
256 LCEVC_FreePicture(lcevc->decoder, picture);
258 goto fail;
259 }
260
261 ret = 0;
262 goto end;
263fail:
264 LCEVC_SkipDecoder(lcevc->decoder, lcevc->last_pts);
265 LCEVC_SynchronizeDecoder(lcevc->decoder, 0);
267end:
268 lcevc->last_pts++;
269
270 return ret;
271}
272
273static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out)
274{
275 FFLCEVCContext *lcevc = frame_ctx->lcevc;
276 LCEVC_PictureDesc desc;
277 LCEVC_DecodeInformation info;
278 LCEVC_PictureHandle picture;
279 LCEVC_ReturnCode res;
280
281 do {
282 res = LCEVC_ReceiveDecoderPicture(lcevc->decoder, &picture, &info);
283 } while (res == LCEVC_Again);
284 if (res != LCEVC_Success)
285 return AVERROR_EXTERNAL;
286
287 res = LCEVC_GetPictureDesc(lcevc->decoder, picture, &desc);
288 if (res != LCEVC_Success) {
289 LCEVC_FreePicture(lcevc->decoder, picture);
290 return AVERROR_EXTERNAL;
291 }
292
294 av_frame_copy_props(frame_ctx->frame, (AVFrame *)info.baseUserData);
295 av_frame_move_ref(out, frame_ctx->frame);
296
297 out->crop_top = desc.cropTop;
298 out->crop_bottom = desc.cropBottom;
299 out->crop_left = desc.cropLeft;
300 out->crop_right = desc.cropRight;
301 out->sample_aspect_ratio.num = desc.sampleAspectRatioNum;
302 out->sample_aspect_ratio.den = desc.sampleAspectRatioDen;
303 out->width = desc.width + out->crop_left + out->crop_right;
304 out->height = desc.height + out->crop_top + out->crop_bottom;
305 out->color_range = AVCOL_RANGE_UNSPECIFIED;
306 if (desc.colorRange == LCEVC_ColorRange_Full)
307 out->color_range = AVCOL_RANGE_JPEG;
308 else if (desc.colorRange == LCEVC_ColorRange_Limited)
309 out->color_range = AVCOL_RANGE_MPEG;
310 out->color_primaries = (enum AVColorPrimaries)desc.colorPrimaries;
311 out->colorspace = (enum AVColorSpace)desc.matrixCoefficients;
312 out->color_trc = (enum AVColorTransferCharacteristic)desc.transferCharacteristics;
313
314 av_log(lcevc, AV_LOG_DEBUG, "out PTS %"PRId64", %dx%d, "
315 "%zu/%zu/%zu/%zu, "
316 "SAR %d:%d, "
317 "color_range %d, color_primaries %d, colorspace %d, color_trc %d, "
318 "hasEnhancement %d, enhanced %d\n",
319 out->pts, out->width, out->height,
320 out->crop_top, out->crop_bottom, out->crop_left, out->crop_right,
321 out->sample_aspect_ratio.num, out->sample_aspect_ratio.den,
322 out->color_range, out->color_primaries, out->colorspace, out->color_trc,
323 info.hasEnhancement, info.enhanced);
324
325 res = LCEVC_FreePicture(lcevc->decoder, picture);
326 if (res != LCEVC_Success)
327 return AVERROR_EXTERNAL;
328
329 return 0;
330}
331
333{
334 FFLCEVCContext *lcevc = frame_ctx->lcevc;
335 int ret;
336
337 ret = generate_output(frame_ctx, out);
338 if (ret < 0)
339 return ret;
340
341 return lcevc_flush_pictures(lcevc);
342}
343
344static const uint8_t level_map[LCEVC_LogLevelCount] = {
345 [LCEVC_LogFatal] = AV_LOG_FATAL,
346 [LCEVC_LogError] = AV_LOG_ERROR,
347 [LCEVC_LogWarning] = AV_LOG_WARNING,
348 [LCEVC_LogInfo] = AV_LOG_INFO,
349 [LCEVC_LogDebug] = AV_LOG_DEBUG,
350 [LCEVC_LogTrace] = AV_LOG_TRACE,
351};
352
353static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event,
354 LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info,
355 const uint8_t *data, uint32_t size, void *logctx)
356{
357 switch (event) {
358 case LCEVC_Log: {
359 unsigned int level = 0;
360 if (size < 3)
361 break;
362 int ret = sscanf(data, "%u ", &level);
363 if (ret != 1 || level >= LCEVC_LogLevelCount || !level_map[level])
364 break;
365 av_log(logctx, level_map[level], "%s\n", data + 2);
366 break;
367 }
368 default:
369 break;
370 }
371}
372
373static void lcevc_free(AVRefStructOpaque unused, void *obj)
374{
375 FFLCEVCContext *lcevc = obj;
376 if (lcevc->initialized == FF_LCEVCDEC_INIT) {
377 LCEVC_FlushDecoder(lcevc->decoder);
379 LCEVC_DestroyDecoder(lcevc->decoder);
380 }
381 if (lcevc->frag)
382 ff_cbs_fragment_free(lcevc->frag);
383 av_freep(&lcevc->frag);
384 ff_cbs_close(&lcevc->cbc);
386 av_opt_free(lcevc);
387 memset(lcevc, 0, sizeof(*lcevc));
388}
389
391{
393
394 frame->frame = av_frame_alloc();
395 if (!frame->frame)
396 return AVERROR(ENOMEM);
397 return 0;
398}
399
401{
403
404 av_frame_unref(frame->frame);
405 av_refstruct_unref(&frame->lcevc);
406}
407
409{
411
412 av_frame_free(&frame->frame);
413}
414
415static int get_log_level(int level)
416{
417 if (level <= AV_LOG_QUIET)
418 return LCEVC_LogDisabled;
419 if (level <= AV_LOG_FATAL)
420 return LCEVC_LogFatal;
421 if (level <= AV_LOG_ERROR)
422 return LCEVC_LogError;
423 if (level <= AV_LOG_WARNING)
424 return LCEVC_LogWarning;
425 if (level <= AV_LOG_INFO)
426 return LCEVC_LogInfo;
427 if (level <= AV_LOG_DEBUG)
428 return LCEVC_LogDebug;
429
430 return LCEVC_LogTrace;
431}
432
433static int lcevc_init(FFLCEVCContext *lcevc)
434{
435 LCEVC_AccelContextHandle dummy = { 0 };
436 const int32_t event = LCEVC_Log;
437 LCEVC_ReturnCode res;
438 int level;
439
441
442 if (LCEVC_CreateDecoder(&lcevc->decoder, dummy) != LCEVC_Success) {
443 av_log(lcevc, AV_LOG_ERROR, "Failed to create LCEVC decoder\n");
444 return AVERROR_EXTERNAL;
445 }
446
447 if (lcevc->pipeline) {
448 res = LCEVC_ConfigureDecoderString(lcevc->decoder, "pipeline", lcevc->pipeline);
449 if (res != LCEVC_Success) {
450 av_log(lcevc, AV_LOG_ERROR, "Failed to set pipeline to \"%s\"\n", lcevc->pipeline);
451 LCEVC_DestroyDecoder(lcevc->decoder);
452 return AVERROR_EXTERNAL;
453 }
454 }
455
456 level = get_log_level(lcevc->loglevel);
457
458 LCEVC_ConfigureDecoderInt(lcevc->decoder, "log_level", level);
459 res = LCEVC_ConfigureDecoderInt(lcevc->decoder, "threads", lcevc->threads);
460 if (res != LCEVC_Success) {
461 av_log(lcevc, AV_LOG_ERROR, "Failed to set threads to %d\n", lcevc->threads);
462 LCEVC_DestroyDecoder(lcevc->decoder);
463 return AVERROR_EXTERNAL;
464 }
465 res = LCEVC_ConfigureDecoderInt(lcevc->decoder, "passthrough_mode", lcevc->passthrough_mode);
466 if (res != LCEVC_Success) {
467 av_log(lcevc, AV_LOG_ERROR, "Failed to set passthrough_mode to %d\n", lcevc->passthrough_mode);
468 LCEVC_DestroyDecoder(lcevc->decoder);
469 return AVERROR_EXTERNAL;
470 }
471 res = LCEVC_ConfigureDecoderBool(lcevc->decoder, "allow_dithering", lcevc->allow_dithering);
472 if (res != LCEVC_Success) {
473 av_log(lcevc, AV_LOG_ERROR, "Failed to set allow_dithering to %d\n", lcevc->allow_dithering);
474 LCEVC_DestroyDecoder(lcevc->decoder);
475 return AVERROR_EXTERNAL;
476 }
477 res = LCEVC_ConfigureDecoderBool(lcevc->decoder, "highlight_residuals", lcevc->highlight_residuals);
478 if (res != LCEVC_Success) {
479 av_log(lcevc, AV_LOG_ERROR, "Failed to set highlight_residuals to %d\n", lcevc->highlight_residuals);
480 LCEVC_DestroyDecoder(lcevc->decoder);
481 return AVERROR_EXTERNAL;
482 }
483 LCEVC_ConfigureDecoderIntArray(lcevc->decoder, "events", 1, &event);
484 LCEVC_SetDecoderEventCallback(lcevc->decoder, event_callback, lcevc);
485
486 if (LCEVC_InitializeDecoder(lcevc->decoder) != LCEVC_Success) {
487 av_log(lcevc, AV_LOG_ERROR, "Failed to initialize LCEVC decoder\n");
488 LCEVC_DestroyDecoder(lcevc->decoder);
489 return AVERROR_EXTERNAL;
490 }
491
493
494 return 0;
495}
496
497int ff_lcevc_process(void *logctx, AVFrame *frame)
498{
499 FrameDecodeData *fdd = frame->private_ref;
500 FFLCEVCFrame *frame_ctx = fdd->post_process_opaque;
501 FFLCEVCContext *lcevc = frame_ctx->lcevc;
502 int ret;
503
504 if (lcevc->initialized == FF_LCEVCDEC_UNINIT) {
505 ret = lcevc_init(lcevc);
506 if (ret < 0)
507 return ret;
508 } else if (lcevc->initialized == FF_LCEVCDEC_FAIL)
509 return 0;
510
511 av_assert0(frame_ctx->frame);
512
513
514 ret = lcevc_send_frame(frame_ctx, frame);
515 if (ret)
516 return ret < 0 ? ret : 0;
517
518 ret = lcevc_receive_frame(frame_ctx, frame);
519 if (ret < 0)
520 return ret;
521
523
524 return 0;
525}
526
528 enum AVPixelFormat *format, enum AVPixelFormat *base_format,
529 int *width, int *height)
530{
532 const LCEVCRawGlobalConfig *gc;
534 int ret;
535
536 ret = ff_cbs_read(lcevc->cbc, lcevc->frag, NULL, sd->data, sd->size);
537 if (ret < 0) {
538 av_log(lcevc, AV_LOG_ERROR, "Failed to parse Access Unit.\n");
539 goto end;
540 }
541
544 if (ret < 0) {
545 ret = 0;
546 goto end;
547 }
548
549 gc = block->payload;
550
553 if (gc->resolution_type < 63) {
556 } else {
559 }
560
561 ret = 0;
562end:
563 ff_cbs_fragment_reset(lcevc->frag);
564
565 return ret;
566}
567
572
573#define OFFSET(x) offsetof(FFLCEVCContext, x)
574#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM)
575static const AVOption lcevc_opts[] = {
576 { "passthrough_mode", "Set passthrough mode", OFFSET(passthrough_mode), AV_OPT_TYPE_INT,
577 { .i64 = 0 }, -1, 2, FLAGS, .unit = "passthrough_mode" },
578 { "disable", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, .unit = "passthrough_mode" },
579 { "allow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .unit = "passthrough_mode" },
580 { "force", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .unit = "passthrough_mode" },
581 { "scale", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .unit = "passthrough_mode" },
582 { "allow_dithering", "Allow dithering", OFFSET(allow_dithering), AV_OPT_TYPE_BOOL,
583 { .i64 = 1 }, 0, 1, FLAGS },
584 { "highlight_residuals", "Highlight residuals", OFFSET(highlight_residuals), AV_OPT_TYPE_BOOL,
585 { .i64 = 0 }, 0, 1, FLAGS },
586 { "threads", "Thread count", OFFSET(threads), AV_OPT_TYPE_INT,
587 { .i64 = 1 }, 0, INT_MAX, FLAGS },
588 { "pipeline", "Decoding pipeline", OFFSET(pipeline), AV_OPT_TYPE_STRING,
589 { .str = NULL }, 0, 0, FLAGS },
590 { NULL },
591};
592#undef OFFSET
593#undef FLAGS
594
596 .class_name = "liblcevc_dec",
597 .item_name = av_default_item_name,
598 .option = lcevc_opts,
599 .version = LIBAVUTIL_VERSION_INT,
600 .category = AV_CLASS_CATEGORY_DECODER,
601};
602
603int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel)
604{
605 FFLCEVCContext *lcevc = NULL;
606 const AVDictionaryEntry *t;
607 int ret;
608
609 lcevc = av_refstruct_alloc_ext(sizeof(*lcevc), 0, NULL, lcevc_free);
610 if (!lcevc)
611 return AVERROR(ENOMEM);
612
614 av_opt_set_defaults(lcevc);
615
616 lcevc->loglevel = loglevel;
617
618 ret = av_opt_set_dict2(lcevc, options, 0);
619 if (ret < 0)
620 goto fail;
621
622 if (t = av_dict_iterate(*options, NULL)) {
623 av_log(NULL, AV_LOG_FATAL, "liblcevc-dec option %s not found.\n", t->key);
625 goto fail;
626 }
627
628 lcevc->frag = av_mallocz(sizeof(*lcevc->frag));
629 if (!lcevc->frag) {
630 ret = AVERROR(ENOMEM);
631 goto fail;
632 }
633
634 ret = ff_cbs_init(&lcevc->cbc, AV_CODEC_ID_LCEVC, lcevc);
635 if (ret < 0)
636 goto fail;
637
640
645 if (!lcevc->frame_pool) {
646 ret = AVERROR(ENOMEM);
647 goto fail;
648 }
649
650 *plcevc = lcevc;
651 return 0;
652fail:
653 av_refstruct_unref(&lcevc);
654 return ret;
655}
static const char *const format[]
Definition af_aiir.c:445
static FILE * out
static const CodedBitstreamUnitType decompose_unit_types[]
Definition apv_parser.c:178
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
int ff_cbs_lcevc_find_process_block(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, uint32_t payload_type, CodedBitstreamUnit **block_unit, LCEVCRawProcessBlock **iter)
Iterate over blocks with the given payload type in an access unit.
Definition cbs_lcevc.c:654
#define FLAGS
Definition cmdutils.c:596
#define NULL
Definition coverity.c:32
static int16_t block[64]
Definition dct.c:125
static AVFrame * frame
int ret
Definition ffplay.c:391
static int dummy
Definition ffplay.c:4453
reference-counted frame API
#define fail
Definition test.h:479
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
@ AV_CODEC_ID_LCEVC
Definition codec_id.h:615
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition dict.c:43
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition error.h:59
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition error.h:63
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition frame.c:499
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition frame.c:662
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
Definition frame.c:728
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition frame.c:526
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:65
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:602
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:53
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition frame.c:486
@ AV_FRAME_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
Definition frame.h:236
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_QUIET
Print no output.
Definition log.h:192
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition log.h:204
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:247
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition opt.c:2042
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition opt.c:1771
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
Definition opt.c:2055
misc image utilities
@ FF_LCEVCDEC_INIT
Definition lcevcdec.h:39
@ FF_LCEVCDEC_FAIL
Definition lcevcdec.h:40
@ FF_LCEVCDEC_UNINIT
Definition lcevcdec.h:38
uintptr_t LCEVC_DecoderHandle
Definition lcevcdec.h:31
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Definition cbs.h:66
@ LCEVC_PAYLOAD_TYPE_GLOBAL_CONFIG
Definition lcevc.h:71
@ LCEVC_NON_IDR_NUT
Definition lcevc.h:60
@ LCEVC_IDR_NUT
Definition lcevc.h:61
static LCEVC_ColorFormat map_format(int format)
Definition lcevcdec.c:34
static int alloc_base_frame(FFLCEVCContext *lcevc, const AVFrame *frame, LCEVC_PictureDesc *desc, LCEVC_PictureHandle *picture)
Definition lcevcdec.c:78
static av_cold int lcevc_frame_init_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:390
static void lcevc_frame_reset_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:400
static int alloc_enhanced_frame(FFLCEVCFrame *frame_ctx, LCEVC_PictureHandle *picture)
Definition lcevcdec.c:120
int ff_lcevc_parse_frame(FFLCEVCContext *lcevc, const AVFrame *frame, enum AVPixelFormat *format, enum AVPixelFormat *base_format, int *width, int *height)
Definition lcevcdec.c:527
static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out)
Definition lcevcdec.c:273
int ff_lcevc_process(void *logctx, AVFrame *frame)
Definition lcevcdec.c:497
static int lcevc_receive_frame(FFLCEVCFrame *frame_ctx, AVFrame *out)
Definition lcevcdec.c:332
static const AVOption lcevc_opts[]
Definition lcevcdec.c:575
static int lcevc_flush_pictures(FFLCEVCContext *lcevc)
Definition lcevcdec.c:147
static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event, LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info, const uint8_t *data, uint32_t size, void *logctx)
Definition lcevcdec.c:353
static av_cold void lcevc_frame_free_entry_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:408
static const uint8_t level_map[LCEVC_LogLevelCount]
Definition lcevcdec.c:344
static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
Definition lcevcdec.c:183
static int lcevc_init(FFLCEVCContext *lcevc)
Definition lcevcdec.c:433
int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel)
Definition lcevcdec.c:603
#define OFFSET(x)
Definition lcevcdec.c:573
static void lcevc_free(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:373
static const AVClass lcevcdec_context_class
Definition lcevcdec.c:595
void ff_lcevc_flush(FFLCEVCContext *lcevc)
Definition lcevcdec.c:172
enum AVPixelFormat ff_lcevc_depth_type[4][4]
Definition lcevctab.c:40
const struct FFLCEVCDim ff_lcevc_resolution_type[63]
Definition lcevctab.c:22
#define av_cold
Definition attributes.h:117
const char * desc
Definition libsvtav1.c:110
static const struct @257111027162314367033347246032313251342043035002 planes[]
@ AV_CLASS_CATEGORY_DECODER
Definition log.h:35
Memory handling functions.
static const char * obj
Definition mscl.c:57
const char data[16]
Definition mxf.c:155
AVOptions.
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:555
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:548
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:775
@ AVCOL_RANGE_UNSPECIFIED
Definition pixfmt.h:758
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:792
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:553
#define AV_VIDEO_MAX_PLANES
Maximum number of planes in any pixel format.
Definition pixfmt.h:40
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:549
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:556
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
Definition pixfmt.h:321
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition pixfmt.h:97
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY12LE
Y , 12bpp, little-endian.
Definition pixfmt.h:319
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
Definition pixfmt.h:361
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:557
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition pixfmt.h:647
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:677
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:551
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:711
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition refstruct.c:121
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
Definition refstruct.h:292
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition refstruct.h:94
static AVRefStructPool * av_refstruct_pool_alloc_ext(size_t size, unsigned flags, void *opaque, int(*init_cb)(AVRefStructOpaque opaque, void *obj), void(*reset_cb)(AVRefStructOpaque opaque, void *obj), void(*free_entry_cb)(AVRefStructOpaque opaque, void *obj), void(*free_cb)(AVRefStructOpaque opaque))
A wrapper around av_refstruct_pool_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition refstruct.h:258
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
Definition log.h:76
char * key
Definition dict.h:91
Structure to hold side data for an AVFrame.
Definition frame.h:334
size_t size
Definition frame.h:337
uint8_t * data
Definition frame.h:336
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:500
int width
Definition frame.h:551
int height
Definition frame.h:551
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:524
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition frame.h:566
AVOption.
Definition opt.h:428
const CodedBitstreamUnitType * decompose_unit_types
Array of unit types which should be decomposed when reading.
Definition cbs.h:255
int nb_decompose_unit_types
Length of the decompose_unit_types array.
Definition cbs.h:259
int passthrough_mode
Definition lcevcdec.h:52
struct CodedBitstreamContext * cbc
Definition lcevcdec.h:46
int64_t last_pts
Definition lcevcdec.h:49
int highlight_residuals
Definition lcevcdec.h:54
LCEVC_DecoderHandle decoder
Definition lcevcdec.h:45
uint8_t * pipeline
Definition lcevcdec.h:55
struct CodedBitstreamFragment * frag
Definition lcevcdec.h:47
struct AVRefStructPool * frame_pool
pool of FFLCEVCFrame
Definition lcevcdec.h:48
int allow_dithering
Definition lcevcdec.h:53
const AVClass * class
Definition lcevcdec.h:44
FFLCEVCContext * lcevc
Definition lcevcdec.h:62
struct AVFrame * frame
Definition lcevcdec.h:63
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
Definition decode.h:33
void * post_process_opaque
RefStruct reference.
Definition decode.h:45
uint8_t chroma_sampling_type
Definition cbs_lcevc.h:53
uint16_t custom_resolution_width
Definition cbs_lcevc.h:82
uint8_t resolution_type
Definition cbs_lcevc.h:51
uint8_t enhancement_depth_type
Definition cbs_lcevc.h:55
uint16_t custom_resolution_height
Definition cbs_lcevc.h:83
uint8_t base_depth_type
Definition cbs_lcevc.h:54
uint8_t level
Definition svq3.c:208
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
int size
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition refstruct.h:58
static enum pl_log_level get_log_level(void)
uint8_t base
Definition vp3data.h:128