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

Go to the source code of this file.

Data Structures

struct  SparseCoeff
 
struct  ShowCQTContext
 

Macros

#define VIDEO_WIDTH   1920
 
#define VIDEO_HEIGHT   1080
 
#define FONT_HEIGHT   32
 
#define SPECTOGRAM_HEIGHT   ((VIDEO_HEIGHT-FONT_HEIGHT)/2)
 
#define SPECTOGRAM_START   (VIDEO_HEIGHT-SPECTOGRAM_HEIGHT)
 
#define BASE_FREQ   20.051392800492
 
#define COEFF_CLAMP   1.0e-4
 
#define TLENGTH_MIN   0.001
 
#define TLENGTH_DEFAULT   "384/f*tc/(384/f+tc)"
 
#define VOLUME_MIN   1e-10
 
#define VOLUME_MAX   100.0
 
#define FONTCOLOR_DEFAULT
 
#define OFFSET(x)   offsetof(ShowCQTContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (showcqt)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
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 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 qsort_sparsecoeff (const SparseCoeff *a, const SparseCoeff *b)
 
static int config_output (AVFilterLink *outlink)
 
static int plot_cqt (AVFilterLink *inlink)
 
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 VIDEO_WIDTH   1920

Definition at line 46 of file avf_showcqt.c.

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

#define VIDEO_HEIGHT   1080

Definition at line 47 of file avf_showcqt.c.

Referenced by config_output().

#define FONT_HEIGHT   32

Definition at line 48 of file avf_showcqt.c.

Referenced by plot_cqt().

#define SPECTOGRAM_HEIGHT   ((VIDEO_HEIGHT-FONT_HEIGHT)/2)

Definition at line 49 of file avf_showcqt.c.

Referenced by config_output(), and plot_cqt().

#define SPECTOGRAM_START   (VIDEO_HEIGHT-SPECTOGRAM_HEIGHT)

Definition at line 50 of file avf_showcqt.c.

Referenced by plot_cqt().

#define BASE_FREQ   20.051392800492

Definition at line 51 of file avf_showcqt.c.

Referenced by config_output().

#define COEFF_CLAMP   1.0e-4

Definition at line 52 of file avf_showcqt.c.

Referenced by config_output().

#define TLENGTH_MIN   0.001

Definition at line 53 of file avf_showcqt.c.

Referenced by config_output().

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

Definition at line 54 of file avf_showcqt.c.

#define VOLUME_MIN   1e-10

Definition at line 55 of file avf_showcqt.c.

Referenced by config_output().

#define VOLUME_MAX   100.0

Definition at line 56 of file avf_showcqt.c.

Referenced by config_output().

#define FONTCOLOR_DEFAULT
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 57 of file avf_showcqt.c.

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

Definition at line 98 of file avf_showcqt.c.

Definition at line 99 of file avf_showcqt.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( showcqt  )
static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 118 of file avf_showcqt.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 136 of file avf_showcqt.c.

static double a_weighting ( void p,
double  f 
)
static

Definition at line 263 of file avf_showcqt.c.

Referenced by config_output().

static double b_weighting ( void p,
double  f 
)
static

Definition at line 271 of file avf_showcqt.c.

Referenced by config_output().

static double c_weighting ( void p,
double  f 
)
static

Definition at line 278 of file avf_showcqt.c.

Referenced by config_output().

static double midi ( void p,
double  f 
)
static

Definition at line 285 of file avf_showcqt.c.

Referenced by config_output().

static double r_func ( void p,
double  x 
)
static

Definition at line 290 of file avf_showcqt.c.

Referenced by config_output().

static double g_func ( void p,
double  x 
)
static

Definition at line 296 of file avf_showcqt.c.

Referenced by config_output().

static double b_func ( void p,
double  x 
)
static

Definition at line 302 of file avf_showcqt.c.

Referenced by config_output().

static int qsort_sparsecoeff ( const SparseCoeff a,
const SparseCoeff b 
)
inlinestatic

Definition at line 308 of file avf_showcqt.c.

Referenced by config_output().

static int config_output ( AVFilterLink outlink)
static

Definition at line 316 of file avf_showcqt.c.

static int plot_cqt ( AVFilterLink inlink)
static

Definition at line 528 of file avf_showcqt.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 706 of file avf_showcqt.c.

Referenced by request_frame().

static int request_frame ( AVFilterLink outlink)
static

Definition at line 766 of file avf_showcqt.c.

Variable Documentation

const AVOption showcqt_options[]
static
Initial value:
= {
{ "volume", "set volume", OFFSET(volume), AV_OPT_TYPE_STRING, { .str = "16" }, CHAR_MIN, CHAR_MAX, FLAGS },
{ "tlength", "set transform length", OFFSET(tlength), AV_OPT_TYPE_STRING, { .str = TLENGTH_DEFAULT }, CHAR_MIN, CHAR_MAX, FLAGS },
{ "timeclamp", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS },
{ "coeffclamp", "set coeffclamp", OFFSET(coeffclamp), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, 0.1, 10, FLAGS },
{ "gamma", "set gamma", OFFSET(gamma), AV_OPT_TYPE_FLOAT, { .dbl = 3 }, 1, 7, FLAGS },
{ "gamma2", "set gamma of bargraph", OFFSET(gamma2), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, 1, 7, FLAGS },
{ "fullhd", "set full HD resolution", OFFSET(fullhd), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS },
{ "fps", "set video fps", OFFSET(fps), AV_OPT_TYPE_INT, { .i64 = 25 }, 10, 100, FLAGS },
{ "count", "set number of transform per frame", OFFSET(count), AV_OPT_TYPE_INT, { .i64 = 6 }, 1, 30, FLAGS },
{ "fontfile", "set font file", OFFSET(fontfile), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, FLAGS },
{ "fontcolor", "set font color", OFFSET(fontcolor), AV_OPT_TYPE_STRING, { .str = FONTCOLOR_DEFAULT }, CHAR_MIN, CHAR_MAX, FLAGS },
{ NULL }
}

Definition at line 101 of file avf_showcqt.c.

const AVFilterPad showcqt_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}

Definition at line 782 of file avf_showcqt.c.

const AVFilterPad showcqt_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
.request_frame = request_frame,
},
{ NULL }
}

Definition at line 791 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 Q Transform) spectrum video output."),
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(ShowCQTContext),
.priv_class = &showcqt_class,
}

Definition at line 801 of file avf_showcqt.c.