From patchwork Mon Sep 13 23:23:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 30234 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4466663iov; Mon, 13 Sep 2021 16:24:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1YWMtnYJqyYSo+4l5zBNqFNdYc5qr6Qhp3CjWRV/HYohuxBQLwzowgpai+ArLBu+cMi89 X-Received: by 2002:a17:906:4346:: with SMTP id z6mr15406467ejm.403.1631575483177; Mon, 13 Sep 2021 16:24:43 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d1si4539623ede.162.2021.09.13.16.24.42; Mon, 13 Sep 2021 16:24:43 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=o2pdvKSc; arc=fail (body hash mismatch); 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8FAF968AED2; Tue, 14 Sep 2021 02:24:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071014.outbound.protection.outlook.com [40.92.71.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA40468AAFE for ; Tue, 14 Sep 2021 02:24:15 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cUJP4dySpMo3fRxsTZsz3x2C0h0AXmVY0ta/3+R5tQ3tNvz66//nOrj9fJZhytefvQAjGDP7iiwMeOe6/B2pkesAjAYqGQufp8XrVe9mw3ELXRghqBiCjgvJwztZksEC6U6UooaxF4ffvUw8DZZkxZj+g7ufKJX5rN/9CfyGDQPpXYvgXOGo4KnlvE2d55JB9pHDEP8i/GClbkk+IGSD9LYWCeKqkVOZM2WjR+lDR0ouBXH5LiQknIyFCE5zwkEPC8KMaRyviE9Fg+AC5Qr+8YZWb7dM2zc2T5Tizn9T+RJ/bFup0Wy0z3mpLIioLHjuAgqnqtH8309me4w//I2JbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=wNL3NNqEBDI0BlFLtV0DvwSmuIKxy+5b2hIUTHGvIIc=; b=YBAxDF9ABDllumTCF4kj/EYSAdinLgOsosfWavKHvCsIy7+qcA8YBeZH4qra1mxD+t+WaY/rN482NvxX8YP5STUcUdhvZ23pX1gGnTuhmLPYu/rq+aoFGI8udysrYhzqA3dNf3Q2SW1Of3p1wLfTDlsEb9XXK7klPgNom6oG5KEBS1nqOqFbItHh2URRXA7/8TBlt5aP1DDcQvXBuzGtTAQMDaWMLXH3xQJx5ZriuiMH6vkYP45dQqWBuabqbJPdQRdqGceXifdA3CCjzDWp+MoLT8aWkCb2l2wMFuXZ0q3Vo6S20bukE3GPb0tKieIEXsRkzOyAUdUhPOqB/CX+Eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wNL3NNqEBDI0BlFLtV0DvwSmuIKxy+5b2hIUTHGvIIc=; b=o2pdvKSc5FomabSs+2tj3sxVrhCb2O5Jr/EgJ7cDkRntu5g6yI6tjora9INmoZWbiupnekgLU2rfMeHaiwkuzcrvxAnMw5iBFz66M76GYKUYFb3rwO+ijeNlJcH+83LLR2DlAV3z57igXXa37Gvs8d2ZQ7VSC5M9RNwE5cfsuRWz1ikKSrcgy7rSrIB86qI/nZXMiIv1LO+T+jQ3vJBJsktTIOmwkg6JC3wrvCfII/FS6g2Mbdxz5QCbtlMEynxkIcV1HpX0U8YmWqlb4/JkGp/kM0gbf0W1OOhpNH16OxYprORlx198Z7yeXEDJaxmn1b1q9rFA73Ta7Ck2QSTYXQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4216.eurprd03.prod.outlook.com (2603:10a6:20b:d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Mon, 13 Sep 2021 23:24:10 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::787b:2156:ca99:fe00]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::787b:2156:ca99:fe00%4]) with mapi id 15.20.4500.019; Mon, 13 Sep 2021 23:24:10 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 14 Sep 2021 01:23:31 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [d6qUybnpOEPWAww+p5Q/oFaQ1XpVDFBn] X-ClientProxiedBy: AM4P190CA0008.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::18) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210913232339.3115725-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.142.38) by AM4P190CA0008.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 23:24:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fbda5dbd-89c1-4fbf-2d72-08d9770d974f X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSwGI4buAwfZe0futHLJHOz9md3MY9BfGlfNK6WvFDPI8QpiUQ5HSVyUHHhqgh2j2ugRk485GXWAjDFk6ALk8CDfIYvJEAzhf2iHjU9jvBOuAuJr3ZI0VSq1NjR6SjUqivt4wJFoX46RdYeQrYw/6cQKtfqyvU4wU+PGL3PN/AJiHgyB2bQ2TwSt4j4YdGgiwJ9DJy0vybI8h1nreP6trSOOLcTD+gpvbyLgFSeV0MF0PYSEGoSxP6H2hS50LVVXCWeImiXY9enU45VdcmEA13NhPQMF/+Gd9KqilYvRiA8pr0uG2dqMwL6oGMytJssQxOo1SzspN71jPv9G+R/FqJ1wxvGs5UdD1Sl2xpfPosHju62nx/RFHUwiyVhIZbC2o+3f0TTz+sW6xtIkssXP21u2k4joNZ95oiDY3vlZfeN8MHqi0vp32IuZQJ4H7O4Y7hLfFb3dAGDfceoUCbZaKaPnQvs1EInL9sclA9PeVmhVcC3fdqpag1ah/suANbjLxIFJQfOvklna4ttegwDlEwBXrsVRDsomwquiPn2Clgvu/cDh8pGtymhiXSvW0TSc2drW+dT81JZUHXw9ISN2GZzTDSXRBdUxIhzznq9nNAfhzQ9QyQ3DOtZ6HMlIe/dzU6xQU8BH5oXTTPl/t+CxaG7JedZdZSeC3B9dC6j2XxHEvswrIO5pBaSWR8B4MZW6zdw+MTMbxVymr+3GATiJKW+wp1SvFjJd13rXTR+A+IKhsHYW/hD3rQfjTykyC8CamA= X-MS-TrafficTypeDiagnostic: AM6PR03MB4216: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8+A61blXsXZ5GuxMSBj2aMU/B/AwoIun9WhJ1ET2ye4hu0buYYbNAVeabNoqtt35HS/ogR3J9PePehDrvjftr9tNdlZIY/+qUbQ72edecKjYwh8KNTGiD7kb4TabJptgoc/fcvRliFJc2kWrG05OP637zfLA5WPDV++UsKjS2kocLtxpCf883ra9LE21sb/uqZASBB2L9np+9Q3daog0fHXb9jHUThitoJQq9wkJg77u+K+r9MNXq+qks+8SEpvi6TjpV+2zBi8MBAdH8dTN/UbMTE01vkeXVHpAdQhLzt75+4RG7fJt9kIZWgcVNsJ/DicxOhIQgZpLIwyL7niCC29XPTl19wIK73nNZxJVadt1vw3Y0T6vQTnNGv/ArwSkJlDe2J13OJWWODPxvlnY4ekMP18ZQVxs6RaMQG3ayLYXV6mtX9VWMnIP1vOCalfk X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8yECJz3B7AWM73HtKHTd7ULlcCAoS28wtJpgCEkpp4IxlhQOUNYH63RR7cGUEz/H+UWG2n7+85SMOGuOFw9ccqnCL34MLqiHoVLidB/dgilp0PZJSweWfrhrPiAvMWWetW18QK9wRXAJFEV+UCZuwg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbda5dbd-89c1-4fbf-2d72-08d9770d974f X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 23:24:10.8386 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4216 Subject: [FFmpeg-devel] [PATCH v2 06/14] avfilter/vf_spp: Use preinit instead of init_dict 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6ltgCtE3Ir+a By using preinit, the AVDCT already exists directly after allocating the filter, so that the filter's AVClass's child_next becomes usable for setting options with the AV_OPT_SEARCH_CHILDREN search flag. This means that it is no longer necessary to use the init_dict callback for this filter. Furthermore, the earlier code did not abide by the documentation of the init_dict callback at all: Instead of only returning the options that have not been recognized it always returned all options on any av_opt_set() error and errored out in this case, even if it is just an unrecognized option. This behaviour has been inherited by avfilter_init_dict(), contradicting its documentation. This is also fixed in this commit. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_spp.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c index b3a52fc99b..6c15dbaf66 100644 --- a/libavfilter/vf_spp.c +++ b/libavfilter/vf_spp.c @@ -338,6 +338,12 @@ static int config_input(AVFilterLink *inlink) const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); const int bps = desc->comp[0].depth; + s->store_slice = store_slice_c; + switch (s->mode) { + case MODE_HARD: s->requantize = hardthresh_c; break; + case MODE_SOFT: s->requantize = softthresh_c; break; + } + av_opt_set_int(s->dct, "bits_per_sample", bps, 0); avcodec_dct_init(s->dct); @@ -451,30 +457,14 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar return AVERROR(ENOSYS); } -static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts) +static av_cold int preinit(AVFilterContext *ctx) { SPPContext *s = ctx->priv; - int ret; s->dct = avcodec_dct_alloc(); if (!s->dct) return AVERROR(ENOMEM); - if (opts) { - AVDictionaryEntry *e = NULL; - - while ((e = av_dict_get(*opts, "", e, AV_DICT_IGNORE_SUFFIX))) { - if ((ret = av_opt_set(s->dct, e->key, e->value, 0)) < 0) - return ret; - } - av_dict_free(opts); - } - - s->store_slice = store_slice_c; - switch (s->mode) { - case MODE_HARD: s->requantize = hardthresh_c; break; - case MODE_SOFT: s->requantize = softthresh_c; break; - } return 0; } @@ -508,7 +498,7 @@ const AVFilter ff_vf_spp = { .name = "spp", .description = NULL_IF_CONFIG_SMALL("Apply a simple post processing filter."), .priv_size = sizeof(SPPContext), - .init_dict = init_dict, + .preinit = preinit, .uninit = uninit, .query_formats = query_formats, FILTER_INPUTS(spp_inputs),