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
2 2
3API changes, most recent first:3API changes, most recent first:
4 4
52024-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
52024-09-18 - xxxxxxxxxx - lavc 61.16.100 - avcodec.h102024-09-18 - xxxxxxxxxx - lavc 61.16.100 - avcodec.h
6 Add AV_CODEC_ID_LCEVC.11 Add AV_CODEC_ID_LCEVC.
7 12
libavformat/avformat.c+5−0
@@ -104,6 +104,10 @@ void ff_free_stream_group(AVStreamGroup **pstg) · 103 unmodified lines
104 av_freep(&stg->params.tile_grid->offsets);104 av_freep(&stg->params.tile_grid->offsets);
105 av_freep(&stg->params.tile_grid);105 av_freep(&stg->params.tile_grid);
106 break;106 break;
107 case AV_STREAM_GROUP_PARAMS_LCEVC:
108 av_opt_free(stg->params.lcevc);
109 av_freep(&stg->params.lcevc);
110 break;
107 default:111 default:
108 break;112 break;
109 }113 }
@@ -327,6 +331,7 @@ const char *avformat_stream_group_name(enum AVStreamGroupParamsType type) · 217 unmodified lines
327 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: return "IAMF Audio Element";331 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: return "IAMF Audio Element";
328 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix Presentation";332 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix Presentation";
329 case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid";333 case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid";
334 case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC (Split video and enhancement)";
330 }335 }
331 return NULL;336 return NULL;
332}337}
libavformat/avformat.h+27−0
@@ -1084,11 +1084,37 @@ typedef struct AVStreamGroupTileGrid { · 1083 unmodified lines
1084 int height;1084 int height;
1085} AVStreamGroupTileGrid;1085} AVStreamGroupTileGrid;
1086 1086
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 */
1095typedef 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
1087enum AVStreamGroupParamsType {1112enum AVStreamGroupParamsType {
1088 AV_STREAM_GROUP_PARAMS_NONE,1113 AV_STREAM_GROUP_PARAMS_NONE,
1089 AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,1114 AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,
1090 AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,1115 AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,
1091 AV_STREAM_GROUP_PARAMS_TILE_GRID,1116 AV_STREAM_GROUP_PARAMS_TILE_GRID,
1117 AV_STREAM_GROUP_PARAMS_LCEVC,
1092};1118};
1093 1119
1094struct AVIAMFAudioElement;1120struct AVIAMFAudioElement;
@@ -1130,6 +1156,7 @@ typedef struct AVStreamGroup { · 35 unmodified lines
1130 struct AVIAMFAudioElement *iamf_audio_element;1156 struct AVIAMFAudioElement *iamf_audio_element;
1131 struct AVIAMFMixPresentation *iamf_mix_presentation;1157 struct AVIAMFMixPresentation *iamf_mix_presentation;
1132 struct AVStreamGroupTileGrid *tile_grid;1158 struct AVStreamGroupTileGrid *tile_grid;
1159 struct AVStreamGroupLCEVC *lcevc;
1133 } params;1160 } params;
1134 1161
1135 /**1162 /**
libavformat/dump.c+27−0
@@ -789,6 +789,33 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed, · 788 unmodified lines
789 }789 }
790 break;790 break;
791 }791 }
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 }
792 default:819 default:
793 break;820 break;
794 }821 }
libavformat/options.c+28−1
@@ -348,7 +348,6 @@ static const AVOption tile_grid_options[] = { · 347 unmodified lines
348 { "vertical_offset", NULL, OFFSET(vertical_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },348 { "vertical_offset", NULL, OFFSET(vertical_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
349 { NULL },349 { NULL },
350};350};
351#undef FLAGS
352#undef OFFSET351#undef OFFSET
353 352
354static const AVClass tile_grid_class = {353static const AVClass tile_grid_class = {
@@ -357,6 +356,20 @@ static const AVClass tile_grid_class = { · 2 unmodified lines
357 .option = tile_grid_options,356 .option = tile_grid_options,
358};357};
359 358
359#define OFFSET(x) offsetof(AVStreamGroupLCEVC, x)
360static 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
367static const AVClass lcevc_class = {
368 .class_name = "AVStreamGroupLCEVC",
369 .version = LIBAVUTIL_VERSION_INT,
370 .option = lcevc_options,
371};
372
360static void *stream_group_child_next(void *obj, void *prev)373static void *stream_group_child_next(void *obj, void *prev)
361{374{
362 AVStreamGroup *stg = obj;375 AVStreamGroup *stg = obj;
@@ -368,6 +381,8 @@ static void *stream_group_child_next(void *obj, void *prev) · 5 unmodified lines
368 return stg->params.iamf_mix_presentation;381 return stg->params.iamf_mix_presentation;
369 case AV_STREAM_GROUP_PARAMS_TILE_GRID:382 case AV_STREAM_GROUP_PARAMS_TILE_GRID:
370 return stg->params.tile_grid;383 return stg->params.tile_grid;
384 case AV_STREAM_GROUP_PARAMS_LCEVC:
385 return stg->params.lcevc;
371 default:386 default:
372 break;387 break;
373 }388 }
@@ -375,6 +390,8 @@ static void *stream_group_child_next(void *obj, void *prev) · 1 unmodified line
375 return NULL;390 return NULL;
376}391}
377 392
393#undef FLAGS
394
378static const AVClass *stream_group_child_iterate(void **opaque)395static const AVClass *stream_group_child_iterate(void **opaque)
379{396{
380 uintptr_t i = (uintptr_t)*opaque;397 uintptr_t i = (uintptr_t)*opaque;
@@ -393,6 +410,9 @@ static const AVClass *stream_group_child_iterate(void **opaque) · 12 unmodified lines
393 case AV_STREAM_GROUP_PARAMS_TILE_GRID:410 case AV_STREAM_GROUP_PARAMS_TILE_GRID:
394 ret = &tile_grid_class;411 ret = &tile_grid_class;
395 break;412 break;
413 case AV_STREAM_GROUP_PARAMS_LCEVC:
414 ret = &lcevc_class;
415 break;
396 default:416 default:
397 break;417 break;
398 }418 }
@@ -462,6 +482,13 @@ AVStreamGroup *avformat_stream_group_create(AVFormatContext *s, · 63 unmodified lines
462 stg->params.tile_grid->av_class = &tile_grid_class;482 stg->params.tile_grid->av_class = &tile_grid_class;
463 av_opt_set_defaults(stg->params.tile_grid);483 av_opt_set_defaults(stg->params.tile_grid);
464 break;484 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;
465 default:492 default:
466 goto fail;493 goto fail;
467 }494 }
libavformat/version.h+2−2
@@ -31,8 +31,8 @@ · 30 unmodified lines
31 31
32#include "version_major.h"32#include "version_major.h"
33 33
34#define LIBAVFORMAT_VERSION_MINOR 534#define LIBAVFORMAT_VERSION_MINOR 6
35#define LIBAVFORMAT_VERSION_MICRO 10135#define LIBAVFORMAT_VERSION_MICRO 100
36 36
37#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \37#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
38 LIBAVFORMAT_VERSION_MINOR, \38 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