diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-05-19 18:48:53 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-05-19 19:23:38 +0200 |
commit | 21d8a80e30e9e2050dbc2335670028331d6dff95 (patch) | |
tree | 4529b5c973c3a53a67703096187a95ac1a20c868 /libavfilter/af_aresample.c | |
parent | 087d09b6d52285b88ddb6199d3386496e5403684 (diff) | |
download | ffmpeg-21d8a80e30e9e2050dbc2335670028331d6dff95.tar.gz |
af_aresample: use new swr API to pass and compensate PTS
This code is not only much more powerfull its also simpler
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/af_aresample.c')
-rw-r--r-- | libavfilter/af_aresample.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c index cc479e802a..3b9fe9d617 100644 --- a/libavfilter/af_aresample.c +++ b/libavfilter/af_aresample.c @@ -182,6 +182,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref outsamplesref->audio->sample_rate = outlink->sample_rate; outsamplesref->audio->nb_samples = n_out; +#if 0 if(insamplesref->pts != AV_NOPTS_VALUE) { aresample->next_pts = outsamplesref->pts = av_rescale_q(insamplesref->pts, inlink->time_base, outlink->time_base) @@ -192,7 +193,16 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref } if(aresample->next_pts != AV_NOPTS_VALUE) aresample->next_pts += av_rescale_q(n_out, (AVRational){1 ,outlink->sample_rate}, outlink->time_base); - +#else + if(insamplesref->pts != AV_NOPTS_VALUE) { + 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); + aresample->next_pts = + outsamplesref->pts = (outpts + inlink->sample_rate/2) / inlink->sample_rate; + } else { + outsamplesref->pts = AV_NOPTS_VALUE; + } +#endif ff_filter_samples(outlink, outsamplesref); avfilter_unref_buffer(insamplesref); } @@ -201,6 +211,7 @@ static int request_frame(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; AResampleContext *aresample = ctx->priv; + AVFilterLink *const inlink = outlink->src->inputs[0]; int ret = avfilter_request_frame(ctx->inputs[0]); if (ret == AVERROR_EOF) { @@ -218,9 +229,13 @@ static int request_frame(AVFilterLink *outlink) outsamplesref->audio->sample_rate = outlink->sample_rate; outsamplesref->audio->nb_samples = n_out; +#if 0 outsamplesref->pts = aresample->next_pts; if(aresample->next_pts != AV_NOPTS_VALUE) aresample->next_pts += av_rescale_q(n_out, (AVRational){1 ,outlink->sample_rate}, outlink->time_base); +#else + outsamplesref->pts = (swr_next_pts(aresample->swr, INT64_MIN) + inlink->sample_rate/2) / inlink->sample_rate; +#endif ff_filter_samples(outlink, outsamplesref); return 0; |