[Libva] [PATCH] VP8 HWEnc: Init CBR QP at begining of gen8_mfc_vp8_init

Zhong Li zhong.li at intel.com
Fri May 22 00:20:30 PDT 2015


Initialize CBR QP at begining of gen8_mfc_vp8_init(), because this
funtion will use qp to init prob_skip_false.

Signed-off-by: Zhong Li <zhong.li at intel.com>
---
 src/gen8_mfc.c           | 13 +++++++++++++
 src/i965_encoder_utils.c | 11 -----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/gen8_mfc.c b/src/gen8_mfc.c
index 0398323..d46f17a 100644
--- a/src/gen8_mfc.c
+++ b/src/gen8_mfc.c
@@ -3619,6 +3619,7 @@ static void gen8_mfc_vp8_init(VADriverContextP ctx,
     int width_in_mbs = 0;
     int height_in_mbs = 0;
     int slice_batchbuffer_size;
+    int is_key_frame, slice_type, rate_control_mode;
 
     VAEncSequenceParameterBufferVP8 *pSequenceParameter = (VAEncSequenceParameterBufferVP8 *)encode_state->seq_param_ext->buffer;
     VAEncPictureParameterBufferVP8 *pic_param = (VAEncPictureParameterBufferVP8 *)encode_state->pic_param_ext->buffer;
@@ -3627,6 +3628,18 @@ static void gen8_mfc_vp8_init(VADriverContextP ctx,
     width_in_mbs = ALIGN(pSequenceParameter->frame_height, 16) / 16;
     height_in_mbs = ALIGN(pSequenceParameter->frame_height, 16) / 16;
 
+    is_key_frame = !pic_param->pic_flags.bits.frame_type;
+    slice_type = (is_key_frame ? SLICE_TYPE_I : SLICE_TYPE_P);
+    rate_control_mode = encoder_context->rate_control_mode;
+
+    if (rate_control_mode == VA_RC_CBR) {
+        q_matrix->quantization_index[0] = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        for (i = 1; i < 4; i++)
+            q_matrix->quantization_index[i] = q_matrix->quantization_index[0];
+        for (i = 0; i < 5; i++)
+            q_matrix->quantization_index_delta[i] = 0;
+    }
+
     slice_batchbuffer_size = 64 * width_in_mbs * height_in_mbs + 4096 +
         (SLICE_HEADER + SLICE_TAIL);
 
diff --git a/src/i965_encoder_utils.c b/src/i965_encoder_utils.c
index 19b2b0b..b9d79f0 100644
--- a/src/i965_encoder_utils.c
+++ b/src/i965_encoder_utils.c
@@ -602,17 +602,6 @@ void binarize_vp8_frame_header(VAEncSequenceParameterBufferVP8 *seq_param,
     int i, j;
     int is_intra_frame = !pic_param->pic_flags.bits.frame_type;
     int log2num = pic_param->pic_flags.bits.num_token_partitions;
-    int is_key_frame = !pic_param->pic_flags.bits.frame_type;
-    int slice_type = (is_key_frame ? SLICE_TYPE_I : SLICE_TYPE_P);
-    unsigned int rate_control_mode = encoder_context->rate_control_mode;
-
-    if (rate_control_mode == VA_RC_CBR) {
-        q_matrix->quantization_index[0] = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
-        for (i = 1; i < 4; i++)
-            q_matrix->quantization_index[i] = q_matrix->quantization_index[0];  
-        for (i = 0; i < 5; i++)
-            q_matrix->quantization_index_delta[i] = 0;
-    }
 
     /* modify picture paramters */
     pic_param->pic_flags.bits.loop_filter_adj_enable = 1;
-- 
1.9.1



More information about the Libva mailing list