[FFmpeg-devel] libavcodec: inter thread signaling
andrey.krieger.utkin at gmail.com
Mon Feb 27 17:45:31 CET 2012
2012/2/27 Anoop Bhagyanath <bhagyanath.anoop at gmail.com>:
> hi everyone,
> i am looking at the decoding of h264. basically frame level
> multi-threading. i find that we have a main thread collecting frames one by
> one from
> user (via avcodec_decode_video2) and passing on to one of (num_cores+1)
> decoding threads spawned. i understand
> the usage of input_cond and output_cond condition variables. also
> progress_cond to some extent.
> *but i do not understand how B frames are handled, ie if we get a B frame
> which depends on future frame. does
> the respective thread wait till that future frame is processed by another
> decoding thread. OR do we receive
> frames in the proper decoding order (may be due to the way av_read_frame
> is implemented) ?
B frame has lower DTS, i.e. it must be consumed by decoder earlier, so
decoding threads don't "wait" for such frame. libavformat demuxers
always give you packets ordered by DTS, so it works seamlessly.
> *when a decoding thread needs some data from another frame(basically
> another decoding thread), it awaits the
> progress of that thread. but on what basis this other decoding thread know
> that someone is waiting for the data
> from him/her.
I think it does not know, and does not need to know.
More information about the ffmpeg-devel