[MPlayer-dev-eng] [PATCH] twopass xvid encoding of indata with multiple headers

Noa Resare noa at resare.com
Mon Nov 29 18:56:11 CET 2004


When I was trying to encode my "Finding Nemo" dvd with mencoder and two
pass xvid encoding the the actual bitrate of the resulting file was way
off.

I tracked it down to the fact that when decoding the mpeg2 stream from
the dvd it encounters multiple "header" segments in the datastream (I'm
unfamiliar with the correct terminology but I hope you get the idea). 
When mpeg2_parse() in libmpcodecs/vd_libmpeg2.c:decode() returns
STATE_SEQUENCE it triggers a call to xvid_encore() with second argument
XVID_ENC_CREATE in libmpcodecs/ve_xvid4.c:config(). The xvid library
then truncates the xvid-twopass.stats file and writes the statistics for
the remaining frames from the beginning of the file.

To avoid this the attached patch makes sure that consecutive calls to
libmpcodecs/vd.c:mpcodecs_config_vo() with the identical geometry and
output format arguments doesn't trigger multiple calls to vf->config().

To study the problem I have prepared a short clip that exhibits the
problem at the following location:
http://bilder.resare.com/tmp/short.avi (4 mb)

As far as I can tell it solves the problem with the truncated xvid-
twopass.stats file. Additionally it removes the error message "FATAL:
Cannot initialize video driver." when encoding the file with lavc.
(However, lavc seemingly just prints the error when receiving multiple
config() calls, no truncated stats file there). 

The patch applies cleanly to cvs HEAD and also seems to work with the
1.0pre5 release.

cheers/noa

ps. Please send me a copy if replying to this message as I'm not on the
list.

-- 
nuclear cia fbi spy password code president bomb
F3C4 AC90 B885 FE15 344B  4D05 220B 7662 A190 6F09
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplayer-twopass.patch
Type: text/x-patch
Size: 1413 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20041129/742d30dc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Detta ?r en digitalt signerad	meddelandedel
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20041129/742d30dc/attachment.pgp>


More information about the MPlayer-dev-eng mailing list