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 755CA45D8F for ; Sat, 7 Oct 2023 16:26:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E48D468CB90; Sat, 7 Oct 2023 19:25:16 +0300 (EEST) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D89C668CBFA for ; Sat, 7 Oct 2023 19:25:09 +0300 (EEST) Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-58907163519so2385044a12.1 for ; Sat, 07 Oct 2023 09:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696695908; x=1697300708; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dPSi2c7vMyFhRZwvKydK4P2hPfnz6C+yzAc9CDcLTYI=; b=RydPVnZ398EbddGCk/eMYk4GwKQAKlR+9PEJHCEH5S2yutU1NTJ2zc8AnzObBkjZnw FSReDoialnfkjMrmJlvzGnK10S6dG38RW3shpTab2C/IQ6KNQQxJOBAYAGeCHHohlnjs 9Jg5DyYaAcFFuWwPL+CbwPtLUluQS3OHomOtOqXhLuv5BQztOMOVdO0jYIBZs6gKUYPN tebac8prEinWsih0165YPGM80KvkOJIcE+ITBG48/dN2rt4wuJ0M051/2AkMGvE5qgyP luJ7orikZObSAZWjfCwQuO1QVjD3FasmCIfuJTyI69LBw3kIzcx9lrO87XXMyj1blSbX Y/Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696695908; x=1697300708; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dPSi2c7vMyFhRZwvKydK4P2hPfnz6C+yzAc9CDcLTYI=; b=LAh480aleMAg+CpyE9oXpM4eHTElc7Npnzi1wTJyw42Ay0FE+JXfVNxzhKP18LRWOD p8r1CBrWPkNeB7C3NsKxPi00QDH+ftNVTLl1DJb/L65EMRuRjwq5dRws62S7YaDrUPKh 9+lmuqdwr6UrcsBw1s15xODZY4Oo3O7TNuRYB4OjX8aFNJ5MD1T3Ezf7ASEKcaSD33/F DmAIEraD5ZtUdIZiGD5wtO12RIQVQlipdemoNoVqkMoaHKQzx37JCfArFuoWUr08wyO1 tWqF7nyP9bjAwqNPx62hZaIzAMGj9Z3fRNyt02+Jyq1sSMaFQbV+NDTRmojdDmR3ngTn 7qPA== X-Gm-Message-State: AOJu0YxJ3llqUCu2NfmB8hNgcMdWahaKCpmJEOiTGwg4eDp+KnkgVAAi 1cZSpoLmoEQrGwBHIHpvnZksFIEZK+s= X-Google-Smtp-Source: AGHT+IFMPwZa+ZmIomdnmbmOm669hwjxcJdRylyjyPAm8iD0hL77UiHxqgSIRZ6qRPbTolWQGc7vug== X-Received: by 2002:a17:90a:9c0f:b0:274:914f:7fcc with SMTP id h15-20020a17090a9c0f00b00274914f7fccmr10966366pjp.1.1696695907733; Sat, 07 Oct 2023 09:25:07 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id 30-20020a17090a191e00b002792b7182dcsm7883180pjg.49.2023.10.07.09.25.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 09:25:07 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 7 Oct 2023 13:25:03 -0300 Message-ID: <20231007162503.1057-8-jamrial@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231007162503.1057-1-jamrial@gmail.com> References: <20231007162503.1057-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/7] fftools/ffplay: support applying container level cropping 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: Signed-off-by: James Almer --- fftools/ffplay.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index d8c69e10bc..5c213bf0d8 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -36,6 +36,7 @@ #include "libavutil/eval.h" #include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" +#include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" #include "libavutil/dict.h" #include "libavutil/fifo.h" @@ -348,6 +349,7 @@ static const char **vfilters_list = NULL; static int nb_vfilters = 0; static char *afilters = NULL; static int autorotate = 1; +static int apply_cropping = 1; static int find_stream_info = 1; static int filter_nbthreads = 0; @@ -1910,6 +1912,28 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c last_filter = filt_ctx; \ } while (0) + if (apply_cropping) { + AVPacketSideData *sd = av_packet_side_data_get(is->video_st->codecpar->coded_side_data, + is->video_st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); + + if (sd->data && sd->size == sizeof(uint32_t) * 4) { + char crop_buf[64]; + int top = AV_RL32(sd->data + 0); + int bottom = AV_RL32(sd->data + 4); + int left = AV_RL32(sd->data + 8); + int right = AV_RL32(sd->data + 12); + + if (top < 0 || bottom < 0 || left < 0 || right < 0) { + ret = AVERROR(EINVAL); + goto fail; + } + + snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", left, right, top, bottom); + INSERT_FILT("crop", crop_buf); + } + } + if (autorotate) { double theta = 0.0; int32_t *displaymatrix = NULL; @@ -2610,6 +2634,7 @@ static int stream_component_open(VideoState *is, int stream_index) av_dict_set(&opts, "threads", "auto", 0); if (stream_lowres) av_dict_set_int(&opts, "lowres", stream_lowres, 0); + av_dict_set_int(&opts, "apply_cropping", apply_cropping, 0); av_dict_set(&opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY); @@ -3608,6 +3633,7 @@ static const OptionDef options[] = { { "scodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" }, { "vcodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &video_codec_name }, "force video decoder", "decoder_name" }, { "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" }, + { "apply_cropping", OPT_BOOL, { &apply_cropping }, "apply frame cropping", "" }, { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info }, "read and decode the streams to fill missing information with heuristics" }, { "filter_threads", HAS_ARG | OPT_INT | OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" }, -- 2.42.0 _______________________________________________ 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".