FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
asrc_sine.c File Reference
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/eval.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"

Go to the source code of this file.

Data Structures

struct  SamplingContext
 
struct  SineContext
 

Macros

#define CONTEXT   SineContext
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define OPT_GENERIC(name, field, def, min, max, descr, type, deffield, ...)
 
#define OPT_INT(name, field, def, min, max, descr, ...)   OPT_GENERIC(name, field, def, min, max, descr, INT, i64, __VA_ARGS__)
 
#define OPT_DBL(name, field, def, min, max, descr, ...)   OPT_GENERIC(name, field, def, min, max, descr, DOUBLE, dbl, __VA_ARGS__)
 
#define OPT_DUR(name, field, def, min, max, descr, ...)   OPT_GENERIC(name, field, def, min, max, descr, DURATION, str, __VA_ARGS__)
 
#define OPT_STR(name, field, def, min, max, descr, ...)   OPT_GENERIC(name, field, def, min, max, descr, STRING, str, __VA_ARGS__)
 
#define LOG_PERIOD   15
 
#define AMPLITUDE   4095
 
#define AMPLITUDE_SHIFT   3
 

Enumerations

enum  {
  VAR_N, VAR_PTS, VAR_T, VAR_TB,
  VAR_VARS_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (sine)
 
static void make_sin_table (int16_t *sin)
 
static void sampling_init (SamplingContext *c, double frequency, int sample_rate)
 
static av_always_inline void sampling_advance (SamplingContext *c)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static av_cold int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static av_cold int config_props (AVFilterLink *outlink)
 
static int activate (AVFilterContext *ctx)
 

Variables

static const AVOption sine_options []
 
static const char *const var_names []
 
static const AVFilterPad sine_outputs []
 
const AVFilter ff_asrc_sine
 

Macro Definition Documentation

◆ CONTEXT

#define CONTEXT   SineContext

Definition at line 58 of file asrc_sine.c.

◆ FLAGS

Definition at line 59 of file asrc_sine.c.

◆ OPT_GENERIC

#define OPT_GENERIC (   name,
  field,
  def,
  min,
  max,
  descr,
  type,
  deffield,
  ... 
)
Value:
{ name, descr, offsetof(CONTEXT, field), AV_OPT_TYPE_ ## type, \
{ .deffield = def }, min, max, FLAGS, __VA_ARGS__ }

Definition at line 61 of file asrc_sine.c.

◆ OPT_INT

#define OPT_INT (   name,
  field,
  def,
  min,
  max,
  descr,
  ... 
)    OPT_GENERIC(name, field, def, min, max, descr, INT, i64, __VA_ARGS__)

Definition at line 65 of file asrc_sine.c.

◆ OPT_DBL

#define OPT_DBL (   name,
  field,
  def,
  min,
  max,
  descr,
  ... 
)    OPT_GENERIC(name, field, def, min, max, descr, DOUBLE, dbl, __VA_ARGS__)

Definition at line 68 of file asrc_sine.c.

◆ OPT_DUR

#define OPT_DUR (   name,
  field,
  def,
  min,
  max,
  descr,
  ... 
)    OPT_GENERIC(name, field, def, min, max, descr, DURATION, str, __VA_ARGS__)

Definition at line 71 of file asrc_sine.c.

◆ OPT_STR

#define OPT_STR (   name,
  field,
  def,
  min,
  max,
  descr,
  ... 
)    OPT_GENERIC(name, field, def, min, max, descr, STRING, str, __VA_ARGS__)

Definition at line 74 of file asrc_sine.c.

◆ LOG_PERIOD

#define LOG_PERIOD   15

Definition at line 92 of file asrc_sine.c.

◆ AMPLITUDE

#define AMPLITUDE   4095

Definition at line 93 of file asrc_sine.c.

◆ AMPLITUDE_SHIFT

#define AMPLITUDE_SHIFT   3

Definition at line 94 of file asrc_sine.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_N 
VAR_PTS 
VAR_T 
VAR_TB 
VAR_VARS_NB 

Definition at line 144 of file asrc_sine.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( sine  )

◆ make_sin_table()

static void make_sin_table ( int16_t *  sin)
static

Definition at line 96 of file asrc_sine.c.

Referenced by init().

◆ sampling_init()

static void sampling_init ( SamplingContext c,
double  frequency,
int  sample_rate 
)
static

Definition at line 152 of file asrc_sine.c.

Referenced by init().

◆ sampling_advance()

static av_always_inline void sampling_advance ( SamplingContext c)
static

Definition at line 171 of file asrc_sine.c.

Referenced by activate().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 181 of file asrc_sine.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 206 of file asrc_sine.c.

◆ query_formats()

static av_cold int query_formats ( const AVFilterContext ctx,
AVFilterFormatsConfig **  cfg_in,
AVFilterFormatsConfig **  cfg_out 
)
static

Definition at line 215 of file asrc_sine.c.

◆ config_props()

static av_cold int config_props ( AVFilterLink outlink)
static

Definition at line 235 of file asrc_sine.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 242 of file asrc_sine.c.

Variable Documentation

◆ sine_options

const AVOption sine_options[]
static
Initial value:
= {
OPT_DBL("frequency", frequency, 440, 0, DBL_MAX, "set the sine frequency",),
OPT_DBL("f", frequency, 440, 0, DBL_MAX, "set the sine frequency",),
OPT_DBL("beep_factor", beep_factor, 0, 0, DBL_MAX, "set the beep frequency factor",),
OPT_DBL("b", beep_factor, 0, 0, DBL_MAX, "set the beep frequency factor",),
OPT_INT("sample_rate", sample_rate, 44100, 1, INT_MAX, "set the sample rate",),
OPT_INT("r", sample_rate, 44100, 1, INT_MAX, "set the sample rate",),
OPT_DUR("duration", duration, 0, 0, INT64_MAX, "set the audio duration",),
OPT_DUR("d", duration, 0, 0, INT64_MAX, "set the audio duration",),
OPT_STR("samples_per_frame", samples_per_frame, "1024", 0, 0, "set the number of samples per frame",),
{NULL}
}

Definition at line 77 of file asrc_sine.c.

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"n",
"pts",
"t",
"TB",
}

Definition at line 136 of file asrc_sine.c.

Referenced by init().

◆ sine_outputs

const AVFilterPad sine_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
},
}

Definition at line 293 of file asrc_sine.c.

◆ ff_asrc_sine

const AVFilter ff_asrc_sine
Initial value:
= {
.name = "sine",
.description = NULL_IF_CONFIG_SMALL("Generate sine wave audio signal."),
.init = init,
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(SineContext),
.priv_class = &sine_class,
}

Definition at line 301 of file asrc_sine.c.

name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
config_props
static av_cold int config_props(AVFilterLink *outlink)
Definition: asrc_sine.c:235
max
#define max(a, b)
Definition: cuda_runtime.h:33
query_formats
static av_cold int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: asrc_sine.c:215
activate
static int activate(AVFilterContext *ctx)
Definition: asrc_sine.c:242
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: asrc_sine.c:206
OPT_DBL
#define OPT_DBL(name, field, def, min, max, descr,...)
Definition: asrc_sine.c:68
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
FLAGS
#define FLAGS
Definition: asrc_sine.c:59
duration
int64_t duration
Definition: movenc.c:65
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
field
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
Definition: writing_filters.txt:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
OPT_DUR
#define OPT_DUR(name, field, def, min, max, descr,...)
Definition: asrc_sine.c:71
NULL
#define NULL
Definition: coverity.c:32
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
SineContext
Definition: asrc_sine.c:41
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
OPT_STR
#define OPT_STR(name, field, def, min, max, descr,...)
Definition: asrc_sine.c:74
sine_outputs
static const AVFilterPad sine_outputs[]
Definition: asrc_sine.c:293
OPT_INT
#define OPT_INT(name, field, def, min, max, descr,...)
Definition: asrc_sine.c:65
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
CONTEXT
#define CONTEXT
Definition: asrc_sine.c:58
init
static av_cold int init(AVFilterContext *ctx)
Definition: asrc_sine.c:181
min
float min
Definition: vorbis_enc_data.h:429