Restrict the MV search range based on MPEG2 encoding LEVEL
authorZhao Yakui <yakui.zhao@intel.com>
Mon, 12 Aug 2013 07:13:23 +0000 (15:13 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 6 Sep 2013 07:31:36 +0000 (15:31 +0800)
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit c05073b1f8764271ccf4fe1aa037f881dedd3818)

src/gen6_mfc_common.c
src/gen6_vme.h
src/gen75_vme.c
src/shaders/vme/mpeg2_inter_haswell.asm
src/shaders/vme/mpeg2_inter_haswell.g75b

index b77916d..1079044 100644 (file)
@@ -1122,6 +1122,24 @@ void intel_vme_mpeg2_state_setup(VADriverContextP ctx,
        VAEncSequenceParameterBufferMPEG2 *seq_param = (VAEncSequenceParameterBufferMPEG2 *)encode_state->seq_param_ext->buffer;
        int width_in_mbs = ALIGN(seq_param->picture_width, 16) / 16;
        int height_in_mbs = ALIGN(seq_param->picture_height, 16) / 16;
+       uint32_t mv_x, mv_y;
+
+       if (vme_context->mpeg2_level == MPEG2_LEVEL_LOW) {
+               mv_x = 512;
+               mv_y = 64;
+       } else if (vme_context->mpeg2_level == MPEG2_LEVEL_MAIN) {
+               mv_x = 1024;
+               mv_y = 128;
+       } else if (vme_context->mpeg2_level == MPEG2_LEVEL_HIGH) {
+               mv_x = 2048;
+               mv_y = 128;
+       } else {
+               WARN_ONCE("Incorrect Mpeg2 level setting!\n");
+               mv_x = 512;
+               mv_y = 64;
+       }
+
+       vme_state_message[MPEG2_MV_RANGE] = (mv_y << 16) | (mv_x);
 
        vme_state_message[MPEG2_PIC_WIDTH_HEIGHT] = (height_in_mbs << 16) |
                                        width_in_mbs;
index 9d7acdf..ab0ff3b 100644 (file)
@@ -85,9 +85,15 @@ struct gen6_vme_context
     unsigned int h264_level;
     unsigned int video_coding_type;
     unsigned int vme_kernel_sum;
+    unsigned int mpeg2_level;
 };
 
 #define MPEG2_PIC_WIDTH_HEIGHT 30
+#define        MPEG2_MV_RANGE          29
+#define        MPEG2_LEVEL_MASK        0x0f
+#define        MPEG2_LEVEL_LOW         0x0a
+#define        MPEG2_LEVEL_MAIN        0x08
+#define        MPEG2_LEVEL_HIGH        0x04
 
 
 Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
index 41b8564..3935528 100644 (file)
@@ -948,6 +948,14 @@ gen75_vme_mpeg2_prepare(VADriverContextP ctx,
     VAStatus vaStatus = VA_STATUS_SUCCESS;
     VAEncSliceParameterBufferMPEG2 *slice_param = (VAEncSliceParameterBufferMPEG2 *)encode_state->slice_params_ext[0]->buffer;
        
+    VAEncSequenceParameterBufferMPEG2 *seq_param = (VAEncSequenceParameterBufferMPEG2 *)encode_state->seq_param_ext->buffer;
+    struct gen6_vme_context *vme_context = encoder_context->vme_context;
+
+    if ((!vme_context->mpeg2_level) ||
+               (vme_context->mpeg2_level != (seq_param->sequence_extension.bits.profile_and_level_indication & MPEG2_LEVEL_MASK))) {
+       vme_context->mpeg2_level = seq_param->sequence_extension.bits.profile_and_level_indication & MPEG2_LEVEL_MASK;
+    }
+
     /*Setup all the memory object*/
     gen75_vme_mpeg2_surface_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
     gen75_vme_interface_setup(ctx, encode_state, encoder_context);
index 17e4843..bd41a90 100644 (file)
@@ -670,6 +670,21 @@ add  (2) TEMP_VAR0.0<1>:w  INPUT_ARG0.8<2,2,1>:w   INPUT_ARG0.0<2,2,1>:w   {align1};
 /* The right/bottom coordinate of reference window */
 add  (1) TEMP_VAR0.16<1>:w     TEMP_VAR0.0<0,1,0>:w    48:w                    {align1};
 add  (1) TEMP_VAR0.18<1>:w     TEMP_VAR0.2<0,1,0>:w    40:w                    {align1};
+
+/* Firstly the MV range is checked */
+mul  (2) TEMP_VAR1.16<1>:w     INPUT_ARG1.16<2,2,1>:w  -1:w    {align1};
+add  (2) TEMP_VAR1.0<1>:w      INPUT_ARG0.8<2,2,1>:w   TEMP_VAR1.16<2,2,1>:w   {align1};
+add  (2) TEMP_VAR1.4<1>:w      INPUT_ARG0.8<2,2,1>:w   INPUT_ARG1.16<2,2,1>:w  {align1};
+
+cmp.l.f0.0 (1) null:w  TEMP_VAR0.0<0,1,0>:w    TEMP_VAR1.0<0,1,0>:w    {align1};
+(f0.0) mov     (1) TEMP_VAR0.0<1>:w    TEMP_VAR1.0<0,1,0>:w    {align1};
+cmp.g.f0.0 (1) null:w  TEMP_VAR0.16<0,1,0>:w   TEMP_VAR1.4<0,1,0>:w    {align1};
+(f0.0) add     (1) TEMP_VAR0.0<1>:w    TEMP_VAR1.4<0,1,0>:w    -48:w   {align1};
+cmp.l.f0.0 (1) null:w  TEMP_VAR0.2<0,1,0>:w    TEMP_VAR1.2<0,1,0>:w    {align1};
+(f0.0) mov     (1) TEMP_VAR0.2<1>:w    TEMP_VAR1.2<0,1,0>:w    {align1};
+cmp.g.f0.0 (1) null:w  TEMP_VAR0.18<0,1,0>:w   TEMP_VAR1.6<0,1,0>:w    {align1};
+(f0.0) add     (1) TEMP_VAR0.2<1>:w    TEMP_VAR1.6<0,1,0>:w    -40:w   {align1};
+
 x_left_cmp:
        cmp.l.f0.0 (1)          null:w          TEMP_VAR0.0<0,1,0>:w    0:w     {align1};
        (-f0.0) jmpi    (1)     x_right_cmp;
index b3e67e7..cdaeb4c 100644 (file)
    { 0x00200040, 0x2f6035ad, 0x00450fa8, 0x00450fa0 },
    { 0x00000040, 0x2f703dad, 0x00000f60, 0x00300030 },
    { 0x00000040, 0x2f723dad, 0x00000f62, 0x00280028 },
+   { 0x00200041, 0x2f903dad, 0x00450fd0, 0xffffffff },
+   { 0x00200040, 0x2f8035ad, 0x00450fa8, 0x00450f90 },
+   { 0x00200040, 0x2f8435ad, 0x00450fa8, 0x00450fd0 },
+   { 0x05000010, 0x200035ac, 0x00000f60, 0x00000f80 },
+   { 0x00010001, 0x2f6001ad, 0x00000f80, 0x00000000 },
+   { 0x03000010, 0x200035ac, 0x00000f70, 0x00000f84 },
+   { 0x00010040, 0x2f603dad, 0x00000f84, 0xffd0ffd0 },
+   { 0x05000010, 0x200035ac, 0x00000f62, 0x00000f82 },
+   { 0x00010001, 0x2f6201ad, 0x00000f82, 0x00000000 },
+   { 0x03000010, 0x200035ac, 0x00000f72, 0x00000f86 },
+   { 0x00010040, 0x2f623dad, 0x00000f86, 0xffd8ffd8 },
    { 0x05000010, 0x20003dac, 0x00000f60, 0x00000000 },
    { 0x00110020, 0x34001c00, 0x00001400, 0x00000020 },
    { 0x00010001, 0x2f6001ed, 0x00000000, 0x00000000 },