Fix weight denom for implicit weight tables on SNB for encoding
authorXiang, Haihao <haihao.xiang@intel.com>
Wed, 30 May 2012 05:12:58 +0000 (13:12 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Wed, 30 May 2012 05:12:58 +0000 (13:12 +0800)
It is the same of commit fd9c532

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
src/gen6_mfc.c

index f5c04c6..7cb34fc 100644 (file)
@@ -358,6 +358,8 @@ gen6_mfc_avc_slice_state(VADriverContextP ctx,
     unsigned char correct[6], grow, shrink;
     int i;
     int weighted_pred_idc = 0;
+    unsigned int luma_log2_weight_denom = slice_param->luma_log2_weight_denom;
+    unsigned int chroma_log2_weight_denom = slice_param->chroma_log2_weight_denom;
 
     if (batch == NULL)
         batch = encoder_context->base.batch;
@@ -371,6 +373,12 @@ gen6_mfc_avc_slice_state(VADriverContextP ctx,
         weighted_pred_idc = pic_param->pic_fields.bits.weighted_pred_flag;
     } else if (slice_type == SLICE_TYPE_B) {
         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;
+        }
     }
 
     maxQpN = mfc_context->bit_rate_control_context[bit_rate_control_target].MaxQpNegModifier;
@@ -392,7 +400,10 @@ gen6_mfc_avc_slice_state(VADriverContextP ctx,
     if (slice_type == SLICE_TYPE_I) {
         OUT_BCS_BATCH(batch, 0);                       /*no reference frames and pred_weight_table*/
     } else {
-        OUT_BCS_BATCH(batch, 0x00010000);      /*1 reference frame*/
+        OUT_BCS_BATCH(batch,
+                      (1 << 16) |                      /*1 reference frame*/
+                      (chroma_log2_weight_denom << 8) |
+                      (luma_log2_weight_denom << 0));
     }
 
     OUT_BCS_BATCH(batch,