Go to the documentation of this file.
98 #define OFFSET(x) offsetof(LoudNormContext, x)
99 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
135 double total_weight = 0.0;
136 const double sigma = 3.5;
140 const int offset = 21 / 2;
141 const double c1 = 1.0 / (sigma * sqrt(2.0 *
M_PI));
142 const double c2 = 2.0 * pow(sigma, 2.0);
144 for (
i = 0;
i < 21;
i++) {
146 s->weights[
i] =
c1 *
exp(-(pow(
x, 2.0) /
c2));
147 total_weight +=
s->weights[
i];
150 adjust = 1.0 / total_weight;
151 for (
i = 0;
i < 21;
i++)
161 for (
i = 0;
i < 21;
i++)
174 buf =
s->limiter_buf;
175 ceiling =
s->target_tp;
178 if (
index >=
s->limiter_buf_size)
179 index -=
s->limiter_buf_size;
186 for (n = 0; n < nb_samples; n++) {
188 double this, next, max_peak;
190 this = fabs(buf[(
index +
c) <
s->limiter_buf_size ? (
index +
c) : (
index +
c -
s->limiter_buf_size)]);
193 if ((
s->prev_smp[
c] <=
this) && (next <=
this) && (
this > ceiling) && (n > 0)) {
197 for (
i = 2;
i < 12;
i++) {
209 if (
c == 0 || fabs(buf[
index +
c]) > max_peak)
210 max_peak = fabs(buf[
index +
c]);
212 s->prev_smp[
c] = fabs(buf[(
index +
c) <
s->limiter_buf_size ? (
index +
c) : (
index +
c -
s->limiter_buf_size)]);
217 *peak_value = max_peak;
221 s->prev_smp[
c] =
this;
225 if (
index >=
s->limiter_buf_size)
226 index -=
s->limiter_buf_size;
232 int n,
c,
index, peak_delta, smp_cnt;
233 double ceiling, peak_value;
236 buf =
s->limiter_buf;
237 ceiling =
s->target_tp;
238 index =
s->limiter_buf_index;
245 for (n = 0; n < 1920; n++) {
253 s->gain_reduction[1] = ceiling /
max;
255 buf =
s->limiter_buf;
257 for (n = 0; n < 1920; n++) {
260 env =
s->gain_reduction[1];
267 buf =
s->limiter_buf;
272 switch(
s->limiter_state) {
275 if (peak_delta != -1) {
277 smp_cnt += (peak_delta -
s->attack_length);
278 s->gain_reduction[0] = 1.;
279 s->gain_reduction[1] = ceiling / peak_value;
282 s->env_index =
s->peak_index - (
s->attack_length *
channels);
283 if (
s->env_index < 0)
284 s->env_index +=
s->limiter_buf_size;
287 if (
s->env_index >
s->limiter_buf_size)
288 s->env_index -=
s->limiter_buf_size;
291 smp_cnt = nb_samples;
296 for (;
s->env_cnt <
s->attack_length;
s->env_cnt++) {
299 env =
s->gain_reduction[0] - ((double)
s->env_cnt / (
s->attack_length - 1) * (
s->gain_reduction[0] -
s->gain_reduction[1]));
300 buf[
s->env_index +
c] *= env;
304 if (
s->env_index >=
s->limiter_buf_size)
305 s->env_index -=
s->limiter_buf_size;
308 if (smp_cnt >= nb_samples) {
314 if (smp_cnt < nb_samples) {
316 s->attack_length = 1920;
323 if (peak_delta == -1) {
325 s->gain_reduction[0] =
s->gain_reduction[1];
326 s->gain_reduction[1] = 1.;
330 double gain_reduction;
331 gain_reduction = ceiling / peak_value;
333 if (gain_reduction < s->gain_reduction[1]) {
336 s->attack_length = peak_delta;
337 if (
s->attack_length <= 1)
338 s->attack_length = 2;
340 s->gain_reduction[0] =
s->gain_reduction[1];
341 s->gain_reduction[1] = gain_reduction;
346 for (
s->env_cnt = 0;
s->env_cnt < peak_delta;
s->env_cnt++) {
349 env =
s->gain_reduction[1];
350 buf[
s->env_index +
c] *= env;
354 if (
s->env_index >=
s->limiter_buf_size)
355 s->env_index -=
s->limiter_buf_size;
358 if (smp_cnt >= nb_samples) {
367 for (;
s->env_cnt <
s->release_length;
s->env_cnt++) {
370 env =
s->gain_reduction[0] + (((double)
s->env_cnt / (
s->release_length - 1)) * (
s->gain_reduction[1] -
s->gain_reduction[0]));
371 buf[
s->env_index +
c] *= env;
375 if (
s->env_index >=
s->limiter_buf_size)
376 s->env_index -=
s->limiter_buf_size;
379 if (smp_cnt >= nb_samples) {
385 if (smp_cnt < nb_samples) {
387 s->limiter_state =
OUT;
393 }
while (smp_cnt < nb_samples);
395 for (n = 0; n < nb_samples; n++) {
398 if (fabs(
out[
c]) > ceiling) {
399 out[
c] = ceiling * (
out[
c] < 0 ? -1 : 1);
404 if (
index >=
s->limiter_buf_size)
405 index -=
s->limiter_buf_size;
419 int i, n,
c, subframe_length, src_index;
420 double gain, gain_next, env_global, env_shortterm,
421 global, shortterm, lra, relative_threshold;
438 src = (
const double *)
in->data[0];
439 dst = (
double *)
out->data[0];
441 limiter_buf =
s->limiter_buf;
446 double offset, offset_tp, true_peak;
452 if (
c == 0 ||
tmp > true_peak)
456 offset = pow(10., (
s->target_i - global) / 20.);
457 offset_tp = true_peak *
offset;
458 s->offset = offset_tp <
s->target_tp ?
offset :
s->target_tp - true_peak;
462 switch (
s->frame_type) {
464 for (n = 0; n <
in->nb_samples; n++) {
466 buf[
s->buf_index +
c] =
src[
c];
469 s->buf_index +=
inlink->channels;
474 if (shortterm < s->measured_thresh) {
475 s->above_threshold = 0;
476 env_shortterm = shortterm <= -70. ? 0. :
s->target_i -
s->measured_i;
478 s->above_threshold = 1;
479 env_shortterm = shortterm <= -70. ? 0. :
s->target_i - shortterm;
482 for (n = 0; n < 30; n++)
483 s->delta[n] = pow(10., env_shortterm / 20.);
484 s->prev_delta =
s->delta[
s->index];
487 s->limiter_buf_index = 0;
489 for (n = 0; n < (
s->limiter_buf_size /
inlink->channels); n++) {
491 limiter_buf[
s->limiter_buf_index +
c] = buf[
s->buf_index +
c] *
s->delta[
s->index] *
s->offset;
493 s->limiter_buf_index +=
inlink->channels;
494 if (
s->limiter_buf_index >=
s->limiter_buf_size)
495 s->limiter_buf_index -=
s->limiter_buf_size;
497 s->buf_index +=
inlink->channels;
508 inlink->partial_buf_size = subframe_length;
517 for (n = 0; n <
in->nb_samples; n++) {
519 buf[
s->prev_buf_index +
c] =
src[
c];
520 limiter_buf[
s->limiter_buf_index +
c] = buf[
s->buf_index +
c] * (gain + (((double) n /
in->nb_samples) * (gain_next - gain))) *
s->offset;
524 s->limiter_buf_index +=
inlink->channels;
525 if (
s->limiter_buf_index >=
s->limiter_buf_size)
526 s->limiter_buf_index -=
s->limiter_buf_size;
528 s->prev_buf_index +=
inlink->channels;
529 if (
s->prev_buf_index >=
s->buf_size)
530 s->prev_buf_index -=
s->buf_size;
532 s->buf_index +=
inlink->channels;
533 if (
s->buf_index >=
s->buf_size)
534 s->buf_index -=
s->buf_size;
538 s->limiter_buf_index =
s->limiter_buf_index + subframe_length < s->limiter_buf_size ?
s->limiter_buf_index + subframe_length :
s->limiter_buf_index + subframe_length -
s->limiter_buf_size;
548 if (
s->above_threshold == 0) {
549 double shortterm_out;
551 if (shortterm >
s->measured_thresh)
552 s->prev_delta *= 1.0058;
555 if (shortterm_out >=
s->target_i)
556 s->above_threshold = 1;
559 if (shortterm < relative_threshold || shortterm <= -70. || s->above_threshold == 0) {
560 s->delta[
s->index] =
s->prev_delta;
562 env_global = fabs(shortterm - global) < (
s->target_lra / 2.) ? shortterm - global : (
s->target_lra / 2.) * ((shortterm - global) < 0 ? -1 : 1);
563 env_shortterm =
s->target_i - shortterm;
564 s->delta[
s->index] = pow(10., (env_global + env_shortterm) / 20.);
567 s->prev_delta =
s->delta[
s->index];
571 s->prev_nb_samples =
in->nb_samples;
572 s->pts +=
in->nb_samples;
577 s->limiter_buf_index = 0;
580 for (n = 0; n <
s->limiter_buf_size /
inlink->channels; n++) {
582 s->limiter_buf[
s->limiter_buf_index +
c] =
src[src_index +
c] * gain *
s->offset;
584 src_index +=
inlink->channels;
586 s->limiter_buf_index +=
inlink->channels;
587 if (
s->limiter_buf_index >=
s->limiter_buf_size)
588 s->limiter_buf_index -=
s->limiter_buf_size;
592 for (
i = 0;
i <
in->nb_samples / subframe_length;
i++) {
595 for (n = 0; n < subframe_length; n++) {
597 if (src_index < (
in->nb_samples *
inlink->channels)) {
598 limiter_buf[
s->limiter_buf_index +
c] =
src[src_index +
c] * gain *
s->offset;
600 limiter_buf[
s->limiter_buf_index +
c] = 0.;
604 if (src_index < (
in->nb_samples *
inlink->channels))
605 src_index +=
inlink->channels;
607 s->limiter_buf_index +=
inlink->channels;
608 if (
s->limiter_buf_index >=
s->limiter_buf_size)
609 s->limiter_buf_index -=
s->limiter_buf_size;
612 dst += (subframe_length *
inlink->channels);
615 dst = (
double *)
out->data[0];
620 for (n = 0; n <
in->nb_samples; n++) {
622 dst[
c] =
src[
c] *
s->offset;
628 dst = (
double *)
out->data[0];
630 s->pts +=
in->nb_samples;
654 nb_samples = (
s->buf_size /
inlink->channels) -
s->prev_nb_samples;
660 frame->nb_samples = nb_samples;
667 s->buf_index =
s->buf_index - offset < 0 ? s->buf_index -
offset +
s->buf_size :
s->buf_index -
offset;
669 for (n = 0; n < nb_samples; n++) {
671 src[
c] = buf[
s->buf_index +
c];
674 s->buf_index +=
inlink->channels;
675 if (
s->buf_index >=
s->buf_size)
676 s->buf_index -=
s->buf_size;
692 static const int input_srate[] = {192000, -1};
741 if (
inlink->channels == 1 &&
s->dual_mono) {
771 s->limiter_buf_index = 0;
772 s->channels =
inlink->channels;
774 s->limiter_state =
OUT;
775 s->offset = pow(10.,
s->offset / 20.);
776 s->target_tp = pow(10.,
s->target_tp / 20.);
790 offset =
s->target_i -
s->measured_i;
791 offset_tp =
s->measured_tp +
offset;
793 if (
s->measured_tp != 99 &&
s->measured_thresh != -70 &&
s->measured_lra != 0 &&
s->measured_i != 0) {
794 if ((offset_tp <= s->target_tp) && (
s->measured_lra <=
s->target_lra)) {
807 double i_in, i_out, lra_in, lra_out, thresh_in, thresh_out, tp_in, tp_out;
810 if (!
s->r128_in || !
s->r128_out)
816 for (
c = 0;
c <
s->channels;
c++) {
819 if ((
c == 0) || (
tmp > tp_in))
826 for (
c = 0;
c <
s->channels;
c++) {
829 if ((
c == 0) || (
tmp > tp_out))
833 switch(
s->print_format) {
840 "\t\"input_i\" : \"%.2f\",\n"
841 "\t\"input_tp\" : \"%.2f\",\n"
842 "\t\"input_lra\" : \"%.2f\",\n"
843 "\t\"input_thresh\" : \"%.2f\",\n"
844 "\t\"output_i\" : \"%.2f\",\n"
845 "\t\"output_tp\" : \"%+.2f\",\n"
846 "\t\"output_lra\" : \"%.2f\",\n"
847 "\t\"output_thresh\" : \"%.2f\",\n"
848 "\t\"normalization_type\" : \"%s\",\n"
849 "\t\"target_offset\" : \"%.2f\"\n"
867 "Input Integrated: %+6.1f LUFS\n"
868 "Input True Peak: %+6.1f dBTP\n"
869 "Input LRA: %6.1f LU\n"
870 "Input Threshold: %+6.1f LUFS\n"
872 "Output Integrated: %+6.1f LUFS\n"
873 "Output True Peak: %+6.1f dBTP\n"
874 "Output LRA: %6.1f LU\n"
875 "Output Threshold: %+6.1f LUFS\n"
877 "Normalization Type: %s\n"
878 "Target Offset: %+6.1f LU\n",
926 .priv_class = &loudnorm_class,
static av_cold int init(AVFilterContext *ctx)
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
A list of supported channel layouts.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static av_cold void uninit(AVFilterContext *ctx)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static enum AVSampleFormat sample_fmts[]
enum MovChannelLayoutTag * layouts
#define AVERROR_EOF
End of file.
static int frame_size(int sample_rate, int frame_len_msec)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
static int linear(InterplayACMContext *s, unsigned ind, unsigned col)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
@ FF_EBUR128_MODE_I
can call ff_ebur128_loudness_global_* and ff_ebur128_relative_threshold
static char * print_format
enum PrintFormat print_format
const char * name
Filter name.
static const AVFilterPad avfilter_af_loudnorm_outputs[]
A link between two filters.
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
int ff_ebur128_loudness_range(FFEBUR128State *st, double *out)
Get loudness range (LRA) of programme in LU.
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
void ff_ebur128_destroy(FFEBUR128State **st)
Destroy library state.
static void true_peak_limiter(LoudNormContext *s, double *out, int nb_samples, int channels)
A filter pad used for either input or output.
@ FF_EBUR128_DUAL_MONO
a channel that is counted twice
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
@ FF_EBUR128_MODE_LRA
can call ff_ebur128_loudness_range
void ff_ebur128_add_frames_double(FFEBUR128State *st, const double *src, size_t frames)
See ebur128_add_frames_short.
static const AVFilterPad outputs[]
enum LimiterState limiter_state
FrameType
G723.1 frame types.
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
int ff_ebur128_sample_peak(FFEBUR128State *st, unsigned int channel_number, double *out)
Get maximum sample peak of selected channel in float format.
static const AVOption loudnorm_options[]
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
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
static int query_formats(AVFilterContext *ctx)
AVFILTER_DEFINE_CLASS(loudnorm)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_ebur128_loudness_shortterm(FFEBUR128State *st, double *out)
Get short-term loudness (last 3s) in LUFS.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static void init_gaussian_filter(LoudNormContext *s)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
AVFilterContext * src
source filter
@ FF_EBUR128_MODE_S
can call ff_ebur128_loudness_shortterm
FFEBUR128State * ff_ebur128_init(unsigned int channels, unsigned long samplerate, unsigned long window, int mode)
Initialize library state.
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 offset
#define AV_LOG_INFO
Standard information.
enum FrameType frame_type
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define i(width, name, range_min, range_max)
int ff_ebur128_set_channel(FFEBUR128State *st, unsigned int channel_number, int value)
Set channel type.
static av_always_inline av_const double round(double x)
libebur128 - a library for loudness measurement according to the EBU R128 standard.
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
Contains information about the state of a loudness measurement.
const char * name
Pad name.
static const AVFilterPad avfilter_af_loudnorm_inputs[]
static int request_frame(AVFilterLink *outlink)
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static int config_input(AVFilterLink *inlink)
int ff_ebur128_relative_threshold(FFEBUR128State *st, double *out)
Get relative threshold in LUFS.
@ FF_EBUR128_MODE_SAMPLE_PEAK
can call ff_ebur128_sample_peak
static void detect_peak(LoudNormContext *s, int offset, int nb_samples, int channels, int *peak_delta, double *peak_value)
static double gaussian_filter(LoudNormContext *s, int index)
FFEBUR128State * r128_out
@ AV_SAMPLE_FMT_DBL
double
int ff_ebur128_loudness_global(FFEBUR128State *st, double *out)
Get global integrated loudness in LUFS.