summaryrefslogtreecommitdiff
path: root/apps/codecs/libtremor/floor1.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libtremor/floor1.c')
-rw-r--r--apps/codecs/libtremor/floor1.c52
1 files changed, 1 insertions, 51 deletions
diff --git a/apps/codecs/libtremor/floor1.c b/apps/codecs/libtremor/floor1.c
index 1ea7ee99b5..0d3828c816 100644
--- a/apps/codecs/libtremor/floor1.c
+++ b/apps/codecs/libtremor/floor1.c
@@ -274,57 +274,7 @@ static const ogg_int32_t FLOOR_fromdB_LOOKUP[256] ICONST_ATTR = {
274 XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff), 274 XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
275}; 275};
276 276
277/* render_line and friend taken from ffmpeg (libavcodec/vorbis.c) */ 277#include "ffmpeg_render_line.h"
278static inline void render_line_unrolled(int x, int y, int x1,
279 int sy, int ady, int adx,
280 ogg_int32_t *buf)
281{
282 int err = -adx;
283 x -= x1 - 1;
284 buf += x1 - 1;
285 while (++x < 0) {
286 err += ady;
287 if (err >= 0) {
288 err += ady - adx;
289 y += sy;
290 buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
291 x++;
292 }
293 buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
294 }
295 if (x <= 0) {
296 if (err + ady >= 0)
297 y += sy;
298 buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
299 }
300}
301
302static void render_line(int x0, int y0, int x1, int y1, ogg_int32_t *buf)
303{
304 int dy = y1 - y0;
305 int adx = x1 - x0;
306 int ady = abs(dy);
307 int sy = dy < 0 ? -1 : 1;
308 buf[x0] = MULT31_SHIFT15(buf[x0],FLOOR_fromdB_LOOKUP[y0]);
309 if (ady*2 <= adx) { // optimized common case
310 render_line_unrolled(x0, y0, x1, sy, ady, adx, buf);
311 } else {
312 int base = dy / adx;
313 int x = x0;
314 int y = y0;
315 int err = -adx;
316 ady -= abs(base) * adx;
317 while (++x < x1) {
318 y += base;
319 err += ady;
320 if (err >= 0) {
321 err -= adx;
322 y += sy;
323 }
324 buf[x] = MULT31_SHIFT15(buf[x],FLOOR_fromdB_LOOKUP[y]);
325 }
326 }
327}
328 278
329static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in) 279static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in)
330 ICODE_ATTR_TREMOR_NOT_MDCT; 280 ICODE_ATTR_TREMOR_NOT_MDCT;