af_aresample: fix rounding of negative timestamps

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-11-26 16:25:47 +01:00
parent 386fc67c79
commit 4b5a12a2cb

View File

@ -191,11 +191,10 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den); int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
int64_t outpts= swr_next_pts(aresample->swr, inpts); int64_t outpts= swr_next_pts(aresample->swr, inpts);
aresample->next_pts = aresample->next_pts =
outsamplesref->pts = (outpts + inlink->sample_rate/2) / inlink->sample_rate; outsamplesref->pts = ROUNDED_DIV(outpts, inlink->sample_rate);
} else { } else {
outsamplesref->pts = AV_NOPTS_VALUE; outsamplesref->pts = AV_NOPTS_VALUE;
} }
n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out, n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
(void *)insamplesref->extended_data, n_in); (void *)insamplesref->extended_data, n_in);
if (n_out <= 0) { if (n_out <= 0) {