Added release note for change

This commit is contained in:
microkatz 2024-08-28 12:42:57 +00:00
parent 0ac26c4004
commit f1654732a6
3 changed files with 21 additions and 17 deletions

View File

@ -66,6 +66,9 @@
`Surface` in `configure` and calls to a new method `detachOutputSurface` `Surface` in `configure` and calls to a new method `detachOutputSurface`
to remove a previously set `Surface` if the codec supports this to remove a previously set `Surface` if the codec supports this
(`MediaCodecInfo.detachedSurfaceSupported`). (`MediaCodecInfo.detachedSurfaceSupported`).
* Use `MediaCodecAdapter` supplied pixel aspect ratio values if provided
when processing `onOutputFormatChanged`
([#1371](https://github.com/androidx/media/pull/1371)).
* Text: * Text:
* Metadata: * Metadata:
* Image: * Image:

View File

@ -1342,16 +1342,17 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
? mediaFormat.getInteger(KEY_CROP_BOTTOM) - mediaFormat.getInteger(KEY_CROP_TOP) + 1 ? mediaFormat.getInteger(KEY_CROP_BOTTOM) - mediaFormat.getInteger(KEY_CROP_TOP) + 1
: mediaFormat.getInteger(MediaFormat.KEY_HEIGHT); : mediaFormat.getInteger(MediaFormat.KEY_HEIGHT);
} }
boolean hasPixelAspectRatio =
(Util.SDK_INT >= 30) pixelWidthHeightRatio = format.pixelWidthHeightRatio;
if (Util.SDK_INT >= 30
&& mediaFormat != null && mediaFormat != null
&& mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH) && mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH)
&& mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT); && mediaFormat.containsKey(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT)) {
pixelWidthHeightRatio = pixelWidthHeightRatio =
hasPixelAspectRatio (float) mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH)
? (float) mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH) / mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT);
/ mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT) }
: format.pixelWidthHeightRatio;
// The decoder applies the rotation when rendering to the surface. For 90 and 270 degree // 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 // rotations, we need to flip the width, height and pixel aspect ratio to reflect the rotation
// that was applied. // that was applied.

View File

@ -116,6 +116,7 @@ public class MediaCodecVideoRendererTest {
.setSampleMimeType(MimeTypes.VIDEO_H264) .setSampleMimeType(MimeTypes.VIDEO_H264)
.setWidth(1920) .setWidth(1920)
.setHeight(1080) .setHeight(1080)
.setPixelWidthHeightRatio(1.0f)
.build(); .build();
private static final TrackGroup TRACK_GROUP_H264 = new TrackGroup(VIDEO_H264); private static final TrackGroup TRACK_GROUP_H264 = new TrackGroup(VIDEO_H264);
@ -762,12 +763,9 @@ public class MediaCodecVideoRendererTest {
public MediaFormat getOutputFormat() { public MediaFormat getOutputFormat() {
MediaFormat mediaFormat = adapter.getOutputFormat(); MediaFormat mediaFormat = adapter.getOutputFormat();
if (Util.SDK_INT >= 30) { if (Util.SDK_INT >= 30) {
int pixelAspectRatioHeight = 1 << 30; // Max integer power of 2. // Change to 9:16 Ratio
int pixelAspectRatioWidth = (int) (0.5f * pixelAspectRatioHeight); mediaFormat.setInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH, 9);
mediaFormat.setInteger( mediaFormat.setInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT, 16);
MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH, pixelAspectRatioWidth);
mediaFormat.setInteger(
MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT, pixelAspectRatioHeight);
} }
return mediaFormat; return mediaFormat;
} }
@ -825,7 +823,9 @@ public class MediaCodecVideoRendererTest {
verify(eventListener) verify(eventListener)
.onVideoSizeChanged( .onVideoSizeChanged(
new VideoSize( new VideoSize(
VIDEO_H264.width, VIDEO_H264.height, VIDEO_H264.pixelWidthHeightRatio / 2)); VIDEO_H264.width,
VIDEO_H264.height,
/* pixelWidthHeightRatio= */ VIDEO_H264.pixelWidthHeightRatio * (9.0f / 16.0f)));
} }
@Test @Test