[FFmpeg-devel] Threading issue with avcodec_decode_video2 ?

Don Moir donmoir at comcast.net
Tue Nov 13 00:25:49 CET 2012


----- Original Message ----- 
From: "Reimar Döffinger" <Reimar.Doeffinger at gmx.de>
To: "FFmpeg development discussions and patches" <ffmpeg-devel at ffmpeg.org>
Sent: Monday, November 12, 2012 4:44 PM
Subject: Re: [FFmpeg-devel] Threading issue with avcodec_decode_video2 ?


> On Mon, Oct 29, 2012 at 10:38:25PM +0100, Hendrik Leppkes wrote:
>> On Mon, Oct 29, 2012 at 10:22 PM, Don Moir <donmoir at comcast.net> wrote:
>> > In vc1dec.c it calls the init functions and does a little more. The code
>> > under return -1; appears to be ok and seems to be happy in either
>> > vc1_decode_init or vc1_decode_frame, but "if (ff_msmpeg4_decode_init(avctx)
>> > < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)" only seems to be happy in
>> > vc1_decode_init or when locked down.
>> >
>> > Do you have a multi-threaded test case for this kind of thing ?
>>
>> I looked over those two functions, and sadly its required to call them
>> there, because its possible that width/height of the video are not
>> known during the init function, or may even change in case of vc1image
>> decoding.
>
> Could you explain how you came to that conclusion?
> At least for ff_msmpeg4_decode_init I am not so sure about that.
> But even if they need to be called there, I see nothing speaking against
> _also_ calling them in the init function, this results in the VLC tables
> being initialized there, thus they will no longer be initialized when
> calling those functions during decode, thus eliminating the race
> condition.

Hendrik might have more info but in vc1_decode_frame you have this code:

    if (s->context_initialized &&
        (s->width  != avctx->coded_width ||
         s->height != avctx->coded_height)) {
        ff_vc1_decode_end(avctx);
    }

If  'ff_vc1_decode_end'  gets called then it's back to being unintialized and back to same problem as far as I can tell. You can 
call it in the init function but not sure that helps in the overall sense. 



More information about the ffmpeg-devel mailing list