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 339ED44110 for ; Mon, 29 Aug 2022 00:03:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0FEDC68B9B5; Mon, 29 Aug 2022 03:03:02 +0300 (EEST) Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 289BD68B7D5 for ; Mon, 29 Aug 2022 03:02:55 +0300 (EEST) Received: by mail-vs1-f52.google.com with SMTP id j6so906131vsr.0 for ; Sun, 28 Aug 2022 17:02:55 -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; bh=ElJDvJQ8KM2aXaB2kw92aGESe+K9Bc0cc0AzYZLCJSs=; b=FqVwPQTM1fht03AhE5UU9pwx0A7RdShkpw+JvWuHsSeRZ1VdeT9sd1Uuw3Nmz5jM0T 4NyToStX+lm+gpfYDHZRBbqKTJsMNADHB0+g6QSDiRPpvQjNThPOOuL97irhIGG+ZwrX Z/qZBEp+ZXPHXzEwC8hpUUscAcNjVKYAuRoa9Ww56rVy2fxKI5z4l63Ndj9P1XDfmtIS g1YddEdU0+SCO0bAP2wsZ1bIuTS+PypKpjr6KREeitdBYw7SSQtkwfBCR0jwCauBoG4l nmhZCya1IDWilsheKrM9u6+BUCkKI7hjExk+elz9ZjcKDjbz7mE5q3Ypo8QDoJepsQYH 61tA== 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; bh=ElJDvJQ8KM2aXaB2kw92aGESe+K9Bc0cc0AzYZLCJSs=; b=W8VoigCi6fH92/ENIU1bYCBuRqKvi1isWG7QuQVBgJT9FFS4lexeDbeWSyvW7/eqnS GUQk8kzSmtwJ8G07czNWYYgP55pVqiZZnuxtJ9zJhoQN+vvQf1YR9u82L/wtHYK2uudd XO3qmJ0JfZ0d7/r/z+rhh7Bljdtgz/6nAai8124oWknHD6lWfp56xir9NB/6cRxXGoAA pPoxPD6uShKJQzbCCya1CaPBIjXoN8ymBw5R3fewhw4uyFMkNpFu8mIQ30kdMUa8SLGx ATts8LXkjTqZkuNWnKV43Dye4AwZbwqajqh/nk3sFgkWKwlzIqkQGFLYCQ9ap6VjEo66 4kqg== X-Gm-Message-State: ACgBeo3uzwaaJkTxpcDP30W/P8fpLGV9iVuMn4rfGxb6f1+zPadCQxTd 7AfUxuNTQC0InThYFX1KDYVvwTut5YxDvw== X-Google-Smtp-Source: AA6agR7/wPMEd7A8ILuxQ3wox2i4NCEWv6LbX2HovWRN4n8XP7nOVJpZcgWihOlKGN/EDBUJJ+6j5w== X-Received: by 2002:a67:ea58:0:b0:38f:d89a:e4b3 with SMTP id r24-20020a67ea58000000b0038fd89ae4b3mr2526190vso.51.1661731373410; Sun, 28 Aug 2022 17:02:53 -0700 (PDT) Received: from cappuccino.. (075-115-109-114.inf.spectrum.com. [75.115.109.114]) by smtp.gmail.com with ESMTPSA id z5-20020ab05645000000b0039f07e29623sm1382804uaa.4.2022.08.28.17.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 17:02:52 -0700 (PDT) From: Stephen Hutchinson To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Aug 2022 20:02:37 -0400 Message-Id: <20220829000244.71123-3-qyot27@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220829000244.71123-1-qyot27@gmail.com> References: <20220829000244.71123-1-qyot27@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/9] avformat/avisynth: add read_frameprop_sar option 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: Stephen Hutchinson 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: Because SAR is much more likely to be negatively affected by operations made in-script, given that resizing is probably far more common than the sort of color manipulation involved in most of the other frame properties, the safest option is to disable reading it by default, allowing users to opt in. Signed-off-by: Stephen Hutchinson --- libavformat/avisynth.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index d978e6ec40..d503c7ed40 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -21,6 +21,7 @@ #include "libavutil/attributes.h" #include "libavutil/internal.h" +#include "libavutil/opt.h" #include "libavcodec/internal.h" @@ -86,6 +87,7 @@ typedef struct AviSynthLibrary { } AviSynthLibrary; typedef struct AviSynthContext { + const AVClass *class; AVS_ScriptEnvironment *env; AVS_Clip *clip; const AVS_VideoInfo *vi; @@ -100,6 +102,9 @@ typedef struct AviSynthContext { int error; + /* (de)activate reading frame properties */ + int frameprop_sar; + /* Linked list pointers. */ struct AviSynthContext *next; } AviSynthContext; @@ -732,9 +737,11 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) } /* Sample aspect ratio */ - sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error); - sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error); - st->sample_aspect_ratio = (AVRational){ sar_num, sar_den }; + if (avs->frameprop_sar) { + sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error); + sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error); + st->sample_aspect_ratio = (AVRational){ sar_num, sar_den }; + } avs_library.avs_release_video_frame(frame); } else { @@ -1140,6 +1147,19 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, return 0; } +#define OFFSET(x) offsetof(AviSynthContext, x) +static const AVOption avisynth_options[] = { + { "read_frameprop_sar", "Read SAR from script's frame properties (AviSynth+ v3.7.1+).", OFFSET(frameprop_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass avisynth_demuxer_class = { + .class_name = "AviSynth demuxer", + .item_name = av_default_item_name, + .option = avisynth_options, + .version = LIBAVUTIL_VERSION_INT, +}; + const AVInputFormat ff_avisynth_demuxer = { .name = "avisynth", .long_name = NULL_IF_CONFIG_SMALL("AviSynth script"), @@ -1149,4 +1169,5 @@ const AVInputFormat ff_avisynth_demuxer = { .read_close = avisynth_read_close, .read_seek = avisynth_read_seek, .extensions = "avs", + .priv_class = &avisynth_demuxer_class, }; -- 2.34.1 _______________________________________________ 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".