summaryrefslogtreecommitdiff
path: root/apps/codecs/libtremor
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2010-08-22 19:50:26 +0000
committerNils Wallménius <nils@rockbox.org>2010-08-22 19:50:26 +0000
commitca47ed6cba3fe022a467a9357e674f3860f5e138 (patch)
tree697f4ff2469d79daf5477ade5d63f67876a6eb2d /apps/codecs/libtremor
parent1eb3970d050d8069e0820734d8053988d9706b39 (diff)
libtremor: use render_line from ffmpeg (libavcodec/vorbis.c), speedup ~1% on both arm and coldfire, output unchanged.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27857 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libtremor')
-rw-r--r--apps/codecs/libtremor/floor1.c75
1 files changed, 49 insertions, 26 deletions
diff --git a/apps/codecs/libtremor/floor1.c b/apps/codecs/libtremor/floor1.c
index 138f718651..21bae2820b 100644
--- a/apps/codecs/libtremor/floor1.c
+++ b/apps/codecs/libtremor/floor1.c
@@ -274,32 +274,55 @@ static const ogg_int32_t FLOOR_fromdB_LOOKUP[256] ICONST_ATTR = {
XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
};
-static void render_line(int n, int x0,register int x1,int y0,int y1,ogg_int32_t *d){
- int dy=y1-y0;
- register int x=x0;
- register int y=y0;
- register int adx=x1-x0;
- register int ady=abs(dy);
- register int base=dy/adx;
- register int sy=(dy<0?base-1:base+1);
- int err=0;
-
- if(n>x1)n=x1;
- ady-=abs(base*adx);
-
- if(LIKELY(x<n))
- d[x]= MULT31_SHIFT15(d[x],FLOOR_fromdB_LOOKUP[y]);
-
- while(++x<n){
- err=err+ady;
- if(err>=adx){
- err-=adx;
- y+=sy;
- }else{
- y+=base;
+static inline void render_line_unrolled(int x, int y, int x1,
+ int sy, int ady, int adx,
+ ogg_int32_t *buf)
+{
+ int err = -adx;
+ x -= x1 - 1;
+ buf += x1 - 1;
+ while (++x < 0) {
+ err += ady;
+ if (err >= 0) {
+ err += ady - adx;
+ y += sy;
+ buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
+ x++;
+ }
+ buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
+ }
+ if (x <= 0) {
+ if (err + ady >= 0)
+ y += sy;
+ buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
+ }
+}
+
+static void render_line(int x0, int y0, int x1, int y1, ogg_int32_t *buf)
+{
+ int dy = y1 - y0;
+ int adx = x1 - x0;
+ int ady = abs(dy);
+ int sy = dy < 0 ? -1 : 1;
+ buf[x0] = MULT31_SHIFT15(buf[x0],FLOOR_fromdB_LOOKUP[y0]);
+ if (ady*2 <= adx) { // optimized common case
+ render_line_unrolled(x0, y0, x1, sy, ady, adx, buf);
+ } else {
+ int base = dy / adx;
+ int x = x0;
+ int y = y0;
+ int err = -adx;
+ ady -= abs(base) * adx;
+ while (++x < x1) {
+ y += base;
+ err += ady;
+ if (err >= 0) {
+ err -= adx;
+ y += sy;
+ }
+ buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
+ }
}
- d[x]= MULT31_SHIFT15(d[x],FLOOR_fromdB_LOOKUP[y]);
- }
}
static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in)
@@ -414,7 +437,7 @@ static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
hy*=info->mult;
hx=info->postlist[current];
- render_line(n,lx,hx,ly,hy,out);
+ render_line(lx, ly, hx, hy, out);
lx=hx;
ly=hy;