[FFmpeg-devel] [PATCH]. Replace codec when stream changes from PCM_DVD to PCM_S16BE

avcoder ffmpeg
Thu Mar 25 17:51:25 CET 2010


On Thu, Mar 25, 2010 at 12:04 AM, stanley kamithi <skamithi at gmail.com> wrote:
> Hello
>
> Found this problem while using the latest mythtv.
> I have a few dvds where ffmpeg says the first few audio packets are detected
> to use the PCM_DVD codec and subsequent packets use PCM_S16BE.
> In libavformat/mpeg.c, when this change is detected, it only changes the
> codec type in the AvCodecContext and nothing else. The problem is that
> mythtv fails to decode subsequent audio frames properly
> because the codec hasn't changed. It still using the PCM_DVD codec so you
> get issues like wrong sample depth causing no audio output or wrong sample
> format causing playback to be too fast.
> Attach patch, against the latest ffmpeg, ?corrects the problem by closing
> the existing codec and attaching the correct one.
>
> Please review and provide your comments.
>

Your patch is wrong!

In a normal scenario of decoding, A/V packet is cached firstly in
demux thread, and then decoded in audio/video decoding thread
you can not dynamically switch to a new codec by avcodec_close(), the
audio/video decoding thread will crash if they still use the older
codec to decode the old cached A/V packet.

We need a general implementation to support codec dynamically switch,
at least the implementation should behave the same logic as
av_find_stream_info() (such as detecting the necessary codec
information)

-- 
-----------------------------------------------------------------------------------------
My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2



More information about the ffmpeg-devel mailing list