matroskaenc.c applies divisors to the display width/height when generating stereo content. This patch adds the corresponding multipliers to matroskadec.c so that the original sample aspect ratio can be recovered.
Unified · Split
| @@ -1648,6 +1648,30 @@ static int matroska_parse_flac(AVFormatContext *s, · 1647 unmodified lines | |||
| 1648 | return 0; | 1648 | return 0; |
| 1649 | } | 1649 | } |
| 1650 | 1650 | ||
| 1651 | static void mkv_stereo_mode_display_mul(int stereo_mode, int *h_width, int *h_height) | ||
| 1652 | { | ||
| 1653 | switch (stereo_mode) { | ||
| 1654 | case MATROSKA_VIDEO_STEREOMODE_TYPE_MONO: | ||
| 1655 | case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL: | ||
| 1656 | case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR: | ||
| 1657 | case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL: | ||
| 1658 | case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR: | ||
| 1659 | break; | ||
| 1660 | case MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT: | ||
| 1661 | case MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT: | ||
| 1662 | case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL: | ||
| 1663 | case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR: | ||
| 1664 | *h_width = 2; | ||
| 1665 | break; | ||
| 1666 | case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP: | ||
| 1667 | case MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM: | ||
| 1668 | case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL: | ||
| 1669 | case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR: | ||
| 1670 | *h_height = 2; | ||
| 1671 | break; | ||
| 1672 | } | ||
| 1673 | } | ||
| 1674 | |||
| 1651 | static int matroska_parse_tracks(AVFormatContext *s) | 1675 | static int matroska_parse_tracks(AVFormatContext *s) |
| 1652 | { | 1676 | { |
| 1653 | MatroskaDemuxContext *matroska = s->priv_data; | 1677 | MatroskaDemuxContext *matroska = s->priv_data; |
| @@ -2007,6 +2031,8 @@ static int matroska_parse_tracks(AVFormatContext *s) · 353 unmodified lines | |||
| 2007 | 2031 | ||
| 2008 | if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { | 2032 | if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { |
| 2009 | MatroskaTrackPlane *planes = track->operation.combine_planes.elem; | 2033 | MatroskaTrackPlane *planes = track->operation.combine_planes.elem; |
| 2034 | int display_width_mul = 1; | ||
| 2035 | int display_height_mul = 1; | ||
| 2010 | 2036 | ||
| 2011 | st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | 2037 | st->codec->codec_type = AVMEDIA_TYPE_VIDEO; |
| 2012 | st->codec->codec_tag = fourcc; | 2038 | st->codec->codec_tag = fourcc; |
| @@ -2014,10 +2040,14 @@ static int matroska_parse_tracks(AVFormatContext *s) · 1 unmodified line | |||
| 2014 | st->codec->bits_per_coded_sample = bit_depth; | 2040 | st->codec->bits_per_coded_sample = bit_depth; |
| 2015 | st->codec->width = track->video.pixel_width; | 2041 | st->codec->width = track->video.pixel_width; |
| 2016 | st->codec->height = track->video.pixel_height; | 2042 | st->codec->height = track->video.pixel_height; |
| 2043 | |||
| 2044 | if (track->video.stereo_mode && track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB) | ||
| 2045 | mkv_stereo_mode_display_mul(track->video.stereo_mode, &display_width_mul, &display_height_mul); | ||
| 2046 | |||
| 2017 | av_reduce(&st->sample_aspect_ratio.num, | 2047 | av_reduce(&st->sample_aspect_ratio.num, |
| 2018 | &st->sample_aspect_ratio.den, | 2048 | &st->sample_aspect_ratio.den, |
| 2019 | st->codec->height * track->video.display_width, | 2049 | st->codec->height * track->video.display_width * display_width_mul, |
| 2020 | st->codec->width * track->video.display_height, | 2050 | st->codec->width * track->video.display_height * display_height_mul, |
| 2021 | 255); | 2051 | 255); |
| 2022 | if (st->codec->codec_id != AV_CODEC_ID_HEVC) | 2052 | if (st->codec->codec_id != AV_CODEC_ID_HEVC) |
| 2023 | st->need_parsing = AVSTREAM_PARSE_HEADERS; | 2053 | st->need_parsing = AVSTREAM_PARSE_HEADERS; |