[Libva] [PATCH 2/2] h264: fix weight denom for implicit weight tables (SNB).

Gwenole Beauchesne gb.devel at gmail.com
Tue Mar 13 11:54:25 PDT 2012


If weighted_bipred_idc == 2, luma and chroma weight denom (in log2 base)
shall be set to the default value on Sandy Bridge. i.e. 5 as per defined
at 8-279 in AVC specs.

https://bugs.freedesktop.org/show_bug.cgi?id=40820

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
---
 src/gen6_mfd.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c
index c6fe1d2..82cf544 100644
--- a/src/gen6_mfd.c
+++ b/src/gen6_mfd.c
@@ -682,6 +682,7 @@ gen6_mfd_avc_slice_state(VADriverContextP ctx,
                          pic_param->seq_fields.bits.mb_adaptive_frame_field_flag);
     int weighted_pred_idc = 0;
     int first_mb_in_slice = 0, first_mb_in_next_slice = 0;
+    unsigned int chroma_log2_weight_denom, luma_log2_weight_denom;
     int slice_type;
 
     if (slice_param->slice_type == SLICE_TYPE_I ||
@@ -695,6 +696,9 @@ gen6_mfd_avc_slice_state(VADriverContextP ctx,
         slice_type = SLICE_TYPE_B;
     }
 
+    luma_log2_weight_denom   = slice_param->luma_log2_weight_denom;
+    chroma_log2_weight_denom = slice_param->chroma_log2_weight_denom;
+
     if (slice_type == SLICE_TYPE_I) {
         assert(slice_param->num_ref_idx_l0_active_minus1 == 0);
         assert(slice_param->num_ref_idx_l1_active_minus1 == 0);
@@ -709,6 +713,12 @@ gen6_mfd_avc_slice_state(VADriverContextP ctx,
         num_ref_idx_l0 = slice_param->num_ref_idx_l0_active_minus1 + 1;
         num_ref_idx_l1 = slice_param->num_ref_idx_l1_active_minus1 + 1;
         weighted_pred_idc = pic_param->pic_fields.bits.weighted_bipred_idc;
+
+        if (weighted_pred_idc == 2) {
+            /* 8.4.3 - Derivation process for prediction weights (8-279) */
+            luma_log2_weight_denom   = 5;
+            chroma_log2_weight_denom = 5;
+        }
     }
 
     first_mb_in_slice = slice_param->first_mb_in_slice << mbaff_picture;
@@ -730,8 +740,8 @@ gen6_mfd_avc_slice_state(VADriverContextP ctx,
     OUT_BCS_BATCH(batch, 
                   (num_ref_idx_l1 << 24) |
                   (num_ref_idx_l0 << 16) |
-                  (slice_param->chroma_log2_weight_denom << 8) |
-                  (slice_param->luma_log2_weight_denom << 0));
+                  (chroma_log2_weight_denom << 8) |
+                  (luma_log2_weight_denom << 0));
     OUT_BCS_BATCH(batch, 
                   (weighted_pred_idc << 30) |
                   (slice_param->direct_spatial_mv_pred_flag << 29) |
-- 
1.7.5.4



More information about the Libva mailing list