[FFmpeg-devel] [PATCH] Make ffplay define in the encoder the number of threads *before* to open it

Michael Dorr dorr
Sat Mar 8 20:31:25 CET 2008


On Saturday 08 March 2008 07:25:49 pm Stefano Sabatini wrote:
> On date Saturday 2008-03-08 18:55:26 +0100, Michael Niedermayer encoded:
> > On Sat, Mar 08, 2008 at 06:33:27PM +0100, Stefano Sabatini wrote:
> > > Hi,
> > > as in $subject.
> > >
> > > If threads support is not enabled and threads count is set to a
> > > value greater than MAX_THREADS (currently is 8), then encoder is
> > > initialized with a value of thread_count equal to 1, then
> > > enc->threads_count is set to the value set by the user, finally
> > > libavcodec crashes when it tryies to free the first thread beyond
> > > MAX_THREADS (this happens when quitting ffplay).
> >
> > the command line parsing code should not accept >MAX_THREADS
>
> [...]
>
> I agree, but MAX_THREADS is defined in libavcodec/mpegvideo.h, which
> is not public, furthermore the patch implements the correct behaviour
> for opening an encoder so I'd like to see it applied.

Shouldn't manually setting enc->thread_count be omitted completely, since it 
gets set correctly in avcodec_thread_init anyway (and if thread_init isn't 
called, it defaults to 1, which is also correct)? Theoretically, 
avcodec_thread_init could fail, then enc->thread_count and the 'real' number 
of threads will differ, and ffmpeg will crash ...

Best regards.

Michael




More information about the ffmpeg-devel mailing list