Skip to content

Commit

Permalink
Added release note for change
Browse files Browse the repository at this point in the history
  • Loading branch information
microkatz committed Aug 30, 2024
1 parent 0ac26c4 commit b16ce6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
`Surface` in `configure` and calls to a new method `detachOutputSurface`
to remove a previously set `Surface` if the codec supports this
(`MediaCodecInfo.detachedSurfaceSupported`).
* Use `MediaCodecAdapter` supplied pixel aspect ratio values if provided
when processing `onOutputFormatChanged`
([#1371](https://github.com/androidx/media/pull/1371)).
* Text:
* Metadata:
* Image:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1342,16 +1342,17 @@ protected void onOutputFormatChanged(Format format, @Nullable MediaFormat mediaF
? mediaFormat.getInteger(KEY_CROP_BOTTOM) - mediaFormat.getInteger(KEY_CROP_TOP) + 1
: mediaFormat.getInteger(MediaFormat.KEY_HEIGHT);
}
boolean hasPixelAspectRatio =
(Util.SDK_INT >= 30)
&& mediaFormat != null
&& mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH)
&& mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT);
pixelWidthHeightRatio =
hasPixelAspectRatio
? (float) mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH)
/ mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT)
: format.pixelWidthHeightRatio;

pixelWidthHeightRatio = format.pixelWidthHeightRatio;
if (Util.SDK_INT >= 30
&& mediaFormat != null
&& mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH)
&& mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT)) {
pixelWidthHeightRatio =
(float) mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH)
/ mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT);
}

// The decoder applies the rotation when rendering to the surface. For 90 and 270 degree
// rotations, we need to flip the width, height and pixel aspect ratio to reflect the rotation
// that was applied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ public MediaFormat getOutputFormat() {
MediaFormat mediaFormat = adapter.getOutputFormat();
if (Util.SDK_INT >= 30) {
int pixelAspectRatioHeight = 1 << 30; // Max integer power of 2.
int pixelAspectRatioWidth = (int) (0.5f * pixelAspectRatioHeight);
int pixelAspectRatioWidth = pixelAspectRatioHeight / 2;
mediaFormat.setInteger(
MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH, pixelAspectRatioWidth);
mediaFormat.setInteger(
Expand Down Expand Up @@ -825,7 +825,9 @@ public MediaFormat getOutputFormat() {
verify(eventListener)
.onVideoSizeChanged(
new VideoSize(
VIDEO_H264.width, VIDEO_H264.height, VIDEO_H264.pixelWidthHeightRatio / 2));
VIDEO_H264.width,
VIDEO_H264.height,
/* pixelWidthHeightRatio= */ VIDEO_H264.pixelWidthHeightRatio / 2));
}

@Test
Expand Down

0 comments on commit b16ce6d

Please sign in to comment.