diff mbox series

[FFmpeg-devel] libavcodec/h264: always set color description fields

Message ID 7c8ed096-18a6-e3b5-ce52-b9990485ad61@gmail.com
State New
Headers show
Series [FFmpeg-devel] libavcodec/h264: always set color description fields
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Xiaolei Yu Nov. 24, 2021, 7:10 a.m. UTC
Color description fields shall be inferred to be UNSPECIFIED if not present.
---
 libavcodec/h264_ps.c    |  4 +++-
 libavcodec/h264_slice.c | 18 +++++++-----------
 2 files changed, 10 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index e21c2b56ac..164e6ea0cc 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -378,7 +378,9 @@  int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
     memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
     memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
     sps->scaling_matrix_present = 0;
-    sps->colorspace = 2; //AVCOL_SPC_UNSPECIFIED
+    sps->colorspace = AVCOL_SPC_UNSPECIFIED;
+    sps->color_trc = AVCOL_TRC_UNSPECIFIED;
+    sps->color_primaries = AVCOL_PRI_UNSPECIFIED;
 
     if (sps->profile_idc == 100 ||  // High profile
         sps->profile_idc == 110 ||  // High10 profile
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 89ea16a57f..b7f1dfc9ef 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1103,17 +1103,13 @@  static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
 
         init_dimensions(h);
 
-        if (sps->video_signal_type_present_flag) {
-            h->avctx->color_range = sps->full_range > 0 ? AVCOL_RANGE_JPEG
-                                                        : AVCOL_RANGE_MPEG;
-            if (sps->colour_description_present_flag) {
-                if (h->avctx->colorspace != sps->colorspace)
-                    needs_reinit = 1;
-                h->avctx->color_primaries = sps->color_primaries;
-                h->avctx->color_trc       = sps->color_trc;
-                h->avctx->colorspace      = sps->colorspace;
-            }
-        }
+        h->avctx->color_range = sps->full_range > 0 ? AVCOL_RANGE_JPEG
+                                                    : AVCOL_RANGE_MPEG;
+        if (h->avctx->colorspace != sps->colorspace)
+            needs_reinit = 1;
+        h->avctx->color_primaries = sps->color_primaries;
+        h->avctx->color_trc       = sps->color_trc;
+        h->avctx->colorspace      = sps->colorspace;
 
         if (h->sei.alternative_transfer.present &&
             av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) &&