From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A1B9844629 for ; Sat, 19 Nov 2022 22:55:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8BE5368AF9F; Sun, 20 Nov 2022 00:55:54 +0200 (EET) Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEDEC68AE3C for ; Sun, 20 Nov 2022 00:55:47 +0200 (EET) Received: by mail-qk1-f171.google.com with SMTP id v8so5869132qkg.12 for ; Sat, 19 Nov 2022 14:55:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=46uigIj5jUrDBG51TZWiYStgHInJrDvm9EyyACkJ66I=; b=FeJo9NCDnT6P0q3EtOe8D1PZFMvlRl6FmRQHq/Ugs9Sb/VOM0GM3Fte0ETdHrvlcV9 D3mQJ+FjZ2n4GmwJVcpstY7P1Sx2bA7bRShfqkA7G6Bg3RWx+IwTLGc7eIQw4BcFUzfB pJqtQZCx/O6nP+cHlzZ4lRq/fwU3hZAlH58i5oBs1mQ/Ycn4PMQMOyA4HMDPKpI/Pfzz EOVYjKvYZu/oyWongDDqYnkd7De2uLf/xEpm5nW/J61A+fmV3Gk45z/dKlyaTu86gBEb qFC9zmVk9p5stvab+QN0hF5eERg54RRDEPMiqHmc4QwqyGqxQ/DNnAfFszxTIaSQr4k4 DuDg== X-Gm-Message-State: ANoB5pn6kxeFbn0FeE8Ah2C6AIh3+WOkEEy+GiTrNQ34taXuJB6Rbe3L 64hHTFHnxS7LWNXSXwd3KF2hbYsypYj3zp7qE10= X-Google-Smtp-Source: AA0mqf5kptjPrRSlbVzF0lL7f+733/LtQJ4r1AVz1aPs0SIJg6jXw3QMHiT7AdcnI76alwe4xtFCmvWSeO6DwFMfLBI= X-Received: by 2002:a05:620a:22c4:b0:6fa:5e09:905b with SMTP id o4-20020a05620a22c400b006fa5e09905bmr11486279qki.526.1668898546577; Sat, 19 Nov 2022 14:55:46 -0800 (PST) MIME-Version: 1.0 References: <20221024031658.1026118-1-quinkblack@foxmail.com> In-Reply-To: From: Aman Karmani Date: Sat, 19 Nov 2022 14:55:35 -0800 Message-ID: To: Zhao Zhili X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH 01/12] avcodec/mediacodec: fix incorrect crop info X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: ffmpeg-devel@ffmpeg.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sat, Nov 19, 2022 at 6:56 AM Zhao Zhili wrote: > On Sat, 2022-11-19 at 00:20 -0800, Aman Karmani wrote: > > Thank you for your work on this patchset! > > > > On Sun, Oct 23, 2022 at 8:17 PM Zhao Zhili > > wrote: > > > From: Zhao Zhili > > > > > > The crop info is optional, but used unconditionally. > > > > > > Signed-off-by: Zhao Zhili > > > --- > > > libavcodec/mediacodecdec_common.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/libavcodec/mediacodecdec_common.c > > > b/libavcodec/mediacodecdec_common.c > > > index 2a605e7f5b..c1cbb28488 100644 > > > --- a/libavcodec/mediacodecdec_common.c > > > +++ b/libavcodec/mediacodecdec_common.c > > > @@ -487,6 +487,11 @@ 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); > > > > > > + if (s->crop_bottom == 0 || s->crop_right == 0) { > > > + s->crop_top = s->crop_left = 0; > > > + s->crop_right = s->width - 1; > > > + s->crop_bottom = s->height - 1; > > > + } > > > width = s->crop_right + 1 - s->crop_left; > > > height = s->crop_bottom + 1 - s->crop_top; > > > > I had another approach I have been using for some time. WDYT? > > > > > http://github.com/tmm1/ffmpeg/commit/ebc0ef75d25e712278c34427ef2f7d42f3dcf883 > > I found the issue when testing NDK mediacodec. There is no 'crop-left', > 'crop-right' and so on. However, there is a 'crop' field in AMediaForma > t, for example: > > android._video-scaling: int32(1), crop: Rect(0, 0, 1919, 1079), color- > standard: int32(1), ... > > Unfortunately, it's available only since API level 28: > > ------------------------------------------------ > extern const char* AMEDIAFORMAT_KEY_DISPLAY_CROP __INTRODUCED_IN(28); > > /** > * Available since API level 28. > */ > bool AMediaFormat_getRect(AMediaFormat*, const char *name, > int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) > __INTRODUCED_IN(28); > ------------------------------------------------- > > So we need to add a new API in mediacodec_wrapper first, then extract > crop info. It's on my TODO list. Ah, yes I remember now. When I tried it, there was no way to access crop information. I filed this bug: https://issuetracker.google.com/issues/111262883?pli=1 > > > For your patch, > > + AMEDIAFORMAT_GET_INT32(width, "crop-width", 0); > + AMEDIAFORMAT_GET_INT32(height, "crop-height", 0); > > I can't find documention about these fields, and they didn't show on > Google Pixel 3. What's the device model? We can use it as a fallback, > after crop-left/crop-right and crop rect failed. I checked this more and it seems to be specific to NVIDIA Shield. In that encoder there is also a non-standard way to request scaling before encode, so perhaps they added crop-{height,width} for scaling purposes as well. For reference you can find libavcodec/mediacodecndkdec.c inside https://downloads.plex.tv/ffmpeg-source/plex-media-server-ffmpeg-gpl-2427c1679fd.tar.gz > > > > > > > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".