OSDN Git Service

Use f_code to determine max MV length
authorMark Thompson <sw@jkqxz.net>
Wed, 25 Apr 2018 22:44:33 +0000 (23:44 +0100)
committerXiang, Haihao <haihao.xiang@intel.com>
Sat, 28 Apr 2018 08:15:40 +0000 (16:15 +0800)
The motion vector length is constrained by the level but not set by it -
we should instead use the f_code values to set the max MV length.

This fixes encoding when the f_code values are not set to the highest
allowed for the level, and also adds support for intermediate levels such
as High 1440 which were not previously handled here.

Signed-off-by: Mark Thompson <sw@jkqxz.net>
src/gen6_mfc_common.c

index 54f3cd6..19f9793 100644 (file)
@@ -1384,23 +1384,11 @@ void intel_vme_mpeg2_state_setup(VADriverContextP ctx,
     VAEncSliceParameterBufferMPEG2 *slice_param = NULL;
     VAEncPictureParameterBufferMPEG2 *pic_param = NULL;
     slice_param = (VAEncSliceParameterBufferMPEG2 *)encode_state->slice_params_ext[0]->buffer;
+    pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
 
-    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;
-    }
+    mv_x = 1 << (2 + pic_param->f_code[0][0]);
+    mv_y = 1 << (2 + pic_param->f_code[0][1]);
 
-    pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
     if (pic_param->picture_type != VAEncPictureTypeIntra) {
         int qp, m_cost, j, mv_count;
         float   lambda, m_costf;