History

avformat: add an LCEVC stream group

James Almer committed 2 years ago

Commit ba0ef081 parent 58963186 files · +94 −3Browse files

Unified · Split

6 files
  1. doc/APIchanges +5 −0
  2. libavformat/avformat.c +5 −0
  3. libavformat/avformat.h +27 −0
  4. libavformat/dump.c +27 −0
  5. libavformat/options.c +28 −1
  6. libavformat/version.h +2 −2
doc/APIchanges+5−0
@@ -2,6 +2,11 @@ The last version increases of all libraries were on 2024-03-07 · 1 unmodified line
22
33 API changes, most recent first:
44
5+2024-09-18 - xxxxxxxxxx - lavf 61.5.100 - avformat.h
6+ Add AVStreamGroupLCEVC
7+ Add AV_STREAM_GROUP_PARAMS_LCEVC
8+ Add AVStreamGroup.params.lcevc
9+
510 2024-09-18 - xxxxxxxxxx - lavc 61.16.100 - avcodec.h
611 Add AV_CODEC_ID_LCEVC.
712
libavformat/avformat.c+5−0
@@ -104,6 +104,10 @@ void ff_free_stream_group(AVStreamGroup **pstg) · 103 unmodified lines
104104 av_freep(&stg->params.tile_grid->offsets);
105105 av_freep(&stg->params.tile_grid);
106106 break;
107+ case AV_STREAM_GROUP_PARAMS_LCEVC:
108+ av_opt_free(stg->params.lcevc);
109+ av_freep(&stg->params.lcevc);
110+ break;
107111 default:
108112 break;
109113 }
@@ -327,6 +331,7 @@ const char *avformat_stream_group_name(enum AVStreamGroupParamsType type) · 217 unmodified lines
327331 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: return "IAMF Audio Element";
328332 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix Presentation";
329333 case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid";
334+ case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC (Split video and enhancement)";
330335 }
331336 return NULL;
332337 }
libavformat/avformat.h+27−0
@@ -1084,11 +1084,37 @@ typedef struct AVStreamGroupTileGrid { · 1083 unmodified lines
10841084 int height;
10851085 } AVStreamGroupTileGrid;
10861086
1087+/**
1088+ * AVStreamGroupLCEVC is meant to define the relation between video streams
1089+ * and a data stream containing LCEVC enhancement layer NALUs.
1090+ *
1091+ * No more than one stream of @ref AVCodecParameters.codec_type "codec_type"
1092+ * AVMEDIA_TYPE_DATA shall be present, and it must be of
1093+ * @ref AVCodecParameters.codec_id "codec_id" AV_CODEC_ID_LCEVC.
1094+ */
1095+typedef struct AVStreamGroupLCEVC {
1096+ const AVClass *av_class;
1097+
1098+ /**
1099+ * Index of the LCEVC data stream in AVStreamGroup.
1100+ */
1101+ unsigned int lcevc_index;
1102+ /**
1103+ * Width of the final stream for presentation.
1104+ */
1105+ int width;
1106+ /**
1107+ * Height of the final image for presentation.
1108+ */
1109+ int height;
1110+} AVStreamGroupLCEVC;
1111+
10871112 enum AVStreamGroupParamsType {
10881113 AV_STREAM_GROUP_PARAMS_NONE,
10891114 AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,
10901115 AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,
10911116 AV_STREAM_GROUP_PARAMS_TILE_GRID,
1117+ AV_STREAM_GROUP_PARAMS_LCEVC,
10921118 };
10931119
10941120 struct AVIAMFAudioElement;
@@ -1130,6 +1156,7 @@ typedef struct AVStreamGroup { · 35 unmodified lines
11301156 struct AVIAMFAudioElement *iamf_audio_element;
11311157 struct AVIAMFMixPresentation *iamf_mix_presentation;
11321158 struct AVStreamGroupTileGrid *tile_grid;
1159+ struct AVStreamGroupLCEVC *lcevc;
11331160 } params;
11341161
11351162 /**
libavformat/dump.c+27−0
@@ -789,6 +789,33 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed, · 788 unmodified lines
789789 }
790790 break;
791791 }
792+ case AV_STREAM_GROUP_PARAMS_LCEVC: {
793+ const AVStreamGroupLCEVC *lcevc = stg->params.lcevc;
794+ AVCodecContext *avctx = avcodec_alloc_context3(NULL);
795+ const char *ptr = NULL;
796+ av_log(NULL, AV_LOG_INFO, " LCEVC:");
797+ if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, stg->streams[0]->codecpar)) {
798+ avctx->width = lcevc->width;
799+ avctx->height = lcevc->height;
800+ avctx->coded_width = lcevc->width;
801+ avctx->coded_height = lcevc->height;
802+ if (ic->dump_separator)
803+ av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
804+ buf[0] = 0;
805+ avcodec_string(buf, sizeof(buf), avctx, is_output);
806+ ptr = av_stristr(buf, " ");
807+ }
808+ avcodec_free_context(&avctx);
809+ if (ptr)
810+ av_log(NULL, AV_LOG_INFO, "%s", ptr);
811+ av_log(NULL, AV_LOG_INFO, "\n");
812+ for (int i = 0; i < stg->nb_streams; i++) {
813+ const AVStream *st = stg->streams[i];
814+ dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE);
815+ printed[st->index] = 1;
816+ }
817+ break;
818+ }
792819 default:
793820 break;
794821 }
libavformat/options.c+28−1
@@ -348,7 +348,6 @@ static const AVOption tile_grid_options[] = { · 347 unmodified lines
348348 { "vertical_offset", NULL, OFFSET(vertical_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
349349 { NULL },
350350 };
351−#undef FLAGS
352351 #undef OFFSET
353352
354353 static const AVClass tile_grid_class = {
@@ -357,6 +356,20 @@ static const AVClass tile_grid_class = { · 2 unmodified lines
357356 .option = tile_grid_options,
358357 };
359358
359+#define OFFSET(x) offsetof(AVStreamGroupLCEVC, x)
360+static const AVOption lcevc_options[] = {
361+ { "video_size", "size of video after LCEVC enhancement has been applied", OFFSET(width),
362+ AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, FLAGS },
363+ { NULL },
364+};
365+#undef OFFSET
366+
367+static const AVClass lcevc_class = {
368+ .class_name = "AVStreamGroupLCEVC",
369+ .version = LIBAVUTIL_VERSION_INT,
370+ .option = lcevc_options,
371+};
372+
360373 static void *stream_group_child_next(void *obj, void *prev)
361374 {
362375 AVStreamGroup *stg = obj;
@@ -368,6 +381,8 @@ static void *stream_group_child_next(void *obj, void *prev) · 5 unmodified lines
368381 return stg->params.iamf_mix_presentation;
369382 case AV_STREAM_GROUP_PARAMS_TILE_GRID:
370383 return stg->params.tile_grid;
384+ case AV_STREAM_GROUP_PARAMS_LCEVC:
385+ return stg->params.lcevc;
371386 default:
372387 break;
373388 }
@@ -375,6 +390,8 @@ static void *stream_group_child_next(void *obj, void *prev) · 1 unmodified line
375390 return NULL;
376391 }
377392
393+#undef FLAGS
394+
378395 static const AVClass *stream_group_child_iterate(void **opaque)
379396 {
380397 uintptr_t i = (uintptr_t)*opaque;
@@ -393,6 +410,9 @@ static const AVClass *stream_group_child_iterate(void **opaque) · 12 unmodified lines
393410 case AV_STREAM_GROUP_PARAMS_TILE_GRID:
394411 ret = &tile_grid_class;
395412 break;
413+ case AV_STREAM_GROUP_PARAMS_LCEVC:
414+ ret = &lcevc_class;
415+ break;
396416 default:
397417 break;
398418 }
@@ -462,6 +482,13 @@ AVStreamGroup *avformat_stream_group_create(AVFormatContext *s, · 63 unmodified lines
462482 stg->params.tile_grid->av_class = &tile_grid_class;
463483 av_opt_set_defaults(stg->params.tile_grid);
464484 break;
485+ case AV_STREAM_GROUP_PARAMS_LCEVC:
486+ stg->params.lcevc = av_mallocz(sizeof(*stg->params.lcevc));
487+ if (!stg->params.lcevc)
488+ goto fail;
489+ stg->params.lcevc->av_class = &lcevc_class;
490+ av_opt_set_defaults(stg->params.lcevc);
491+ break;
465492 default:
466493 goto fail;
467494 }
libavformat/version.h+2−2
@@ -31,8 +31,8 @@ · 30 unmodified lines
3131
3232 #include "version_major.h"
3333
34−#define LIBAVFORMAT_VERSION_MINOR 5
35−#define LIBAVFORMAT_VERSION_MICRO 101
34+#define LIBAVFORMAT_VERSION_MINOR 6
35+#define LIBAVFORMAT_VERSION_MICRO 100
3636
3737 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3838 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t