summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorSteven Robertson <steven@strobe.cc>2016-08-17 00:25:47 -0700
committerMichael Niedermayer <michael@niedermayer.cc>2016-08-21 02:58:24 +0200
commita3cab3d43387add8914c1c471fc99d733227d81b (patch)
treedb93deb21ebab1e6a133fa70a30be89d0df10e52 /libavformat
parentcf7b0b5050e82451ff75ec5ad9f0f222e90030d5 (diff)
libavformat/mov: Accept known codepoints in 'colr'
This change relaxes the whitelist on reading color metadata in MOV/BMFF containers. The whitelist on writing values is still in place. As a consequence it also fixes an apparent bug in reading 'nclc' values. The 'nclc' spec [1] is in harmony with ISO 23001-8 for the values it lists, but the code getting removed was remapping 5->6 and 6->7 for primaries, which is incorrect, and was remapping 6->5 for color matrix ("colorspace" in the code), which is equivalent but an unnecessary inconsistency. This logic error doesn't appear in movenc. Removing the whitelist allows proper conversion when the source codec relies on the container for proper signaling of newer codepoints, such as DNxHR and VP9. If converting to a codec or container that has updated its spec to include the new codepoints, the metadata will be preserved. If going back to MOV/BMFF, the output whitelist will still kick in, so this won't result in out-of-spec files being created. [1] https://developer.apple.com/library/mac/technotes/tn2162/_index.html Signed-off-by: Steven Robertson <steven@strobe.cc> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mov.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0dfdec0245..1bc3800fad 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1325,38 +1325,16 @@ static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st->codecpar->color_range = AVCOL_RANGE_JPEG;
else
st->codecpar->color_range = AVCOL_RANGE_MPEG;
- /* 14496-12 references JPEG XR specs (rather than the more complete
- * 23001-8) so some adjusting is required */
- if (color_primaries >= AVCOL_PRI_FILM)
- color_primaries = AVCOL_PRI_UNSPECIFIED;
- if ((color_trc >= AVCOL_TRC_LINEAR &&
- color_trc <= AVCOL_TRC_LOG_SQRT) ||
- color_trc >= AVCOL_TRC_BT2020_10)
- color_trc = AVCOL_TRC_UNSPECIFIED;
- if (color_matrix >= AVCOL_SPC_BT2020_NCL)
- color_matrix = AVCOL_SPC_UNSPECIFIED;
- st->codecpar->color_primaries = color_primaries;
- st->codecpar->color_trc = color_trc;
- st->codecpar->color_space = color_matrix;
- } else if (!strncmp(color_parameter_type, "nclc", 4)) {
- /* color primaries, Table 4-4 */
- switch (color_primaries) {
- case 1: st->codecpar->color_primaries = AVCOL_PRI_BT709; break;
- case 5: st->codecpar->color_primaries = AVCOL_PRI_SMPTE170M; break;
- case 6: st->codecpar->color_primaries = AVCOL_PRI_SMPTE240M; break;
- }
- /* color transfer, Table 4-5 */
- switch (color_trc) {
- case 1: st->codecpar->color_trc = AVCOL_TRC_BT709; break;
- case 7: st->codecpar->color_trc = AVCOL_TRC_SMPTE240M; break;
- }
- /* color matrix, Table 4-6 */
- switch (color_matrix) {
- case 1: st->codecpar->color_space = AVCOL_SPC_BT709; break;
- case 6: st->codecpar->color_space = AVCOL_SPC_BT470BG; break;
- case 7: st->codecpar->color_space = AVCOL_SPC_SMPTE240M; break;
- }
}
+ if (color_primaries >= AVCOL_PRI_NB)
+ color_primaries = AVCOL_PRI_UNSPECIFIED;
+ if (color_trc >= AVCOL_TRC_NB)
+ color_trc = AVCOL_TRC_UNSPECIFIED;
+ if (color_matrix >= AVCOL_SPC_NB)
+ color_matrix = AVCOL_SPC_UNSPECIFIED;
+ st->codecpar->color_primaries = color_primaries;
+ st->codecpar->color_trc = color_trc;
+ st->codecpar->color_space = color_matrix;
av_log(c->fc, AV_LOG_TRACE, "\n");
return 0;