@ -48,29 +48,39 @@ void ff_h264_unref_picture(H264Picture *pic)
av_frame_unref ( pic - > f_grain ) ;
ff_refstruct_unref ( & pic - > hwaccel_picture_private ) ;
av_bu ffer_unref( & pic - > qscale_table_buf ) ;
av_bu ffer_unref( & pic - > mb_type_buf ) ;
ff_r efst ruct _unref ( & pic - > qscale_table_base ) ;
ff_r efst ruct _unref ( & pic - > mb_type_base ) ;
ff_refstruct_unref ( & pic - > pps ) ;
for ( i = 0 ; i < 2 ; i + + ) {
av_bu ffer_unref( & pic - > motion_val_buf [ i ] ) ;
av_bu ffer_unref( & pic - > ref_index_buf [ i ] ) ;
ff_r efst ruct _unref ( & pic - > motion_val_base [ i ] ) ;
ff_r efst ruct _unref ( & pic - > ref_index [ i ] ) ;
}
av_bu ffer_unref( & pic - > decode_error_flags ) ;
ff_r efst ruct _unref ( & pic - > decode_error_flags ) ;
memset ( ( uint8_t * ) pic + off , 0 , sizeof ( * pic ) - off ) ;
}
static void h264_copy_picture_params ( H264Picture * dst , const H264Picture * src )
{
ff_refstruct_replace ( & dst - > qscale_table_base , src - > qscale_table_base ) ;
ff_refstruct_replace ( & dst - > mb_type_base , src - > mb_type_base ) ;
ff_refstruct_replace ( & dst - > pps , src - > pps ) ;
for ( int i = 0 ; i < 2 ; i + + ) {
ff_refstruct_replace ( & dst - > motion_val_base [ i ] , src - > motion_val_base [ i ] ) ;
ff_refstruct_replace ( & dst - > ref_index [ i ] , src - > ref_index [ i ] ) ;
}
ff_refstruct_replace ( & dst - > hwaccel_picture_private ,
src - > hwaccel_picture_private ) ;
ff_refstruct_replace ( & dst - > decode_error_flags , src - > decode_error_flags ) ;
dst - > qscale_table = src - > qscale_table ;
dst - > mb_type = src - > mb_type ;
for ( int i = 0 ; i < 2 ; i + + ) {
for ( int i = 0 ; i < 2 ; i + + )
dst - > motion_val [ i ] = src - > motion_val [ i ] ;
dst - > ref_index [ i ] = src - > ref_index [ i ] ;
}
for ( int i = 0 ; i < 2 ; i + + )
dst - > field_poc [ i ] = src - > field_poc [ i ] ;
@ -96,7 +106,7 @@ static void h264_copy_picture_params(H264Picture *dst, const H264Picture *src)
int ff_h264_ref_picture ( H264Picture * dst , const H264Picture * src )
{
int ret , i ;
int ret ;
av_assert0 ( ! dst - > f - > buf [ 0 ] ) ;
av_assert0 ( src - > f - > buf [ 0 ] ) ;
@ -113,29 +123,6 @@ int ff_h264_ref_picture(H264Picture *dst, const H264Picture *src)
goto fail ;
}
dst - > qscale_table_buf = av_buffer_ref ( src - > qscale_table_buf ) ;
dst - > mb_type_buf = av_buffer_ref ( src - > mb_type_buf ) ;
if ( ! dst - > qscale_table_buf | | ! dst - > mb_type_buf ) {
ret = AVERROR ( ENOMEM ) ;
goto fail ;
}
for ( i = 0 ; i < 2 ; i + + ) {
dst - > motion_val_buf [ i ] = av_buffer_ref ( src - > motion_val_buf [ i ] ) ;
dst - > ref_index_buf [ i ] = av_buffer_ref ( src - > ref_index_buf [ i ] ) ;
if ( ! dst - > motion_val_buf [ i ] | | ! dst - > ref_index_buf [ i ] ) {
ret = AVERROR ( ENOMEM ) ;
goto fail ;
}
}
ff_refstruct_replace ( & dst - > hwaccel_picture_private ,
src - > hwaccel_picture_private ) ;
ret = av_buffer_replace ( & dst - > decode_error_flags , src - > decode_error_flags ) ;
if ( ret < 0 )
goto fail ;
h264_copy_picture_params ( dst , src ) ;
return 0 ;
@ -146,7 +133,7 @@ fail:
int ff_h264_replace_picture ( H264Picture * dst , const H264Picture * src )
{
int ret , i ;
int ret ;
if ( ! src - > f | | ! src - > f - > buf [ 0 ] ) {
ff_h264_unref_picture ( dst ) ;
@ -167,25 +154,6 @@ int ff_h264_replace_picture(H264Picture *dst, const H264Picture *src)
goto fail ;
}
ret = av_buffer_replace ( & dst - > qscale_table_buf , src - > qscale_table_buf ) ;
ret | = av_buffer_replace ( & dst - > mb_type_buf , src - > mb_type_buf ) ;
if ( ret < 0 )
goto fail ;
for ( i = 0 ; i < 2 ; i + + ) {
ret = av_buffer_replace ( & dst - > motion_val_buf [ i ] , src - > motion_val_buf [ i ] ) ;
ret | = av_buffer_replace ( & dst - > ref_index_buf [ i ] , src - > ref_index_buf [ i ] ) ;
if ( ret < 0 )
goto fail ;
}
ff_refstruct_replace ( & dst - > hwaccel_picture_private ,
src - > hwaccel_picture_private ) ;
ret = av_buffer_replace ( & dst - > decode_error_flags , src - > decode_error_flags ) ;
if ( ret < 0 )
goto fail ;
h264_copy_picture_params ( dst , src ) ;
return 0 ;