Skip to content

Commit

Permalink
Merge pull request xbmc#24750 from a1rwulf/bugfix_fix-android-mediaco…
Browse files Browse the repository at this point in the history
…dec-ar

VideoPlayer: MediaCodec - Fix PAL videos not rendering in fullscreen
  • Loading branch information
a1rwulf authored Mar 12, 2024
2 parents 401d715 + 1ca1dae commit 348313a
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<double>(disp_width) / static_cast<double>(disp_height);
}

if (m_hints.aspect > 1.0 && !m_hints.forced_aspect)
{
m_videobuffer.iDisplayWidth = ((int)lrint(m_videobuffer.iHeight * m_hints.aspect)) & ~3;
Expand Down

0 comments on commit 348313a

Please sign in to comment.