Commit 26c0c847 authored by Tobias Rapp's avatar Tobias Rapp

avformat/avienc: fix fields-per-frame value for interlaced video streams

Writes one set of field framing information for progressive streams and
two sets for interlaced streams. Fixes ticket #6383.

Unfortunately the OpenDML v1.02 document is not very specific on what
value to use for start_line when frame data is not coming from a
capturing device, so this is just using 0/1 depending on the field order
as a best-effort guess.
Signed-off-by: 's avatarTobias Rapp <t.rapp@noa-archive.com>
parent 0e93694e
...@@ -501,8 +501,14 @@ static int avi_write_header(AVFormatContext *s) ...@@ -501,8 +501,14 @@ static int avi_write_header(AVFormatContext *s)
AVRational dar = av_mul_q(st->sample_aspect_ratio, AVRational dar = av_mul_q(st->sample_aspect_ratio,
(AVRational) { par->width, (AVRational) { par->width,
par->height }); par->height });
int num, den; int num, den, fields, i;
av_reduce(&num, &den, dar.num, dar.den, 0xFFFF); av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
if (par->field_order == AV_FIELD_TT || par->field_order == AV_FIELD_BB ||
par->field_order == AV_FIELD_TB || par->field_order == AV_FIELD_BT) {
fields = 2; // interlaced
} else {
fields = 1; // progressive
}
avio_wl32(pb, 0); // video format = unknown avio_wl32(pb, 0); // video format = unknown
avio_wl32(pb, 0); // video standard = unknown avio_wl32(pb, 0); // video standard = unknown
...@@ -514,17 +520,30 @@ static int avi_write_header(AVFormatContext *s) ...@@ -514,17 +520,30 @@ static int avi_write_header(AVFormatContext *s)
avio_wl16(pb, num); avio_wl16(pb, num);
avio_wl32(pb, par->width); avio_wl32(pb, par->width);
avio_wl32(pb, par->height); avio_wl32(pb, par->height);
avio_wl32(pb, 1); // progressive FIXME avio_wl32(pb, fields); // fields per frame
avio_wl32(pb, par->height); for (i = 0; i < fields; i++) {
avio_wl32(pb, par->width); int start_line;
avio_wl32(pb, par->height); // OpenDML v1.02 is not very specific on what value to use for
avio_wl32(pb, par->width); // start_line when frame data is not coming from a capturing device,
avio_wl32(pb, 0); // so just use 0/1 depending on the field order for interlaced frames
avio_wl32(pb, 0); if (par->field_order == AV_FIELD_TT || par->field_order == AV_FIELD_TB) {
start_line = (i == 0) ? 0 : 1;
} else if (par->field_order == AV_FIELD_BB || par->field_order == AV_FIELD_BT) {
start_line = (i == 0) ? 1 : 0;
} else {
start_line = 0;
}
avio_wl32(pb, 0); avio_wl32(pb, par->height / fields); // compressed bitmap height
avio_wl32(pb, 0); avio_wl32(pb, par->width); // compressed bitmap width
avio_wl32(pb, par->height / fields); // valid bitmap height
avio_wl32(pb, par->width); // valid bitmap width
avio_wl32(pb, 0); // valid bitmap X offset
avio_wl32(pb, 0); // valid bitmap Y offset
avio_wl32(pb, 0); // valid X offset in T
avio_wl32(pb, start_line); // valid Y start line
}
ff_end_tag(pb, vprp); ff_end_tag(pb, vprp);
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// Also please add any ticket numbers that you believe might be affected here // Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58 #define LIBAVFORMAT_VERSION_MAJOR 58
#define LIBAVFORMAT_VERSION_MINOR 2 #define LIBAVFORMAT_VERSION_MINOR 2
#define LIBAVFORMAT_VERSION_MICRO 102 #define LIBAVFORMAT_VERSION_MICRO 103
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \ LIBAVFORMAT_VERSION_MINOR, \
......
6f6b211cbc8de9871e8e09e64048e2f9 *tests/data/fate/copy-trac2211-avi.avi 0920978f3f8196413c43f0033b55a5b6 *tests/data/fate/copy-trac2211-avi.avi
1777924 tests/data/fate/copy-trac2211-avi.avi 1777956 tests/data/fate/copy-trac2211-avi.avi
#tb 0: 1/14 #tb 0: 1/14
#media_type 0: video #media_type 0: video
#codec_id 0: rawvideo #codec_id 0: rawvideo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment