codecs: gstvp9statefulparser: feature_data should be 0 if feature_enable is 0
authorDaniel Almeida <daniel.almeida@collabora.com>
Thu, 29 Jul 2021 15:20:30 +0000 (12:20 -0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 9 Sep 2021 18:32:42 +0000 (18:32 +0000)
The spec says in 6.2.11 that feature_data[i][j] should be zero if
feature_enabled[i][j] is zero. Instead we retained the old value in the parser.
Fix it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2449>

gst-libs/gst/codecs/gstvp9statefulparser.c

index 099699b..6289c3f 100644 (file)
@@ -727,12 +727,18 @@ parse_segmentation_params (GstBitReader * br, GstVp9SegmentationParams * params)
 
     for (i = 0; i < GST_VP9_MAX_SEGMENTS; i++) {
       VP9_READ_BIT (params->feature_enabled[i][GST_VP9_SEG_LVL_ALT_Q]);
-      if (params->feature_enabled[i][GST_VP9_SEG_LVL_ALT_Q])
+      if (params->feature_enabled[i][GST_VP9_SEG_LVL_ALT_Q]) {
         VP9_READ_SIGNED_16 (params->feature_data[i][GST_VP9_SEG_LVL_ALT_Q], 8);
+      } else {
+        params->feature_data[i][GST_VP9_SEG_LVL_ALT_Q] = 0;
+      }
 
       VP9_READ_BIT (params->feature_enabled[i][GST_VP9_SEG_LVL_ALT_L]);
-      if (params->feature_enabled[i][GST_VP9_SEG_LVL_ALT_L])
+      if (params->feature_enabled[i][GST_VP9_SEG_LVL_ALT_L]) {
         VP9_READ_SIGNED_8 (params->feature_data[i][GST_VP9_SEG_LVL_ALT_L], 6);
+      } else {
+        params->feature_data[i][GST_VP9_SEG_LVL_ALT_L] = 0;
+      }
 
       VP9_READ_BIT (params->feature_enabled[i][GST_VP9_SEG_LVL_REF_FRAME]);
       if (params->feature_enabled[i][GST_VP9_SEG_LVL_REF_FRAME]) {
@@ -740,6 +746,8 @@ parse_segmentation_params (GstBitReader * br, GstVp9SegmentationParams * params)
 
         VP9_READ_UINT8 (val, 2);
         params->feature_data[i][GST_VP9_SEG_LVL_REF_FRAME] = val;
+      } else {
+        params->feature_data[i][GST_VP9_SEG_LVL_REF_FRAME] = 0;
       }
 
       VP9_READ_BIT (params->feature_enabled[i][GST_VP9_SEG_SEG_LVL_SKIP]);