af_aresample: fix properties setting in the output buffer

In particular: set output timebase to 1/output_sample_rate, fix output
PTS computation, and do not forget to copy properties values from the
input buffer.
This commit is contained in:
Stefano Sabatini 2011-09-17 01:30:15 +02:00
parent cc6b8c4b61
commit 22137bb5c2

View File

@ -83,6 +83,7 @@ static int config_output(AVFilterLink *outlink)
aresample->out_rate = outlink->sample_rate;
else
outlink->sample_rate = aresample->out_rate;
outlink->time_base = (AVRational) {1, aresample->out_rate};
//TODO: make the resampling parameters configurable
aresample->resample = av_resample_init(aresample->out_rate, inlink->sample_rate,
@ -270,13 +271,14 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
aresample->outsamplesref =
avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, requested_out_nb_samples);
avfilter_copy_buffer_ref_props(aresample->outsamplesref, insamplesref);
aresample->outsamplesref->pts =
insamplesref->pts / inlink->sample_rate * outlink->sample_rate;
aresample->outsamplesref->audio->sample_rate = outlink->sample_rate;
outlink->out_buf = aresample->outsamplesref;
}
avfilter_copy_buffer_ref_props(aresample->outsamplesref, insamplesref);
aresample->outsamplesref->audio->sample_rate = outlink->sample_rate;
aresample->outsamplesref->pts =
av_rescale(outlink->sample_rate, insamplesref->pts, inlink->sample_rate);
/* av_resample() works with planar audio buffers */
if (!inlink->planar && nb_channels > 1) {
int16_t *out[8];