[Libva] [PATCH v2 7/8] Enabling BDW avc encoding configuration

Zhong Li zhong.li at intel.com
Thu Aug 7 21:05:42 PDT 2014


Signed-off-by: Zhong Li <zhong.li at intel.com>
---
 src/gen8_vme.c                       |   21 ++++++++------
 src/shaders/vme/inter_frame_gen8.asm |   51 ++++++++++++++++++++++++++++------
 src/shaders/vme/inter_frame_gen8.g8b |   39 ++++++++++++++++++++++----
 src/shaders/vme/vme8.inc             |    8 +++++-
 4 files changed, 95 insertions(+), 24 deletions(-)

diff --git a/src/gen8_vme.c b/src/gen8_vme.c
index 34a3b68..8cae2a0 100644
--- a/src/gen8_vme.c
+++ b/src/gen8_vme.c
@@ -557,7 +557,7 @@ gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx,
    
             /*inline data */
             *command_ptr++ = (mb_width << 16 | mb_y << 8 | mb_x);
-            *command_ptr++ = ( (1 << 16) | transform_8x8_mode_flag | (mb_intra_ub << 8));
+            *command_ptr++ = ((encoder_context->quality_level << 24) | (1 << 16) | transform_8x8_mode_flag | (mb_intra_ub << 8));
 
             *command_ptr++ = CMD_MEDIA_STATE_FLUSH;
             *command_ptr++ = 0;
@@ -603,13 +603,18 @@ static void gen8_vme_pipeline_programing(VADriverContextP ctx,
     int kernel_shader;
     bool allow_hwscore = true;
     int s;
-
-    for (s = 0; s < encode_state->num_slice_params_ext; s++) {
-        pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[s]->buffer; 
-        if ((pSliceParameter->macroblock_address % width_in_mbs)) {
-            allow_hwscore = false;
-            break;
-	}
+    unsigned int is_low_quality = (encoder_context->quality_level == ENCODER_LOW_QUALITY);
+
+    if (is_low_quality)
+        allow_hwscore = false;
+    else {
+        for (s = 0; s < encode_state->num_slice_params_ext; s++) {
+            pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[s]->buffer; 
+            if ((pSliceParameter->macroblock_address % width_in_mbs)) {
+                allow_hwscore = false;
+                break;
+            }
+        }
     }
 
     if ((pSliceParameter->slice_type == SLICE_TYPE_I) ||
diff --git a/src/shaders/vme/inter_frame_gen8.asm b/src/shaders/vme/inter_frame_gen8.asm
index 7db5fa6..991d903 100644
--- a/src/shaders/vme/inter_frame_gen8.asm
+++ b/src/shaders/vme/inter_frame_gen8.asm
@@ -479,24 +479,57 @@ send (16)
         {align1};
 
 /* IME search */
+cmp.z.f0.0 (1)		null<1>:uw	quality_level_ub<0,1,0>:ub		LOW_QUALITY_LEVEL:uw   {align1};
+(f0.0) jmpi (1) __low_quality_search;
+
+__high_quality_search:
+/* M3/M4 search path */
+mov  (1) vme_msg_3.0<1>:UD	0x01010101:UD {align1};
+mov  (1) vme_msg_3.4<1>:UD	0x10010101:UD {align1};
+mov  (1) vme_msg_3.8<1>:UD	0x0F0F0F0F:UD {align1};
+mov  (1) vme_msg_3.12<1>:UD	0x100F0F0F:UD {align1};
+mov  (1) vme_msg_3.16<1>:UD	0x01010101:UD {align1};
+mov  (1) vme_msg_3.20<1>:UD	0x10010101:UD {align1};
+mov  (1) vme_msg_3.24<1>:UD	0x0F0F0F0F:UD {align1};
+mov  (1) vme_msg_3.28<1>:UD	0x100F0F0F:UD {align1};
+mov  (1) vme_msg_4.0<1>:UD	0x01010101:UD {align1};
+mov  (1) vme_msg_4.4<1>:UD	0x10010101:UD {align1};
+mov  (1) vme_msg_4.8<1>:UD	0x0F0F0F0F:UD {align1};
+mov  (1) vme_msg_4.12<1>:UD	0x000F0F0F:UD {align1};
+mov  (4) vme_msg_4.16<1>:UD	0x0:UD {align1};
+
 mov  (1) vme_m0.12<1>:UD        SEARCH_CTRL_SINGLE + INTER_PART_MASK + INTER_SAD_HAAR:UD {align1};    /* 16x16 Source, harr */
 mov  (1) vme_m0.22<1>:UW        REF_REGION_SIZE {align1};         /* Reference Width&Height, 48x40 */
-
-mov  (1) vme_m0.0<1>:UD		vme_m0.8<0,1,0>:UD      {align1};
-
-add  (1) vme_m0.0<1>:W          vme_m0.0<0,1,0>:W -16:W {align1};		/* Reference = (x-16,y-12)-(x+32,y+28) */
-add  (1) vme_m0.2<1>:W          vme_m0.2<0,1,0>:W -12:W {align1};
-
 mov  (1) vme_m0.0<1>:W		-16:W			{align1};
 mov  (1) vme_m0.2<1>:W		-12:W			{align1};
 
-mov  (1) vme_m0.4<1>:UD		vme_m0.0<0,1,0>:UD	{align1};
-
 and.z.f0.0 (1)		null:uw	input_mb_intra_ub<0,1,0>:ub	INTRA_PRED_AVAIL_FLAG_AE:uw   {align1};
 (f0.0)	add 	(1)	vme_m0.0<1>:w	vme_m0.0<0,1,0>:w	12:w	{align1};
 and.z.f0.0 (1)		null:uw	input_mb_intra_ub<0,1,0>:ub	INTRA_PRED_AVAIL_FLAG_B:uw   {align1};
 (f0.0)	add 	(1)	vme_m0.2<1>:w	vme_m0.2<0,1,0>:w	8:w	{align1};
- 
+jmpi (1) __vme_msg;
+
+__low_quality_search:
+/* M3/M4 search path */
+mov  (1) vme_msg_3.0<1>:UD	0x10010101:UD {align1};
+mov  (1) vme_msg_3.4<1>:UD	0x100F0F0F:UD {align1};
+mov  (1) vme_msg_3.8<1>:UD	0x10010101:UD {align1};
+mov  (1) vme_msg_3.12<1>:UD	0x000F0F0F:UD {align1};
+mov  (4) vme_msg_3.16<1>:UD	0x0:UD {align1};
+mov  (8) vme_msg_4.16<1>:UD	0x0:UD {align1};
+
+mov  (1) vme_m0.12<1>:UD        SEARCH_CTRL_SINGLE + INTER_PART_MASK + INTER_SAD_HAAR:UD {align1};    /* 16x16 Source, harr */
+mov  (1) vme_m0.22<1>:UW        MIN_REF_REGION_SIZE {align1};         /* Reference Width&Height, 32x32 */
+mov  (1) vme_m0.0<1>:W		-8:W			{align1};
+mov  (1) vme_m0.2<1>:W		-8:W			{align1};
+
+and.z.f0.0 (1)		null:uw	input_mb_intra_ub<0,1,0>:ub	INTRA_PRED_AVAIL_FLAG_AE:uw   {align1};
+(f0.0)	add 	(1)	vme_m0.0<1>:w	vme_m0.0<0,1,0>:w	4:w	{align1};
+and.z.f0.0 (1)		null:uw	input_mb_intra_ub<0,1,0>:ub	INTRA_PRED_AVAIL_FLAG_B:uw   {align1};
+(f0.0)	add 	(1)	vme_m0.2<1>:w	vme_m0.2<0,1,0>:w	4:w	{align1};
+
+__vme_msg:
+mov  (1) vme_m0.4<1>:UD		vme_m0.0<0,1,0>:UD	{align1};
 add  (2) vme_m0.0<1>:w		vme_m0.0<2,2,1>:w	mb_ref_win.16<2,2,1>:w	{align1};
 add  (2) vme_m0.4<1>:w		vme_m0.4<2,2,1>:w	mb_ref_win.16<2,2,1>:w	{align1};
 mov  (8) vme_msg_0.0<1>:UD      vme_m0.0<8,8,1>:UD {align1};
diff --git a/src/shaders/vme/inter_frame_gen8.g8b b/src/shaders/vme/inter_frame_gen8.g8b
index 6356541..d0cc25d 100644
--- a/src/shaders/vme/inter_frame_gen8.g8b
+++ b/src/shaders/vme/inter_frame_gen8.g8b
@@ -146,13 +146,13 @@
    { 0x00000001, 0x2fa41a68, 0x00000b04, 0x00000000 },
    { 0x00000001, 0x2fa81a68, 0x00000b24, 0x00000000 },
    { 0x00000040, 0x2fe00008, 0x06001400, 0x00000020 },
-   { 0x00000020, 0x34000000, 0x0e001400, 0x00000870 },
+   { 0x00000020, 0x34000000, 0x0e001400, 0x00000a20 },
    { 0x00000001, 0x2ac01a68, 0x00000fe4, 0x00000000 },
    { 0x00000001, 0x2fa01a68, 0x00000ae6, 0x00000000 },
    { 0x00000001, 0x2fa41a68, 0x00000b06, 0x00000000 },
    { 0x00000001, 0x2fa81a68, 0x00000b26, 0x00000000 },
    { 0x00000040, 0x2fe00008, 0x06001400, 0x00000020 },
-   { 0x00000020, 0x34000000, 0x0e001400, 0x00000810 },
+   { 0x00000020, 0x34000000, 0x0e001400, 0x000009c0 },
    { 0x00000001, 0x2ac21a68, 0x00000fe4, 0x00000000 },
    { 0x0020000c, 0x2a801a68, 0x1e450ac0, 0x00020002 },
    { 0x00200040, 0x2a881a68, 0x1e450a80, 0x00030003 },
@@ -193,18 +193,45 @@
    { 0x00000001, 0x28380208, 0x0000019c, 0x00000000 },
    { 0x00000001, 0x283c0208, 0x00000488, 0x00000000 },
    { 0x0a800031, 0x20000a60, 0x0e000800, 0x040a0203 },
+   { 0x01000010, 0x20002240, 0x160000a7, 0x00020002 },
+   { 0x00010020, 0x34000000, 0x0e001400, 0x00000160 },
+   { 0x00000001, 0x28600608, 0x00000000, 0x01010101 },
+   { 0x00000001, 0x28640608, 0x00000000, 0x10010101 },
+   { 0x00000001, 0x28680608, 0x00000000, 0x0f0f0f0f },
+   { 0x00000001, 0x286c0608, 0x00000000, 0x100f0f0f },
+   { 0x00000001, 0x28700608, 0x00000000, 0x01010101 },
+   { 0x00000001, 0x28740608, 0x00000000, 0x10010101 },
+   { 0x00000001, 0x28780608, 0x00000000, 0x0f0f0f0f },
+   { 0x00000001, 0x287c0608, 0x00000000, 0x100f0f0f },
+   { 0x00000001, 0x28800608, 0x00000000, 0x01010101 },
+   { 0x00000001, 0x28840608, 0x00000000, 0x10010101 },
+   { 0x00000001, 0x28880608, 0x00000000, 0x0f0f0f0f },
+   { 0x00000001, 0x288c0608, 0x00000000, 0x000f0f0f },
+   { 0x00400001, 0x28900608, 0x00000000, 0x00000000 },
    { 0x00000001, 0x244c0608, 0x00000000, 0x00200000 },
    { 0x00000001, 0x24561648, 0x10000000, 0x28302830 },
-   { 0x00000001, 0x24400208, 0x00000448, 0x00000000 },
-   { 0x00000040, 0x24401a68, 0x1e000440, 0xfff0fff0 },
-   { 0x00000040, 0x24421a68, 0x1e000442, 0xfff4fff4 },
    { 0x00000001, 0x24401e68, 0x18000000, 0xfff0fff0 },
    { 0x00000001, 0x24421e68, 0x18000000, 0xfff4fff4 },
-   { 0x00000001, 0x24440208, 0x00000440, 0x00000000 },
    { 0x01000005, 0x20002240, 0x160000a5, 0x00600060 },
    { 0x00010040, 0x24401a68, 0x1e000440, 0x000c000c },
    { 0x01000005, 0x20002240, 0x160000a5, 0x00100010 },
    { 0x00010040, 0x24421a68, 0x1e000442, 0x00080008 },
+   { 0x00000020, 0x34000000, 0x0e001400, 0x000000e0 },
+   { 0x00000001, 0x28600608, 0x00000000, 0x10010101 },
+   { 0x00000001, 0x28640608, 0x00000000, 0x100f0f0f },
+   { 0x00000001, 0x28680608, 0x00000000, 0x10010101 },
+   { 0x00000001, 0x286c0608, 0x00000000, 0x000f0f0f },
+   { 0x00400001, 0x28700608, 0x00000000, 0x00000000 },
+   { 0x00600001, 0x28900608, 0x00000000, 0x00000000 },
+   { 0x00000001, 0x244c0608, 0x00000000, 0x00200000 },
+   { 0x00000001, 0x24561648, 0x10000000, 0x20202020 },
+   { 0x00000001, 0x24401e68, 0x18000000, 0xfff8fff8 },
+   { 0x00000001, 0x24421e68, 0x18000000, 0xfff8fff8 },
+   { 0x01000005, 0x20002240, 0x160000a5, 0x00600060 },
+   { 0x00010040, 0x24401a68, 0x1e000440, 0x00040004 },
+   { 0x01000005, 0x20002240, 0x160000a5, 0x00100010 },
+   { 0x00010040, 0x24421a68, 0x1e000442, 0x00040004 },
+   { 0x00000001, 0x24440208, 0x00000440, 0x00000000 },
    { 0x00200040, 0x24401a68, 0x1a450440, 0x00450a90 },
    { 0x00200040, 0x24441a68, 0x1a450444, 0x00450a90 },
    { 0x00600001, 0x28000208, 0x008d0440, 0x00000000 },
diff --git a/src/shaders/vme/vme8.inc b/src/shaders/vme/vme8.inc
index bf60ad5..5b6f469 100644
--- a/src/shaders/vme/vme8.inc
+++ b/src/shaders/vme/vme8.inc
@@ -59,6 +59,8 @@ define(`SEARCH_CTRL_DUAL_RECORD',       `0x00000300')
 define(`SEARCH_CTRL_DUAL_REFERENCE',    `0x00000700')
 
 define(`REF_REGION_SIZE',               `0x2830:UW')
+define(`MIN_REF_REGION_SIZE',           `0x2020:UW')
+define(`DREF_REGION_SIZE',              `0x2020:UW')
 
 define(`BI_SUB_MB_PART_MASK',           `0x0c000000')
 define(`MAX_NUM_MV',                    `0x00000020')
@@ -133,6 +135,7 @@ define(`orig_y_ub',             `inline_reg0.1')
 define(`transform_8x8_ub',      `inline_reg0.4')
 define(`input_mb_intra_ub',     `inline_reg0.5')
 define(`num_macroblocks',       `inline_reg0.6')
+define(`quality_level_ub',      `inline_reg0.7')
 
 /*
  * GRF 6~11 -- reserved
@@ -312,7 +315,6 @@ define(`mb_mv3',		`r96')
 define(`mb_ref',		`r97')
 define(`mb_ref_win',		`r84')
 
-define(`DREF_REGION_SIZE',               `0x2020:UW')
 define(`PRED_L0',               `0x0':uw)
 define(`PRED_L1',               `0x1':uw)
 define(`PRED_BI',               `0x2':uw)
@@ -339,3 +341,7 @@ define(`INTER_8X16MODE',		`0x02')
 define(`OBR_MESSAGE_FENCE',              `7')
 define(`OBR_MF_NOCOMMIT',		 `0')
 define(`OBR_MF_COMMIT',			 `0x20')
+
+define(`DEFAULT_QUALITY_LEVEL',           `0x01')
+define(`HIGH_QUALITY_LEVEL',              `DEFAULT_QUALITY_LEVEL')
+define(`LOW_QUALITY_LEVEL',               `0x02')
-- 
1.7.9.5



More information about the Libva mailing list