[Ffmpeg-devel] Parallel mpeg4/h264 decoding in same process

Adam Thayer krevnik
Wed Jun 1 00:58:47 CEST 2005

Indeed, IIRC from my own adventures, it is a very bad idea to have static
variables for the codec with the assumption that it will only have one
instance being used at a time. My suggestion? Move the variables and make
the tweaks and see if it runs, then just submit the patch. If it is clean
and fixes your particular problem, I don't see why Michael will not import
the patch into the repository. Just be careful to ensure the patch follows
the submission guidelines.

-----Original Message-----
From: ffmpeg-devel-bounces at mplayerhq.hu
[mailto:ffmpeg-devel-bounces at mplayerhq.hu] On Behalf Of Dario Souza
Sent: Tuesday, May 31, 2005 3:45 PM
To: ffmpeg-devel at mplayerhq.hu
Cc: 'Jorge B. Jorge'
Subject: [Ffmpeg-devel] Parallel mpeg4/h264 decoding in same process

I have noticed that when trying to do parallel decoding with MPEG4 decoder
(meaning simultaneous avcodec_decode_video calls, serialized by a global
mutex), video decoding corrupts the image.
Note that I am not talking about using the same codec context of course.
I mean different streams using different AVCodecContext*.

After looking at the code, I could see that (although AVCodecContext holds
the priv member with the codec specific context that *should* in thesis
store the codec state), some static variables are being used and that may
hold state during the decode process.
If so, even if I serialize all the decoder operations, one stream's
operation would corrupt other's state. Note that it wouldn't happen if codec
code accessed only the data that's in the codec specific
AVCodecContext::priv data (H264Context for instance).

My question is:

1) Has anyone succeeded in decoding simultaneous streams in the same
2) If I move the static variables that I suspect to be shared among the
decoding operations, is there a chance to patch it into repository?


Dario Andrade
Executive Director
Mobile +55.21.9453.5005
Office +55.21.2141.9525

ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu

More information about the ffmpeg-devel mailing list