summaryrefslogtreecommitdiffstats
path: root/libvpx/vp9/common/mips/dspr2/vp9_itrans32_dspr2.c
blob: d3aee73cbc2df68e96bed042da630ff5cfc8805e (plain)
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
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
/*
 *  Copyright (c) 2013 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <assert.h>
#include <stdio.h>

#include "./vpx_config.h"
#include "./vp9_rtcd.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_idct.h"
#include "vp9/common/mips/dspr2/vp9_common_dspr2.h"

#if HAVE_DSPR2
static void idct32_1d_rows_dspr2(const int16_t *input, int16_t *output) {
  int16_t step1_0, step1_1, step1_2, step1_3, step1_4, step1_5, step1_6;
  int16_t step1_7, step1_8, step1_9, step1_10, step1_11, step1_12, step1_13;
  int16_t step1_14, step1_15, step1_16, step1_17, step1_18, step1_19, step1_20;
  int16_t step1_21, step1_22, step1_23, step1_24, step1_25, step1_26, step1_27;
  int16_t step1_28, step1_29, step1_30, step1_31;
  int16_t step2_0, step2_1, step2_2, step2_3, step2_4, step2_5, step2_6;
  int16_t step2_7, step2_8, step2_9, step2_10, step2_11, step2_12, step2_13;
  int16_t step2_14, step2_15, step2_16, step2_17, step2_18, step2_19, step2_20;
  int16_t step2_21, step2_22, step2_23, step2_24, step2_25, step2_26, step2_27;
  int16_t step2_28, step2_29, step2_30, step2_31;
  int16_t step3_8, step3_9, step3_10, step3_11, step3_12, step3_13, step3_14;
  int16_t step3_15, step3_16, step3_17, step3_18, step3_19, step3_20, step3_21;
  int16_t step3_22, step3_23, step3_24, step3_25, step3_26, step3_27, step3_28;
  int16_t step3_29, step3_30, step3_31;
  int temp0, temp1, temp2, temp3;
  int load1, load2, load3, load4;
  int result1, result2;
  int temp21;
  int i;
  const int const_2_power_13 = 8192;
  const int32_t *input_int;

  for (i = 32; i--; ) {
    input_int = (const int32_t *)input;

    if (!(input_int[0]  | input_int[1]  | input_int[2]  | input_int[3]  |
          input_int[4]  | input_int[5]  | input_int[6]  | input_int[7]  |
          input_int[8]  | input_int[9]  | input_int[10] | input_int[11] |
          input_int[12] | input_int[13] | input_int[14] | input_int[15])) {
      input += 32;

      __asm__ __volatile__ (
          "sh     $zero,     0(%[output])     \n\t"
          "sh     $zero,    64(%[output])     \n\t"
          "sh     $zero,   128(%[output])     \n\t"
          "sh     $zero,   192(%[output])     \n\t"
          "sh     $zero,   256(%[output])     \n\t"
          "sh     $zero,   320(%[output])     \n\t"
          "sh     $zero,   384(%[output])     \n\t"
          "sh     $zero,   448(%[output])     \n\t"
          "sh     $zero,   512(%[output])     \n\t"
          "sh     $zero,   576(%[output])     \n\t"
          "sh     $zero,   640(%[output])     \n\t"
          "sh     $zero,   704(%[output])     \n\t"
          "sh     $zero,   768(%[output])     \n\t"
          "sh     $zero,   832(%[output])     \n\t"
          "sh     $zero,   896(%[output])     \n\t"
          "sh     $zero,   960(%[output])     \n\t"
          "sh     $zero,  1024(%[output])     \n\t"
          "sh     $zero,  1088(%[output])     \n\t"
          "sh     $zero,  1152(%[output])     \n\t"
          "sh     $zero,  1216(%[output])     \n\t"
          "sh     $zero,  1280(%[output])     \n\t"
          "sh     $zero,  1344(%[output])     \n\t"
          "sh     $zero,  1408(%[output])     \n\t"
          "sh     $zero,  1472(%[output])     \n\t"
          "sh     $zero,  1536(%[output])     \n\t"
          "sh     $zero,  1600(%[output])     \n\t"
          "sh     $zero,  1664(%[output])     \n\t"
          "sh     $zero,  1728(%[output])     \n\t"
          "sh     $zero,  1792(%[output])     \n\t"
          "sh     $zero,  1856(%[output])     \n\t"
          "sh     $zero,  1920(%[output])     \n\t"
          "sh     $zero,  1984(%[output])     \n\t"

          :
          : [output] "r" (output)
      );

      output += 1;

      continue;
    }

    /* prefetch row */
    vp9_prefetch_load((const uint8_t *)(input + 32));
    vp9_prefetch_load((const uint8_t *)(input + 48));

    __asm__ __volatile__ (
        "lh       %[load1],             2(%[input])                     \n\t"
        "lh       %[load2],             62(%[input])                    \n\t"
        "lh       %[load3],             34(%[input])                    \n\t"
        "lh       %[load4],             30(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_31_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_1_64]   \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"

        "madd     $ac3,                 %[load1],       %[cospi_1_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_31_64]  \n\t"
        "extp     %[temp3],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"

        "madd     $ac2,                 %[load3],       %[cospi_15_64]  \n\t"
        "msub     $ac2,                 %[load4],       %[cospi_17_64]  \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "madd     $ac1,                 %[load3],       %[cospi_17_64]  \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_15_64]  \n\t"
        "extp     %[temp2],             $ac1,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "sub      %[load1],             %[temp3],       %[temp2]        \n\t"
        "sub      %[load2],             %[temp0],       %[temp1]        \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_28_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_4_64]   \n\t"
        "madd     $ac3,                 %[load1],       %[cospi_4_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_28_64]  \n\t"

        "extp     %[step1_17],          $ac1,           31              \n\t"
        "extp     %[step1_30],          $ac3,           31              \n\t"
        "add      %[step1_16],          %[temp0],       %[temp1]        \n\t"
        "add      %[step1_31],          %[temp2],       %[temp3]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step1_16] "=r" (step1_16), [step1_17] "=r" (step1_17),
          [step1_30] "=r" (step1_30), [step1_31] "=r" (step1_31)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_31_64] "r" (cospi_31_64), [cospi_1_64] "r" (cospi_1_64),
          [cospi_4_64] "r" (cospi_4_64), [cospi_17_64] "r" (cospi_17_64),
          [cospi_15_64] "r" (cospi_15_64), [cospi_28_64] "r" (cospi_28_64)
    );

    __asm__ __volatile__ (
        "lh       %[load1],             18(%[input])                    \n\t"
        "lh       %[load2],             46(%[input])                    \n\t"
        "lh       %[load3],             50(%[input])                    \n\t"
        "lh       %[load4],             14(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_23_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_9_64]   \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"

        "madd     $ac3,                 %[load1],       %[cospi_9_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_23_64]  \n\t"
        "extp     %[temp3],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"

        "madd     $ac2,                 %[load3],       %[cospi_7_64]   \n\t"
        "msub     $ac2,                 %[load4],       %[cospi_25_64]  \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "madd     $ac1,                 %[load3],       %[cospi_25_64]  \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_7_64]   \n\t"
        "extp     %[temp2],             $ac1,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "sub      %[load1],             %[temp1],       %[temp0]        \n\t"
        "sub      %[load2],             %[temp2],       %[temp3]        \n\t"

        "msub     $ac1,                 %[load1],       %[cospi_28_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_4_64]   \n\t"
        "msub     $ac3,                 %[load1],       %[cospi_4_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_28_64]  \n\t"

        "extp     %[step1_18],          $ac1,           31              \n\t"
        "extp     %[step1_29],          $ac3,           31              \n\t"
        "add      %[step1_19],          %[temp0],       %[temp1]        \n\t"
        "add      %[step1_28],          %[temp2],       %[temp3]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step1_18] "=r" (step1_18), [step1_19] "=r" (step1_19),
          [step1_28] "=r" (step1_28), [step1_29] "=r" (step1_29)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_23_64] "r" (cospi_23_64), [cospi_9_64] "r" (cospi_9_64),
          [cospi_4_64] "r" (cospi_4_64), [cospi_7_64] "r" (cospi_7_64),
          [cospi_25_64] "r" (cospi_25_64), [cospi_28_64] "r" (cospi_28_64)
    );

    __asm__ __volatile__ (
        "lh       %[load1],             10(%[input])                    \n\t"
        "lh       %[load2],             54(%[input])                    \n\t"
        "lh       %[load3],             42(%[input])                    \n\t"
        "lh       %[load4],             22(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_27_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_5_64]   \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"

        "madd     $ac3,                 %[load1],       %[cospi_5_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_27_64]  \n\t"
        "extp     %[temp3],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"

        "madd     $ac2,                 %[load3],       %[cospi_11_64]  \n\t"
        "msub     $ac2,                 %[load4],       %[cospi_21_64]  \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "madd     $ac1,                 %[load3],       %[cospi_21_64]  \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_11_64]  \n\t"
        "extp     %[temp2],             $ac1,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "sub      %[load1],             %[temp0],       %[temp1]        \n\t"
        "sub      %[load2],             %[temp3],       %[temp2]        \n\t"

        "madd     $ac1,                 %[load2],       %[cospi_12_64]  \n\t"
        "msub     $ac1,                 %[load1],       %[cospi_20_64]  \n\t"
        "madd     $ac3,                 %[load1],       %[cospi_12_64]  \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_20_64]  \n\t"

        "extp     %[step1_21],          $ac1,           31              \n\t"
        "extp     %[step1_26],          $ac3,           31              \n\t"
        "add      %[step1_20],          %[temp0],       %[temp1]        \n\t"
        "add      %[step1_27],          %[temp2],       %[temp3]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step1_20] "=r" (step1_20), [step1_21] "=r" (step1_21),
          [step1_26] "=r" (step1_26), [step1_27] "=r" (step1_27)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_27_64] "r" (cospi_27_64), [cospi_5_64] "r" (cospi_5_64),
          [cospi_11_64] "r" (cospi_11_64), [cospi_21_64] "r" (cospi_21_64),
          [cospi_12_64] "r" (cospi_12_64), [cospi_20_64] "r" (cospi_20_64)
    );

    __asm__ __volatile__ (
        "lh       %[load1],             26(%[input])                    \n\t"
        "lh       %[load2],             38(%[input])                    \n\t"
        "lh       %[load3],             58(%[input])                    \n\t"
        "lh       %[load4],              6(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_19_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_13_64]  \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"

        "madd     $ac3,                 %[load1],       %[cospi_13_64]  \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_19_64]  \n\t"
        "extp     %[temp3],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"

        "madd     $ac2,                 %[load3],       %[cospi_3_64]   \n\t"
        "msub     $ac2,                 %[load4],       %[cospi_29_64]  \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "madd     $ac1,                 %[load3],       %[cospi_29_64]  \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_3_64]   \n\t"
        "extp     %[temp2],             $ac1,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "sub      %[load1],             %[temp1],       %[temp0]        \n\t"
        "sub      %[load2],             %[temp2],       %[temp3]        \n\t"

        "msub     $ac1,                 %[load1],       %[cospi_12_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_20_64]  \n\t"
        "msub     $ac3,                 %[load1],       %[cospi_20_64]  \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_12_64]  \n\t"

        "extp     %[step1_22],          $ac1,           31              \n\t"
        "extp     %[step1_25],          $ac3,           31              \n\t"
        "add      %[step1_23],          %[temp0],       %[temp1]        \n\t"
        "add      %[step1_24],          %[temp2],       %[temp3]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step1_22] "=r" (step1_22), [step1_23] "=r" (step1_23),
          [step1_24] "=r" (step1_24), [step1_25] "=r" (step1_25)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_19_64] "r" (cospi_19_64), [cospi_13_64] "r" (cospi_13_64),
          [cospi_3_64] "r" (cospi_3_64), [cospi_29_64] "r" (cospi_29_64),
          [cospi_12_64] "r" (cospi_12_64), [cospi_20_64] "r" (cospi_20_64)
    );

    __asm__ __volatile__ (
        "lh       %[load1],              4(%[input])                    \n\t"
        "lh       %[load2],             60(%[input])                    \n\t"
        "lh       %[load3],             36(%[input])                    \n\t"
        "lh       %[load4],             28(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_30_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_2_64]   \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"

        "madd     $ac3,                 %[load1],       %[cospi_2_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_30_64]  \n\t"
        "extp     %[temp3],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"

        "madd     $ac2,                 %[load3],       %[cospi_14_64]  \n\t"
        "msub     $ac2,                 %[load4],       %[cospi_18_64]  \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "madd     $ac1,                 %[load3],       %[cospi_18_64]  \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_14_64]  \n\t"
        "extp     %[temp2],             $ac1,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "sub      %[load1],             %[temp0],       %[temp1]        \n\t"
        "sub      %[load2],             %[temp3],       %[temp2]        \n\t"

        "msub     $ac1,                 %[load1],       %[cospi_8_64]   \n\t"
        "madd     $ac1,                 %[load2],       %[cospi_24_64]  \n\t"
        "madd     $ac3,                 %[load1],       %[cospi_24_64]  \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_8_64]   \n\t"

        "extp     %[step2_9],           $ac1,           31              \n\t"
        "extp     %[step2_14],          $ac3,           31              \n\t"
        "add      %[step2_8],           %[temp0],       %[temp1]        \n\t"
        "add      %[step2_15],          %[temp2],       %[temp3]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step2_8] "=r" (step2_8), [step2_9] "=r" (step2_9),
          [step2_14] "=r" (step2_14), [step2_15] "=r" (step2_15)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_30_64] "r" (cospi_30_64), [cospi_2_64] "r" (cospi_2_64),
          [cospi_14_64] "r" (cospi_14_64), [cospi_18_64] "r" (cospi_18_64),
          [cospi_8_64] "r" (cospi_8_64), [cospi_24_64] "r" (cospi_24_64)
    );

    __asm__ __volatile__ (
        "lh       %[load1],             20(%[input])                    \n\t"
        "lh       %[load2],             44(%[input])                    \n\t"
        "lh       %[load3],             52(%[input])                    \n\t"
        "lh       %[load4],             12(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_22_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_10_64]  \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"

        "madd     $ac3,                 %[load1],       %[cospi_10_64]  \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_22_64]  \n\t"
        "extp     %[temp3],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"

        "madd     $ac2,                 %[load3],       %[cospi_6_64]   \n\t"
        "msub     $ac2,                 %[load4],       %[cospi_26_64]  \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "madd     $ac1,                 %[load3],       %[cospi_26_64]  \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_6_64]   \n\t"
        "extp     %[temp2],             $ac1,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "sub      %[load1],             %[temp1],       %[temp0]        \n\t"
        "sub      %[load2],             %[temp2],       %[temp3]        \n\t"

        "msub     $ac1,                 %[load1],       %[cospi_24_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_8_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_24_64]  \n\t"
        "msub     $ac3,                 %[load1],       %[cospi_8_64]   \n\t"

        "extp     %[step2_10],          $ac1,           31              \n\t"
        "extp     %[step2_13],          $ac3,           31              \n\t"
        "add      %[step2_11],          %[temp0],       %[temp1]        \n\t"
        "add      %[step2_12],          %[temp2],       %[temp3]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step2_10] "=r" (step2_10), [step2_11] "=r" (step2_11),
          [step2_12] "=r" (step2_12), [step2_13] "=r" (step2_13)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_22_64] "r" (cospi_22_64), [cospi_10_64] "r" (cospi_10_64),
          [cospi_6_64] "r" (cospi_6_64), [cospi_26_64] "r" (cospi_26_64),
          [cospi_8_64] "r" (cospi_8_64), [cospi_24_64] "r" (cospi_24_64)
    );

    __asm__ __volatile__ (
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "sub      %[temp0],             %[step2_14],    %[step2_13]     \n\t"
        "sub      %[temp0],             %[temp0],       %[step2_9]      \n\t"
        "add      %[temp0],             %[temp0],       %[step2_10]     \n\t"
        "madd     $ac0,                 %[temp0],       %[cospi_16_64]  \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "sub      %[temp1],             %[step2_14],    %[step2_13]     \n\t"
        "add      %[temp1],             %[temp1],       %[step2_9]      \n\t"
        "sub      %[temp1],             %[temp1],       %[step2_10]     \n\t"
        "madd     $ac1,                 %[temp1],       %[cospi_16_64]  \n\t"

        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"
        "sub      %[temp0],             %[step2_15],    %[step2_12]     \n\t"
        "sub      %[temp0],             %[temp0],       %[step2_8]      \n\t"
        "add      %[temp0],             %[temp0],       %[step2_11]     \n\t"
        "madd     $ac2,                 %[temp0],       %[cospi_16_64]  \n\t"

        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"
        "sub      %[temp1],             %[step2_15],    %[step2_12]     \n\t"
        "add      %[temp1],             %[temp1],       %[step2_8]      \n\t"
        "sub      %[temp1],             %[temp1],       %[step2_11]     \n\t"
        "madd     $ac3,                 %[temp1],       %[cospi_16_64]  \n\t"

        "add      %[step3_8],           %[step2_8],     %[step2_11]     \n\t"
        "add      %[step3_9],           %[step2_9],     %[step2_10]     \n\t"
        "add      %[step3_14],          %[step2_13],    %[step2_14]     \n\t"
        "add      %[step3_15],          %[step2_12],    %[step2_15]     \n\t"

        "extp     %[step3_10],          $ac0,           31              \n\t"
        "extp     %[step3_13],          $ac1,           31              \n\t"
        "extp     %[step3_11],          $ac2,           31              \n\t"
        "extp     %[step3_12],          $ac3,           31              \n\t"

        : [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [step3_8] "=r" (step3_8), [step3_9] "=r" (step3_9),
          [step3_10] "=r" (step3_10), [step3_11] "=r" (step3_11),
          [step3_12] "=r" (step3_12), [step3_13] "=r" (step3_13),
          [step3_14] "=r" (step3_14), [step3_15] "=r" (step3_15)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_8] "r" (step2_8), [step2_9] "r" (step2_9),
          [step2_10] "r" (step2_10), [step2_11] "r" (step2_11),
          [step2_12] "r" (step2_12), [step2_13] "r" (step2_13),
          [step2_14] "r" (step2_14), [step2_15] "r" (step2_15),
          [cospi_16_64] "r" (cospi_16_64)
    );

    step2_18 = step1_17 - step1_18;
    step2_29 = step1_30 - step1_29;

    __asm__ __volatile__ (
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "msub     $ac0,                 %[step2_18],    %[cospi_8_64]   \n\t"
        "madd     $ac0,                 %[step2_29],    %[cospi_24_64]  \n\t"
        "extp     %[step3_18],          $ac0,           31              \n\t"

        : [step3_18] "=r" (step3_18)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_18] "r" (step2_18), [step2_29] "r" (step2_29),
          [cospi_24_64] "r" (cospi_24_64), [cospi_8_64] "r" (cospi_8_64)
    );

    temp21 = step2_18 * cospi_24_64 + step2_29 * cospi_8_64;
    step3_29 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    step2_19 = step1_16 - step1_19;
    step2_28 = step1_31 - step1_28;

    __asm__ __volatile__ (
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "msub     $ac0,                 %[step2_19],    %[cospi_8_64]   \n\t"
        "madd     $ac0,                 %[step2_28],    %[cospi_24_64]  \n\t"
        "extp     %[step3_19],          $ac0,           31              \n\t"

        : [step3_19] "=r" (step3_19)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_19] "r" (step2_19), [step2_28] "r" (step2_28),
          [cospi_24_64] "r" (cospi_24_64), [cospi_8_64] "r" (cospi_8_64)
    );

    temp21 = step2_19 * cospi_24_64 + step2_28 * cospi_8_64;
    step3_28 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    step3_16 = step1_16 + step1_19;
    step3_17 = step1_17 + step1_18;
    step3_30 = step1_29 + step1_30;
    step3_31 = step1_28 + step1_31;

    step2_20 = step1_23 - step1_20;
    step2_27 = step1_24 - step1_27;

    __asm__ __volatile__ (
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "msub     $ac0,                 %[step2_20],    %[cospi_24_64]  \n\t"
        "msub     $ac0,                 %[step2_27],    %[cospi_8_64]   \n\t"
        "extp     %[step3_20],          $ac0,           31              \n\t"

        : [step3_20] "=r" (step3_20)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_20] "r" (step2_20), [step2_27] "r" (step2_27),
          [cospi_24_64] "r" (cospi_24_64), [cospi_8_64] "r" (cospi_8_64)
    );

    temp21 = -step2_20 * cospi_8_64 + step2_27 * cospi_24_64;
    step3_27 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    step2_21 = step1_22 - step1_21;
    step2_26 = step1_25 - step1_26;

    __asm__ __volatile__ (
        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "msub     $ac1,                 %[step2_21],    %[cospi_24_64]  \n\t"
        "msub     $ac1,                 %[step2_26],    %[cospi_8_64]   \n\t"
        "extp     %[step3_21],          $ac1,           31              \n\t"

        : [step3_21] "=r" (step3_21)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_21] "r" (step2_21), [step2_26] "r" (step2_26),
          [cospi_24_64] "r" (cospi_24_64), [cospi_8_64] "r" (cospi_8_64)
    );

    temp21 = -step2_21 * cospi_8_64 + step2_26 * cospi_24_64;
    step3_26 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    step3_22 = step1_21 + step1_22;
    step3_23 = step1_20 + step1_23;
    step3_24 = step1_24 + step1_27;
    step3_25 = step1_25 + step1_26;

    step2_16 = step3_16 + step3_23;
    step2_17 = step3_17 + step3_22;
    step2_18 = step3_18 + step3_21;
    step2_19 = step3_19 + step3_20;
    step2_20 = step3_19 - step3_20;
    step2_21 = step3_18 - step3_21;
    step2_22 = step3_17 - step3_22;
    step2_23 = step3_16 - step3_23;

    step2_24 = step3_31 - step3_24;
    step2_25 = step3_30 - step3_25;
    step2_26 = step3_29 - step3_26;
    step2_27 = step3_28 - step3_27;
    step2_28 = step3_28 + step3_27;
    step2_29 = step3_29 + step3_26;
    step2_30 = step3_30 + step3_25;
    step2_31 = step3_31 + step3_24;

    __asm__ __volatile__ (
        "lh       %[load1],             0(%[input])                     \n\t"
        "lh       %[load2],             32(%[input])                    \n\t"
        "lh       %[load3],             16(%[input])                    \n\t"
        "lh       %[load4],             48(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"
        "add      %[result1],           %[load1],       %[load2]        \n\t"
        "sub      %[result2],           %[load1],       %[load2]        \n\t"
        "madd     $ac1,                 %[result1],     %[cospi_16_64]  \n\t"
        "madd     $ac2,                 %[result2],     %[cospi_16_64]  \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"
        "madd     $ac3,                 %[load3],       %[cospi_24_64]  \n\t"
        "msub     $ac3,                 %[load4],       %[cospi_8_64]   \n\t"
        "extp     %[temp2],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "madd     $ac1,                 %[load3],       %[cospi_8_64]   \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_24_64]  \n\t"
        "extp     %[temp3],             $ac1,           31              \n\t"

        "add      %[step1_0],          %[temp0],        %[temp3]        \n\t"
        "add      %[step1_1],          %[temp1],        %[temp2]        \n\t"
        "sub      %[step1_2],          %[temp1],        %[temp2]        \n\t"
        "sub      %[step1_3],          %[temp0],        %[temp3]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [result1] "=&r" (result1), [result2] "=&r" (result2),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step1_0] "=r" (step1_0), [step1_1] "=r" (step1_1),
          [step1_2] "=r" (step1_2), [step1_3] "=r" (step1_3)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_16_64] "r" (cospi_16_64),
          [cospi_24_64] "r" (cospi_24_64), [cospi_8_64] "r" (cospi_8_64)

    );

    __asm__ __volatile__ (
        "lh       %[load1],             8(%[input])                     \n\t"
        "lh       %[load2],             56(%[input])                    \n\t"
        "lh       %[load3],             40(%[input])                    \n\t"
        "lh       %[load4],             24(%[input])                    \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_28_64]  \n\t"
        "msub     $ac1,                 %[load2],       %[cospi_4_64]   \n\t"
        "extp     %[temp0],             $ac1,           31              \n\t"

        "madd     $ac3,                 %[load1],       %[cospi_4_64]   \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_28_64]  \n\t"
        "extp     %[temp3],             $ac3,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac2                            \n\t"
        "mthi     $zero,                $ac2                            \n\t"

        "madd     $ac2,                 %[load3],       %[cospi_12_64]  \n\t"
        "msub     $ac2,                 %[load4],       %[cospi_20_64]  \n\t"
        "extp     %[temp1],             $ac2,           31              \n\t"

        "madd     $ac1,                 %[load3],       %[cospi_20_64]  \n\t"
        "madd     $ac1,                 %[load4],       %[cospi_12_64]  \n\t"
        "extp     %[temp2],             $ac1,           31              \n\t"

        "mtlo     %[const_2_power_13],  $ac1                            \n\t"
        "mthi     $zero,                $ac1                            \n\t"
        "mtlo     %[const_2_power_13],  $ac3                            \n\t"
        "mthi     $zero,                $ac3                            \n\t"

        "sub      %[load1],             %[temp3],       %[temp2]        \n\t"
        "sub      %[load1],             %[load1],       %[temp0]        \n\t"
        "add      %[load1],             %[load1],       %[temp1]        \n\t"

        "sub      %[load2],             %[temp0],       %[temp1]        \n\t"
        "sub      %[load2],             %[load2],       %[temp2]        \n\t"
        "add      %[load2],             %[load2],       %[temp3]        \n\t"

        "madd     $ac1,                 %[load1],       %[cospi_16_64]  \n\t"
        "madd     $ac3,                 %[load2],       %[cospi_16_64]  \n\t"

        "extp     %[step1_5],           $ac1,           31              \n\t"
        "extp     %[step1_6],           $ac3,           31              \n\t"
        "add      %[step1_4],           %[temp0],       %[temp1]        \n\t"
        "add      %[step1_7],           %[temp3],       %[temp2]        \n\t"

        : [load1] "=&r" (load1), [load2] "=&r" (load2),
          [load3] "=&r" (load3), [load4] "=&r" (load4),
          [temp0] "=&r" (temp0), [temp1] "=&r" (temp1),
          [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
          [step1_4] "=r" (step1_4), [step1_5] "=r" (step1_5),
          [step1_6] "=r" (step1_6), [step1_7] "=r" (step1_7)
        : [const_2_power_13] "r" (const_2_power_13), [input] "r" (input),
          [cospi_20_64] "r" (cospi_20_64), [cospi_12_64] "r" (cospi_12_64),
          [cospi_4_64] "r" (cospi_4_64), [cospi_28_64] "r" (cospi_28_64),
          [cospi_16_64] "r" (cospi_16_64)
    );

    step2_0 = step1_0 + step1_7;
    step2_1 = step1_1 + step1_6;
    step2_2 = step1_2 + step1_5;
    step2_3 = step1_3 + step1_4;
    step2_4 = step1_3 - step1_4;
    step2_5 = step1_2 - step1_5;
    step2_6 = step1_1 - step1_6;
    step2_7 = step1_0 - step1_7;

    step1_0 = step2_0 + step3_15;
    step1_1 = step2_1 + step3_14;
    step1_2 = step2_2 + step3_13;
    step1_3 = step2_3 + step3_12;
    step1_4 = step2_4 + step3_11;
    step1_5 = step2_5 + step3_10;
    step1_6 = step2_6 + step3_9;
    step1_7 = step2_7 + step3_8;
    step1_8 = step2_7 - step3_8;
    step1_9 = step2_6 - step3_9;
    step1_10 = step2_5 - step3_10;
    step1_11 = step2_4 - step3_11;
    step1_12 = step2_3 - step3_12;
    step1_13 = step2_2 - step3_13;
    step1_14 = step2_1 - step3_14;
    step1_15 = step2_0 - step3_15;

    __asm__ __volatile__ (
        "sub      %[temp0],             %[step2_27],    %[step2_20]     \n\t"
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "madd     $ac0,                 %[temp0],       %[cospi_16_64]  \n\t"
        "extp     %[step1_20],          $ac0,           31              \n\t"

        : [temp0] "=&r" (temp0), [step1_20] "=r" (step1_20)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_20] "r" (step2_20), [step2_27] "r" (step2_27),
          [cospi_16_64] "r" (cospi_16_64)
    );

    temp21 = (step2_20 + step2_27) * cospi_16_64;
    step1_27 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    __asm__ __volatile__ (
        "sub      %[temp0],             %[step2_26],    %[step2_21]     \n\t"
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "madd     $ac0,                 %[temp0],       %[cospi_16_64]  \n\t"
        "extp     %[step1_21],          $ac0,           31              \n\t"

        : [temp0] "=&r" (temp0), [step1_21] "=r" (step1_21)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_26] "r" (step2_26), [step2_21] "r" (step2_21),
          [cospi_16_64] "r" (cospi_16_64)
    );

    temp21 = (step2_21 + step2_26) * cospi_16_64;
    step1_26 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    __asm__ __volatile__ (
        "sub      %[temp0],             %[step2_25],    %[step2_22]     \n\t"
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "madd     $ac0,                 %[temp0],       %[cospi_16_64]  \n\t"
        "extp     %[step1_22],          $ac0,           31              \n\t"

        : [temp0] "=&r" (temp0), [step1_22] "=r" (step1_22)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_25] "r" (step2_25), [step2_22] "r" (step2_22),
          [cospi_16_64] "r" (cospi_16_64)
    );

    temp21 = (step2_22 + step2_25) * cospi_16_64;
    step1_25 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    __asm__ __volatile__ (
        "sub      %[temp0],             %[step2_24],    %[step2_23]     \n\t"
        "mtlo     %[const_2_power_13],  $ac0                            \n\t"
        "mthi     $zero,                $ac0                            \n\t"
        "madd     $ac0,                 %[temp0],       %[cospi_16_64]  \n\t"
        "extp     %[step1_23],          $ac0,           31              \n\t"

        : [temp0] "=&r" (temp0), [step1_23] "=r" (step1_23)
        : [const_2_power_13] "r" (const_2_power_13),
          [step2_24] "r" (step2_24), [step2_23] "r" (step2_23),
          [cospi_16_64] "r" (cospi_16_64)
    );

    temp21 = (step2_23 + step2_24) * cospi_16_64;
    step1_24 = (temp21 + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;

    // final stage
    output[0 * 32] = step1_0 + step2_31;
    output[1 * 32] = step1_1 + step2_30;
    output[2 * 32] = step1_2 + step2_29;
    output[3 * 32] = step1_3 + step2_28;
    output[4 * 32] = step1_4 + step1_27;
    output[5 * 32] = step1_5 + step1_26;
    output[6 * 32] = step1_6 + step1_25;
    output[7 * 32] = step1_7 + step1_24;
    output[8 * 32] = step1_8 + step1_23;
    output[9 * 32] = step1_9 + step1_22;
    output[10 * 32] = step1_10 + step1_21;
    output[11 * 32] = step1_11 + step1_20;
    output[12 * 32] = step1_12 + step2_19;
    output[13 * 32] = step1_13 + step2_18;
    output[14 * 32] = step1_14 + step2_17;
    output[15 * 32] = step1_15 + step2_16;
    output[16 * 32] = step1_15 - step2_16;
    output[17 * 32] = step1_14 - step2_17;
    output[18 * 32] = step1_13 - step2_18;
    output[19 * 32] = step1_12 - step2_19;
    output[20 * 32] = step1_11 - step1_20;
    output[21 * 32] = step1_10 - step1_21;
    output[22 * 32] = step1_9 - step1_22;
    output[23 * 32] = step1_8 - step1_23;
    output[24 * 32] = step1_7 - step1_24;
    output[25 * 32] = step1_6 - step1_25;
    output[26 * 32] = step1_5 - step1_26;
    output[27 * 32] = step1_4 - step1_27;
    output[28 * 32] = step1_3 - step2_28;
    output[29 * 32] = step1_2 - step2_29;
    output[30 * 32] = step1_1 - step2_30;
    output[31 * 32] = step1_0 - step2_31;

    input += 32;
    output += 1;
  }
}

void vp9_idct32x32_1024_add_dspr2(const int16_t *input, uint8_t *dest,
                                  int dest_stride) {
  DECLARE_ALIGNED(32, int16_t,  out[32 * 32]);
  int16_t *outptr = out;
  uint32_t pos = 45;

  /* bit positon for extract from acc */
  __asm__ __volatile__ (
    "wrdsp      %[pos],     1           \n\t"
    :
    : [pos] "r" (pos)
  );

  // Rows
  idct32_1d_rows_dspr2(input, outptr);

  // Columns
  vp9_idct32_1d_cols_add_blk_dspr2(out, dest, dest_stride);
}

void vp9_idct32x32_1_add_dspr2(const int16_t *input, uint8_t *dest,
                               int stride) {
  int       r, out;
  int32_t   a1, absa1;
  int32_t   vector_a1;
  int32_t   t1, t2, t3, t4;
  int32_t   vector_1, vector_2, vector_3, vector_4;
  uint32_t  pos = 45;

  /* bit positon for extract from acc */
  __asm__ __volatile__ (
    "wrdsp      %[pos],     1           \n\t"

    :
    : [pos] "r" (pos)
  );

  out = DCT_CONST_ROUND_SHIFT_TWICE_COSPI_16_64(input[0]);
  __asm__ __volatile__ (
      "addi     %[out],    %[out],    32      \n\t"
      "sra      %[a1],     %[out],    6       \n\t"

      : [out] "+r" (out), [a1] "=r" (a1)
      :
  );

  if (a1 < 0) {
    /* use quad-byte
     * input and output memory are four byte aligned */
    __asm__ __volatile__ (
        "abs        %[absa1],     %[a1]         \n\t"
        "replv.qb   %[vector_a1], %[absa1]      \n\t"

        : [absa1] "=r" (absa1), [vector_a1] "=r" (vector_a1)
        : [a1] "r" (a1)
    );

    for (r = 32; r--;) {
      __asm__ __volatile__ (
          "lw             %[t1],          0(%[dest])                      \n\t"
          "lw             %[t2],          4(%[dest])                      \n\t"
          "lw             %[t3],          8(%[dest])                      \n\t"
          "lw             %[t4],          12(%[dest])                     \n\t"
          "subu_s.qb      %[vector_1],    %[t1],          %[vector_a1]    \n\t"
          "subu_s.qb      %[vector_2],    %[t2],          %[vector_a1]    \n\t"
          "subu_s.qb      %[vector_3],    %[t3],          %[vector_a1]    \n\t"
          "subu_s.qb      %[vector_4],    %[t4],          %[vector_a1]    \n\t"
          "sw             %[vector_1],    0(%[dest])                      \n\t"
          "sw             %[vector_2],    4(%[dest])                      \n\t"
          "sw             %[vector_3],    8(%[dest])                      \n\t"
          "sw             %[vector_4],    12(%[dest])                     \n\t"

          "lw             %[t1],          16(%[dest])                     \n\t"
          "lw             %[t2],          20(%[dest])                     \n\t"
          "lw             %[t3],          24(%[dest])                     \n\t"
          "lw             %[t4],          28(%[dest])                     \n\t"
          "subu_s.qb      %[vector_1],    %[t1],          %[vector_a1]    \n\t"
          "subu_s.qb      %[vector_2],    %[t2],          %[vector_a1]    \n\t"
          "subu_s.qb      %[vector_3],    %[t3],          %[vector_a1]    \n\t"
          "subu_s.qb      %[vector_4],    %[t4],          %[vector_a1]    \n\t"
          "sw             %[vector_1],    16(%[dest])                     \n\t"
          "sw             %[vector_2],    20(%[dest])                     \n\t"
          "sw             %[vector_3],    24(%[dest])                     \n\t"
          "sw             %[vector_4],    28(%[dest])                     \n\t"

          "add            %[dest],        %[dest],        %[stride]       \n\t"

          : [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3), [t4] "=&r" (t4),
            [vector_1] "=&r" (vector_1), [vector_2] "=&r" (vector_2),
            [vector_3] "=&r" (vector_3), [vector_4] "=&r" (vector_4),
            [dest] "+&r" (dest)
          : [stride] "r" (stride), [vector_a1] "r" (vector_a1)
      );
    }
  } else {
    /* use quad-byte
     * input and output memory are four byte aligned */
    __asm__ __volatile__ (
        "replv.qb       %[vector_a1],   %[a1]     \n\t"

        : [vector_a1] "=r" (vector_a1)
        : [a1] "r" (a1)
    );

    for (r = 32; r--;) {
      __asm__ __volatile__ (
          "lw             %[t1],          0(%[dest])                      \n\t"
          "lw             %[t2],          4(%[dest])                      \n\t"
          "lw             %[t3],          8(%[dest])                      \n\t"
          "lw             %[t4],          12(%[dest])                     \n\t"
          "addu_s.qb      %[vector_1],    %[t1],          %[vector_a1]    \n\t"
          "addu_s.qb      %[vector_2],    %[t2],          %[vector_a1]    \n\t"
          "addu_s.qb      %[vector_3],    %[t3],          %[vector_a1]    \n\t"
          "addu_s.qb      %[vector_4],    %[t4],          %[vector_a1]    \n\t"
          "sw             %[vector_1],    0(%[dest])                      \n\t"
          "sw             %[vector_2],    4(%[dest])                      \n\t"
          "sw             %[vector_3],    8(%[dest])                      \n\t"
          "sw             %[vector_4],    12(%[dest])                     \n\t"

          "lw             %[t1],          16(%[dest])                     \n\t"
          "lw             %[t2],          20(%[dest])                     \n\t"
          "lw             %[t3],          24(%[dest])                     \n\t"
          "lw             %[t4],          28(%[dest])                     \n\t"
          "addu_s.qb      %[vector_1],    %[t1],          %[vector_a1]    \n\t"
          "addu_s.qb      %[vector_2],    %[t2],          %[vector_a1]    \n\t"
          "addu_s.qb      %[vector_3],    %[t3],          %[vector_a1]    \n\t"
          "addu_s.qb      %[vector_4],    %[t4],          %[vector_a1]    \n\t"
          "sw             %[vector_1],    16(%[dest])                     \n\t"
          "sw             %[vector_2],    20(%[dest])                     \n\t"
          "sw             %[vector_3],    24(%[dest])                     \n\t"
          "sw             %[vector_4],    28(%[dest])                     \n\t"

          "add            %[dest],        %[dest],        %[stride]       \n\t"

          : [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3), [t4] "=&r" (t4),
            [vector_1] "=&r" (vector_1), [vector_2] "=&r" (vector_2),
            [vector_3] "=&r" (vector_3), [vector_4] "=&r" (vector_4),
            [dest] "+&r" (dest)
          : [stride] "r" (stride), [vector_a1] "r" (vector_a1)
      );
    }
  }
}
#endif  // #if HAVE_DSPR2