From 70483a59aacc2196d6685ee7100c817d42cea7e6 Mon Sep 17 00:00:00 2001 From: Magnus Jedvert Date: Fri, 18 Aug 2023 13:10:36 +0200 Subject: [PATCH] Add unscaled getWidth/Height to TextureBuffer interface Bug: b/289762633 Change-Id: I36a8c108ca03d464cd4dd08441dc9b64077343c1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/316860 Commit-Queue: Magnus Jedvert Reviewed-by: Fabian Bergmark Cr-Commit-Position: refs/heads/main@{#40567} --- .../api/org/webrtc/TextureBufferImpl.java | 10 ++-------- sdk/android/api/org/webrtc/VideoFrame.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/sdk/android/api/org/webrtc/TextureBufferImpl.java b/sdk/android/api/org/webrtc/TextureBufferImpl.java index c08fc4c29b..7e2bed84fc 100644 --- a/sdk/android/api/org/webrtc/TextureBufferImpl.java +++ b/sdk/android/api/org/webrtc/TextureBufferImpl.java @@ -140,18 +140,12 @@ public class TextureBufferImpl implements VideoFrame.TextureBuffer { (int) Math.round(unscaledHeight * cropHeight / (float) height), scaleWidth, scaleHeight); } - /** - * Returns the width of the texture in memory. This should only be used for downscaling, and you - * should still respect the width from getWidth(). - */ + @Override public int getUnscaledWidth() { return unscaledWidth; } - /** - * Returns the height of the texture in memory. This should only be used for downscaling, and you - * should still respect the height from getHeight(). - */ + @Override public int getUnscaledHeight() { return unscaledHeight; } diff --git a/sdk/android/api/org/webrtc/VideoFrame.java b/sdk/android/api/org/webrtc/VideoFrame.java index 52a378b8f8..443a0315af 100644 --- a/sdk/android/api/org/webrtc/VideoFrame.java +++ b/sdk/android/api/org/webrtc/VideoFrame.java @@ -146,6 +146,22 @@ public class VideoFrame implements RefCounted { Matrix transformMatrix, int newWidth, int newHeight) { throw new UnsupportedOperationException("Not implemented"); } + + /** + * Returns the width of the texture in memory. This should only be used for downscaling, and you + * should still respect the width from getWidth(). + */ + default public int getUnscaledWidth() { + return getWidth(); + } + + /** + * Returns the height of the texture in memory. This should only be used for downscaling, and + * you should still respect the height from getHeight(). + */ + default public int getUnscaledHeight() { + return getHeight(); + } } private final Buffer buffer;