aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vorbis.c
diff options
context:
space:
mode:
authorLoren Merritt <lorenm@u.washington.edu>2008-02-09 13:53:15 +0000
committerLoren Merritt <lorenm@u.washington.edu>2008-02-09 13:53:15 +0000
commite1813a2f1e6db6635b4baa25211103389cbc7785 (patch)
treef69ab40d223af1cec864190f4b996a6d7d299275 /libavcodec/vorbis.c
parent2c70770e331b7e397c1a2a038b0f95043ed48676 (diff)
downloadffmpeg-e1813a2f1e6db6635b4baa25211103389cbc7785.tar.gz
30% faster ff_vorbis_floor1_render_list, 3% faster overall
Originally committed as revision 11883 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/vorbis.c')
-rw-r--r--libavcodec/vorbis.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index 0be5976a67..76d6308b5c 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -141,29 +141,23 @@ void ff_vorbis_ready_floor1_list(floor1_entry_t * list, int values) {
}
}
-static void render_line(int x0, int y0, int x1, int y1, float * buf, int n) {
+static void render_line(int x0, int y0, int x1, int y1, float * buf) {
int dy = y1 - y0;
int adx = x1 - x0;
- int ady = FFABS(dy);
int base = dy / adx;
+ int ady = FFABS(dy) - FFABS(base) * adx;
int x = x0;
int y = y0;
int err = 0;
- int sy;
- if (dy < 0) sy = base - 1;
- else sy = base + 1;
- ady = ady - FFABS(base) * adx;
- if (x >= n) return;
+ int sy = dy<0 ? -1 : 1;
buf[x] = ff_vorbis_floor1_inverse_db_table[y];
- for (x = x0 + 1; x < x1; x++) {
- if (x >= n) return;
+ while (++x < x1) {
err += ady;
if (err >= adx) {
err -= adx;
y += sy;
- } else {
- y += base;
}
+ y += base;
buf[x] = ff_vorbis_floor1_inverse_db_table[y];
}
}
@@ -175,11 +169,14 @@ void ff_vorbis_floor1_render_list(floor1_entry_t * list, int values, uint_fast16
for (i = 1; i < values; i++) {
int pos = list[i].sort;
if (flag[pos]) {
- render_line(lx, ly, list[pos].x, y_list[pos] * multiplier, out, samples);
- lx = list[pos].x;
- ly = y_list[pos] * multiplier;
+ int x1 = list[pos].x;
+ int y1 = y_list[pos] * multiplier;
+ if (lx < samples)
+ render_line(lx, ly, FFMIN(x1,samples), y1, out);
+ lx = x1;
+ ly = y1;
}
if (lx >= samples) break;
}
- if (lx < samples) render_line(lx, ly, samples, ly, out, samples);
+ if (lx < samples) render_line(lx, ly, samples, ly, out);
}