Mercurial > libavcodec.hg
comparison vp3dsp.c @ 1977:89422281f6f6 libavcodec
reorganize and simplify the VP3 IDCT stuff
author | melanson |
---|---|
date | Mon, 26 Apr 2004 00:20:29 +0000 |
parents | 1755f959ab7f |
children | f65d87bfdd5a |
comparison
equal
deleted
inserted
replaced
1976:5dfde318d44a | 1977:89422281f6f6 |
---|---|
38 void vp3_dsp_init_c(void) | 38 void vp3_dsp_init_c(void) |
39 { | 39 { |
40 /* nop */ | 40 /* nop */ |
41 } | 41 } |
42 | 42 |
43 static void vp3_idct_c(int32_t *dequantized_data, int16_t *output_data) | 43 void vp3_idct_c(int16_t *input_data, int16_t *dequant_matrix, |
44 int coeff_count, int16_t *output_data) | |
44 { | 45 { |
46 int32_t dequantized_data[64]; | |
45 int32_t *ip = dequantized_data; | 47 int32_t *ip = dequantized_data; |
46 int16_t *op = output_data; | 48 int16_t *op = output_data; |
47 | 49 |
48 int32_t A_, B_, C_, D_, _Ad, _Bd, _Cd, _Dd, E_, F_, G_, H_; | 50 int32_t A_, B_, C_, D_, _Ad, _Bd, _Cd, _Dd, E_, F_, G_, H_; |
49 int32_t _Ed, _Gd, _Add, _Bdd, _Fd, _Hd; | 51 int32_t _Ed, _Gd, _Add, _Bdd, _Fd, _Hd; |
50 int32_t t1, t2; | 52 int32_t t1, t2; |
51 | 53 |
52 int i; | 54 int i, j; |
55 | |
56 /* de-zigzag and dequantize */ | |
57 for (i = 0; i < coeff_count; i++) { | |
58 j = dezigzag_index[i]; | |
59 dequantized_data[j] = dequant_matrix[i] * input_data[i]; | |
60 } | |
53 | 61 |
54 /* Inverse DCT on the rows now */ | 62 /* Inverse DCT on the rows now */ |
55 for (i = 0; i < 8; i++) { | 63 for (i = 0; i < 8; i++) { |
56 /* Check for non-zero values */ | 64 /* Check for non-zero values */ |
57 if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) { | 65 if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) { |
246 | 254 |
247 ip++; /* next column */ | 255 ip++; /* next column */ |
248 op++; | 256 op++; |
249 } | 257 } |
250 } | 258 } |
251 | |
252 void vp3_idct_put_c(int16_t *input_data, int16_t *dequant_matrix, | |
253 int coeff_count, uint8_t *dest, int stride) | |
254 { | |
255 int32_t dequantized_data[64]; | |
256 int16_t transformed_data[64]; | |
257 int16_t *op; | |
258 int i, j; | |
259 | |
260 /* de-zigzag and dequantize */ | |
261 for (i = 0; i < coeff_count; i++) { | |
262 j = dezigzag_index[i]; | |
263 dequantized_data[j] = dequant_matrix[i] * input_data[i]; | |
264 } | |
265 | |
266 vp3_idct_c(dequantized_data, transformed_data); | |
267 | |
268 /* place in final output */ | |
269 op = transformed_data; | |
270 for (i = 0; i < 8; i++) { | |
271 for (j = 0; j < 8; j++) { | |
272 if (*op < -128) | |
273 *dest = 0; | |
274 else if (*op > 127) | |
275 *dest = 255; | |
276 else | |
277 *dest = (uint8_t)(*op + 128); | |
278 op++; | |
279 dest++; | |
280 } | |
281 dest += (stride - 8); | |
282 } | |
283 } | |
284 | |
285 void vp3_idct_add_c(int16_t *input_data, int16_t *dequant_matrix, | |
286 int coeff_count, uint8_t *dest, int stride) | |
287 { | |
288 int32_t dequantized_data[64]; | |
289 int16_t transformed_data[64]; | |
290 int16_t *op; | |
291 int i, j; | |
292 int16_t sample; | |
293 | |
294 /* de-zigzag and dequantize */ | |
295 for (i = 0; i < coeff_count; i++) { | |
296 j = dezigzag_index[i]; | |
297 dequantized_data[j] = dequant_matrix[i] * input_data[i]; | |
298 } | |
299 | |
300 vp3_idct_c(dequantized_data, transformed_data); | |
301 | |
302 /* place in final output */ | |
303 op = transformed_data; | |
304 for (i = 0; i < 8; i++) { | |
305 for (j = 0; j < 8; j++) { | |
306 sample = *dest + *op; | |
307 if (sample < 0) | |
308 *dest = 0; | |
309 else if (sample > 255) | |
310 *dest = 255; | |
311 else | |
312 *dest = (uint8_t)(sample & 0xFF); | |
313 op++; | |
314 dest++; | |
315 } | |
316 dest += (stride - 8); | |
317 } | |
318 } |