[MPlayer-dev-eng] [PATCH] delay-compensated B-frames and dwStart

Corey Hickey bugfood-ml at fatooh.org
Thu Feb 9 06:45:20 CET 2006


This patch is the combination of my earlier efforts into (a)fixing video
delay when encoding with B-frames and (b)making mplayer/mencoder
recognize dwStart correctly. The history of each topic is in two
respective threads on mplayer-dev-eng; both were started by myself:

Subject: [PATCH] mencoder, B-frames, and video/audio delay
Date: Fri, 20 Jan 2006 16:09:15 -0800

Subject: dwStart (stream delay in AVI files)
Date: Mon, 30 Jan 2006 20:17:05 -0800


I'm sending this in for review as one big patch because some of the changes
I propose don't make much sense out of context of the other changes. Once
all the changes look acceptable I intend to propose them as a few smaller,
self-contained patches, so please don't tell me to separate them just yet.

-------------------------------changes------------------------------------

1. demux_avi recognizes dwStart values and calculates the stream delay in
seconds. These are stored individually in sh_audio->stream_delay and
sh_video->stream_delay. Other demuxers are free to set stream_delay in the
same manner.

2. MPlayer applies the stream delays to audio_delay. This is cumulative with
any delay specified by the '-delay' option.

3. MEncoder applies the stream delays to muxer->audio_delay_fix. This is
cumulative with delays specified by the '-audio-delay' option.

4. muxer_avi writes muxer->audio_delay_fix as a dwStart on the appropriate
stream. Other muxers are, of course, free to use muxer->audio_delay_fix in
the same manner.

5. mencoder is no longer restricted to positive values with '-audio-delay'.
Negative values are applied (inverted) to the video stream. This is
documented in the man page.

6. There is a new option: '-ignore-start'. This makes MPlayer and MEncoder
ignore any delays specified by dwStart. I found this useful during testing,
so I left it in and documented it. I don't care strongly, though, so it
could be left out if nobody thinks it's useful enough. Or, if somebody comes
up with a better option name...

7. The video encoders that support B-frames adjust for encoding delay by
incrementing mux_v->encoder_delay every time an input frame doesn't result
in an output frame (meaning the encoder has it buffered). This lets MEncoder
adjust its internal A-V sync smoothly and avoid duplicating frames
unnecessarily.

8. The video encoders that support B-frames set mux_v->decoder_delay to 1
when B-frames are used. ve_x264 sets decoder_delay=2 when b_pyramid is in
use. MEncoder applies decoder_delay to muxer->audio_delay_fix cumulatively
with what may already be there from '-audio-delay' and/or from the source
dwStart. Whatever remains is written as a dwStart to the appropriate stream
when using muxer_avi.

--------------------------------------------------------------------------

So, what do you think? What needs fixing? I'm not going to threaten to apply
this because there are too many diverse changes; I would really appreciate
any testing and feedback, though. If I don't hear anything negative then I'm
going to make a patch to let MPlayer support dwStart, threaten to apply that
one, and move forward from there with individual patches for the rest of the
changes.

-Corey
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bframes-and-dwStart.diff
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20060208/3e8d4463/attachment.txt>


More information about the MPlayer-dev-eng mailing list