diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-10-29 13:30:08 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-10-29 16:08:00 +0100 |
commit | 6103faaa51d2f46d6ccecaad9a089b4b42ff66ee (patch) | |
tree | 67e5def94d92fc5f5dcdbe08df98df25b370683a /libavformat | |
parent | a483aae7d8bcd37b50bb86345606bbcd2301110b (diff) | |
download | ffmpeg-6103faaa51d2f46d6ccecaad9a089b4b42ff66ee.tar.gz |
matroskaenc: fixed display width / height calculation for stereo mode
Based-on: patch by Asan Usipov <asan.usipov@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroskaenc.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index b9848b66a5..d8355b23cc 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -592,6 +592,8 @@ static int mkv_write_tracks(AVFormatContext *s) int bit_depth = av_get_bits_per_sample(codec->codec_id); int sample_rate = codec->sample_rate; int output_sample_rate = 0; + int display_width_div = 1; + int display_height_div = 1; AVDictionaryEntry *tag; if (codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) { @@ -723,6 +725,21 @@ static int mkv_write_tracks(AVFormatContext *s) return AVERROR(EINVAL); } else put_ebml_uint(pb, MATROSKA_ID_VIDEOSTEREOMODE, st_mode); + + switch (st_mode) { + case 1: + case 8: + case 9: + case 11: + display_width_div = 2; + break; + case 2: + case 3: + case 6: + case 7: + display_height_div = 2; + break; + } } if ((tag = av_dict_get(st->metadata, "alpha_mode", NULL, 0)) || @@ -737,8 +754,11 @@ static int mkv_write_tracks(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Overflow in display width\n"); return AVERROR(EINVAL); } - put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width); - put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height); + put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width / display_width_div); + put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height / display_height_div); + } else if (display_width_div != 1 || display_height_div != 1) { + put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , codec->width / display_width_div); + put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height / display_height_div); } if (codec->codec_id == AV_CODEC_ID_RAWVIDEO) { |