[FFmpeg-cvslog] avcodec/mediacodec: fix incorrect crop info
Zhao Zhili
git at videolan.org
Mon Nov 21 18:05:10 EET 2022
ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Mon Oct 10 23:19:02 2022 +0800| [093c4373214f002decc73ce337450d7ec641b3f4] | committer: Zhao Zhili
avcodec/mediacodec: fix incorrect crop info
The crop info is optional, but used unconditionally.
Co-authored-by: Aman Karmani <ffmpeg at tmm1.net>
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=093c4373214f002decc73ce337450d7ec641b3f4
---
libavcodec/mediacodecdec_common.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index 2a605e7f5b..f430cfed31 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -487,8 +487,20 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte
AMEDIAFORMAT_GET_INT32(s->crop_left, "crop-left", 0);
AMEDIAFORMAT_GET_INT32(s->crop_right, "crop-right", 0);
- width = s->crop_right + 1 - s->crop_left;
- height = s->crop_bottom + 1 - s->crop_top;
+ if (s->crop_right && s->crop_bottom) {
+ width = s->crop_right + 1 - s->crop_left;
+ height = s->crop_bottom + 1 - s->crop_top;
+ } else {
+ /* TODO: NDK MediaFormat should try getRect() first.
+ * Try crop-width/crop-height, it works on NVIDIA Shield.
+ */
+ AMEDIAFORMAT_GET_INT32(width, "crop-width", 0);
+ AMEDIAFORMAT_GET_INT32(height, "crop-height", 0);
+ }
+ if (!width || !height) {
+ width = s->width;
+ height = s->height;
+ }
AMEDIAFORMAT_GET_INT32(s->display_width, "display-width", 0);
AMEDIAFORMAT_GET_INT32(s->display_height, "display-height", 0);
More information about the ffmpeg-cvslog
mailing list