summaryrefslogtreecommitdiff
path: root/apps/codecs/libtremor/ffmpeg_render_line.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libtremor/ffmpeg_render_line.h')
-rw-r--r--apps/codecs/libtremor/ffmpeg_render_line.h71
1 files changed, 69 insertions, 2 deletions
diff --git a/apps/codecs/libtremor/ffmpeg_render_line.h b/apps/codecs/libtremor/ffmpeg_render_line.h
index 1b760ae20e..a08952d95d 100644
--- a/apps/codecs/libtremor/ffmpeg_render_line.h
+++ b/apps/codecs/libtremor/ffmpeg_render_line.h
@@ -21,6 +21,9 @@
21 */ 21 */
22 22
23/* render_line and friend taken from ffmpeg (libavcodec/vorbis.c) */ 23/* render_line and friend taken from ffmpeg (libavcodec/vorbis.c) */
24
25#include "misc.h"
26
24static inline void render_line_unrolled(int x, int y, int x1, 27static inline void render_line_unrolled(int x, int y, int x1,
25 int sy, int ady, int adx, 28 int sy, int ady, int adx,
26 const ogg_int32_t *lookup, ogg_int32_t *buf) 29 const ogg_int32_t *lookup, ogg_int32_t *buf)
@@ -45,8 +48,8 @@ static inline void render_line_unrolled(int x, int y, int x1,
45 } 48 }
46} 49}
47 50
48static void render_line(int x0, int y0, int x1, int y1, 51static inline void render_line(int x0, int y0, int x1, int y1,
49 const ogg_int32_t *lookup, ogg_int32_t *buf) 52 const ogg_int32_t *lookup, ogg_int32_t *buf)
50{ 53{
51 int dy = y1 - y0; 54 int dy = y1 - y0;
52 int adx = x1 - x0; 55 int adx = x1 - x0;
@@ -72,3 +75,67 @@ static void render_line(int x0, int y0, int x1, int y1,
72 } 75 }
73 } 76 }
74} 77}
78
79#ifndef INCL_OPTIMIZED_VECTOR_FMUL_WINDOW
80#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW
81static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0,
82 const ogg_int32_t *src1, const ogg_int32_t *win, int len){
83 int i,j;
84 dst += len;
85 win += len;
86 src0+= len;
87 for(i=-len, j=len-1; i<0; i++, j--) {
88 ogg_int32_t s0 = src0[i];
89 ogg_int32_t s1 = src1[j];
90 ogg_int32_t wi = win[i];
91 ogg_int32_t wj = win[j];
92 XNPROD31(s0, s1, wj, wi, &dst[i], &dst[j]);
93 /*
94 dst[i] = MULT31(s0,wj) - MULT31(s1,wi);
95 dst[j] = MULT31(s0,wi) + MULT31(s1,wj);
96 */
97 }
98}
99#endif
100
101static inline void copy_normalize(ogg_int32_t *dst, ogg_int32_t *src, int len)
102{
103 memcpy(dst, src, len * sizeof(ogg_int32_t));
104}
105
106static inline void window_overlap_add(unsigned int blocksize, unsigned int lastblock,
107 unsigned int bs0, unsigned int bs1, int ch,
108 const ogg_int32_t *win, vorbis_dsp_state *v)
109{
110 unsigned retlen = (blocksize + lastblock) / 4;
111 int j;
112 for (j = 0; j < ch; j++) {
113 ogg_int32_t *residue = v->residues[v->ri] + j * blocksize / 2;
114 ogg_int32_t *saved;
115 saved = v->saved_ptr[j];
116 ogg_int32_t *ret = v->floors + j * retlen;
117 ogg_int32_t *buf = residue;
118
119 if (v->W == v->lW) {
120 ff_vector_fmul_window_c(ret, saved, buf, win, blocksize / 4);
121 } else if (v->W > v->lW) {
122 ff_vector_fmul_window_c(ret, saved, buf, win, bs0 / 4);
123 copy_normalize(ret+bs0/2, buf+bs0/4, (bs1-bs0)/4);
124 } else {
125 copy_normalize(ret, saved, (bs1 - bs0) / 4);
126 ff_vector_fmul_window_c(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
127 }
128 if (v->residues[1] == NULL) {
129 memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(ogg_int32_t));
130 v->saved_ptr[j] = v->saved + j * bs1 / 4;
131 } else {
132 v->saved_ptr[j] = buf + blocksize / 4;
133 }
134
135 v->pcmb[j] = ret;
136 }
137
138 if (v->residues[1] != NULL) {
139 v->ri ^= 1;
140 }
141}