From patchwork Sat Dec 28 14:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17024 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 7ED4244AF3C for ; Sat, 28 Dec 2019 16:47:02 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 63A0868ABF3; Sat, 28 Dec 2019 16:47:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B0D86688153 for ; Sat, 28 Dec 2019 16:46:56 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7739BE3EAA; Sat, 28 Dec 2019 15:46:56 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j8EAfYHPHRU6; Sat, 28 Dec 2019 15:46:54 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0552FE3E8F; Sat, 28 Dec 2019 15:46:54 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Dec 2019 15:46:24 +0100 Message-Id: <20191228144625.28804-2-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191228144625.28804-1-cus@passwd.hu> References: <20191228144625.28804-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 2/3] avfilter/vf_geq: use per-thread state for expression evaluation 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 Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes ticket #7528. Signed-off-by: Marton Balint --- libavfilter/vf_geq.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c index 2905efae24..417b92222d 100644 --- a/libavfilter/vf_geq.c +++ b/libavfilter/vf_geq.c @@ -377,6 +377,7 @@ static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_j int x, y; uint8_t *ptr; uint16_t *ptr16; + AVExprState *state = av_expr_state_alloc(); double values[VAR_VARS_NB]; values[VAR_W] = geq->values[VAR_W]; @@ -386,6 +387,9 @@ static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_j values[VAR_SH] = geq->values[VAR_SH]; values[VAR_T] = geq->values[VAR_T]; + if (!state) + return AVERROR(ENOMEM); + if (geq->bps == 8) { for (y = slice_start; y < slice_end; y++) { ptr = geq->dst + linesize * y; @@ -393,7 +397,7 @@ static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_j for (x = 0; x < width; x++) { values[VAR_X] = x; - ptr[x] = av_expr_eval(geq->e[plane], values, geq); + ptr[x] = av_expr_eval2(geq->e[plane], state, values, geq); } ptr += linesize; } @@ -404,10 +408,11 @@ static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_j values[VAR_Y] = y; for (x = 0; x < width; x++) { values[VAR_X] = x; - ptr16[x] = av_expr_eval(geq->e[plane], values, geq); + ptr16[x] = av_expr_eval2(geq->e[plane], state, values, geq); } } } + av_expr_state_free(&state); return 0; }