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 0150943162 for ; Tue, 20 Dec 2022 15:37:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 828366880B3; Tue, 20 Dec 2022 17:37:26 +0200 (EET) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2E88668B1F1 for ; Tue, 20 Dec 2022 17:37:20 +0200 (EET) Received: by mail-wr1-f51.google.com with SMTP id y16so12130942wrm.2 for ; Tue, 20 Dec 2022 07:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vm0FT5EN5QkxYkTK2NySaKVLbde+JZdPpigd+ndmP0s=; b=UlnU3yaNGWmR5pc4s2ztvIR8qKSwOCupQ32+tE9ypPUJ/2WOwWoh5E4c59hGoC/yvZ NiRdQjBlw/Y1rIkCJoMbVVcmj4H14IyCJ0/UptSkFwj2qwi7zXtgl6d5HPAOTsJa9UvT 1j+cSiyE9hl9Qgwn+3BpRuGli0f2BFwdLlizW/VYdvLq+hHwAl3xaiO1BPeDRl4h5OwW 6fDnAAgCnK3jVG1q2VInx1Q4dNV23GiIQurH6l0aB0qPNWV7rMA0aJjQi8OflW5bQZBV OWvGIGTSv6ziiI+UIbulveGgH8YNsyuqB1KCs6LjpC6BEGGfcHVEdjhVGvjPrKmmXo4c g30Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vm0FT5EN5QkxYkTK2NySaKVLbde+JZdPpigd+ndmP0s=; b=wEDmrR0gBdE/uRTgWnhrOlBJkxh9S1g3cqmJAs9YHB1Oa/iKyYEyOvUNS+nvk7ceM6 ehtF7yZcVZ4t3060l9xLRUucItIuZYLtgzvh5wOPuzaj/sxHClYulkXWy94ekUR2hU6Z +gvjE5319U4YxwbY++DIUF7tW4iZIC1j/FRQSKBnel9Kd0wbJc7oajiDLBA/59mX3D8v tYHrxtQT6t9ZHk1HzYhSM8vUvjk5+Hmo4V8bKiEeqCl2BSzNLEvuSJD5mOBRzV1sOnN9 LJ/yHPRYzJekVg2uWo+qf5sdeKyQS8GiJSIH1THceNVJZObXVcdRnby/x6KTPfzP9Qdy AYDA== X-Gm-Message-State: ANoB5pl8Hg8MkvDBWLM4P5p0YkOITBwuyWkI57iZinEJTzNtFllCjDF0 2t62pjO+q0PbEfVZ7BJ3ZgM4xHvQnGk= X-Google-Smtp-Source: AA0mqf4bjHKPMDkSvNk/P5VB7GvR/RBuP+5MLhNiZu5fPUiMM63LtBhHXL0cZP4LDnadR31p9XxC0g== X-Received: by 2002:a05:6000:10cf:b0:242:5ba8:d025 with SMTP id b15-20020a05600010cf00b002425ba8d025mr29542381wrx.39.1671550639076; Tue, 20 Dec 2022 07:37:19 -0800 (PST) Received: from dovchinn.amd.com (109-93-70-158.dynamic.isp.telekom.rs. [109.93.70.158]) by smtp.gmail.com with ESMTPSA id y1-20020adfd081000000b002421a8f4fa6sm13167716wrh.92.2022.12.20.07.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 07:37:18 -0800 (PST) From: Dmitrii Ovchinnikov X-Google-Original-From: Dmitrii Ovchinnikov To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Dec 2022 16:37:09 +0100 Message-Id: <20221220153711.1831-1-Dmitriy.Ovchinnikov@amd.com> X-Mailer: git-send-email 2.38.1.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [crop support for matroska demuxer, V4 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters. 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: Dmitrii Ovchinnikov 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: From: Dmitrii Ovchinnikov --- libavcodec/avcodec.h | 35 +++++++++++++++++++++++++++++++++++ libavcodec/codec_par.h | 8 ++++++++ libavcodec/options_table.h | 4 ++++ 3 files changed, 47 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 3edd8e2636..57b340c24d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -380,6 +380,19 @@ typedef struct RcOverride{ */ #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0) +/** +* Video decoding only. Certain container support cropping, meaning that +* only a sub-rectangle of the decoded frame is intended for display. +* Certain codec supports cropping as well.This option controls how +* cropping is handled by libavcodec when container cropping and +* codec cropping exist. +*/ +enum CONTAINER_CROPPING_POLICY_TYPE { + FF_CONTAINER_CROPPING_IGNORE = 0, + FF_CONTAINER_CROPPING_ADDITION, + FF_CONTAINER_CROPPING_OVERWRITE +}; + struct AVCodecInternal; /** @@ -2057,6 +2070,28 @@ typedef struct AVCodecContext { * The decoder can then override during decoding as needed. */ AVChannelLayout ch_layout; + + /* When set to 1 (the default), libavcodec will apply container cropping + * to codec cropping additionally. + * + * When set to 2, libavcodec will use container cropping to overwrite + * codec cropping (the final cropping uses container cropping parameters) + * + * When set to 0, libavcodec will ignore container cropping parameters + * (the final cropping uses codec cropping parameters) + * + * This field works with "apply_cropping". Only if apply_cropping is 1, this + * field works + */ + enum CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping; + + /** + * The cropping parameters from container. + */ + int container_crop_top; + int container_crop_left; + int container_crop_bottom; + int container_crop_right; } AVCodecContext; /** diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h index f51d27c590..cc0695689c 100644 --- a/libavcodec/codec_par.h +++ b/libavcodec/codec_par.h @@ -211,6 +211,14 @@ typedef struct AVCodecParameters { * Audio only. The channel layout and number of channels. */ AVChannelLayout ch_layout; + + /** + * The cropping parameters from container. + */ + int container_crop_top; + int container_crop_left; + int container_crop_bottom; + int container_crop_right; } AVCodecParameters; /** diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index cd02f5096f..fd1ef21f90 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -401,6 +401,10 @@ static const AVOption avcodec_options[] = { {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"}, {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, +{ "container_apply_cropping", "ploicy using container cropping parameters", OFFSET(container_apply_cropping), AV_OPT_TYPE_INT64, {.i64 = FF_CONTAINER_CROPPING_ADDITION }, 0, 2, V | D, "container_apply_cropping" }, +{ "ignore", "ignore container cropping", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_IGNORE }, 0, 0, V | D, "container_apply_cropping" }, +{ "addition", "apply container cropping additionally to elementary stream cropping", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_ADDITION }, 0, 0, V | D, "container_apply_cropping" }, +{ "overwrite", "use container cropping to overwrite elementary stream cropping", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_OVERWRITE }, 0, 0, V | D, "container_apply_cropping" }, {NULL}, }; -- 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".