avformat/wtvenc: pad judiciously when writing mpeg2 extradata

Padding rule described here http://msdn.microsoft.com/en-us/library/windows/desktop/dd390707(v=vs.85).aspx

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Peter Ross 2014-03-30 12:43:50 +11:00 committed by Michael Niedermayer
parent 73a2d16bfa
commit 31ac3f306c
3 changed files with 26 additions and 25 deletions

View File

@ -243,14 +243,15 @@ static void put_videoinfoheader2(AVIOContext *pb, AVStream *st)
ff_put_bmp_header(pb, st->codec, ff_codec_bmp_tags, 0, 1);
if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
int padding = (st->codec->extradata_size & 3) ? 4 - (st->codec->extradata_size & 3) : 0;
/* MPEG2VIDEOINFO */
avio_wl32(pb, 0);
avio_wl32(pb, st->codec->extradata_size);
avio_wl32(pb, st->codec->extradata_size + padding);
avio_wl32(pb, -1);
avio_wl32(pb, -1);
avio_wl32(pb, 0);
avio_write(pb, st->codec->extradata, st->codec->extradata_size);
avio_wl64(pb, 0);
ffio_fill(pb, 0, padding);
}
}

View File

@ -1,3 +1,3 @@
13cbdaf2c5e7c97991781cc48d9a958f *./tests/data/lavf/lavf.wtv
363b349a85c9642bcc65d4296a5cab46 *./tests/data/lavf/lavf.wtv
413696 ./tests/data/lavf/lavf.wtv
./tests/data/lavf/lavf.wtv CRC=0x71287e25

View File

@ -1,48 +1,48 @@
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret: 0 st: 0 flags:0 ts: 0.788334
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret: 0 st: 0 flags:1 ts:-0.317499
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret:-1 st: 1 flags:0 ts: 2.576668
ret: 0 st: 1 flags:1 ts: 1.470835
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret:-1 st: 0 flags:0 ts: 2.153336
ret: 0 st: 0 flags:1 ts: 1.047503
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st: 1 flags:0 ts:-0.058330
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st: 1 flags:1 ts: 2.835837
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret:-1 st:-1 flags:0 ts: 1.730004
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st: 0 flags:0 ts:-0.481662
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st: 0 flags:1 ts: 2.412505
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret:-1 st: 1 flags:0 ts: 1.306672
ret: 0 st: 1 flags:1 ts: 0.200839
ret: 0 st: 1 flags:1 dts: 0.211950 pts: 0.211950 pos: 99296 size: 209
ret: 0 st: 1 flags:1 dts: 0.211950 pts: 0.211950 pos: 99280 size: 209
ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret: 0 st: 0 flags:0 ts: 0.883340
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret: 0 st: 0 flags:1 ts:-0.222493
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret:-1 st: 1 flags:0 ts: 2.671674
ret: 0 st: 1 flags:1 ts: 1.565841
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size: 209
ret: 0 st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294672 size: 209
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26288 size: 208
ret: 0 st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos: 26272 size: 208