Mercurial > mplayer.hg
annotate libmpcodecs/native/RTjpegN.c @ 22768:7989c3586b9e
add mf://bmp wish, remove deinterlace filter during playback
author | compn |
---|---|
date | Fri, 23 Mar 2007 01:48:54 +0000 |
parents | cea0eb833758 |
children | b21e1506e50b |
rev | line source |
---|---|
3802 | 1 /* |
2 RTjpeg (C) Justin Schoeman 1998 (justin@suntiger.ee.up.ac.za) | |
3 | |
4 With modifications by: | |
5 (c) 1998, 1999 by Joerg Walter <trouble@moes.pmnet.uni-oldenburg.de> | |
6 and | |
7 (c) 1999 by Wim Taymans <wim.taymans@tvd.be> | |
8 | |
9 This program is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2 of the License, or | |
12 (at your option) any later version. | |
13 | |
14 This program is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with this program; if not, write to the Free Software | |
21977
cea0eb833758
Fix FSF address and otherwise broken license headers.
diego
parents:
21507
diff
changeset
|
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3802 | 22 */ |
23 | |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 #include <string.h> | |
3805 | 27 |
28 #include "config.h" | |
29 #ifdef HAVE_MMX | |
30 #define MMX | |
31 #endif | |
32 | |
21372 | 33 #include "libavutil/common.h" |
21507
fa99b3d31d13
Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents:
21372
diff
changeset
|
34 #include "mpbswap.h" |
3802 | 35 #include "RTjpegN.h" |
36 | |
37 #ifdef MMX | |
38 #include "mmx.h" | |
39 #endif | |
40 | |
41 //#define SHOWBLOCK 1 | |
42 #define BETTERCOMPRESSION 1 | |
43 | |
44 static const unsigned char RTjpeg_ZZ[64]={ | |
45 0, | |
46 8, 1, | |
47 2, 9, 16, | |
48 24, 17, 10, 3, | |
49 4, 11, 18, 25, 32, | |
50 40, 33, 26, 19, 12, 5, | |
51 6, 13, 20, 27, 34, 41, 48, | |
52 56, 49, 42, 35, 28, 21, 14, 7, | |
53 15, 22, 29, 36, 43, 50, 57, | |
54 58, 51, 44, 37, 30, 23, | |
55 31, 38, 45, 52, 59, | |
56 60, 53, 46, 39, | |
57 47, 54, 61, | |
58 62, 55, | |
59 63 }; | |
60 | |
61 static const __u64 RTjpeg_aan_tab[64]={ | |
62 4294967296ULL, 5957222912ULL, 5611718144ULL, 5050464768ULL, 4294967296ULL, 3374581504ULL, 2324432128ULL, 1184891264ULL, | |
63 5957222912ULL, 8263040512ULL, 7783580160ULL, 7005009920ULL, 5957222912ULL, 4680582144ULL, 3224107520ULL, 1643641088ULL, | |
64 5611718144ULL, 7783580160ULL, 7331904512ULL, 6598688768ULL, 5611718144ULL, 4408998912ULL, 3036936960ULL, 1548224000ULL, | |
65 5050464768ULL, 7005009920ULL, 6598688768ULL, 5938608128ULL, 5050464768ULL, 3968072960ULL, 2733115392ULL, 1393296000ULL, | |
66 4294967296ULL, 5957222912ULL, 5611718144ULL, 5050464768ULL, 4294967296ULL, 3374581504ULL, 2324432128ULL, 1184891264ULL, | |
67 3374581504ULL, 4680582144ULL, 4408998912ULL, 3968072960ULL, 3374581504ULL, 2651326208ULL, 1826357504ULL, 931136000ULL, | |
68 2324432128ULL, 3224107520ULL, 3036936960ULL, 2733115392ULL, 2324432128ULL, 1826357504ULL, 1258030336ULL, 641204288ULL, | |
69 1184891264ULL, 1643641088ULL, 1548224000ULL, 1393296000ULL, 1184891264ULL, 931136000ULL, 641204288ULL, 326894240ULL, | |
70 }; | |
71 | |
72 #ifndef MMX | |
73 static __s32 RTjpeg_ws[64+31]; | |
74 #endif | |
75 __u8 RTjpeg_alldata[2*64+4*64+4*64+4*64+4*64+32]; | |
76 | |
3835 | 77 static __s16 *block; // rh |
78 static __s16 *RTjpeg_block; | |
79 static __s32 *RTjpeg_lqt; | |
80 static __s32 *RTjpeg_cqt; | |
81 static __u32 *RTjpeg_liqt; | |
82 static __u32 *RTjpeg_ciqt; | |
83 | |
84 static unsigned char RTjpeg_lb8; | |
85 static unsigned char RTjpeg_cb8; | |
86 static int RTjpeg_width, RTjpeg_height; | |
87 static int RTjpeg_Ywidth, RTjpeg_Cwidth; | |
88 static int RTjpeg_Ysize, RTjpeg_Csize; | |
89 | |
90 static __s16 *RTjpeg_old=NULL; | |
3802 | 91 |
92 #ifdef MMX | |
93 mmx_t RTjpeg_lmask; | |
94 mmx_t RTjpeg_cmask; | |
95 #else | |
96 __u16 RTjpeg_lmask; | |
97 __u16 RTjpeg_cmask; | |
98 #endif | |
99 int RTjpeg_mtest=0; | |
100 | |
101 static const unsigned char RTjpeg_lum_quant_tbl[64] = { | |
102 16, 11, 10, 16, 24, 40, 51, 61, | |
103 12, 12, 14, 19, 26, 58, 60, 55, | |
104 14, 13, 16, 24, 40, 57, 69, 56, | |
105 14, 17, 22, 29, 51, 87, 80, 62, | |
106 18, 22, 37, 56, 68, 109, 103, 77, | |
107 24, 35, 55, 64, 81, 104, 113, 92, | |
108 49, 64, 78, 87, 103, 121, 120, 101, | |
109 72, 92, 95, 98, 112, 100, 103, 99 | |
110 }; | |
111 | |
112 static const unsigned char RTjpeg_chrom_quant_tbl[64] = { | |
113 17, 18, 24, 47, 99, 99, 99, 99, | |
114 18, 21, 26, 66, 99, 99, 99, 99, | |
115 24, 26, 56, 99, 99, 99, 99, 99, | |
116 47, 66, 99, 99, 99, 99, 99, 99, | |
117 99, 99, 99, 99, 99, 99, 99, 99, | |
118 99, 99, 99, 99, 99, 99, 99, 99, | |
119 99, 99, 99, 99, 99, 99, 99, 99, | |
120 99, 99, 99, 99, 99, 99, 99, 99 | |
121 }; | |
122 | |
123 #ifdef BETTERCOMPRESSION | |
124 | |
125 /*--------------------------------------------------*/ | |
126 /* better encoding, but needs a lot more cpu time */ | |
127 /* seems to be more effective than old method +lzo */ | |
128 /* with this encoding lzo isn't efficient anymore */ | |
129 /* there is still more potential for better */ | |
130 /* encoding but that would need even more cputime */ | |
131 /* anyway your mileage may vary */ | |
132 /* */ | |
133 /* written by Martin BIELY and Roman HOCHLEITNER */ | |
134 /*--------------------------------------------------*/ | |
135 | |
136 /* +++++++++++++++++++++++++++++++++++++++++++++++++++*/ | |
137 /* Block to Stream (encoding) */ | |
138 /* */ | |
139 | |
140 int RTjpeg_b2s(__s16 *data, __s8 *strm, __u8 bt8) | |
141 { | |
142 register int ci, co=1; | |
143 register __s16 ZZvalue; | |
144 register unsigned char bitten; | |
145 register unsigned char bitoff; | |
146 | |
147 #ifdef SHOWBLOCK | |
148 | |
149 int ii; | |
150 for (ii=0; ii < 64; ii++) { | |
151 fprintf(stdout, "%d ", data[RTjpeg_ZZ[ii]]); | |
152 } | |
153 fprintf(stdout, "\n\n"); | |
154 | |
155 #endif | |
156 | |
157 // *strm++ = 0x10; | |
158 // *strm = 0x00; | |
159 // | |
160 // return 2; | |
161 | |
162 // first byte allways written | |
12378 | 163 ((__u8*)strm)[0]= |
3802 | 164 (__u8)(data[RTjpeg_ZZ[0]]>254) ? 254:((data[RTjpeg_ZZ[0]]<0)?0:data[RTjpeg_ZZ[0]]); |
165 | |
166 | |
167 ci=63; | |
168 while (data[RTjpeg_ZZ[ci]]==0 && ci>0) ci--; | |
169 | |
170 bitten = ((unsigned char)ci) << 2; | |
171 | |
172 if (ci==0) { | |
12378 | 173 ((__u8*)strm)[1]= bitten; |
3802 | 174 co = 2; |
175 return (int)co; | |
176 } | |
177 | |
178 /* bitoff=0 because the high 6bit contain first non zero position */ | |
179 bitoff = 0; | |
180 co = 1; | |
181 | |
182 for(; ci>0; ci--) { | |
183 | |
184 ZZvalue = data[RTjpeg_ZZ[ci]]; | |
185 | |
186 switch(ZZvalue) { | |
187 case 0: | |
188 break; | |
189 case 1: | |
190 bitten |= (0x01<<bitoff); | |
191 break; | |
192 case -1: | |
193 bitten |= (0x03<<bitoff); | |
194 break; | |
195 default: | |
196 bitten |= (0x02<<bitoff); | |
197 goto HERZWEH; | |
198 break; | |
199 } | |
200 | |
201 if( bitoff == 0 ) { | |
12378 | 202 ((__u8*)strm)[co]= bitten; |
3802 | 203 bitten = 0; |
204 bitoff = 8; | |
205 co++; | |
206 } /* "fall through" */ | |
207 bitoff-=2; | |
208 | |
209 } | |
210 | |
211 /* ci must be 0 */ | |
212 if(bitoff != 6) { | |
213 | |
12378 | 214 ((__u8*)strm)[co]= bitten; |
3802 | 215 co++; |
216 | |
217 } | |
218 goto BAUCHWEH; | |
219 | |
220 HERZWEH: | |
221 /* ci cannot be 0 */ | |
222 /* correct bitoff to nibble boundaries */ | |
223 | |
224 switch(bitoff){ | |
225 case 4: | |
226 case 6: | |
227 bitoff = 0; | |
228 break; | |
229 case 2: | |
230 case 0: | |
12378 | 231 ((__u8*)strm)[co]= bitten; |
3802 | 232 bitoff = 4; |
233 co++; | |
234 bitten = 0; // clear half nibble values in bitten | |
235 break; | |
236 default: | |
237 break; | |
238 } | |
239 | |
240 for(; ci>0; ci--) { | |
241 | |
242 ZZvalue = data[RTjpeg_ZZ[ci]]; | |
243 | |
244 if( (ZZvalue > 7) || (ZZvalue < -7) ) { | |
245 bitten |= (0x08<<bitoff); | |
246 goto HIRNWEH; | |
247 } | |
248 | |
249 bitten |= (ZZvalue&0xf)<<bitoff; | |
250 | |
251 if( bitoff == 0 ) { | |
12378 | 252 ((__u8*)strm)[co]= bitten; |
3802 | 253 bitten = 0; |
254 bitoff = 8; | |
255 co++; | |
256 } /* "fall thru" */ | |
257 bitoff-=4; | |
258 } | |
259 | |
260 /* ci must be 0 */ | |
261 if( bitoff == 0 ) { | |
12378 | 262 ((__u8*)strm)[co]= bitten; |
3802 | 263 co++; |
264 } | |
265 goto BAUCHWEH; | |
266 | |
267 HIRNWEH: | |
268 | |
12378 | 269 ((__u8*)strm)[co]= bitten; |
3802 | 270 co++; |
271 | |
272 | |
273 /* bitting is over now we bite */ | |
274 for(; ci>0; ci--) { | |
275 | |
276 ZZvalue = data[RTjpeg_ZZ[ci]]; | |
277 | |
278 if(ZZvalue>0) | |
279 { | |
280 strm[co++]=(__s8)(ZZvalue>127)?127:ZZvalue; | |
281 } | |
282 else | |
283 { | |
284 strm[co++]=(__s8)(ZZvalue<-128)?-128:ZZvalue; | |
285 } | |
286 | |
287 } | |
288 | |
289 | |
290 BAUCHWEH: | |
291 /* we gotoo much now we are ill */ | |
292 #ifdef SHOWBLOCK | |
293 { | |
294 int i; | |
295 fprintf(stdout, "\nco = '%d'\n", co); | |
296 for (i=0; i < co+2; i++) { | |
297 fprintf(stdout, "%d ", strm[i]); | |
298 } | |
299 fprintf(stdout, "\n\n"); | |
300 } | |
301 #endif | |
302 | |
303 return (int)co; | |
304 } | |
305 | |
306 /* +++++++++++++++++++++++++++++++++++++++++++++++++++*/ | |
307 /* Stream to Block (decoding) */ | |
308 /* */ | |
309 | |
310 int RTjpeg_s2b(__s16 *data, __s8 *strm, __u8 bt8, __u32 *qtbl) | |
311 { | |
312 int ci; | |
313 register int co; | |
314 register int i; | |
315 register unsigned char bitten; | |
316 register unsigned char bitoff; | |
317 | |
318 /* first byte always read */ | |
319 i=RTjpeg_ZZ[0]; | |
320 data[i]=((__u8)strm[0])*qtbl[i]; | |
321 | |
322 /* we start at the behind */ | |
323 | |
324 bitten = ((unsigned char)strm[1]) >> 2; | |
325 co = 63; | |
326 for(; co > bitten; co--) { | |
327 | |
328 data[RTjpeg_ZZ[co]] = 0; | |
329 | |
330 } | |
331 | |
332 if (co==0) { | |
333 ci = 2; | |
334 goto AUTOBAHN; | |
335 } | |
336 | |
337 /* we have to read the last 2 bits of the second byte */ | |
338 ci=1; | |
339 bitoff = 0; | |
340 | |
341 for(; co>0; co--) { | |
342 | |
343 bitten = ((unsigned char)strm[ci]) >> bitoff; | |
344 bitten &= 0x03; | |
345 | |
346 i=RTjpeg_ZZ[co]; | |
347 | |
348 switch( bitten ) { | |
349 case 0x03: | |
350 data[i]= -qtbl[i]; | |
351 break; | |
352 case 0x02: | |
353 goto FUSSWEG; | |
354 break; | |
355 case 0x01: | |
356 data[i]= qtbl[i]; | |
357 break; | |
358 case 0x00: | |
359 data[i]= 0; | |
360 break; | |
361 default: | |
6335
e9bd97d5c5cc
warning & newline fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
5602
diff
changeset
|
362 break; |
3802 | 363 } |
364 | |
365 if( bitoff == 0 ) { | |
366 bitoff = 8; | |
367 ci++; | |
368 } | |
369 bitoff -= 2; | |
370 } | |
371 /* co is 0 now */ | |
372 /* data is written properly */ | |
373 | |
374 /* if bitoff!=6 then ci is the index, but should be the byte count, so we increment by 1 */ | |
375 if (bitoff!=6) ci++; | |
376 | |
377 goto AUTOBAHN; | |
378 | |
379 | |
380 FUSSWEG: | |
381 /* correct bitoff to nibble */ | |
382 switch(bitoff){ | |
383 case 4: | |
384 case 6: | |
385 bitoff = 0; | |
386 break; | |
387 case 2: | |
388 case 0: | |
389 /* we have to read from the next byte */ | |
390 ci++; | |
391 bitoff = 4; | |
392 break; | |
393 default: | |
394 break; | |
395 } | |
396 | |
397 for(; co>0; co--) { | |
398 | |
399 bitten = ((unsigned char)strm[ci]) >> bitoff; | |
400 bitten &= 0x0f; | |
401 | |
402 i=RTjpeg_ZZ[co]; | |
403 | |
404 if( bitten == 0x08 ) { | |
405 goto STRASSE; | |
406 } | |
407 | |
408 /* the compiler cannot do sign extension for signed nibbles */ | |
409 if( bitten & 0x08 ) { | |
410 bitten |= 0xf0; | |
411 } | |
412 /* the unsigned char bitten now is a valid signed char */ | |
413 | |
414 data[i]=((signed char)bitten)*qtbl[i]; | |
415 | |
416 if( bitoff == 0 ) { | |
417 bitoff = 8; | |
418 ci++; | |
419 } | |
420 bitoff -= 4; | |
421 } | |
422 /* co is 0 */ | |
423 | |
424 /* if bitoff!=4 then ci is the index, but should be the byte count, so we increment by 1 */ | |
425 if (bitoff!=4) ci++; | |
426 | |
427 goto AUTOBAHN; | |
428 | |
429 STRASSE: | |
430 ci++; | |
431 | |
432 for(; co>0; co--) { | |
433 i=RTjpeg_ZZ[co]; | |
434 data[i]=strm[ci++]*qtbl[i]; | |
435 } | |
436 | |
437 /* ci now is the count, because it points to next element => no incrementing */ | |
438 | |
439 AUTOBAHN: | |
440 | |
441 #ifdef SHOWBLOCK | |
442 fprintf(stdout, "\nci = '%d'\n", ci); | |
443 for (i=0; i < 64; i++) { | |
444 fprintf(stdout, "%d ", data[RTjpeg_ZZ[i]]); | |
445 } | |
446 fprintf(stdout, "\n\n"); | |
447 #endif | |
448 | |
449 return ci; | |
450 } | |
451 | |
452 #else | |
453 | |
454 int RTjpeg_b2s(__s16 *data, __s8 *strm, __u8 bt8) | |
455 { | |
456 register int ci, co=1, tmp; | |
457 register __s16 ZZvalue; | |
458 | |
459 #ifdef SHOWBLOCK | |
460 | |
461 int ii; | |
462 for (ii=0; ii < 64; ii++) { | |
463 fprintf(stdout, "%d ", data[RTjpeg_ZZ[ii]]); | |
464 } | |
465 fprintf(stdout, "\n\n"); | |
466 | |
467 #endif | |
468 | |
469 (__u8)strm[0]=(__u8)(data[RTjpeg_ZZ[0]]>254) ? 254:((data[RTjpeg_ZZ[0]]<0)?0:data[RTjpeg_ZZ[0]]); | |
470 | |
471 for(ci=1; ci<=bt8; ci++) | |
472 { | |
473 ZZvalue = data[RTjpeg_ZZ[ci]]; | |
474 | |
475 if(ZZvalue>0) | |
476 { | |
477 strm[co++]=(__s8)(ZZvalue>127)?127:ZZvalue; | |
478 } | |
479 else | |
480 { | |
481 strm[co++]=(__s8)(ZZvalue<-128)?-128:ZZvalue; | |
482 } | |
483 } | |
484 | |
485 for(; ci<64; ci++) | |
486 { | |
487 ZZvalue = data[RTjpeg_ZZ[ci]]; | |
488 | |
489 if(ZZvalue>0) | |
490 { | |
491 strm[co++]=(__s8)(ZZvalue>63)?63:ZZvalue; | |
492 } | |
493 else if(ZZvalue<0) | |
494 { | |
495 strm[co++]=(__s8)(ZZvalue<-64)?-64:ZZvalue; | |
496 } | |
497 else /* compress zeros */ | |
498 { | |
499 tmp=ci; | |
500 do | |
501 { | |
502 ci++; | |
503 } | |
504 while((ci<64)&&(data[RTjpeg_ZZ[ci]]==0)); | |
505 | |
506 strm[co++]=(__s8)(63+(ci-tmp)); | |
507 ci--; | |
508 } | |
509 } | |
510 return (int)co; | |
511 } | |
512 | |
513 int RTjpeg_s2b(__s16 *data, __s8 *strm, __u8 bt8, __u32 *qtbl) | |
514 { | |
515 int ci=1, co=1, tmp; | |
516 register int i; | |
517 | |
518 i=RTjpeg_ZZ[0]; | |
519 data[i]=((__u8)strm[0])*qtbl[i]; | |
520 | |
521 for(co=1; co<=bt8; co++) | |
522 { | |
523 i=RTjpeg_ZZ[co]; | |
524 data[i]=strm[ci++]*qtbl[i]; | |
525 } | |
526 | |
527 for(; co<64; co++) | |
528 { | |
529 if(strm[ci]>63) | |
530 { | |
531 tmp=co+strm[ci]-63; | |
532 for(; co<tmp; co++)data[RTjpeg_ZZ[co]]=0; | |
533 co--; | |
534 } else | |
535 { | |
536 i=RTjpeg_ZZ[co]; | |
537 data[i]=strm[ci]*qtbl[i]; | |
538 } | |
539 ci++; | |
540 } | |
541 return (int)ci; | |
542 } | |
543 #endif | |
544 | |
545 #if defined(MMX) | |
546 void RTjpeg_quant_init(void) | |
547 { | |
548 int i; | |
549 __s16 *qtbl; | |
550 | |
551 qtbl=(__s16 *)RTjpeg_lqt; | |
552 for(i=0; i<64; i++)qtbl[i]=(__s16)RTjpeg_lqt[i]; | |
553 | |
554 qtbl=(__s16 *)RTjpeg_cqt; | |
555 for(i=0; i<64; i++)qtbl[i]=(__s16)RTjpeg_cqt[i]; | |
556 } | |
557 | |
12928 | 558 static mmx_t RTjpeg_ones={0x0001000100010001LL}; |
559 static mmx_t RTjpeg_half={0x7fff7fff7fff7fffLL}; | |
3802 | 560 |
561 void RTjpeg_quant(__s16 *block, __s32 *qtbl) | |
562 { | |
563 int i; | |
564 mmx_t *bl, *ql; | |
565 | |
566 ql=(mmx_t *)qtbl; | |
567 bl=(mmx_t *)block; | |
568 | |
569 movq_m2r(RTjpeg_ones, mm6); | |
570 movq_m2r(RTjpeg_half, mm7); | |
571 | |
572 for(i=16; i; i--) | |
573 { | |
574 movq_m2r(*(ql++), mm0); /* quant vals (4) */ | |
575 movq_m2r(*bl, mm2); /* block vals (4) */ | |
576 movq_r2r(mm0, mm1); | |
577 movq_r2r(mm2, mm3); | |
578 | |
579 punpcklwd_r2r(mm6, mm0); /* 1 qb 1 qa */ | |
580 punpckhwd_r2r(mm6, mm1); /* 1 qd 1 qc */ | |
581 | |
582 punpcklwd_r2r(mm7, mm2); /* 32767 bb 32767 ba */ | |
583 punpckhwd_r2r(mm7, mm3); /* 32767 bd 32767 bc */ | |
584 | |
585 pmaddwd_r2r(mm2, mm0); /* 32767+bb*qb 32767+ba*qa */ | |
586 pmaddwd_r2r(mm3, mm1); /* 32767+bd*qd 32767+bc*qc */ | |
587 | |
588 psrad_i2r(16, mm0); | |
589 psrad_i2r(16, mm1); | |
590 | |
591 packssdw_r2r(mm1, mm0); | |
592 | |
593 movq_r2m(mm0, *(bl++)); | |
594 | |
595 } | |
596 } | |
597 #else | |
598 void RTjpeg_quant_init(void) | |
599 { | |
600 } | |
601 | |
602 void RTjpeg_quant(__s16 *block, __s32 *qtbl) | |
603 { | |
604 int i; | |
605 | |
606 for(i=0; i<64; i++) | |
607 block[i]=(__s16)((block[i]*qtbl[i]+32767)>>16); | |
608 } | |
609 #endif | |
610 | |
611 /* | |
612 * Perform the forward DCT on one block of samples. | |
613 */ | |
614 #ifdef MMX | |
12928 | 615 static mmx_t RTjpeg_C4 ={0x2D412D412D412D41LL}; |
616 static mmx_t RTjpeg_C6 ={0x187E187E187E187ELL}; | |
617 static mmx_t RTjpeg_C2mC6={0x22A322A322A322A3LL}; | |
618 static mmx_t RTjpeg_C2pC6={0x539F539F539F539FLL}; | |
619 static mmx_t RTjpeg_zero ={0x0000000000000000LL}; | |
3802 | 620 |
621 #else | |
622 | |
623 #define FIX_0_382683433 ((__s32) 98) /* FIX(0.382683433) */ | |
624 #define FIX_0_541196100 ((__s32) 139) /* FIX(0.541196100) */ | |
625 #define FIX_0_707106781 ((__s32) 181) /* FIX(0.707106781) */ | |
626 #define FIX_1_306562965 ((__s32) 334) /* FIX(1.306562965) */ | |
627 | |
628 #define DESCALE10(x) (__s16)( ((x)+128) >> 8) | |
629 #define DESCALE20(x) (__s16)(((x)+32768) >> 16) | |
630 #define D_MULTIPLY(var,const) ((__s32) ((var) * (const))) | |
631 #endif | |
632 | |
633 void RTjpeg_dct_init(void) | |
634 { | |
635 int i; | |
636 | |
637 for(i=0; i<64; i++) | |
638 { | |
639 RTjpeg_lqt[i]=(((__u64)RTjpeg_lqt[i]<<32)/RTjpeg_aan_tab[i]); | |
640 RTjpeg_cqt[i]=(((__u64)RTjpeg_cqt[i]<<32)/RTjpeg_aan_tab[i]); | |
641 } | |
642 } | |
643 | |
644 void RTjpeg_dctY(__u8 *idata, __s16 *odata, int rskip) | |
645 { | |
646 #ifndef MMX | |
647 __s32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | |
648 __s32 tmp10, tmp11, tmp12, tmp13; | |
649 __s32 z1, z2, z3, z4, z5, z11, z13; | |
650 __u8 *idataptr; | |
651 __s16 *odataptr; | |
652 __s32 *wsptr; | |
653 int ctr; | |
654 | |
655 idataptr = idata; | |
656 wsptr = RTjpeg_ws; | |
657 for (ctr = 7; ctr >= 0; ctr--) { | |
658 tmp0 = idataptr[0] + idataptr[7]; | |
659 tmp7 = idataptr[0] - idataptr[7]; | |
660 tmp1 = idataptr[1] + idataptr[6]; | |
661 tmp6 = idataptr[1] - idataptr[6]; | |
662 tmp2 = idataptr[2] + idataptr[5]; | |
663 tmp5 = idataptr[2] - idataptr[5]; | |
664 tmp3 = idataptr[3] + idataptr[4]; | |
665 tmp4 = idataptr[3] - idataptr[4]; | |
666 | |
667 tmp10 = (tmp0 + tmp3); /* phase 2 */ | |
668 tmp13 = tmp0 - tmp3; | |
669 tmp11 = (tmp1 + tmp2); | |
670 tmp12 = tmp1 - tmp2; | |
671 | |
672 wsptr[0] = (tmp10 + tmp11)<<8; /* phase 3 */ | |
673 wsptr[4] = (tmp10 - tmp11)<<8; | |
674 | |
675 z1 = D_MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ | |
676 wsptr[2] = (tmp13<<8) + z1; /* phase 5 */ | |
677 wsptr[6] = (tmp13<<8) - z1; | |
678 | |
679 tmp10 = tmp4 + tmp5; /* phase 2 */ | |
680 tmp11 = tmp5 + tmp6; | |
681 tmp12 = tmp6 + tmp7; | |
682 | |
683 z5 = D_MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ | |
684 z2 = D_MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ | |
685 z4 = D_MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ | |
686 z3 = D_MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ | |
687 | |
688 z11 = (tmp7<<8) + z3; /* phase 5 */ | |
689 z13 = (tmp7<<8) - z3; | |
690 | |
691 wsptr[5] = z13 + z2; /* phase 6 */ | |
692 wsptr[3] = z13 - z2; | |
693 wsptr[1] = z11 + z4; | |
694 wsptr[7] = z11 - z4; | |
695 | |
696 idataptr += rskip<<3; /* advance pointer to next row */ | |
697 wsptr += 8; | |
698 } | |
699 | |
700 wsptr = RTjpeg_ws; | |
701 odataptr=odata; | |
702 for (ctr = 7; ctr >= 0; ctr--) { | |
703 tmp0 = wsptr[0] + wsptr[56]; | |
704 tmp7 = wsptr[0] - wsptr[56]; | |
705 tmp1 = wsptr[8] + wsptr[48]; | |
706 tmp6 = wsptr[8] - wsptr[48]; | |
707 tmp2 = wsptr[16] + wsptr[40]; | |
708 tmp5 = wsptr[16] - wsptr[40]; | |
709 tmp3 = wsptr[24] + wsptr[32]; | |
710 tmp4 = wsptr[24] - wsptr[32]; | |
711 | |
712 tmp10 = tmp0 + tmp3; /* phase 2 */ | |
713 tmp13 = tmp0 - tmp3; | |
714 tmp11 = tmp1 + tmp2; | |
715 tmp12 = tmp1 - tmp2; | |
716 | |
717 odataptr[0] = DESCALE10(tmp10 + tmp11); /* phase 3 */ | |
718 odataptr[32] = DESCALE10(tmp10 - tmp11); | |
719 | |
720 z1 = D_MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ | |
721 odataptr[16] = DESCALE20((tmp13<<8) + z1); /* phase 5 */ | |
722 odataptr[48] = DESCALE20((tmp13<<8) - z1); | |
723 | |
724 tmp10 = tmp4 + tmp5; /* phase 2 */ | |
725 tmp11 = tmp5 + tmp6; | |
726 tmp12 = tmp6 + tmp7; | |
727 | |
728 z5 = D_MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ | |
729 z2 = D_MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ | |
730 z4 = D_MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ | |
731 z3 = D_MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ | |
732 | |
733 z11 = (tmp7<<8) + z3; /* phase 5 */ | |
734 z13 = (tmp7<<8) - z3; | |
735 | |
736 odataptr[40] = DESCALE20(z13 + z2); /* phase 6 */ | |
737 odataptr[24] = DESCALE20(z13 - z2); | |
738 odataptr[8] = DESCALE20(z11 + z4); | |
739 odataptr[56] = DESCALE20(z11 - z4); | |
740 | |
741 odataptr++; /* advance pointer to next column */ | |
742 wsptr++; | |
743 } | |
744 #else | |
745 volatile mmx_t tmp6, tmp7; | |
746 register mmx_t *dataptr = (mmx_t *)odata; | |
747 mmx_t *idata2 = (mmx_t *)idata; | |
748 | |
749 // first copy the input 8 bit to the destination 16 bits | |
750 | |
751 movq_m2r(RTjpeg_zero, mm2); | |
752 | |
753 | |
754 movq_m2r(*idata2, mm0); | |
755 movq_r2r(mm0, mm1); | |
756 | |
757 punpcklbw_r2r(mm2, mm0); | |
758 movq_r2m(mm0, *(dataptr)); | |
759 | |
760 punpckhbw_r2r(mm2, mm1); | |
761 movq_r2m(mm1, *(dataptr+1)); | |
762 | |
763 idata2 += rskip; | |
764 | |
765 movq_m2r(*idata2, mm0); | |
766 movq_r2r(mm0, mm1); | |
767 | |
768 punpcklbw_r2r(mm2, mm0); | |
769 movq_r2m(mm0, *(dataptr+2)); | |
770 | |
771 punpckhbw_r2r(mm2, mm1); | |
772 movq_r2m(mm1, *(dataptr+3)); | |
773 | |
774 idata2 += rskip; | |
775 | |
776 movq_m2r(*idata2, mm0); | |
777 movq_r2r(mm0, mm1); | |
778 | |
779 punpcklbw_r2r(mm2, mm0); | |
780 movq_r2m(mm0, *(dataptr+4)); | |
781 | |
782 punpckhbw_r2r(mm2, mm1); | |
783 movq_r2m(mm1, *(dataptr+5)); | |
784 | |
785 idata2 += rskip; | |
786 | |
787 movq_m2r(*idata2, mm0); | |
788 movq_r2r(mm0, mm1); | |
789 | |
790 punpcklbw_r2r(mm2, mm0); | |
791 movq_r2m(mm0, *(dataptr+6)); | |
792 | |
793 punpckhbw_r2r(mm2, mm1); | |
794 movq_r2m(mm1, *(dataptr+7)); | |
795 | |
796 idata2 += rskip; | |
797 | |
798 movq_m2r(*idata2, mm0); | |
799 movq_r2r(mm0, mm1); | |
800 | |
801 punpcklbw_r2r(mm2, mm0); | |
802 movq_r2m(mm0, *(dataptr+8)); | |
803 | |
804 punpckhbw_r2r(mm2, mm1); | |
805 movq_r2m(mm1, *(dataptr+9)); | |
806 | |
807 idata2 += rskip; | |
808 | |
809 movq_m2r(*idata2, mm0); | |
810 movq_r2r(mm0, mm1); | |
811 | |
812 punpcklbw_r2r(mm2, mm0); | |
813 movq_r2m(mm0, *(dataptr+10)); | |
814 | |
815 punpckhbw_r2r(mm2, mm1); | |
816 movq_r2m(mm1, *(dataptr+11)); | |
817 | |
818 idata2 += rskip; | |
819 | |
820 movq_m2r(*idata2, mm0); | |
821 movq_r2r(mm0, mm1); | |
822 | |
823 punpcklbw_r2r(mm2, mm0); | |
824 movq_r2m(mm0, *(dataptr+12)); | |
825 | |
826 punpckhbw_r2r(mm2, mm1); | |
827 movq_r2m(mm1, *(dataptr+13)); | |
828 | |
829 idata2 += rskip; | |
830 | |
831 movq_m2r(*idata2, mm0); | |
832 movq_r2r(mm0, mm1); | |
833 | |
834 punpcklbw_r2r(mm2, mm0); | |
835 movq_r2m(mm0, *(dataptr+14)); | |
836 | |
837 punpckhbw_r2r(mm2, mm1); | |
838 movq_r2m(mm1, *(dataptr+15)); | |
839 | |
840 /* Start Transpose to do calculations on rows */ | |
841 | |
842 movq_m2r(*(dataptr+9), mm7); // m03:m02|m01:m00 - first line (line 4)and copy into m5 | |
843 | |
844 movq_m2r(*(dataptr+13), mm6); // m23:m22|m21:m20 - third line (line 6)and copy into m2 | |
845 movq_r2r(mm7, mm5); | |
846 | |
847 punpcklwd_m2r(*(dataptr+11), mm7); // m11:m01|m10:m00 - interleave first and second lines | |
848 movq_r2r(mm6, mm2); | |
849 | |
850 punpcklwd_m2r(*(dataptr+15), mm6); // m31:m21|m30:m20 - interleave third and fourth lines | |
851 movq_r2r(mm7, mm1); | |
852 | |
853 movq_m2r(*(dataptr+11), mm3); // m13:m13|m11:m10 - second line | |
854 punpckldq_r2r(mm6, mm7); // m30:m20|m10:m00 - interleave to produce result 1 | |
855 | |
856 movq_m2r(*(dataptr+15), mm0); // m13:m13|m11:m10 - fourth line | |
857 punpckhdq_r2r(mm6, mm1); // m31:m21|m11:m01 - interleave to produce result 2 | |
858 | |
859 movq_r2m(mm7,*(dataptr+9)); // write result 1 | |
860 punpckhwd_r2r(mm3, mm5); // m13:m03|m12:m02 - interleave first and second lines | |
861 | |
862 movq_r2m(mm1,*(dataptr+11)); // write result 2 | |
863 punpckhwd_r2r(mm0, mm2); // m33:m23|m32:m22 - interleave third and fourth lines | |
864 | |
865 movq_r2r(mm5, mm1); | |
866 punpckldq_r2r(mm2, mm5); // m32:m22|m12:m02 - interleave to produce result 3 | |
867 | |
868 movq_m2r(*(dataptr+1), mm0); // m03:m02|m01:m00 - first line, 4x4 | |
869 punpckhdq_r2r(mm2, mm1); // m33:m23|m13:m03 - interleave to produce result 4 | |
870 | |
871 movq_r2m(mm5,*(dataptr+13)); // write result 3 | |
872 | |
873 // last 4x4 done | |
874 | |
875 movq_r2m(mm1, *(dataptr+15)); // write result 4, last 4x4 | |
876 | |
877 movq_m2r(*(dataptr+5), mm2); // m23:m22|m21:m20 - third line | |
878 movq_r2r(mm0, mm6); | |
879 | |
880 punpcklwd_m2r(*(dataptr+3), mm0); // m11:m01|m10:m00 - interleave first and second lines | |
881 movq_r2r(mm2, mm7); | |
882 | |
883 punpcklwd_m2r(*(dataptr+7), mm2); // m31:m21|m30:m20 - interleave third and fourth lines | |
884 movq_r2r(mm0, mm4); | |
885 | |
886 // | |
887 movq_m2r(*(dataptr+8), mm1); // n03:n02|n01:n00 - first line | |
888 punpckldq_r2r(mm2, mm0); // m30:m20|m10:m00 - interleave to produce first result | |
889 | |
890 movq_m2r(*(dataptr+12), mm3); // n23:n22|n21:n20 - third line | |
891 punpckhdq_r2r(mm2, mm4); // m31:m21|m11:m01 - interleave to produce second result | |
892 | |
893 punpckhwd_m2r(*(dataptr+3), mm6); // m13:m03|m12:m02 - interleave first and second lines | |
894 movq_r2r(mm1, mm2); // copy first line | |
895 | |
896 punpckhwd_m2r(*(dataptr+7), mm7); // m33:m23|m32:m22 - interleave third and fourth lines | |
897 movq_r2r(mm6, mm5); // copy first intermediate result | |
898 | |
899 movq_r2m(mm0, *(dataptr+8)); // write result 1 | |
900 punpckhdq_r2r(mm7, mm5); // m33:m23|m13:m03 - produce third result | |
901 | |
902 punpcklwd_m2r(*(dataptr+10), mm1); // n11:n01|n10:n00 - interleave first and second lines | |
903 movq_r2r(mm3, mm0); // copy third line | |
904 | |
905 punpckhwd_m2r(*(dataptr+10), mm2); // n13:n03|n12:n02 - interleave first and second lines | |
906 | |
907 movq_r2m(mm4, *(dataptr+10)); // write result 2 out | |
908 punpckldq_r2r(mm7, mm6); // m32:m22|m12:m02 - produce fourth result | |
909 | |
910 punpcklwd_m2r(*(dataptr+14), mm3); // n31:n21|n30:n20 - interleave third and fourth lines | |
911 movq_r2r(mm1, mm4); | |
912 | |
913 movq_r2m(mm6, *(dataptr+12)); // write result 3 out | |
914 punpckldq_r2r(mm3, mm1); // n30:n20|n10:n00 - produce first result | |
915 | |
916 punpckhwd_m2r(*(dataptr+14), mm0); // n33:n23|n32:n22 - interleave third and fourth lines | |
917 movq_r2r(mm2, mm6); | |
918 | |
919 movq_r2m(mm5, *(dataptr+14)); // write result 4 out | |
920 punpckhdq_r2r(mm3, mm4); // n31:n21|n11:n01- produce second result | |
921 | |
922 movq_r2m(mm1, *(dataptr+1)); // write result 5 out - (first result for other 4 x 4 block) | |
923 punpckldq_r2r(mm0, mm2); // n32:n22|n12:n02- produce third result | |
924 | |
925 movq_r2m(mm4, *(dataptr+3)); // write result 6 out | |
926 punpckhdq_r2r(mm0, mm6); // n33:n23|n13:n03 - produce fourth result | |
927 | |
928 movq_r2m(mm2, *(dataptr+5)); // write result 7 out | |
929 | |
930 movq_m2r(*dataptr, mm0); // m03:m02|m01:m00 - first line, first 4x4 | |
931 | |
932 movq_r2m(mm6, *(dataptr+7)); // write result 8 out | |
933 | |
934 | |
935 // Do first 4x4 quadrant, which is used in the beginning of the DCT: | |
936 | |
937 movq_m2r(*(dataptr+4), mm7); // m23:m22|m21:m20 - third line | |
938 movq_r2r(mm0, mm2); | |
939 | |
940 punpcklwd_m2r(*(dataptr+2), mm0); // m11:m01|m10:m00 - interleave first and second lines | |
941 movq_r2r(mm7, mm4); | |
942 | |
943 punpcklwd_m2r(*(dataptr+6), mm7); // m31:m21|m30:m20 - interleave third and fourth lines | |
944 movq_r2r(mm0, mm1); | |
945 | |
946 movq_m2r(*(dataptr+2), mm6); // m13:m12|m11:m10 - second line | |
947 punpckldq_r2r(mm7, mm0); // m30:m20|m10:m00 - interleave to produce result 1 | |
948 | |
949 movq_m2r(*(dataptr+6), mm5); // m33:m32|m31:m30 - fourth line | |
950 punpckhdq_r2r(mm7, mm1); // m31:m21|m11:m01 - interleave to produce result 2 | |
951 | |
952 movq_r2r(mm0, mm7); // write result 1 | |
953 punpckhwd_r2r(mm6, mm2); // m13:m03|m12:m02 - interleave first and second lines | |
954 | |
955 psubw_m2r(*(dataptr+14), mm7); // tmp07=x0-x7 /* Stage 1 */ | |
956 movq_r2r(mm1, mm6); // write result 2 | |
957 | |
958 paddw_m2r(*(dataptr+14), mm0); // tmp00=x0+x7 /* Stage 1 */ | |
959 punpckhwd_r2r(mm5, mm4); // m33:m23|m32:m22 - interleave third and fourth lines | |
960 | |
961 paddw_m2r(*(dataptr+12), mm1); // tmp01=x1+x6 /* Stage 1 */ | |
962 movq_r2r(mm2, mm3); // copy first intermediate result | |
963 | |
964 psubw_m2r(*(dataptr+12), mm6); // tmp06=x1-x6 /* Stage 1 */ | |
965 punpckldq_r2r(mm4, mm2); // m32:m22|m12:m02 - interleave to produce result 3 | |
966 | |
967 movq_r2m(mm7, tmp7); | |
968 movq_r2r(mm2, mm5); // write result 3 | |
969 | |
970 movq_r2m(mm6, tmp6); | |
971 punpckhdq_r2r(mm4, mm3); // m33:m23|m13:m03 - interleave to produce result 4 | |
972 | |
973 paddw_m2r(*(dataptr+10), mm2); // tmp02=x2+5 /* Stage 1 */ | |
974 movq_r2r(mm3, mm4); // write result 4 | |
975 | |
976 /************************************************************************************************ | |
977 End of Transpose | |
978 ************************************************************************************************/ | |
979 | |
980 | |
981 paddw_m2r(*(dataptr+8), mm3); // tmp03=x3+x4 /* stage 1*/ | |
982 movq_r2r(mm0, mm7); | |
983 | |
984 psubw_m2r(*(dataptr+8), mm4); // tmp04=x3-x4 /* stage 1*/ | |
985 movq_r2r(mm1, mm6); | |
986 | |
987 paddw_r2r(mm3, mm0); // tmp10 = tmp00 + tmp03 /* even 2 */ | |
988 psubw_r2r(mm3, mm7); // tmp13 = tmp00 - tmp03 /* even 2 */ | |
989 | |
990 psubw_r2r(mm2, mm6); // tmp12 = tmp01 - tmp02 /* even 2 */ | |
991 paddw_r2r(mm2, mm1); // tmp11 = tmp01 + tmp02 /* even 2 */ | |
992 | |
993 psubw_m2r(*(dataptr+10), mm5); // tmp05=x2-x5 /* stage 1*/ | |
994 paddw_r2r(mm7, mm6); // tmp12 + tmp13 | |
995 | |
996 /* stage 3 */ | |
997 | |
998 movq_m2r(tmp6, mm2); | |
999 movq_r2r(mm0, mm3); | |
1000 | |
1001 psllw_i2r(2, mm6); // m8 * 2^2 | |
1002 paddw_r2r(mm1, mm0); | |
1003 | |
1004 pmulhw_m2r(RTjpeg_C4, mm6); // z1 | |
1005 psubw_r2r(mm1, mm3); | |
1006 | |
1007 movq_r2m(mm0, *dataptr); | |
1008 movq_r2r(mm7, mm0); | |
1009 | |
1010 /* Odd part */ | |
1011 movq_r2m(mm3, *(dataptr+8)); | |
1012 paddw_r2r(mm5, mm4); // tmp10 | |
1013 | |
1014 movq_m2r(tmp7, mm3); | |
1015 paddw_r2r(mm6, mm0); // tmp32 | |
1016 | |
1017 paddw_r2r(mm2, mm5); // tmp11 | |
1018 psubw_r2r(mm6, mm7); // tmp33 | |
1019 | |
1020 movq_r2m(mm0, *(dataptr+4)); | |
1021 paddw_r2r(mm3, mm2); // tmp12 | |
1022 | |
1023 /* stage 4 */ | |
1024 | |
1025 movq_r2m(mm7, *(dataptr+12)); | |
1026 movq_r2r(mm4, mm1); // copy of tmp10 | |
1027 | |
1028 psubw_r2r(mm2, mm1); // tmp10 - tmp12 | |
1029 psllw_i2r(2, mm4); // m8 * 2^2 | |
1030 | |
1031 movq_m2r(RTjpeg_C2mC6, mm0); | |
1032 psllw_i2r(2, mm1); | |
1033 | |
1034 pmulhw_m2r(RTjpeg_C6, mm1); // z5 | |
1035 psllw_i2r(2, mm2); | |
1036 | |
1037 pmulhw_r2r(mm0, mm4); // z5 | |
1038 | |
1039 /* stage 5 */ | |
1040 | |
1041 pmulhw_m2r(RTjpeg_C2pC6, mm2); | |
1042 psllw_i2r(2, mm5); | |
1043 | |
1044 pmulhw_m2r(RTjpeg_C4, mm5); // z3 | |
1045 movq_r2r(mm3, mm0); // copy tmp7 | |
1046 | |
1047 movq_m2r(*(dataptr+1), mm7); | |
1048 paddw_r2r(mm1, mm4); // z2 | |
1049 | |
1050 paddw_r2r(mm1, mm2); // z4 | |
1051 | |
1052 paddw_r2r(mm5, mm0); // z11 | |
1053 psubw_r2r(mm5, mm3); // z13 | |
1054 | |
1055 /* stage 6 */ | |
1056 | |
1057 movq_r2r(mm3, mm5); // copy z13 | |
1058 psubw_r2r(mm4, mm3); // y3=z13 - z2 | |
1059 | |
1060 paddw_r2r(mm4, mm5); // y5=z13 + z2 | |
1061 movq_r2r(mm0, mm6); // copy z11 | |
1062 | |
1063 movq_r2m(mm3, *(dataptr+6)); //save y3 | |
1064 psubw_r2r(mm2, mm0); // y7=z11 - z4 | |
1065 | |
1066 movq_r2m(mm5, *(dataptr+10)); //save y5 | |
1067 paddw_r2r(mm2, mm6); // y1=z11 + z4 | |
1068 | |
1069 movq_r2m(mm0, *(dataptr+14)); //save y7 | |
1070 | |
1071 /************************************************ | |
1072 * End of 1st 4 rows | |
1073 ************************************************/ | |
1074 | |
1075 movq_m2r(*(dataptr+3), mm1); // load x1 /* stage 1 */ | |
1076 movq_r2r(mm7, mm0); // copy x0 | |
1077 | |
1078 movq_r2m(mm6, *(dataptr+2)); //save y1 | |
1079 | |
1080 movq_m2r(*(dataptr+5), mm2); // load x2 /* stage 1 */ | |
1081 movq_r2r(mm1, mm6); // copy x1 | |
1082 | |
1083 paddw_m2r(*(dataptr+15), mm0); // tmp00 = x0 + x7 | |
1084 | |
1085 movq_m2r(*(dataptr+7), mm3); // load x3 /* stage 1 */ | |
1086 movq_r2r(mm2, mm5); // copy x2 | |
1087 | |
1088 psubw_m2r(*(dataptr+15), mm7); // tmp07 = x0 - x7 | |
1089 movq_r2r(mm3, mm4); // copy x3 | |
1090 | |
1091 paddw_m2r(*(dataptr+13), mm1); // tmp01 = x1 + x6 | |
1092 | |
1093 movq_r2m(mm7, tmp7); // save tmp07 | |
1094 movq_r2r(mm0, mm7); // copy tmp00 | |
1095 | |
1096 psubw_m2r(*(dataptr+13), mm6); // tmp06 = x1 - x6 | |
1097 | |
1098 /* stage 2, Even Part */ | |
1099 | |
1100 paddw_m2r(*(dataptr+9), mm3); // tmp03 = x3 + x4 | |
1101 | |
1102 movq_r2m(mm6, tmp6); // save tmp07 | |
1103 movq_r2r(mm1, mm6); // copy tmp01 | |
1104 | |
1105 paddw_m2r(*(dataptr+11), mm2); // tmp02 = x2 + x5 | |
1106 paddw_r2r(mm3, mm0); // tmp10 = tmp00 + tmp03 | |
1107 | |
1108 psubw_r2r(mm3, mm7); // tmp13 = tmp00 - tmp03 | |
1109 | |
1110 psubw_m2r(*(dataptr+9), mm4); // tmp04 = x3 - x4 | |
1111 psubw_r2r(mm2, mm6); // tmp12 = tmp01 - tmp02 | |
1112 | |
1113 paddw_r2r(mm2, mm1); // tmp11 = tmp01 + tmp02 | |
1114 | |
1115 psubw_m2r(*(dataptr+11), mm5); // tmp05 = x2 - x5 | |
1116 paddw_r2r(mm7, mm6); // tmp12 + tmp13 | |
1117 | |
1118 /* stage 3, Even and stage 4 & 5 even */ | |
1119 | |
1120 movq_m2r(tmp6, mm2); // load tmp6 | |
1121 movq_r2r(mm0, mm3); // copy tmp10 | |
1122 | |
1123 psllw_i2r(2, mm6); // shift z1 | |
1124 paddw_r2r(mm1, mm0); // y0=tmp10 + tmp11 | |
1125 | |
1126 pmulhw_m2r(RTjpeg_C4, mm6); // z1 | |
1127 psubw_r2r(mm1, mm3); // y4=tmp10 - tmp11 | |
1128 | |
1129 movq_r2m(mm0, *(dataptr+1)); //save y0 | |
1130 movq_r2r(mm7, mm0); // copy tmp13 | |
1131 | |
1132 /* odd part */ | |
1133 | |
1134 movq_r2m(mm3, *(dataptr+9)); //save y4 | |
1135 paddw_r2r(mm5, mm4); // tmp10 = tmp4 + tmp5 | |
1136 | |
1137 movq_m2r(tmp7, mm3); // load tmp7 | |
1138 paddw_r2r(mm6, mm0); // tmp32 = tmp13 + z1 | |
1139 | |
1140 paddw_r2r(mm2, mm5); // tmp11 = tmp5 + tmp6 | |
1141 psubw_r2r(mm6, mm7); // tmp33 = tmp13 - z1 | |
1142 | |
1143 movq_r2m(mm0, *(dataptr+5)); //save y2 | |
1144 paddw_r2r(mm3, mm2); // tmp12 = tmp6 + tmp7 | |
1145 | |
1146 /* stage 4 */ | |
1147 | |
1148 movq_r2m(mm7, *(dataptr+13)); //save y6 | |
1149 movq_r2r(mm4, mm1); // copy tmp10 | |
1150 | |
1151 psubw_r2r(mm2, mm1); // tmp10 - tmp12 | |
1152 psllw_i2r(2, mm4); // shift tmp10 | |
1153 | |
1154 movq_m2r(RTjpeg_C2mC6, mm0); // load C2mC6 | |
1155 psllw_i2r(2, mm1); // shift (tmp10-tmp12) | |
1156 | |
1157 pmulhw_m2r(RTjpeg_C6, mm1); // z5 | |
1158 psllw_i2r(2, mm5); // prepare for multiply | |
1159 | |
1160 pmulhw_r2r(mm0, mm4); // multiply by converted real | |
1161 | |
1162 /* stage 5 */ | |
1163 | |
1164 pmulhw_m2r(RTjpeg_C4, mm5); // z3 | |
1165 psllw_i2r(2, mm2); // prepare for multiply | |
1166 | |
1167 pmulhw_m2r(RTjpeg_C2pC6, mm2); // multiply | |
1168 movq_r2r(mm3, mm0); // copy tmp7 | |
1169 | |
1170 movq_m2r(*(dataptr+9), mm7); // m03:m02|m01:m00 - first line (line 4)and copy into mm7 | |
1171 paddw_r2r(mm1, mm4); // z2 | |
1172 | |
1173 paddw_r2r(mm5, mm0); // z11 | |
1174 psubw_r2r(mm5, mm3); // z13 | |
1175 | |
1176 /* stage 6 */ | |
1177 | |
1178 movq_r2r(mm3, mm5); // copy z13 | |
1179 paddw_r2r(mm1, mm2); // z4 | |
1180 | |
1181 movq_r2r(mm0, mm6); // copy z11 | |
1182 psubw_r2r(mm4, mm5); // y3 | |
1183 | |
1184 paddw_r2r(mm2, mm6); // y1 | |
1185 paddw_r2r(mm4, mm3); // y5 | |
1186 | |
1187 movq_r2m(mm5, *(dataptr+7)); //save y3 | |
1188 | |
1189 movq_r2m(mm6, *(dataptr+3)); //save y1 | |
1190 psubw_r2r(mm2, mm0); // y7 | |
1191 | |
1192 /************************************************************************************************ | |
1193 Start of Transpose | |
1194 ************************************************************************************************/ | |
1195 | |
1196 movq_m2r(*(dataptr+13), mm6); // m23:m22|m21:m20 - third line (line 6)and copy into m2 | |
1197 movq_r2r(mm7, mm5); // copy first line | |
1198 | |
1199 punpcklwd_r2r(mm3, mm7); // m11:m01|m10:m00 - interleave first and second lines | |
1200 movq_r2r(mm6, mm2); // copy third line | |
1201 | |
1202 punpcklwd_r2r(mm0, mm6); // m31:m21|m30:m20 - interleave third and fourth lines | |
1203 movq_r2r(mm7, mm1); // copy first intermediate result | |
1204 | |
1205 punpckldq_r2r(mm6, mm7); // m30:m20|m10:m00 - interleave to produce result 1 | |
1206 | |
1207 punpckhdq_r2r(mm6, mm1); // m31:m21|m11:m01 - interleave to produce result 2 | |
1208 | |
1209 movq_r2m(mm7, *(dataptr+9)); // write result 1 | |
1210 punpckhwd_r2r(mm3, mm5); // m13:m03|m12:m02 - interleave first and second lines | |
1211 | |
1212 movq_r2m(mm1, *(dataptr+11)); // write result 2 | |
1213 punpckhwd_r2r(mm0, mm2); // m33:m23|m32:m22 - interleave third and fourth lines | |
1214 | |
1215 movq_r2r(mm5, mm1); // copy first intermediate result | |
1216 punpckldq_r2r(mm2, mm5); // m32:m22|m12:m02 - interleave to produce result 3 | |
1217 | |
1218 movq_m2r(*(dataptr+1), mm0); // m03:m02|m01:m00 - first line, 4x4 | |
1219 punpckhdq_r2r(mm2, mm1); // m33:m23|m13:m03 - interleave to produce result 4 | |
1220 | |
1221 movq_r2m(mm5, *(dataptr+13)); // write result 3 | |
1222 | |
1223 /****** last 4x4 done */ | |
1224 | |
1225 movq_r2m(mm1, *(dataptr+15)); // write result 4, last 4x4 | |
1226 | |
1227 movq_m2r(*(dataptr+5), mm2); // m23:m22|m21:m20 - third line | |
1228 movq_r2r(mm0, mm6); // copy first line | |
1229 | |
1230 punpcklwd_m2r(*(dataptr+3), mm0); // m11:m01|m10:m00 - interleave first and second lines | |
1231 movq_r2r(mm2, mm7); // copy third line | |
1232 | |
1233 punpcklwd_m2r(*(dataptr+7), mm2); // m31:m21|m30:m20 - interleave third and fourth lines | |
1234 movq_r2r(mm0, mm4); // copy first intermediate result | |
1235 | |
1236 | |
1237 | |
1238 movq_m2r(*(dataptr+8), mm1); // n03:n02|n01:n00 - first line | |
1239 punpckldq_r2r(mm2, mm0); // m30:m20|m10:m00 - interleave to produce first result | |
1240 | |
1241 movq_m2r(*(dataptr+12), mm3); // n23:n22|n21:n20 - third line | |
1242 punpckhdq_r2r(mm2, mm4); // m31:m21|m11:m01 - interleave to produce second result | |
1243 | |
1244 punpckhwd_m2r(*(dataptr+3), mm6); // m13:m03|m12:m02 - interleave first and second lines | |
1245 movq_r2r(mm1, mm2); // copy first line | |
1246 | |
1247 punpckhwd_m2r(*(dataptr+7), mm7); // m33:m23|m32:m22 - interleave third and fourth lines | |
1248 movq_r2r(mm6, mm5); // copy first intermediate result | |
1249 | |
1250 movq_r2m(mm0, *(dataptr+8)); // write result 1 | |
1251 punpckhdq_r2r(mm7, mm5); // m33:m23|m13:m03 - produce third result | |
1252 | |
1253 punpcklwd_m2r(*(dataptr+10), mm1); // n11:n01|n10:n00 - interleave first and second lines | |
1254 movq_r2r(mm3, mm0); // copy third line | |
1255 | |
1256 punpckhwd_m2r(*(dataptr+10), mm2); // n13:n03|n12:n02 - interleave first and second lines | |
1257 | |
1258 movq_r2m(mm4, *(dataptr+10)); // write result 2 out | |
1259 punpckldq_r2r(mm7, mm6); // m32:m22|m12:m02 - produce fourth result | |
1260 | |
1261 punpcklwd_m2r(*(dataptr+14), mm3); // n33:n23|n32:n22 - interleave third and fourth lines | |
1262 movq_r2r(mm1, mm4); // copy second intermediate result | |
1263 | |
1264 movq_r2m(mm6, *(dataptr+12)); // write result 3 out | |
1265 punpckldq_r2r(mm3, mm1); // | |
1266 | |
1267 punpckhwd_m2r(*(dataptr+14), mm0); // n33:n23|n32:n22 - interleave third and fourth lines | |
1268 movq_r2r(mm2, mm6); // copy second intermediate result | |
1269 | |
1270 movq_r2m(mm5, *(dataptr+14)); // write result 4 out | |
1271 punpckhdq_r2r(mm3, mm4); // n31:n21|n11:n01- produce second result | |
1272 | |
1273 movq_r2m(mm1, *(dataptr+1)); // write result 5 out - (first result for other 4 x 4 block) | |
1274 punpckldq_r2r(mm0, mm2); // n32:n22|n12:n02- produce third result | |
1275 | |
1276 movq_r2m(mm4, *(dataptr+3)); // write result 6 out | |
1277 punpckhdq_r2r(mm0, mm6); // n33:n23|n13:n03 - produce fourth result | |
1278 | |
1279 movq_r2m(mm2, *(dataptr+5)); // write result 7 out | |
1280 | |
1281 movq_m2r(*dataptr, mm0); // m03:m02|m01:m00 - first line, first 4x4 | |
1282 | |
1283 movq_r2m(mm6, *(dataptr+7)); // write result 8 out | |
1284 | |
1285 // Do first 4x4 quadrant, which is used in the beginning of the DCT: | |
1286 | |
1287 movq_m2r(*(dataptr+4), mm7); // m23:m22|m21:m20 - third line | |
1288 movq_r2r(mm0, mm2); // copy first line | |
1289 | |
1290 punpcklwd_m2r(*(dataptr+2), mm0); // m11:m01|m10:m00 - interleave first and second lines | |
1291 movq_r2r(mm7, mm4); // copy third line | |
1292 | |
1293 punpcklwd_m2r(*(dataptr+6), mm7); // m31:m21|m30:m20 - interleave third and fourth lines | |
1294 movq_r2r(mm0, mm1); // copy first intermediate result | |
1295 | |
1296 movq_m2r(*(dataptr+2), mm6); // m13:m12|m11:m10 - second line | |
1297 punpckldq_r2r(mm7, mm0); // m30:m20|m10:m00 - interleave to produce result 1 | |
1298 | |
1299 movq_m2r(*(dataptr+6), mm5); // m33:m32|m31:m30 - fourth line | |
1300 punpckhdq_r2r(mm7, mm1); // m31:m21|m11:m01 - interleave to produce result 2 | |
1301 | |
1302 movq_r2r(mm0, mm7); // write result 1 | |
1303 punpckhwd_r2r(mm6, mm2); // m13:m03|m12:m02 - interleave first and second lines | |
1304 | |
1305 psubw_m2r(*(dataptr+14), mm7); // tmp07=x0-x7 /* Stage 1 */ | |
1306 movq_r2r(mm1, mm6); // write result 2 | |
1307 | |
1308 paddw_m2r(*(dataptr+14), mm0); // tmp00=x0+x7 /* Stage 1 */ | |
1309 punpckhwd_r2r(mm5, mm4); // m33:m23|m32:m22 - interleave third and fourth lines | |
1310 | |
1311 paddw_m2r(*(dataptr+12), mm1); // tmp01=x1+x6 /* Stage 1 */ | |
1312 movq_r2r(mm2, mm3); // copy first intermediate result | |
1313 | |
1314 psubw_m2r(*(dataptr+12), mm6); // tmp06=x1-x6 /* Stage 1 */ | |
1315 punpckldq_r2r(mm4, mm2); // m32:m22|m12:m02 - interleave to produce result 3 | |
1316 | |
1317 movq_r2m(mm7, tmp7); // save tmp07 | |
1318 movq_r2r(mm2, mm5); // write result 3 | |
1319 | |
1320 movq_r2m(mm6, tmp6); // save tmp06 | |
1321 | |
1322 punpckhdq_r2r(mm4, mm3); // m33:m23|m13:m03 - interleave to produce result 4 | |
1323 | |
1324 paddw_m2r(*(dataptr+10), mm2); // tmp02=x2+x5 /* stage 1 */ | |
1325 movq_r2r(mm3, mm4); // write result 4 | |
1326 | |
1327 /************************************************************************************************ | |
1328 End of Transpose 2 | |
1329 ************************************************************************************************/ | |
1330 | |
1331 paddw_m2r(*(dataptr+8), mm3); // tmp03=x3+x4 /* stage 1*/ | |
1332 movq_r2r(mm0, mm7); | |
1333 | |
1334 psubw_m2r(*(dataptr+8), mm4); // tmp04=x3-x4 /* stage 1*/ | |
1335 movq_r2r(mm1, mm6); | |
1336 | |
1337 paddw_r2r(mm3, mm0); // tmp10 = tmp00 + tmp03 /* even 2 */ | |
1338 psubw_r2r(mm3, mm7); // tmp13 = tmp00 - tmp03 /* even 2 */ | |
1339 | |
1340 psubw_r2r(mm2, mm6); // tmp12 = tmp01 - tmp02 /* even 2 */ | |
1341 paddw_r2r(mm2, mm1); // tmp11 = tmp01 + tmp02 /* even 2 */ | |
1342 | |
1343 psubw_m2r(*(dataptr+10), mm5); // tmp05=x2-x5 /* stage 1*/ | |
1344 paddw_r2r(mm7, mm6); // tmp12 + tmp13 | |
1345 | |
1346 /* stage 3 */ | |
1347 | |
1348 movq_m2r(tmp6, mm2); | |
1349 movq_r2r(mm0, mm3); | |
1350 | |
1351 psllw_i2r(2, mm6); // m8 * 2^2 | |
1352 paddw_r2r(mm1, mm0); | |
1353 | |
1354 pmulhw_m2r(RTjpeg_C4, mm6); // z1 | |
1355 psubw_r2r(mm1, mm3); | |
1356 | |
1357 movq_r2m(mm0, *dataptr); | |
1358 movq_r2r(mm7, mm0); | |
1359 | |
1360 /* Odd part */ | |
1361 movq_r2m(mm3, *(dataptr+8)); | |
1362 paddw_r2r(mm5, mm4); // tmp10 | |
1363 | |
1364 movq_m2r(tmp7, mm3); | |
1365 paddw_r2r(mm6, mm0); // tmp32 | |
1366 | |
1367 paddw_r2r(mm2, mm5); // tmp11 | |
1368 psubw_r2r(mm6, mm7); // tmp33 | |
1369 | |
1370 movq_r2m(mm0, *(dataptr+4)); | |
1371 paddw_r2r(mm3, mm2); // tmp12 | |
1372 | |
1373 /* stage 4 */ | |
1374 movq_r2m(mm7, *(dataptr+12)); | |
1375 movq_r2r(mm4, mm1); // copy of tmp10 | |
1376 | |
1377 psubw_r2r(mm2, mm1); // tmp10 - tmp12 | |
1378 psllw_i2r(2, mm4); // m8 * 2^2 | |
1379 | |
1380 movq_m2r(RTjpeg_C2mC6, mm0); | |
1381 psllw_i2r(2, mm1); | |
1382 | |
1383 pmulhw_m2r(RTjpeg_C6, mm1); // z5 | |
1384 psllw_i2r(2, mm2); | |
1385 | |
1386 pmulhw_r2r(mm0, mm4); // z5 | |
1387 | |
1388 /* stage 5 */ | |
1389 | |
1390 pmulhw_m2r(RTjpeg_C2pC6, mm2); | |
1391 psllw_i2r(2, mm5); | |
1392 | |
1393 pmulhw_m2r(RTjpeg_C4, mm5); // z3 | |
1394 movq_r2r(mm3, mm0); // copy tmp7 | |
1395 | |
1396 movq_m2r(*(dataptr+1), mm7); | |
1397 paddw_r2r(mm1, mm4); // z2 | |
1398 | |
1399 paddw_r2r(mm1, mm2); // z4 | |
1400 | |
1401 paddw_r2r(mm5, mm0); // z11 | |
1402 psubw_r2r(mm5, mm3); // z13 | |
1403 | |
1404 /* stage 6 */ | |
1405 | |
1406 movq_r2r(mm3, mm5); // copy z13 | |
1407 psubw_r2r(mm4, mm3); // y3=z13 - z2 | |
1408 | |
1409 paddw_r2r(mm4, mm5); // y5=z13 + z2 | |
1410 movq_r2r(mm0, mm6); // copy z11 | |
1411 | |
1412 movq_r2m(mm3, *(dataptr+6)); //save y3 | |
1413 psubw_r2r(mm2, mm0); // y7=z11 - z4 | |
1414 | |
1415 movq_r2m(mm5, *(dataptr+10)); //save y5 | |
1416 paddw_r2r(mm2, mm6); // y1=z11 + z4 | |
1417 | |
1418 movq_r2m(mm0, *(dataptr+14)); //save y7 | |
1419 | |
1420 /************************************************ | |
1421 * End of 1st 4 rows | |
1422 ************************************************/ | |
1423 | |
1424 movq_m2r(*(dataptr+3), mm1); // load x1 /* stage 1 */ | |
1425 movq_r2r(mm7, mm0); // copy x0 | |
1426 | |
1427 movq_r2m(mm6, *(dataptr+2)); //save y1 | |
1428 | |
1429 movq_m2r(*(dataptr+5), mm2); // load x2 /* stage 1 */ | |
1430 movq_r2r(mm1, mm6); // copy x1 | |
1431 | |
1432 paddw_m2r(*(dataptr+15), mm0); // tmp00 = x0 + x7 | |
1433 | |
1434 movq_m2r(*(dataptr+7), mm3); // load x3 /* stage 1 */ | |
1435 movq_r2r(mm2, mm5); // copy x2 | |
1436 | |
1437 psubw_m2r(*(dataptr+15), mm7); // tmp07 = x0 - x7 | |
1438 movq_r2r(mm3, mm4); // copy x3 | |
1439 | |
1440 paddw_m2r(*(dataptr+13), mm1); // tmp01 = x1 + x6 | |
1441 | |
1442 movq_r2m(mm7, tmp7); // save tmp07 | |
1443 movq_r2r(mm0, mm7); // copy tmp00 | |
1444 | |
1445 psubw_m2r(*(dataptr+13), mm6); // tmp06 = x1 - x6 | |
1446 | |
1447 /* stage 2, Even Part */ | |
1448 | |
1449 paddw_m2r(*(dataptr+9), mm3); // tmp03 = x3 + x4 | |
1450 | |
1451 movq_r2m(mm6, tmp6); // save tmp07 | |
1452 movq_r2r(mm1, mm6); // copy tmp01 | |
1453 | |
1454 paddw_m2r(*(dataptr+11), mm2); // tmp02 = x2 + x5 | |
1455 paddw_r2r(mm3, mm0); // tmp10 = tmp00 + tmp03 | |
1456 | |
1457 psubw_r2r(mm3, mm7); // tmp13 = tmp00 - tmp03 | |
1458 | |
1459 psubw_m2r(*(dataptr+9), mm4); // tmp04 = x3 - x4 | |
1460 psubw_r2r(mm2, mm6); // tmp12 = tmp01 - tmp02 | |
1461 | |
1462 paddw_r2r(mm2, mm1); // tmp11 = tmp01 + tmp02 | |
1463 | |
1464 psubw_m2r(*(dataptr+11), mm5); // tmp05 = x2 - x5 | |
1465 paddw_r2r(mm7, mm6); // tmp12 + tmp13 | |
1466 | |
1467 /* stage 3, Even and stage 4 & 5 even */ | |
1468 | |
1469 movq_m2r(tmp6, mm2); // load tmp6 | |
1470 movq_r2r(mm0, mm3); // copy tmp10 | |
1471 | |
1472 psllw_i2r(2, mm6); // shift z1 | |
1473 paddw_r2r(mm1, mm0); // y0=tmp10 + tmp11 | |
1474 | |
1475 pmulhw_m2r(RTjpeg_C4, mm6); // z1 | |
1476 psubw_r2r(mm1, mm3); // y4=tmp10 - tmp11 | |
1477 | |
1478 movq_r2m(mm0, *(dataptr+1)); //save y0 | |
1479 movq_r2r(mm7, mm0); // copy tmp13 | |
1480 | |
1481 /* odd part */ | |
1482 | |
1483 movq_r2m(mm3, *(dataptr+9)); //save y4 | |
1484 paddw_r2r(mm5, mm4); // tmp10 = tmp4 + tmp5 | |
1485 | |
1486 movq_m2r(tmp7, mm3); // load tmp7 | |
1487 paddw_r2r(mm6, mm0); // tmp32 = tmp13 + z1 | |
1488 | |
1489 paddw_r2r(mm2, mm5); // tmp11 = tmp5 + tmp6 | |
1490 psubw_r2r(mm6, mm7); // tmp33 = tmp13 - z1 | |
1491 | |
1492 movq_r2m(mm0, *(dataptr+5)); //save y2 | |
1493 paddw_r2r(mm3, mm2); // tmp12 = tmp6 + tmp7 | |
1494 | |
1495 /* stage 4 */ | |
1496 | |
1497 movq_r2m(mm7, *(dataptr+13)); //save y6 | |
1498 movq_r2r(mm4, mm1); // copy tmp10 | |
1499 | |
1500 psubw_r2r(mm2, mm1); // tmp10 - tmp12 | |
1501 psllw_i2r(2, mm4); // shift tmp10 | |
1502 | |
1503 movq_m2r(RTjpeg_C2mC6, mm0); // load C2mC6 | |
1504 psllw_i2r(2, mm1); // shift (tmp10-tmp12) | |
1505 | |
1506 pmulhw_m2r(RTjpeg_C6, mm1); // z5 | |
1507 psllw_i2r(2, mm5); // prepare for multiply | |
1508 | |
1509 pmulhw_r2r(mm0, mm4); // multiply by converted real | |
1510 | |
1511 /* stage 5 */ | |
1512 | |
1513 pmulhw_m2r(RTjpeg_C4, mm5); // z3 | |
1514 psllw_i2r(2, mm2); // prepare for multiply | |
1515 | |
1516 pmulhw_m2r(RTjpeg_C2pC6, mm2); // multiply | |
1517 movq_r2r(mm3, mm0); // copy tmp7 | |
1518 | |
1519 movq_m2r(*(dataptr+9), mm7); // m03:m02|m01:m00 - first line (line 4)and copy into mm7 | |
1520 paddw_r2r(mm1, mm4); // z2 | |
1521 | |
1522 paddw_r2r(mm5, mm0); // z11 | |
1523 psubw_r2r(mm5, mm3); // z13 | |
1524 | |
1525 /* stage 6 */ | |
1526 | |
1527 movq_r2r(mm3, mm5); // copy z13 | |
1528 paddw_r2r(mm1, mm2); // z4 | |
1529 | |
1530 movq_r2r(mm0, mm6); // copy z11 | |
1531 psubw_r2r(mm4, mm5); // y3 | |
1532 | |
1533 paddw_r2r(mm2, mm6); // y1 | |
1534 paddw_r2r(mm4, mm3); // y5 | |
1535 | |
1536 movq_r2m(mm5, *(dataptr+7)); //save y3 | |
1537 psubw_r2r(mm2, mm0); // yè=z11 - z4 | |
1538 | |
1539 movq_r2m(mm3, *(dataptr+11)); //save y5 | |
1540 | |
1541 movq_r2m(mm6, *(dataptr+3)); //save y1 | |
1542 | |
1543 movq_r2m(mm0, *(dataptr+15)); //save y7 | |
1544 | |
1545 | |
1546 #endif | |
1547 } | |
1548 | |
1549 #define FIX_1_082392200 ((__s32) 277) /* FIX(1.082392200) */ | |
1550 #define FIX_1_414213562 ((__s32) 362) /* FIX(1.414213562) */ | |
1551 #define FIX_1_847759065 ((__s32) 473) /* FIX(1.847759065) */ | |
1552 #define FIX_2_613125930 ((__s32) 669) /* FIX(2.613125930) */ | |
1553 | |
1554 #define DESCALE(x) (__s16)( ((x)+4) >> 3) | |
1555 | |
1556 /* clip yuv to 16..235 (should be 16..240 for cr/cb but ... */ | |
1557 | |
1558 #define RL(x) ((x)>235) ? 235 : (((x)<16) ? 16 : (x)) | |
1559 #define MULTIPLY(var,const) (((__s32) ((var) * (const)) + 128)>>8) | |
1560 | |
1561 void RTjpeg_idct_init(void) | |
1562 { | |
1563 int i; | |
1564 | |
1565 for(i=0; i<64; i++) | |
1566 { | |
1567 RTjpeg_liqt[i]=((__u64)RTjpeg_liqt[i]*RTjpeg_aan_tab[i])>>32; | |
1568 RTjpeg_ciqt[i]=((__u64)RTjpeg_ciqt[i]*RTjpeg_aan_tab[i])>>32; | |
1569 } | |
1570 } | |
1571 | |
1572 void RTjpeg_idct(__u8 *odata, __s16 *data, int rskip) | |
1573 { | |
1574 #ifdef MMX | |
1575 | |
12928 | 1576 static mmx_t fix_141 = {0x5a825a825a825a82LL}; |
1577 static mmx_t fix_184n261 = {0xcf04cf04cf04cf04LL}; | |
1578 static mmx_t fix_184 = {0x7641764176417641LL}; | |
1579 static mmx_t fix_n184 = {0x896f896f896f896fLL}; | |
1580 static mmx_t fix_108n184 = {0xcf04cf04cf04cf04LL}; | |
3802 | 1581 |
1582 mmx_t workspace[64]; | |
1583 mmx_t *wsptr = workspace; | |
1584 register mmx_t *dataptr = (mmx_t *)odata; | |
1585 mmx_t *idata = (mmx_t *)data; | |
1586 | |
1587 rskip = rskip>>3; | |
1588 /* | |
1589 * Perform inverse DCT on one block of coefficients. | |
1590 */ | |
1591 | |
1592 /* Odd part */ | |
1593 | |
1594 movq_m2r(*(idata+10), mm1); // load idata[DCTSIZE*5] | |
1595 | |
1596 movq_m2r(*(idata+6), mm0); // load idata[DCTSIZE*3] | |
1597 | |
1598 movq_m2r(*(idata+2), mm3); // load idata[DCTSIZE*1] | |
1599 | |
1600 movq_r2r(mm1, mm2); // copy tmp6 /* phase 6 */ | |
1601 | |
1602 movq_m2r(*(idata+14), mm4); // load idata[DCTSIZE*7] | |
1603 | |
1604 paddw_r2r(mm0, mm1); // z13 = tmp6 + tmp5; | |
1605 | |
1606 psubw_r2r(mm0, mm2); // z10 = tmp6 - tmp5 | |
1607 | |
1608 psllw_i2r(2, mm2); // shift z10 | |
1609 movq_r2r(mm2, mm0); // copy z10 | |
1610 | |
1611 pmulhw_m2r(fix_184n261, mm2); // MULTIPLY( z12, FIX_1_847759065); /* 2*c2 */ | |
1612 movq_r2r(mm3, mm5); // copy tmp4 | |
1613 | |
1614 pmulhw_m2r(fix_n184, mm0); // MULTIPLY(z10, -FIX_1_847759065); /* 2*c2 */ | |
1615 paddw_r2r(mm4, mm3); // z11 = tmp4 + tmp7; | |
1616 | |
1617 movq_r2r(mm3, mm6); // copy z11 /* phase 5 */ | |
1618 psubw_r2r(mm4, mm5); // z12 = tmp4 - tmp7; | |
1619 | |
1620 psubw_r2r(mm1, mm6); // z11-z13 | |
1621 psllw_i2r(2, mm5); // shift z12 | |
1622 | |
1623 movq_m2r(*(idata+12), mm4); // load idata[DCTSIZE*6], even part | |
1624 movq_r2r(mm5, mm7); // copy z12 | |
1625 | |
1626 pmulhw_m2r(fix_108n184, mm5); // MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; /* 2*(c2-c6) */ even part | |
1627 paddw_r2r(mm1, mm3); // tmp7 = z11 + z13; | |
1628 | |
1629 //ok | |
1630 | |
1631 /* Even part */ | |
1632 pmulhw_m2r(fix_184, mm7); // MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; /* -2*(c2+c6) */ | |
1633 psllw_i2r(2, mm6); | |
1634 | |
1635 movq_m2r(*(idata+4), mm1); // load idata[DCTSIZE*2] | |
1636 | |
1637 paddw_r2r(mm5, mm0); // tmp10 | |
1638 | |
1639 paddw_r2r(mm7, mm2); // tmp12 | |
1640 | |
1641 pmulhw_m2r(fix_141, mm6); // tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ | |
1642 psubw_r2r(mm3, mm2); // tmp6 = tmp12 - tmp7 | |
1643 | |
1644 movq_r2r(mm1, mm5); // copy tmp1 | |
1645 paddw_r2r(mm4, mm1); // tmp13= tmp1 + tmp3; /* phases 5-3 */ | |
1646 | |
1647 psubw_r2r(mm4, mm5); // tmp1-tmp3 | |
1648 psubw_r2r(mm2, mm6); // tmp5 = tmp11 - tmp6; | |
1649 | |
1650 movq_r2m(mm1, *(wsptr)); // save tmp13 in workspace | |
1651 psllw_i2r(2, mm5); // shift tmp1-tmp3 | |
1652 | |
1653 movq_m2r(*(idata), mm7); // load idata[DCTSIZE*0] | |
1654 | |
1655 pmulhw_m2r(fix_141, mm5); // MULTIPLY(tmp1 - tmp3, FIX_1_414213562) | |
1656 paddw_r2r(mm6, mm0); // tmp4 = tmp10 + tmp5; | |
1657 | |
1658 movq_m2r(*(idata+8), mm4); // load idata[DCTSIZE*4] | |
1659 | |
1660 psubw_r2r(mm1, mm5); // tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ | |
1661 | |
1662 movq_r2m(mm0, *(wsptr+4)); // save tmp4 in workspace | |
1663 movq_r2r(mm7, mm1); // copy tmp0 /* phase 3 */ | |
1664 | |
1665 movq_r2m(mm5, *(wsptr+2)); // save tmp12 in workspace | |
1666 psubw_r2r(mm4, mm1); // tmp11 = tmp0 - tmp2; | |
1667 | |
1668 paddw_r2r(mm4, mm7); // tmp10 = tmp0 + tmp2; | |
1669 movq_r2r(mm1, mm5); // copy tmp11 | |
1670 | |
1671 paddw_m2r(*(wsptr+2), mm1); // tmp1 = tmp11 + tmp12; | |
1672 movq_r2r(mm7, mm4); // copy tmp10 /* phase 2 */ | |
1673 | |
1674 paddw_m2r(*(wsptr), mm7); // tmp0 = tmp10 + tmp13; | |
1675 | |
1676 psubw_m2r(*(wsptr), mm4); // tmp3 = tmp10 - tmp13; | |
1677 movq_r2r(mm7, mm0); // copy tmp0 | |
1678 | |
1679 psubw_m2r(*(wsptr+2), mm5); // tmp2 = tmp11 - tmp12; | |
1680 paddw_r2r(mm3, mm7); // wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); | |
1681 | |
1682 psubw_r2r(mm3, mm0); // wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); | |
1683 | |
1684 movq_r2m(mm7, *(wsptr)); // wsptr[DCTSIZE*0] | |
1685 movq_r2r(mm1, mm3); // copy tmp1 | |
1686 | |
1687 movq_r2m(mm0, *(wsptr+14)); // wsptr[DCTSIZE*7] | |
1688 paddw_r2r(mm2, mm1); // wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); | |
1689 | |
1690 psubw_r2r(mm2, mm3); // wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); | |
1691 | |
1692 movq_r2m(mm1, *(wsptr+2)); // wsptr[DCTSIZE*1] | |
1693 movq_r2r(mm4, mm1); // copy tmp3 | |
1694 | |
1695 movq_r2m(mm3, *(wsptr+12)); // wsptr[DCTSIZE*6] | |
1696 | |
1697 paddw_m2r(*(wsptr+4), mm4); // wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); | |
1698 | |
1699 psubw_m2r(*(wsptr+4), mm1); // wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); | |
1700 | |
1701 movq_r2m(mm4, *(wsptr+8)); | |
1702 movq_r2r(mm5, mm7); // copy tmp2 | |
1703 | |
1704 paddw_r2r(mm6, mm5); // wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) | |
1705 | |
1706 movq_r2m(mm1, *(wsptr+6)); | |
1707 psubw_r2r(mm6, mm7); // wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); | |
1708 | |
1709 movq_r2m(mm5, *(wsptr+4)); | |
1710 | |
1711 movq_r2m(mm7, *(wsptr+10)); | |
1712 | |
1713 //ok | |
1714 | |
1715 | |
1716 /*****************************************************************/ | |
1717 | |
1718 idata++; | |
1719 wsptr++; | |
1720 | |
1721 /*****************************************************************/ | |
1722 | |
1723 movq_m2r(*(idata+10), mm1); // load idata[DCTSIZE*5] | |
1724 | |
1725 movq_m2r(*(idata+6), mm0); // load idata[DCTSIZE*3] | |
1726 | |
1727 movq_m2r(*(idata+2), mm3); // load idata[DCTSIZE*1] | |
1728 movq_r2r(mm1, mm2); // copy tmp6 /* phase 6 */ | |
1729 | |
1730 movq_m2r(*(idata+14), mm4); // load idata[DCTSIZE*7] | |
1731 paddw_r2r(mm0, mm1); // z13 = tmp6 + tmp5; | |
1732 | |
1733 psubw_r2r(mm0, mm2); // z10 = tmp6 - tmp5 | |
1734 | |
1735 psllw_i2r(2, mm2); // shift z10 | |
1736 movq_r2r(mm2, mm0); // copy z10 | |
1737 | |
1738 pmulhw_m2r(fix_184n261, mm2); // MULTIPLY( z12, FIX_1_847759065); /* 2*c2 */ | |
1739 movq_r2r(mm3, mm5); // copy tmp4 | |
1740 | |
1741 pmulhw_m2r(fix_n184, mm0); // MULTIPLY(z10, -FIX_1_847759065); /* 2*c2 */ | |
1742 paddw_r2r(mm4, mm3); // z11 = tmp4 + tmp7; | |
1743 | |
1744 movq_r2r(mm3, mm6); // copy z11 /* phase 5 */ | |
1745 psubw_r2r(mm4, mm5); // z12 = tmp4 - tmp7; | |
1746 | |
1747 psubw_r2r(mm1, mm6); // z11-z13 | |
1748 psllw_i2r(2, mm5); // shift z12 | |
1749 | |
1750 movq_m2r(*(idata+12), mm4); // load idata[DCTSIZE*6], even part | |
1751 movq_r2r(mm5, mm7); // copy z12 | |
1752 | |
1753 pmulhw_m2r(fix_108n184, mm5); // MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; /* 2*(c2-c6) */ even part | |
1754 paddw_r2r(mm1, mm3); // tmp7 = z11 + z13; | |
1755 | |
1756 //ok | |
1757 | |
1758 /* Even part */ | |
1759 pmulhw_m2r(fix_184, mm7); // MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; /* -2*(c2+c6) */ | |
1760 psllw_i2r(2, mm6); | |
1761 | |
1762 movq_m2r(*(idata+4), mm1); // load idata[DCTSIZE*2] | |
1763 | |
1764 paddw_r2r(mm5, mm0); // tmp10 | |
1765 | |
1766 paddw_r2r(mm7, mm2); // tmp12 | |
1767 | |
1768 pmulhw_m2r(fix_141, mm6); // tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ | |
1769 psubw_r2r(mm3, mm2); // tmp6 = tmp12 - tmp7 | |
1770 | |
1771 movq_r2r(mm1, mm5); // copy tmp1 | |
1772 paddw_r2r(mm4, mm1); // tmp13= tmp1 + tmp3; /* phases 5-3 */ | |
1773 | |
1774 psubw_r2r(mm4, mm5); // tmp1-tmp3 | |
1775 psubw_r2r(mm2, mm6); // tmp5 = tmp11 - tmp6; | |
1776 | |
1777 movq_r2m(mm1, *(wsptr)); // save tmp13 in workspace | |
1778 psllw_i2r(2, mm5); // shift tmp1-tmp3 | |
1779 | |
1780 movq_m2r(*(idata), mm7); // load idata[DCTSIZE*0] | |
1781 paddw_r2r(mm6, mm0); // tmp4 = tmp10 + tmp5; | |
1782 | |
1783 pmulhw_m2r(fix_141, mm5); // MULTIPLY(tmp1 - tmp3, FIX_1_414213562) | |
1784 | |
1785 movq_m2r(*(idata+8), mm4); // load idata[DCTSIZE*4] | |
1786 | |
1787 psubw_r2r(mm1, mm5); // tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ | |
1788 | |
1789 movq_r2m(mm0, *(wsptr+4)); // save tmp4 in workspace | |
1790 movq_r2r(mm7, mm1); // copy tmp0 /* phase 3 */ | |
1791 | |
1792 movq_r2m(mm5, *(wsptr+2)); // save tmp12 in workspace | |
1793 psubw_r2r(mm4, mm1); // tmp11 = tmp0 - tmp2; | |
1794 | |
1795 paddw_r2r(mm4, mm7); // tmp10 = tmp0 + tmp2; | |
1796 movq_r2r(mm1, mm5); // copy tmp11 | |
1797 | |
1798 paddw_m2r(*(wsptr+2), mm1); // tmp1 = tmp11 + tmp12; | |
1799 movq_r2r(mm7, mm4); // copy tmp10 /* phase 2 */ | |
1800 | |
1801 paddw_m2r(*(wsptr), mm7); // tmp0 = tmp10 + tmp13; | |
1802 | |
1803 psubw_m2r(*(wsptr), mm4); // tmp3 = tmp10 - tmp13; | |
1804 movq_r2r(mm7, mm0); // copy tmp0 | |
1805 | |
1806 psubw_m2r(*(wsptr+2), mm5); // tmp2 = tmp11 - tmp12; | |
1807 paddw_r2r(mm3, mm7); // wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); | |
1808 | |
1809 psubw_r2r(mm3, mm0); // wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); | |
1810 | |
1811 movq_r2m(mm7, *(wsptr)); // wsptr[DCTSIZE*0] | |
1812 movq_r2r(mm1, mm3); // copy tmp1 | |
1813 | |
1814 movq_r2m(mm0, *(wsptr+14)); // wsptr[DCTSIZE*7] | |
1815 paddw_r2r(mm2, mm1); // wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); | |
1816 | |
1817 psubw_r2r(mm2, mm3); // wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); | |
1818 | |
1819 movq_r2m(mm1, *(wsptr+2)); // wsptr[DCTSIZE*1] | |
1820 movq_r2r(mm4, mm1); // copy tmp3 | |
1821 | |
1822 movq_r2m(mm3, *(wsptr+12)); // wsptr[DCTSIZE*6] | |
1823 | |
1824 paddw_m2r(*(wsptr+4), mm4); // wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); | |
1825 | |
1826 psubw_m2r(*(wsptr+4), mm1); // wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); | |
1827 | |
1828 movq_r2m(mm4, *(wsptr+8)); | |
1829 movq_r2r(mm5, mm7); // copy tmp2 | |
1830 | |
1831 paddw_r2r(mm6, mm5); // wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) | |
1832 | |
1833 movq_r2m(mm1, *(wsptr+6)); | |
1834 psubw_r2r(mm6, mm7); // wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); | |
1835 | |
1836 movq_r2m(mm5, *(wsptr+4)); | |
1837 | |
1838 movq_r2m(mm7, *(wsptr+10)); | |
1839 | |
1840 /*****************************************************************/ | |
1841 | |
1842 /* Pass 2: process rows from work array, store into output array. */ | |
1843 /* Note that we must descale the results by a factor of 8 == 2**3, */ | |
1844 /* and also undo the PASS1_BITS scaling. */ | |
1845 | |
1846 /*****************************************************************/ | |
1847 /* Even part */ | |
1848 | |
1849 wsptr--; | |
1850 | |
1851 // tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); | |
1852 // tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); | |
1853 // tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); | |
1854 // tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]); | |
1855 movq_m2r(*(wsptr), mm0); // wsptr[0,0],[0,1],[0,2],[0,3] | |
1856 | |
1857 movq_m2r(*(wsptr+1), mm1); // wsptr[0,4],[0,5],[0,6],[0,7] | |
1858 movq_r2r(mm0, mm2); | |
1859 | |
1860 movq_m2r(*(wsptr+2), mm3); // wsptr[1,0],[1,1],[1,2],[1,3] | |
1861 paddw_r2r(mm1, mm0); // wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] | |
1862 | |
1863 movq_m2r(*(wsptr+3), mm4); // wsptr[1,4],[1,5],[1,6],[1,7] | |
1864 psubw_r2r(mm1, mm2); // wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] | |
1865 | |
1866 movq_r2r(mm0, mm6); | |
1867 movq_r2r(mm3, mm5); | |
1868 | |
1869 paddw_r2r(mm4, mm3); // wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] | |
1870 movq_r2r(mm2, mm1); | |
1871 | |
1872 psubw_r2r(mm4, mm5); // wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] | |
1873 punpcklwd_r2r(mm3, mm0); // wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] | |
1874 | |
1875 movq_m2r(*(wsptr+7), mm7); // wsptr[3,4],[3,5],[3,6],[3,7] | |
1876 punpckhwd_r2r(mm3, mm6); // wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] | |
1877 | |
1878 movq_m2r(*(wsptr+4), mm3); // wsptr[2,0],[2,1],[2,2],[2,3] | |
1879 punpckldq_r2r(mm6, mm0); // wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] | |
1880 | |
1881 punpcklwd_r2r(mm5, mm1); // wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] | |
1882 movq_r2r(mm3, mm4); | |
1883 | |
1884 movq_m2r(*(wsptr+6), mm6); // wsptr[3,0],[3,1],[3,2],[3,3] | |
1885 punpckhwd_r2r(mm5, mm2); // wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] | |
1886 | |
1887 movq_m2r(*(wsptr+5), mm5); // wsptr[2,4],[2,5],[2,6],[2,7] | |
1888 punpckldq_r2r(mm2, mm1); // wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] | |
1889 | |
1890 | |
1891 paddw_r2r(mm5, mm3); // wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] | |
1892 movq_r2r(mm6, mm2); | |
1893 | |
1894 psubw_r2r(mm5, mm4); // wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] | |
1895 paddw_r2r(mm7, mm6); // wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] | |
1896 | |
1897 movq_r2r(mm3, mm5); | |
1898 punpcklwd_r2r(mm6, mm3); // wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] | |
1899 | |
1900 psubw_r2r(mm7, mm2); // wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] | |
1901 punpckhwd_r2r(mm6, mm5); // wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] | |
1902 | |
1903 movq_r2r(mm4, mm7); | |
1904 punpckldq_r2r(mm5, mm3); // wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] | |
1905 | |
1906 punpcklwd_r2r(mm2, mm4); // wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] | |
1907 | |
1908 punpckhwd_r2r(mm2, mm7); // wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] | |
1909 | |
1910 punpckldq_r2r(mm7, mm4); // wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] | |
1911 movq_r2r(mm1, mm6); | |
1912 | |
1913 //ok | |
1914 | |
1915 // mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] | |
1916 // mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] | |
1917 | |
1918 | |
1919 movq_r2r(mm0, mm2); | |
1920 punpckhdq_r2r(mm4, mm6); // wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] | |
1921 | |
1922 punpckldq_r2r(mm4, mm1); // wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] | |
1923 psllw_i2r(2, mm6); | |
1924 | |
1925 pmulhw_m2r(fix_141, mm6); | |
1926 punpckldq_r2r(mm3, mm0); // wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] | |
1927 | |
1928 punpckhdq_r2r(mm3, mm2); // wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] | |
1929 movq_r2r(mm0, mm7); | |
1930 | |
1931 // tmp0 = tmp10 + tmp13; | |
1932 // tmp3 = tmp10 - tmp13; | |
1933 paddw_r2r(mm2, mm0); // [0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] | |
1934 psubw_r2r(mm2, mm7); // [0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] | |
1935 | |
1936 // tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13; | |
1937 psubw_r2r(mm2, mm6); // wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] | |
1938 // tmp1 = tmp11 + tmp12; | |
1939 // tmp2 = tmp11 - tmp12; | |
1940 movq_r2r(mm1, mm5); | |
1941 | |
1942 //OK | |
1943 | |
1944 /* Odd part */ | |
1945 | |
1946 // z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; | |
1947 // z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; | |
1948 // z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; | |
1949 // z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; | |
1950 movq_m2r(*(wsptr), mm3); // wsptr[0,0],[0,1],[0,2],[0,3] | |
1951 paddw_r2r(mm6, mm1); // [0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] | |
1952 | |
1953 movq_m2r(*(wsptr+1), mm4); // wsptr[0,4],[0,5],[0,6],[0,7] | |
1954 psubw_r2r(mm6, mm5); // [0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] | |
1955 | |
1956 movq_r2r(mm3, mm6); | |
1957 punpckldq_r2r(mm4, mm3); // wsptr[0,0],[0,1],[0,4],[0,5] | |
1958 | |
1959 punpckhdq_r2r(mm6, mm4); // wsptr[0,6],[0,7],[0,2],[0,3] | |
1960 movq_r2r(mm3, mm2); | |
1961 | |
1962 //Save tmp0 and tmp1 in wsptr | |
1963 movq_r2m(mm0, *(wsptr)); // save tmp0 | |
1964 paddw_r2r(mm4, mm2); // wsptr[xxx],[0,z11],[xxx],[0,z13] | |
1965 | |
1966 | |
1967 //Continue with z10 --- z13 | |
1968 movq_m2r(*(wsptr+2), mm6); // wsptr[1,0],[1,1],[1,2],[1,3] | |
1969 psubw_r2r(mm4, mm3); // wsptr[xxx],[0,z12],[xxx],[0,z10] | |
1970 | |
1971 movq_m2r(*(wsptr+3), mm0); // wsptr[1,4],[1,5],[1,6],[1,7] | |
1972 movq_r2r(mm6, mm4); | |
1973 | |
1974 movq_r2m(mm1, *(wsptr+1)); // save tmp1 | |
1975 punpckldq_r2r(mm0, mm6); // wsptr[1,0],[1,1],[1,4],[1,5] | |
1976 | |
1977 punpckhdq_r2r(mm4, mm0); // wsptr[1,6],[1,7],[1,2],[1,3] | |
1978 movq_r2r(mm6, mm1); | |
1979 | |
1980 //Save tmp2 and tmp3 in wsptr | |
1981 paddw_r2r(mm0, mm6); // wsptr[xxx],[1,z11],[xxx],[1,z13] | |
1982 movq_r2r(mm2, mm4); | |
1983 | |
1984 //Continue with z10 --- z13 | |
1985 movq_r2m(mm5, *(wsptr+2)); // save tmp2 | |
1986 punpcklwd_r2r(mm6, mm2); // wsptr[xxx],[xxx],[0,z11],[1,z11] | |
1987 | |
1988 psubw_r2r(mm0, mm1); // wsptr[xxx],[1,z12],[xxx],[1,z10] | |
1989 punpckhwd_r2r(mm6, mm4); // wsptr[xxx],[xxx],[0,z13],[1,z13] | |
1990 | |
1991 movq_r2r(mm3, mm0); | |
1992 punpcklwd_r2r(mm1, mm3); // wsptr[xxx],[xxx],[0,z12],[1,z12] | |
1993 | |
1994 movq_r2m(mm7, *(wsptr+3)); // save tmp3 | |
1995 punpckhwd_r2r(mm1, mm0); // wsptr[xxx],[xxx],[0,z10],[1,z10] | |
1996 | |
1997 movq_m2r(*(wsptr+4), mm6); // wsptr[2,0],[2,1],[2,2],[2,3] | |
1998 punpckhdq_r2r(mm2, mm0); // wsptr[0,z10],[1,z10],[0,z11],[1,z11] | |
1999 | |
2000 movq_m2r(*(wsptr+5), mm7); // wsptr[2,4],[2,5],[2,6],[2,7] | |
2001 punpckhdq_r2r(mm4, mm3); // wsptr[0,z12],[1,z12],[0,z13],[1,z13] | |
2002 | |
2003 movq_m2r(*(wsptr+6), mm1); // wsptr[3,0],[3,1],[3,2],[3,3] | |
2004 movq_r2r(mm6, mm4); | |
2005 | |
2006 punpckldq_r2r(mm7, mm6); // wsptr[2,0],[2,1],[2,4],[2,5] | |
2007 movq_r2r(mm1, mm5); | |
2008 | |
2009 punpckhdq_r2r(mm4, mm7); // wsptr[2,6],[2,7],[2,2],[2,3] | |
2010 movq_r2r(mm6, mm2); | |
2011 | |
2012 movq_m2r(*(wsptr+7), mm4); // wsptr[3,4],[3,5],[3,6],[3,7] | |
2013 paddw_r2r(mm7, mm6); // wsptr[xxx],[2,z11],[xxx],[2,z13] | |
2014 | |
2015 psubw_r2r(mm7, mm2); // wsptr[xxx],[2,z12],[xxx],[2,z10] | |
2016 punpckldq_r2r(mm4, mm1); // wsptr[3,0],[3,1],[3,4],[3,5] | |
2017 | |
2018 punpckhdq_r2r(mm5, mm4); // wsptr[3,6],[3,7],[3,2],[3,3] | |
2019 movq_r2r(mm1, mm7); | |
2020 | |
2021 paddw_r2r(mm4, mm1); // wsptr[xxx],[3,z11],[xxx],[3,z13] | |
2022 psubw_r2r(mm4, mm7); // wsptr[xxx],[3,z12],[xxx],[3,z10] | |
2023 | |
2024 movq_r2r(mm6, mm5); | |
2025 punpcklwd_r2r(mm1, mm6); // wsptr[xxx],[xxx],[2,z11],[3,z11] | |
2026 | |
2027 punpckhwd_r2r(mm1, mm5); // wsptr[xxx],[xxx],[2,z13],[3,z13] | |
2028 movq_r2r(mm2, mm4); | |
2029 | |
2030 punpcklwd_r2r(mm7, mm2); // wsptr[xxx],[xxx],[2,z12],[3,z12] | |
2031 | |
2032 punpckhwd_r2r(mm7, mm4); // wsptr[xxx],[xxx],[2,z10],[3,z10] | |
2033 | |
2034 punpckhdq_r2r(mm6, mm4); /// wsptr[2,z10],[3,z10],[2,z11],[3,z11] | |
2035 | |
2036 punpckhdq_r2r(mm5, mm2); // wsptr[2,z12],[3,z12],[2,z13],[3,z13] | |
2037 movq_r2r(mm0, mm5); | |
2038 | |
2039 punpckldq_r2r(mm4, mm0); // wsptr[0,z10],[1,z10],[2,z10],[3,z10] | |
2040 | |
2041 punpckhdq_r2r(mm4, mm5); // wsptr[0,z11],[1,z11],[2,z11],[3,z11] | |
2042 movq_r2r(mm3, mm4); | |
2043 | |
2044 punpckhdq_r2r(mm2, mm4); // wsptr[0,z13],[1,z13],[2,z13],[3,z13] | |
2045 movq_r2r(mm5, mm1); | |
2046 | |
2047 punpckldq_r2r(mm2, mm3); // wsptr[0,z12],[1,z12],[2,z12],[3,z12] | |
2048 // tmp7 = z11 + z13; /* phase 5 */ | |
2049 // tmp8 = z11 - z13; /* phase 5 */ | |
2050 psubw_r2r(mm4, mm1); // tmp8 | |
2051 | |
2052 paddw_r2r(mm4, mm5); // tmp7 | |
2053 // tmp21 = MULTIPLY(tmp8, FIX_1_414213562); /* 2*c4 */ | |
2054 psllw_i2r(2, mm1); | |
2055 | |
2056 psllw_i2r(2, mm0); | |
2057 | |
2058 pmulhw_m2r(fix_141, mm1); // tmp21 | |
2059 // tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) /* 2*(c2-c6) */ | |
2060 // + MULTIPLY(z10, - FIX_1_847759065); /* 2*c2 */ | |
2061 psllw_i2r(2, mm3); | |
2062 movq_r2r(mm0, mm7); | |
2063 | |
2064 pmulhw_m2r(fix_n184, mm7); | |
2065 movq_r2r(mm3, mm6); | |
2066 | |
2067 movq_m2r(*(wsptr), mm2); // tmp0,final1 | |
2068 | |
2069 pmulhw_m2r(fix_108n184, mm6); | |
2070 // tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) /* -2*(c2+c6) */ | |
2071 // + MULTIPLY(z12, FIX_1_847759065); /* 2*c2 */ | |
2072 movq_r2r(mm2, mm4); // final1 | |
2073 | |
2074 pmulhw_m2r(fix_184n261, mm0); | |
2075 paddw_r2r(mm5, mm2); // tmp0+tmp7,final1 | |
2076 | |
2077 pmulhw_m2r(fix_184, mm3); | |
2078 psubw_r2r(mm5, mm4); // tmp0-tmp7,final1 | |
2079 | |
2080 // tmp6 = tmp22 - tmp7; /* phase 2 */ | |
2081 psraw_i2r(3, mm2); // outptr[0,0],[1,0],[2,0],[3,0],final1 | |
2082 | |
2083 paddw_r2r(mm6, mm7); // tmp20 | |
2084 psraw_i2r(3, mm4); // outptr[0,7],[1,7],[2,7],[3,7],final1 | |
2085 | |
2086 paddw_r2r(mm0, mm3); // tmp22 | |
2087 | |
2088 // tmp5 = tmp21 - tmp6; | |
2089 psubw_r2r(mm5, mm3); // tmp6 | |
2090 | |
2091 // tmp4 = tmp20 + tmp5; | |
2092 movq_m2r(*(wsptr+1), mm0); // tmp1,final2 | |
2093 psubw_r2r(mm3, mm1); // tmp5 | |
2094 | |
2095 movq_r2r(mm0, mm6); // final2 | |
2096 paddw_r2r(mm3, mm0); // tmp1+tmp6,final2 | |
2097 | |
2098 /* Final output stage: scale down by a factor of 8 and range-limit */ | |
2099 | |
2100 | |
2101 // outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) | |
2102 // & RANGE_MASK]; | |
2103 // outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) | |
2104 // & RANGE_MASK]; final1 | |
2105 | |
2106 | |
2107 // outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) | |
2108 // & RANGE_MASK]; | |
2109 // outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) | |
2110 // & RANGE_MASK]; final2 | |
2111 psubw_r2r(mm3, mm6); // tmp1-tmp6,final2 | |
2112 psraw_i2r(3, mm0); // outptr[0,1],[1,1],[2,1],[3,1] | |
2113 | |
2114 psraw_i2r(3, mm6); // outptr[0,6],[1,6],[2,6],[3,6] | |
2115 | |
2116 packuswb_r2r(mm4, mm0); // out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] | |
2117 | |
2118 movq_m2r(*(wsptr+2), mm5); // tmp2,final3 | |
2119 packuswb_r2r(mm6, mm2); // out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] | |
2120 | |
2121 // outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) | |
2122 // & RANGE_MASK]; | |
2123 // outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) | |
2124 // & RANGE_MASK]; final3 | |
2125 paddw_r2r(mm1, mm7); // tmp4 | |
2126 movq_r2r(mm5, mm3); | |
2127 | |
2128 paddw_r2r(mm1, mm5); // tmp2+tmp5 | |
2129 psubw_r2r(mm1, mm3); // tmp2-tmp5 | |
2130 | |
2131 psraw_i2r(3, mm5); // outptr[0,2],[1,2],[2,2],[3,2] | |
2132 | |
2133 movq_m2r(*(wsptr+3), mm4); // tmp3,final4 | |
2134 psraw_i2r(3, mm3); // outptr[0,5],[1,5],[2,5],[3,5] | |
2135 | |
2136 | |
2137 | |
2138 // outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) | |
2139 // & RANGE_MASK]; | |
2140 // outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) | |
2141 // & RANGE_MASK]; final4 | |
2142 movq_r2r(mm4, mm6); | |
2143 paddw_r2r(mm7, mm4); // tmp3+tmp4 | |
2144 | |
2145 psubw_r2r(mm7, mm6); // tmp3-tmp4 | |
2146 psraw_i2r(3, mm4); // outptr[0,4],[1,4],[2,4],[3,4] | |
2147 | |
2148 // mov ecx, [dataptr] | |
2149 | |
2150 psraw_i2r(3, mm6); // outptr[0,3],[1,3],[2,3],[3,3] | |
2151 | |
2152 packuswb_r2r(mm4, mm5); // out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] | |
2153 | |
2154 packuswb_r2r(mm3, mm6); // out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] | |
2155 movq_r2r(mm2, mm4); | |
2156 | |
2157 movq_r2r(mm5, mm7); | |
2158 punpcklbw_r2r(mm0, mm2); // out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] | |
2159 | |
2160 punpckhbw_r2r(mm0, mm4); // out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] | |
2161 movq_r2r(mm2, mm1); | |
2162 | |
2163 punpcklbw_r2r(mm6, mm5); // out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] | |
2164 | |
2165 // add dataptr, 4 | |
2166 | |
2167 punpckhbw_r2r(mm6, mm7); // out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] | |
2168 | |
2169 punpcklwd_r2r(mm5, mm2); // out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] | |
2170 | |
2171 // add ecx, output_col | |
2172 | |
2173 movq_r2r(mm7, mm6); | |
2174 punpckhwd_r2r(mm5, mm1); // out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] | |
2175 | |
2176 movq_r2r(mm2, mm0); | |
2177 punpcklwd_r2r(mm4, mm6); // out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] | |
2178 | |
2179 // mov idata, [dataptr] | |
2180 | |
2181 punpckldq_r2r(mm6, mm2); // out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] | |
2182 | |
2183 // add dataptr, 4 | |
2184 | |
2185 movq_r2r(mm1, mm3); | |
2186 | |
2187 // add idata, output_col | |
2188 | |
2189 punpckhwd_r2r(mm4, mm7); // out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] | |
2190 | |
2191 movq_r2m(mm2, *(dataptr)); | |
2192 | |
2193 punpckhdq_r2r(mm6, mm0); // out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] | |
2194 | |
2195 dataptr += rskip; | |
2196 movq_r2m(mm0, *(dataptr)); | |
2197 | |
2198 punpckldq_r2r(mm7, mm1); // out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] | |
2199 punpckhdq_r2r(mm7, mm3); // out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] | |
2200 | |
2201 dataptr += rskip; | |
2202 movq_r2m(mm1, *(dataptr)); | |
2203 | |
2204 dataptr += rskip; | |
2205 movq_r2m(mm3, *(dataptr)); | |
2206 | |
2207 /*******************************************************************/ | |
2208 | |
2209 wsptr += 8; | |
2210 | |
2211 /*******************************************************************/ | |
2212 | |
2213 // tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); | |
2214 // tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); | |
2215 // tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); | |
2216 // tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]); | |
2217 movq_m2r(*(wsptr), mm0); // wsptr[0,0],[0,1],[0,2],[0,3] | |
2218 | |
2219 movq_m2r(*(wsptr+1), mm1); // wsptr[0,4],[0,5],[0,6],[0,7] | |
2220 movq_r2r(mm0, mm2); | |
2221 | |
2222 movq_m2r(*(wsptr+2), mm3); // wsptr[1,0],[1,1],[1,2],[1,3] | |
2223 paddw_r2r(mm1, mm0); // wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] | |
2224 | |
2225 movq_m2r(*(wsptr+3), mm4); // wsptr[1,4],[1,5],[1,6],[1,7] | |
2226 psubw_r2r(mm1, mm2); // wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] | |
2227 | |
2228 movq_r2r(mm0, mm6); | |
2229 movq_r2r(mm3, mm5); | |
2230 | |
2231 paddw_r2r(mm4, mm3); // wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] | |
2232 movq_r2r(mm2, mm1); | |
2233 | |
2234 psubw_r2r(mm4, mm5); // wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] | |
2235 punpcklwd_r2r(mm3, mm0); // wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] | |
2236 | |
2237 movq_m2r(*(wsptr+7), mm7); // wsptr[3,4],[3,5],[3,6],[3,7] | |
2238 punpckhwd_r2r(mm3, mm6); // wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] | |
2239 | |
2240 movq_m2r(*(wsptr+4), mm3); // wsptr[2,0],[2,1],[2,2],[2,3] | |
2241 punpckldq_r2r(mm6, mm0); // wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] | |
2242 | |
2243 punpcklwd_r2r(mm5, mm1); // wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] | |
2244 movq_r2r(mm3, mm4); | |
2245 | |
2246 movq_m2r(*(wsptr+6), mm6); // wsptr[3,0],[3,1],[3,2],[3,3] | |
2247 punpckhwd_r2r(mm5, mm2); // wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] | |
2248 | |
2249 movq_m2r(*(wsptr+5), mm5); // wsptr[2,4],[2,5],[2,6],[2,7] | |
2250 punpckldq_r2r(mm2, mm1); // wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] | |
2251 | |
2252 paddw_r2r(mm5, mm3); // wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] | |
2253 movq_r2r(mm6, mm2); | |
2254 | |
2255 psubw_r2r(mm5, mm4); // wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] | |
2256 paddw_r2r(mm7, mm6); // wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] | |
2257 | |
2258 movq_r2r(mm3, mm5); | |
2259 punpcklwd_r2r(mm6, mm3); // wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] | |
2260 | |
2261 psubw_r2r(mm7, mm2); // wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] | |
2262 punpckhwd_r2r(mm6, mm5); // wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] | |
2263 | |
2264 movq_r2r(mm4, mm7); | |
2265 punpckldq_r2r(mm5, mm3); // wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] | |
2266 | |
2267 punpcklwd_r2r(mm2, mm4); // wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] | |
2268 | |
2269 punpckhwd_r2r(mm2, mm7); // wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] | |
2270 | |
2271 punpckldq_r2r(mm7, mm4); // wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] | |
2272 movq_r2r(mm1, mm6); | |
2273 | |
2274 //OK | |
2275 | |
2276 // mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] | |
2277 // mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] | |
2278 | |
2279 movq_r2r(mm0, mm2); | |
2280 punpckhdq_r2r(mm4, mm6); // wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] | |
2281 | |
2282 punpckldq_r2r(mm4, mm1); // wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] | |
2283 psllw_i2r(2, mm6); | |
2284 | |
2285 pmulhw_m2r(fix_141, mm6); | |
2286 punpckldq_r2r(mm3, mm0); // wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] | |
2287 | |
2288 punpckhdq_r2r(mm3, mm2); // wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] | |
2289 movq_r2r(mm0, mm7); | |
2290 | |
2291 // tmp0 = tmp10 + tmp13; | |
2292 // tmp3 = tmp10 - tmp13; | |
2293 paddw_r2r(mm2, mm0); // [0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] | |
2294 psubw_r2r(mm2, mm7); // [0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] | |
2295 | |
2296 // tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13; | |
2297 psubw_r2r(mm2, mm6); // wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] | |
2298 // tmp1 = tmp11 + tmp12; | |
2299 // tmp2 = tmp11 - tmp12; | |
2300 movq_r2r(mm1, mm5); | |
2301 | |
2302 //OK | |
2303 | |
2304 | |
2305 /* Odd part */ | |
2306 | |
2307 // z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; | |
2308 // z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; | |
2309 // z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; | |
2310 // z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; | |
2311 movq_m2r(*(wsptr), mm3); // wsptr[0,0],[0,1],[0,2],[0,3] | |
2312 paddw_r2r(mm6, mm1); // [0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] | |
2313 | |
2314 movq_m2r(*(wsptr+1), mm4); // wsptr[0,4],[0,5],[0,6],[0,7] | |
2315 psubw_r2r(mm6, mm5); // [0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] | |
2316 | |
2317 movq_r2r(mm3, mm6); | |
2318 punpckldq_r2r(mm4, mm3); // wsptr[0,0],[0,1],[0,4],[0,5] | |
2319 | |
2320 punpckhdq_r2r(mm6, mm4); // wsptr[0,6],[0,7],[0,2],[0,3] | |
2321 movq_r2r(mm3, mm2); | |
2322 | |
2323 //Save tmp0 and tmp1 in wsptr | |
2324 movq_r2m(mm0, *(wsptr)); // save tmp0 | |
2325 paddw_r2r(mm4, mm2); // wsptr[xxx],[0,z11],[xxx],[0,z13] | |
2326 | |
2327 | |
2328 //Continue with z10 --- z13 | |
2329 movq_m2r(*(wsptr+2), mm6); // wsptr[1,0],[1,1],[1,2],[1,3] | |
2330 psubw_r2r(mm4, mm3); // wsptr[xxx],[0,z12],[xxx],[0,z10] | |
2331 | |
2332 movq_m2r(*(wsptr+3), mm0); // wsptr[1,4],[1,5],[1,6],[1,7] | |
2333 movq_r2r(mm6, mm4); | |
2334 | |
2335 movq_r2m(mm1, *(wsptr+1)); // save tmp1 | |
2336 punpckldq_r2r(mm0, mm6); // wsptr[1,0],[1,1],[1,4],[1,5] | |
2337 | |
2338 punpckhdq_r2r(mm4, mm0); // wsptr[1,6],[1,7],[1,2],[1,3] | |
2339 movq_r2r(mm6, mm1); | |
2340 | |
2341 //Save tmp2 and tmp3 in wsptr | |
2342 paddw_r2r(mm0, mm6); // wsptr[xxx],[1,z11],[xxx],[1,z13] | |
2343 movq_r2r(mm2, mm4); | |
2344 | |
2345 //Continue with z10 --- z13 | |
2346 movq_r2m(mm5, *(wsptr+2)); // save tmp2 | |
2347 punpcklwd_r2r(mm6, mm2); // wsptr[xxx],[xxx],[0,z11],[1,z11] | |
2348 | |
2349 psubw_r2r(mm0, mm1); // wsptr[xxx],[1,z12],[xxx],[1,z10] | |
2350 punpckhwd_r2r(mm6, mm4); // wsptr[xxx],[xxx],[0,z13],[1,z13] | |
2351 | |
2352 movq_r2r(mm3, mm0); | |
2353 punpcklwd_r2r(mm1, mm3); // wsptr[xxx],[xxx],[0,z12],[1,z12] | |
2354 | |
2355 movq_r2m(mm7, *(wsptr+3)); // save tmp3 | |
2356 punpckhwd_r2r(mm1, mm0); // wsptr[xxx],[xxx],[0,z10],[1,z10] | |
2357 | |
2358 movq_m2r(*(wsptr+4), mm6); // wsptr[2,0],[2,1],[2,2],[2,3] | |
2359 punpckhdq_r2r(mm2, mm0); // wsptr[0,z10],[1,z10],[0,z11],[1,z11] | |
2360 | |
2361 movq_m2r(*(wsptr+5), mm7); // wsptr[2,4],[2,5],[2,6],[2,7] | |
2362 punpckhdq_r2r(mm4, mm3); // wsptr[0,z12],[1,z12],[0,z13],[1,z13] | |
2363 | |
2364 movq_m2r(*(wsptr+6), mm1); // wsptr[3,0],[3,1],[3,2],[3,3] | |
2365 movq_r2r(mm6, mm4); | |
2366 | |
2367 punpckldq_r2r(mm7, mm6); // wsptr[2,0],[2,1],[2,4],[2,5] | |
2368 movq_r2r(mm1, mm5); | |
2369 | |
2370 punpckhdq_r2r(mm4, mm7); // wsptr[2,6],[2,7],[2,2],[2,3] | |
2371 movq_r2r(mm6, mm2); | |
2372 | |
2373 movq_m2r(*(wsptr+7), mm4); // wsptr[3,4],[3,5],[3,6],[3,7] | |
2374 paddw_r2r(mm7, mm6); // wsptr[xxx],[2,z11],[xxx],[2,z13] | |
2375 | |
2376 psubw_r2r(mm7, mm2); // wsptr[xxx],[2,z12],[xxx],[2,z10] | |
2377 punpckldq_r2r(mm4, mm1); // wsptr[3,0],[3,1],[3,4],[3,5] | |
2378 | |
2379 punpckhdq_r2r(mm5, mm4); // wsptr[3,6],[3,7],[3,2],[3,3] | |
2380 movq_r2r(mm1, mm7); | |
2381 | |
2382 paddw_r2r(mm4, mm1); // wsptr[xxx],[3,z11],[xxx],[3,z13] | |
2383 psubw_r2r(mm4, mm7); // wsptr[xxx],[3,z12],[xxx],[3,z10] | |
2384 | |
2385 movq_r2r(mm6, mm5); | |
2386 punpcklwd_r2r(mm1, mm6); // wsptr[xxx],[xxx],[2,z11],[3,z11] | |
2387 | |
2388 punpckhwd_r2r(mm1, mm5); // wsptr[xxx],[xxx],[2,z13],[3,z13] | |
2389 movq_r2r(mm2, mm4); | |
2390 | |
2391 punpcklwd_r2r(mm7, mm2); // wsptr[xxx],[xxx],[2,z12],[3,z12] | |
2392 | |
2393 punpckhwd_r2r(mm7, mm4); // wsptr[xxx],[xxx],[2,z10],[3,z10] | |
2394 | |
2395 punpckhdq_r2r(mm6, mm4); // wsptr[2,z10],[3,z10],[2,z11],[3,z11] | |
2396 | |
2397 punpckhdq_r2r(mm5, mm2); // wsptr[2,z12],[3,z12],[2,z13],[3,z13] | |
2398 movq_r2r(mm0, mm5); | |
2399 | |
2400 punpckldq_r2r(mm4, mm0); // wsptr[0,z10],[1,z10],[2,z10],[3,z10] | |
2401 | |
2402 punpckhdq_r2r(mm4, mm5); // wsptr[0,z11],[1,z11],[2,z11],[3,z11] | |
2403 movq_r2r(mm3, mm4); | |
2404 | |
2405 punpckhdq_r2r(mm2, mm4); // wsptr[0,z13],[1,z13],[2,z13],[3,z13] | |
2406 movq_r2r(mm5, mm1); | |
2407 | |
2408 punpckldq_r2r(mm2, mm3); // wsptr[0,z12],[1,z12],[2,z12],[3,z12] | |
2409 // tmp7 = z11 + z13; /* phase 5 */ | |
2410 // tmp8 = z11 - z13; /* phase 5 */ | |
2411 psubw_r2r(mm4, mm1); // tmp8 | |
2412 | |
2413 paddw_r2r(mm4, mm5); // tmp7 | |
2414 // tmp21 = MULTIPLY(tmp8, FIX_1_414213562); /* 2*c4 */ | |
2415 psllw_i2r(2, mm1); | |
2416 | |
2417 psllw_i2r(2, mm0); | |
2418 | |
2419 pmulhw_m2r(fix_141, mm1); // tmp21 | |
2420 // tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) /* 2*(c2-c6) */ | |
2421 // + MULTIPLY(z10, - FIX_1_847759065); /* 2*c2 */ | |
2422 psllw_i2r(2, mm3); | |
2423 movq_r2r(mm0, mm7); | |
2424 | |
2425 pmulhw_m2r(fix_n184, mm7); | |
2426 movq_r2r(mm3, mm6); | |
2427 | |
2428 movq_m2r(*(wsptr), mm2); // tmp0,final1 | |
2429 | |
2430 pmulhw_m2r(fix_108n184, mm6); | |
2431 // tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) /* -2*(c2+c6) */ | |
2432 // + MULTIPLY(z12, FIX_1_847759065); /* 2*c2 */ | |
2433 movq_r2r(mm2, mm4); // final1 | |
2434 | |
2435 pmulhw_m2r(fix_184n261, mm0); | |
2436 paddw_r2r(mm5, mm2); // tmp0+tmp7,final1 | |
2437 | |
2438 pmulhw_m2r(fix_184, mm3); | |
2439 psubw_r2r(mm5, mm4); // tmp0-tmp7,final1 | |
2440 | |
2441 // tmp6 = tmp22 - tmp7; /* phase 2 */ | |
2442 psraw_i2r(3, mm2); // outptr[0,0],[1,0],[2,0],[3,0],final1 | |
2443 | |
2444 paddw_r2r(mm6, mm7); // tmp20 | |
2445 psraw_i2r(3, mm4); // outptr[0,7],[1,7],[2,7],[3,7],final1 | |
2446 | |
2447 paddw_r2r(mm0, mm3); // tmp22 | |
2448 | |
2449 // tmp5 = tmp21 - tmp6; | |
2450 psubw_r2r(mm5, mm3); // tmp6 | |
2451 | |
2452 // tmp4 = tmp20 + tmp5; | |
2453 movq_m2r(*(wsptr+1), mm0); // tmp1,final2 | |
2454 psubw_r2r(mm3, mm1); // tmp5 | |
2455 | |
2456 movq_r2r(mm0, mm6); // final2 | |
2457 paddw_r2r(mm3, mm0); // tmp1+tmp6,final2 | |
2458 | |
2459 /* Final output stage: scale down by a factor of 8 and range-limit */ | |
2460 | |
2461 // outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) | |
2462 // & RANGE_MASK]; | |
2463 // outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) | |
2464 // & RANGE_MASK]; final1 | |
2465 | |
2466 | |
2467 // outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) | |
2468 // & RANGE_MASK]; | |
2469 // outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) | |
2470 // & RANGE_MASK]; final2 | |
2471 psubw_r2r(mm3, mm6); // tmp1-tmp6,final2 | |
2472 psraw_i2r(3, mm0); // outptr[0,1],[1,1],[2,1],[3,1] | |
2473 | |
2474 psraw_i2r(3, mm6); // outptr[0,6],[1,6],[2,6],[3,6] | |
2475 | |
2476 packuswb_r2r(mm4, mm0); // out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] | |
2477 | |
2478 movq_m2r(*(wsptr+2), mm5); // tmp2,final3 | |
2479 packuswb_r2r(mm6, mm2); // out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] | |
2480 | |
2481 // outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) | |
2482 // & RANGE_MASK]; | |
2483 // outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) | |
2484 // & RANGE_MASK]; final3 | |
2485 paddw_r2r(mm1, mm7); // tmp4 | |
2486 movq_r2r(mm5, mm3); | |
2487 | |
2488 paddw_r2r(mm1, mm5); // tmp2+tmp5 | |
2489 psubw_r2r(mm1, mm3); // tmp2-tmp5 | |
2490 | |
2491 psraw_i2r(3, mm5); // outptr[0,2],[1,2],[2,2],[3,2] | |
2492 | |
2493 movq_m2r(*(wsptr+3), mm4); // tmp3,final4 | |
2494 psraw_i2r(3, mm3); // outptr[0,5],[1,5],[2,5],[3,5] | |
2495 | |
2496 | |
2497 | |
2498 // outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) | |
2499 // & RANGE_MASK]; | |
2500 // outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) | |
2501 // & RANGE_MASK]; final4 | |
2502 movq_r2r(mm4, mm6); | |
2503 paddw_r2r(mm7, mm4); // tmp3+tmp4 | |
2504 | |
2505 psubw_r2r(mm7, mm6); // tmp3-tmp4 | |
2506 psraw_i2r(3, mm4); // outptr[0,4],[1,4],[2,4],[3,4] | |
2507 | |
2508 psraw_i2r(3, mm6); // outptr[0,3],[1,3],[2,3],[3,3] | |
2509 | |
2510 /* | |
2511 movq_r2m(mm4, *dummy); | |
2512 fprintf(stderr, "3-4 %016llx\n", dummy); | |
2513 movq_r2m(mm4, *dummy); | |
2514 fprintf(stderr, "3+4 %016llx\n", dummy); | |
2515 */ | |
2516 | |
2517 | |
2518 packuswb_r2r(mm4, mm5); // out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] | |
2519 | |
2520 packuswb_r2r(mm3, mm6); // out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] | |
2521 movq_r2r(mm2, mm4); | |
2522 | |
2523 movq_r2r(mm5, mm7); | |
2524 punpcklbw_r2r(mm0, mm2); // out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] | |
2525 | |
2526 punpckhbw_r2r(mm0, mm4); // out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] | |
2527 movq_r2r(mm2, mm1); | |
2528 | |
2529 punpcklbw_r2r(mm6, mm5); // out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] | |
2530 | |
2531 punpckhbw_r2r(mm6, mm7); // out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] | |
2532 | |
2533 punpcklwd_r2r(mm5, mm2); // out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] | |
2534 | |
2535 movq_r2r(mm7, mm6); | |
2536 punpckhwd_r2r(mm5, mm1); // out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] | |
2537 | |
2538 movq_r2r(mm2, mm0); | |
2539 punpcklwd_r2r(mm4, mm6); // out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] | |
2540 | |
2541 punpckldq_r2r(mm6, mm2); // out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] | |
2542 | |
2543 movq_r2r(mm1, mm3); | |
2544 | |
2545 punpckhwd_r2r(mm4, mm7); // out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] | |
2546 | |
2547 dataptr += rskip; | |
2548 movq_r2m(mm2, *(dataptr)); | |
2549 | |
2550 punpckhdq_r2r(mm6, mm0); // out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] | |
2551 | |
2552 dataptr += rskip; | |
2553 movq_r2m(mm0, *(dataptr)); | |
2554 | |
2555 punpckldq_r2r(mm7, mm1); // out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] | |
2556 | |
2557 punpckhdq_r2r(mm7, mm3); // out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] | |
2558 | |
2559 dataptr += rskip; | |
2560 movq_r2m(mm1, *(dataptr)); | |
2561 | |
2562 dataptr += rskip; | |
2563 movq_r2m(mm3, *(dataptr)); | |
2564 | |
2565 #else | |
2566 __s32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | |
2567 __s32 tmp10, tmp11, tmp12, tmp13; | |
2568 __s32 z5, z10, z11, z12, z13; | |
2569 __s16 *inptr; | |
2570 __s32 *wsptr; | |
2571 __u8 *outptr; | |
2572 int ctr; | |
2573 __s32 dcval; | |
2574 __s32 workspace[64]; | |
2575 | |
2576 inptr = data; | |
2577 wsptr = workspace; | |
2578 for (ctr = 8; ctr > 0; ctr--) { | |
2579 | |
2580 if ((inptr[8] | inptr[16] | inptr[24] | | |
2581 inptr[32] | inptr[40] | inptr[48] | inptr[56]) == 0) { | |
2582 dcval = inptr[0]; | |
2583 wsptr[0] = dcval; | |
2584 wsptr[8] = dcval; | |
2585 wsptr[16] = dcval; | |
2586 wsptr[24] = dcval; | |
2587 wsptr[32] = dcval; | |
2588 wsptr[40] = dcval; | |
2589 wsptr[48] = dcval; | |
2590 wsptr[56] = dcval; | |
2591 | |
2592 inptr++; | |
2593 wsptr++; | |
2594 continue; | |
2595 } | |
2596 | |
2597 tmp0 = inptr[0]; | |
2598 tmp1 = inptr[16]; | |
2599 tmp2 = inptr[32]; | |
2600 tmp3 = inptr[48]; | |
2601 | |
2602 tmp10 = tmp0 + tmp2; | |
2603 tmp11 = tmp0 - tmp2; | |
2604 | |
2605 tmp13 = tmp1 + tmp3; | |
2606 tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; | |
2607 | |
2608 tmp0 = tmp10 + tmp13; | |
2609 tmp3 = tmp10 - tmp13; | |
2610 tmp1 = tmp11 + tmp12; | |
2611 tmp2 = tmp11 - tmp12; | |
2612 | |
2613 tmp4 = inptr[8]; | |
2614 tmp5 = inptr[24]; | |
2615 tmp6 = inptr[40]; | |
2616 tmp7 = inptr[56]; | |
2617 | |
2618 z13 = tmp6 + tmp5; | |
2619 z10 = tmp6 - tmp5; | |
2620 z11 = tmp4 + tmp7; | |
2621 z12 = tmp4 - tmp7; | |
2622 | |
2623 tmp7 = z11 + z13; | |
2624 tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); | |
2625 | |
2626 z5 = MULTIPLY(z10 + z12, FIX_1_847759065); | |
2627 tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; | |
2628 tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; | |
2629 | |
2630 tmp6 = tmp12 - tmp7; | |
2631 tmp5 = tmp11 - tmp6; | |
2632 tmp4 = tmp10 + tmp5; | |
2633 | |
2634 wsptr[0] = (__s32) (tmp0 + tmp7); | |
2635 wsptr[56] = (__s32) (tmp0 - tmp7); | |
2636 wsptr[8] = (__s32) (tmp1 + tmp6); | |
2637 wsptr[48] = (__s32) (tmp1 - tmp6); | |
2638 wsptr[16] = (__s32) (tmp2 + tmp5); | |
2639 wsptr[40] = (__s32) (tmp2 - tmp5); | |
2640 wsptr[32] = (__s32) (tmp3 + tmp4); | |
2641 wsptr[24] = (__s32) (tmp3 - tmp4); | |
2642 | |
2643 inptr++; | |
2644 wsptr++; | |
2645 } | |
2646 | |
2647 wsptr = workspace; | |
2648 for (ctr = 0; ctr < 8; ctr++) { | |
2649 outptr = &(odata[ctr*rskip]); | |
2650 | |
2651 tmp10 = wsptr[0] + wsptr[4]; | |
2652 tmp11 = wsptr[0] - wsptr[4]; | |
2653 | |
2654 tmp13 = wsptr[2] + wsptr[6]; | |
2655 tmp12 = MULTIPLY(wsptr[2] - wsptr[6], FIX_1_414213562) - tmp13; | |
2656 | |
2657 tmp0 = tmp10 + tmp13; | |
2658 tmp3 = tmp10 - tmp13; | |
2659 tmp1 = tmp11 + tmp12; | |
2660 tmp2 = tmp11 - tmp12; | |
2661 | |
2662 z13 = wsptr[5] + wsptr[3]; | |
2663 z10 = wsptr[5] - wsptr[3]; | |
2664 z11 = wsptr[1] + wsptr[7]; | |
2665 z12 = wsptr[1] - wsptr[7]; | |
2666 | |
2667 tmp7 = z11 + z13; | |
2668 tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); | |
2669 | |
2670 z5 = MULTIPLY(z10 + z12, FIX_1_847759065); | |
2671 tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; | |
2672 tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; | |
2673 | |
2674 tmp6 = tmp12 - tmp7; | |
2675 tmp5 = tmp11 - tmp6; | |
2676 tmp4 = tmp10 + tmp5; | |
2677 | |
2678 outptr[0] = RL(DESCALE(tmp0 + tmp7)); | |
2679 outptr[7] = RL(DESCALE(tmp0 - tmp7)); | |
2680 outptr[1] = RL(DESCALE(tmp1 + tmp6)); | |
2681 outptr[6] = RL(DESCALE(tmp1 - tmp6)); | |
2682 outptr[2] = RL(DESCALE(tmp2 + tmp5)); | |
2683 outptr[5] = RL(DESCALE(tmp2 - tmp5)); | |
2684 outptr[4] = RL(DESCALE(tmp3 + tmp4)); | |
2685 outptr[3] = RL(DESCALE(tmp3 - tmp4)); | |
2686 | |
2687 wsptr += 8; | |
2688 } | |
2689 #endif | |
2690 } | |
2691 /* | |
2692 | |
2693 Main Routines | |
2694 | |
2695 This file contains most of the initialisation and control functions | |
2696 | |
2697 (C) Justin Schoeman 1998 | |
2698 | |
2699 */ | |
2700 | |
2701 /* | |
2702 | |
2703 Private function | |
2704 | |
2705 Initialise all the cache-aliged data blocks | |
2706 | |
2707 */ | |
2708 | |
2709 void RTjpeg_init_data(void) | |
2710 { | |
2711 unsigned long dptr; | |
2712 | |
2713 dptr=(unsigned long)&(RTjpeg_alldata[0]); | |
2714 dptr+=32; | |
2715 dptr=dptr>>5; | |
2716 dptr=dptr<<5; /* cache align data */ | |
2717 | |
2718 RTjpeg_block=(__s16 *)dptr; | |
2719 dptr+=sizeof(__s16)*64; | |
2720 RTjpeg_lqt=(__s32 *)dptr; | |
2721 dptr+=sizeof(__s32)*64; | |
2722 RTjpeg_cqt=(__s32 *)dptr; | |
2723 dptr+=sizeof(__s32)*64; | |
2724 RTjpeg_liqt=(__u32 *)dptr; | |
2725 dptr+=sizeof(__u32)*64; | |
2726 RTjpeg_ciqt=(__u32 *)dptr; | |
2727 } | |
2728 | |
2729 /* | |
2730 | |
2731 External Function | |
2732 | |
2733 Re-set quality factor | |
2734 | |
2735 Input: buf -> pointer to 128 ints for quant values store to pass back to | |
2736 init_decompress. | |
2737 Q -> quality factor (192=best, 32=worst) | |
2738 */ | |
2739 | |
2740 void RTjpeg_init_Q(__u8 Q) | |
2741 { | |
2742 int i; | |
2743 __u64 qual; | |
2744 | |
2745 qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */ | |
2746 | |
2747 for(i=0; i<64; i++) | |
2748 { | |
2749 RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3); | |
2750 if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1; | |
2751 RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3); | |
2752 if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1; | |
2753 RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3); | |
2754 RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3); | |
2755 RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3; | |
2756 RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3; | |
2757 } | |
2758 | |
2759 RTjpeg_lb8=0; | |
2760 while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); | |
2761 RTjpeg_lb8--; | |
2762 RTjpeg_cb8=0; | |
2763 while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); | |
2764 RTjpeg_cb8--; | |
2765 | |
2766 RTjpeg_dct_init(); | |
2767 RTjpeg_idct_init(); | |
2768 RTjpeg_quant_init(); | |
2769 } | |
2770 | |
2771 /* | |
2772 | |
2773 External Function | |
2774 | |
2775 Initialise compression. | |
2776 | |
2777 Input: buf -> pointer to 128 ints for quant values store to pass back to | |
2778 init_decompress. | |
2779 width -> width of image | |
2780 height -> height of image | |
2781 Q -> quality factor (192=best, 32=worst) | |
2782 | |
2783 */ | |
2784 | |
2785 void RTjpeg_init_compress(__u32 *buf, int width, int height, __u8 Q) | |
2786 { | |
2787 int i; | |
2788 __u64 qual; | |
2789 | |
2790 RTjpeg_init_data(); | |
2791 | |
2792 RTjpeg_width=width; | |
2793 RTjpeg_height=height; | |
2794 RTjpeg_Ywidth = RTjpeg_width>>3; | |
2795 RTjpeg_Ysize=width * height; | |
2796 RTjpeg_Cwidth = RTjpeg_width>>4; | |
2797 RTjpeg_Csize= (width>>1) * height; | |
2798 | |
2799 qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */ | |
2800 | |
2801 for(i=0; i<64; i++) | |
2802 { | |
2803 RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3); | |
2804 if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1; | |
2805 RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3); | |
2806 if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1; | |
2807 RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3); | |
2808 RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3); | |
2809 RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3; | |
2810 RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3; | |
2811 } | |
2812 | |
2813 RTjpeg_lb8=0; | |
2814 while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); | |
2815 RTjpeg_lb8--; | |
2816 RTjpeg_cb8=0; | |
2817 while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); | |
2818 RTjpeg_cb8--; | |
2819 | |
2820 RTjpeg_dct_init(); | |
2821 RTjpeg_quant_init(); | |
2822 | |
2823 for(i=0; i<64; i++) | |
14896
9ddae5897422
Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents:
14642
diff
changeset
|
2824 buf[i]=le2me_32(RTjpeg_liqt[i]); |
3802 | 2825 for(i=0; i<64; i++) |
14896
9ddae5897422
Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents:
14642
diff
changeset
|
2826 buf[64+i]=le2me_32(RTjpeg_ciqt[i]); |
3802 | 2827 } |
2828 | |
2829 void RTjpeg_init_decompress(__u32 *buf, int width, int height) | |
2830 { | |
2831 int i; | |
2832 | |
2833 RTjpeg_init_data(); | |
2834 | |
2835 RTjpeg_width=width; | |
2836 RTjpeg_height=height; | |
2837 RTjpeg_Ywidth = RTjpeg_width>>3; | |
2838 RTjpeg_Ysize=width * height; | |
2839 RTjpeg_Cwidth = RTjpeg_width>>4; | |
2840 RTjpeg_Csize= (width>>1) * height; | |
2841 | |
2842 for(i=0; i<64; i++) | |
2843 { | |
14896
9ddae5897422
Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents:
14642
diff
changeset
|
2844 RTjpeg_liqt[i]=le2me_32(buf[i]); |
9ddae5897422
Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents:
14642
diff
changeset
|
2845 RTjpeg_ciqt[i]=le2me_32(buf[i+64]); |
3802 | 2846 } |
2847 | |
2848 RTjpeg_lb8=0; | |
2849 while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); | |
2850 RTjpeg_lb8--; | |
2851 RTjpeg_cb8=0; | |
2852 while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); | |
2853 RTjpeg_cb8--; | |
2854 | |
2855 RTjpeg_idct_init(); | |
2856 | |
2857 // RTjpeg_color_init(); | |
2858 } | |
2859 | |
2860 int RTjpeg_compressYUV420(__s8 *sp, unsigned char *bp) | |
2861 { | |
2862 __s8 * sb; | |
2863 register __s8 * bp1 = bp + (RTjpeg_width<<3); | |
2864 register __s8 * bp2 = bp + RTjpeg_Ysize; | |
2865 register __s8 * bp3 = bp2 + (RTjpeg_Csize>>1); | |
2866 register int i, j, k; | |
2867 | |
2868 #ifdef MMX | |
2869 emms(); | |
2870 #endif | |
2871 sb=sp; | |
2872 /* Y */ | |
2873 for(i=RTjpeg_height>>1; i; i-=8) | |
2874 { | |
2875 for(j=0, k=0; j<RTjpeg_width; j+=16, k+=8) | |
2876 { | |
2877 RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_Ywidth); | |
2878 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
2879 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
2880 | |
2881 RTjpeg_dctY(bp+j+8, RTjpeg_block, RTjpeg_Ywidth); | |
2882 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
2883 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
2884 | |
2885 RTjpeg_dctY(bp1+j, RTjpeg_block, RTjpeg_Ywidth); | |
2886 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
2887 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
2888 | |
2889 RTjpeg_dctY(bp1+j+8, RTjpeg_block, RTjpeg_Ywidth); | |
2890 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
2891 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
2892 | |
2893 RTjpeg_dctY(bp2+k, RTjpeg_block, RTjpeg_Cwidth); | |
2894 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
2895 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
2896 | |
2897 RTjpeg_dctY(bp3+k, RTjpeg_block, RTjpeg_Cwidth); | |
2898 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
2899 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
2900 | |
2901 } | |
2902 bp+=RTjpeg_width<<4; | |
2903 bp1+=RTjpeg_width<<4; | |
2904 bp2+=RTjpeg_width<<2; | |
2905 bp3+=RTjpeg_width<<2; | |
2906 | |
2907 } | |
2908 #ifdef MMX | |
2909 emms(); | |
2910 #endif | |
2911 return (sp-sb); | |
2912 } | |
2913 | |
2914 int RTjpeg_compressYUV422(__s8 *sp, unsigned char *bp) | |
2915 { | |
2916 __s8 * sb; | |
2917 register __s8 * bp2 = bp + RTjpeg_Ysize; | |
2918 register __s8 * bp3 = bp2 + RTjpeg_Csize; | |
2919 register int i, j, k; | |
2920 | |
2921 #ifdef MMX | |
2922 emms(); | |
2923 #endif | |
2924 sb=sp; | |
2925 /* Y */ | |
2926 for(i=RTjpeg_height; i; i-=8) | |
2927 { | |
2928 for(j=0, k=0; j<RTjpeg_width; j+=16, k+=8) | |
2929 { | |
2930 RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_Ywidth); | |
2931 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
2932 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
2933 | |
2934 RTjpeg_dctY(bp+j+8, RTjpeg_block, RTjpeg_Ywidth); | |
2935 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
2936 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
2937 | |
2938 RTjpeg_dctY(bp2+k, RTjpeg_block, RTjpeg_Cwidth); | |
2939 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
2940 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
2941 | |
2942 RTjpeg_dctY(bp3+k, RTjpeg_block, RTjpeg_Cwidth); | |
2943 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
2944 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
2945 | |
2946 } | |
2947 bp+=RTjpeg_width<<3; | |
2948 bp2+=RTjpeg_width<<2; | |
2949 bp3+=RTjpeg_width<<2; | |
2950 | |
2951 } | |
2952 #ifdef MMX | |
2953 emms(); | |
2954 #endif | |
2955 return (sp-sb); | |
2956 } | |
2957 | |
2958 int RTjpeg_compress8(__s8 *sp, unsigned char *bp) | |
2959 { | |
2960 __s8 * sb; | |
2961 int i, j; | |
2962 | |
2963 #ifdef MMX | |
2964 emms(); | |
2965 #endif | |
2966 | |
2967 sb=sp; | |
2968 /* Y */ | |
2969 for(i=0; i<RTjpeg_height; i+=8) | |
2970 { | |
2971 for(j=0; j<RTjpeg_width; j+=8) | |
2972 { | |
2973 RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_width); | |
2974 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
2975 sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
2976 } | |
2977 bp+=RTjpeg_width; | |
2978 } | |
2979 | |
2980 #ifdef MMX | |
2981 emms(); | |
2982 #endif | |
2983 return (sp-sb); | |
2984 } | |
2985 | |
2986 void RTjpeg_decompressYUV422(__s8 *sp, __u8 *bp) | |
2987 { | |
2988 register __s8 * bp2 = bp + RTjpeg_Ysize; | |
2989 register __s8 * bp3 = bp2 + (RTjpeg_Csize); | |
2990 int i, j,k; | |
2991 | |
2992 #ifdef MMX | |
2993 emms(); | |
2994 #endif | |
2995 | |
2996 /* Y */ | |
2997 for(i=RTjpeg_height; i; i-=8) | |
2998 { | |
2999 for(k=0, j=0; j<RTjpeg_width; j+=16, k+=8) { | |
3000 if(*sp==-1)sp++; | |
3001 else | |
3002 { | |
3003 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt); | |
3004 RTjpeg_idct(bp+j, RTjpeg_block, RTjpeg_width); | |
3005 } | |
3006 if(*sp==-1)sp++; | |
3007 else | |
3008 { | |
3009 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt); | |
3010 RTjpeg_idct(bp+j+8, RTjpeg_block, RTjpeg_width); | |
3011 } | |
3012 if(*sp==-1)sp++; | |
3013 else | |
3014 { | |
3015 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt); | |
3016 RTjpeg_idct(bp2+k, RTjpeg_block, RTjpeg_width>>1); | |
3017 } | |
3018 if(*sp==-1)sp++; | |
3019 else | |
3020 { | |
3021 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt); | |
3022 RTjpeg_idct(bp3+k, RTjpeg_block, RTjpeg_width>>1); | |
3023 } | |
3024 } | |
3025 bp+=RTjpeg_width<<3; | |
3026 bp2+=RTjpeg_width<<2; | |
3027 bp3+=RTjpeg_width<<2; | |
3028 } | |
3029 #ifdef MMX | |
3030 emms(); | |
3031 #endif | |
3032 } | |
3033 | |
3034 void RTjpeg_decompressYUV420(__s8 *sp, __u8 *bp) | |
3035 { | |
3036 register __s8 * bp1 = bp + (RTjpeg_width<<3); | |
3037 register __s8 * bp2 = bp + RTjpeg_Ysize; | |
3038 register __s8 * bp3 = bp2 + (RTjpeg_Csize>>1); | |
3039 int i, j,k; | |
3040 | |
3041 #ifdef MMX | |
3042 emms(); | |
3043 #endif | |
3044 | |
3045 /* Y */ | |
3046 for(i=RTjpeg_height>>1; i; i-=8) | |
3047 { | |
3048 for(k=0, j=0; j<RTjpeg_width; j+=16, k+=8) { | |
3049 if(*sp==-1)sp++; | |
3050 else | |
3051 { | |
3052 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt); | |
3053 RTjpeg_idct(bp+j, RTjpeg_block, RTjpeg_width); | |
3054 } | |
3055 if(*sp==-1)sp++; | |
3056 else | |
3057 { | |
3058 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt); | |
3059 RTjpeg_idct(bp+j+8, RTjpeg_block, RTjpeg_width); | |
3060 } | |
3061 if(*sp==-1)sp++; | |
3062 else | |
3063 { | |
3064 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt); | |
3065 RTjpeg_idct(bp1+j, RTjpeg_block, RTjpeg_width); | |
3066 } | |
3067 if(*sp==-1)sp++; | |
3068 else | |
3069 { | |
3070 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt); | |
3071 RTjpeg_idct(bp1+j+8, RTjpeg_block, RTjpeg_width); | |
3072 } | |
3073 if(*sp==-1)sp++; | |
3074 else | |
3075 { | |
3076 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt); | |
3077 RTjpeg_idct(bp2+k, RTjpeg_block, RTjpeg_width>>1); | |
3078 } | |
3079 if(*sp==-1)sp++; | |
3080 else | |
3081 { | |
3082 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt); | |
3083 RTjpeg_idct(bp3+k, RTjpeg_block, RTjpeg_width>>1); | |
3084 } | |
3085 } | |
3086 bp+=RTjpeg_width<<4; | |
3087 bp1+=RTjpeg_width<<4; | |
3088 bp2+=RTjpeg_width<<2; | |
3089 bp3+=RTjpeg_width<<2; | |
3090 } | |
3091 #ifdef MMX | |
3092 emms(); | |
3093 #endif | |
3094 } | |
3095 | |
3096 void RTjpeg_decompress8(__s8 *sp, __u8 *bp) | |
3097 { | |
3098 int i, j; | |
3099 | |
3100 #ifdef MMX | |
3101 emms(); | |
3102 #endif | |
3103 | |
3104 /* Y */ | |
3105 for(i=0; i<RTjpeg_height; i+=8) | |
3106 { | |
3107 for(j=0; j<RTjpeg_width; j+=8) | |
3108 if(*sp==-1)sp++; | |
3109 else | |
3110 { | |
3111 sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt); | |
3112 RTjpeg_idct(bp+j, RTjpeg_block, RTjpeg_width); | |
3113 } | |
3114 bp+=RTjpeg_width<<3; | |
3115 } | |
3116 } | |
3117 | |
3118 /* | |
3119 External Function | |
3120 | |
3121 Initialise additional data structures for motion compensation | |
3122 | |
3123 */ | |
3124 | |
3125 void RTjpeg_init_mcompress(void) | |
3126 { | |
3127 unsigned long tmp; | |
3128 | |
3129 if(!RTjpeg_old) | |
3130 { | |
3131 RTjpeg_old=malloc((4*RTjpeg_width*RTjpeg_height)+32); | |
3132 tmp=(unsigned long)RTjpeg_old; | |
3133 tmp+=32; | |
3134 tmp=tmp>>5; | |
3135 RTjpeg_old=(__s16 *)(tmp<<5); | |
3136 } | |
3137 if (!RTjpeg_old) | |
3138 { | |
3139 fprintf(stderr, "RTjpeg: Could not allocate memory\n"); | |
3140 exit(-1); | |
3141 } | |
14642
38572280e8e7
bzero is deprecated patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
12928
diff
changeset
|
3142 memset(RTjpeg_old, 0, ((4*RTjpeg_width*RTjpeg_height))); |
3802 | 3143 } |
3144 | |
3145 #ifdef MMX | |
3146 | |
3147 int RTjpeg_bcomp(__s16 *old, mmx_t *mask) | |
3148 { | |
3149 int i; | |
3150 mmx_t *mold=(mmx_t *)old; | |
3151 mmx_t *mblock=(mmx_t *)RTjpeg_block; | |
3152 volatile mmx_t result; | |
12928 | 3153 static mmx_t neg={0xffffffffffffffffULL}; |
3802 | 3154 |
3155 movq_m2r(*mask, mm7); | |
3156 movq_m2r(neg, mm6); | |
3157 pxor_r2r(mm5, mm5); | |
3158 | |
3159 for(i=0; i<8; i++) | |
3160 { | |
3161 movq_m2r(*(mblock++), mm0); | |
3162 movq_m2r(*(mblock++), mm2); | |
3163 movq_m2r(*(mold++), mm1); | |
3164 movq_m2r(*(mold++), mm3); | |
3165 psubsw_r2r(mm1, mm0); | |
3166 psubsw_r2r(mm3, mm2); | |
3167 movq_r2r(mm0, mm1); | |
3168 movq_r2r(mm2, mm3); | |
3169 pcmpgtw_r2r(mm7, mm0); | |
3170 pcmpgtw_r2r(mm7, mm2); | |
3171 pxor_r2r(mm6, mm1); | |
3172 pxor_r2r(mm6, mm3); | |
3173 pcmpgtw_r2r(mm7, mm1); | |
3174 pcmpgtw_r2r(mm7, mm3); | |
3175 por_r2r(mm0, mm5); | |
3176 por_r2r(mm2, mm5); | |
3177 por_r2r(mm1, mm5); | |
3178 por_r2r(mm3, mm5); | |
3179 } | |
3180 movq_r2m(mm5, result); | |
3181 | |
3182 if(result.q) | |
3183 { | |
3184 // if(!RTjpeg_mtest) | |
3185 // for(i=0; i<16; i++)((__u64 *)old)[i]=((__u64 *)RTjpeg_block)[i]; | |
3186 return 0; | |
3187 } | |
3188 // printf("."); | |
3189 return 1; | |
3190 } | |
3191 | |
3192 #else | |
3193 int RTjpeg_bcomp(__s16 *old, __u16 *mask) | |
3194 { | |
3195 int i; | |
3196 | |
3197 for(i=0; i<64; i++) | |
3198 if(abs(old[i]-RTjpeg_block[i])>*mask) | |
3199 { | |
3200 if(!RTjpeg_mtest) | |
3201 for(i=0; i<16; i++)((__u64 *)old)[i]=((__u64 *)RTjpeg_block)[i]; | |
3202 return 0; | |
3203 } | |
3204 return 1; | |
3205 } | |
3206 #endif | |
3207 | |
3208 void RTjpeg_set_test(int i) | |
3209 { | |
3210 RTjpeg_mtest=i; | |
3211 } | |
3212 | |
3213 int RTjpeg_mcompressYUV420(__s8 *sp, unsigned char *bp, __u16 lmask, __u16 cmask) | |
3214 { | |
3215 __s8 * sb; | |
3216 //rh __s16 *block; | |
3217 register __s8 * bp1 = bp + (RTjpeg_width<<3); | |
3218 register __s8 * bp2 = bp + RTjpeg_Ysize; | |
3219 register __s8 * bp3 = bp2 + (RTjpeg_Csize>>1); | |
3220 register int i, j, k; | |
3221 | |
3222 #ifdef MMX | |
3223 emms(); | |
16653
27b0d49988b2
Fix 100l bugs that break playback on 64 bit systems (like typedefing __u32
reimar
parents:
14896
diff
changeset
|
3224 RTjpeg_lmask.uq=((__u64)lmask<<48)|((__u64)lmask<<32)|((__u64)lmask<<16)|lmask; |
27b0d49988b2
Fix 100l bugs that break playback on 64 bit systems (like typedefing __u32
reimar
parents:
14896
diff
changeset
|
3225 RTjpeg_cmask.uq=((__u64)cmask<<48)|((__u64)cmask<<32)|((__u64)cmask<<16)|cmask; |
3802 | 3226 #else |
16661
adb581352e63
Stupidity in last patch broke compile without MMX: RTjpeg_lmask is a union
reimar
parents:
16653
diff
changeset
|
3227 RTjpeg_lmask=lmask; |
adb581352e63
Stupidity in last patch broke compile without MMX: RTjpeg_lmask is a union
reimar
parents:
16653
diff
changeset
|
3228 RTjpeg_cmask=cmask; |
3802 | 3229 #endif |
3230 | |
3231 sb=sp; | |
3232 block=RTjpeg_old; | |
3233 /* Y */ | |
3234 for(i=RTjpeg_height>>1; i; i-=8) | |
3235 { | |
3236 for(j=0, k=0; j<RTjpeg_width; j+=16, k+=8) | |
3237 { | |
3238 RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_Ywidth); | |
3239 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
3240 if(RTjpeg_bcomp(block, &RTjpeg_lmask)) | |
3241 { | |
3242 *((__u8 *)sp++)=255; | |
3243 } | |
3244 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
3245 block+=64; | |
3246 | |
3247 RTjpeg_dctY(bp+j+8, RTjpeg_block, RTjpeg_Ywidth); | |
3248 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
3249 if(RTjpeg_bcomp(block, &RTjpeg_lmask)) | |
3250 { | |
3251 *((__u8 *)sp++)=255; | |
3252 } | |
3253 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
3254 block+=64; | |
3255 | |
3256 RTjpeg_dctY(bp1+j, RTjpeg_block, RTjpeg_Ywidth); | |
3257 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
3258 if(RTjpeg_bcomp(block, &RTjpeg_lmask)) | |
3259 { | |
3260 *((__u8 *)sp++)=255; | |
3261 } | |
3262 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
3263 block+=64; | |
3264 | |
3265 RTjpeg_dctY(bp1+j+8, RTjpeg_block, RTjpeg_Ywidth); | |
3266 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
3267 if(RTjpeg_bcomp(block, &RTjpeg_lmask)) | |
3268 { | |
3269 *((__u8 *)sp++)=255; | |
3270 } | |
3271 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
3272 block+=64; | |
3273 | |
3274 RTjpeg_dctY(bp2+k, RTjpeg_block, RTjpeg_Cwidth); | |
3275 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
3276 if(RTjpeg_bcomp(block, &RTjpeg_cmask)) | |
3277 { | |
3278 *((__u8 *)sp++)=255; | |
3279 } | |
3280 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
3281 block+=64; | |
3282 | |
3283 RTjpeg_dctY(bp3+k, RTjpeg_block, RTjpeg_Cwidth); | |
3284 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
3285 if(RTjpeg_bcomp(block, &RTjpeg_cmask)) | |
3286 { | |
3287 *((__u8 *)sp++)=255; | |
3288 } | |
3289 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
3290 block+=64; | |
3291 } | |
3292 bp+=RTjpeg_width<<4; | |
3293 bp1+=RTjpeg_width<<4; | |
3294 bp2+=RTjpeg_width<<2; | |
3295 bp3+=RTjpeg_width<<2; | |
3296 | |
3297 } | |
3298 #ifdef MMX | |
3299 emms(); | |
3300 #endif | |
3301 return (sp-sb); | |
3302 } | |
3303 | |
3304 | |
3305 int RTjpeg_mcompressYUV422(__s8 *sp, unsigned char *bp, __u16 lmask, __u16 cmask) | |
3306 { | |
3307 __s8 * sb; | |
3308 __s16 *block; | |
3309 register __s8 * bp2; | |
3310 register __s8 * bp3; | |
3311 register int i, j, k; | |
3312 | |
3313 #ifdef MMX | |
3314 emms(); | |
16653
27b0d49988b2
Fix 100l bugs that break playback on 64 bit systems (like typedefing __u32
reimar
parents:
14896
diff
changeset
|
3315 RTjpeg_lmask.uq=((__u64)lmask<<48)|((__u64)lmask<<32)|((__u64)lmask<<16)|lmask; |
27b0d49988b2
Fix 100l bugs that break playback on 64 bit systems (like typedefing __u32
reimar
parents:
14896
diff
changeset
|
3316 RTjpeg_cmask.uq=((__u64)cmask<<48)|((__u64)cmask<<32)|((__u64)cmask<<16)|cmask; |
3802 | 3317 #else |
16661
adb581352e63
Stupidity in last patch broke compile without MMX: RTjpeg_lmask is a union
reimar
parents:
16653
diff
changeset
|
3318 RTjpeg_lmask=lmask; |
adb581352e63
Stupidity in last patch broke compile without MMX: RTjpeg_lmask is a union
reimar
parents:
16653
diff
changeset
|
3319 RTjpeg_cmask=cmask; |
3802 | 3320 #endif |
3321 | |
3322 bp = bp - RTjpeg_width*0; | |
3323 bp2 = bp + RTjpeg_Ysize-RTjpeg_width*0; | |
3324 bp3 = bp2 + RTjpeg_Csize; | |
3325 | |
3326 sb=sp; | |
3327 block=RTjpeg_old; | |
3328 /* Y */ | |
3329 for(i=RTjpeg_height; i; i-=8) | |
3330 { | |
3331 for(j=0, k=0; j<RTjpeg_width; j+=16, k+=8) | |
3332 { | |
3333 RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_Ywidth); | |
3334 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
3335 if(RTjpeg_bcomp(block, &RTjpeg_lmask)) | |
3336 { | |
3337 *((__u8 *)sp++)=255; | |
3338 } | |
3339 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
3340 block+=64; | |
3341 | |
3342 RTjpeg_dctY(bp+j+8, RTjpeg_block, RTjpeg_Ywidth); | |
3343 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
3344 if(RTjpeg_bcomp(block, &RTjpeg_lmask)) | |
3345 { | |
3346 *((__u8 *)sp++)=255; | |
3347 } | |
3348 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
3349 block+=64; | |
3350 | |
3351 RTjpeg_dctY(bp2+k, RTjpeg_block, RTjpeg_Cwidth); | |
3352 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
3353 if(RTjpeg_bcomp(block, &RTjpeg_cmask)) | |
3354 { | |
3355 *((__u8 *)sp++)=255; | |
3356 } | |
3357 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
3358 block+=64; | |
3359 | |
3360 RTjpeg_dctY(bp3+k, RTjpeg_block, RTjpeg_Cwidth); | |
3361 RTjpeg_quant(RTjpeg_block, RTjpeg_cqt); | |
3362 if(RTjpeg_bcomp(block, &RTjpeg_cmask)) | |
3363 { | |
3364 *((__u8 *)sp++)=255; | |
3365 } | |
3366 else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8); | |
3367 block+=64; | |
3368 | |
3369 } | |
3370 bp+=RTjpeg_width<<3; | |
3371 bp2+=RTjpeg_width<<2; | |
3372 bp3+=RTjpeg_width<<2; | |
3373 } | |
3374 printf ("%d\n", block - RTjpeg_old); | |
3375 #ifdef MMX | |
3376 emms(); | |
3377 #endif | |
3378 return (sp-sb); | |
3379 } | |
3380 | |
3381 int RTjpeg_mcompress8(__s8 *sp, unsigned char *bp, __u16 lmask) | |
3382 { | |
3383 __s8 * sb; | |
3384 __s16 *block; | |
3385 int i, j; | |
3386 | |
3387 #ifdef MMX | |
3388 emms(); | |
16653
27b0d49988b2
Fix 100l bugs that break playback on 64 bit systems (like typedefing __u32
reimar
parents:
14896
diff
changeset
|
3389 RTjpeg_lmask.uq=((__u64)lmask<<48)|((__u64)lmask<<32)|((__u64)lmask<<16)|lmask; |
3802 | 3390 #else |
16661
adb581352e63
Stupidity in last patch broke compile without MMX: RTjpeg_lmask is a union
reimar
parents:
16653
diff
changeset
|
3391 RTjpeg_lmask=lmask; |
3802 | 3392 #endif |
3393 | |
3394 | |
3395 sb=sp; | |
3396 block=RTjpeg_old; | |
3397 /* Y */ | |
3398 for(i=0; i<RTjpeg_height; i+=8) | |
3399 { | |
3400 for(j=0; j<RTjpeg_width; j+=8) | |
3401 { | |
3402 RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_width); | |
3403 RTjpeg_quant(RTjpeg_block, RTjpeg_lqt); | |
3404 if(RTjpeg_bcomp(block, &RTjpeg_lmask)) | |
3405 { | |
3406 *((__u8 *)sp++)=255; | |
3407 // printf("* %d ", sp[-1]); | |
3408 } else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8); | |
3409 block+=64; | |
3410 } | |
3411 bp+=RTjpeg_width<<3; | |
3412 } | |
3413 #ifdef MMX | |
3414 emms(); | |
3415 #endif | |
3416 return (sp-sb); | |
3417 } | |
3418 | |
3419 void RTjpeg_color_init(void) | |
3420 { | |
3421 } | |
3422 | |
3423 #define KcrR 76284 | |
3424 #define KcrG 53281 | |
3425 #define KcbG 25625 | |
3426 #define KcbB 132252 | |
3427 #define Ky 76284 | |
3428 | |
3429 void RTjpeg_yuv422rgb(__u8 *buf, __u8 *rgb, int stride) | |
3430 { | |
3431 int tmp; | |
3432 int i, j; | |
3433 __s32 y, crR, crG, cbG, cbB; | |
3434 __u8 *bufcr, *bufcb, *bufy, *bufoute; | |
3435 int yskip; | |
3436 | |
3437 yskip=RTjpeg_width; | |
3438 | |
3439 bufcb=&buf[RTjpeg_width*RTjpeg_height]; | |
3440 bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/2]; | |
3441 bufy=&buf[0]; | |
3442 bufoute=rgb; | |
3443 | |
3444 for(i=0; i<(RTjpeg_height); i++) | |
3445 { | |
3446 for(j=0; j<RTjpeg_width; j+=2) | |
3447 { | |
3448 crR=(*bufcr-128)*KcrR; | |
3449 crG=(*(bufcr++)-128)*KcrG; | |
3450 cbG=(*bufcb-128)*KcbG; | |
3451 cbB=(*(bufcb++)-128)*KcbB; | |
3452 | |
3453 y=(bufy[j]-16)*Ky; | |
3454 | |
3455 tmp=(y+crR)>>16; | |
3456 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3457 tmp=(y-crG-cbG)>>16; | |
3458 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3459 tmp=(y+cbB)>>16; | |
3460 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3461 | |
3462 y=(bufy[j+1]-16)*Ky; | |
3463 | |
3464 tmp=(y+crR)>>16; | |
3465 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3466 tmp=(y-crG-cbG)>>16; | |
3467 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3468 tmp=(y+cbB)>>16; | |
3469 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3470 | |
3471 } | |
3472 bufy+=yskip; | |
3473 } | |
3474 } | |
3475 | |
3476 | |
3477 void RTjpeg_yuv420rgb(__u8 *buf, __u8 *rgb, int stride) | |
3478 { | |
3479 int tmp; | |
3480 int i, j; | |
3481 __s32 y, crR, crG, cbG, cbB; | |
3482 __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto; | |
3483 int oskip, yskip; | |
3484 | |
3485 if(stride==0) | |
3486 oskip=RTjpeg_width*3; | |
3487 else | |
3488 oskip=2*stride-RTjpeg_width*3; | |
3489 | |
3490 yskip=RTjpeg_width; | |
3491 | |
3492 bufcb=&buf[RTjpeg_width*RTjpeg_height]; | |
3493 bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/4]; | |
3494 bufy=&buf[0]; | |
3495 bufoute=rgb; | |
3496 bufouto=rgb+RTjpeg_width*3; | |
3497 | |
3498 for(i=0; i<(RTjpeg_height>>1); i++) | |
3499 { | |
3500 for(j=0; j<RTjpeg_width; j+=2) | |
3501 { | |
3502 crR=(*bufcr-128)*KcrR; | |
3503 crG=(*(bufcr++)-128)*KcrG; | |
3504 cbG=(*bufcb-128)*KcbG; | |
3505 cbB=(*(bufcb++)-128)*KcbB; | |
3506 | |
3507 y=(bufy[j]-16)*Ky; | |
3508 | |
3509 tmp=(y+crR)>>16; | |
3510 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3511 tmp=(y-crG-cbG)>>16; | |
3512 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3513 tmp=(y+cbB)>>16; | |
3514 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3515 | |
3516 y=(bufy[j+1]-16)*Ky; | |
3517 | |
3518 tmp=(y+crR)>>16; | |
3519 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3520 tmp=(y-crG-cbG)>>16; | |
3521 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3522 tmp=(y+cbB)>>16; | |
3523 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3524 | |
3525 y=(bufy[j+yskip]-16)*Ky; | |
3526 | |
3527 tmp=(y+crR)>>16; | |
3528 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3529 tmp=(y-crG-cbG)>>16; | |
3530 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3531 tmp=(y+cbB)>>16; | |
3532 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3533 | |
3534 y=(bufy[j+1+yskip]-16)*Ky; | |
3535 | |
3536 tmp=(y+crR)>>16; | |
3537 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3538 tmp=(y-crG-cbG)>>16; | |
3539 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3540 tmp=(y+cbB)>>16; | |
3541 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3542 | |
3543 } | |
3544 bufoute+=oskip; | |
3545 bufouto+=oskip; | |
3546 bufy+=yskip<<1; | |
3547 } | |
3548 } | |
3549 | |
3550 | |
3551 void RTjpeg_yuvrgb32(__u8 *buf, __u8 *rgb, int stride) | |
3552 { | |
3553 int tmp; | |
3554 int i, j; | |
3555 __s32 y, crR, crG, cbG, cbB; | |
3556 __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto; | |
3557 int oskip, yskip; | |
3558 | |
3559 if(stride==0) | |
3560 oskip=RTjpeg_width*4; | |
3561 else | |
3562 oskip = 2*stride-RTjpeg_width*4; | |
3563 yskip=RTjpeg_width; | |
3564 | |
3565 bufcb=&buf[RTjpeg_width*RTjpeg_height]; | |
3566 bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/2]; | |
3567 bufy=&buf[0]; | |
3568 bufoute=rgb; | |
3569 bufouto=rgb+RTjpeg_width*4; | |
3570 | |
3571 for(i=0; i<(RTjpeg_height>>1); i++) | |
3572 { | |
3573 for(j=0; j<RTjpeg_width; j+=2) | |
3574 { | |
3575 crR=(*bufcr-128)*KcrR; | |
3576 crG=(*(bufcr++)-128)*KcrG; | |
3577 cbG=(*bufcb-128)*KcbG; | |
3578 cbB=(*(bufcb++)-128)*KcbB; | |
3579 | |
3580 y=(bufy[j]-16)*Ky; | |
3581 | |
3582 tmp=(y+cbB)>>16; | |
3583 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3584 tmp=(y-crG-cbG)>>16; | |
3585 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3586 tmp=(y+crR)>>16; | |
3587 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3588 bufoute++; | |
3589 | |
3590 y=(bufy[j+1]-16)*Ky; | |
3591 | |
3592 tmp=(y+cbB)>>16; | |
3593 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3594 tmp=(y-crG-cbG)>>16; | |
3595 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3596 tmp=(y+crR)>>16; | |
3597 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3598 bufoute++; | |
3599 | |
3600 y=(bufy[j+yskip]-16)*Ky; | |
3601 | |
3602 tmp=(y+cbB)>>16; | |
3603 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3604 tmp=(y-crG-cbG)>>16; | |
3605 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3606 tmp=(y+crR)>>16; | |
3607 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3608 bufouto++; | |
3609 | |
3610 y=(bufy[j+1+yskip]-16)*Ky; | |
3611 | |
3612 tmp=(y+cbB)>>16; | |
3613 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3614 tmp=(y-crG-cbG)>>16; | |
3615 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3616 tmp=(y+crR)>>16; | |
3617 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3618 bufouto++; | |
3619 | |
3620 } | |
3621 bufoute+=oskip; | |
3622 bufouto+=oskip; | |
3623 bufy+=yskip<<1; | |
3624 } | |
3625 } | |
3626 | |
3627 void RTjpeg_yuvrgb24(__u8 *buf, __u8 *rgb, int stride) | |
3628 { | |
3629 int tmp; | |
3630 int i, j; | |
3631 __s32 y, crR, crG, cbG, cbB; | |
3632 __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto; | |
3633 int oskip, yskip; | |
3634 | |
3635 if(stride==0) | |
3636 oskip=RTjpeg_width*3; | |
3637 else | |
3638 oskip=2*stride - RTjpeg_width*3; | |
3639 | |
3640 yskip=RTjpeg_width; | |
3641 | |
3642 bufcb=&buf[RTjpeg_width*RTjpeg_height]; | |
3643 bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/4]; | |
3644 bufy=&buf[0]; | |
3645 bufoute=rgb; | |
3646 bufouto=rgb+RTjpeg_width*3; | |
3647 | |
3648 for(i=0; i<(RTjpeg_height>>1); i++) | |
3649 { | |
3650 for(j=0; j<RTjpeg_width; j+=2) | |
3651 { | |
3652 crR=(*bufcr-128)*KcrR; | |
3653 crG=(*(bufcr++)-128)*KcrG; | |
3654 cbG=(*bufcb-128)*KcbG; | |
3655 cbB=(*(bufcb++)-128)*KcbB; | |
3656 | |
3657 y=(bufy[j]-16)*Ky; | |
3658 | |
3659 tmp=(y+cbB)>>16; | |
3660 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3661 tmp=(y-crG-cbG)>>16; | |
3662 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3663 tmp=(y+crR)>>16; | |
3664 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3665 | |
3666 y=(bufy[j+1]-16)*Ky; | |
3667 | |
3668 tmp=(y+cbB)>>16; | |
3669 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3670 tmp=(y-crG-cbG)>>16; | |
3671 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3672 tmp=(y+crR)>>16; | |
3673 *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3674 | |
3675 y=(bufy[j+yskip]-16)*Ky; | |
3676 | |
3677 tmp=(y+cbB)>>16; | |
3678 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3679 tmp=(y-crG-cbG)>>16; | |
3680 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3681 tmp=(y+crR)>>16; | |
3682 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3683 | |
3684 y=(bufy[j+1+yskip]-16)*Ky; | |
3685 | |
3686 tmp=(y+cbB)>>16; | |
3687 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3688 tmp=(y-crG-cbG)>>16; | |
3689 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3690 tmp=(y+crR)>>16; | |
3691 *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp); | |
3692 | |
3693 } | |
3694 bufoute+=oskip; | |
3695 bufouto+=oskip; | |
3696 bufy+=yskip<<1; | |
3697 } | |
3698 } | |
3699 | |
3700 void RTjpeg_yuvrgb16(__u8 *buf, __u8 *rgb, int stride) | |
3701 { | |
3702 int tmp; | |
3703 int i, j; | |
3704 __s32 y, crR, crG, cbG, cbB; | |
3705 __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto; | |
3706 int oskip, yskip; | |
3707 unsigned char r, g, b; | |
3708 | |
3709 if(stride==0) | |
3710 oskip=RTjpeg_width*2; | |
3711 else | |
3712 oskip=2*stride-RTjpeg_width*2; | |
3713 | |
3714 yskip=RTjpeg_width; | |
3715 | |
3716 bufcb=&buf[RTjpeg_width*RTjpeg_height]; | |
3717 bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/4]; | |
3718 bufy=&buf[0]; | |
3719 bufoute=rgb; | |
3720 bufouto=rgb+RTjpeg_width*2; | |
3721 | |
3722 for(i=0; i<(RTjpeg_height>>1); i++) | |
3723 { | |
3724 for(j=0; j<RTjpeg_width; j+=2) | |
3725 { | |
3726 crR=(*bufcr-128)*KcrR; | |
3727 crG=(*(bufcr++)-128)*KcrG; | |
3728 cbG=(*bufcb-128)*KcbG; | |
3729 cbB=(*(bufcb++)-128)*KcbB; | |
3730 | |
3731 y=(bufy[j]-16)*Ky; | |
3732 | |
3733 tmp=(y+cbB)>>16; | |
3734 b=(tmp>255)?255:((tmp<0)?0:tmp); | |
3735 tmp=(y-crG-cbG)>>16; | |
3736 g=(tmp>255)?255:((tmp<0)?0:tmp); | |
3737 tmp=(y+crR)>>16; | |
3738 r=(tmp>255)?255:((tmp<0)?0:tmp); | |
3739 tmp=(int)((int)b >> 3); | |
3740 tmp|=(int)(((int)g >> 2) << 5); | |
3741 tmp|=(int)(((int)r >> 3) << 11); | |
3742 *(bufoute++)=tmp&0xff; | |
3743 *(bufoute++)=tmp>>8; | |
3744 | |
3745 | |
3746 y=(bufy[j+1]-16)*Ky; | |
3747 | |
3748 tmp=(y+cbB)>>16; | |
3749 b=(tmp>255)?255:((tmp<0)?0:tmp); | |
3750 tmp=(y-crG-cbG)>>16; | |
3751 g=(tmp>255)?255:((tmp<0)?0:tmp); | |
3752 tmp=(y+crR)>>16; | |
3753 r=(tmp>255)?255:((tmp<0)?0:tmp); | |
3754 tmp=(int)((int)b >> 3); | |
3755 tmp|=(int)(((int)g >> 2) << 5); | |
3756 tmp|=(int)(((int)r >> 3) << 11); | |
3757 *(bufoute++)=tmp&0xff; | |
3758 *(bufoute++)=tmp>>8; | |
3759 | |
3760 y=(bufy[j+yskip]-16)*Ky; | |
3761 | |
3762 tmp=(y+cbB)>>16; | |
3763 b=(tmp>255)?255:((tmp<0)?0:tmp); | |
3764 tmp=(y-crG-cbG)>>16; | |
3765 g=(tmp>255)?255:((tmp<0)?0:tmp); | |
3766 tmp=(y+crR)>>16; | |
3767 r=(tmp>255)?255:((tmp<0)?0:tmp); | |
3768 tmp=(int)((int)b >> 3); | |
3769 tmp|=(int)(((int)g >> 2) << 5); | |
3770 tmp|=(int)(((int)r >> 3) << 11); | |
3771 *(bufouto++)=tmp&0xff; | |
3772 *(bufouto++)=tmp>>8; | |
3773 | |
3774 y=(bufy[j+1+yskip]-16)*Ky; | |
3775 | |
3776 tmp=(y+cbB)>>16; | |
3777 b=(tmp>255)?255:((tmp<0)?0:tmp); | |
3778 tmp=(y-crG-cbG)>>16; | |
3779 g=(tmp>255)?255:((tmp<0)?0:tmp); | |
3780 tmp=(y+crR)>>16; | |
3781 r=(tmp>255)?255:((tmp<0)?0:tmp); | |
3782 tmp=(int)((int)b >> 3); | |
3783 tmp|=(int)(((int)g >> 2) << 5); | |
3784 tmp|=(int)(((int)r >> 3) << 11); | |
3785 *(bufouto++)=tmp&0xff; | |
3786 *(bufouto++)=tmp>>8; | |
3787 | |
3788 } | |
3789 bufoute+=oskip; | |
3790 bufouto+=oskip; | |
3791 bufy+=yskip<<1; | |
3792 } | |
3793 } | |
3794 | |
3795 /* fix stride */ | |
3796 | |
3797 void RTjpeg_yuvrgb8(__u8 *buf, __u8 *rgb, int stride) | |
3798 { | |
9763 | 3799 memcpy(rgb, buf, RTjpeg_width*RTjpeg_height); |
3802 | 3800 } |
3801 |