Commit 33d55631 by Oliver Woodman

Fix handling of pixel aspect ratio change.

The new logic assumes that an input format change will be
followed by an output format change, but I think this is
pretty much guaranteed. If this weren't to happen then the
new pixel aspect ratio wont be picked up, but I think it's
extremely unlikely (it would require the format to stay
exactly the same except for the pixel aspect ratio, which
would be bizarre).
parent c7635c9d
...@@ -132,6 +132,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -132,6 +132,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
private int currentWidth; private int currentWidth;
private int currentHeight; private int currentHeight;
private float currentPixelWidthHeightRatio; private float currentPixelWidthHeightRatio;
private float pendingPixelWidthHeightRatio;
private int lastReportedWidth; private int lastReportedWidth;
private int lastReportedHeight; private int lastReportedHeight;
private float lastReportedPixelWidthHeightRatio; private float lastReportedPixelWidthHeightRatio;
...@@ -248,6 +249,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -248,6 +249,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
currentWidth = -1; currentWidth = -1;
currentHeight = -1; currentHeight = -1;
currentPixelWidthHeightRatio = -1; currentPixelWidthHeightRatio = -1;
pendingPixelWidthHeightRatio = -1;
lastReportedWidth = -1; lastReportedWidth = -1;
lastReportedHeight = -1; lastReportedHeight = -1;
lastReportedPixelWidthHeightRatio = -1; lastReportedPixelWidthHeightRatio = -1;
...@@ -316,6 +318,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -316,6 +318,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
currentWidth = -1; currentWidth = -1;
currentHeight = -1; currentHeight = -1;
currentPixelWidthHeightRatio = -1; currentPixelWidthHeightRatio = -1;
pendingPixelWidthHeightRatio = -1;
lastReportedWidth = -1; lastReportedWidth = -1;
lastReportedHeight = -1; lastReportedHeight = -1;
lastReportedPixelWidthHeightRatio = -1; lastReportedPixelWidthHeightRatio = -1;
...@@ -367,9 +370,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -367,9 +370,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
@Override @Override
protected void onInputFormatChanged(MediaFormatHolder holder) throws ExoPlaybackException { protected void onInputFormatChanged(MediaFormatHolder holder) throws ExoPlaybackException {
super.onInputFormatChanged(holder); super.onInputFormatChanged(holder);
// TODO: Ideally this would be read in onOutputFormatChanged, but there doesn't seem pendingPixelWidthHeightRatio = holder.format.pixelWidthHeightRatio == MediaFormat.NO_VALUE ? 1
// to be a way to pass a custom key/value pair value through to the output format.
currentPixelWidthHeightRatio = holder.format.pixelWidthHeightRatio == MediaFormat.NO_VALUE ? 1
: holder.format.pixelWidthHeightRatio; : holder.format.pixelWidthHeightRatio;
} }
...@@ -392,6 +393,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -392,6 +393,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
currentHeight = hasCrop currentHeight = hasCrop
? outputFormat.getInteger(KEY_CROP_BOTTOM) - outputFormat.getInteger(KEY_CROP_TOP) + 1 ? outputFormat.getInteger(KEY_CROP_BOTTOM) - outputFormat.getInteger(KEY_CROP_TOP) + 1
: outputFormat.getInteger(android.media.MediaFormat.KEY_HEIGHT); : outputFormat.getInteger(android.media.MediaFormat.KEY_HEIGHT);
currentPixelWidthHeightRatio = pendingPixelWidthHeightRatio;
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment