[Libva] [PATCH] mpeg2: fix incorrect slice_vertical_position from codec layers.

Xiang, Haihao haihao.xiang at intel.com
Wed Mar 28 22:42:22 PDT 2012


> +            vpos = slice_param->slice_vertical_position;
> +            if (vpos >= mb_height || vpos == last_vpos + 2)
> +                return 1;

Why is the workaround applied for vpos == last_vpos + 2 ? I think it is
right that vpos = 0, 2, 4, ... for top field and vpos = 1, 3, 5, .. for
bottom field. 

I still met GPU hang issue when playing some mpeg2 conformance tests
such as sony-ct1.bits.  The root cause is that the codec layers pass
wrong parameters to the driver.  I think a safe way to avoid GPU hang
issue is not to decode the stream. 

Thanks
Haihao


> +            last_vpos = vpos;
> +        }
> +    }
> +    return 0;
> +}
> +
>  /* Generate flat scaling matrices for H.264 decoding */
>  void
>  avc_gen_default_iq_matrix(VAIQMatrixBufferH264 *iq_matrix)
> diff --git a/src/i965_decoder_utils.h b/src/i965_decoder_utils.h
> index 37402b4..1c624c0 100644
> --- a/src/i965_decoder_utils.h
> +++ b/src/i965_decoder_utils.h
> @@ -27,6 +27,14 @@
>  #include "i965_decoder.h"
>  #include "intel_batchbuffer.h"
>  
> +struct decode_state;
> +
> +int
> +mpeg2_wa_slice_vertical_position(
> +    struct decode_state           *decode_state,
> +    VAPictureParameterBufferMPEG2 *pic_param
> +);
> +
>  void
>  avc_gen_default_iq_matrix(VAIQMatrixBufferH264 *iq_matrix);
>  
> diff --git a/src/i965_media_mpeg2.c b/src/i965_media_mpeg2.c
> index 9278ab7..55e2109 100644
> --- a/src/i965_media_mpeg2.c
> +++ b/src/i965_media_mpeg2.c
> @@ -36,6 +36,7 @@
>  #include "intel_driver.h"
>  #include "i965_defines.h"
>  #include "i965_drv_video.h"
> +#include "i965_decoder_utils.h"
>  
>  #include "i965_media.h"
>  #include "i965_media_mpeg2.h"
> @@ -879,6 +880,7 @@ i965_media_mpeg2_objects(VADriverContextP ctx,
>                           struct decode_state *decode_state,
>                           struct i965_media_context *media_context)
>  {
> +    struct i965_mpeg2_context * const i965_mpeg2_context = media_context->private_context;
>      struct intel_batchbuffer *batch = media_context->base.batch;
>      VASliceParameterBufferMPEG2 *slice_param;
>      VAPictureParameterBufferMPEG2 *pic_param;
> @@ -887,6 +889,10 @@ i965_media_mpeg2_objects(VADriverContextP ctx,
>      assert(decode_state->pic_param && decode_state->pic_param->buffer);
>      pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer;
>  
> +    if (i965_mpeg2_context->wa_slice_vertical_position < 0)
> +        i965_mpeg2_context->wa_slice_vertical_position =
> +            mpeg2_wa_slice_vertical_position(decode_state, pic_param);
> +
>      for (j = 0; j < decode_state->num_slice_params; j++) {
>          assert(decode_state->slice_params[j] && decode_state->slice_params[j]->buffer);
>          assert(decode_state->slice_datas[j] && decode_state->slice_datas[j]->bo);
> @@ -895,8 +901,9 @@ i965_media_mpeg2_objects(VADriverContextP ctx,
>          for (i = 0; i < decode_state->slice_params[j]->num_elements; i++) {
>              int vpos, hpos, is_field_pic = 0;
>  
> -            if (pic_param->picture_coding_extension.bits.picture_structure == MPEG_TOP_FIELD ||
> -                pic_param->picture_coding_extension.bits.picture_structure == MPEG_BOTTOM_FIELD)
> +            if (i965_mpeg2_context->wa_slice_vertical_position > 0 &&
> +                (pic_param->picture_coding_extension.bits.picture_structure == MPEG_TOP_FIELD ||
> +                 pic_param->picture_coding_extension.bits.picture_structure == MPEG_BOTTOM_FIELD))
>                  is_field_pic = 1;
>  
>              assert(slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_ALL);
> @@ -970,6 +977,7 @@ i965_media_mpeg2_dec_context_init(VADriverContextP ctx, struct i965_media_contex
>      int i;
>  
>      i965_mpeg2_context = calloc(1, sizeof(struct i965_mpeg2_context));
> +    i965_mpeg2_context->wa_slice_vertical_position = -1;
>  
>      /* kernel */
>      assert(NUM_MPEG2_VLD_KERNELS == (sizeof(mpeg2_vld_kernels_gen4) / 
> diff --git a/src/i965_media_mpeg2.h b/src/i965_media_mpeg2.h
> index 65e308c..5b8867e 100644
> --- a/src/i965_media_mpeg2.h
> +++ b/src/i965_media_mpeg2.h
> @@ -44,6 +44,7 @@ struct i965_mpeg2_context
>  {
>      struct i965_kernel vld_kernels[NUM_MPEG2_VLD_KERNELS];
>      VAIQMatrixBufferMPEG2 iq_matrix;
> +    int wa_slice_vertical_position;
>  };
>  
>  void i965_media_mpeg2_decode_init(VADriverContextP ctx, struct decode_state * decode_state, struct i965_media_context *media_context);




More information about the Libva mailing list