|
|
|
@ -29,17 +29,20 @@ |
|
|
|
|
#include "libavutil/rational.h" |
|
|
|
|
#include "avfilter.h" |
|
|
|
|
#include "internal.h" |
|
|
|
|
#include "audio.h" |
|
|
|
|
#include "video.h" |
|
|
|
|
|
|
|
|
|
static const char *const var_names[] = { |
|
|
|
|
"AVTB", /* default timebase 1/AV_TIME_BASE */ |
|
|
|
|
"intb", /* input timebase */ |
|
|
|
|
"sr", /* sample rate */ |
|
|
|
|
NULL |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
enum var_name { |
|
|
|
|
VAR_AVTB, |
|
|
|
|
VAR_INTB, |
|
|
|
|
VAR_SR, |
|
|
|
|
VAR_VARS_NB |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -70,6 +73,7 @@ static int config_output_props(AVFilterLink *outlink) |
|
|
|
|
|
|
|
|
|
settb->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q); |
|
|
|
|
settb->var_values[VAR_INTB] = av_q2d(inlink->time_base); |
|
|
|
|
settb->var_values[VAR_SR] = inlink->sample_rate; |
|
|
|
|
|
|
|
|
|
outlink->w = inlink->w; |
|
|
|
|
outlink->h = inlink->h; |
|
|
|
@ -113,9 +117,28 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
|
|
|
|
ff_start_frame(outlink, picref2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) |
|
|
|
|
{ |
|
|
|
|
AVFilterContext *ctx = inlink->dst; |
|
|
|
|
AVFilterLink *outlink = ctx->outputs[0]; |
|
|
|
|
AVFilterBufferRef *outsamples = insamples; |
|
|
|
|
|
|
|
|
|
if (av_cmp_q(inlink->time_base, outlink->time_base)) { |
|
|
|
|
outsamples = avfilter_ref_buffer(insamples, ~0); |
|
|
|
|
outsamples->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base); |
|
|
|
|
av_log(ctx, AV_LOG_DEBUG, "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n", |
|
|
|
|
inlink ->time_base.num, inlink ->time_base.den, insamples ->pts, |
|
|
|
|
outlink->time_base.num, outlink->time_base.den, outsamples->pts); |
|
|
|
|
avfilter_unref_buffer(insamples); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ff_filter_samples(outlink, outsamples); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if CONFIG_SETTB_FILTER |
|
|
|
|
AVFilter avfilter_vf_settb = { |
|
|
|
|
.name = "settb", |
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Set timebase for the output link."), |
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Set timebase for the video output link."), |
|
|
|
|
.init = init, |
|
|
|
|
|
|
|
|
|
.priv_size = sizeof(SetTBContext), |
|
|
|
@ -132,3 +155,28 @@ AVFilter avfilter_vf_settb = { |
|
|
|
|
.config_props = config_output_props, }, |
|
|
|
|
{ .name = NULL}}, |
|
|
|
|
}; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if CONFIG_ASETTB_FILTER |
|
|
|
|
AVFilter avfilter_af_asettb = { |
|
|
|
|
.name = "asettb", |
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Set timebase for the audio output link."), |
|
|
|
|
.init = init, |
|
|
|
|
|
|
|
|
|
.priv_size = sizeof(SetTBContext), |
|
|
|
|
|
|
|
|
|
.inputs = (const AVFilterPad[]) { |
|
|
|
|
{ .name = "default", |
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO, |
|
|
|
|
.get_audio_buffer = ff_null_get_audio_buffer, |
|
|
|
|
.filter_samples = filter_samples, }, |
|
|
|
|
{ .name = NULL } |
|
|
|
|
}, |
|
|
|
|
.outputs = (const AVFilterPad[]) { |
|
|
|
|
{ .name = "default", |
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO, |
|
|
|
|
.config_props = config_output_props, }, |
|
|
|
|
{ .name = NULL} |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
#endif |
|
|
|
|