diff mbox

[FFmpeg-devel] avformat/movenc: Add support for more colorspaces

Message ID 20171214195245.145421-1-steven@strobe.cc
State Accepted
Commit 2d131fc31bcd3a6cd0ddee689d1e4fc9741dc32e
Headers show

Commit Message

Steven Robertson Dec. 14, 2017, 7:52 p.m. UTC
With FCPX 10.4, Apple has expanded the set of colorspace, primaries,
and trc flags officially supported in QuickTime files. The expanded set
matches the codepoints used in ffmpeg and many other specs.
---
 libavformat/movenc.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Comments

Michael Niedermayer Dec. 14, 2017, 10:54 p.m. UTC | #1
On Thu, Dec 14, 2017 at 11:52:45AM -0800, Steven Robertson wrote:
> With FCPX 10.4, Apple has expanded the set of colorspace, primaries,
> and trc flags officially supported in QuickTime files. The expanded set
> matches the codepoints used in ffmpeg and many other specs.
> ---
>  libavformat/movenc.c | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)

will apply

thx

[...]
Carl Eugen Hoyos Dec. 15, 2017, 2:50 a.m. UTC | #2
2017-12-14 20:52 GMT+01:00 Steven Robertson <steven@strobe.cc>:
> With FCPX 10.4, Apple has expanded the set of colorspace,
> primaries, and trc flags officially supported in QuickTime files.

What happens if new files (with new colorspace etc.) areplayed
back with older QT?

Carl Eugen
Steven Robertson Dec. 15, 2017, 7:22 a.m. UTC | #3
Actually QT has supported these codepoints for some time now internally,
but not officially. That said, I modified this to write nonsense values and
it interpreted everything as Rec 601 625 aka 470BG, which isn't great (I
think the default for anything should be 709 these days) but is not crazy
either. I presume the same behavior applies to very old versions of
QuickTime looking at these new codepoints.

On Dec 14, 2017 6:51 PM, "Carl Eugen Hoyos" <ceffmpeg@gmail.com> wrote:

> 2017-12-14 20:52 GMT+01:00 Steven Robertson <steven@strobe.cc>:
> > With FCPX 10.4, Apple has expanded the set of colorspace,
> > primaries, and trc flags officially supported in QuickTime files.
>
> What happens if new files (with new colorspace etc.) areplayed
> back with older QT?
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Carl Eugen Hoyos Dec. 15, 2017, 11:09 a.m. UTC | #4
2017-12-15 8:22 GMT+01:00 Steven Robertson <steven@strobe.cc>:
> Actually QT has supported these codepoints for some time now internally,
> but not officially. That said, I modified this to write nonsense values and
> it interpreted everything as Rec 601 625 aka 470BG, which isn't great (I
> think the default for anything should be 709 these days) but is not crazy
> either.

Thank you for testing and reporting this!

Please avoid top-posting here, Carl Eugen
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 901577401e..a597b0853d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1809,23 +1809,30 @@  static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track)
         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_BT470BG:   avio_wb16(pb, 5); 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;
-    default:                  avio_wb16(pb, 2);
+    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_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;
-    default:                  avio_wb16(pb, 2);
+    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);
     }
 
     if (track->mode == MODE_MP4) {