@ -195,8 +195,18 @@ static void fill_slice_short(DXVA_Slice_H264_Short *slice,
slice - > wBadSliceChopping = 0 ;
slice - > wBadSliceChopping = 0 ;
}
}
static int get_refpic_index ( const DXVA_PicParams_H264 * pp , int surface_index )
{
int i ;
for ( i = 0 ; i < FF_ARRAY_ELEMS ( pp - > RefFrameList ) ; i + + ) {
if ( ( pp - > RefFrameList [ i ] . bPicEntry & 0x7f ) = = surface_index )
return i ;
}
return 0x7f ;
}
static void fill_slice_long ( AVCodecContext * avctx , DXVA_Slice_H264_Long * slice ,
static void fill_slice_long ( AVCodecContext * avctx , DXVA_Slice_H264_Long * slice ,
unsigned position , unsigned size )
const DXVA_PicParams_H264 * pp , unsigned position , unsigned size )
{
{
const H264Context * h = avctx - > priv_data ;
const H264Context * h = avctx - > priv_data ;
struct dxva_context * ctx = avctx - > hwaccel_context ;
struct dxva_context * ctx = avctx - > hwaccel_context ;
@ -229,8 +239,8 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
if ( list < h - > list_count & & i < h - > ref_count [ list ] ) {
if ( list < h - > list_count & & i < h - > ref_count [ list ] ) {
const H264Picture * r = & h - > ref_list [ list ] [ i ] ;
const H264Picture * r = & h - > ref_list [ list ] [ i ] ;
unsigned plane ;
unsigned plane ;
fill_picture_entry ( & slice - > RefPicList [ list ] [ i ] ,
unsigned index = get_refpic_index ( pp , ff_dxva2_get_surface_index ( ctx , & r - > f ) ) ;
ff_dxva2_get_surface_index ( ctx , & r - > f ) ,
fill_picture_entry ( & slice - > RefPicList [ list ] [ i ] , index ,
r - > reference = = PICT_BOTTOM_FIELD ) ;
r - > reference = = PICT_BOTTOM_FIELD ) ;
for ( plane = 0 ; plane < 3 ; plane + + ) {
for ( plane = 0 ; plane < 3 ; plane + + ) {
int w , o ;
int w , o ;
@ -415,7 +425,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx,
position , size ) ;
position , size ) ;
else
else
fill_slice_long ( avctx , & ctx_pic - > slice_long [ ctx_pic - > slice_count ] ,
fill_slice_long ( avctx , & ctx_pic - > slice_long [ ctx_pic - > slice_count ] ,
position , size ) ;
& ctx_pic - > pp , position , size ) ;
ctx_pic - > slice_count + + ;
ctx_pic - > slice_count + + ;
if ( h - > slice_type ! = AV_PICTURE_TYPE_I & & h - > slice_type ! = AV_PICTURE_TYPE_SI )
if ( h - > slice_type ! = AV_PICTURE_TYPE_I & & h - > slice_type ! = AV_PICTURE_TYPE_SI )