comparison vorbis.c @ 6340:575e0a847f0c libavcodec

30% faster ff_vorbis_floor1_render_list, 3% faster overall
author lorenm
date Sat, 09 Feb 2008 13:53:15 +0000
parents 2b72f9bc4f06
children c93570aeb3eb
comparison
equal deleted inserted replaced
6339:0ea2b97aa9f6 6340:575e0a847f0c
139 } 139 }
140 } 140 }
141 } 141 }
142 } 142 }
143 143
144 static void render_line(int x0, int y0, int x1, int y1, float * buf, int n) { 144 static void render_line(int x0, int y0, int x1, int y1, float * buf) {
145 int dy = y1 - y0; 145 int dy = y1 - y0;
146 int adx = x1 - x0; 146 int adx = x1 - x0;
147 int ady = FFABS(dy);
148 int base = dy / adx; 147 int base = dy / adx;
148 int ady = FFABS(dy) - FFABS(base) * adx;
149 int x = x0; 149 int x = x0;
150 int y = y0; 150 int y = y0;
151 int err = 0; 151 int err = 0;
152 int sy; 152 int sy = dy<0 ? -1 : 1;
153 if (dy < 0) sy = base - 1;
154 else sy = base + 1;
155 ady = ady - FFABS(base) * adx;
156 if (x >= n) return;
157 buf[x] = ff_vorbis_floor1_inverse_db_table[y]; 153 buf[x] = ff_vorbis_floor1_inverse_db_table[y];
158 for (x = x0 + 1; x < x1; x++) { 154 while (++x < x1) {
159 if (x >= n) return;
160 err += ady; 155 err += ady;
161 if (err >= adx) { 156 if (err >= adx) {
162 err -= adx; 157 err -= adx;
163 y += sy; 158 y += sy;
164 } else {
165 y += base;
166 } 159 }
160 y += base;
167 buf[x] = ff_vorbis_floor1_inverse_db_table[y]; 161 buf[x] = ff_vorbis_floor1_inverse_db_table[y];
168 } 162 }
169 } 163 }
170 164
171 void ff_vorbis_floor1_render_list(floor1_entry_t * list, int values, uint_fast16_t * y_list, int * flag, int multiplier, float * out, int samples) { 165 void ff_vorbis_floor1_render_list(floor1_entry_t * list, int values, uint_fast16_t * y_list, int * flag, int multiplier, float * out, int samples) {
173 lx = 0; 167 lx = 0;
174 ly = y_list[0] * multiplier; 168 ly = y_list[0] * multiplier;
175 for (i = 1; i < values; i++) { 169 for (i = 1; i < values; i++) {
176 int pos = list[i].sort; 170 int pos = list[i].sort;
177 if (flag[pos]) { 171 if (flag[pos]) {
178 render_line(lx, ly, list[pos].x, y_list[pos] * multiplier, out, samples); 172 int x1 = list[pos].x;
179 lx = list[pos].x; 173 int y1 = y_list[pos] * multiplier;
180 ly = y_list[pos] * multiplier; 174 if (lx < samples)
175 render_line(lx, ly, FFMIN(x1,samples), y1, out);
176 lx = x1;
177 ly = y1;
181 } 178 }
182 if (lx >= samples) break; 179 if (lx >= samples) break;
183 } 180 }
184 if (lx < samples) render_line(lx, ly, samples, ly, out, samples); 181 if (lx < samples) render_line(lx, ly, samples, ly, out);
185 } 182 }