From patchwork Fri Oct 28 07:27:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 1211 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp958961vsd; Fri, 28 Oct 2016 00:29:32 -0700 (PDT) X-Received: by 10.194.229.7 with SMTP id sm7mr12229006wjc.150.1477639772259; Fri, 28 Oct 2016 00:29:32 -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 m63si8400049wma.64.2016.10.28.00.29.31; Fri, 28 Oct 2016 00:29:32 -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=@gmail.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; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E2283689F69; Fri, 28 Oct 2016 10:29:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C3DBB689CE8 for ; Fri, 28 Oct 2016 10:29:18 +0300 (EEST) Received: by mail-pf0-f194.google.com with SMTP id n85so477810pfi.3 for ; Fri, 28 Oct 2016 00:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=TAgXU/zwapmo4q8JANmEgVevkG/P/JvByXnbFLk9tSQ=; b=BbcY4iaHRvYFyx7VmV2sQJK1yzUCrWNyfj+fSAWSEZ7lw7vuqTAwRgsnO++wDfU6w/ kkvtF6xutZZlLjbgEEPtJKmy6f1TreiuEjwKqocWC75zwgPcglfYwR35Kdge6wEQ4i/W ubsOIZUNgu4gpLH7uSxN4Jm4G1+e0dl5K14GxsHgSl4WmIlutEFQTaP0ndG1kl8CubPs r8OyE67xOUErWcBGpuQdoMnrpcZimKwnzW3XmQM9Ij18wyY37wfvoUwPGmTvy+cVi3h0 UcDHHsuMD41wEch/L4/lmkq7/+NqQJzmAJOYv4U3cMQv1eQbSYwZNIGt3rjTx1EgS/EI Udbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TAgXU/zwapmo4q8JANmEgVevkG/P/JvByXnbFLk9tSQ=; b=PVKvvwnWJTgxxpUE0IVEy880TK1NVhBLtppnvS2VcJIHXeVrk4Nsg+EoOjuLFFNm/2 j2fMcC3SwmTWua6As1iqn0dI/GxcJ1yNuG7bReBK+nFXS990ieCSKU6PNeQuSz0uIZAh ArVgAL9Jr0KPlkWQOWc9YpzggqMDa1Be3FEJAJIVjcNyGNg936bRkXej3q7WTbGrlNK2 S423VWT9B8TB4aOg05mpCbhq4lGjtpjuNCcp/tPhJj09/h1DDOkpSycp/B5tgLfjSEDs iRZS9ZRid6d0e3pAWFR7AQMDB92DB40P6w/LlpGtfg84bGkE1Mfa57+opaqsNkkJQM+I NAUA== X-Gm-Message-State: ABUngved4pPEenqRdcvyxvnxtogBrvp3tJloDLUGn9JWFBRam49mcD4UxcG18iQ/izhG5A== X-Received: by 10.99.213.21 with SMTP id c21mr18632322pgg.176.1477639760111; Fri, 28 Oct 2016 00:29:20 -0700 (PDT) Received: from localhost.localdomain.localdomain ([114.121.233.240]) by smtp.gmail.com with ESMTPSA id ak3sm16521620pad.19.2016.10.28.00.29.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 00:29:19 -0700 (PDT) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Oct 2016 14:27:00 +0700 Message-Id: <1477639620-16315-1-git-send-email-mfcc64@gmail.com> X-Mailer: git-send-email 2.5.0 Subject: [FFmpeg-devel] [PATCH] avfilter/avf_showcqt: add bar_t option 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: Muhammad Faiz MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" custom bargraph transparency Signed-off-by: Muhammad Faiz --- doc/filters.texi | 4 ++++ libavfilter/avf_showcqt.c | 14 +++++++++----- libavfilter/avf_showcqt.h | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c37fa29..fb04a56 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16835,6 +16835,10 @@ Acceptable range is @code{[1, 7]}. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is @code{[1, 7]}. +@item bar_t +Specify the bargraph transparency level. Lower value makes the bargraph sharper. +Default value is @code{1}. Acceptable range is @code{[0, 1]}. + @item timeclamp, tc Specify the transform timeclamp. At low frequency, there is trade-off between accuracy in time domain and frequency domain. If timeclamp is lower, diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index 49b950c..a25176d 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -75,6 +75,7 @@ static const AVOption showcqt_options[] = { { "gamma", "set sonogram gamma", OFFSET(sono_g), AV_OPT_TYPE_FLOAT, { .dbl = 3.0 }, 1.0, 7.0, FLAGS }, { "bar_g", "set bargraph gamma", OFFSET(bar_g), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 1.0, 7.0, FLAGS }, { "gamma2", "set bargraph gamma", OFFSET(bar_g), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 1.0, 7.0, FLAGS }, + { "bar_t", "set bar transparency", OFFSET(bar_t), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 1.0, FLAGS }, { "timeclamp", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS }, { "tc", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS }, { "basefreq", "set base frequency", OFFSET(basefreq), AV_OPT_TYPE_DOUBLE, { .dbl = BASEFREQ }, 10.0, 100000.0, FLAGS }, @@ -752,10 +753,10 @@ static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int le } static void draw_bar_rgb(AVFrame *out, const float *h, const float *rcp_h, - const ColorFloat *c, int bar_h) + const ColorFloat *c, int bar_h, float bar_t) { int x, y, w = out->width; - float mul, ht, rcp_bar_h = 1.0f / bar_h; + float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t; uint8_t *v = out->data[0], *lp; int ls = out->linesize[0]; @@ -769,6 +770,7 @@ static void draw_bar_rgb(AVFrame *out, const float *h, const float *rcp_h, *lp++ = 0; } else { mul = (h[x] - ht) * rcp_h[x]; + mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; *lp++ = lrintf(mul * c[x].rgb.r); *lp++ = lrintf(mul * c[x].rgb.g); *lp++ = lrintf(mul * c[x].rgb.b); @@ -785,6 +787,7 @@ do { \ *lpv++ = 128; \ } else { \ mul = (h[x] - ht) * rcp_h[x]; \ + mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \ *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \ *lpu++ = lrintf(mul * c[x].yuv.u + 128.0f); \ *lpv++ = lrintf(mul * c[x].yuv.v + 128.0f); \ @@ -797,15 +800,16 @@ do { \ *lpy++ = 16; \ } else { \ mul = (h[x] - ht) * rcp_h[x]; \ + mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \ *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \ } \ } while (0) static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h, - const ColorFloat *c, int bar_h) + const ColorFloat *c, int bar_h, float bar_t) { int x, y, yh, w = out->width; - float mul, ht, rcp_bar_h = 1.0f / bar_h; + float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t; uint8_t *vy = out->data[0], *vu = out->data[1], *vv = out->data[2]; uint8_t *lpy, *lpu, *lpv; int lsy = out->linesize[0], lsu = out->linesize[1], lsv = out->linesize[2]; @@ -1160,7 +1164,7 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout) UPDATE_TIME(s->alloc_time); if (s->bar_h) { - s->draw_bar(out, s->h_buf, s->rcp_h_buf, s->c_buf, s->bar_h); + s->draw_bar(out, s->h_buf, s->rcp_h_buf, s->c_buf, s->bar_h, s->bar_t); UPDATE_TIME(s->bar_time); } diff --git a/libavfilter/avf_showcqt.h b/libavfilter/avf_showcqt.h index 165d36e..3fa36f8 100644 --- a/libavfilter/avf_showcqt.h +++ b/libavfilter/avf_showcqt.h @@ -78,7 +78,7 @@ typedef struct { int len, int fft_len); void (*permute_coeffs)(float *v, int len); void (*draw_bar)(AVFrame *out, const float *h, const float *rcp_h, - const ColorFloat *c, int bar_h); + const ColorFloat *c, int bar_h, float bar_t); void (*draw_axis)(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off); void (*draw_sono)(AVFrame *out, AVFrame *sono, int off, int idx); void (*update_sono)(AVFrame *sono, const ColorFloat *c, int idx); @@ -102,6 +102,7 @@ typedef struct { char *bar_v; float sono_g; float bar_g; + float bar_t; double timeclamp; double basefreq; double endfreq;