mpeg2: fix TFF calculation (SNB).
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 27 Feb 2012 12:57:09 +0000 (13:57 +0100)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 29 Mar 2012 08:23:34 +0000 (16:23 +0800)
Gen6 has specific requirements for the TFF flag, and thus has different
semantics than Gen7 (IVB). In particular, HW uses picture_structure and
TFF flag to determine the correct field to render.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit 01c37fad8c991714026d6a995e9e35cc7865933e)

src/gen6_mfd.c

index e25b09f..e131edb 100644 (file)
@@ -1161,10 +1161,18 @@ gen6_mfd_mpeg2_pic_state(VADriverContextP ctx,
 {
     struct intel_batchbuffer *batch = gen6_mfd_context->base.batch;
     VAPictureParameterBufferMPEG2 *pic_param;
+    unsigned int tff, pic_structure;
 
     assert(decode_state->pic_param && decode_state->pic_param->buffer);
     pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer;
 
+    pic_structure = pic_param->picture_coding_extension.bits.picture_structure;
+    if (pic_structure == MPEG_FRAME)
+        tff = pic_param->picture_coding_extension.bits.top_field_first;
+    else
+        tff = !(pic_param->picture_coding_extension.bits.is_first_field ^
+                (pic_structure & MPEG_TOP_FIELD));
+
     BEGIN_BCS_BATCH(batch, 4);
     OUT_BCS_BATCH(batch, MFX_MPEG2_PIC_STATE | (4 - 2));
     OUT_BCS_BATCH(batch,
@@ -1174,7 +1182,7 @@ gen6_mfd_mpeg2_pic_state(VADriverContextP ctx,
                   ((pic_param->f_code >> 12) & 0xf) << 16 | /* f_code[0][0] */
                   pic_param->picture_coding_extension.bits.intra_dc_precision << 14 |
                   pic_param->picture_coding_extension.bits.picture_structure << 12 |
-                  pic_param->picture_coding_extension.bits.top_field_first << 11 |
+                  tff << 11 |
                   pic_param->picture_coding_extension.bits.frame_pred_frame_dct << 10 |
                   pic_param->picture_coding_extension.bits.concealment_motion_vectors << 9 |
                   pic_param->picture_coding_extension.bits.q_scale_type << 8 |