cbs_h265: Fix ranges of prediction weight offsets
authorMark Thompson <sw@jkqxz.net>
Mon, 28 Aug 2017 16:07:01 +0000 (17:07 +0100)
committerMark Thompson <sw@jkqxz.net>
Tue, 12 Sep 2017 21:11:55 +0000 (22:11 +0100)
The bracketing was wrong - '-' binds before '<<'.  This would
previously incorrectly reject the streams in the WP_A and WP_B
conformance tests.

libavcodec/cbs_h265_syntax_template.c

index 8564220..a194887 100644 (file)
@@ -1133,7 +1133,7 @@ static int FUNC(pred_weight_table)(CodedBitstreamContext *ctx, RWContext *rw,
             se(delta_luma_weight_l0[i], -128, +127);
             se(luma_offset_l0[i],
                -(1 << (sps->bit_depth_luma_minus8 + 8 - 1)),
             se(delta_luma_weight_l0[i], -128, +127);
             se(luma_offset_l0[i],
                -(1 << (sps->bit_depth_luma_minus8 + 8 - 1)),
-               +(1 << (sps->bit_depth_luma_minus8 + 8 - 1) - 1));
+               ((1 << (sps->bit_depth_luma_minus8 + 8 - 1)) - 1));
         } else {
             infer(delta_luma_weight_l0[i], 0);
             infer(luma_offset_l0[i],       0);
         } else {
             infer(delta_luma_weight_l0[i], 0);
             infer(luma_offset_l0[i],       0);
@@ -1143,7 +1143,7 @@ static int FUNC(pred_weight_table)(CodedBitstreamContext *ctx, RWContext *rw,
                 se(delta_chroma_weight_l0[i][j], -128, +127);
                 se(chroma_offset_l0[i][j],
                    -(4 << (sps->bit_depth_chroma_minus8 + 8 - 1)),
                 se(delta_chroma_weight_l0[i][j], -128, +127);
                 se(chroma_offset_l0[i][j],
                    -(4 << (sps->bit_depth_chroma_minus8 + 8 - 1)),
-                   +(4 << (sps->bit_depth_chroma_minus8 + 8 - 1) - 1));
+                   ((4 << (sps->bit_depth_chroma_minus8 + 8 - 1)) - 1));
             }
         } else {
             for (j = 0; j < 2; j++) {
             }
         } else {
             for (j = 0; j < 2; j++) {
@@ -1173,8 +1173,8 @@ static int FUNC(pred_weight_table)(CodedBitstreamContext *ctx, RWContext *rw,
             if (current->luma_weight_l1_flag[i]) {
                 se(delta_luma_weight_l1[i], -128, +127);
                 se(luma_offset_l1[i],
             if (current->luma_weight_l1_flag[i]) {
                 se(delta_luma_weight_l1[i], -128, +127);
                 se(luma_offset_l1[i],
-                   - 1 << (sps->bit_depth_luma_minus8 + 8 - 1),
-                   + 1 << (sps->bit_depth_luma_minus8 + 8 - 1) - 1);
+                   -(1 << (sps->bit_depth_luma_minus8 + 8 - 1)),
+                   ((1 << (sps->bit_depth_luma_minus8 + 8 - 1)) - 1));
             } else {
                 infer(delta_luma_weight_l1[i], 0);
                 infer(luma_offset_l1[i],       0);
             } else {
                 infer(delta_luma_weight_l1[i], 0);
                 infer(luma_offset_l1[i],       0);
@@ -1183,8 +1183,8 @@ static int FUNC(pred_weight_table)(CodedBitstreamContext *ctx, RWContext *rw,
                 for (j = 0; j < 2; j++) {
                     se(delta_chroma_weight_l1[i][j], -128, +127);
                     se(chroma_offset_l1[i][j],
                 for (j = 0; j < 2; j++) {
                     se(delta_chroma_weight_l1[i][j], -128, +127);
                     se(chroma_offset_l1[i][j],
-                       - 4 << (sps->bit_depth_chroma_minus8 + 8 - 1),
-                       + 4 << (sps->bit_depth_chroma_minus8 + 8 - 1) - 1);
+                       -(4 << (sps->bit_depth_chroma_minus8 + 8 - 1)),
+                       ((4 << (sps->bit_depth_chroma_minus8 + 8 - 1)) - 1));
                 }
             } else {
                 for (j = 0; j < 2; j++) {
                 }
             } else {
                 for (j = 0; j < 2; j++) {