[FFmpeg-cvslog] avformat/movenc: use enum values directly for colr atom
Michael Bradshaw
git at videolan.org
Mon Apr 13 18:57:07 EEST 2020
ffmpeg | branch: master | Michael Bradshaw <mjbshaw at google.com> | Tue Mar 31 09:36:31 2020 -0600| [b1699f4ac38cedef79f565ba3b8f9fdec952f412] | committer: Michael Bradshaw
avformat/movenc: use enum values directly for colr atom
The switch cases were missing:
- Primaries: bt470m, film, smpte428, and ebu3213.
- TRCs: gamma22, gamma28, linear, log, log_sqrt, iec61966_2_4, bt1361,
iec61966_2_1, bt2020_10bit, and bt2020_12bit.
- Space: rgb, fcc, ycgco, bt2020_cl, smpte2085, chroma-derived-nc,
chroma-derived-c, and ictcp.
They also annoyingly remapped the following (which are functionally
equivalent but can be treated differently by clients):
- smpte240m primaries to smpte170m.
- smpte170m TRC to bt709.
- bt470bg color space to smpte170m.
The enum values in FFmpeg are the same values as ITU-T H.273 and
ISO/IEC 23001-8 so we can just use them directly, which is both simpler
and preserves the user intent.
Signed-off-by: Michael Bradshaw <mjbshaw at google.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1699f4ac38cedef79f565ba3b8f9fdec952f412
---
libavformat/movenc.c | 31 +++----------------------------
1 file changed, 3 insertions(+), 28 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6db09b73e6..3042e3ccd2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1932,34 +1932,9 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc)
ffio_wfourcc(pb, "nclx");
else
ffio_wfourcc(pb, "nclc");
- switch (track->par->color_primaries) {
- case AVCOL_PRI_BT709: avio_wb16(pb, 1); break;
- case AVCOL_PRI_BT470BG: avio_wb16(pb, 5); break;
- case AVCOL_PRI_SMPTE170M:
- case AVCOL_PRI_SMPTE240M: avio_wb16(pb, 6); break;
- case AVCOL_PRI_BT2020: avio_wb16(pb, 9); break;
- case AVCOL_PRI_SMPTE431: avio_wb16(pb, 11); break;
- case AVCOL_PRI_SMPTE432: avio_wb16(pb, 12); break;
- default: avio_wb16(pb, 2);
- }
- switch (track->par->color_trc) {
- case AVCOL_TRC_BT709: avio_wb16(pb, 1); break;
- case AVCOL_TRC_SMPTE170M: avio_wb16(pb, 1); break; // remapped
- case AVCOL_TRC_SMPTE240M: avio_wb16(pb, 7); break;
- case AVCOL_TRC_SMPTEST2084: avio_wb16(pb, 16); break;
- case AVCOL_TRC_SMPTE428: avio_wb16(pb, 17); break;
- case AVCOL_TRC_ARIB_STD_B67: avio_wb16(pb, 18); break;
- default: avio_wb16(pb, 2);
- }
- switch (track->par->color_space) {
- case AVCOL_SPC_BT709: avio_wb16(pb, 1); break;
- case AVCOL_SPC_BT470BG:
- case AVCOL_SPC_SMPTE170M: avio_wb16(pb, 6); break;
- case AVCOL_SPC_SMPTE240M: avio_wb16(pb, 7); break;
- case AVCOL_SPC_BT2020_NCL: avio_wb16(pb, 9); break;
- default: avio_wb16(pb, 2);
- }
-
+ avio_wb16(pb, track->par->color_primaries);
+ avio_wb16(pb, track->par->color_trc);
+ avio_wb16(pb, track->par->color_space);
if (track->mode == MODE_MP4) {
int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
avio_w8(pb, full_range << 7);
More information about the ffmpeg-cvslog
mailing list