Browse code

avcodec/dnxhddec: Do not overwrite colorspace if the container has set it.

The existing logic overrides container metadata even in cases where the
container metadata must be trusted (e.g. HDR). The original spec had no
provision for specifying color volume, so many files rely on the
assumption of Rec. 709.

An update to the spec included a 'clv' field for explicitly signaling
that the container should be trusted in an existing bitfield in the
frame header, but the default of 0 from old encoders forces Rec. 709,
which would break any HDR stream. Because there is no place in DNxHR for
specifying a transfer function, DNxHR HDR files must include
container-level color information.

This patch maintains the existing behavior of choosing the 709 over the
601 matrix when container-level information is missing, and allows
container-level information to win if present.

Signed-off-by: Steven Robertson <steven@strobe.cc>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Steven Robertson authored on 2017/11/29 09:49:46
Showing 1 changed files
... ...
@@ -93,7 +93,9 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
93 93
 
94 94
     ctx->avctx = avctx;
95 95
     ctx->cid = -1;
96
-    avctx->colorspace = AVCOL_SPC_BT709;
96
+    if (avctx->colorspace == AVCOL_SPC_UNSPECIFIED) {
97
+        avctx->colorspace = AVCOL_SPC_BT709;
98
+    }
97 99
 
98 100
     avctx->coded_width  = FFALIGN(avctx->width,  16);
99 101
     avctx->coded_height = FFALIGN(avctx->height, 16);