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
172static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
173{
174 FFLCEVCContext *lcevc = frame_ctx->lcevc;
175 LCEVC_ColorFormat fmt = map_format(in->format);
177 AVFrame *opaque;
178 LCEVC_PictureHandle picture;
179 LCEVC_PictureDesc desc, base_desc;
180 LCEVC_ReturnCode res;
181 int ret;
182
183 if (!sd || fmt == LCEVC_ColorFormat_Unknown || lcevc->passthrough_mode == 1)
184 return 1;
185
186 res = LCEVC_SendDecoderEnhancementData(lcevc->decoder, lcevc->last_pts,
187 sd->data, sd->size);
188 if (res != LCEVC_Success) {
190 goto end;
191 }
192
193 ret = alloc_base_frame(lcevc, in, &base_desc, &picture);
194 if (ret < 0)
195 goto fail;
196
197 opaque = av_frame_clone(in);
198 if (!opaque) {
199 LCEVC_FreePicture(lcevc->decoder, picture);
200 ret = AVERROR(ENOMEM);
201 goto fail;
202 }
203
204 res = LCEVC_SetPictureUserData(lcevc->decoder, picture, opaque);
205 if (res != LCEVC_Success) {
206 LCEVC_FreePicture(lcevc->decoder, picture);
207 av_frame_free(&opaque);
209 goto fail;
210 }
211
212 res = LCEVC_SendDecoderBase(lcevc->decoder, lcevc->last_pts, picture, -1, opaque);
213 if (res != LCEVC_Success) {
214 LCEVC_FreePicture(lcevc->decoder, picture);
215 av_frame_free(&opaque);
217 goto fail;
218 }
219
220 res = LCEVC_PeekDecoderPictureDesc(lcevc->decoder, lcevc->last_pts, &desc);
221 if (res != LCEVC_Success ||
222 desc.width != frame_ctx->frame->width ||
223 desc.height != frame_ctx->frame->height ||
224 desc.colorFormat != map_format(frame_ctx->frame->format)) {
225 if (res == LCEVC_Success &&
226 desc.width == base_desc.width &&
227 desc.height == base_desc.height &&
228 desc.colorFormat == base_desc.colorFormat) {
229 av_log(lcevc, AV_LOG_VERBOSE, "Passing the base picture through\n");
230 ret = 1;
231 goto fail;
232 }
233 av_log(lcevc, AV_LOG_ERROR, "Output picture does not match the enhancement data\n");
235 goto fail;
236 }
237
238 memset(&picture, 0, sizeof(picture));
239 ret = alloc_enhanced_frame(frame_ctx, &picture);
240 if (ret < 0)
241 goto fail;
242
243 res = LCEVC_SendDecoderPicture(lcevc->decoder, picture);
244 if (res != LCEVC_Success) {
245 LCEVC_FreePicture(lcevc->decoder, picture);
247 goto fail;
248 }
249
250 ret = 0;
251 goto end;
252fail:
253 LCEVC_SkipDecoder(lcevc->decoder, lcevc->last_pts);
254 LCEVC_SynchronizeDecoder(lcevc->decoder, 0);
256end:
257 lcevc->last_pts++;
258
259 return ret;
260}
261
262static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out)
263{
264 FFLCEVCContext *lcevc = frame_ctx->lcevc;
265 LCEVC_PictureDesc desc;
266 LCEVC_DecodeInformation info;
267 LCEVC_PictureHandle picture;
268 LCEVC_ReturnCode res;
269
270 do {
271 res = LCEVC_ReceiveDecoderPicture(lcevc->decoder, &picture, &info);
272 } while (res == LCEVC_Again);
273 if (res != LCEVC_Success)
274 return AVERROR_EXTERNAL;
275
276 res = LCEVC_GetPictureDesc(lcevc->decoder, picture, &desc);
277 if (res != LCEVC_Success) {
278 LCEVC_FreePicture(lcevc->decoder, picture);
279 return AVERROR_EXTERNAL;
280 }
281
283 av_frame_copy_props(frame_ctx->frame, (AVFrame *)info.baseUserData);
284 av_frame_move_ref(out, frame_ctx->frame);
285
286 out->crop_top = desc.cropTop;
287 out->crop_bottom = desc.cropBottom;
288 out->crop_left = desc.cropLeft;
289 out->crop_right = desc.cropRight;
290 out->sample_aspect_ratio.num = desc.sampleAspectRatioNum;
291 out->sample_aspect_ratio.den = desc.sampleAspectRatioDen;
292 out->width = desc.width + out->crop_left + out->crop_right;
293 out->height = desc.height + out->crop_top + out->crop_bottom;
294 out->color_range = AVCOL_RANGE_UNSPECIFIED;
295 if (desc.colorRange == LCEVC_ColorRange_Full)
296 out->color_range = AVCOL_RANGE_JPEG;
297 else if (desc.colorRange == LCEVC_ColorRange_Limited)
298 out->color_range = AVCOL_RANGE_MPEG;
299 out->color_primaries = (enum AVColorPrimaries)desc.colorPrimaries;
300 out->colorspace = (enum AVColorSpace)desc.matrixCoefficients;
301 out->color_trc = (enum AVColorTransferCharacteristic)desc.transferCharacteristics;
302
303 av_log(lcevc, AV_LOG_DEBUG, "out PTS %"PRId64", %dx%d, "
304 "%zu/%zu/%zu/%zu, "
305 "SAR %d:%d, "
306 "color_range %d, color_primaries %d, colorspace %d, color_trc %d, "
307 "hasEnhancement %d, enhanced %d\n",
308 out->pts, out->width, out->height,
309 out->crop_top, out->crop_bottom, out->crop_left, out->crop_right,
310 out->sample_aspect_ratio.num, out->sample_aspect_ratio.den,
311 out->color_range, out->color_primaries, out->colorspace, out->color_trc,
312 info.hasEnhancement, info.enhanced);
313
314 res = LCEVC_FreePicture(lcevc->decoder, picture);
315 if (res != LCEVC_Success)
316 return AVERROR_EXTERNAL;
317
318 return 0;
319}
320
322{
323 FFLCEVCContext *lcevc = frame_ctx->lcevc;
324 int ret;
325
326 ret = generate_output(frame_ctx, out);
327 if (ret < 0)
328 return ret;
329
330 return lcevc_flush_pictures(lcevc);
331}
332
333static const uint8_t level_map[LCEVC_LogLevelCount] = {
334 [LCEVC_LogFatal] = AV_LOG_FATAL,
335 [LCEVC_LogError] = AV_LOG_ERROR,
336 [LCEVC_LogWarning] = AV_LOG_WARNING,
337 [LCEVC_LogInfo] = AV_LOG_INFO,
338 [LCEVC_LogDebug] = AV_LOG_DEBUG,
339 [LCEVC_LogTrace] = AV_LOG_TRACE,
340};
341
342static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event,
343 LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info,
344 const uint8_t *data, uint32_t size, void *logctx)
345{
346 switch (event) {
347 case LCEVC_Log: {
348 unsigned int level = 0;
349 if (size < 3)
350 break;
351 int ret = sscanf(data, "%u ", &level);
352 if (ret != 1 || level >= LCEVC_LogLevelCount || !level_map[level])
353 break;
354 av_log(logctx, level_map[level], "%s\n", data + 2);
355 break;
356 }
357 default:
358 break;
359 }
360}
361
362static void lcevc_free(AVRefStructOpaque unused, void *obj)
363{
364 FFLCEVCContext *lcevc = obj;
365 if (lcevc->initialized == FF_LCEVCDEC_INIT) {
366 LCEVC_FlushDecoder(lcevc->decoder);
368 LCEVC_DestroyDecoder(lcevc->decoder);
369 }
370 if (lcevc->frag)
371 ff_cbs_fragment_free(lcevc->frag);
372 av_freep(&lcevc->frag);
373 ff_cbs_close(&lcevc->cbc);
375 av_opt_free(lcevc);
376 memset(lcevc, 0, sizeof(*lcevc));
377}
378
380{
382
383 frame->frame = av_frame_alloc();
384 if (!frame->frame)
385 return AVERROR(ENOMEM);
386 return 0;
387}
388
390{
392
393 av_frame_unref(frame->frame);
394 av_refstruct_unref(&frame->lcevc);
395}
396
398{
400
401 av_frame_free(&frame->frame);
402}
403
404static int get_log_level(int level)
405{
406 if (level <= AV_LOG_QUIET)
407 return LCEVC_LogDisabled;
408 if (level <= AV_LOG_FATAL)
409 return LCEVC_LogFatal;
410 if (level <= AV_LOG_ERROR)
411 return LCEVC_LogError;
412 if (level <= AV_LOG_WARNING)
413 return LCEVC_LogWarning;
414 if (level <= AV_LOG_INFO)
415 return LCEVC_LogInfo;
416 if (level <= AV_LOG_DEBUG)
417 return LCEVC_LogDebug;
418
419 return LCEVC_LogTrace;
420}
421
422static int lcevc_init(FFLCEVCContext *lcevc)
423{
424 LCEVC_AccelContextHandle dummy = { 0 };
425 const int32_t event = LCEVC_Log;
426 LCEVC_ReturnCode res;
427 int level;
428
430
431 if (LCEVC_CreateDecoder(&lcevc->decoder, dummy) != LCEVC_Success) {
432 av_log(lcevc, AV_LOG_ERROR, "Failed to create LCEVC decoder\n");
433 return AVERROR_EXTERNAL;
434 }
435
436 if (lcevc->pipeline) {
437 res = LCEVC_ConfigureDecoderString(lcevc->decoder, "pipeline", lcevc->pipeline);
438 if (res != LCEVC_Success) {
439 av_log(lcevc, AV_LOG_ERROR, "Failed to set pipeline to \"%s\"\n", lcevc->pipeline);
440 LCEVC_DestroyDecoder(lcevc->decoder);
441 return AVERROR_EXTERNAL;
442 }
443 }
444
445 level = get_log_level(lcevc->loglevel);
446
447 LCEVC_ConfigureDecoderInt(lcevc->decoder, "log_level", level);
448 res = LCEVC_ConfigureDecoderInt(lcevc->decoder, "threads", lcevc->threads);
449 if (res != LCEVC_Success) {
450 av_log(lcevc, AV_LOG_ERROR, "Failed to set threads to %d\n", lcevc->threads);
451 LCEVC_DestroyDecoder(lcevc->decoder);
452 return AVERROR_EXTERNAL;
453 }
454 res = LCEVC_ConfigureDecoderInt(lcevc->decoder, "passthrough_mode", lcevc->passthrough_mode);
455 if (res != LCEVC_Success) {
456 av_log(lcevc, AV_LOG_ERROR, "Failed to set passthrough_mode to %d\n", lcevc->passthrough_mode);
457 LCEVC_DestroyDecoder(lcevc->decoder);
458 return AVERROR_EXTERNAL;
459 }
460 res = LCEVC_ConfigureDecoderBool(lcevc->decoder, "allow_dithering", lcevc->allow_dithering);
461 if (res != LCEVC_Success) {
462 av_log(lcevc, AV_LOG_ERROR, "Failed to set allow_dithering to %d\n", lcevc->allow_dithering);
463 LCEVC_DestroyDecoder(lcevc->decoder);
464 return AVERROR_EXTERNAL;
465 }
466 res = LCEVC_ConfigureDecoderBool(lcevc->decoder, "highlight_residuals", lcevc->highlight_residuals);
467 if (res != LCEVC_Success) {
468 av_log(lcevc, AV_LOG_ERROR, "Failed to set highlight_residuals to %d\n", lcevc->highlight_residuals);
469 LCEVC_DestroyDecoder(lcevc->decoder);
470 return AVERROR_EXTERNAL;
471 }
472 LCEVC_ConfigureDecoderIntArray(lcevc->decoder, "events", 1, &event);
473 LCEVC_SetDecoderEventCallback(lcevc->decoder, event_callback, lcevc);
474
475 if (LCEVC_InitializeDecoder(lcevc->decoder) != LCEVC_Success) {
476 av_log(lcevc, AV_LOG_ERROR, "Failed to initialize LCEVC decoder\n");
477 LCEVC_DestroyDecoder(lcevc->decoder);
478 return AVERROR_EXTERNAL;
479 }
480
482
483 return 0;
484}
485
486int ff_lcevc_process(void *logctx, AVFrame *frame)
487{
488 FrameDecodeData *fdd = frame->private_ref;
489 FFLCEVCFrame *frame_ctx = fdd->post_process_opaque;
490 FFLCEVCContext *lcevc = frame_ctx->lcevc;
491 int ret;
492
493 if (lcevc->initialized == FF_LCEVCDEC_UNINIT) {
494 ret = lcevc_init(lcevc);
495 if (ret < 0)
496 return ret;
497 } else if (lcevc->initialized == FF_LCEVCDEC_FAIL)
498 return 0;
499
500 av_assert0(frame_ctx->frame);
501
502
503 ret = lcevc_send_frame(frame_ctx, frame);
504 if (ret)
505 return ret < 0 ? ret : 0;
506
507 ret = lcevc_receive_frame(frame_ctx, frame);
508 if (ret < 0)
509 return ret;
510
512
513 return 0;
514}
515
517 enum AVPixelFormat *format, enum AVPixelFormat *base_format,
518 int *width, int *height)
519{
521 const LCEVCRawGlobalConfig *gc;
523 int ret;
524
525 ret = ff_cbs_read(lcevc->cbc, lcevc->frag, NULL, sd->data, sd->size);
526 if (ret < 0) {
527 av_log(lcevc, AV_LOG_ERROR, "Failed to parse Access Unit.\n");
528 goto end;
529 }
530
533 if (ret < 0) {
534 ret = 0;
535 goto end;
536 }
537
538 gc = block->payload;
539
542 if (gc->resolution_type < 63) {
545 } else {
548 }
549
550 ret = 0;
551end:
552 ff_cbs_fragment_reset(lcevc->frag);
553
554 return ret;
555}
556
561
562#define OFFSET(x) offsetof(FFLCEVCContext, x)
563#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM)
564static const AVOption lcevc_opts[] = {
565 { "passthrough_mode", "Set passthrough mode", OFFSET(passthrough_mode), AV_OPT_TYPE_INT,
566 { .i64 = 0 }, -1, 2, FLAGS, .unit = "passthrough_mode" },
567 { "disable", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, .unit = "passthrough_mode" },
568 { "allow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .unit = "passthrough_mode" },
569 { "force", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .unit = "passthrough_mode" },
570 { "scale", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .unit = "passthrough_mode" },
571 { "allow_dithering", "Allow dithering", OFFSET(allow_dithering), AV_OPT_TYPE_BOOL,
572 { .i64 = 1 }, 0, 1, FLAGS },
573 { "highlight_residuals", "Highlight residuals", OFFSET(highlight_residuals), AV_OPT_TYPE_BOOL,
574 { .i64 = 0 }, 0, 1, FLAGS },
575 { "threads", "Thread count", OFFSET(threads), AV_OPT_TYPE_INT,
576 { .i64 = 1 }, 0, INT_MAX, FLAGS },
577 { "pipeline", "Decoding pipeline", OFFSET(pipeline), AV_OPT_TYPE_STRING,
578 { .str = NULL }, 0, 0, FLAGS },
579 { NULL },
580};
581#undef OFFSET
582#undef FLAGS
583
585 .class_name = "liblcevc_dec",
586 .item_name = av_default_item_name,
587 .option = lcevc_opts,
588 .version = LIBAVUTIL_VERSION_INT,
589 .category = AV_CLASS_CATEGORY_DECODER,
590};
591
592int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel)
593{
594 FFLCEVCContext *lcevc = NULL;
595 const AVDictionaryEntry *t;
596 int ret;
597
598 lcevc = av_refstruct_alloc_ext(sizeof(*lcevc), 0, NULL, lcevc_free);
599 if (!lcevc)
600 return AVERROR(ENOMEM);
601
603 av_opt_set_defaults(lcevc);
604
605 lcevc->loglevel = loglevel;
606
607 ret = av_opt_set_dict2(lcevc, options, 0);
608 if (ret < 0)
609 goto fail;
610
611 if (t = av_dict_iterate(*options, NULL)) {
612 av_log(NULL, AV_LOG_FATAL, "liblcevc-dec option %s not found.\n", t->key);
614 goto fail;
615 }
616
617 lcevc->frag = av_mallocz(sizeof(*lcevc->frag));
618 if (!lcevc->frag) {
619 ret = AVERROR(ENOMEM);
620 goto fail;
621 }
622
623 ret = ff_cbs_init(&lcevc->cbc, AV_CODEC_ID_LCEVC, lcevc);
624 if (ret < 0)
625 goto fail;
626
629
634 if (!lcevc->frame_pool) {
635 ret = AVERROR(ENOMEM);
636 goto fail;
637 }
638
639 *plcevc = lcevc;
640 return 0;
641fail:
642 av_refstruct_unref(&lcevc);
643 return ret;
644}
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, LCEVCRawProcessBlock **iter)
Iterate over blocks with the given payload type in an access unit.
Definition cbs_lcevc.c:662
#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:4427
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:614
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:2033
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition opt.c:1762
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:2046
misc image utilities
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:379
static void lcevc_frame_reset_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:389
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:516
static int generate_output(FFLCEVCFrame *frame_ctx, AVFrame *out)
Definition lcevcdec.c:262
int ff_lcevc_process(void *logctx, AVFrame *frame)
Definition lcevcdec.c:486
static int lcevc_receive_frame(FFLCEVCFrame *frame_ctx, AVFrame *out)
Definition lcevcdec.c:321
static const AVOption lcevc_opts[]
Definition lcevcdec.c:564
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:342
static av_cold void lcevc_frame_free_entry_cb(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:397
static const uint8_t level_map[LCEVC_LogLevelCount]
Definition lcevcdec.c:333
static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
Definition lcevcdec.c:172
static int lcevc_init(FFLCEVCContext *lcevc)
Definition lcevcdec.c:422
int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel)
Definition lcevcdec.c:592
#define OFFSET(x)
Definition lcevcdec.c:562
static void lcevc_free(AVRefStructOpaque unused, void *obj)
Definition lcevcdec.c:362
static const AVClass lcevcdec_context_class
Definition lcevcdec.c:584
@ 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
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:83
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:149
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:771
@ AVCOL_RANGE_UNSPECIFIED
Definition pixfmt.h:754
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:788
#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