From patchwork Sun Apr 10 06:06:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 35243 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp447200pzh; Sat, 9 Apr 2022 23:07:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztzyUIegFpWHHU1GLPGqxSf/lRNu/0et2jUylBVgsDacRheloYRLJ7m8/wdmQ1LgTSGniY X-Received: by 2002:a17:907:6d23:b0:6d9:ac9d:222 with SMTP id sa35-20020a1709076d2300b006d9ac9d0222mr25944359ejc.595.1649570820814; Sat, 09 Apr 2022 23:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649570820; cv=none; d=google.com; s=arc-20160816; b=VFHN1xtBlSqbhizoBQMWJJ0B8oIi29HEZd6FAPNUrPVR0+mj+Rv+f9g08NOm7JeQ9o uCG6/1xoLYfwUs7PvlWdUHknUaFJ0FHb/rS5oeRxF7QwRvTENMWDrrhEB8ALBKFA8IDS wX0mC9Qboc1ADDNMv/SlIPct3x1nJyIBhd5Fe4+BHef3yDcVvMoY5yWfQ1ASWHzTC79O lbZUSF+czWhw8YtnIj0cedGxbjZBZ6husp+DJ7ajSDMVxq6q0z5eGXkyEGq3FOgstq6A 0QQ/vRWyZ73E83jVfuNN1EXcHy+dl3HD86utSI4cDCAZzhnn+utdCMRZcAVQHgwv5NUa Z9Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=wsPw3IDzbaZwdHNf3x9yGXBJxuRHFl23kZW/MKkVKRY=; b=i/wsQvueOyxNRizg88ihN4goic5dBCUXvDoiClg6MtThqffV9U/Q885jYknmhJi/Yg D3HFKHOhh9JHv9Lc5dBu7E4nZC3suZg66koQz5I4HR5FDFPhMZQI44lAVVvURf55jPKM SmCSKPVc3Y0WwcGiuS7LB5Ccf0h9ltQkYRaWgIHkEsrXzWYn1UMW+pijW0cQoEgWZiLM gmPojxG0/AYAgOjQO9VT+gfi47/TML0StB2KmL7ttWBKtH+fn/MWaD7kNfM3dogmjGDp OGP+Rj9p9xDjSjjPyE14kgoQlqoq3IoCLQzaHFDq8s0atWY36r5qaUfGlbBy2RSHhQ/P Ci7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ga10-20020a1709070c0a00b006e7027c46a0si5432310ejc.5.2022.04.09.23.07.00; Sat, 09 Apr 2022 23:07:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A0E0A68B339; Sun, 10 Apr 2022 09:06:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D20A768B2A5 for ; Sun, 10 Apr 2022 09:06:51 +0300 (EEST) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4KbhMZ3qxQz9sQr for ; Sun, 10 Apr 2022 08:06:50 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Apr 2022 11:36:22 +0530 Message-Id: <20220410060622.1734-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/lensfun: add option db_path 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: c5rEqMfbz/b8 The lensfun filter, at present, loads its database from a path hardcoded at build time. This may not be known or available to end users. Added option db_path allows custom path. --- doc/filters.texi | 4 ++++ libavfilter/vf_lensfun.c | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 6a66b0ed11..9861f43c07 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -14693,6 +14693,10 @@ required. The model of the lens (for example, "Canon EF-S 18-55mm f/3.5-5.6 IS STM"). This option is required. +@item db_path +The full path to the lens database folder. If not set, the filter will attempt to +load the database from the install path when the library was built. Default is unset. + @item mode The type of correction to apply. The following values are valid options: diff --git a/libavfilter/vf_lensfun.c b/libavfilter/vf_lensfun.c index 596daed104..35c522a723 100644 --- a/libavfilter/vf_lensfun.c +++ b/libavfilter/vf_lensfun.c @@ -73,7 +73,7 @@ typedef struct DistortionCorrectionThreadData { typedef struct LensfunContext { const AVClass *class; - const char *make, *model, *lens_model; + const char *make, *model, *lens_model, *db_path; int mode; float focal_length; float aperture; @@ -97,6 +97,7 @@ static const AVOption lensfun_options[] = { { "make", "set camera maker", OFFSET(make), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, { "model", "set camera model", OFFSET(model), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, { "lens_model", "set lens model", OFFSET(lens_model), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, + { "db_path", "set path to database", OFFSET(db_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=GEOMETRY_DISTORTION}, 0, VIGNETTING | GEOMETRY_DISTORTION | SUBPIXEL_DISTORTION, FLAGS, "mode" }, { "vignetting", "fix lens vignetting", 0, AV_OPT_TYPE_CONST, {.i64=VIGNETTING}, 0, 0, FLAGS, "mode" }, { "geometry", "correct geometry distortion", 0, AV_OPT_TYPE_CONST, {.i64=GEOMETRY_DISTORTION}, 0, 0, FLAGS, "mode" }, @@ -136,9 +137,10 @@ static av_cold int init(AVFilterContext *ctx) const lfLens **lenses; db = lf_db_create(); - if (lf_db_load(db) != LF_NO_ERROR) { + if ((lensfun->db_path ? lf_db_load_path(db, lensfun->db_path) : lf_db_load(db)) != LF_NO_ERROR) { lf_db_destroy(db); - av_log(ctx, AV_LOG_FATAL, "Failed to load lensfun database\n"); + av_log(ctx, AV_LOG_FATAL, "Failed to load lensfun database from %s path\n", + lensfun->db_path ? lensfun->db_path : "default"); return AVERROR_INVALIDDATA; }