[FFmpeg-cvslog] wtvenc: populate VIDEOINFOHEADER2

Peter Ross git at videolan.org
Mon Dec 23 15:58:36 CET 2013


ffmpeg | branch: master | Peter Ross <pross at xvid.org> | Mon Dec 23 20:37:28 2013 +1100| [6da21c1f8190d674fd1e5619bb148c1bbab8ca3c] | committer: Michael Niedermayer

wtvenc: populate VIDEOINFOHEADER2

Fixes ticket #2835.

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=6da21c1f8190d674fd1e5619bb148c1bbab8ca3c
---

 libavformat/wtvenc.c    |   51 +++++++++++++++++++++++++++++++++++++++--------
 tests/ref/lavf/wtv      |    2 +-
 tests/ref/seek/lavf-wtv |   44 ++++++++++++++++++++--------------------
 3 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index 04e6cc2..ba0f178 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -223,9 +223,50 @@ static void finish_chunk(AVFormatContext *s)
         write_index(s);
 }
 
+static void put_videoinfoheader2(AVIOContext *pb, AVStream *st)
+{
+    AVRational dar = av_mul_q(st->sample_aspect_ratio, (AVRational){st->codec->width, st->codec->height});
+    unsigned int num, den;
+    av_reduce(&num, &den, dar.num, dar.den, 0xFFFFFFFF);
+
+    /* VIDEOINFOHEADER2 */
+    avio_wl32(pb, 0);
+    avio_wl32(pb, 0);
+    avio_wl32(pb, st->codec->width);
+    avio_wl32(pb, st->codec->height);
+
+    avio_wl32(pb, 0);
+    avio_wl32(pb, 0);
+    avio_wl32(pb, 0);
+    avio_wl32(pb, 0);
+
+    avio_wl32(pb, st->codec->bit_rate);
+    avio_wl32(pb, 0);
+    avio_wl64(pb, st->avg_frame_rate.num && st->avg_frame_rate.den ? INT64_C(10000000) / av_q2d(st->avg_frame_rate) : 0);
+    avio_wl32(pb, 0);
+    avio_wl32(pb, 0);
+
+    avio_wl32(pb, num);
+    avio_wl32(pb, den);
+    avio_wl32(pb, 0);
+    avio_wl32(pb, 0);
+
+    ff_put_bmp_header(pb, st->codec, ff_codec_bmp_tags, 0, 1);
+
+    if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+        /* MPEG2VIDEOINFO */
+        avio_wl32(pb, 0);
+        avio_wl32(pb, st->codec->extradata_size);
+        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);
+    }
+}
+
 static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
 {
-    WtvContext *wctx = s->priv_data;
     const ff_asf_guid *g, *media_type, *format_type;
     AVIOContext *pb = s->pb;
     int64_t  hdr_pos_start;
@@ -257,13 +298,7 @@ static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
 
     hdr_pos_start = avio_tell(pb);
     if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-        if (wctx->first_video_flag) {
-            write_pad(pb, 216); //The size is sensitive.
-            wctx->first_video_flag = 0;
-        } else {
-            write_pad(pb, 72); // aspect ratio
-            ff_put_bmp_header(pb, st->codec, ff_codec_bmp_tags, 0);
-        }
+        put_videoinfoheader2(pb, st);
     } else {
         ff_put_wav_header(pb, st->codec);
     }
diff --git a/tests/ref/lavf/wtv b/tests/ref/lavf/wtv
index fe1b83c..8d69f79 100644
--- a/tests/ref/lavf/wtv
+++ b/tests/ref/lavf/wtv
@@ -1,3 +1,3 @@
-98dd5205889313542da71351fbaf4172 *./tests/data/lavf/lavf.wtv
+13cbdaf2c5e7c97991781cc48d9a958f *./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 71703c5..2808c10 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:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size:   209
 ret: 0         st: 0 flags:0  ts: 0.788334
-ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size:   209
 ret: 0         st: 0 flags:1  ts:-0.317499
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 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: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size:   209
 ret: 0         st:-1 flags:0  ts: 0.365002
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st:-1 flags:1  ts:-0.740831
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 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:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st: 1 flags:0  ts:-0.058330
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st: 1 flags:1  ts: 2.835837
-ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 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:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st: 0 flags:0  ts:-0.481662
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st: 0 flags:1  ts: 2.412505
-ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 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:  99352 size:   209
+ret: 0         st: 1 flags:1 dts: 0.211950 pts: 0.211950 pos:  99296 size:   209
 ret: 0         st:-1 flags:0  ts:-0.904994
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st:-1 flags:1  ts: 1.989173
-ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size:   209
 ret: 0         st: 0 flags:0  ts: 0.883340
-ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size:   209
 ret: 0         st: 0 flags:1  ts:-0.222493
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 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: 294744 size:   209
+ret: 0         st: 1 flags:1 dts: 0.734399 pts: 0.734399 pos: 294688 size:   209
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208
 ret: 0         st:-1 flags:1  ts:-0.645825
-ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26344 size:   208
+ret: 0         st: 1 flags:1 dts: 0.029093 pts: 0.029093 pos:  26288 size:   208



More information about the ffmpeg-cvslog mailing list