avcodec/utils/ff_init_buffer_info: Favor color information from AVFrame if available
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 3 Jun 2014 02:50:07 +0000 (04:50 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 3 Jun 2014 03:13:51 +0000 (05:13 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/utils.c

index e1301b0..565e2ff 100644 (file)
@@ -786,13 +786,16 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
     frame->reordered_opaque = avctx->reordered_opaque;
 
 #if FF_API_AVFRAME_COLORSPACE
-    frame->color_primaries = avctx->color_primaries;
-    frame->color_trc       = avctx->color_trc;
+    if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED)
+        frame->color_primaries = avctx->color_primaries;
+    if (frame->color_trc == AVCOL_TRC_UNSPECIFIED)
+        frame->color_trc = avctx->color_trc;
     if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED)
         av_frame_set_colorspace(frame, avctx->colorspace);
     if (av_frame_get_color_range(frame) == AVCOL_RANGE_UNSPECIFIED)
         av_frame_set_color_range(frame, avctx->color_range);
-    frame->chroma_location = avctx->chroma_sample_location;
+    if (frame->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
+        frame->chroma_location = avctx->chroma_sample_location;
 #endif
 
     switch (avctx->codec->type) {