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 C419F4844D for ; Mon, 4 Dec 2023 15:59:19 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 938E668CC0B; Mon, 4 Dec 2023 17:59:16 +0200 (EET) Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B1FB68ABE6 for ; Mon, 4 Dec 2023 17:59:10 +0200 (EET) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-1fa26074783so2241771fac.1 for ; Mon, 04 Dec 2023 07:59:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701705548; x=1702310348; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=f2Lk529WdhELOaWgfsH+PQC0Cl2xJ8a9qSoMcbjBzYY=; b=ASR3JWiRvfQEFXeogLvcCQKMVdq5OhWi1SEuYVXnAxyhcxq2/sSSyjxlpB7RKz0IQD 30Hu8Huf13DHPmNNKmmBtSnt/nZ6nLpl/Ug2jlQPxAASf/UCTTFkNOGQblCLs4VpuFXT R7ITQsErJ+qWkWPNP6e5WVnD39w/DDw/RfUpsa7bA8ZUR7oAIy7rIJtEl76GUJT3J1w+ yzB3ovIhjm01uJvb/ncrQ9HCxW0wSQoWGGNG0WTnz0hy5tu2ZRsv9WtI5Gpjk7GYgAoa MVwk4Hsy42tne/QiAUEjOH7ebHSHfrWFDli35qnpJyyfQEryN77vZLcRrHiSeS1YR4bm hIVw== X-Gm-Message-State: AOJu0Ywb8BNHnkogx4Fjhvv2cyf1CRCIJKxMnLoeHmKzGBIkwYPfk9hf mD4pogDvZfZLFsuhycGF+ySakvgn/apcR84Wxvpry9Wene8bmlqXRpQ= X-Google-Smtp-Source: AGHT+IHrr4C8/hdwRcWFsjY7pyU6sAbgmC4kK4NzlRpNCkPBsKdy8SUwfblJ27aU3NGTNqVhljnixaPutS0WpZJeySU= X-Received: by 2002:a05:6870:ab8a:b0:1fb:15c3:2884 with SMTP id gs10-20020a056870ab8a00b001fb15c32884mr4694663oab.39.1701705548562; Mon, 04 Dec 2023 07:59:08 -0800 (PST) MIME-Version: 1.0 Date: Mon, 4 Dec 2023 15:58:57 +0000 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avfilter/vf_libvmaf: fix string comparison bug 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: , From: Nil Fons Miret via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Nil Fons Miret , Kyle Swanson 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: The libvmaf filter was doing substring checks in place of string equality comparisons. This led to a bug when the user specified the pooling method "harmonic_mean", since "mean" was checked first and the substring comparison returned true. This patch changes all substring comparisons for string equality comparisons. This is both correct and more efficient than the existing method. Signed-off-by: nilfm --- libavfilter/vf_libvmaf.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index 12810b7267..46ff8154ef 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -251,7 +251,7 @@ static int parse_features(AVFilterContext *ctx) const AVDictionaryEntry *e = NULL; while (e = av_dict_iterate(dict[i], e)) { - if (av_stristr(e->key, "name")) { + if (!strcmp(e->key, "name")) { feature_name = e->value; continue; } @@ -312,29 +312,29 @@ static int parse_models(AVFilterContext *ctx) char *path = NULL; while (e = av_dict_iterate(dict[i], e)) { - if (av_stristr(e->key, "disable_clip")) { - model_cfg.flags |= av_stristr(e->value, "true") ? + if (!strcmp(e->key, "disable_clip")) { + model_cfg.flags |= !strcmp(e->value, "true") ? VMAF_MODEL_FLAG_DISABLE_CLIP : 0; continue; } - if (av_stristr(e->key, "enable_transform")) { - model_cfg.flags |= av_stristr(e->value, "true") ? + if (!strcmp(e->key, "enable_transform")) { + model_cfg.flags |= !strcmp(e->value, "true") ? VMAF_MODEL_FLAG_ENABLE_TRANSFORM : 0; continue; } - if (av_stristr(e->key, "name")) { + if (!strcmp(e->key, "name")) { model_cfg.name = e->value; continue; } - if (av_stristr(e->key, "version")) { + if (!strcmp(e->key, "version")) { version = e->value; continue; } - if (av_stristr(e->key, "path")) { + if (!strcmp(e->key, "path")) { path = e->value; continue; } @@ -529,13 +529,13 @@ static int activate(AVFilterContext *ctx) static enum VmafOutputFormat log_fmt_map(const char *log_fmt) { if (log_fmt) { - if (av_stristr(log_fmt, "xml")) + if (!strcmp(log_fmt, "xml")) return VMAF_OUTPUT_FORMAT_XML; - if (av_stristr(log_fmt, "json")) + if (!strcmp(log_fmt, "json")) return VMAF_OUTPUT_FORMAT_JSON; - if (av_stristr(log_fmt, "csv")) + if (!strcmp(log_fmt, "csv")) return VMAF_OUTPUT_FORMAT_CSV; - if (av_stristr(log_fmt, "sub")) + if (!strcmp(log_fmt, "sub")) return VMAF_OUTPUT_FORMAT_SUB; } @@ -545,11 +545,11 @@ static enum VmafOutputFormat log_fmt_map(const char *log_fmt) static enum VmafPoolingMethod pool_method_map(const char *pool_method) { if (pool_method) { - if (av_stristr(pool_method, "min")) + if (!strcmp(pool_method, "min")) return VMAF_POOL_METHOD_MIN; - if (av_stristr(pool_method, "mean")) + if (!strcmp(pool_method, "mean")) return VMAF_POOL_METHOD_MEAN; - if (av_stristr(pool_method, "harmonic_mean")) + if (!strcmp(pool_method, "harmonic_mean")) return VMAF_POOL_METHOD_HARMONIC_MEAN; } -- 2.37.1 (Apple Git-137.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".