|
|
@ -682,6 +682,7 @@ static int request_frame(AVFilterLink *outlink) |
|
|
|
|
|
|
|
|
|
|
|
static int query_formats(AVFilterContext *ctx) |
|
|
|
static int query_formats(AVFilterContext *ctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
LoudNormContext *s = ctx->priv; |
|
|
|
AVFilterFormats *formats; |
|
|
|
AVFilterFormats *formats; |
|
|
|
AVFilterChannelLayouts *layouts; |
|
|
|
AVFilterChannelLayouts *layouts; |
|
|
|
AVFilterLink *inlink = ctx->inputs[0]; |
|
|
|
AVFilterLink *inlink = ctx->inputs[0]; |
|
|
@ -707,15 +708,17 @@ static int query_formats(AVFilterContext *ctx) |
|
|
|
if (ret < 0) |
|
|
|
if (ret < 0) |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
|
|
formats = ff_make_format_list(input_srate); |
|
|
|
if (s->frame_type != LINEAR_MODE) { |
|
|
|
if (!formats) |
|
|
|
formats = ff_make_format_list(input_srate); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
if (!formats) |
|
|
|
ret = ff_formats_ref(formats, &inlink->out_samplerates); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
if (ret < 0) |
|
|
|
ret = ff_formats_ref(formats, &inlink->out_samplerates); |
|
|
|
return ret; |
|
|
|
if (ret < 0) |
|
|
|
ret = ff_formats_ref(formats, &outlink->in_samplerates); |
|
|
|
return ret; |
|
|
|
if (ret < 0) |
|
|
|
ret = ff_formats_ref(formats, &outlink->in_samplerates); |
|
|
|
return ret; |
|
|
|
if (ret < 0) |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -754,21 +757,6 @@ static int config_input(AVFilterLink *inlink) |
|
|
|
|
|
|
|
|
|
|
|
init_gaussian_filter(s); |
|
|
|
init_gaussian_filter(s); |
|
|
|
|
|
|
|
|
|
|
|
s->frame_type = FIRST_FRAME; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s->linear) { |
|
|
|
|
|
|
|
double offset, offset_tp; |
|
|
|
|
|
|
|
offset = s->target_i - s->measured_i; |
|
|
|
|
|
|
|
offset_tp = s->measured_tp + offset; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s->measured_tp != 99 && s->measured_thresh != -70 && s->measured_lra != 0 && s->measured_i != 0) { |
|
|
|
|
|
|
|
if ((offset_tp <= s->target_tp) && (s->measured_lra <= s->target_lra)) { |
|
|
|
|
|
|
|
s->frame_type = LINEAR_MODE; |
|
|
|
|
|
|
|
s->offset = offset; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s->frame_type != LINEAR_MODE) { |
|
|
|
if (s->frame_type != LINEAR_MODE) { |
|
|
|
inlink->min_samples = |
|
|
|
inlink->min_samples = |
|
|
|
inlink->max_samples = |
|
|
|
inlink->max_samples = |
|
|
@ -790,6 +778,27 @@ static int config_input(AVFilterLink *inlink) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static av_cold int init(AVFilterContext *ctx) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LoudNormContext *s = ctx->priv; |
|
|
|
|
|
|
|
s->frame_type = FIRST_FRAME; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s->linear) { |
|
|
|
|
|
|
|
double offset, offset_tp; |
|
|
|
|
|
|
|
offset = s->target_i - s->measured_i; |
|
|
|
|
|
|
|
offset_tp = s->measured_tp + offset; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s->measured_tp != 99 && s->measured_thresh != -70 && s->measured_lra != 0 && s->measured_i != 0) { |
|
|
|
|
|
|
|
if ((offset_tp <= s->target_tp) && (s->measured_lra <= s->target_lra)) { |
|
|
|
|
|
|
|
s->frame_type = LINEAR_MODE; |
|
|
|
|
|
|
|
s->offset = offset; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static av_cold void uninit(AVFilterContext *ctx) |
|
|
|
static av_cold void uninit(AVFilterContext *ctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LoudNormContext *s = ctx->priv; |
|
|
|
LoudNormContext *s = ctx->priv; |
|
|
@ -914,6 +923,7 @@ AVFilter ff_af_loudnorm = { |
|
|
|
.priv_size = sizeof(LoudNormContext), |
|
|
|
.priv_size = sizeof(LoudNormContext), |
|
|
|
.priv_class = &loudnorm_class, |
|
|
|
.priv_class = &loudnorm_class, |
|
|
|
.query_formats = query_formats, |
|
|
|
.query_formats = query_formats, |
|
|
|
|
|
|
|
.init = init, |
|
|
|
.uninit = uninit, |
|
|
|
.uninit = uninit, |
|
|
|
.inputs = avfilter_af_loudnorm_inputs, |
|
|
|
.inputs = avfilter_af_loudnorm_inputs, |
|
|
|
.outputs = avfilter_af_loudnorm_outputs, |
|
|
|
.outputs = avfilter_af_loudnorm_outputs, |
|
|
|