FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
avf_showcqt.c File Reference
#include "config.h"
#include "libavcodec/avfft.h"
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "libavutil/xga_font_data.h"
#include "libavutil/eval.h"
#include "libavutil/pixdesc.h"
#include "libavutil/time.h"
#include "avfilter.h"
#include "internal.h"
#include "lavfutils.h"
#include "lswsutils.h"
#include "avf_showcqt.h"

Go to the source code of this file.

Macros

#define BASEFREQ   20.01523126408007475
 
#define ENDFREQ   20495.59681441799654
 
#define TLENGTH   "384*tc/(384+tc*f)"
 
#define TLENGTH_MIN   0.001
 
#define VOLUME_MAX   100.0
 
#define FONTCOLOR
 
#define CSCHEME   "1|0.5|0|0|0.5|1"
 
#define PTS_STEP   10
 
#define PTS_TOLERANCE   1
 
#define OFFSET(x)   offsetof(ShowCQTContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
 
#define DRAW_BAR_WITH_CHROMA(x)
 
#define DRAW_BAR_WITHOUT_CHROMA(x)
 
#define BLEND_WITH_CHROMA(c)
 
#define BLEND_WITHOUT_CHROMA(c, alpha_inc)
 
#define BLEND_CHROMA2(c)
 
#define BLEND_CHROMA2x2(c)
 
#define UPDATE_TIME(t)
 

Functions

 AVFILTER_DEFINE_CLASS (showcqt)
 
static void common_uninit (ShowCQTContext *s)
 
static double * create_freq_table (double base, double end, int n)
 
static double clip_with_log (void *log_ctx, const char *name, double val, double min, double max, double nan_replace, int idx)
 
static double a_weighting (void *p, double f)
 
static double b_weighting (void *p, double f)
 
static double c_weighting (void *p, double f)
 
static int init_volume (ShowCQTContext *s)
 
static void cqt_calc (FFTComplex *dst, const FFTComplex *src, const Coeffs *coeffs, int len, int fft_len)
 
static int init_cqt (ShowCQTContext *s)
 
static AVFramealloc_frame_empty (enum AVPixelFormat format, int w, int h)
 
static enum AVPixelFormat convert_axis_pixel_format (enum AVPixelFormat format)
 
static int init_axis_empty (ShowCQTContext *s)
 
static int init_axis_from_file (ShowCQTContext *s)
 
static double midi (void *p, double f)
 
static double r_func (void *p, double x)
 
static double g_func (void *p, double x)
 
static double b_func (void *p, double x)
 
static int init_axis_color (ShowCQTContext *s, AVFrame *tmp, int half)
 
static int render_freetype (ShowCQTContext *s, AVFrame *tmp, char *fontfile)
 
static int render_fontconfig (ShowCQTContext *s, AVFrame *tmp, char *font)
 
static int render_default_font (AVFrame *tmp)
 
static int init_axis_from_font (ShowCQTContext *s)
 
static float calculate_gamma (float v, float g)
 
static void rgb_from_cqt (ColorFloat *c, const FFTComplex *v, float g, int len, float cscheme[6])
 
static void yuv_from_cqt (ColorFloat *c, const FFTComplex *v, float gamma, int len, float cm[3][3], float cscheme[6])
 
static void draw_bar_rgb (AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h, float bar_t)
 
static void draw_bar_yuv (AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h, float bar_t)
 
static void draw_axis_rgb (AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
 
static void draw_axis_yuv (AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
 
static void draw_sono (AVFrame *out, AVFrame *sono, int off, int idx)
 
static void update_sono_rgb (AVFrame *sono, const ColorFloat *c, int idx)
 
static void update_sono_yuv (AVFrame *sono, const ColorFloat *c, int idx)
 
static void process_cqt (ShowCQTContext *s)
 
static int plot_cqt (AVFilterContext *ctx, AVFrame **frameout)
 
static void init_colormatrix (ShowCQTContext *s)
 
static int init_cscheme (ShowCQTContext *s)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *insamples)
 
static int request_frame (AVFilterLink *outlink)
 

Variables

static const AVOption showcqt_options []
 
static const AVFilterPad showcqt_inputs []
 
static const AVFilterPad showcqt_outputs []
 
AVFilter ff_avf_showcqt
 

Macro Definition Documentation

#define BASEFREQ   20.01523126408007475

Definition at line 45 of file avf_showcqt.c.

Referenced by init_axis_color().

#define ENDFREQ   20495.59681441799654

Definition at line 46 of file avf_showcqt.c.

Referenced by init_axis_color().

#define TLENGTH   "384*tc/(384+tc*f)"

Definition at line 47 of file avf_showcqt.c.

#define TLENGTH_MIN   0.001

Definition at line 48 of file avf_showcqt.c.

Referenced by init_cqt().

#define VOLUME_MAX   100.0

Definition at line 49 of file avf_showcqt.c.

Referenced by init_volume().

#define FONTCOLOR
Value:
"st(0, (midi(f)-59.5)/12);" \
"st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));" \
"r(1-ld(1)) + b(ld(1))"

Definition at line 50 of file avf_showcqt.c.

#define CSCHEME   "1|0.5|0|0|0.5|1"

Definition at line 53 of file avf_showcqt.c.

#define PTS_STEP   10

Definition at line 54 of file avf_showcqt.c.

Referenced by config_output(), filter_frame(), and plot_cqt().

#define PTS_TOLERANCE   1

Definition at line 55 of file avf_showcqt.c.

Referenced by filter_frame().

#define OFFSET (   x)    offsetof(ShowCQTContext, x)

Definition at line 57 of file avf_showcqt.c.

Definition at line 58 of file avf_showcqt.c.

#define DRAW_BAR_WITH_CHROMA (   x)
Value:
do { \
if (h[x] <= ht) { \
*lpy++ = 16; \
*lpu++ = 128; \
*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); \
} \
} while (0)
#define lrintf(x)
Definition: libm_mips.h:70
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]

Definition at line 782 of file avf_showcqt.c.

Referenced by draw_bar_yuv().

#define DRAW_BAR_WITHOUT_CHROMA (   x)
Value:
do { \
if (h[x] <= ht) { \
*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)
#define lrintf(x)
Definition: libm_mips.h:70
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]

Definition at line 797 of file avf_showcqt.c.

Referenced by draw_bar_yuv().

#define BLEND_WITH_CHROMA (   c)
Value:
do { \
if (!*lpaa) { \
*lpy = lrintf(c.yuv.y + 16.0f); \
*lpu = lrintf(c.yuv.u + 128.0f); \
*lpv = lrintf(c.yuv.v + 128.0f); \
} else if (255 == *lpaa) { \
*lpy = *lpay; \
*lpu = *lpau; \
*lpv = *lpav; \
} else { \
float a = (1.0f/255.0f) * (*lpaa); \
*lpy = lrintf(a * (*lpay) + (1.0f - a) * (c.yuv.y + 16.0f)); \
*lpu = lrintf(a * (*lpau) + (1.0f - a) * (c.yuv.u + 128.0f)); \
*lpv = lrintf(a * (*lpav) + (1.0f - a) * (c.yuv.v + 128.0f)); \
} \
lpy++; lpu++; lpv++; \
lpay++; lpau++; lpav++; lpaa++; \
} while (0)
#define lrintf(x)
Definition: libm_mips.h:70
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]

Definition at line 888 of file avf_showcqt.c.

Referenced by draw_axis_yuv().

#define BLEND_WITHOUT_CHROMA (   c,
  alpha_inc 
)
Value:
do { \
if (!*lpaa) { \
*lpy = lrintf(c.yuv.y + 16.0f); \
} else if (255 == *lpaa) { \
*lpy = *lpay; \
} else { \
float a = (1.0f/255.0f) * (*lpaa); \
*lpy = lrintf(a * (*lpay) + (1.0f - a) * (c.yuv.y + 16.0f)); \
} \
lpy++; \
lpay++; lpaa += alpha_inc; \
} while (0)
#define lrintf(x)
Definition: libm_mips.h:70
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]

Definition at line 908 of file avf_showcqt.c.

Referenced by draw_axis_yuv().

#define BLEND_CHROMA2 (   c)
Value:
do { \
if (!lpaa[0] && !lpaa[1]) { \
*lpu = lrintf(c.yuv.u + 128.0f); \
*lpv = lrintf(c.yuv.v + 128.0f); \
} else if (255 == lpaa[0] && 255 == lpaa[1]) { \
*lpu = *lpau; *lpv = *lpav; \
} else { \
float a0 = (0.5f/255.0f) * lpaa[0]; \
float a1 = (0.5f/255.0f) * lpaa[1]; \
float b = 1.0f - a0 - a1; \
*lpu = lrintf(a0 * lpau[0] + a1 * lpau[1] + b * (c.yuv.u + 128.0f)); \
*lpv = lrintf(a0 * lpav[0] + a1 * lpav[1] + b * (c.yuv.v + 128.0f)); \
} \
lpau += 2; lpav += 2; lpaa++; lpu++; lpv++; \
} while (0)
#define a0
Definition: regdef.h:46
const char * b
Definition: vf_curves.c:113
#define a1
Definition: regdef.h:47
#define lrintf(x)
Definition: libm_mips.h:70
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]

Definition at line 922 of file avf_showcqt.c.

Referenced by draw_axis_yuv().

#define BLEND_CHROMA2x2 (   c)
Value:
do { \
if (!lpaa[0] && !lpaa[1] && !lpaa[lsaa] && !lpaa[lsaa+1]) { \
*lpu = lrintf(c.yuv.u + 128.0f); \
*lpv = lrintf(c.yuv.v + 128.0f); \
} else if (255 == lpaa[0] && 255 == lpaa[1] && \
255 == lpaa[lsaa] && 255 == lpaa[lsaa+1]) { \
*lpu = *lpau; *lpv = *lpav; \
} else { \
float a0 = (0.25f/255.0f) * lpaa[0]; \
float a1 = (0.25f/255.0f) * lpaa[1]; \
float a2 = (0.25f/255.0f) * lpaa[lsaa]; \
float a3 = (0.25f/255.0f) * lpaa[lsaa+1]; \
float b = 1.0f - a0 - a1 - a2 - a3; \
*lpu = lrintf(a0 * lpau[0] + a1 * lpau[1] + a2 * lpau[lsau] + a3 * lpau[lsau+1] \
+ b * (c.yuv.u + 128.0f)); \
*lpv = lrintf(a0 * lpav[0] + a1 * lpav[1] + a2 * lpav[lsav] + a3 * lpav[lsav+1] \
+ b * (c.yuv.v + 128.0f)); \
} \
lpau += 2; lpav += 2; lpaa++; lpu++; lpv++; \
} while (0)
#define a0
Definition: regdef.h:46
const char * b
Definition: vf_curves.c:113
#define a1
Definition: regdef.h:47
#define a3
Definition: regdef.h:49
#define lrintf(x)
Definition: libm_mips.h:70
#define a2
Definition: regdef.h:48
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]

Definition at line 939 of file avf_showcqt.c.

Referenced by draw_axis_yuv().

#define UPDATE_TIME (   t)
Value:
t += cur_time - last_time; \
last_time = cur_time
static int64_t cur_time
Definition: ffserver.c:252
int64_t av_gettime(void)
Get the current time in microseconds.
Definition: time.c:39

Referenced by plot_cqt().

Function Documentation

AVFILTER_DEFINE_CLASS ( showcqt  )
static void common_uninit ( ShowCQTContext s)
static

Definition at line 107 of file avf_showcqt.c.

Referenced by config_output(), and uninit().

static double* create_freq_table ( double  base,
double  end,
int  n 
)
static

Definition at line 163 of file avf_showcqt.c.

Referenced by config_output(), and init_axis_color().

static double clip_with_log ( void log_ctx,
const char *  name,
double  val,
double  min,
double  max,
double  nan_replace,
int  idx 
)
static

Definition at line 183 of file avf_showcqt.c.

Referenced by init_cqt(), and init_volume().

static double a_weighting ( void p,
double  f 
)
static

Definition at line 204 of file avf_showcqt.c.

Referenced by init_volume().

static double b_weighting ( void p,
double  f 
)
static

Definition at line 212 of file avf_showcqt.c.

Referenced by init_volume().

static double c_weighting ( void p,
double  f 
)
static

Definition at line 219 of file avf_showcqt.c.

Referenced by init_volume().

static int init_volume ( ShowCQTContext s)
static

Definition at line 226 of file avf_showcqt.c.

Referenced by config_output().

static void cqt_calc ( FFTComplex dst,
const FFTComplex src,
const Coeffs coeffs,
int  len,
int  fft_len 
)
static

Definition at line 268 of file avf_showcqt.c.

Referenced by config_output().

static int init_cqt ( ShowCQTContext s)
static

Definition at line 295 of file avf_showcqt.c.

Referenced by config_output().

static AVFrame* alloc_frame_empty ( enum AVPixelFormat  format,
int  w,
int  h 
)
static

Definition at line 357 of file avf_showcqt.c.

Referenced by config_output(), init_axis_empty(), and init_axis_from_font().

static enum AVPixelFormat convert_axis_pixel_format ( enum AVPixelFormat  format)
static

Definition at line 383 of file avf_showcqt.c.

Referenced by init_axis_empty(), init_axis_from_file(), and init_axis_from_font().

static int init_axis_empty ( ShowCQTContext s)
static

Definition at line 394 of file avf_showcqt.c.

Referenced by config_output().

static int init_axis_from_file ( ShowCQTContext s)
static

Definition at line 401 of file avf_showcqt.c.

Referenced by config_output().

static double midi ( void p,
double  f 
)
static

Definition at line 433 of file avf_showcqt.c.

Referenced by init_axis_color().

static double r_func ( void p,
double  x 
)
static

Definition at line 438 of file avf_showcqt.c.

Referenced by init_axis_color().

static double g_func ( void p,
double  x 
)
static

Definition at line 444 of file avf_showcqt.c.

Referenced by init_axis_color().

static double b_func ( void p,
double  x 
)
static

Definition at line 450 of file avf_showcqt.c.

Referenced by init_axis_color().

static int init_axis_color ( ShowCQTContext s,
AVFrame tmp,
int  half 
)
static

Definition at line 456 of file avf_showcqt.c.

Referenced by init_axis_from_font().

static int render_freetype ( ShowCQTContext s,
AVFrame tmp,
char *  fontfile 
)
static

Definition at line 503 of file avf_showcqt.c.

Referenced by init_axis_from_font(), and render_fontconfig().

static int render_fontconfig ( ShowCQTContext s,
AVFrame tmp,
char *  font 
)
static

Definition at line 587 of file avf_showcqt.c.

Referenced by init_axis_from_font().

static int render_default_font ( AVFrame tmp)
static

Definition at line 651 of file avf_showcqt.c.

Referenced by init_axis_from_font().

static int init_axis_from_font ( ShowCQTContext s)
static

Definition at line 677 of file avf_showcqt.c.

Referenced by config_output().

static float calculate_gamma ( float  v,
float  g 
)
static

Definition at line 718 of file avf_showcqt.c.

Referenced by process_cqt(), rgb_from_cqt(), and yuv_from_cqt().

static void rgb_from_cqt ( ColorFloat c,
const FFTComplex v,
float  g,
int  len,
float  cscheme[6] 
)
static

Definition at line 731 of file avf_showcqt.c.

Referenced by process_cqt().

static void yuv_from_cqt ( ColorFloat c,
const FFTComplex v,
float  gamma,
int  len,
float  cm[3][3],
float  cscheme[6] 
)
static

Definition at line 741 of file avf_showcqt.c.

Referenced by process_cqt().

static void draw_bar_rgb ( AVFrame out,
const float *  h,
const float *  rcp_h,
const ColorFloat c,
int  bar_h,
float  bar_t 
)
static

Definition at line 755 of file avf_showcqt.c.

Referenced by config_output().

static void draw_bar_yuv ( AVFrame out,
const float *  h,
const float *  rcp_h,
const ColorFloat c,
int  bar_h,
float  bar_t 
)
static

Definition at line 808 of file avf_showcqt.c.

Referenced by config_output().

static void draw_axis_rgb ( AVFrame out,
AVFrame axis,
const ColorFloat c,
int  off 
)
static

Definition at line 859 of file avf_showcqt.c.

Referenced by config_output().

static void draw_axis_yuv ( AVFrame out,
AVFrame axis,
const ColorFloat c,
int  off 
)
static

Definition at line 961 of file avf_showcqt.c.

Referenced by config_output().

static void draw_sono ( AVFrame out,
AVFrame sono,
int  off,
int  idx 
)
static

Definition at line 1026 of file avf_showcqt.c.

Referenced by config_output().

static void update_sono_rgb ( AVFrame sono,
const ColorFloat c,
int  idx 
)
static

Definition at line 1050 of file avf_showcqt.c.

Referenced by config_output().

static void update_sono_yuv ( AVFrame sono,
const ColorFloat c,
int  idx 
)
static

Definition at line 1062 of file avf_showcqt.c.

Referenced by config_output().

static void process_cqt ( ShowCQTContext s)
static

Definition at line 1081 of file avf_showcqt.c.

Referenced by plot_cqt().

static int plot_cqt ( AVFilterContext ctx,
AVFrame **  frameout 
)
static

Definition at line 1127 of file avf_showcqt.c.

Referenced by filter_frame().

static void init_colormatrix ( ShowCQTContext s)
static

Definition at line 1189 of file avf_showcqt.c.

Referenced by init().

static int init_cscheme ( ShowCQTContext s)
static

Definition at line 1224 of file avf_showcqt.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 1246 of file avf_showcqt.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1303 of file avf_showcqt.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 1308 of file avf_showcqt.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 1343 of file avf_showcqt.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 1456 of file avf_showcqt.c.

Referenced by request_frame().

static int request_frame ( AVFilterLink outlink)
static

Definition at line 1537 of file avf_showcqt.c.

Variable Documentation

const AVOption showcqt_options[]
static

Definition at line 60 of file avf_showcqt.c.

const AVFilterPad showcqt_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
Definition: avf_showcqt.c:1456

Definition at line 1548 of file avf_showcqt.c.

const AVFilterPad showcqt_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_output(AVFilterLink *outlink)
Definition: avf_showcqt.c:1343
static int request_frame(AVFilterLink *outlink)
Definition: avf_showcqt.c:1537

Definition at line 1557 of file avf_showcqt.c.

AVFilter ff_avf_showcqt
Initial value:
= {
.name = "showcqt",
.description = NULL_IF_CONFIG_SMALL("Convert input audio to a CQT (Constant/Clamped Q Transform) spectrum video output."),
.init = init,
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(ShowCQTContext),
.priv_class = &showcqt_class,
}
static av_cold int init(AVFilterContext *ctx)
Definition: avf_showcqt.c:1246
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_showcqt.c:1303
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVFilterPad showcqt_outputs[]
Definition: avf_showcqt.c:1557
static const AVFilterPad showcqt_inputs[]
Definition: avf_showcqt.c:1548
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
static int query_formats(AVFilterContext *ctx)
Definition: avf_showcqt.c:1308

Definition at line 1567 of file avf_showcqt.c.