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 41C7C40925 for ; Sat, 1 Oct 2022 06:14:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D7CF68BABE; Sat, 1 Oct 2022 09:14:06 +0300 (EEST) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 90B3968BA8D for ; Sat, 1 Oct 2022 09:13:59 +0300 (EEST) Received: by mail-wm1-f42.google.com with SMTP id z13-20020a7bc7cd000000b003b5054c6f9bso6159184wmk.2 for ; Fri, 30 Sep 2022 23:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=H8LE0iXY563yY2OPdkcT8TgOCfWi9f6JlAWAWqGIC20=; b=qZKfAPX7FWGMGIoJ4eOJWJUVjnJQtR8paS2Z7gbDLQYgIUgGBdUmO8Lgkx/Y/eTiOO ixmwuf3ErR+XGtzYkEyQnSEeYGHLkbeJ1Xaf0r3A8g7lib0RIVkWTGyOLhsUAxuvpdNy /hspo2wImeBVBEkUPUs148JZL14pgMANY5ypXLQIGyi19rqOWZ81ZRaT16rqzVdRRjSV JZb7bMmyalAg4OHv3xgZLyV8gd5O0diMIgZ8KAm+JGwEI9oFZiqUNlB1Jtklkcgx5YZb cnc1+rYJAMttuOF/HWaAxh9zibuA+oP3z//B8VhxXrz4yeJr7qYS1gBnQoGm0FnW7yEI 9Iig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=H8LE0iXY563yY2OPdkcT8TgOCfWi9f6JlAWAWqGIC20=; b=Vni6Jx/K8VsG7YxtfEc3YYXfkWNAGxvVsLYF9MTOBOxq3yoNLoxZNg7iw+OEXVeSuw 2cjjR9m2d7DT4wDU5mI2RfGtqg0cUw7AYUUia1LPq2TxZ8WDuzsLXbIa4HK8O9fxnrSA N4m6hK/rqBoAHexQeOy67RuTk76Jl6B+rgfwmeA6FFfuhBzeLO2X85kca2OkK4Onsvep 6PTNA46tYFO5FSfr+xnVdsOSI7Z0Q+WsVRd0a5UZ9g0zLXMv61hKYzEALgveLCbSViWY YUvTR3YScpxzhzVtjihl66uANlhh7EWUfSFefbyCwRrUrwKFwnoFZLRRF0SXQK9K5hyL aBlg== X-Gm-Message-State: ACrzQf2/R/z7pKn+pjFKya11YifdadyHMIpj6qPTSi/pG5cYxc5y+kjC 1MbZ4S4oL3K0DT0YZyHsEtzrXRjwtmgvYA== X-Google-Smtp-Source: AMsMyM76n1hfb42YAEM8HT1fBTDYjiiTqHlCVsaqTHAxG7+lOKTdMJImXbjlCYZe1FXoqJ2e+Xgzwg== X-Received: by 2002:a7b:cb91:0:b0:3b4:75b9:5a4b with SMTP id m17-20020a7bcb91000000b003b475b95a4bmr799425wmi.33.1664604837903; Fri, 30 Sep 2022 23:13:57 -0700 (PDT) Received: from localhost.localdomain (178-222-23-217.dynamic.isp.telekom.rs. [178.222.23.217]) by smtp.gmail.com with ESMTPSA id bv14-20020a0560001f0e00b0022ae8b862a7sm4171739wrb.35.2022.09.30.23.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 23:13:56 -0700 (PDT) From: OvchinnikovDmitrii To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Oct 2022 08:13:40 +0200 Message-Id: <20221001061341.662-2-ovchinnikov.dmitrii@gmail.com> X-Mailer: git-send-email 2.30.0.windows.2 In-Reply-To: <20221001061341.662-1-ovchinnikov.dmitrii@gmail.com> References: <20221001061341.662-1-ovchinnikov.dmitrii@gmail.com> MIME-Version: 1.0 Subject: [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 Cc: OvchinnikovDmitrii 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: 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; + } + } } else { ret = decode_receive_frame_internal(avctx, frame); if (ret < 0) -- 2.30.0.windows.2 _______________________________________________ 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".