[FFmpeg-devel] [PATCH v3] avcodec: fix atomics usage for h264/mpeg error_count

wm4 nfxjfg at googlemail.com
Wed Mar 14 09:11:35 EET 2018


On Tue, 13 Mar 2018 19:07:33 +0100
Michael Niedermayer <michael at niedermayer.cc> wrote:

> On Tue, Mar 13, 2018 at 04:02:57PM +0000, Aman Gupta wrote:
> > On Tue, Mar 13, 2018 at 4:39 AM Michael Niedermayer <michael at niedermayer.cc>
> > wrote:
> >   
> > > On Mon, Mar 12, 2018 at 06:49:19PM -0700, Aman Gupta wrote:  
> > > > From: Aman Gupta <aman at tmm1.net>
> > > >
> > > > ---
> > > >  libavcodec/h264_slice.c    |  5 +++--
> > > >  libavcodec/mpeg12dec.c     | 12 +++++++-----
> > > >  libavcodec/mpegvideo_enc.c |  3 ++-
> > > >  3 files changed, 12 insertions(+), 8 deletions(-)  
> > >
> > > Iam a little bit confused, you write about "fixing" but not what this is
> > > fixing and it appears there are several distinct types of changes  
> > 
> > 
> > The type of error_count is already atomic_int. I don't know when that was
> > changed.
> > 
> > The fix here is that these files do not compile on FreeBSD because of
> > errors such as:
> > 
> > [2018-03-11 18:26:55.078686] [freebsd-x86_64] libavcodec/mpegvideo_enc.c:
> > In function 'merge_context_after_encode':
> > 
> > [2018-03-11 18:26:55.081607] [freebsd-x86_64]
> > libavcodec/mpegvideo_enc.c:3578:33: error: invalid operands to binary +
> > (have 'atomic_int' and 'atomic_int')
> > 
> > 
> > [2018-03-11 16:43:23.543072] [freebsd-x86_64] CC    libavcodec/mpeg12dec.o
> > 
> > [2018-03-11 16:43:23.768864] [freebsd-x86_64] libavcodec/mpeg12dec.c: In
> > function 'slice_decode_thread':
> >   
> 
> > [2018-03-11 16:43:23.769713] [freebsd-x86_64]
> > libavcodec/mpeg12dec.c:1996:23: error: incompatible types when assigning to
> > type 'atomic_int' from type 'int'  
> 
> what compiler is this ?
>     6.5.16.1 Simple assignment
>     Constraints
>     One of the following shall hold: 114)
>     — the left operand has atomic, qualified, or unqualified arithmetic type, and the right has
>     arithmetic type;
> 
> Please someone correct me here if iam wrong but
> To me this sounds like doing normal arithmetic operations between atomic and
> non atomic arithmetic types is allowed.

It's true that C11 atomics allow direct access, but we also have
some atomic wrappers that won't work correctly then. I haven't checked
why this one fails, but the gcc compat wrappers use non-atomic types for
the emulation, so this patch is justified and necessary.



More information about the ffmpeg-devel mailing list