[Libva] [PATCH 11/13] Adjust the maximum number of motion vectors for B frame on HSW+

Qu, Pengfei pengfei.qu at intel.com
Mon Jul 11 02:56:54 UTC 2016


AVC SPEC only allow max 16 frames for 1080P at level 5.1. and Level 4/4.1/4.2 only allow max 4 ref frames. And level 5 allow max 13 ref frames for 1080P.

Here the user should be careful when set “denom”. The driver now use the default value “1”  to set the VME. it is safe by now.

Thanks,
Pengfei
From: Peter Frühberger [mailto:peter.fruehberger at gmail.com]
Sent: Saturday, July 9, 2016 2:05 PM
To: Qu, Pengfei <pengfei.qu at intel.com>
Cc: libva at lists.freedesktop.org; Meng, Jia <jia.meng at intel.com>
Subject: Re: [Libva] [PATCH 11/13] Adjust the maximum number of motion vectors for B frame on HSW+

Be careful here, please,

some real life files lie about their spec, e.g. they are announcing Level 4.1 High but ship 16 Reframes at 1920x1080. Afaik mpeg-2 always uses 2 (one past and one future). That would result in pixelation, right?

Best regards
Peter

2016-07-07 11:18 GMT+02:00 Pengfei Qu <Pengfei.Qu at intel.com<mailto:Pengfei.Qu at intel.com>>:
From: Jia Meng <jia.meng at intel.com<mailto:jia.meng at intel.com>>

Signed-off-by: Jia Meng <jia.meng at intel.com<mailto:jia.meng at intel.com>>
Signed-off-by: Pengfei Qu <Pengfei.Qu at intel.com<mailto:Pengfei.Qu at intel.com>>
---
 src/gen75_vme.c | 13 +++++++------
 src/gen8_vme.c  | 15 ++++++++-------
 src/gen9_vme.c  | 17 +++++++++--------
 3 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/gen75_vme.c b/src/gen75_vme.c
index 174a642..81925fe 100644
--- a/src/gen75_vme.c
+++ b/src/gen75_vme.c
@@ -330,7 +330,8 @@ static VAStatus gen75_vme_interface_setup(VADriverContextP ctx,

 static VAStatus gen75_vme_constant_setup(VADriverContextP ctx,
                                          struct encode_state *encode_state,
-                                         struct intel_encoder_context *encoder_context)
+                                         struct intel_encoder_context *encoder_context,
+                                         int denom)
 {
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     unsigned char *constant_buffer;
@@ -342,13 +343,13 @@ static VAStatus gen75_vme_constant_setup(VADriverContextP ctx,
     if (encoder_context->codec == CODEC_H264 ||
         encoder_context->codec == CODEC_H264_MVC) {
         if (vme_context->h264_level >= 30) {
-            mv_num = 16;
+            mv_num = 16 / denom;

             if (vme_context->h264_level >= 31)
-                mv_num = 8;
+                mv_num = 8 / denom;
         }
     } else if (encoder_context->codec == CODEC_MPEG2) {
-        mv_num = 2;
+        mv_num = 2 / denom;
     }

     vme_state_message[31] = mv_num;
@@ -675,7 +676,7 @@ static VAStatus gen75_vme_prepare(VADriverContextP ctx,
     gen75_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
     gen75_vme_interface_setup(ctx, encode_state, encoder_context);
     //gen75_vme_vme_state_setup(ctx, encode_state, is_intra, encoder_context);
-    gen75_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen75_vme_constant_setup(ctx, encode_state, encoder_context, (pSliceParameter->slice_type == SLICE_TYPE_B) ? 2 : 1);

     /*Programing media pipeline*/
     gen75_vme_pipeline_programing(ctx, encode_state, encoder_context);
@@ -987,7 +988,7 @@ gen75_vme_mpeg2_prepare(VADriverContextP ctx,
     gen75_vme_interface_setup(ctx, encode_state, encoder_context);
     gen75_vme_vme_state_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
     intel_vme_mpeg2_state_setup(ctx, encode_state, encoder_context);
-    gen75_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen75_vme_constant_setup(ctx, encode_state, encoder_context, 1);

     /*Programing media pipeline*/
     gen75_vme_mpeg2_pipeline_programing(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
diff --git a/src/gen8_vme.c b/src/gen8_vme.c
index 28b8195..f4a874e 100644
--- a/src/gen8_vme.c
+++ b/src/gen8_vme.c
@@ -363,7 +363,8 @@ static VAStatus gen8_vme_interface_setup(VADriverContextP ctx,

 static VAStatus gen8_vme_constant_setup(VADriverContextP ctx,
                                         struct encode_state *encode_state,
-                                        struct intel_encoder_context *encoder_context)
+                                        struct intel_encoder_context *encoder_context,
+                                        int denom)
 {
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     unsigned char *constant_buffer;
@@ -375,13 +376,13 @@ static VAStatus gen8_vme_constant_setup(VADriverContextP ctx,
     if (encoder_context->codec == CODEC_H264 ||
         encoder_context->codec == CODEC_H264_MVC) {
         if (vme_context->h264_level >= 30) {
-            mv_num = 16;
+            mv_num = 16 / denom;

             if (vme_context->h264_level >= 31)
-                mv_num = 8;
+                mv_num = 8 / denom;
         }
     } else if (encoder_context->codec == CODEC_MPEG2) {
-        mv_num = 2;
+        mv_num = 2 / denom;
     }

     vme_state_message[31] = mv_num;
@@ -749,7 +750,7 @@ static VAStatus gen8_vme_prepare(VADriverContextP ctx,
     gen8_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
     gen8_vme_interface_setup(ctx, encode_state, encoder_context);
     //gen8_vme_vme_state_setup(ctx, encode_state, is_intra, encoder_context);
-    gen8_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen8_vme_constant_setup(ctx, encode_state, encoder_context, (pSliceParameter->slice_type == SLICE_TYPE_B) ? 2 : 1);

     /*Programing media pipeline*/
     gen8_vme_pipeline_programing(ctx, encode_state, encoder_context);
@@ -1139,7 +1140,7 @@ gen8_vme_mpeg2_prepare(VADriverContextP ctx,
     gen8_vme_interface_setup(ctx, encode_state, encoder_context);
     //gen8_vme_vme_state_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
     intel_vme_mpeg2_state_setup(ctx, encode_state, encoder_context);
-    gen8_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen8_vme_constant_setup(ctx, encode_state, encoder_context, 1);

     /*Programing media pipeline*/
     gen8_vme_mpeg2_pipeline_programing(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
@@ -1272,7 +1273,7 @@ static VAStatus gen8_vme_vp8_prepare(VADriverContextP ctx,
     /*Setup all the memory object*/
     gen8_vme_vp8_surface_setup(ctx, encode_state, is_intra, encoder_context);
     gen8_vme_interface_setup(ctx, encode_state, encoder_context);
-    gen8_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen8_vme_constant_setup(ctx, encode_state, encoder_context, 1);

     /*Programing media pipeline*/
     gen8_vme_vp8_pipeline_programing(ctx, encode_state, is_intra, encoder_context);
diff --git a/src/gen9_vme.c b/src/gen9_vme.c
index 46ba9c0..b495f28 100644
--- a/src/gen9_vme.c
+++ b/src/gen9_vme.c
@@ -400,7 +400,8 @@ static VAStatus gen9_vme_interface_setup(VADriverContextP ctx,

 static VAStatus gen9_vme_constant_setup(VADriverContextP ctx,
                                         struct encode_state *encode_state,
-                                        struct intel_encoder_context *encoder_context)
+                                        struct intel_encoder_context *encoder_context,
+                                        int denom)
 {
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     unsigned char *constant_buffer;
@@ -412,13 +413,13 @@ static VAStatus gen9_vme_constant_setup(VADriverContextP ctx,
     if (encoder_context->codec == CODEC_H264 ||
         encoder_context->codec == CODEC_H264_MVC) {
         if (vme_context->h264_level >= 30) {
-            mv_num = 16;
+            mv_num = 16 / denom;

             if (vme_context->h264_level >= 31)
-                mv_num = 8;
+                mv_num = 8 / denom;
         }
     } else if (encoder_context->codec == CODEC_MPEG2) {
-        mv_num = 2;
+        mv_num = 2 / denom;
     }else if (encoder_context->codec == CODEC_HEVC) {
         if (vme_context->hevc_level >= 30*3) {
             mv_num = 16;
@@ -795,7 +796,7 @@ static VAStatus gen9_vme_prepare(VADriverContextP ctx,
     gen9_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
     gen9_vme_interface_setup(ctx, encode_state, encoder_context);
     //gen9_vme_vme_state_setup(ctx, encode_state, is_intra, encoder_context);
-    gen9_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen9_vme_constant_setup(ctx, encode_state, encoder_context, (pSliceParameter->slice_type == SLICE_TYPE_B) ? 2 : 1);

     /*Programing media pipeline*/
     gen9_vme_pipeline_programing(ctx, encode_state, encoder_context);
@@ -1187,7 +1188,7 @@ gen9_vme_mpeg2_prepare(VADriverContextP ctx,
     gen9_vme_interface_setup(ctx, encode_state, encoder_context);
     //gen9_vme_vme_state_setup(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
     intel_vme_mpeg2_state_setup(ctx, encode_state, encoder_context);
-    gen9_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen9_vme_constant_setup(ctx, encode_state, encoder_context, 1);

     /*Programing media pipeline*/
     gen9_vme_mpeg2_pipeline_programing(ctx, encode_state, slice_param->is_intra_slice, encoder_context);
@@ -1322,7 +1323,7 @@ static VAStatus gen9_vme_vp8_prepare(VADriverContextP ctx,
     /*Setup all the memory object*/
     gen9_vme_vp8_surface_setup(ctx, encode_state, is_intra, encoder_context);
     gen9_vme_interface_setup(ctx, encode_state, encoder_context);
-    gen9_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen9_vme_constant_setup(ctx, encode_state, encoder_context, 1);

     /*Programing media pipeline*/
     gen9_vme_vp8_pipeline_programing(ctx, encode_state, is_intra, encoder_context);
@@ -1754,7 +1755,7 @@ static VAStatus gen9_vme_hevc_prepare(VADriverContextP ctx,
     gen9_vme_hevc_surface_setup(ctx, encode_state, is_intra, encoder_context);
     gen9_vme_interface_setup(ctx, encode_state, encoder_context);
     //gen9_vme_vme_state_setup(ctx, encode_state, is_intra, encoder_context);
-    gen9_vme_constant_setup(ctx, encode_state, encoder_context);
+    gen9_vme_constant_setup(ctx, encode_state, encoder_context, 1);

     /*Programing media pipeline*/
     gen9_vme_hevc_pipeline_programing(ctx, encode_state, encoder_context);
--
2.7.4

_______________________________________________
Libva mailing list
Libva at lists.freedesktop.org<mailto:Libva at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/libva



--
                   Key-ID:     0x1A995A9B
                   keyserver: pgp.mit.edu<http://pgp.mit.edu>
==============================================================
Fingerprint: 4606 DA19 EC2E 9A0B 0157  C81B DA07 CF63 1A99 5A9B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libva/attachments/20160711/d1b106c3/attachment-0001.html>


More information about the Libva mailing list