aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mips/simple_idct_mmi.c
blob: 3c1a4f7eafcc5b5cefcdce382f115461f224db22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
/*
 * Loongson SIMD optimized simple idct
 *
 * Copyright (c) 2015 Loongson Technology Corporation Limited
 * Copyright (c) 2015 Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
 *                    Zhang Shuangshuang <zhangshuangshuang@ict.ac.cn>
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "idctdsp_mips.h"
#include "constants.h"

#define C0 23170 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define C1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define C2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define C3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define C4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) - 0.5
#define C5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define C6 8867  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define C7 4520  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5

#define ROW_SHIFT 11
#define COL_SHIFT 20

DECLARE_ALIGNED(8, static const int16_t, coeffs)[]= {
    1<<(ROW_SHIFT-1),   0, 1<<(ROW_SHIFT-1),   0,
    1<<(ROW_SHIFT-1),   1, 1<<(ROW_SHIFT-1),   0,
                  C4,  C4,               C4,  C4,
                  C4, -C4,               C4, -C4,
                  C2,  C6,               C2,  C6,
                  C6, -C2,               C6, -C2,
                  C1,  C3,               C1,  C3,
                  C5,  C7,               C5,  C7,
                  C3, -C7,               C3, -C7,
                 -C1, -C5,              -C1, -C5,
                  C5, -C1,               C5, -C1,
                  C7,  C3,               C7,  C3,
                  C7, -C5,               C7, -C5,
                  C3, -C1,               C3, -C1
};

static void simple_idct_mmi(int16_t *block)
{
        DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
        int16_t * const temp= (int16_t*)align_tmp;

        __asm__ volatile (
#undef  DC_COND_IDCT
#define DC_COND_IDCT(src0, src4, src1, src5, dst, rounder, rarg, shift)      \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f2, " #src4 "            \n\t" /* R6     R2      r6      r2 */\
        "ldc1 $f4, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f6, " #src5 "            \n\t" /* R7     R5      r7      r5 */\
        "ldc1 $f8, %3                   \n\t"                                \
        "and  $f8, $f8, $f0             \n\t"                                \
        "or $f8, $f8, $f2               \n\t"                                \
        "or $f8, $f8, $f4               \n\t"                                \
        "or $f8, $f8, $f6               \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t"                                \
        "li $11, " #shift "             \n\t"                                \
        "mfc1 $10, $f8                  \n\t"                                \
        "mtc1 $11, $f18                 \n\t"                                \
        "beqz $10, 1f                   \n\t"                                \
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f10, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "pmaddhw $f10, $f10, $f2        \n\t" /* C6R6+C2R2      C6r6+C2r2  */\
        "ldc1 $f12, 40(%2)              \n\t" /* -C2    C6      -C2     C6 */\
        "pmaddhw $f2, $f2, $f12         \n\t" /* -C2R6+C6R2     -C2r6+C6r2 */\
        "ldc1 $f14, 48(%2)              \n\t" /* C3     C1      C3      C1 */\
        "ldc1 $f16, " #rarg "           \n\t"                                \
        "pmaddhw $f14, $f14, $f4        \n\t" /* C3R3+C1R1      C3r3+C1r1  */\
        #rounder " $f8, $f8, $f16       \n\t"                                \
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "paddw $f8, $f8, $f10           \n\t" /* A0             a0         */\
        "psubw $f12, $f12, $f10         \n\t" /* A3             a3         */\
        "ldc1 $f10, 56(%2)              \n\t" /* C7     C5      C7      C5 */\
        "ldc1 $f16, " #rarg "           \n\t"                                \
        "pmaddhw $f10, $f10, $f6        \n\t" /* C7R7+C5R5      C7r7+C5r5  */\
        #rounder " $f0, $f0, $f16       \n\t"                                \
        "paddw $f2, $f2, $f0            \n\t" /* A1             a1         */\
        "ldc1 $f16, 64(%2)              \n\t"                                \
        "paddw $f0, $f0, $f0            \n\t"                                \
        "psubw $f0, $f0, $f2            \n\t" /* A2             a2         */\
        "pmaddhw $f4, $f4, $f16         \n\t" /* -C7R3+C3R1     -C7r3+C3r1 */\
        "paddw $f14, $f14, $f10         \n\t" /* B0             b0         */\
        "ldc1 $f10, 72(%2)              \n\t" /* -C5    -C1     -C5    -C1 */\
        "pmaddhw $f10, $f10, $f6        \n\t" /* -C5R7-C1R5     -C5r7-C1r5 */\
        "paddw $f14, $f14, $f8          \n\t" /* A0+B0          a0+b0      */\
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "psubw $f8, $f8, $f14           \n\t" /* A0-B0          a0-b0      */\
        "paddw $f10, $f10, $f4          \n\t" /* B1             b1         */\
        "psraw $f14, $f14, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f4, $f2                 \n\t" /* A1             a1         */\
        "paddw $f2, $f2, $f10           \n\t" /* A1+B1          a1+b1      */\
        "psubw $f4, $f4, $f10           \n\t" /* A1-B1          a1-b1      */\
        "psraw $f2, $f2, $f18           \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f14, $f14, $f2       \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0   */\
        "packsswh $f4, $f4, $f8         \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1   */\
        "sdc1 $f14, " #dst "            \n\t"                                \
        "ldc1 $f2, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f8, 80(%2)               \n\t" /* -C1    C5      -C1     C5 */\
        "sdc1 $f4, 24+" #dst "          \n\t"                                \
        "pmaddhw $f8, $f8, $f2          \n\t" /* -C1R3+C5R1     -C1r3+C5r1 */\
        "ldc1 $f16, 96(%2)              \n\t"                                \
        "ldc1 $f14, 88(%2)              \n\t" /* C3     C7      C3      C7 */\
        "pmaddhw $f2, $f2, $f16         \n\t" /* -C5R3+C7R1     -C5r3+C7r1 */\
        "pmaddhw $f14, $f14, $f6        \n\t" /* C3R7+C7R5      C3r7+C7r5  */\
        "ldc1 $f16, 104(%2)             \n\t"                                \
        "mov.d $f4, $f0                 \n\t" /* A2             a2         */\
        "pmaddhw $f6, $f6, $f16         \n\t" /* -C1R7+C3R5     -C1r7+C3r5 */\
        "paddw $f8, $f8, $f14           \n\t" /* B2             b2         */\
        "paddw $f4, $f4, $f8            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f0, $f0, $f8            \n\t" /* a2-B2          a2-b2      */\
        "psraw $f4, $f4, $f18           \n\t"                                \
        "psraw $f0, $f0, $f18           \n\t"                                \
        "mov.d $f8, $f12                \n\t" /* A3             a3         */\
        "paddw $f6, $f6, $f2            \n\t" /* B3             b3         */\
        "paddw $f12, $f12, $f6          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f8, $f8, $f6            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "packsswh $f4, $f4, $f12        \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2   */\
        "sdc1 $f4, 8+" #dst "           \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "packsswh $f8, $f8, $f0         \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3   */\
        "sdc1 $f8, 16+" #dst "          \n\t"                                \
        "b 2f                           \n\t"                                \
        "1:                             \n\t"                                \
        "li $10, 16                     \n\t"                                \
        "mtc1 $10, $f16                 \n\t"                                \
        "psllw $f0, $f0, $f16           \n\t"                                \
        "ldc1 $f16, %4                  \n\t"                                \
        "paddw $f0, $f0, $f16           \n\t"                                \
        "li $10, 13                     \n\t"                                \
        "mtc1 $10, $f16                 \n\t"                                \
        "psraw $f0, $f0, $f16           \n\t"                                \
        "packsswh $f0, $f0, $f0         \n\t"                                \
        "sdc1 $f0, " #dst "             \n\t"                                \
        "sdc1 $f0, 8+" #dst "           \n\t"                                \
        "sdc1 $f0, 16+" #dst "          \n\t"                                \
        "sdc1 $f0, 24+" #dst "          \n\t"                                \
        "2:                             \n\t"

#undef  Z_COND_IDCT
#define Z_COND_IDCT(src0, src4, src1, src5, dst, rounder, rarg, shift, bt)   \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f2, " #src4 "            \n\t" /* R6     R2      r6      r2 */\
        "ldc1 $f4, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f6, " #src5 "            \n\t" /* R7     R5      r7      r5 */\
        "mov.d $f8, $f0                 \n\t"                                \
        "or $f8, $f8, $f2               \n\t"                                \
        "or $f8, $f8, $f4               \n\t"                                \
        "or $f8, $f8, $f6               \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t"                                \
        "mfc1 $10, $f8                  \n\t"                                \
        "beqz $10, " #bt "              \n\t"                                \
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f10, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "pmaddhw $f10, $f10, $f2        \n\t" /* C6R6+C2R2      C6r6+C2r2  */\
        "ldc1 $f12, 40(%2)              \n\t" /* -C2    C6      -C2     C6 */\
        "pmaddhw $f2, $f2, $f12         \n\t" /* -C2R6+C6R2     -C2r6+C6r2 */\
        "ldc1 $f14, 48(%2)              \n\t" /* C3     C1      C3      C1 */\
        "ldc1 $f16, " #rarg "           \n\t"                                \
        "pmaddhw $f14, $f14, $f4        \n\t" /* C3R3+C1R1      C3r3+C1r1  */\
        #rounder " $f8, $f8, $f16       \n\t"                                \
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "paddw $f8, $f8, $f10           \n\t" /* A0             a0         */\
        "psubw $f12, $f12, $f10         \n\t" /* A3             a3         */\
        "ldc1 $f10, 56(%2)              \n\t" /* C7     C5      C7      C5 */\
        "ldc1 $f16, " #rarg "           \n\t"                                \
        "pmaddhw $f10, $f10, $f6        \n\t" /* C7R7+C5R5      C7r7+C5r5  */\
        #rounder " $f0, $f0, $f16       \n\t"                                \
        "paddw $f2, $f2, $f0            \n\t" /* A1             a1         */\
        "paddw $f0, $f0, $f0            \n\t"                                \
        "ldc1 $f16, 64(%2)              \n\t"                                \
        "psubw $f0, $f0, $f2            \n\t" /* A2             a2         */\
        "pmaddhw $f4, $f4, $f16         \n\t" /* -C7R3+C3R1     -C7r3+C3r1 */\
        "paddw $f14, $f14, $f10         \n\t" /* B0             b0         */\
        "ldc1 $f10, 72(%2)              \n\t" /* -C5    -C1     -C5    -C1 */\
        "pmaddhw $f10, $f10, $f6        \n\t" /* -C5R7-C1R5     -C5r7-C1r5 */\
        "paddw $f14, $f14, $f8          \n\t" /* A0+B0          a0+b0      */\
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "li $10, " #shift "             \n\t"                                \
        "psubw $f8, $f8, $f14           \n\t" /* A0-B0          a0-b0      */\
        "mtc1 $10, $f18                 \n\t"                                \
        "paddw $f10, $f10, $f4          \n\t" /* B1             b1         */\
        "psraw $f14, $f14, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f4, $f2                 \n\t" /* A1             a1         */\
        "paddw $f2, $f2, $f10           \n\t" /* A1+B1          a1+b1      */\
        "psubw $f4, $f4, $f10           \n\t" /* A1-B1          a1-b1      */\
        "psraw $f2, $f2, $f18           \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f14, $f14, $f2       \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0   */\
        "packsswh $f4, $f4, $f8         \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1   */\
        "sdc1 $f14, " #dst "            \n\t"                                \
        "ldc1 $f2, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f8, 80(%2)               \n\t" /* -C1    C5      -C1     C5 */\
        "sdc1 $f4, 24+" #dst "          \n\t"                                \
        "pmaddhw $f8, $f8, $f2          \n\t" /* -C1R3+C5R1     -C1r3+C5r1 */\
        "ldc1 $f16, 96(%2)              \n\t"                                \
        "ldc1 $f14, 88(%2)              \n\t" /* C3     C7      C3      C7 */\
        "pmaddhw $f2, $f2, $f16         \n\t" /* -C5R3+C7R1     -C5r3+C7r1 */\
        "pmaddhw $f14, $f14, $f6        \n\t" /* C3R7+C7R5      C3r7+C7r5  */\
        "ldc1 $f16, 104(%2)             \n\t"                                \
        "mov.d $f4, $f0                 \n\t" /* A2             a2         */\
        "pmaddhw $f6, $f6, $f16         \n\t" /* -C1R7+C3R5     -C1r7+C3r5 */\
        "paddw $f8, $f8, $f14           \n\t" /* B2             b2         */\
        "paddw $f4, $f4, $f8            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f0, $f0, $f8            \n\t" /* a2-B2          a2-b2      */\
        "psraw $f4, $f4, $f18           \n\t"                                \
        "psraw $f0, $f0, $f18           \n\t"                                \
        "mov.d $f8, $f12                \n\t" /* A3             a3         */\
        "paddw $f6, $f6, $f2            \n\t" /* B3             b3         */\
        "paddw $f12, $f12, $f6          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f8, $f8, $f6            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "packsswh $f4, $f4, $f12        \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2   */\
        "sdc1 $f4, 8+" #dst "           \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "packsswh $f8, $f8, $f0         \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3   */\
        "sdc1 $f8, 16+" #dst "          \n\t"                                \

        //IDCT(       src0,   src4,   src1,   src5,    dst,     rounder, shift)
        DC_COND_IDCT(0(%0),  8(%0), 16(%0), 24(%0),  0(%1), paddw,8(%2), 11)
        Z_COND_IDCT(32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddw,(%2), 11, 4f)
        Z_COND_IDCT(64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddw,(%2), 11, 2f)
        Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1), paddw,(%2), 11, 1f)

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f2, " #src4 "            \n\t" /* R6     R2      r6      r2 */\
        "ldc1 $f4, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f6, " #src5 "            \n\t" /* R7     R5      r7      r5 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f10, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "pmaddhw $f10, $f10, $f2        \n\t" /* C6R6+C2R2      C6r6+C2r2  */\
        "ldc1 $f12, 40(%2)              \n\t" /* -C2    C6      -C2     C6 */\
        "pmaddhw $f2, $f2, $f12         \n\t" /* -C2R6+C6R2     -C2r6+C6r2 */\
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f14, 48(%2)              \n\t" /* C3     C1      C3      C1 */\
        "pmaddhw $f14, $f14, $f4        \n\t" /* C3R3+C1R1      C3r3+C1r1  */\
        "paddw $f8, $f8, $f10           \n\t" /* A0             a0         */\
        "psubw $f12, $f12, $f10         \n\t" /* A3             a3         */\
        "mov.d $f10, $f0                \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "paddw $f0, $f0, $f2            \n\t" /* A1             a1         */\
        "psubw $f10, $f10, $f2          \n\t" /* A2             a2         */\
        "ldc1 $f2, 56(%2)               \n\t" /* C7     C5      C7      C5 */\
        "ldc1 $f16, 64(%2)              \n\t"                                \
        "pmaddhw $f2, $f2, $f6          \n\t" /* C7R7+C5R5      C7r7+C5r5  */\
        "pmaddhw $f4, $f4, $f16         \n\t" /* -C7R3+C3R1     -C7r3+C3r1 */\
        "li $10, " #shift "             \n\t"                                \
        "paddw $f14, $f14, $f2          \n\t" /* B0             b0         */\
        "ldc1 $f2, 72(%2)               \n\t" /* -C5    -C1     -C5    -C1 */\
        "mtc1 $10, $f18                 \n\t"                                \
        "pmaddhw $f2, $f2, $f6          \n\t" /* -C5R7-C1R5     -C5r7-C1r5 */\
        "paddw $f14, $f14, $f8          \n\t" /* A0+B0          a0+b0      */\
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "psubw $f8, $f8, $f14           \n\t" /* A0-B0          a0-b0      */\
        "paddw $f2, $f2, $f4            \n\t" /* B1             b1         */\
        "psraw $f14, $f14, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f4, $f0                 \n\t" /* A1             a1         */\
        "paddw $f0, $f0, $f2            \n\t" /* A1+B1          a1+b1      */\
        "psubw $f4, $f4, $f2            \n\t" /* A1-B1          a1-b1      */\
        "psraw $f0, $f0, $f18           \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f14, $f14, $f14      \n\t" /* A0+B0          a0+b0      */\
        "swc1 $f14, " #dst "            \n\t"                                \
        "packsswh $f0, $f0, $f0         \n\t" /* A1+B1          a1+b1      */\
        "swc1 $f0, 16+" #dst "          \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A1-B1          a1-b1      */\
        "swc1 $f4, 96+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A0-B0          a0-b0      */\
        "swc1 $f8, 112+" #dst "         \n\t"                                \
        "ldc1 $f0, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f8, 80(%2)               \n\t" /* -C1    C5      -C1     C5 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* -C1R3+C5R1     -C1r3+C5r1 */\
        "ldc1 $f16, 96(%2)              \n\t"                                \
        "ldc1 $f14, 88(%2)              \n\t" /* C3     C7      C3      C7 */\
        "pmaddhw $f0, $f0, $f16         \n\t" /* -C5R3+C7R1     -C5r3+C7r1 */\
        "pmaddhw $f14, $f14, $f6        \n\t" /* C3R7+C7R5      C3r7+C7r5  */\
        "ldc1 $f16, 104(%2)             \n\t"                                \
        "mov.d $f4, $f10                \n\t" /* A2             a2         */\
        "pmaddhw $f6, $f6, $f16         \n\t" /* -C1R7+C3R5     -C1r7+C3r5 */\
        "paddw $f8, $f8, $f14           \n\t" /* B2             b2         */\
        "paddw $f4, $f4, $f8            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f10, $f10, $f8          \n\t" /* a2-B2          a2-b2      */\
        "psraw $f4, $f4, $f18           \n\t"                                \
        "psraw $f10, $f10, $f18         \n\t"                                \
        "mov.d $f8, $f12                \n\t" /* A3             a3         */\
        "paddw $f6, $f6, $f0            \n\t" /* B3             b3         */\
        "paddw $f12, $f12, $f6          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f8, $f8, $f6            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A2+B2          a2+b2      */\
        "packsswh $f12, $f12, $f12      \n\t" /* A3+B3          a3+b3      */\
        "swc1 $f4, 32+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A3-B3          a3-b3      */\
        "packsswh $f10, $f10, $f10      \n\t" /* A2-B2          a2-b2      */\
        "swc1 $f12, 48+" #dst "         \n\t"                                \
        "swc1 $f8, 64+" #dst "          \n\t"                                \
        "swc1 $f10, 80+" #dst "         \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)
        IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),    20)
        "b 9f                           \n\t"

        "# .p2align 4                   \n\t"
        "4:                             \n\t"
        Z_COND_IDCT(64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddw,(%2), 11, 6f)
        Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1),paddw,(%2), 11, 5f)

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f2, " #src4 "            \n\t" /* R6     R2      r6      r2 */\
        "ldc1 $f6, " #src5 "            \n\t" /* R7     R5      r7      r5 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f10, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "pmaddhw $f10, $f10, $f2        \n\t" /* C6R6+C2R2      C6r6+C2r2  */\
        "ldc1 $f12, 40(%2)              \n\t" /* -C2    C6      -C2     C6 */\
        "pmaddhw $f2, $f2, $f12         \n\t" /* -C2R6+C6R2     -C2r6+C6r2 */\
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "paddw $f8, $f8, $f10           \n\t" /* A0             a0         */\
        "psubw $f12, $f12, $f10         \n\t" /* A3             a3         */\
        "mov.d $f10, $f0                \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "paddw $f0, $f0, $f2            \n\t" /* A1             a1         */\
        "psubw $f10, $f10, $f2          \n\t" /* A2             a2         */\
        "ldc1 $f2, 56(%2)               \n\t" /* C7     C5      C7      C5 */\
        "li $10, " #shift "             \n\t"                                \
        "pmaddhw $f2, $f2, $f6          \n\t" /* C7R7+C5R5      C7r7+C5r5  */\
        "ldc1 $f14, 72(%2)              \n\t" /* -C5    -C1     -C5    -C1 */\
        "mtc1 $10, $f18                 \n\t"                                \
        "pmaddhw $f14, $f14, $f6        \n\t" /* -C5R7-C1R5     -C5r7-C1r5 */\
        "paddw $f2, $f2, $f8            \n\t" /* A0+B0          a0+b0      */\
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "psubw $f8, $f8, $f2            \n\t" /* A0-B0          a0-b0      */\
        "psraw $f2, $f2, $f18           \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f4, $f0                 \n\t" /* A1             a1         */\
        "paddw $f0, $f0, $f14           \n\t" /* A1+B1          a1+b1      */\
        "psubw $f4, $f4, $f14           \n\t" /* A1-B1          a1-b1      */\
        "psraw $f0, $f0, $f18           \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f2, $f2, $f2         \n\t" /* A0+B0          a0+b0      */\
        "swc1 $f2, " #dst "             \n\t"                                \
        "packsswh $f0, $f0, $f0         \n\t" /* A1+B1          a1+b1      */\
        "swc1 $f0, 16+" #dst "          \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A1-B1          a1-b1      */\
        "swc1 $f4, 96+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A0-B0          a0-b0      */\
        "swc1 $f8, 112+" #dst "         \n\t"                                \
        "ldc1 $f2, 88(%2)               \n\t" /* C3     C7      C3      C7 */\
        "ldc1 $f16, 104(%2)             \n\t"                                \
        "pmaddhw $f2, $f2, $f6          \n\t" /* C3R7+C7R5      C3r7+C7r5  */\
        "mov.d $f4, $f10                \n\t" /* A2             a2         */\
        "pmaddhw $f6, $f6, $f16         \n\t" /* -C1R7+C3R5     -C1r7+C3r5 */\
        "paddw $f4, $f4, $f2            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f10, $f10, $f2          \n\t" /* a2-B2          a2-b2      */\
        "psraw $f4, $f4, $f18           \n\t"                                \
        "psraw $f10, $f10, $f18         \n\t"                                \
        "mov.d $f2, $f12                \n\t" /* A3             a3         */\
        "paddw $f12, $f12, $f6          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f2, $f2, $f6            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "psraw $f2, $f2, $f18           \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A2+B2          a2+b2      */\
        "packsswh $f12, $f12, $f12      \n\t" /* A3+B3          a3+b3      */\
        "swc1 $f4, 32+" #dst "          \n\t"                                \
        "packsswh $f2, $f2, $f2         \n\t" /* A3-B3          a3-b3      */\
        "packsswh $f10, $f10, $f10      \n\t" /* A2-B2          a2-b2      */\
        "swc1 $f12, 48+" #dst "         \n\t"                                \
        "swc1 $f2, 64+" #dst "          \n\t"                                \
        "swc1 $f10, 80+" #dst "         \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)
        IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),    20)
        "b 9f                           \n\t"

        "# .p2align 4                   \n\t"
        "6:                             \n\t"
        Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1),paddw,(%2), 11, 7f)

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f6, " #src5 "            \n\t" /* R7     R5      r7      r5 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "mov.d $f10, $f0                \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f2, 56(%2)               \n\t" /* C7     C5      C7      C5 */\
        "pmaddhw $f2, $f2, $f6          \n\t" /* C7R7+C5R5      C7r7+C5r5  */\
        "ldc1 $f14, 72(%2)              \n\t" /* -C5    -C1     -C5    -C1 */\
        "li $10, " #shift "             \n\t"                                \
        "pmaddhw $f14, $f14, $f6        \n\t" /* -C5R7-C1R5     -C5r7-C1r5 */\
        "paddw $f2, $f2, $f8            \n\t" /* A0+B0          a0+b0      */\
        "mtc1 $10, $f18                 \n\t"                                \
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "psubw $f8, $f8, $f2            \n\t" /* A0-B0          a0-b0      */\
        "psraw $f2, $f2, $f18           \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f4, $f0                 \n\t" /* A1             a1         */\
        "paddw $f0, $f0, $f14           \n\t" /* A1+B1          a1+b1      */\
        "psubw $f4, $f4, $f14           \n\t" /* A1-B1          a1-b1      */\
        "psraw $f0, $f0, $f18           \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f2, $f2, $f2         \n\t" /* A0+B0          a0+b0      */\
        "swc1 $f2, " #dst "             \n\t"                                \
        "packsswh $f0, $f0, $f0         \n\t" /* A1+B1          a1+b1      */\
        "swc1 $f0, 16+" #dst "          \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A1-B1          a1-b1      */\
        "swc1 $f4, 96+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A0-B0          a0-b0      */\
        "swc1 $f8, 112+" #dst "         \n\t"                                \
        "ldc1 $f2, 88(%2)               \n\t" /* C3     C7      C3      C7 */\
        "ldc1 $f16, 104(%2)             \n\t"                                \
        "pmaddhw $f2, $f2, $f6          \n\t" /* C3R7+C7R5      C3r7+C7r5  */\
        "mov.d $f4, $f10                \n\t" /* A2             a2         */\
        "pmaddhw $f6, $f6, $f16         \n\t" /* -C1R7+C3R5     -C1r7+C3r5 */\
        "paddw $f4, $f4, $f2            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f10, $f10, $f2          \n\t" /* a2-B2          a2-b2      */\
        "psraw $f4, $f4, $f18           \n\t"                                \
        "psraw $f10, $f10, $f18         \n\t"                                \
        "mov.d $f2, $f12                \n\t" /* A3             a3         */\
        "paddw $f12, $f12, $f6          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f2, $f2, $f6            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "psraw $f2, $f2, $f18           \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A2+B2          a2+b2      */\
        "packsswh $f12, $f12, $f12      \n\t" /* A3+B3          a3+b3      */\
        "swc1 $f4, 32+" #dst "          \n\t"                                \
        "packsswh $f2, $f2, $f2         \n\t" /* A3-B3          a3-b3      */\
        "packsswh $f10, $f10, $f10      \n\t" /* A2-B2          a2-b2      */\
        "swc1 $f12, 48+" #dst "         \n\t"                                \
        "swc1 $f2, 64+" #dst "          \n\t"                                \
        "swc1 $f10, 80+" #dst "         \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)
        IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),    20)
        "b 9f                           \n\t"

        "# .p2align 4                   \n\t"
        "2:                             \n\t"
        Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1),paddw,(%2), 11, 3f)

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f4, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f6, " #src5 "            \n\t" /* R7     R5      r7      r5 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f14, 48(%2)              \n\t" /* C3     C1      C3      C1 */\
        "pmaddhw $f14, $f14, $f4        \n\t" /* C3R3+C1R1      C3r3+C1r1  */\
        "mov.d $f10, $f0                \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f2, 56(%2)               \n\t" /* C7     C5      C7      C5 */\
        "pmaddhw $f2, $f2, $f6          \n\t" /* C7R7+C5R5      C7r7+C5r5  */\
        "ldc1 $f16, 64(%2)              \n\t"                                \
        "pmaddhw $f4, $f4, $f16         \n\t" /* -C7R3+C3R1     -C7r3+C3r1 */\
        "paddw $f14, $f14, $f2          \n\t" /* B0             b0         */\
        "ldc1 $f2, 72(%2)               \n\t" /* -C5    -C1     -C5    -C1 */\
        "li $10, " #shift "             \n\t"                                \
        "pmaddhw $f2, $f2, $f6          \n\t" /* -C5R7-C1R5     -C5r7-C1r5 */\
        "paddw $f14, $f14, $f8          \n\t" /* A0+B0          a0+b0      */\
        "mtc1 $10, $f18                 \n\t"                                \
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "psubw $f8, $f8, $f14           \n\t" /* A0-B0          a0-b0      */\
        "paddw $f2, $f2, $f4            \n\t" /* B1             b1         */\
        "psraw $f14, $f14, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f4, $f0                 \n\t" /* A1             a1         */\
        "paddw $f0, $f0, $f2            \n\t" /* A1+B1          a1+b1      */\
        "psubw $f4, $f4, $f2            \n\t" /* A1-B1          a1-b1      */\
        "psraw $f0, $f0, $f18           \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f14, $f14, $f14      \n\t" /* A0+B0          a0+b0      */\
        "swc1 $f14, " #dst "            \n\t"                                \
        "packsswh $f0, $f0, $f0         \n\t" /* A1+B1          a1+b1      */\
        "swc1 $f0, 16+" #dst "          \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A1-B1          a1-b1      */\
        "swc1 $f4, 96+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A0-B0          a0-b0      */\
        "swc1 $f8, 112+" #dst "         \n\t"                                \
        "ldc1 $f0, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f8, 80(%2)               \n\t" /* -C1    C5      -C1     C5 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* -C1R3+C5R1     -C1r3+C5r1 */\
        "ldc1 $f14, 88(%2)              \n\t" /* C3     C7      C3      C7 */\
        "ldc1 $f16, 96(%2)              \n\t"                                \
        "pmaddhw $f0, $f0, $f16         \n\t" /* -C5R3+C7R1     -C5r3+C7r1 */\
        "pmaddhw $f14, $f14, $f6        \n\t" /* C3R7+C7R5      C3r7+C7r5  */\
        "mov.d $f4, $f10                \n\t" /* A2             a2         */\
        "ldc1 $f16, 104(%2)             \n\t"                                \
        "pmaddhw $f6, $f6, $f16         \n\t" /* -C1R7+C3R5     -C1r7+C3r5 */\
        "paddw $f8, $f8, $f14           \n\t" /* B2             b2         */\
        "paddw $f4, $f4, $f8            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f10, $f10, $f8          \n\t" /* a2-B2          a2-b2      */\
        "psraw $f4, $f4, $f18           \n\t"                                \
        "psraw $f10, $f10, $f18         \n\t"                                \
        "mov.d $f8, $f12                \n\t" /* A3             a3         */\
        "paddw $f6, $f6, $f0            \n\t" /* B3             b3         */\
        "paddw $f12, $f12, $f6          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f8, $f8, $f6            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "packsswh $f4, $f4, $f4         \n\t" /* A2+B2          a2+b2      */\
        "packsswh $f12, $f12, $f12      \n\t" /* A3+B3          a3+b3      */\
        "swc1 $f4, 32+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A3-B3          a3-b3      */\
        "packsswh $f10, $f10, $f10      \n\t" /* A2-B2          a2-b2      */\
        "swc1 $f12, 48+" #dst "         \n\t"                                \
        "swc1 $f8, 64+" #dst "          \n\t"                                \
        "swc1 $f10, 80+" #dst "         \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)
        IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),    20)
        "b 9f                           \n\t"

        "# .p2align 4                   \n\t"
        "3:                             \n\t"

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f4, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f14, 48(%2)              \n\t" /* C3     C1      C3      C1 */\
        "pmaddhw $f14, $f14, $f4        \n\t" /* C3R3+C1R1      C3r3+C1r1  */\
        "mov.d $f10, $f0                \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f6, 64(%2)               \n\t"                                \
        "pmaddhw $f6, $f6, $f4          \n\t" /* -C7R3+C3R1     -C7r3+C3r1 */\
        "li $10, " #shift "             \n\t"                                \
        "paddw $f14, $f14, $f8          \n\t" /* A0+B0          a0+b0      */\
        "mtc1 $10, $f18                 \n\t"                                \
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "psubw $f8, $f8, $f14           \n\t" /* A0-B0          a0-b0      */\
        "psraw $f14, $f14, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f2, $f0                 \n\t" /* A1             a1         */\
        "paddw $f0, $f0, $f6            \n\t" /* A1+B1          a1+b1      */\
        "psubw $f2, $f2, $f6            \n\t" /* A1-B1          a1-b1      */\
        "psraw $f0, $f0, $f18           \n\t"                                \
        "psraw $f2, $f2, $f18           \n\t"                                \
        "packsswh $f14, $f14, $f14      \n\t" /* A0+B0  a0+b0              */\
        "swc1 $f14, " #dst "            \n\t"                                \
        "packsswh $f0, $f0, $f0         \n\t" /* A1+B1  a1+b1              */\
        "swc1 $f0, 16+" #dst "          \n\t"                                \
        "packsswh $f2, $f2, $f2         \n\t" /* A1-B1  a1-b1              */\
        "swc1 $f2, 96+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A0-B0  a0-b0              */\
        "swc1 $f8, 112+" #dst "         \n\t"                                \
        "ldc1 $f8, 80(%2)               \n\t" /* -C1    C5      -C1     C5 */\
        "ldc1 $f16, 96(%2)              \n\t"                                \
        "pmaddhw $f8, $f8, $f4          \n\t" /* -C1R3+C5R1     -C1r3+C5r1 */\
        "pmaddhw $f4, $f4, $f16         \n\t" /* -C5R3+C7R1     -C5r3+C7r1 */\
        "mov.d $f2, $f10                \n\t" /* A2             a2         */\
        "paddw $f2, $f2, $f8            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f10, $f10, $f8          \n\t" /* a2-B2          a2-b2      */\
        "psraw $f2, $f2, $f18           \n\t"                                \
        "psraw $f10, $f10, $f18         \n\t"                                \
        "mov.d $f8, $f12                \n\t" /* A3             a3         */\
        "paddw $f12, $f12, $f4          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f8, $f8, $f4            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "packsswh $f2, $f2, $f2         \n\t" /* A2+B2  a2+b2              */\
        "packsswh $f12, $f12, $f12      \n\t" /* A3+B3  a3+b3              */\
        "swc1 $f2, 32+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A3-B3  a3-b3              */\
        "packsswh $f10, $f10, $f10      \n\t" /* A2-B2  a2-b2              */\
        "swc1 $f12, 48+" #dst "         \n\t"                                \
        "swc1 $f8, 64+" #dst "          \n\t"                                \
        "swc1 $f10, 80+" #dst "         \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)
        IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),    20)
        "b 9f                           \n\t"

        "# .p2align 4                   \n\t"
        "5:                             \n\t"

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f2, " #src4 "            \n\t" /* R6     R2      r6      r2 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f10, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "pmaddhw $f10, $f10, $f2        \n\t" /* C6R6+C2R2      C6r6+C2r2  */\
        "ldc1 $f12, 40(%2)              \n\t" /* -C2    C6      -C2     C6 */\
        "pmaddhw $f2, $f2, $f12         \n\t" /* -C2R6+C6R2     -C2r6+C6r2 */\
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "paddw $f8, $f8, $f10           \n\t" /* A0             a0         */\
        "psubw $f12, $f12, $f10         \n\t" /* A3             a3         */\
        "mov.d $f10, $f0                \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "paddw $f0, $f0, $f2            \n\t" /* A1             a1         */\
        "psubw $f10, $f10, $f2          \n\t" /* A2             a2         */\
        "ldc1 $f4, 8+" #src0 "          \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f6, 8+" #src4 "          \n\t" /* R6     R2      r6      r2 */\
        "ldc1 $f2, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f2, $f2, $f4          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f14, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f4, $f4, $f14         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f14, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "ldc1 $f16, 40(%2)              \n\t"                                \
        "pmaddhw $f14, $f14, $f6        \n\t" /* C6R6+C2R2      C6r6+C2r2  */\
        "pmaddhw $f6, $f6, $f16         \n\t" /* -C2R6+C6R2     -C2r6+C6r2 */\
        "paddw $f14, $f14, $f2          \n\t" /* A0             a0         */\
        "paddw $f2, $f2, $f2            \n\t" /* 2C0            2c0        */\
        "psubw $f2, $f2, $f14           \n\t" /* A3             a3         */\
        "li $10, " #shift "             \n\t"                                \
        "paddw $f6, $f6, $f4            \n\t" /* A1             a1         */\
        "mtc1 $10, $f18                 \n\t"                                \
        "paddw $f4, $f4, $f4            \n\t" /* 2C1            2c1        */\
        "psubw $f4, $f4, $f6            \n\t" /* A2             a2         */\
        "psraw $f8, $f8, $f18           \n\t"                                \
        "psraw $f14, $f14, $f18         \n\t"                                \
        "psraw $f6, $f6, $f18           \n\t"                                \
        "packsswh $f8, $f8, $f14        \n\t" /* A0             a0         */\
        "sdc1 $f8, " #dst "             \n\t"                                \
        "psraw $f0, $f0, $f18           \n\t"                                \
        "packsswh $f0, $f0, $f6         \n\t" /* A1             a1         */\
        "sdc1 $f0, 16+" #dst "          \n\t"                                \
        "sdc1 $f0, 96+" #dst "          \n\t"                                \
        "sdc1 $f8, 112+" #dst "         \n\t"                                \
        "psraw $f10, $f10, $f18         \n\t"                                \
        "psraw $f12, $f12, $f18         \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f10, $f10, $f4       \n\t" /* A2-B2          a2-b2      */\
        "sdc1 $f10, 32+" #dst "         \n\t"                                \
        "psraw $f2, $f2, $f18           \n\t"                                \
        "packsswh $f12, $f12, $f2       \n\t" /* A3+B3          a3+b3      */\
        "sdc1 $f12, 48+" #dst "         \n\t"                                \
        "sdc1 $f12, 64+" #dst "         \n\t"                                \
        "sdc1 $f10, 80+" #dst "         \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(   0(%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)
        "b 9f                           \n\t"

        "# .p2align 4                   \n\t"
        "1:                             \n\t"

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f2, " #src4 "            \n\t" /* R6     R2      r6      r2 */\
        "ldc1 $f4, " #src1 "            \n\t" /* R3     R1      r3      r1 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "li $10, " #shift "             \n\t"                                \
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "mtc1 $10, $f18                 \n\t"                                \
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f10, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "pmaddhw $f10, $f10, $f2        \n\t" /* C6R6+C2R2      C6r6+C2r2  */\
        "ldc1 $f12, 40(%2)              \n\t" /* -C2    C6      -C2     C6 */\
        "pmaddhw $f2, $f2, $f12         \n\t" /* -C2R6+C6R2     -C2r6+C6r2 */\
        "mov.d $f12, $f8                \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f14, 48(%2)              \n\t" /* C3     C1      C3      C1 */\
        "pmaddhw $f14, $f14, $f4        \n\t" /* C3R3+C1R1      C3r3+C1r1  */\
        "paddw $f8, $f8, $f10           \n\t" /* A0             a0         */\
        "psubw $f12, $f12, $f10         \n\t" /* A3             a3         */\
        "mov.d $f10, $f0                \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "paddw $f0, $f0, $f2            \n\t" /* A1             a1         */\
        "psubw $f10, $f10, $f2          \n\t" /* A2             a2         */\
        "ldc1 $f2, 64(%2)               \n\t"                                \
        "pmaddhw $f2, $f2, $f4          \n\t" /* -C7R3+C3R1     -C7r3+C3r1 */\
        "paddw $f14, $f14, $f8          \n\t" /* A0+B0          a0+b0      */\
        "paddw $f8, $f8, $f8            \n\t" /* 2A0            2a0        */\
        "psubw $f8, $f8, $f14           \n\t" /* A0-B0          a0-b0      */\
        "psraw $f14, $f14, $f18         \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "mov.d $f6, $f0                 \n\t" /* A1             a1         */\
        "paddw $f0, $f0, $f2            \n\t" /* A1+B1          a1+b1      */\
        "psubw $f6, $f6, $f2            \n\t" /* A1-B1          a1-b1      */\
        "psraw $f0, $f0, $f18           \n\t"                                \
        "psraw $f6, $f6, $f18           \n\t"                                \
        "packsswh $f14, $f14, $f14      \n\t" /* A0+B0  a0+b0              */\
        "swc1 $f14, " #dst "            \n\t"                                \
        "packsswh $f0, $f0, $f0         \n\t" /* A1+B1  a1+b1              */\
        "swc1 $f0, 16+" #dst "          \n\t"                                \
        "packsswh $f6, $f6, $f6         \n\t" /* A1-B1  a1-b1              */\
        "swc1 $f6, 96+" #dst "          \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A0-B0  a0-b0              */\
        "swc1 $f8, 112+" #dst "         \n\t"                                \
        "ldc1 $f8, 80(%2)               \n\t" /* -C1    C5      -C1     C5 */\
        "ldc1 $f16, 96(%2)              \n\t"                                \
        "pmaddhw $f8, $f8, $f4          \n\t" /* -C1R3+C5R1     -C1r3+C5r1 */\
        "pmaddhw $f4, $f4, $f16         \n\t" /* -C5R3+C7R1     -C5r3+C7r1 */\
        "mov.d $f6, $f10                \n\t" /* A2             a2         */\
        "paddw $f6, $f6, $f8            \n\t" /* A2+B2          a2+b2      */\
        "psubw $f10, $f10, $f8          \n\t" /* a2-B2          a2-b2      */\
        "psraw $f6, $f6, $f18           \n\t"                                \
        "psraw $f10, $f10, $f18         \n\t"                                \
        "mov.d $f8, $f12                \n\t" /* A3             a3         */\
        "paddw $f12, $f12, $f4          \n\t" /* A3+B3          a3+b3      */\
        "psubw $f8, $f8, $f4            \n\t" /* a3-B3          a3-b3      */\
        "psraw $f12, $f12, $f18         \n\t"                                \
        "packsswh $f6, $f6, $f6         \n\t" /* A2+B2          a2+b2      */\
        "swc1 $f6, 32+" #dst "          \n\t"                                \
        "psraw $f8, $f8, $f18           \n\t"                                \
        "packsswh $f12, $f12, $f12      \n\t" /* A3+B3          a3+b3      */\
        "swc1 $f12, 48+" #dst "         \n\t"                                \
        "packsswh $f8, $f8, $f8         \n\t" /* A3-B3          a3-b3      */\
        "packsswh $f10, $f10, $f10      \n\t" /* A2-B2          a2-b2      */\
        "swc1 $f8, 64+" #dst "          \n\t"                                \
        "swc1 $f10, 80+" #dst "         \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)
        IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),    20)
        "b 9f                           \n\t"

        "# .p2align 4                   \n\t"
        "7:                             \n\t"

#undef  IDCT
#define IDCT(src0, src4, src1, src5, dst, shift)                             \
        "ldc1 $f0, " #src0 "            \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f8, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "li $10, " #shift "             \n\t"                                \
        "pmaddhw $f8, $f8, $f0          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "mtc1 $10, $f18                 \n\t"                                \
        "ldc1 $f10, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f0, $f0, $f10         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "psraw $f8, $f8, $f18           \n\t"                                \
        "psraw $f0, $f0, $f18           \n\t"                                \
        "ldc1 $f4, 8+" #src0 "          \n\t" /* R4     R0      r4      r0 */\
        "ldc1 $f2, 16(%2)               \n\t" /* C4     C4      C4      C4 */\
        "pmaddhw $f2, $f2, $f4          \n\t" /* C4R4+C4R0      C4r4+C4r0  */\
        "ldc1 $f14, 24(%2)              \n\t" /* -C4    C4      -C4     C4 */\
        "pmaddhw $f4, $f4, $f14         \n\t" /* -C4R4+C4R0     -C4r4+C4r0 */\
        "ldc1 $f14, 32(%2)              \n\t" /* C6     C2      C6      C2 */\
        "psraw $f2, $f2, $f18           \n\t"                                \
        "packsswh $f8, $f8, $f2         \n\t" /* A0             a0         */\
        "sdc1 $f8, " #dst "             \n\t"                                \
        "psraw $f4, $f4, $f18           \n\t"                                \
        "packsswh $f0, $f0, $f4         \n\t" /* A1             a1         */\
        "sdc1 $f0, 16+" #dst "          \n\t"                                \
        "sdc1 $f0, 96+" #dst "          \n\t"                                \
        "sdc1 $f8, 112+" #dst "         \n\t"                                \
        "sdc1 $f0, 32+" #dst "          \n\t"                                \
        "sdc1 $f8, 48+" #dst "          \n\t"                                \
        "sdc1 $f8, 64+" #dst "          \n\t"                                \
        "sdc1 $f0, 80+" #dst "          \n\t"

        //IDCT(  src0,   src4,   src1,    src5,    dst, shift)
        IDCT(   0(%1), 64(%1), 32(%1),  96(%1),  0(%0),    20)
        IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),    20)

        "9:                             \n\t"
        ::"r"(block),"r"(temp),"r"(coeffs),"m"(ff_wm1010),"m"(ff_d40000)
        : "$10","$11"
    );
}

void ff_simple_idct_mmi(int16_t *block)
{
    simple_idct_mmi(block);
}

void ff_simple_idct_put_mmi(uint8_t *dest, int32_t line_size, int16_t *block)
{
    simple_idct_mmi(block);
    ff_put_pixels_clamped_mmi(block, dest, line_size);
}

void ff_simple_idct_add_mmi(uint8_t *dest, int32_t line_size, int16_t *block)
{
    simple_idct_mmi(block);
    ff_add_pixels_clamped_mmi(block, dest, line_size);
}