From patchwork Mon Feb 24 12:37:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 17908 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6A8F044A135 for ; Mon, 24 Feb 2020 14:39:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 45C6068B0E0; Mon, 24 Feb 2020 14:39:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A02A368B488 for ; Mon, 24 Feb 2020 14:39:22 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id 50CDB2951AA for ; Mon, 24 Feb 2020 13:39:22 +0100 (CET) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 0Rj59mwBtrcI for ; Mon, 24 Feb 2020 13:39:21 +0100 (CET) Received: from quelana.khirnov.net (unknown [IPv6:2a00:c500:61:23b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "quelana.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id D33232951A8 for ; Mon, 24 Feb 2020 13:39:21 +0100 (CET) Received: from localhost (quelana.khirnov.net [IPv6:::1]) by quelana.khirnov.net (Postfix) with ESMTP id 7A5D22522B for ; Mon, 24 Feb 2020 13:39:20 +0100 (CET) Received: from quelana.khirnov.net ([IPv6:::1]) by localhost (quelana.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Gxh2XiPx0Z2n for ; Mon, 24 Feb 2020 13:39:18 +0100 (CET) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) by quelana.khirnov.net (Postfix) with ESMTP id 7153D2522E for ; Mon, 24 Feb 2020 13:39:14 +0100 (CET) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id 08B8B20E0355; Mon, 24 Feb 2020 13:39:10 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Feb 2020 13:37:30 +0100 Message-Id: <20200224123739.31154-4-anton@khirnov.net> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200224123739.31154-1-anton@khirnov.net> References: <20200224123739.31154-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/12] lavfi: drop vf_qp X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" It fundamentally depends on an API that has been deprecated for five years, has seen no commits since that time and is of highly dubious usefulness. --- doc/filters.texi | 32 ------- libavfilter/Makefile | 1 - libavfilter/allfilters.c | 1 - libavfilter/vf_qp.c | 183 ------------------------------------ tests/fate/filter-video.mak | 7 +- tests/ref/fate/filter-pp2 | 1 - tests/ref/fate/filter-pp3 | 1 - 7 files changed, 1 insertion(+), 225 deletions(-) delete mode 100644 libavfilter/vf_qp.c delete mode 100644 tests/ref/fate/filter-pp2 delete mode 100644 tests/ref/fate/filter-pp3 diff --git a/doc/filters.texi b/doc/filters.texi index 70fd7a4cc7..2a1235183f 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -15335,38 +15335,6 @@ telecine NTSC input: ffmpeg -i input -vf pullup -r 24000/1001 ... @end example -@section qp - -Change video quantization parameters (QP). - -The filter accepts the following option: - -@table @option -@item qp -Set expression for quantization parameter. -@end table - -The expression is evaluated through the eval API and can contain, among others, -the following constants: - -@table @var -@item known -1 if index is not 129, 0 otherwise. - -@item qp -Sequential index starting from -129 to 128. -@end table - -@subsection Examples - -@itemize -@item -Some equation like: -@example -qp=2+2*sin(PI*qp) -@end example -@end itemize - @section random Flush video frames from internal cache of frames into a random order. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 089880a39d..74968b32e1 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -349,7 +349,6 @@ OBJS-$(CONFIG_PROGRAM_OPENCL_FILTER) += vf_program_opencl.o opencl.o fra OBJS-$(CONFIG_PSEUDOCOLOR_FILTER) += vf_pseudocolor.o OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o framesync.o OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o -OBJS-$(CONFIG_QP_FILTER) += vf_qp.o OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o OBJS-$(CONFIG_READVITC_FILTER) += vf_readvitc.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 88ebd121ad..aa6f006ddb 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -332,7 +332,6 @@ extern AVFilter ff_vf_program_opencl; extern AVFilter ff_vf_pseudocolor; extern AVFilter ff_vf_psnr; extern AVFilter ff_vf_pullup; -extern AVFilter ff_vf_qp; extern AVFilter ff_vf_random; extern AVFilter ff_vf_readeia608; extern AVFilter ff_vf_readvitc; diff --git a/libavfilter/vf_qp.c b/libavfilter/vf_qp.c deleted file mode 100644 index 33d39493bc..0000000000 --- a/libavfilter/vf_qp.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "libavutil/eval.h" -#include "libavutil/imgutils.h" -#include "libavutil/pixdesc.h" -#include "libavutil/opt.h" -#include "avfilter.h" -#include "formats.h" -#include "internal.h" -#include "video.h" - -typedef struct QPContext { - const AVClass *class; - char *qp_expr_str; - int8_t lut[257]; - int h, qstride; - int evaluate_per_mb; -} QPContext; - -#define OFFSET(x) offsetof(QPContext, x) -#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM - -static const AVOption qp_options[] = { - { "qp", "set qp expression", OFFSET(qp_expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, - { NULL } -}; - -AVFILTER_DEFINE_CLASS(qp); - -static int config_input(AVFilterLink *inlink) -{ - AVFilterContext *ctx = inlink->dst; - QPContext *s = ctx->priv; - int i; - int ret; - AVExpr *e = NULL; - static const char *var_names[] = { "known", "qp", "x", "y", "w", "h", NULL }; - - if (!s->qp_expr_str) - return 0; - - ret = av_expr_parse(&e, s->qp_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx); - if (ret < 0) - return ret; - - s->h = (inlink->h + 15) >> 4; - s->qstride = (inlink->w + 15) >> 4; - for (i = -129; i < 128; i++) { - double var_values[] = { i != -129, i, NAN, NAN, s->qstride, s->h, 0}; - double temp_val = av_expr_eval(e, var_values, NULL); - - if (isnan(temp_val)) { - if(strchr(s->qp_expr_str, 'x') || strchr(s->qp_expr_str, 'y')) - s->evaluate_per_mb = 1; - else { - av_expr_free(e); - return AVERROR(EINVAL); - } - } - - s->lut[i + 129] = lrintf(temp_val); - } - av_expr_free(e); - - return 0; -} - -static int filter_frame(AVFilterLink *inlink, AVFrame *in) -{ - AVFilterContext *ctx = inlink->dst; - AVFilterLink *outlink = ctx->outputs[0]; - QPContext *s = ctx->priv; - AVBufferRef *out_qp_table_buf; - AVFrame *out = NULL; - const int8_t *in_qp_table; - int type, stride, ret; - - if (!s->qp_expr_str || ctx->is_disabled) - return ff_filter_frame(outlink, in); - - out_qp_table_buf = av_buffer_alloc(s->h * s->qstride); - if (!out_qp_table_buf) { - ret = AVERROR(ENOMEM); - goto fail; - } - - out = av_frame_clone(in); - if (!out) { - av_buffer_unref(&out_qp_table_buf); - ret = AVERROR(ENOMEM); - goto fail; - } - - in_qp_table = av_frame_get_qp_table(in, &stride, &type); - av_frame_set_qp_table(out, out_qp_table_buf, s->qstride, type); - - - if (s->evaluate_per_mb) { - int y, x; - - for (y = 0; y < s->h; y++) - for (x = 0; x < s->qstride; x++) { - int qp = in_qp_table ? in_qp_table[x + stride * y] : NAN; - double var_values[] = { !!in_qp_table, qp, x, y, s->qstride, s->h, 0}; - static const char *var_names[] = { "known", "qp", "x", "y", "w", "h", NULL }; - double temp_val; - - ret = av_expr_parse_and_eval(&temp_val, s->qp_expr_str, - var_names, var_values, - NULL, NULL, NULL, NULL, 0, 0, ctx); - if (ret < 0) - goto fail; - out_qp_table_buf->data[x + s->qstride * y] = lrintf(temp_val); - } - } else if (in_qp_table) { - int y, x; - - for (y = 0; y < s->h; y++) - for (x = 0; x < s->qstride; x++) - out_qp_table_buf->data[x + s->qstride * y] = s->lut[129 + - ((int8_t)in_qp_table[x + stride * y])]; - } else { - int y, x, qp = s->lut[0]; - - for (y = 0; y < s->h; y++) - for (x = 0; x < s->qstride; x++) - out_qp_table_buf->data[x + s->qstride * y] = qp; - } - - ret = ff_filter_frame(outlink, out); - out = NULL; -fail: - av_frame_free(&in); - av_frame_free(&out); - return ret; -} - -static const AVFilterPad qp_inputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame, - .config_props = config_input, - }, - { NULL } -}; - -static const AVFilterPad qp_outputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - }, - { NULL } -}; - -AVFilter ff_vf_qp = { - .name = "qp", - .description = NULL_IF_CONFIG_SMALL("Change video quantization parameters."), - .priv_size = sizeof(QPContext), - .inputs = qp_inputs, - .outputs = qp_outputs, - .priv_class = &qp_class, - .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, -}; diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 2da27f714a..5f4fd75b40 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -531,21 +531,16 @@ fate-filter-idet: CMD = framecrc -flags bitexact -idct simple -i $(SRC) -vf idet FATE_FILTER_VSYNTH-$(CONFIG_PAD_FILTER) += fate-filter-pad fate-filter-pad: CMD = video_filter "pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2" -FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp2 fate-filter-pp3 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6 +FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6 FATE_FILTER_VSYNTH-$(CONFIG_PP_FILTER) += $(FATE_FILTER_PP) $(FATE_FILTER_PP): fate-vsynth1-mpeg4-qprd fate-filter-pp: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp=be/hb/vb/tn/l5/al" fate-filter-pp1: CMD = video_filter "pp=fq|4/be/hb/vb/tn/l5/al" -fate-filter-pp2: CMD = video_filter "qp=x+y,pp=be/h1/v1/lb" -fate-filter-pp3: CMD = video_filter "qp=x+y,pp=be/ha|128|7/va/li" fate-filter-pp4: CMD = video_filter "pp=be/ci" fate-filter-pp5: CMD = video_filter "pp=md" fate-filter-pp6: CMD = video_filter "pp=be/fd" -FATE_FILTER_VSYNTH-$(call ALLYES, QP_FILTER PP_FILTER) += fate-filter-qp -fate-filter-qp: CMD = video_filter "qp=17,pp=be/hb/vb/tn/l5/al" - FATE_FILTER_VSYNTH-$(CONFIG_SELECT_FILTER) += fate-filter-select fate-filter-select: CMD = framecrc -flags bitexact -idct simple -i $(SRC) -vf "select=not(eq(mod(n\,2)\,0)+eq(mod(n\,3)\,0))" -frames:v 25 -flags +bitexact diff --git a/tests/ref/fate/filter-pp2 b/tests/ref/fate/filter-pp2 deleted file mode 100644 index ed5e77322a..0000000000 --- a/tests/ref/fate/filter-pp2 +++ /dev/null @@ -1 +0,0 @@ -pp2 566d48ad25dfa7a9680de933cbdf66d9 diff --git a/tests/ref/fate/filter-pp3 b/tests/ref/fate/filter-pp3 deleted file mode 100644 index 536bf8e9d2..0000000000 --- a/tests/ref/fate/filter-pp3 +++ /dev/null @@ -1 +0,0 @@ -pp3 586fc14a52699540a865c070dd113229