[FFmpeg-devel] [PATCH] h264: don't touch H264Context->ref_count[] during MB decoding.

Michael Niedermayer michaelni at gmx.at
Thu Oct 4 03:56:12 CEST 2012


On Wed, Oct 03, 2012 at 04:25:14PM -0700, Ronald S. Bultje wrote:
> From: "Ronald S. Bultje" <rsbultje at gmail.com>
> 
> The variable is copied to subsequent threads at the same time, so this
> may cause wrong ref_count[] values to be copied to subsequent threads.
> 
> This bug was found using TSAN.
> ---
>  libavcodec/h264_cabac.c |   41 ++++++++++++++++-------------------------
>  libavcodec/h264_cavlc.c |   33 +++++++++++++--------------------
>  2 files changed, 29 insertions(+), 45 deletions(-)
> 
> diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
> index 7e8947b..97e8128 100644
> --- a/libavcodec/h264_cabac.c
> +++ b/libavcodec/h264_cabac.c
> @@ -2003,11 +2003,6 @@ decode_intra_mb:
>          return 0;
>      }
>  
> -    if(MB_MBAFF){
> -        h->ref_count[0] <<= 1;
> -        h->ref_count[1] <<= 1;
> -    }
> -
>      fill_decode_caches(h, mb_type);
>  
>      if( IS_INTRA( mb_type ) ) {

i suggest to add a priv/local/tls/whatever_ref_count[2]
and set/change it as ref_count is before your patch
that way the shift doesnt need to be done multiple times in the
more inner loops. This should also keep the code smaller and reduce
pressure on the code cache

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121004/6cdd31db/attachment.asc>


More information about the ffmpeg-devel mailing list