mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
cf7b0b5050
commit
a3cab3d433
|
@ -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)
|
||||
}
|
||||
if (color_primaries >= AVCOL_PRI_NB)
|
||||
color_primaries = AVCOL_PRI_UNSPECIFIED;
|
||||
if ((color_trc >= AVCOL_TRC_LINEAR &&
|
||||
color_trc <= AVCOL_TRC_LOG_SQRT) ||
|
||||
color_trc >= AVCOL_TRC_BT2020_10)
|
||||
if (color_trc >= AVCOL_TRC_NB)
|
||||
color_trc = AVCOL_TRC_UNSPECIFIED;
|
||||
if (color_matrix >= AVCOL_SPC_BT2020_NCL)
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
av_log(c->fc, AV_LOG_TRACE, "\n");
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue