[FFmpeg-cvslog] avformat/wtvenc: pad judiciously when writing mpeg2 extradata

Peter Ross git at videolan.org
Sun Mar 30 06:32:33 CEST 2014


ffmpeg | branch: master | Peter Ross <pross at xvid.org> | Sun Mar 30 12:43:50 2014 +1100| [31ac3f306c45ed6bbc90ced2f17f06d9d809be50] | committer: Michael Niedermayer

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 at xvid.org>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31ac3f306c45ed6bbc90ced2f17f06d9d809be50
---

 libavformat/wtvenc.c    |    5 +++--
 tests/ref/lavf/wtv      |    2 +-
 tests/ref/seek/lavf-wtv |   44 ++++++++++++++++++++++----------------------
 3 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index b82ff0b..a1286ae 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -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);
     }
 }
 
diff --git a/tests/ref/lavf/wtv b/tests/ref/lavf/wtv
index 8d69f79..034a0f5 100644
--- a/tests/ref/lavf/wtv
+++ b/tests/ref/lavf/wtv
@@ -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
diff --git a/tests/ref/seek/lavf-wtv b/tests/ref/seek/lavf-wtv
index 2808c10..355ab98 100644
--- a/tests/ref/seek/lavf-wtv
+++ b/tests/ref/seek/lavf-wtv
@@ -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



More information about the ffmpeg-cvslog mailing list