FFmpeg
Data Structures | Macros | Functions | Variables
af_astats.c File Reference
#include <float.h>
#include <math.h>
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"

Go to the source code of this file.

Data Structures

struct  ChannelStats
 
struct  AudioStatsContext
 

Macros

#define HISTOGRAM_SIZE   8192
 
#define HISTOGRAM_MAX   (HISTOGRAM_SIZE-1)
 
#define MEASURE_ALL   UINT_MAX
 
#define MEASURE_NONE   0
 
#define MEASURE_DC_OFFSET   (1 << 0)
 
#define MEASURE_MIN_LEVEL   (1 << 1)
 
#define MEASURE_MAX_LEVEL   (1 << 2)
 
#define MEASURE_MIN_DIFFERENCE   (1 << 3)
 
#define MEASURE_MAX_DIFFERENCE   (1 << 4)
 
#define MEASURE_MEAN_DIFFERENCE   (1 << 5)
 
#define MEASURE_RMS_DIFFERENCE   (1 << 6)
 
#define MEASURE_PEAK_LEVEL   (1 << 7)
 
#define MEASURE_RMS_LEVEL   (1 << 8)
 
#define MEASURE_RMS_PEAK   (1 << 9)
 
#define MEASURE_RMS_TROUGH   (1 << 10)
 
#define MEASURE_CREST_FACTOR   (1 << 11)
 
#define MEASURE_FLAT_FACTOR   (1 << 12)
 
#define MEASURE_PEAK_COUNT   (1 << 13)
 
#define MEASURE_BIT_DEPTH   (1 << 14)
 
#define MEASURE_DYNAMIC_RANGE   (1 << 15)
 
#define MEASURE_ZERO_CROSSINGS   (1 << 16)
 
#define MEASURE_ZERO_CROSSINGS_RATE   (1 << 17)
 
#define MEASURE_NUMBER_OF_SAMPLES   (1 << 18)
 
#define MEASURE_NUMBER_OF_NANS   (1 << 19)
 
#define MEASURE_NUMBER_OF_INFS   (1 << 20)
 
#define MEASURE_NUMBER_OF_DENORMALS   (1 << 21)
 
#define MEASURE_NOISE_FLOOR   (1 << 22)
 
#define MEASURE_NOISE_FLOOR_COUNT   (1 << 23)
 
#define MEASURE_ENTROPY   (1 << 24)
 
#define MEASURE_ABS_PEAK_COUNT   (1 << 25)
 
#define MEASURE_MINMAXPEAK   (MEASURE_MIN_LEVEL | MEASURE_MAX_LEVEL | MEASURE_PEAK_LEVEL)
 
#define OFFSET(x)   offsetof(AudioStatsContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define LINEAR_TO_DB(x)   (log10(x) * 20)
 
#define UPDATE_STATS_P(type, update_func, update_float, channel_func)
 
#define UPDATE_STATS_I(type, update_func, update_float, channel_func)
 
#define UPDATE_STATS(planar, type, sample, normalizer_suffix, int_sample)
 

Functions

 AVFILTER_DEFINE_CLASS (astats)
 
static void reset_stats (AudioStatsContext *s)
 
static int config_output (AVFilterLink *outlink)
 
static void bit_depth (AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
 
static double calc_entropy (AudioStatsContext *s, ChannelStats *p)
 
static double calc_noise_floor (double *ss, double x, double px, int n, int *ffront, int *bback)
 
static void update_minmax (AudioStatsContext *s, ChannelStats *p, double d)
 
static void update_stat (AudioStatsContext *s, ChannelStats *p, double d, double nd, int64_t i)
 
static void update_float_stat (AudioStatsContext *s, ChannelStats *p, float d)
 
static void update_double_stat (AudioStatsContext *s, ChannelStats *p, double d)
 
static void set_meta (AVDictionary **metadata, int chan, const char *key, const char *fmt, double val)
 
static void set_metadata (AudioStatsContext *s, AVDictionary **metadata)
 
static int filter_channel (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *buf)
 
static void print_stats (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption astats_options []
 
static const AVFilterPad astats_inputs []
 
static const AVFilterPad astats_outputs []
 
const AVFilter ff_af_astats
 

Macro Definition Documentation

◆ HISTOGRAM_SIZE

#define HISTOGRAM_SIZE   8192

Definition at line 31 of file af_astats.c.

◆ HISTOGRAM_MAX

#define HISTOGRAM_MAX   (HISTOGRAM_SIZE-1)

Definition at line 32 of file af_astats.c.

◆ MEASURE_ALL

#define MEASURE_ALL   UINT_MAX

Definition at line 34 of file af_astats.c.

◆ MEASURE_NONE

#define MEASURE_NONE   0

Definition at line 35 of file af_astats.c.

◆ MEASURE_DC_OFFSET

#define MEASURE_DC_OFFSET   (1 << 0)

Definition at line 37 of file af_astats.c.

◆ MEASURE_MIN_LEVEL

#define MEASURE_MIN_LEVEL   (1 << 1)

Definition at line 38 of file af_astats.c.

◆ MEASURE_MAX_LEVEL

#define MEASURE_MAX_LEVEL   (1 << 2)

Definition at line 39 of file af_astats.c.

◆ MEASURE_MIN_DIFFERENCE

#define MEASURE_MIN_DIFFERENCE   (1 << 3)

Definition at line 40 of file af_astats.c.

◆ MEASURE_MAX_DIFFERENCE

#define MEASURE_MAX_DIFFERENCE   (1 << 4)

Definition at line 41 of file af_astats.c.

◆ MEASURE_MEAN_DIFFERENCE

#define MEASURE_MEAN_DIFFERENCE   (1 << 5)

Definition at line 42 of file af_astats.c.

◆ MEASURE_RMS_DIFFERENCE

#define MEASURE_RMS_DIFFERENCE   (1 << 6)

Definition at line 43 of file af_astats.c.

◆ MEASURE_PEAK_LEVEL

#define MEASURE_PEAK_LEVEL   (1 << 7)

Definition at line 44 of file af_astats.c.

◆ MEASURE_RMS_LEVEL

#define MEASURE_RMS_LEVEL   (1 << 8)

Definition at line 45 of file af_astats.c.

◆ MEASURE_RMS_PEAK

#define MEASURE_RMS_PEAK   (1 << 9)

Definition at line 46 of file af_astats.c.

◆ MEASURE_RMS_TROUGH

#define MEASURE_RMS_TROUGH   (1 << 10)

Definition at line 47 of file af_astats.c.

◆ MEASURE_CREST_FACTOR

#define MEASURE_CREST_FACTOR   (1 << 11)

Definition at line 48 of file af_astats.c.

◆ MEASURE_FLAT_FACTOR

#define MEASURE_FLAT_FACTOR   (1 << 12)

Definition at line 49 of file af_astats.c.

◆ MEASURE_PEAK_COUNT

#define MEASURE_PEAK_COUNT   (1 << 13)

Definition at line 50 of file af_astats.c.

◆ MEASURE_BIT_DEPTH

#define MEASURE_BIT_DEPTH   (1 << 14)

Definition at line 51 of file af_astats.c.

◆ MEASURE_DYNAMIC_RANGE

#define MEASURE_DYNAMIC_RANGE   (1 << 15)

Definition at line 52 of file af_astats.c.

◆ MEASURE_ZERO_CROSSINGS

#define MEASURE_ZERO_CROSSINGS   (1 << 16)

Definition at line 53 of file af_astats.c.

◆ MEASURE_ZERO_CROSSINGS_RATE

#define MEASURE_ZERO_CROSSINGS_RATE   (1 << 17)

Definition at line 54 of file af_astats.c.

◆ MEASURE_NUMBER_OF_SAMPLES

#define MEASURE_NUMBER_OF_SAMPLES   (1 << 18)

Definition at line 55 of file af_astats.c.

◆ MEASURE_NUMBER_OF_NANS

#define MEASURE_NUMBER_OF_NANS   (1 << 19)

Definition at line 56 of file af_astats.c.

◆ MEASURE_NUMBER_OF_INFS

#define MEASURE_NUMBER_OF_INFS   (1 << 20)

Definition at line 57 of file af_astats.c.

◆ MEASURE_NUMBER_OF_DENORMALS

#define MEASURE_NUMBER_OF_DENORMALS   (1 << 21)

Definition at line 58 of file af_astats.c.

◆ MEASURE_NOISE_FLOOR

#define MEASURE_NOISE_FLOOR   (1 << 22)

Definition at line 59 of file af_astats.c.

◆ MEASURE_NOISE_FLOOR_COUNT

#define MEASURE_NOISE_FLOOR_COUNT   (1 << 23)

Definition at line 60 of file af_astats.c.

◆ MEASURE_ENTROPY

#define MEASURE_ENTROPY   (1 << 24)

Definition at line 61 of file af_astats.c.

◆ MEASURE_ABS_PEAK_COUNT

#define MEASURE_ABS_PEAK_COUNT   (1 << 25)

Definition at line 62 of file af_astats.c.

◆ MEASURE_MINMAXPEAK

#define MEASURE_MINMAXPEAK   (MEASURE_MIN_LEVEL | MEASURE_MAX_LEVEL | MEASURE_PEAK_LEVEL)

Definition at line 64 of file af_astats.c.

◆ OFFSET

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

Definition at line 119 of file af_astats.c.

◆ FLAGS

Definition at line 120 of file af_astats.c.

◆ LINEAR_TO_DB

#define LINEAR_TO_DB (   x)    (log10(x) * 20)

Definition at line 477 of file af_astats.c.

◆ UPDATE_STATS_P

#define UPDATE_STATS_P (   type,
  update_func,
  update_float,
  channel_func 
)
Value:
for (int c = start; c < end; c++) { \
ChannelStats *p = &s->chstats[c]; \
const type *src = (const type *)data[c]; \
const type * const srcend = src + samples; \
for (; src < srcend; src++) { \
update_func; \
update_float; \
} \
channel_func; \
}

Definition at line 648 of file af_astats.c.

◆ UPDATE_STATS_I

#define UPDATE_STATS_I (   type,
  update_func,
  update_float,
  channel_func 
)
Value:
for (int c = start; c < end; c++) { \
ChannelStats *p = &s->chstats[c]; \
const type *src = (const type *)data[0]; \
const type * const srcend = src + samples * channels; \
for (src += c; src < srcend; src += channels) { \
update_func; \
update_float; \
} \
channel_func; \
}

Definition at line 660 of file af_astats.c.

◆ UPDATE_STATS

#define UPDATE_STATS (   planar,
  type,
  sample,
  normalizer_suffix,
  int_sample 
)
Value:
if ((s->measure_overall | s->measure_perchannel) & ~MEASURE_MINMAXPEAK) { \
UPDATE_STATS_##planar(type, update_stat(s, p, sample, sample normalizer_suffix, int_sample), s->is_float ? update_float_stat(s, p, sample) : s->is_double ? update_double_stat(s, p, sample) : (void)NULL, ); \
} else { \
UPDATE_STATS_##planar(type, update_minmax(s, p, sample), , p->nmin = p->min normalizer_suffix; p->nmax = p->max normalizer_suffix;); \
}

Definition at line 672 of file af_astats.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( astats  )

◆ reset_stats()

static void reset_stats ( AudioStatsContext s)
static

Definition at line 161 of file af_astats.c.

Referenced by config_output(), and filter_frame().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 209 of file af_astats.c.

◆ bit_depth()

static void bit_depth ( AudioStatsContext s,
const uint64_t *const  mask,
uint8_t *  depth 
)
static

Definition at line 246 of file af_astats.c.

Referenced by calc_squared_error_and_weight(), check_add_res(), check_alf_classify(), check_alf_filter(), check_avg(), check_bdof(), check_chrConvertRange(), check_chroma_mc(), check_deblock_chroma(), check_deblock_luma(), check_dmvr(), check_idct(), check_idct_dc(), check_idct_multiple(), check_ipred(), check_itxfm(), check_loop_filter(), check_loop_filter_intra(), check_loopfilter(), check_lumConvertRange(), check_mc(), check_put_vvc_chroma(), check_put_vvc_chroma_uni(), check_put_vvc_luma(), check_put_vvc_luma_uni(), check_sao_band(), check_sao_edge(), check_transform_luma(), check_vvc_sad(), checkasm_check_h264pred(), checkasm_check_h264qpel(), checkasm_check_hevc_add_res(), checkasm_check_hevc_deblock(), checkasm_check_hevc_epel(), checkasm_check_hevc_epel_bi(), checkasm_check_hevc_epel_bi_w(), checkasm_check_hevc_epel_uni(), checkasm_check_hevc_epel_uni_w(), checkasm_check_hevc_idct(), checkasm_check_hevc_qpel(), checkasm_check_hevc_qpel_bi(), checkasm_check_hevc_qpel_bi_w(), checkasm_check_hevc_qpel_uni(), checkasm_check_hevc_qpel_uni_w(), checkasm_check_hevc_sao(), checkasm_check_vvc_alf(), copy_subcoefs(), cuvid_test_capabilities(), d3d12va_encode_hevc_init_sequence_params(), dct4x4_impl(), dct8x8(), dnxhd_calc_bits_thread(), dvdvideo_audio_stream_analyze(), ff_bwdif_init_aarch64(), ff_bwdif_init_filter_line(), ff_bwdif_init_x86(), ff_dnxhd_find_cid(), ff_get_qtpalette(), ff_h264_pred_init(), ff_h264_pred_init_aarch64(), ff_h264_pred_init_arm(), ff_h264_pred_init_loongarch(), ff_h264_pred_init_mips(), ff_h264chroma_init(), ff_h264chroma_init_aarch64(), ff_h264chroma_init_arm(), ff_h264chroma_init_loongarch(), ff_h264chroma_init_mips(), ff_h264chroma_init_ppc(), ff_h264chroma_init_riscv(), ff_h264chroma_init_x86(), ff_h264dsp_init(), ff_h264dsp_init_aarch64(), ff_h264dsp_init_arm(), ff_h264dsp_init_loongarch(), ff_h264dsp_init_mips(), ff_h264dsp_init_ppc(), ff_h264dsp_init_riscv(), ff_h264dsp_init_x86(), ff_h264qpel_init(), ff_h264qpel_init_aarch64(), ff_h264qpel_init_arm(), ff_h264qpel_init_loongarch(), ff_h264qpel_init_mips(), ff_h264qpel_init_ppc(), ff_h264qpel_init_riscv(), ff_h264qpel_init_x86(), ff_hevc_dsp_init(), ff_hevc_dsp_init_aarch64(), ff_hevc_dsp_init_arm(), ff_hevc_dsp_init_loongarch(), ff_hevc_dsp_init_mips(), ff_hevc_dsp_init_neon(), ff_hevc_dsp_init_ppc(), ff_hevc_dsp_init_x86(), ff_hevc_parse_sps(), ff_hevc_pred_init(), ff_hevc_pred_init_mips(), ff_hevc_sao_offset_abs_decode(), ff_hw_base_encode_init_params_h264(), ff_hw_base_encode_init_params_h265(), ff_isom_get_vpcc_features(), ff_spatial_idwt_init(), ff_vvc_dsp_init(), ff_vvc_ep_init_stat_coeff(), ff_yadif_init_x86(), ftx(), get_sw_pixel_format(), get_vt_hevc_profile_level(), h264_pred_init_neon(), h264dsp_init_neon(), hl_decode_mb(), hl_decode_mb_444(), jpegxl_get_bit_depth(), lmcs_derive_lut(), mkv_write_track(), parse_bitstream(), parse_nal_unit(), pps_scc_extension(), PRED4x4(), print_stats(), randomize_buffers(), randomize_loopfilter_buffers(), randomize_luma_buffers(), set_metadata(), sps_scc_extension(), vaapi_av1_get_bit_depth_idx(), and xavs2_init().

◆ calc_entropy()

static double calc_entropy ( AudioStatsContext s,
ChannelStats p 
)
static

Definition at line 270 of file af_astats.c.

Referenced by print_stats(), and set_metadata().

◆ calc_noise_floor()

static double calc_noise_floor ( double ss,
double  x,
double  px,
int  n,
int *  ffront,
int *  bback 
)
static

Definition at line 284 of file af_astats.c.

Referenced by update_stat().

◆ update_minmax()

static void update_minmax ( AudioStatsContext s,
ChannelStats p,
double  d 
)
inlinestatic

Definition at line 341 of file af_astats.c.

◆ update_stat()

static void update_stat ( AudioStatsContext s,
ChannelStats p,
double  d,
double  nd,
int64_t  i 
)
inlinestatic

Definition at line 349 of file af_astats.c.

◆ update_float_stat()

static void update_float_stat ( AudioStatsContext s,
ChannelStats p,
float  d 
)
inlinestatic

Definition at line 445 of file af_astats.c.

◆ update_double_stat()

static void update_double_stat ( AudioStatsContext s,
ChannelStats p,
double  d 
)
inlinestatic

Definition at line 454 of file af_astats.c.

◆ set_meta()

static void set_meta ( AVDictionary **  metadata,
int  chan,
const char *  key,
const char *  fmt,
double  val 
)
static

Definition at line 463 of file af_astats.c.

Referenced by set_metadata().

◆ set_metadata()

static void set_metadata ( AudioStatsContext s,
AVDictionary **  metadata 
)
static

Definition at line 479 of file af_astats.c.

Referenced by filter_frame().

◆ filter_channel()

static int filter_channel ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 679 of file af_astats.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 726 of file af_astats.c.

◆ print_stats()

static void print_stats ( AVFilterContext ctx)
static

Definition at line 751 of file af_astats.c.

Referenced by uninit().

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 926 of file af_astats.c.

Variable Documentation

◆ astats_options

const AVOption astats_options[]
static

Definition at line 122 of file af_astats.c.

◆ astats_inputs

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

Definition at line 943 of file af_astats.c.

◆ astats_outputs

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

Definition at line 951 of file af_astats.c.

◆ ff_af_astats

const AVFilter ff_af_astats
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AV_SAMPLE_FMT_S32P
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
Definition: samplefmt.h:65
data
const char data[16]
Definition: mxf.c:149
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_astats.c:209
update_stat
static void update_stat(AudioStatsContext *s, ChannelStats *p, double d, double nd, int64_t i)
Definition: af_astats.c:349
update_minmax
static void update_minmax(AudioStatsContext *s, ChannelStats *p, double d)
Definition: af_astats.c:341
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
AV_SAMPLE_FMT_S64P
@ AV_SAMPLE_FMT_S64P
signed 64 bits, planar
Definition: samplefmt.h:69
planar
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
Definition: audioconvert.c:56
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: filters.h:250
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: af_astats.c:726
channels
channels
Definition: aptx.h:31
update_double_stat
static void update_double_stat(AudioStatsContext *s, ChannelStats *p, double d)
Definition: af_astats.c:454
update_float_stat
static void update_float_stat(AudioStatsContext *s, ChannelStats *p, float d)
Definition: af_astats.c:445
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_astats.c:926
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AudioStatsContext
Definition: af_astats.c:101
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
sample
#define sample
Definition: flacdsp_template.c:44
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
astats_inputs
static const AVFilterPad astats_inputs[]
Definition: af_astats.c:943
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:168
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:152
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:61
MEASURE_MINMAXPEAK
#define MEASURE_MINMAXPEAK
Definition: af_astats.c:64
AV_SAMPLE_FMT_S32
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:59
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:60
astats_outputs
static const AVFilterPad astats_outputs[]
Definition: af_astats.c:951
src
#define src
Definition: vp8dsp.c:248
AV_SAMPLE_FMT_S64
@ AV_SAMPLE_FMT_S64
signed 64 bits
Definition: samplefmt.h:68