[Libva] [PATCH] MPEG2ENC: Initialize the f_code based on supported level instead of hacked setting

yakui.zhao at intel.com yakui.zhao at intel.com
Thu Jul 4 19:46:25 PDT 2013


From: Zhao Yakui <yakui.zhao at intel.com>

The f_code of MPEG2 picture parameter indicates the max search range of the
motion vector prediction. The small value will cause the unoptimized motion
vector prediction. So remove the hack setting.

Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
 test/encode/mpeg2enc.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/test/encode/mpeg2enc.c b/test/encode/mpeg2enc.c
index 4e1776d..f49af27 100644
--- a/test/encode/mpeg2enc.c
+++ b/test/encode/mpeg2enc.c
@@ -1012,6 +1012,7 @@ mpeg2enc_update_picture_parameter(struct mpeg2enc_context *ctx,
                                   int display_order)
 {
     VAEncPictureParameterBufferMPEG2 *pic_param = &ctx->pic_param;
+    uint8_t f_code_x, f_code_y;
 
     pic_param->picture_type = picture_type;
     pic_param->temporal_reference = (display_order - ctx->gop_header_in_display_order) & 0x3FF;
@@ -1019,6 +1020,21 @@ mpeg2enc_update_picture_parameter(struct mpeg2enc_context *ctx,
     pic_param->forward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L0];
     pic_param->backward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L1];
 
+    f_code_x = 0xf;
+    f_code_y = 0xf;
+    if (pic_param->picture_type != VAEncPictureTypeIntra) {
+	if (ctx->level == MPEG2_LEVEL_LOW) {
+		f_code_x = 7;
+		f_code_y = 4;
+	} else if (ctx->level == MPEG2_LEVEL_MAIN) {
+		f_code_x = 8;
+		f_code_y = 5;
+	} else {
+		f_code_x = 9;
+		f_code_y = 5;
+	}
+    }
+    
     if (pic_param->picture_type == VAEncPictureTypeIntra) {
         pic_param->f_code[0][0] = 0xf;
         pic_param->f_code[0][1] = 0xf;
@@ -1028,17 +1044,17 @@ mpeg2enc_update_picture_parameter(struct mpeg2enc_context *ctx,
         pic_param->backward_reference_picture = VA_INVALID_SURFACE;
 
     } else if (pic_param->picture_type == VAEncPictureTypePredictive) {
-        pic_param->f_code[0][0] = 0x1;
-        pic_param->f_code[0][1] = 0x1;
+        pic_param->f_code[0][0] = f_code_x;
+        pic_param->f_code[0][1] = f_code_y;
         pic_param->f_code[1][0] = 0xf;
         pic_param->f_code[1][1] = 0xf;
         pic_param->forward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L0];
         pic_param->backward_reference_picture = VA_INVALID_SURFACE;
     } else if (pic_param->picture_type == VAEncPictureTypeBidirectional) {
-        pic_param->f_code[0][0] = 0x1;
-        pic_param->f_code[0][1] = 0x1;
-        pic_param->f_code[1][0] = 0x1;
-        pic_param->f_code[1][1] = 0x1;
+        pic_param->f_code[0][0] = f_code_x;
+        pic_param->f_code[0][1] = f_code_y;
+        pic_param->f_code[1][0] = f_code_x;
+        pic_param->f_code[1][1] = f_code_y;
         pic_param->forward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L0];
         pic_param->backward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L1];
     } else {
-- 
1.8.2-rc2



More information about the Libva mailing list