diff options
author | Michael Bradshaw <mjbshaw@google.com> | 2020-03-27 17:19:02 -0600 |
---|---|---|
committer | Michael Bradshaw <mjbshaw@google.com> | 2020-04-01 09:44:18 -0600 |
commit | 5a0575e32c62765549675833a0e523769955b616 (patch) | |
tree | c2d11b970ac3e1b1884be5fa57573caf691eb27f | |
parent | 00ce1ec6a5d301b4075e2e7e5c9ea3b37c9c4be5 (diff) | |
download | ffmpeg-5a0575e32c62765549675833a0e523769955b616.tar.gz |
avformat/movenc: add write_clli flag to write clli atom
The clli atom isn't in ISO/IEC 14496-12:2015 so the flag is marked as
experimental and the clli atom is not written by default.
The clli atom is already parsed by FFmpeg in mov.c.
Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
-rw-r--r-- | libavformat/movenc.c | 26 | ||||
-rw-r--r-- | libavformat/movenc.h | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 1c178fc4bc..6db09b73e6 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -77,6 +77,7 @@ static const AVOption options[] = { { "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "write_clli", "Write clli atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_CLLI}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "prefer_icc", "If writing colr atom prioritise usage of ICC profile if it exists in stream packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_PREFER_ICC}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, @@ -1967,6 +1968,25 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc) return update_size(pb, pos); } +static int mov_write_clli_tag(AVIOContext *pb, MOVTrack *track) +{ + const uint8_t *side_data; + const AVContentLightMetadata *content_light_metadata; + + side_data = av_stream_get_side_data(track->st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, NULL); + if (!side_data) { + av_log(NULL, AV_LOG_WARNING, "Not writing 'clli' atom. No content light level info.\n"); + return 0; + } + content_light_metadata = (const AVContentLightMetadata*)side_data; + + avio_wb32(pb, 12); // size + ffio_wfourcc(pb, "clli"); + avio_wb16(pb, content_light_metadata->MaxCLL); + avio_wb16(pb, content_light_metadata->MaxFALL); + return 12; +} + static void find_compressor(char * compressor_name, int len, MOVTrack *track) { AVDictionaryEntry *encoder; @@ -2140,6 +2160,12 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex else av_log(mov->fc, AV_LOG_WARNING, "Not writing 'colr' atom. Format is not MOV or MP4.\n"); } + if (mov->flags & FF_MOV_FLAG_WRITE_CLLI) { + if (track->mode == MODE_MOV || track->mode == MODE_MP4) + mov_write_clli_tag(pb, track); + else + av_log(mov->fc, AV_LOG_WARNING, "Not writing 'clli' atom. Format is not MOV or MP4.\n"); + } if (track->mode == MODE_MP4 && mov->fc->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { AVStereo3D* stereo_3d = (AVStereo3D*) av_stream_get_side_data(track->st, AV_PKT_DATA_STEREO3D, NULL); diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 997b2d61c0..a7a0841f55 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -261,6 +261,7 @@ typedef struct MOVMuxContext { #define FF_MOV_FLAG_SKIP_SIDX (1 << 21) #define FF_MOV_FLAG_CMAF (1 << 22) #define FF_MOV_FLAG_PREFER_ICC (1 << 23) +#define FF_MOV_FLAG_WRITE_CLLI (1 << 24) int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); |