diff options
author | Peter Ross <pross@xvid.org> | 2013-12-23 20:37:28 +1100 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2013-12-24 07:59:01 +0100 |
commit | fa45feefad0e653ff32a216e7bb98095a10ba49e (patch) | |
tree | 3170086833062184cc57b3f989f5fb2f56258c2d | |
parent | 9f3135b30bfb04dc507305044687797cdb73bfa2 (diff) | |
download | ffmpeg-fa45feefad0e653ff32a216e7bb98095a10ba49e.tar.gz |
wtvenc: populate VIDEOINFOHEADER2
Fixes ticket #2835.
Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 6da21c1f8190d674fd1e5619bb148c1bbab8ca3c)
Conflicts:
tests/ref/lavf/wtv
tests/ref/seek/lavf-wtv
-rw-r--r-- | libavformat/wtvenc.c | 51 | ||||
-rw-r--r-- | tests/ref/lavf/wtv | 2 | ||||
-rw-r--r-- | tests/ref/seek/lavf-wtv | 44 |
3 files changed, 66 insertions, 31 deletions
diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c index 22917a454c..9e44001c02 100644 --- a/libavformat/wtvenc.c +++ b/libavformat/wtvenc.c @@ -227,9 +227,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; @@ -261,13 +302,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 8f2c2acc6c..bcdcb3e8f3 100644 --- a/tests/ref/lavf/wtv +++ b/tests/ref/lavf/wtv @@ -1,3 +1,3 @@ -345516d3a03fd239c62e5e7257c9f4a2 *./tests/data/lavf/lavf.wtv +ea7ac962126198092454f36cc3af3433 *./tests/data/lavf/lavf.wtv 413696 ./tests/data/lavf/lavf.wtv ./tests/data/lavf/lavf.wtv CRC=0xcc2dc628 diff --git a/tests/ref/seek/lavf-wtv b/tests/ref/seek/lavf-wtv index 67def8aae3..c214cde7db 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.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294688 size: 209 ret: 0 st: 0 flags:0 ts: 0.788334 -ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294688 size: 209 ret: 0 st: 0 flags:1 ts:-0.317499 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 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.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294688 size: 209 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 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.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294688 size: 209 ret: 0 st: 1 flags:0 ts:-0.058330 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st: 1 flags:1 ts: 2.835837 -ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 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.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st: 0 flags:0 ts:-0.481662 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st: 0 flags:1 ts: 2.412505 -ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 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.224195 pts: 0.224195 pos: 112904 size: 209 +ret: 0 st: 1 flags:1 dts: 0.224195 pts: 0.224195 pos: 112848 size: 209 ret: 0 st:-1 flags:0 ts:-0.904994 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294688 size: 209 ret: 0 st: 0 flags:0 ts: 0.883340 -ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294688 size: 209 ret: 0 st: 0 flags:1 ts:-0.222493 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 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.694399 pts: 0.694399 pos: 294744 size: 209 +ret: 0 st: 1 flags:1 dts: 0.694399 pts: 0.694399 pos: 294688 size: 209 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26344 size: 208 +ret: 0 st: 1 flags:1 dts:-0.010907 pts:-0.010907 pos: 26288 size: 208 |