[Libva] [PATCH 5/5] Restrict the max MV number in MV prediction

yakui.zhao at intel.com yakui.zhao at intel.com
Mon Oct 29 23:50:36 PDT 2012


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

This is to follow the level limits for MV number for the two
consecutive MBs in H264 Spec.

Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
 src/gen6_vme.c                           | 17 ++++++++++++++++-
 src/gen6_vme.h                           |  1 +
 src/gen75_vme.c                          | 19 ++++++++++++++++++-
 src/shaders/vme/inter_frame.asm          |  4 +++-
 src/shaders/vme/inter_frame.g6b          |  3 ++-
 src/shaders/vme/inter_frame.g7b          |  3 ++-
 src/shaders/vme/inter_frame_haswell.asm  |  3 ++-
 src/shaders/vme/inter_frame_haswell.g75b |  2 +-
 8 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/src/gen6_vme.c b/src/gen6_vme.c
index 4504d5a..81f094b 100644
--- a/src/gen6_vme.c
+++ b/src/gen6_vme.c
@@ -316,10 +316,19 @@ static VAStatus gen6_vme_constant_setup(VADriverContextP ctx,
 {
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     // unsigned char *constant_buffer;
+    unsigned int *vme_state_message;
+    int mv_num = 32;
+    if (vme_context->h264_level >= 30) {
+	mv_num = 16;
+	if (vme_context->h264_level >= 31)
+		mv_num = 8;
+    } 
 
     dri_bo_map(vme_context->gpe_context.curbe.bo, 1);
     assert(vme_context->gpe_context.curbe.bo->virtual);
     // constant_buffer = vme_context->curbe.bo->virtual;
+    vme_state_message = (unsigned int *)vme_context->gpe_context.curbe.bo->virtual;
+    vme_state_message[31] = mv_num;
 	
     /*TODO copy buffer into CURB*/
 
@@ -567,7 +576,13 @@ static VAStatus gen6_vme_prepare(VADriverContextP ctx,
     VAStatus vaStatus = VA_STATUS_SUCCESS;
     VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer;
     int is_intra = pSliceParameter->slice_type == SLICE_TYPE_I;
-	
+    VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
+    struct gen6_vme_context *vme_context = encoder_context->vme_context;
+
+    if (!vme_context->h264_level ||
+		(vme_context->h264_level != pSequenceParameter->level_idc)) {
+	vme_context->h264_level = pSequenceParameter->level_idc;	
+    }	
     /*Setup all the memory object*/
     gen6_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
     gen6_vme_interface_setup(ctx, encode_state, encoder_context);
diff --git a/src/gen6_vme.h b/src/gen6_vme.h
index 3b66b25..e34c376 100644
--- a/src/gen6_vme.h
+++ b/src/gen6_vme.h
@@ -82,6 +82,7 @@ struct gen6_vme_context
                                             unsigned long binding_table_offset,
                                             unsigned long surface_state_offset);
     void *vme_state_message;
+    unsigned int h264_level;
 };
 
 Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
diff --git a/src/gen75_vme.c b/src/gen75_vme.c
index 79408dd..c0b021c 100644
--- a/src/gen75_vme.c
+++ b/src/gen75_vme.c
@@ -297,6 +297,16 @@ static VAStatus gen75_vme_constant_setup(VADriverContextP ctx,
 {
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     unsigned char *constant_buffer;
+    unsigned int *vme_state_message;
+    int mv_num = 32;
+
+    vme_state_message = (unsigned int *)vme_context->vme_state_message;
+    if (vme_context->h264_level >= 30) {
+	mv_num = 16;
+	if (vme_context->h264_level >= 31)
+		mv_num = 8;
+    } 
+    vme_state_message[31] = mv_num;
 
     dri_bo_map(vme_context->gpe_context.curbe.bo, 1);
     assert(vme_context->gpe_context.curbe.bo->virtual);
@@ -306,7 +316,7 @@ static VAStatus gen75_vme_constant_setup(VADriverContextP ctx,
 	/* Now it uses the fixed search path. So it is constructed directly
 	 * in the GPU shader.
 	 */
-    memcpy(constant_buffer, (char *)vme_context->vme_state_message, 32);
+    memcpy(constant_buffer, (char *)vme_context->vme_state_message, 128);
 	
     dri_bo_unmap( vme_context->gpe_context.curbe.bo);
 
@@ -550,6 +560,13 @@ static VAStatus gen75_vme_prepare(VADriverContextP ctx,
     VAStatus vaStatus = VA_STATUS_SUCCESS;
     VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer;
     int is_intra = pSliceParameter->slice_type == SLICE_TYPE_I;
+    VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
+    struct gen6_vme_context *vme_context = encoder_context->vme_context;
+
+    if (!vme_context->h264_level ||
+		(vme_context->h264_level != pSequenceParameter->level_idc)) {
+	vme_context->h264_level = pSequenceParameter->level_idc;	
+    }	
 	
     /*Setup all the memory object*/
     gen75_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
diff --git a/src/shaders/vme/inter_frame.asm b/src/shaders/vme/inter_frame.asm
index 24387cd..ce4bd11 100644
--- a/src/shaders/vme/inter_frame.asm
+++ b/src/shaders/vme/inter_frame.asm
@@ -50,7 +50,9 @@ mov  (1) vme_m0.20<1>:UB        thread_id_ub {align1};                  /* dispa
 mov  (1) vme_m0.22<1>:UW        REF_REGION_SIZE {align1};               /* Reference Width&Height, 32x32 */
 
 mov  (1) vme_m1.0<1>:UD         ADAPTIVE_SEARCH_ENABLE:ud {align1} ;
-mov  (1) vme_m1.4<1>:UD         FB_PRUNING_ENABLE + MAX_NUM_MV:UD {align1};                                   /* Default value MAX 32 MVs */
+mov  (1) vme_m1.4<1>:UD         FB_PRUNING_ENABLE:UD {align1};
+/* MV num is passed by constant buffer. R4.28 */
+mov  (1) vme_m1.4<1>:UB		r4.28<0,1,0>:UB {align1};
 mov  (1) vme_m1.8<1>:UD         START_CENTER + SEARCH_PATH_LEN:UD {align1};
 
 mul  (1) obw_m0.8<1>:UD         w_in_mb_uw<0,1,0>:UW orig_y_ub<0,1,0>:UB {align1};
diff --git a/src/shaders/vme/inter_frame.g6b b/src/shaders/vme/inter_frame.g6b
index c63f7d7..ea66788 100644
--- a/src/shaders/vme/inter_frame.g6b
+++ b/src/shaders/vme/inter_frame.g6b
@@ -18,7 +18,8 @@
    { 0x00000001, 0x24540231, 0x00000014, 0x00000000 },
    { 0x00000001, 0x24560169, 0x00000000, 0x28302830 },
    { 0x00000001, 0x24600061, 0x00000000, 0x00000002 },
-   { 0x00000001, 0x24640061, 0x00000000, 0x40000020 },
+   { 0x00000001, 0x24640061, 0x00000000, 0x40000000 },
+   { 0x00000001, 0x24640231, 0x0000009c, 0x00000000 },
    { 0x00000001, 0x24680061, 0x00000000, 0x30003030 },
    { 0x00000041, 0x24884521, 0x000000a2, 0x000000a1 },
    { 0x00000040, 0x24884421, 0x00000488, 0x000000a0 },
diff --git a/src/shaders/vme/inter_frame.g7b b/src/shaders/vme/inter_frame.g7b
index 5e738ca..4601ba8 100644
--- a/src/shaders/vme/inter_frame.g7b
+++ b/src/shaders/vme/inter_frame.g7b
@@ -17,7 +17,8 @@
    { 0x00000001, 0x24540231, 0x00000014, 0x00000000 },
    { 0x00000001, 0x24560169, 0x00000000, 0x28302830 },
    { 0x00000001, 0x24600061, 0x00000000, 0x00000002 },
-   { 0x00000001, 0x24640061, 0x00000000, 0x40000020 },
+   { 0x00000001, 0x24640061, 0x00000000, 0x40000000 },
+   { 0x00000001, 0x24640231, 0x0000009c, 0x00000000 },
    { 0x00000001, 0x24680061, 0x00000000, 0x30003030 },
    { 0x00000041, 0x24884521, 0x000000a2, 0x000000a1 },
    { 0x00000040, 0x24884421, 0x00000488, 0x000000a0 },
diff --git a/src/shaders/vme/inter_frame_haswell.asm b/src/shaders/vme/inter_frame_haswell.asm
index 8024b0b..80df800 100644
--- a/src/shaders/vme/inter_frame_haswell.asm
+++ b/src/shaders/vme/inter_frame_haswell.asm
@@ -193,7 +193,8 @@ mov  (1) vme_m0.4<1>:UD		vme_m0.0<0,1,0>:UD	{align1};
 mov  (8) vme_msg_0.0<1>:UD      vme_m0.0<8,8,1>:UD {align1};
 
 mov  (1) vme_m1.0<1>:UD         ADAPTIVE_SEARCH_ENABLE:ud {align1} ;
-mov  (1) vme_m1.4<1>:UD         MAX_NUM_MV:UD {align1};                                   /* Default value MAX 32 MVs */
+/* the Max MV number is passed by constant buffer */
+mov  (1) vme_m1.4<1>:UB         r4.28<0,1,0>:UB {align1};          
 mov  (1) vme_m1.8<1>:UD         START_CENTER + SEARCH_PATH_LEN:UD {align1};
 mov  (8) vme_msg_1.0<1>:UD      vme_m1.0<8,8,1>:UD {align1};
 
diff --git a/src/shaders/vme/inter_frame_haswell.g75b b/src/shaders/vme/inter_frame_haswell.g75b
index cc1da86..2e240b7 100644
--- a/src/shaders/vme/inter_frame_haswell.g75b
+++ b/src/shaders/vme/inter_frame_haswell.g75b
@@ -79,7 +79,7 @@
    { 0x00000001, 0x24440021, 0x00000440, 0x00000000 },
    { 0x00600001, 0x28000021, 0x008d0440, 0x00000000 },
    { 0x00000001, 0x24600061, 0x00000000, 0x00000002 },
-   { 0x00000001, 0x24640061, 0x00000000, 0x00000020 },
+   { 0x00000001, 0x24640231, 0x0000009c, 0x00000000 },
    { 0x00000001, 0x24680061, 0x00000000, 0x30003030 },
    { 0x00600001, 0x28200021, 0x008d0460, 0x00000000 },
    { 0x00600001, 0x28400021, 0x008d0560, 0x00000000 },
-- 
1.7.12-rc1



More information about the Libva mailing list