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 29F204382A for ; Sat, 1 Oct 2022 07:16:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4AEED68BAD5; Sat, 1 Oct 2022 10:16:40 +0300 (EEST) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA93B68B8C5 for ; Sat, 1 Oct 2022 10:16:33 +0300 (EEST) Received: by mail-lf1-f54.google.com with SMTP id c2so3570215lfb.10 for ; Sat, 01 Oct 2022 00:16:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date; bh=KR8EO4C6lW6a6bhLxjvDoCdnFsNvg57kxWKuzEZ8dsE=; b=ZB1CgQhH16mrZMQqfG9pIGP+IzxSov/1qRT6YCDNUBM/GEfu2brI2cxNmU8wBdeUVQ 4+5AzNmOMatb7BqydZf/hp1KRkv+xH7zoyHwszaYBCxRgeHdx4CQCLXBD3gUC9/SxSeo V6uIo3HmqmrwHSMVxs1SBVBjG14IY9+nbbdZeTtSEEwHLCA8xewU5mpUDeMtGUnltgms sq9mTF6ZF7gKRiBFUWfLHJ+Rawz5W5P48QIpJU0a8m/dQ96gV2BZIklhNkA+t1SWc/3+ /Ww2RQg/2GrB2tHbxTILVDZOPDwRSv+dHK7DfllezMPKLD2zi5KaIyKcEQV0b9g7iF+V E36g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date; bh=KR8EO4C6lW6a6bhLxjvDoCdnFsNvg57kxWKuzEZ8dsE=; b=4XDdQNycMjCIuuhdmVzH8jotLBILT53lM3Jo1BzSwHgXdabMhCXVvPE4wAm/WagyDy 8cm0s6cwFnArpLEWBBk5pAfmCaSY3uTWSHWMTmhsNjHyDCEYT3KJBrb5xl/smjxLiFi9 0YDKe7KKBWOQc3OscYMqguqPyiNa3KAUje1pjSE+b+vNNc9KS1/IH6jyDzi6MNr8JZVA WypDFZVaHfHCYrq1LvTZ7HedQo5ZnmXcNLULKHIfWdXVUgqFntBh6+svqID5fo/3YP2R EnjtfVZpQRjhjvJ6PKPScgsdr/M8htSaNkeM0EqIt2LqQi3+MVP/6c/9oAJPoXn31uEv neaQ== X-Gm-Message-State: ACrzQf2thAeHeaMWtP8L1TNriqDKvo3MPVoadRh2j0lPVjguI0Zh2USl s3e7cQNJ8pmTk+ZPomhB5Lc3AOe2k6CO64OXhBv3ysSF X-Google-Smtp-Source: AMsMyM5QGcwc5IR7qFHjH7rGAyk5Aj77cM0Zi8e2y2Jq6BxVrTxyV61NPNDrzT5iVRkQg92/f8PNj1zMN6tiscqlE+8= X-Received: by 2002:a05:6512:b0d:b0:4a1:baad:8d7a with SMTP id w13-20020a0565120b0d00b004a1baad8d7amr4844966lfu.293.1664608592147; Sat, 01 Oct 2022 00:16:32 -0700 (PDT) MIME-Version: 1.0 References: <20221001061341.662-1-ovchinnikov.dmitrii@gmail.com> <20221001061341.662-2-ovchinnikov.dmitrii@gmail.com> In-Reply-To: <20221001061341.662-2-ovchinnikov.dmitrii@gmail.com> From: Hendrik Leppkes Date: Sat, 1 Oct 2022 09:16:20 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop 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 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, Oct 1, 2022 at 8:14 AM OvchinnikovDmitrii wrote: > > Support both simple and receive_frame api > The container crop information is applied additional to frame crop information > --- > libavcodec/codec_par.c | 8 ++++++++ > libavcodec/decode.c | 20 ++++++++++++++++++++ > 2 files changed, 28 insertions(+) > > diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c > index abda649aa8..f74964a817 100644 > --- a/libavcodec/codec_par.c > +++ b/libavcodec/codec_par.c > @@ -118,6 +118,10 @@ int avcodec_parameters_from_context(AVCodecParameters *par, > par->format = codec->pix_fmt; > par->width = codec->width; > par->height = codec->height; > + par->crop_top = codec->crop_top; > + par->crop_left = codec->crop_left; > + par->crop_bottom = codec->crop_bottom; > + par->crop_right = codec->crop_right; > par->field_order = codec->field_order; > par->color_range = codec->color_range; > par->color_primaries = codec->color_primaries; > @@ -199,6 +203,10 @@ int avcodec_parameters_to_context(AVCodecContext *codec, > codec->pix_fmt = par->format; > codec->width = par->width; > codec->height = par->height; > + codec->crop_top = par->crop_top; > + codec->crop_left = par->crop_left; > + codec->crop_bottom = par->crop_bottom; > + codec->crop_right = par->crop_right; > codec->field_order = par->field_order; > codec->color_range = par->color_range; > codec->color_primaries = par->color_primaries; > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index 6be2d3d6ed..548225c904 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -324,6 +324,16 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, > emms_c(); > actual_got_frame = got_frame; > > + /* crop for simple api mode. apply additional container crop info to frame */ > + if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) { > + if (avctx->crop_top != 0 || avctx->crop_left != 0 || avctx->crop_right != 0 || avctx->crop_bottom != 0){ > + frame->crop_top += avctx->crop_top; > + frame->crop_left += avctx->crop_left; > + frame->crop_right += avctx->crop_right; > + frame->crop_bottom += avctx->crop_bottom; > + } > + } > + > if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) { > if (frame->flags & AV_FRAME_FLAG_DISCARD) > got_frame = 0; > @@ -707,6 +717,16 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame) > > if (avci->buffer_frame->buf[0]) { > av_frame_move_ref(frame, avci->buffer_frame); > + > + /* crop for receive_frame api mode. apply additional container crop info to frame */ > + if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) { > + if (avctx->crop_top != 0 || avctx->crop_left != 0 || avctx->crop_right != 0 || avctx->crop_bottom != 0){ > + frame->crop_top += avctx->crop_top; > + frame->crop_left += avctx->crop_left; > + frame->crop_right += avctx->crop_right; > + frame->crop_bottom += avctx->crop_bottom; > + } > + } Somehow I don't feel like adding the two crops together is really going to do what most users would expect to happen. It just feels weird. It also changes the decoder crop information, and an API user does not get the pure information from the decoder, but rather an "interpreted" form. As an API user, I do not get the ability here to extract the pure decoder crop info, unless I manually null out the container info beforehand, or subtract it again, both of which seems odd and undesirable to me. Shouldn't I be provided with clean information, and then I (the API user) can choose how to act? - Hendrik _______________________________________________ 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".