[FFmpeg-devel] [PATCH] Rewrite COMMON_CORE resampling loop.
Clément Bœsch
u at pkh.me
Tue May 27 00:18:44 CEST 2014
On Mon, May 26, 2014 at 06:09:56PM -0400, Ronald S. Bultje wrote:
> This moves a condition in the loop outside. In one particular fate
> test (fate-swr-resample-s32p-8000-2626), this makes the code about
> 10% faster. It also simplifies the loop, allowing us to rewrite it
> in yasm at some later point.
> ---
> libswresample/resample_template.c | 30 ++++++++++++++++--------------
> 1 file changed, 16 insertions(+), 14 deletions(-)
>
[...]
Just so that diff can be reviewed more easily, I'm included here version
without the whitespace chunks:
diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c
index becff12..44fb667 100644
--- a/libswresample/resample_template.c
+++ b/libswresample/resample_template.c
@@ -135,16 +135,16 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int
*consumed= index;
index = 0;
}else if(compensation_distance == 0 && !c->linear && index >= 0){
+ int64_t end_index = (1 + src_size - c->filter_length) << c->phase_shift;
+ int64_t delta_frac = (end_index - index) * c->src_incr - c->frac;
+ int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr;
+ int n = FFMIN(dst_size, delta_n);
int sample_index = 0;
- for(dst_index=0; dst_index < dst_size; dst_index++){
+
+ for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter;
- sample_index += index >> c->phase_shift;
- index &= c->phase_mask;
filter= ((FELEM*)c->filter_bank) + c->filter_alloc*index;
- if(sample_index + c->filter_length > src_size){
- break;
- }else{
#ifdef COMMON_CORE
COMMON_CORE
#else
@@ -154,7 +154,6 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int
}
OUT(dst[dst_index], val);
#endif
- }
frac += dst_incr_frac;
index += dst_incr;
@@ -162,7 +161,10 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int
frac -= c->src_incr;
index++;
}
+ sample_index += index >> c->phase_shift;
+ index &= c->phase_mask;
}
*consumed = sample_index;
}else{
int sample_index = 0;
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140527/a0f3ad28/attachment.asc>
More information about the ffmpeg-devel
mailing list