diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index 0bc6305eaf393..9295be2adca8d 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -1731,6 +1731,8 @@ void CDVDVideoCodecAndroidMediaCodec::ConfigureOutputFormat(CJNIMediaFormat& med int crop_top = 0; int crop_right = 0; int crop_bottom = 0; + int disp_width = 0; + int disp_height = 0; if (mediaformat.containsKey(CJNIMediaFormat::KEY_WIDTH)) width = mediaformat.getInteger(CJNIMediaFormat::KEY_WIDTH); @@ -1759,6 +1761,14 @@ void CDVDVideoCodecAndroidMediaCodec::ConfigureOutputFormat(CJNIMediaFormat& med crop_bottom = mediaformat.getInteger(CJNIMediaFormat::KEY_CROP_BOTTOM); } + // Note: These properties are not documented in the Android SDK but + // are available in the MediaFormat object. + // This is how it's done in ffmpeg too. + if (mediaformat.containsKey("display-width")) + disp_width = mediaformat.getInteger("display-width"); + if (mediaformat.containsKey("display-height")) + disp_height = mediaformat.getInteger("display-height"); + if (!crop_right) crop_right = width-1; if (!crop_bottom) @@ -1793,6 +1803,11 @@ void CDVDVideoCodecAndroidMediaCodec::ConfigureOutputFormat(CJNIMediaFormat& med m_videobuffer.iDisplayWidth = m_videobuffer.iWidth = width; m_videobuffer.iDisplayHeight = m_videobuffer.iHeight = height; + if (disp_width > 0 && disp_height > 0 && !m_hints.forced_aspect) + { + m_hints.aspect = static_cast(disp_width) / static_cast(disp_height); + } + if (m_hints.aspect > 1.0 && !m_hints.forced_aspect) { m_videobuffer.iDisplayWidth = ((int)lrint(m_videobuffer.iHeight * m_hints.aspect)) & ~3;