From patchwork Mon Dec 30 11:09:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 17059 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 F3D7544B230 for ; Mon, 30 Dec 2019 13:10:18 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DF07B68AA9D; Mon, 30 Dec 2019 13:10:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 937C768AB36 for ; Mon, 30 Dec 2019 13:10:12 +0200 (EET) Received: by mail-pf1-f194.google.com with SMTP id n9so10221500pff.13 for ; Mon, 30 Dec 2019 03:10:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hD9iRXQEiv2fqBCtx9TzmTqHHNBXYh2J7gHEYq04alw=; b=A84nq21hwU40YTu2tir+4p3B/d2TwEpdXq2meiMLxIuhR8jJSFYYDxe+LZvlJuUzL1 BGQhd5Fn3NfCLFGZ5F9LWYumMXE4Z4L6SsOnHMSarcScnYsJAyYk3VLRbnzMEytc95fm 5w0/NHM/KF+TR5lSc5Ya0ds/YxQiHRWVb8Z4/ywHXtGB18T36RF2eW/hBg14m2cvwF9t vedoBZjlN9z3r0IdlYbLAqGsVZRYiKOLGXL2qkH3A8BgNoqLn2Ka32IpB3sw6Zx2ornb 8xRmKSLDdvShPUmbUWyKT2f6BsmJ4hQxRnIFfWWMkoD4vknj8mpVT7Rf9SwTPSkSRNNm W3RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hD9iRXQEiv2fqBCtx9TzmTqHHNBXYh2J7gHEYq04alw=; b=adlNuEKfhJ8I8jPSyrPpTVIBcWiMqPIk+sleGyX5hgIF9GjG3I9KITz9wAwQ9jsLMD Nt0iyNZ7d75JyVQJukvEnJi0vU6DnLHDli8h+/Kgx3fpTyrG6mrp+lVOV2GmDuCMD9JR gRWtCVzvLHGCzv9f92yBo/dS8E3yTW+C2axylExRosPCU7XUiLBMjiv6yaPG5CNbG+EG +O0Qq04XUlL71fMJNY3erj6Tl2/uX4YfS6+4wOEy+XRERrecupQ3GgNBNWLiu0w6BTmJ mWW3mQhIkzN6hre2F8OeU5lUEIfIoqfmSc328pHHvWSezBi7MJkRbU7NDMSBfyiuQZvC c3hA== X-Gm-Message-State: APjAAAXvHPVTmcz12yLuQEIEivKyRmMerxyZuDW7t+STUq9lGwnhRyvD lHMc/Z2Jc52+uP1r69CvjxcGfjaX X-Google-Smtp-Source: APXvYqwF2VvGL8IAGNHBFggUHAcD7rfz8+MJB5+CY6jN2J/bV0NxXEVAiCfv5xLm/WCpnahq6/2jng== X-Received: by 2002:a63:fc01:: with SMTP id j1mr73827928pgi.220.1577704210801; Mon, 30 Dec 2019 03:10:10 -0800 (PST) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id m3sm46908334pgp.32.2019.12.30.03.10.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Dec 2019 03:10:10 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Dec 2019 19:09:57 +0800 Message-Id: <20191230110958.6188-4-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20191230110958.6188-1-lance.lmwang@gmail.com> References: <20191230110958.6188-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1 4/5] avfilter/vf_signalstats: make the alloc array used for any bit depth 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_signalstats.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c index 7dadff45b3..8b2a9ca7c2 100644 --- a/libavfilter/vf_signalstats.c +++ b/libavfilter/vf_signalstats.c @@ -168,7 +168,6 @@ static int config_output(AVFilterLink *outlink) s->vsub = desc->log2_chroma_h; s->depth = desc->comp[0].depth; s->maxsize = 1 << s->depth; - if (s->depth > 8) { s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy)); s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu)); s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv)); @@ -176,7 +175,6 @@ static int config_output(AVFilterLink *outlink) if (!s->histy || !s->histu || !s->histv || !s->histsat) return AVERROR(ENOMEM); - } outlink->w = inlink->w; outlink->h = inlink->h; @@ -464,8 +462,6 @@ static const struct { {NULL} }; -#define DEPTH 256 - static int compute_sat_hue_metrics8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { int i, j; @@ -559,11 +555,11 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) pw = 0, cpw = 0; // prev int fil; char metabuf[128]; - unsigned int histy[DEPTH] = {0}, - histu[DEPTH] = {0}, - histv[DEPTH] = {0}, + unsigned int *histy = s->histy, + *histu = s->histu, + *histv = s->histv, histhue[360] = {0}, - histsat[DEPTH] = {0}; // limited to 8 bit data. + *histsat = s->histsat; int miny = -1, minu = -1, minv = -1; int maxy = -1, maxu = -1, maxv = -1; int lowy = -1, lowu = -1, lowv = -1; @@ -607,6 +603,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) NULL, FFMIN(s->chromah, ff_filter_get_nb_threads(ctx))); // Calculate luma histogram and difference with previous frame or field. + memset(s->histy, 0, s->maxsize * sizeof(*s->histy)); for (j = 0; j < link->h; j++) { for (i = 0; i < link->w; i++) { const int yuv = in->data[0][w + i]; @@ -620,6 +617,9 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) } // Calculate chroma histogram and difference with previous frame or field. + memset(s->histu, 0, s->maxsize * sizeof(*s->histu)); + memset(s->histv, 0, s->maxsize * sizeof(*s->histv)); + memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat)); for (j = 0; j < s->chromah; j++) { for (i = 0; i < s->chromaw; i++) { const int yuvu = in->data[1][cw+i]; @@ -664,7 +664,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) chighp = lrint(s->cfs * 90 / 100.); accy = accu = accv = accsat = 0; - for (fil = 0; fil < DEPTH; fil++) { + for (fil = 0; fil < s->maxsize; fil++) { if (miny < 0 && histy[fil]) miny = fil; if (minu < 0 && histu[fil]) minu = fil; if (minv < 0 && histv[fil]) minv = fil;