summaryrefslogtreecommitdiff
path: root/libavformat/avienc.c
diff options
context:
space:
mode:
authorTobias Rapp <t.rapp@noa-archive.com>2017-11-27 09:13:05 +0100
committerTobias Rapp <t.rapp@noa-archive.com>2017-11-27 09:13:05 +0100
commit26c0c84784f1f4e73e2de25b09b659781f06b0f2 (patch)
tree890e9ca4b2e1070222f51e8c37b936c745480718 /libavformat/avienc.c
parent0e93694e64cdc72f7ccb8a986171593e672b8dba (diff)
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: Tobias Rapp <t.rapp@noa-archive.com>
Diffstat (limited to 'libavformat/avienc.c')
-rw-r--r--libavformat/avienc.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 483f5b54b1..ac0f04c354 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -501,8 +501,14 @@ static int avi_write_header(AVFormatContext *s)
AVRational dar = av_mul_q(st->sample_aspect_ratio,
(AVRational) { par->width,
par->height });
- int num, den;
+ int num, den, fields, i;
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 standard = unknown
@@ -514,17 +520,30 @@ static int avi_write_header(AVFormatContext *s)
avio_wl16(pb, num);
avio_wl32(pb, par->width);
avio_wl32(pb, par->height);
- avio_wl32(pb, 1); // progressive FIXME
-
- avio_wl32(pb, par->height);
- avio_wl32(pb, par->width);
- avio_wl32(pb, par->height);
- avio_wl32(pb, par->width);
- avio_wl32(pb, 0);
- avio_wl32(pb, 0);
+ avio_wl32(pb, fields); // fields per frame
+
+ for (i = 0; i < fields; i++) {
+ int start_line;
+ // OpenDML v1.02 is not very specific on what value to use for
+ // start_line when frame data is not coming from a capturing device,
+ // so just use 0/1 depending on the field order for interlaced frames
+ 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, 0);
+ avio_wl32(pb, par->height / fields); // compressed bitmap height
+ 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);
}