Mercurial > libavcodec.hg
comparison jfdctint.c @ 1589:eb26d190cf5a libavcodec
move identical code into its own function
intXY_t -> int_fastXY_t
author | michael |
---|---|
date | Thu, 30 Oct 2003 22:51:02 +0000 |
parents | e08df4d22d27 |
children | ef2149182f1c |
comparison
equal
deleted
inserted
replaced
1588:de5e2acd0f80 | 1589:eb26d190cf5a |
---|---|
146 #else | 146 #else |
147 #define MULTIPLY(var,const) ((var) * (const)) | 147 #define MULTIPLY(var,const) ((var) * (const)) |
148 #endif | 148 #endif |
149 | 149 |
150 | 150 |
151 /* | 151 static always_inline void row_fdct(DCTELEM * data){ |
152 * Perform the forward DCT on one block of samples. | 152 int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; |
153 */ | 153 int_fast32_t tmp10, tmp11, tmp12, tmp13; |
154 | 154 int_fast32_t z1, z2, z3, z4, z5; |
155 GLOBAL(void) | |
156 ff_jpeg_fdct_islow (DCTELEM * data) | |
157 { | |
158 int32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | |
159 int32_t tmp10, tmp11, tmp12, tmp13; | |
160 int32_t z1, z2, z3, z4, z5; | |
161 DCTELEM *dataptr; | 155 DCTELEM *dataptr; |
162 int ctr; | 156 int ctr; |
163 SHIFT_TEMPS | 157 SHIFT_TEMPS |
164 | 158 |
165 /* Pass 1: process rows. */ | 159 /* Pass 1: process rows. */ |
223 dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); | 217 dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); |
224 dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); | 218 dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); |
225 | 219 |
226 dataptr += DCTSIZE; /* advance pointer to next row */ | 220 dataptr += DCTSIZE; /* advance pointer to next row */ |
227 } | 221 } |
222 } | |
223 | |
224 /* | |
225 * Perform the forward DCT on one block of samples. | |
226 */ | |
227 | |
228 GLOBAL(void) | |
229 ff_jpeg_fdct_islow (DCTELEM * data) | |
230 { | |
231 int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | |
232 int_fast32_t tmp10, tmp11, tmp12, tmp13; | |
233 int_fast32_t z1, z2, z3, z4, z5; | |
234 DCTELEM *dataptr; | |
235 int ctr; | |
236 SHIFT_TEMPS | |
237 | |
238 row_fdct(data); | |
228 | 239 |
229 /* Pass 2: process columns. | 240 /* Pass 2: process columns. |
230 * We remove the PASS1_BITS scaling, but leave the results scaled up | 241 * We remove the PASS1_BITS scaling, but leave the results scaled up |
231 * by an overall factor of 8. | 242 * by an overall factor of 8. |
232 */ | 243 */ |
302 * you do even part two times. | 313 * you do even part two times. |
303 */ | 314 */ |
304 GLOBAL(void) | 315 GLOBAL(void) |
305 ff_fdct248_islow (DCTELEM * data) | 316 ff_fdct248_islow (DCTELEM * data) |
306 { | 317 { |
307 int32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | 318 int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; |
308 int32_t tmp10, tmp11, tmp12, tmp13; | 319 int_fast32_t tmp10, tmp11, tmp12, tmp13; |
309 int32_t z1, z2, z3, z4, z5; | 320 int_fast32_t z1; |
310 DCTELEM *dataptr; | 321 DCTELEM *dataptr; |
311 int ctr; | 322 int ctr; |
312 SHIFT_TEMPS | 323 SHIFT_TEMPS |
313 | 324 |
314 /* Pass 1: process rows. */ | 325 row_fdct(data); |
315 /* Note results are scaled up by sqrt(8) compared to a true DCT; */ | |
316 /* furthermore, we scale the results by 2**PASS1_BITS. */ | |
317 | |
318 dataptr = data; | |
319 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { | |
320 tmp0 = dataptr[0] + dataptr[7]; | |
321 tmp7 = dataptr[0] - dataptr[7]; | |
322 tmp1 = dataptr[1] + dataptr[6]; | |
323 tmp6 = dataptr[1] - dataptr[6]; | |
324 tmp2 = dataptr[2] + dataptr[5]; | |
325 tmp5 = dataptr[2] - dataptr[5]; | |
326 tmp3 = dataptr[3] + dataptr[4]; | |
327 tmp4 = dataptr[3] - dataptr[4]; | |
328 | |
329 /* Even part per LL&M figure 1 --- note that published figure is faulty; | |
330 * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". | |
331 */ | |
332 | |
333 tmp10 = tmp0 + tmp3; | |
334 tmp13 = tmp0 - tmp3; | |
335 tmp11 = tmp1 + tmp2; | |
336 tmp12 = tmp1 - tmp2; | |
337 | |
338 dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); | |
339 dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); | |
340 | |
341 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); | |
342 dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), | |
343 CONST_BITS-PASS1_BITS); | |
344 dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), | |
345 CONST_BITS-PASS1_BITS); | |
346 | |
347 /* Odd part per figure 8 --- note paper omits factor of sqrt(2). | |
348 * cK represents cos(K*pi/16). | |
349 * i0..i3 in the paper are tmp4..tmp7 here. | |
350 */ | |
351 | |
352 z1 = tmp4 + tmp7; | |
353 z2 = tmp5 + tmp6; | |
354 z3 = tmp4 + tmp6; | |
355 z4 = tmp5 + tmp7; | |
356 z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ | |
357 | |
358 tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ | |
359 tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ | |
360 tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ | |
361 tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ | |
362 z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ | |
363 z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ | |
364 z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ | |
365 z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ | |
366 | |
367 z3 += z5; | |
368 z4 += z5; | |
369 | |
370 dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); | |
371 dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); | |
372 dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); | |
373 dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); | |
374 | |
375 dataptr += DCTSIZE; /* advance pointer to next row */ | |
376 } | |
377 | 326 |
378 /* Pass 2: process columns. | 327 /* Pass 2: process columns. |
379 * We remove the PASS1_BITS scaling, but leave the results scaled up | 328 * We remove the PASS1_BITS scaling, but leave the results scaled up |
380 * by an overall factor of 8. | 329 * by an overall factor of 8. |
381 */ | 330 */ |