diff options
author | Aaron Colwell <acolwell@google.com> | 2015-12-02 18:13:18 -0500 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-12-07 11:27:42 -0500 |
commit | febfb49a70e82f5ac46dc7ea34dabd4d56b19b31 (patch) | |
tree | 16e8c4026bea65f08ae6012d5aa83a1ec6c01204 /libavformat/matroskadec.c | |
parent | c34df422628e6b7b657faee241fe7bb2629e0f57 (diff) | |
download | ffmpeg-febfb49a70e82f5ac46dc7ea34dabd4d56b19b31.tar.gz |
matroskadec: Fix sample_aspect_ratio for stereo matroska content
matroskaenc applies divisors to the display width/height when generating
stereo content. This patch adds the corresponding multipliers to matroskadec
so that the original sample aspect ratio can be recovered.
Signed-off-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r-- | libavformat/matroskadec.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index bdf2eb4219..0757bf586f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1525,6 +1525,31 @@ static int matroska_parse_flac(AVFormatContext *s, return 0; } +static void mkv_stereo_mode_display_mul(int stereo_mode, + int *h_width, int *h_height) +{ + switch (stereo_mode) { + case MATROSKA_VIDEO_STEREOMODE_TYPE_MONO: + case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL: + case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR: + case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL: + case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR: + break; + case MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT: + case MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT: + case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL: + case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR: + *h_width = 2; + break; + case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP: + case MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM: + case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL: + case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR: + *h_height = 2; + break; + } +} + static int matroska_parse_tracks(AVFormatContext *s) { MatroskaDemuxContext *matroska = s->priv_data; @@ -1810,14 +1835,21 @@ static int matroska_parse_tracks(AVFormatContext *s) } if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { + int display_width_mul = 1; + int display_height_mul = 1; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_tag = track->video.fourcc; st->codec->width = track->video.pixel_width; st->codec->height = track->video.pixel_height; + + if (track->video.stereo_mode && track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB) + mkv_stereo_mode_display_mul(track->video.stereo_mode, &display_width_mul, &display_height_mul); + av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, - st->codec->height * track->video.display_width, - st->codec->width * track->video.display_height, + st->codec->height * track->video.display_width * display_width_mul, + st->codec->width * track->video.display_height * display_height_mul, 255); if (st->codec->codec_id != AV_CODEC_ID_H264 && st->codec->codec_id != AV_CODEC_ID_HEVC) |