FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
avf_showcqt.c File Reference
#include <math.h>
#include <stdlib.h>
#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 "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 OFFSET(x)   offsetof(ShowCQTContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
 

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)
 
static int render_freetype (ShowCQTContext *s, AVFrame *tmp)
 
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)
 
static void yuv_from_cqt (ColorFloat *c, const FFTComplex *v, float gamma, int len)
 
static void draw_bar_rgb (AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h)
 
static void draw_bar_yuv (AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h)
 
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)
 
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 43 of file avf_showcqt.c.

Referenced by init_axis_color().

#define ENDFREQ   20495.59681441799654

Definition at line 44 of file avf_showcqt.c.

Referenced by init_axis_color().

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

Definition at line 45 of file avf_showcqt.c.

#define TLENGTH_MIN   0.001

Definition at line 46 of file avf_showcqt.c.

Referenced by init_cqt().

#define VOLUME_MAX   100.0

Definition at line 47 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 48 of file avf_showcqt.c.

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

Definition at line 52 of file avf_showcqt.c.

Definition at line 53 of file avf_showcqt.c.

Function Documentation

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

Definition at line 91 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 121 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 141 of file avf_showcqt.c.

Referenced by init_cqt(), and init_volume().

static double a_weighting ( void p,
double  f 
)
static

Definition at line 162 of file avf_showcqt.c.

Referenced by init_volume().

static double b_weighting ( void p,
double  f 
)
static

Definition at line 170 of file avf_showcqt.c.

Referenced by init_volume().

static double c_weighting ( void p,
double  f 
)
static

Definition at line 177 of file avf_showcqt.c.

Referenced by init_volume().

static int init_volume ( ShowCQTContext s)
static

Definition at line 184 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 226 of file avf_showcqt.c.

Referenced by config_output().

static int init_cqt ( ShowCQTContext s)
static

Definition at line 289 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 361 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 387 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 398 of file avf_showcqt.c.

Referenced by config_output().

static int init_axis_from_file ( ShowCQTContext s)
static

Definition at line 405 of file avf_showcqt.c.

Referenced by config_output().

static double midi ( void p,
double  f 
)
static

Definition at line 437 of file avf_showcqt.c.

Referenced by init_axis_color().

static double r_func ( void p,
double  x 
)
static

Definition at line 442 of file avf_showcqt.c.

Referenced by init_axis_color().

static double g_func ( void p,
double  x 
)
static

Definition at line 448 of file avf_showcqt.c.

Referenced by init_axis_color().

static double b_func ( void p,
double  x 
)
static

Definition at line 454 of file avf_showcqt.c.

Referenced by init_axis_color().

static int init_axis_color ( ShowCQTContext s,
AVFrame tmp 
)
static

Definition at line 460 of file avf_showcqt.c.

Referenced by init_axis_from_font().

static int render_freetype ( ShowCQTContext s,
AVFrame tmp 
)
static

Definition at line 506 of file avf_showcqt.c.

Referenced by init_axis_from_font().

static int render_default_font ( AVFrame tmp)
static

Definition at line 590 of file avf_showcqt.c.

Referenced by init_axis_from_font().

static int init_axis_from_font ( ShowCQTContext s)
static

Definition at line 617 of file avf_showcqt.c.

Referenced by config_output().

static float calculate_gamma ( float  v,
float  g 
)
static

Definition at line 651 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 
)
static

Definition at line 664 of file avf_showcqt.c.

Referenced by process_cqt().

static void yuv_from_cqt ( ColorFloat c,
const FFTComplex v,
float  gamma,
int  len 
)
static

Definition at line 674 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 
)
static

Definition at line 688 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 
)
static

Definition at line 714 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 812 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 831 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 891 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 915 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 927 of file avf_showcqt.c.

Referenced by config_output().

static void process_cqt ( ShowCQTContext s)
static

Definition at line 946 of file avf_showcqt.c.

Referenced by plot_cqt().

static int plot_cqt ( AVFilterContext ctx)
static

Definition at line 992 of file avf_showcqt.c.

Referenced by filter_frame().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 1027 of file avf_showcqt.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1082 of file avf_showcqt.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 1087 of file avf_showcqt.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 1122 of file avf_showcqt.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 1232 of file avf_showcqt.c.

Referenced by request_frame().

static int request_frame ( AVFilterLink outlink)
static

Definition at line 1290 of file avf_showcqt.c.

Variable Documentation

const AVOption showcqt_options[]
static

Definition at line 55 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:1232

Definition at line 1301 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:1122
static int request_frame(AVFilterLink *outlink)
Definition: avf_showcqt.c:1290

Definition at line 1310 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:1027
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_showcqt.c:1082
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static const AVFilterPad showcqt_outputs[]
Definition: avf_showcqt.c:1310
static const AVFilterPad showcqt_inputs[]
Definition: avf_showcqt.c:1301
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:385
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:375
static int query_formats(AVFilterContext *ctx)
Definition: avf_showcqt.c:1087

Definition at line 1320 of file avf_showcqt.c.