Blame view

ffmpeg-4.2.2/libavcodec/mips/mpegaudiodsp_mips_fixed.c 60.6 KB
aac5773f   hucm   功能基本完成,接口待打磨
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
      /*
   * Copyright (c) 2012
   *      MIPS Technologies, Inc., California.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in the
   *    documentation and/or other materials provided with the distribution.
   * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
   *    contributors may be used to endorse or promote products derived from
   *    this software without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
   * Author:  Bojan Zivkovic (bojan@mips.com)
   *
   * MPEG Audio decoder optimized for MIPS fixed-point architecture
   *
   * 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
   */
  
  /**
   * @file
   * Reference: libavcodec/mpegaudiodsp_template.c
   */
  
  #include <string.h>
  
  #include "libavutil/mips/asmdefs.h"
  #include "libavcodec/mpegaudiodsp.h"
  
  #if HAVE_INLINE_ASM
  #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
  
  static void ff_mpadsp_apply_window_mips_fixed(int32_t *synth_buf, int32_t *window,
                                 int *dither_state, int16_t *samples, ptrdiff_t incr)
  {
      register const int32_t *w, *w2, *p;
      int j;
      int16_t *samples2;
      int w_asm, p_asm, w_asm1, p_asm1, w_asm2, p_asm2;
      int w2_asm, w2_asm1, *p_temp1, *p_temp2;
      int sum1 = 0;
      int const min_asm = -32768, max_asm = 32767;
      int temp1, temp2 = 0, temp3 = 0;
      int64_t sum;
  
      /* copy to avoid wrap */
      memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
      samples2 = samples + 31 * incr;
      w = window;
      w2 = window + 31;
      sum = *dither_state;
      p = synth_buf + 16;
      p_temp1 = synth_buf + 16;
      p_temp2 = synth_buf + 48;
      temp1 = sum;
  
      /**
      * use of round_sample function from the original code is eliminated,
      * changed with appropriate assembly instructions.
      */
      __asm__ volatile (
           "mthi   $zero                                                    \n\t"
           "mtlo   %[temp1]                                                 \n\t"
           "lw     %[w_asm],  0(%[w])                                       \n\t"
           "lw     %[p_asm],  0(%[p])                                       \n\t"
           "lw     %[w_asm1], 64*4(%[w])                                    \n\t"
           "lw     %[p_asm1], 64*4(%[p])                                    \n\t"
           "lw     %[w_asm2], 128*4(%[w])                                   \n\t"
           "lw     %[p_asm2], 128*4(%[p])                                   \n\t"
           "madd   %[w_asm],  %[p_asm]                                      \n\t"
           "madd   %[w_asm1], %[p_asm1]                                     \n\t"
           "madd   %[w_asm2], %[p_asm2]                                     \n\t"
           "lw     %[w_asm],  192*4(%[w])                                   \n\t"
           "lw     %[p_asm],  192*4(%[p])                                   \n\t"
           "lw     %[w_asm1], 256*4(%[w])                                   \n\t"
           "lw     %[p_asm1], 256*4(%[p])                                   \n\t"
           "lw     %[w_asm2], 320*4(%[w])                                   \n\t"
           "lw     %[p_asm2], 320*4(%[p])                                   \n\t"
           "madd   %[w_asm],  %[p_asm]                                      \n\t"
           "madd   %[w_asm1], %[p_asm1]                                     \n\t"
           "madd   %[w_asm2], %[p_asm2]                                     \n\t"
           "lw     %[w_asm],  384*4(%[w])                                   \n\t"
           "lw     %[p_asm],  384*4(%[p])                                   \n\t"
           "lw     %[w_asm1], 448*4(%[w])                                   \n\t"
           "lw     %[p_asm1], 448*4(%[p])                                   \n\t"
           "lw     %[w_asm2], 32*4(%[w])                                    \n\t"
           "lw     %[p_asm2], 32*4(%[p])                                    \n\t"
           "madd   %[w_asm],  %[p_asm]                                      \n\t"
           "madd   %[w_asm1], %[p_asm1]                                     \n\t"
           "msub   %[w_asm2], %[p_asm2]                                     \n\t"
           "lw     %[w_asm],  96*4(%[w])                                    \n\t"
           "lw     %[p_asm],  96*4(%[p])                                    \n\t"
           "lw     %[w_asm1], 160*4(%[w])                                   \n\t"
           "lw     %[p_asm1], 160*4(%[p])                                   \n\t"
           "lw     %[w_asm2], 224*4(%[w])                                   \n\t"
           "lw     %[p_asm2], 224*4(%[p])                                   \n\t"
           "msub   %[w_asm],  %[p_asm]                                      \n\t"
           "msub   %[w_asm1], %[p_asm1]                                     \n\t"
           "msub   %[w_asm2], %[p_asm2]                                     \n\t"
           "lw     %[w_asm],  288*4(%[w])                                   \n\t"
           "lw     %[p_asm],  288*4(%[p])                                   \n\t"
           "lw     %[w_asm1], 352*4(%[w])                                   \n\t"
           "lw     %[p_asm1], 352*4(%[p])                                   \n\t"
           "msub   %[w_asm],  %[p_asm]                                      \n\t"
           "lw     %[w_asm],  480*4(%[w])                                   \n\t"
           "lw     %[p_asm],  480*4(%[p])                                   \n\t"
           "lw     %[w_asm2], 416*4(%[w])                                   \n\t"
           "lw     %[p_asm2], 416*4(%[p])                                   \n\t"
           "msub   %[w_asm],  %[p_asm]                                      \n\t"
           "msub   %[w_asm1], %[p_asm1]                                     \n\t"
           "msub   %[w_asm2], %[p_asm2]                                     \n\t"
  
           /*round_sample function from the original code is eliminated,
            * changed with appropriate assembly instructions
            * code example:
  
           "extr.w  %[sum1],$ac0,24                                       \n\t"
           "mflo %[temp3],  $ac0                                          \n\t"
           "and  %[temp1],  %[temp3],  0x00ffffff                         \n\t"
           "slt  %[temp2],  %[sum1],   %[min_asm]                         \n\t"
           "movn %[sum1],   %[min_asm],%[temp2]                           \n\t"
           "slt  %[temp2],  %[max_asm],%[sum1]                            \n\t"
           "movn %[sum1],   %[max_asm],%[temp2]                           \n\t"
           "sh   %[sum1],   0(%[samples])                                 \n\t"
           */
  
           "extr.w %[sum1],   $ac0,       24                                \n\t"
           "mflo   %[temp3]                                                 \n\t"
           PTR_ADDIU "%[w],   %[w],       4                                 \n\t"
           "and    %[temp1],  %[temp3],   0x00ffffff                        \n\t"
           "slt    %[temp2],  %[sum1],    %[min_asm]                        \n\t"
           "movn   %[sum1],   %[min_asm], %[temp2]                          \n\t"
           "slt    %[temp2],  %[max_asm], %[sum1]                           \n\t"
           "movn   %[sum1],   %[max_asm], %[temp2]                          \n\t"
           "sh     %[sum1],   0(%[samples])                                 \n\t"
  
          : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
            [p_asm1] "=&r" (p_asm1), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
            [w_asm2] "=&r" (w_asm2), [p_asm2] "=&r" (p_asm2),
            [sum1] "+r" (sum1), [w] "+r" (w), [temp3] "+r" (temp3)
          : [p] "r" (p), [samples] "r" (samples), [min_asm] "r" (min_asm),
            [max_asm] "r" (max_asm)
          : "memory", "hi","lo"
       );
  
       samples += incr;
  
      /* we calculate two samples at the same time to avoid one memory
         access per two sample */
  
      for(j = 1; j < 16; j++) {
          __asm__ volatile (
               "mthi   $0,         $ac1                                      \n\t"
               "mtlo   $0,         $ac1                                      \n\t"
               "mthi   $0                                                    \n\t"
               "mtlo   %[temp1]                                              \n\t"
               PTR_ADDIU "%[p_temp1], %[p_temp1],    4                       \n\t"
               "lw     %[w_asm],   0(%[w])                                   \n\t"
               "lw     %[p_asm],   0(%[p_temp1])                             \n\t"
               "lw     %[w2_asm],  0(%[w2])                                  \n\t"
               "lw     %[w_asm1],  64*4(%[w])                                \n\t"
               "lw     %[p_asm1],  64*4(%[p_temp1])                          \n\t"
               "lw     %[w2_asm1], 64*4(%[w2])                               \n\t"
               "madd   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "madd   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               "lw     %[w_asm],   128*4(%[w])                               \n\t"
               "lw     %[p_asm],   128*4(%[p_temp1])                         \n\t"
               "lw     %[w2_asm],  128*4(%[w2])                              \n\t"
               "lw     %[w_asm1],  192*4(%[w])                               \n\t"
               "lw     %[p_asm1],  192*4(%[p_temp1])                         \n\t"
               "lw     %[w2_asm1], 192*4(%[w2])                              \n\t"
               "madd   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "madd   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               "lw     %[w_asm],   256*4(%[w])                               \n\t"
               "lw     %[p_asm],   256*4(%[p_temp1])                         \n\t"
               "lw     %[w2_asm],  256*4(%[w2])                              \n\t"
               "lw     %[w_asm1],  320*4(%[w])                               \n\t"
               "lw     %[p_asm1],  320*4(%[p_temp1])                         \n\t"
               "lw     %[w2_asm1], 320*4(%[w2])                              \n\t"
               "madd   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "madd   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               "lw     %[w_asm],   384*4(%[w])                               \n\t"
               "lw     %[p_asm],   384*4(%[p_temp1])                         \n\t"
               "lw     %[w2_asm],  384*4(%[w2])                              \n\t"
               "lw     %[w_asm1],  448*4(%[w])                               \n\t"
               "lw     %[p_asm1],  448*4(%[p_temp1])                         \n\t"
               "lw     %[w2_asm1], 448*4(%[w2])                              \n\t"
               "madd   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "madd   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               PTR_ADDIU "%[p_temp2], %[p_temp2],   -4                      \n\t"
               "lw     %[w_asm],   32*4(%[w])                                \n\t"
               "lw     %[p_asm],   0(%[p_temp2])                             \n\t"
               "lw     %[w2_asm],  32*4(%[w2])                               \n\t"
               "lw     %[w_asm1],  96*4(%[w])                                \n\t"
               "lw     %[p_asm1],  64*4(%[p_temp2])                          \n\t"
               "lw     %[w2_asm1], 96*4(%[w2])                               \n\t"
               "msub   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "msub   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               "lw     %[w_asm],   160*4(%[w])                               \n\t"
               "lw     %[p_asm],   128*4(%[p_temp2])                         \n\t"
               "lw     %[w2_asm],  160*4(%[w2])                              \n\t"
               "lw     %[w_asm1],  224*4(%[w])                               \n\t"
               "lw     %[p_asm1],  192*4(%[p_temp2])                         \n\t"
               "lw     %[w2_asm1], 224*4(%[w2])                              \n\t"
               "msub   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "msub   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               "lw     %[w_asm],   288*4(%[w])                               \n\t"
               "lw     %[p_asm],   256*4(%[p_temp2])                         \n\t"
               "lw     %[w2_asm],  288*4(%[w2])                              \n\t"
               "lw     %[w_asm1],  352*4(%[w])                               \n\t"
               "lw     %[p_asm1],  320*4(%[p_temp2])                         \n\t"
               "lw     %[w2_asm1], 352*4(%[w2])                              \n\t"
               "msub   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "msub   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               "lw     %[w_asm],   416*4(%[w])                               \n\t"
               "lw     %[p_asm],   384*4(%[p_temp2])                         \n\t"
               "lw     %[w2_asm],  416*4(%[w2])                              \n\t"
               "lw     %[w_asm1],  480*4(%[w])                               \n\t"
               "lw     %[p_asm1],  448*4(%[p_temp2])                         \n\t"
               "lw     %[w2_asm1], 480*4(%[w2])                              \n\t"
               "msub   %[w_asm],   %[p_asm]                                  \n\t"
               "msub   %[w_asm1],  %[p_asm1]                                 \n\t"
               "msub   $ac1,       %[w2_asm],        %[p_asm]                \n\t"
               "msub   $ac1,       %[w2_asm1],       %[p_asm1]               \n\t"
               PTR_ADDIU "%[w],    %[w],             4                       \n\t"
               PTR_ADDIU "%[w2],   %[w2],            -4                      \n\t"
               "mflo   %[temp2]                                              \n\t"
               "extr.w %[sum1],    $ac0,             24                      \n\t"
               "li     %[temp3],   1                                         \n\t"
               "and    %[temp1],   %[temp2],         0x00ffffff              \n\t"
               "madd   $ac1,       %[temp1],         %[temp3]                \n\t"
               "slt    %[temp2],   %[sum1],          %[min_asm]              \n\t"
               "movn   %[sum1],    %[min_asm],       %[temp2]                \n\t"
               "slt    %[temp2],   %[max_asm],       %[sum1]                 \n\t"
               "movn   %[sum1],    %[max_asm],       %[temp2]                \n\t"
               "sh     %[sum1],    0(%[samples])                             \n\t"
               "mflo   %[temp3],   $ac1                                      \n\t"
               "extr.w %[sum1],    $ac1,             24                      \n\t"
               "and    %[temp1],   %[temp3],         0x00ffffff              \n\t"
               "slt    %[temp2],   %[sum1],          %[min_asm]              \n\t"
               "movn   %[sum1],    %[min_asm],       %[temp2]                \n\t"
               "slt    %[temp2],   %[max_asm],       %[sum1]                 \n\t"
               "movn   %[sum1],    %[max_asm],       %[temp2]                \n\t"
               "sh     %[sum1],    0(%[samples2])                            \n\t"
  
              : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
                [p_asm1] "=&r" (p_asm1), [w2_asm1] "=&r" (w2_asm1),
                [w2_asm] "=&r" (w2_asm), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
                [p_temp1] "+r" (p_temp1), [p_temp2] "+r" (p_temp2), [sum1] "+r" (sum1),
                [w] "+r" (w), [w2] "+r" (w2), [samples] "+r" (samples),
                [samples2] "+r" (samples2), [temp3] "+r" (temp3)
              : [min_asm] "r" (min_asm), [max_asm] "r" (max_asm)
              : "memory", "hi", "lo", "$ac1hi", "$ac1lo"
          );
  
          samples += incr;
          samples2 -= incr;
      }
  
      p = synth_buf + 32;
  
      __asm__ volatile (
          "mthi   $0                                                        \n\t"
          "mtlo   %[temp1]                                                  \n\t"
          "lw     %[w_asm],  32*4(%[w])                                     \n\t"
          "lw     %[p_asm],  0(%[p])                                        \n\t"
          "lw     %[w_asm1], 96*4(%[w])                                     \n\t"
          "lw     %[p_asm1], 64*4(%[p])                                     \n\t"
          "lw     %[w_asm2], 160*4(%[w])                                    \n\t"
          "lw     %[p_asm2], 128*4(%[p])                                    \n\t"
          "msub   %[w_asm],  %[p_asm]                                       \n\t"
          "msub   %[w_asm1], %[p_asm1]                                      \n\t"
          "msub   %[w_asm2], %[p_asm2]                                      \n\t"
          "lw     %[w_asm],  224*4(%[w])                                    \n\t"
          "lw     %[p_asm],  192*4(%[p])                                    \n\t"
          "lw     %[w_asm1], 288*4(%[w])                                    \n\t"
          "lw     %[p_asm1], 256*4(%[p])                                    \n\t"
          "lw     %[w_asm2], 352*4(%[w])                                    \n\t"
          "lw     %[p_asm2], 320*4(%[p])                                    \n\t"
          "msub   %[w_asm],  %[p_asm]                                       \n\t"
          "msub   %[w_asm1], %[p_asm1]                                      \n\t"
          "msub   %[w_asm2], %[p_asm2]                                      \n\t"
          "lw     %[w_asm],  416*4(%[w])                                    \n\t"
          "lw     %[p_asm],  384*4(%[p])                                    \n\t"
          "lw     %[w_asm1], 480*4(%[w])                                    \n\t"
          "lw     %[p_asm1], 448*4(%[p])                                    \n\t"
          "msub   %[w_asm],  %[p_asm]                                       \n\t"
          "msub   %[w_asm1], %[p_asm1]                                      \n\t"
          "extr.w %[sum1],   $ac0,       24                                 \n\t"
          "mflo   %[temp2]                                                  \n\t"
          "and    %[temp1],  %[temp2],   0x00ffffff                         \n\t"
          "slt    %[temp2],  %[sum1],    %[min_asm]                         \n\t"
          "movn   %[sum1],   %[min_asm], %[temp2]                           \n\t"
          "slt    %[temp2],  %[max_asm], %[sum1]                            \n\t"
          "movn   %[sum1],   %[max_asm], %[temp2]                           \n\t"
          "sh     %[sum1],   0(%[samples])                                  \n\t"
  
          : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
            [p_asm1] "=&r" (p_asm1), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
            [w_asm2] "=&r" (w_asm2), [p_asm2] "=&r" (p_asm2), [sum1] "+r" (sum1)
          : [w] "r" (w), [p] "r" (p), [samples] "r" (samples), [min_asm] "r" (min_asm),
            [max_asm] "r" (max_asm)
          : "memory", "hi", "lo", "$ac1hi", "$ac1lo"
       );
  
      *dither_state= temp1;
  }
  
  static void imdct36_mips_fixed(int *out, int *buf, int *in, int *win)
  {
      int j;
      int t0, t1, t2, t3, s0, s1, s2, s3;
      int tmp[18], *tmp1, *in1;
      /* temporary variables */
      int temp_reg1, temp_reg2, temp_reg3, temp_reg4, temp_reg5, temp_reg6;
      int t4, t5, t6, t8, t7;
  
     /* values defined in macros and tables are
      * eliminated - they are directly loaded in appropriate variables
      */
      int const C_1  =  4229717092; /* cos(pi*1/18)*2  */
      int const C_2  =  4035949074; /* cos(pi*2/18)*2  */
      int const C_3  =  575416510;  /* -cos(pi*3/18)*2 */
      int const C_3A =  3719550786; /* cos(pi*3/18)*2  */
      int const C_4  =  1004831466; /* -cos(pi*4/18)*2 */
      int const C_5  =  1534215534; /* -cos(pi*5/18)*2 */
      int const C_7  = -1468965330; /* -cos(pi*7/18)*2 */
      int const C_8  = -745813244;  /* -cos(pi*8/18)*2 */
  
     /*
      * instructions of the first two loops are reorganized and loops are unrolled,
      * in order to eliminate unnecessary readings and writings in array
      */
  
      __asm__ volatile (
          "lw   %[t1], 17*4(%[in])                                         \n\t"
          "lw   %[t2], 16*4(%[in])                                         \n\t"
          "lw   %[t3], 15*4(%[in])                                         \n\t"
          "lw   %[t4], 14*4(%[in])                                         \n\t"
          "addu %[t1], %[t1],      %[t2]                                   \n\t"
          "addu %[t2], %[t2],      %[t3]                                   \n\t"
          "addu %[t3], %[t3],      %[t4]                                   \n\t"
          "lw   %[t5], 13*4(%[in])                                         \n\t"
          "addu %[t1], %[t1],      %[t3]                                   \n\t"
          "sw   %[t2], 16*4(%[in])                                         \n\t"
          "lw   %[t6], 12*4(%[in])                                         \n\t"
          "sw   %[t1], 17*4(%[in])                                         \n\t"
          "addu %[t4], %[t4],      %[t5]                                   \n\t"
          "addu %[t5], %[t5],      %[t6]                                   \n\t"
          "lw   %[t7], 11*4(%[in])                                         \n\t"
          "addu %[t3], %[t3],      %[t5]                                   \n\t"
          "sw   %[t4], 14*4(%[in])                                         \n\t"
          "lw   %[t8], 10*4(%[in])                                         \n\t"
          "sw   %[t3], 15*4(%[in])                                         \n\t"
          "addu %[t6], %[t6],      %[t7]                                   \n\t"
          "addu %[t7], %[t7],      %[t8]                                   \n\t"
          "sw   %[t6], 12*4(%[in])                                         \n\t"
          "addu %[t5], %[t5],      %[t7]                                   \n\t"
          "lw   %[t1], 9*4(%[in])                                          \n\t"
          "lw   %[t2], 8*4(%[in])                                          \n\t"
          "sw   %[t5], 13*4(%[in])                                         \n\t"
          "addu %[t8], %[t8],      %[t1]                                   \n\t"
          "addu %[t1], %[t1],      %[t2]                                   \n\t"
          "sw   %[t8], 10*4(%[in])                                         \n\t"
          "addu %[t7], %[t7],      %[t1]                                   \n\t"
          "lw   %[t3], 7*4(%[in])                                          \n\t"
          "lw   %[t4], 6*4(%[in])                                          \n\t"
          "sw   %[t7], 11*4(%[in])                                         \n\t"
          "addu %[t2], %[t2],      %[t3]                                   \n\t"
          "addu %[t3], %[t3],      %[t4]                                   \n\t"
          "sw   %[t2], 8*4(%[in])                                          \n\t"
          "addu %[t1], %[t1],      %[t3]                                   \n\t"
          "lw   %[t5], 5*4(%[in])                                          \n\t"
          "lw   %[t6], 4*4(%[in])                                          \n\t"
          "sw   %[t1], 9*4(%[in])                                          \n\t"
          "addu %[t4], %[t4],      %[t5]                                   \n\t"
          "addu %[t5], %[t5],      %[t6]                                   \n\t"
          "sw   %[t4], 6*4(%[in])                                          \n\t"
          "addu %[t3], %[t3],      %[t5]                                   \n\t"
          "lw   %[t7], 3*4(%[in])                                          \n\t"
          "lw   %[t8], 2*4(%[in])                                          \n\t"
          "sw   %[t3], 7*4(%[in])                                          \n\t"
          "addu %[t6], %[t6],      %[t7]                                   \n\t"
          "addu %[t7], %[t7],      %[t8]                                   \n\t"
          "sw   %[t6], 4*4(%[in])                                          \n\t"
          "addu %[t5], %[t5],      %[t7]                                   \n\t"
          "lw   %[t1], 1*4(%[in])                                          \n\t"
          "lw   %[t2], 0*4(%[in])                                          \n\t"
          "sw   %[t5], 5*4(%[in])                                          \n\t"
          "addu %[t8], %[t8],      %[t1]                                   \n\t"
          "addu %[t1], %[t1],      %[t2]                                   \n\t"
          "sw   %[t8], 2*4(%[in])                                          \n\t"
          "addu %[t7], %[t7],      %[t1]                                   \n\t"
          "sw   %[t7], 3*4(%[in])                                          \n\t"
          "sw   %[t1], 1*4(%[in])                                          \n\t"
  
          : [in] "+r" (in), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3),
            [t4] "=&r" (t4), [t5] "=&r" (t5), [t6] "=&r" (t6),
            [t7] "=&r" (t7), [t8] "=&r" (t8)
          :
          : "memory"
      );
  
      for(j = 0; j < 2; j++) {
  
          tmp1 = tmp + j;
          in1 = in + j;
  
           /**
           *  Original constants are multiplied by two in advanced
           *  for assembly optimization (e.g. C_2 = 2 * C2).
           *  That can lead to overflow in operations where they are used.
           *
           *  Example of the solution:
           *
           *  in original code:
           *  t0 = ((int64_t)(in1[2*2] + in1[2*4]) * (int64_t)(2*C2))>>32
           *
           *  in assembly:
           *  C_2 = 2 * C2;
           *   .
           *   .
           *  "lw   %[t7],       4*4(%[in1])                               \n\t"
           *  "lw   %[t8],       8*4(%[in1])                               \n\t"
           *  "addu %[temp_reg2],%[t7],       %[t8]                        \n\t"
           *  "multu %[C_2],     %[temp_reg2]                              \n\t"
           *  "mfhi %[temp_reg1]                                           \n\t"
           *  "sra  %[temp_reg2],%[temp_reg2],31                           \n\t"
           *  "move %[t0],       $0                                        \n\t"
           *  "movn %[t0],       %[C_2],      %[temp_reg2]                 \n\t"
           *  "sub  %[t0],       %[temp_reg1],%[t0]                        \n\t"
           */
  
          __asm__ volatile (
              "lw    %[t7],        4*4(%[in1])                               \n\t"
              "lw    %[t8],        8*4(%[in1])                               \n\t"
              "lw    %[t6],        16*4(%[in1])                              \n\t"
              "lw    %[t4],        0*4(%[in1])                               \n\t"
              "addu  %[temp_reg2], %[t7],        %[t8]                       \n\t"
              "addu  %[t2],        %[t6],        %[t8]                       \n\t"
              "multu %[C_2],       %[temp_reg2]                              \n\t"
              "lw    %[t5],        12*4(%[in1])                              \n\t"
              "sub   %[t2],        %[t2],        %[t7]                       \n\t"
              "sub   %[t1],        %[t4],        %[t5]                       \n\t"
              "sra   %[t3],        %[t5],        1                           \n\t"
              "sra   %[temp_reg1], %[t2],        1                           \n\t"
              "addu  %[t3],        %[t3],        %[t4]                       \n\t"
              "sub   %[temp_reg1], %[t1],        %[temp_reg1]                \n\t"
              "sra   %[temp_reg2], %[temp_reg2], 31                          \n\t"
              "sw    %[temp_reg1], 6*4(%[tmp1])                              \n\t"
              "move  %[t0],        $0                                        \n\t"
              "movn  %[t0],        %[C_2],       %[temp_reg2]                \n\t"
              "mfhi  %[temp_reg1]                                            \n\t"
              "addu  %[t1],        %[t1],        %[t2]                       \n\t"
              "sw    %[t1],        16*4(%[tmp1])                             \n\t"
              "sub   %[temp_reg4], %[t8],        %[t6]                       \n\t"
              "add   %[temp_reg2], %[t7],        %[t6]                       \n\t"
              "mult  $ac1,         %[C_8],       %[temp_reg4]                \n\t"
              "multu $ac2,         %[C_4],       %[temp_reg2]                \n\t"
              "sub   %[t0],        %[temp_reg1], %[t0]                       \n\t"
              "sra   %[temp_reg1], %[temp_reg2], 31                          \n\t"
              "move  %[t2],        $0                                        \n\t"
              "movn  %[t2],        %[C_4],       %[temp_reg1]                \n\t"
              "mfhi  %[t1],        $ac1                                      \n\t"
              "mfhi  %[temp_reg1], $ac2                                      \n\t"
              "lw    %[t6],        10*4(%[in1])                              \n\t"
              "lw    %[t8],        14*4(%[in1])                              \n\t"
              "lw    %[t7],        2*4(%[in1])                               \n\t"
              "lw    %[t4],        6*4(%[in1])                               \n\t"
              "sub   %[temp_reg3], %[t3],        %[t0]                       \n\t"
              "add   %[temp_reg4], %[t3],        %[t0]                       \n\t"
              "sub   %[temp_reg1], %[temp_reg1], %[temp_reg2]                \n\t"
              "add   %[temp_reg4], %[temp_reg4], %[t1]                       \n\t"
              "sub   %[t2],        %[temp_reg1], %[t2]                       \n\t"
              "sw    %[temp_reg4], 2*4(%[tmp1])                              \n\t"
              "sub   %[temp_reg3], %[temp_reg3], %[t2]                       \n\t"
              "add   %[temp_reg1], %[t3],        %[t2]                       \n\t"
              "sw    %[temp_reg3], 10*4(%[tmp1])                             \n\t"
              "sub   %[temp_reg1], %[temp_reg1], %[t1]                       \n\t"
              "addu  %[temp_reg2], %[t6],        %[t8]                       \n\t"
              "sw    %[temp_reg1], 14*4(%[tmp1])                             \n\t"
              "sub   %[temp_reg2], %[temp_reg2], %[t7]                       \n\t"
              "addu  %[temp_reg3], %[t7],        %[t6]                       \n\t"
              "multu $ac3,         %[C_3],       %[temp_reg2]                \n\t"
              "multu %[C_1],       %[temp_reg3]                              \n\t"
              "sra   %[temp_reg1], %[temp_reg2], 31                          \n\t"
              "move  %[t1],        $0                                        \n\t"
              "sra   %[temp_reg3], %[temp_reg3], 31                          \n\t"
              "movn  %[t1],        %[C_3],       %[temp_reg1]                \n\t"
              "mfhi  %[temp_reg1], $ac3                                      \n\t"
              "mfhi  %[temp_reg4]                                            \n\t"
              "move  %[t2],        $0                                        \n\t"
              "movn  %[t2],        %[C_1],       %[temp_reg3]                \n\t"
              "sub   %[temp_reg3], %[t6],        %[t8]                       \n\t"
              "sub   %[t2],        %[temp_reg4], %[t2]                       \n\t"
              "multu $ac1,         %[C_7],       %[temp_reg3]                \n\t"
              "sub   %[temp_reg1], %[temp_reg1], %[temp_reg2]                \n\t"
              "sra   %[temp_reg4], %[temp_reg3], 31                          \n\t"
              "sub   %[t1],        %[temp_reg1], %[t1]                       \n\t"
              "move  %[t3],        $0                                        \n\t"
              "sw    %[t1],        4*4(%[tmp1])                              \n\t"
              "movn  %[t3],        %[C_7],       %[temp_reg4]                \n\t"
              "multu $ac2,         %[C_3A],      %[t4]                       \n\t"
              "add   %[temp_reg2], %[t7],        %[t8]                       \n\t"
              "move  %[t1],        $0                                        \n\t"
              "mfhi  %[temp_reg4], $ac1                                      \n\t"
              "multu $ac3,%[C_5],  %[temp_reg2]                              \n\t"
              "move  %[t0],        $0                                        \n\t"
              "sra   %[temp_reg1], %[temp_reg2], 31                          \n\t"
              "movn  %[t1],%[C_5], %[temp_reg1]                              \n\t"
              "sub   %[temp_reg4], %[temp_reg4], %[temp_reg3]                \n\t"
              "mfhi  %[temp_reg1], $ac3                                      \n\t"
              "sra   %[temp_reg3], %[t4],        31                          \n\t"
              "movn  %[t0],        %[C_3A],      %[temp_reg3]                \n\t"
              "mfhi  %[temp_reg3], $ac2                                      \n\t"
              "sub   %[t3],        %[temp_reg4], %[t3]                       \n\t"
              "add   %[temp_reg4], %[t3],        %[t2]                       \n\t"
              "sub   %[temp_reg1], %[temp_reg1], %[temp_reg2]                \n\t"
              "sub   %[t1],        %[temp_reg1], %[t1]                       \n\t"
              "sub   %[t0],        %[temp_reg3], %[t0]                       \n\t"
              "add   %[temp_reg1], %[t2],        %[t1]                       \n\t"
              "add   %[temp_reg4], %[temp_reg4], %[t0]                       \n\t"
              "sub   %[temp_reg2], %[t3],        %[t1]                       \n\t"
              "sw    %[temp_reg4], 0*4(%[tmp1])                              \n\t"
              "sub   %[temp_reg1], %[temp_reg1], %[t0]                       \n\t"
              "sub   %[temp_reg2], %[temp_reg2], %[t0]                       \n\t"
              "sw    %[temp_reg1], 12*4(%[tmp1])                             \n\t"
              "sw    %[temp_reg2], 8*4(%[tmp1])                              \n\t"
  
              : [t7] "=&r" (t7), [temp_reg1] "=&r" (temp_reg1),
                [temp_reg2] "=&r" (temp_reg2), [temp_reg4] "=&r" (temp_reg4),
                [temp_reg3] "=&r" (temp_reg3), [t8] "=&r" (t8), [t0] "=&r" (t0),
                [t4] "=&r" (t4), [t5] "=&r" (t5), [t6] "=&r"(t6), [t2] "=&r" (t2),
                [t3] "=&r" (t3), [t1] "=&r" (t1)
              : [C_2] "r" (C_2), [in1] "r" (in1), [tmp1] "r" (tmp1), [C_8] "r" (C_8),
                [C_4] "r" (C_4), [C_3] "r" (C_3), [C_1] "r" (C_1), [C_7] "r" (C_7),
                [C_3A] "r" (C_3A), [C_5] "r" (C_5)
              : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
                "$ac3hi", "$ac3lo"
           );
      }
  
      /**
      * loop is unrolled four times
      *
      * values defined in tables(icos36[] and icos36h[]) are not loaded from
      * these tables - they are directly loaded in appropriate registers
      *
      */
  
      __asm__ volatile (
          "lw     %[t2],        1*4(%[tmp])                                  \n\t"
          "lw     %[t3],        3*4(%[tmp])                                  \n\t"
          "lw     %[t0],        0*4(%[tmp])                                  \n\t"
          "lw     %[t1],        2*4(%[tmp])                                  \n\t"
          "addu   %[temp_reg1], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg2], 0x807D2B1E                                   \n\t"
          "move   %[s1],        $0                                           \n\t"
          "multu  %[temp_reg2], %[temp_reg1]                                 \n\t"
          "sra    %[temp_reg1], %[temp_reg1], 31                             \n\t"
          "movn   %[s1],        %[temp_reg2], %[temp_reg1]                   \n\t"
          "sub    %[temp_reg3], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg4], 0x2de5151                                    \n\t"
          "mfhi   %[temp_reg2]                                               \n\t"
          "addu   %[s0],        %[t1],        %[t0]                          \n\t"
          "lw     %[temp_reg5], 9*4(%[win])                                  \n\t"
          "mult   $ac1,         %[temp_reg4], %[temp_reg3]                   \n\t"
          "lw     %[temp_reg6], 4*9*4(%[buf])                                \n\t"
          "sub    %[s2],        %[t1],        %[t0]                          \n\t"
          "lw     %[temp_reg3], 29*4(%[win])                                 \n\t"
          "subu   %[s1],        %[temp_reg2], %[s1]                          \n\t"
          "lw     %[temp_reg4], 28*4(%[win])                                 \n\t"
          "add    %[t0],        %[s0],        %[s1]                          \n\t"
          "extr.w %[s3],        $ac1,23                                      \n\t"
          "mult   $ac2,         %[t0],        %[temp_reg3]                   \n\t"
          "sub    %[t1],        %[s0],        %[s1]                          \n\t"
          "lw     %[temp_reg1], 4*8*4(%[buf])                                \n\t"
          "mult   %[t1],        %[temp_reg5]                                 \n\t"
          "lw     %[temp_reg2], 8*4(%[win])                                  \n\t"
          "mfhi   %[temp_reg3], $ac2                                         \n\t"
          "mult   $ac3,         %[t0],        %[temp_reg4]                   \n\t"
          "add    %[t0],        %[s2],        %[s3]                          \n\t"
          "mfhi   %[temp_reg5]                                               \n\t"
          "mult   $ac1,         %[t1],        %[temp_reg2]                   \n\t"
          "sub    %[t1],        %[s2],        %[s3]                          \n\t"
          "sw     %[temp_reg3], 4*9*4(%[buf])                                \n\t"
          "mfhi   %[temp_reg4], $ac3                                         \n\t"
          "lw     %[temp_reg3], 37*4(%[win])                                 \n\t"
          "mfhi   %[temp_reg2], $ac1                                         \n\t"
          "add    %[temp_reg5], %[temp_reg5], %[temp_reg6]                   \n\t"
          "lw     %[temp_reg6], 17*4(%[win])                                 \n\t"
          "sw     %[temp_reg5], 32*9*4(%[out])                               \n\t"
          "sw     %[temp_reg4], 4*8*4(%[buf])                                \n\t"
          "mult   %[t1],        %[temp_reg6]                                 \n\t"
          "add    %[temp_reg1], %[temp_reg1], %[temp_reg2]                   \n\t"
          "lw     %[temp_reg2], 0*4(%[win])                                  \n\t"
          "lw     %[temp_reg5], 4*17*4(%[buf])                               \n\t"
          "sw     %[temp_reg1], 8*32*4(%[out])                               \n\t"
          "mfhi   %[temp_reg6]                                               \n\t"
          "mult   $ac1,         %[t1],        %[temp_reg2]                   \n\t"
          "lw     %[temp_reg4], 20*4(%[win])                                 \n\t"
          "lw     %[temp_reg1], 0(%[buf])                                    \n\t"
          "mult   $ac2,         %[t0],        %[temp_reg3]                   \n\t"
          "mult   %[t0],        %[temp_reg4]                                 \n\t"
          "mfhi   %[temp_reg2], $ac1                                         \n\t"
          "lw     %[t0],        4*4(%[tmp])                                  \n\t"
          "add    %[temp_reg5], %[temp_reg5], %[temp_reg6]                   \n\t"
          "mfhi   %[temp_reg3], $ac2                                         \n\t"
          "mfhi   %[temp_reg4]                                               \n\t"
          "sw     %[temp_reg5], 17*32*4(%[out])                              \n\t"
          "lw     %[t1],        6*4(%[tmp])                                  \n\t"
          "add    %[temp_reg1], %[temp_reg1], %[temp_reg2]                   \n\t"
          "lw     %[t2],        5*4(%[tmp])                                  \n\t"
          "sw     %[temp_reg1], 0*32*4(%[out])                               \n\t"
          "addu   %[s0],        %[t1],        %[t0]                          \n\t"
          "sw     %[temp_reg3], 4*17*4(%[buf])                               \n\t"
          "lw     %[t3],        7*4(%[tmp])                                  \n\t"
          "sub    %[s2],        %[t1],        %[t0]                          \n\t"
          "sw     %[temp_reg4], 0(%[buf])                                    \n\t"
          "addu   %[temp_reg5], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg6], 0x8483EE0C                                   \n\t"
          "move   %[s1],        $0                                           \n\t"
          "multu  %[temp_reg6], %[temp_reg5]                                 \n\t"
          "sub    %[temp_reg1], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg2], 0xf746ea                                     \n\t"
          "sra    %[temp_reg5], %[temp_reg5], 31                             \n\t"
          "mult   $ac1,         %[temp_reg2], %[temp_reg1]                   \n\t"
          "movn   %[s1],        %[temp_reg6], %[temp_reg5]                   \n\t"
          "mfhi   %[temp_reg5]                                               \n\t"
          "lw     %[temp_reg3], 10*4(%[win])                                 \n\t"
          "lw     %[temp_reg4], 4*10*4(%[buf])                               \n\t"
          "extr.w %[s3],        $ac1,         23                             \n\t"
          "lw     %[temp_reg1], 4*7*4(%[buf])                                \n\t"
          "lw     %[temp_reg2], 7*4(%[win])                                  \n\t"
          "lw     %[temp_reg6], 30*4(%[win])                                 \n\t"
          "subu   %[s1],        %[temp_reg5], %[s1]                          \n\t"
          "sub    %[t1],        %[s0],        %[s1]                          \n\t"
          "add    %[t0],        %[s0],        %[s1]                          \n\t"
          "mult   $ac2,         %[t1],        %[temp_reg3]                   \n\t"
          "mult   $ac3,         %[t1],        %[temp_reg2]                   \n\t"
          "mult   %[t0],        %[temp_reg6]                                 \n\t"
          "lw     %[temp_reg5], 27*4(%[win])                                 \n\t"
          "mult   $ac1,         %[t0],        %[temp_reg5]                   \n\t"
          "mfhi   %[temp_reg3], $ac2                                         \n\t"
          "mfhi   %[temp_reg2], $ac3                                         \n\t"
          "mfhi   %[temp_reg6]                                               \n\t"
          "add    %[t0],        %[s2],        %[s3]                          \n\t"
          "sub    %[t1],        %[s2],        %[s3]                          \n\t"
          "add    %[temp_reg3], %[temp_reg3], %[temp_reg4]                   \n\t"
          "lw     %[temp_reg4], 16*4(%[win])                                 \n\t"
          "mfhi   %[temp_reg5], $ac1                                         \n\t"
          "sw     %[temp_reg3], 32*10*4(%[out])                              \n\t"
          "add    %[temp_reg1], %[temp_reg1], %[temp_reg2]                   \n\t"
          "lw     %[temp_reg3], 4*16*4(%[buf])                               \n\t"
          "sw     %[temp_reg6], 4*10*4(%[buf])                               \n\t"
          "sw     %[temp_reg1], 7*32*4(%[out])                               \n\t"
          "mult   $ac2,         %[t1],        %[temp_reg4]                   \n\t"
          "sw     %[temp_reg5], 4*7*4(%[buf])                                \n\t"
          "lw     %[temp_reg6], 1*4(%[win])                                  \n\t"
          "lw     %[temp_reg5], 4*1*4(%[buf])                                \n\t"
          "lw     %[temp_reg1], 36*4(%[win])                                 \n\t"
          "mult   $ac3,         %[t1],        %[temp_reg6]                   \n\t"
          "lw     %[temp_reg2], 21*4(%[win])                                 \n\t"
          "mfhi   %[temp_reg4], $ac2                                         \n\t"
          "mult   %[t0],        %[temp_reg1]                                 \n\t"
          "mult   $ac1,         %[t0],%[temp_reg2]                           \n\t"
          "lw     %[t0],        8*4(%[tmp])                                  \n\t"
          "mfhi   %[temp_reg6], $ac3                                         \n\t"
          "lw     %[t1],        10*4(%[tmp])                                 \n\t"
          "lw     %[t3],        11*4(%[tmp])                                 \n\t"
          "mfhi   %[temp_reg1]                                               \n\t"
          "add    %[temp_reg3], %[temp_reg3], %[temp_reg4]                   \n\t"
          "lw     %[t2],        9*4(%[tmp])                                  \n\t"
          "mfhi   %[temp_reg2], $ac1                                         \n\t"
          "add    %[temp_reg5], %[temp_reg5], %[temp_reg6]                   \n\t"
          "sw     %[temp_reg3], 16*32*4(%[out])                              \n\t"
          "sw     %[temp_reg5], 1*32*4(%[out])                               \n\t"
          "sw     %[temp_reg1], 4*16*4(%[buf])                               \n\t"
          "addu   %[temp_reg3], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg4], 0x8D3B7CD6                                   \n\t"
          "sw     %[temp_reg2], 4*1*4(%[buf])                                \n\t"
          "multu  %[temp_reg4],%[temp_reg3]                                  \n\t"
          "sra    %[temp_reg3], %[temp_reg3], 31                             \n\t"
          "move   %[s1],        $0                                           \n\t"
          "movn   %[s1],        %[temp_reg4], %[temp_reg3]                   \n\t"
          "addu   %[s0],        %[t1],        %[t0]                          \n\t"
          "mfhi   %[temp_reg3]                                               \n\t"
          "sub    %[s2],        %[t1],        %[t0]                          \n\t"
          "sub    %[temp_reg5], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg6], 0x976fd9                                     \n\t"
          "lw     %[temp_reg2], 11*4(%[win])                                 \n\t"
          "lw     %[temp_reg1], 4*11*4(%[buf])                               \n\t"
          "mult   $ac1,         %[temp_reg6], %[temp_reg5]                   \n\t"
          "subu   %[s1],        %[temp_reg3], %[s1]                          \n\t"
          "lw     %[temp_reg5], 31*4(%[win])                                 \n\t"
          "sub    %[t1],        %[s0],        %[s1]                          \n\t"
          "add    %[t0],        %[s0],        %[s1]                          \n\t"
          "mult   $ac2,         %[t1],        %[temp_reg2]                   \n\t"
          "mult   %[t0],        %[temp_reg5]                                 \n\t"
          "lw     %[temp_reg4], 6*4(%[win])                                  \n\t"
          "extr.w %[s3],        $ac1,         23                             \n\t"
          "lw     %[temp_reg3], 4*6*4(%[buf])                                \n\t"
          "mfhi   %[temp_reg2], $ac2                                         \n\t"
          "lw     %[temp_reg6], 26*4(%[win])                                 \n\t"
          "mfhi   %[temp_reg5]                                               \n\t"
          "mult   $ac3,         %[t1],        %[temp_reg4]                   \n\t"
          "mult   $ac1,         %[t0],        %[temp_reg6]                   \n\t"
          "add    %[t0],        %[s2],        %[s3]                          \n\t"
          "sub    %[t1],        %[s2],        %[s3]                          \n\t"
          "add    %[temp_reg2], %[temp_reg2], %[temp_reg1]                   \n\t"
          "mfhi   %[temp_reg4], $ac3                                         \n\t"
          "mfhi   %[temp_reg6], $ac1                                         \n\t"
          "sw     %[temp_reg5], 4*11*4(%[buf])                               \n\t"
          "sw     %[temp_reg2], 32*11*4(%[out])                              \n\t"
          "lw     %[temp_reg1], 4*15*4(%[buf])                               \n\t"
          "add    %[temp_reg3], %[temp_reg3], %[temp_reg4]                   \n\t"
          "lw     %[temp_reg2], 15*4(%[win])                                 \n\t"
          "sw     %[temp_reg3], 6*32*4(%[out])                               \n\t"
          "sw     %[temp_reg6], 4*6*4(%[buf])                                \n\t"
          "mult   %[t1],        %[temp_reg2]                                 \n\t"
          "lw     %[temp_reg3], 2*4(%[win])                                  \n\t"
          "lw     %[temp_reg4], 4*2*4(%[buf])                                \n\t"
          "lw     %[temp_reg5], 35*4(%[win])                                 \n\t"
          "mult   $ac1,         %[t1],        %[temp_reg3]                   \n\t"
          "mfhi   %[temp_reg2]                                               \n\t"
          "lw     %[temp_reg6], 22*4(%[win])                                 \n\t"
          "mult   $ac2,         %[t0],        %[temp_reg5]                   \n\t"
          "lw     %[t1],        14*4(%[tmp])                                 \n\t"
          "mult   $ac3,         %[t0],        %[temp_reg6]                   \n\t"
          "lw     %[t0],        12*4(%[tmp])                                 \n\t"
          "mfhi   %[temp_reg3], $ac1                                         \n\t"
          "add    %[temp_reg1], %[temp_reg1], %[temp_reg2]                   \n\t"
          "mfhi   %[temp_reg5], $ac2                                         \n\t"
          "sw     %[temp_reg1], 15*32*4(%[out])                              \n\t"
          "mfhi   %[temp_reg6], $ac3                                         \n\t"
          "lw     %[t2],        13*4(%[tmp])                                 \n\t"
          "lw     %[t3],        15*4(%[tmp])                                 \n\t"
          "add    %[temp_reg4], %[temp_reg4], %[temp_reg3]                   \n\t"
          "sw     %[temp_reg5], 4*15*4(%[buf])                               \n\t"
          "addu   %[temp_reg1], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg2], 0x9C42577C                                   \n\t"
          "move   %[s1],        $0                                           \n\t"
          "multu  %[temp_reg2], %[temp_reg1]                                 \n\t"
          "sw     %[temp_reg4], 2*32*4(%[out])                               \n\t"
          "sra    %[temp_reg1], %[temp_reg1], 31                             \n\t"
          "movn   %[s1],        %[temp_reg2], %[temp_reg1]                   \n\t"
          "sub    %[temp_reg3], %[t3],        %[t2]                          \n\t"
          "li     %[temp_reg4], 0x6f94a2                                     \n\t"
          "mfhi   %[temp_reg1]                                               \n\t"
          "addu   %[s0],        %[t1],        %[t0]                          \n\t"
          "sw     %[temp_reg6], 4*2*4(%[buf])                                \n\t"
          "mult   $ac1,         %[temp_reg4], %[temp_reg3]                   \n\t"
          "sub    %[s2],        %[t1],        %[t0]                          \n\t"
          "lw     %[temp_reg5], 12*4(%[win])                                 \n\t"
          "lw     %[temp_reg6], 4*12*4(%[buf])                               \n\t"
          "subu   %[s1],        %[temp_reg1], %[s1]                          \n\t"
          "sub    %[t1],        %[s0],        %[s1]                          \n\t"
          "lw     %[temp_reg3], 32*4(%[win])                                 \n\t"
          "mult   $ac2,         %[t1],        %[temp_reg5]                   \n\t"
          "add    %[t0],        %[s0],        %[s1]                          \n\t"
          "extr.w %[s3],        $ac1,         23                             \n\t"
          "lw     %[temp_reg2], 5*4(%[win])                                  \n\t"
          "mult   %[t0],        %[temp_reg3]                                 \n\t"
          "mfhi   %[temp_reg5], $ac2                                         \n\t"
          "lw     %[temp_reg4], 25*4(%[win])                                 \n\t"
          "lw     %[temp_reg1], 4*5*4(%[buf])                                \n\t"
          "mult   $ac3,         %[t1],        %[temp_reg2]                   \n\t"
          "mult   $ac1,         %[t0],        %[temp_reg4]                   \n\t"
          "mfhi   %[temp_reg3]                                               \n\t"
          "add    %[t0],        %[s2],        %[s3]                          \n\t"
          "add    %[temp_reg5], %[temp_reg5], %[temp_reg6]                   \n\t"
          "mfhi   %[temp_reg2], $ac3                                         \n\t"
          "mfhi   %[temp_reg4], $ac1                                         \n\t"
          "sub    %[t1],        %[s2],        %[s3]                          \n\t"
          "sw     %[temp_reg5], 32*12*4(%[out])                              \n\t"
          "sw     %[temp_reg3], 4*12*4(%[buf])                               \n\t"
          "lw     %[temp_reg6], 14*4(%[win])                                 \n\t"
          "lw     %[temp_reg5], 4*14*4(%[buf])                               \n\t"
          "add    %[temp_reg1], %[temp_reg1], %[temp_reg2]                   \n\t"
          "sw     %[temp_reg4], 4*5*4(%[buf])                                \n\t"
          "sw     %[temp_reg1], 5*32*4(%[out])                               \n\t"
          "mult   %[t1],        %[temp_reg6]                                 \n\t"
          "lw     %[temp_reg4], 34*4(%[win])                                 \n\t"
          "lw     %[temp_reg2], 3*4(%[win])                                  \n\t"
          "lw     %[temp_reg1], 4*3*4(%[buf])                                \n\t"
          "mult   $ac2,         %[t0],        %[temp_reg4]                   \n\t"
          "mfhi   %[temp_reg6]                                               \n\t"
          "mult   $ac1,         %[t1],        %[temp_reg2]                   \n\t"
          "lw     %[temp_reg3], 23*4(%[win])                                 \n\t"
          "lw     %[s0],        16*4(%[tmp])                                 \n\t"
          "mfhi   %[temp_reg4], $ac2                                         \n\t"
          "lw     %[t1],        17*4(%[tmp])                                 \n\t"
          "mult   $ac3,         %[t0],        %[temp_reg3]                   \n\t"
          "move   %[s1],        $0                                           \n\t"
          "add    %[temp_reg5], %[temp_reg5], %[temp_reg6]                   \n\t"
          "mfhi   %[temp_reg2], $ac1                                         \n\t"
          "sw     %[temp_reg5], 14*32*4(%[out])                              \n\t"
          "sw     %[temp_reg4], 4*14*4(%[buf])                               \n\t"
          "mfhi   %[temp_reg3], $ac3                                         \n\t"
          "li     %[temp_reg5], 0xB504F334                                   \n\t"
          "add    %[temp_reg1], %[temp_reg1], %[temp_reg2]                   \n\t"
          "multu  %[temp_reg5], %[t1]                                        \n\t"
          "lw     %[temp_reg2], 4*13*4(%[buf])                               \n\t"
          "sw     %[temp_reg1], 3*32*4(%[out])                               \n\t"
          "sra    %[t1],        %[t1],        31                             \n\t"
          "mfhi   %[temp_reg6]                                               \n\t"
          "movn   %[s1],        %[temp_reg5], %[t1]                          \n\t"
          "sw     %[temp_reg3], 4*3*4(%[buf])                                \n\t"
          "lw     %[temp_reg1], 13*4(%[win])                                 \n\t"
          "lw     %[temp_reg4], 4*4*4(%[buf])                                \n\t"
          "lw     %[temp_reg3], 4*4(%[win])                                  \n\t"
          "lw     %[temp_reg5], 33*4(%[win])                                 \n\t"
          "subu   %[s1],        %[temp_reg6], %[s1]                          \n\t"
          "lw     %[temp_reg6], 24*4(%[win])                                 \n\t"
          "sub    %[t1],        %[s0],        %[s1]                          \n\t"
          "add    %[t0],        %[s0],        %[s1]                          \n\t"
          "mult   $ac1,         %[t1],        %[temp_reg1]                   \n\t"
          "mult   $ac2,         %[t1],        %[temp_reg3]                   \n\t"
          "mult   $ac3,         %[t0],        %[temp_reg5]                   \n\t"
          "mult   %[t0],        %[temp_reg6]                                 \n\t"
          "mfhi   %[temp_reg1], $ac1                                         \n\t"
          "mfhi   %[temp_reg3], $ac2                                         \n\t"
          "mfhi   %[temp_reg5], $ac3                                         \n\t"
          "mfhi   %[temp_reg6]                                               \n\t"
          "add    %[temp_reg2], %[temp_reg2], %[temp_reg1]                   \n\t"
          "add    %[temp_reg4], %[temp_reg4], %[temp_reg3]                   \n\t"
          "sw     %[temp_reg2], 13*32*4(%[out])                              \n\t"
          "sw     %[temp_reg4], 4*32*4(%[out])                               \n\t"
          "sw     %[temp_reg5], 4*13*4(%[buf])                               \n\t"
          "sw     %[temp_reg6], 4*4*4(%[buf])                                \n\t"
  
          : [t0] "=&r" (t0), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3),
            [s0] "=&r" (s0), [s2] "=&r" (s2), [temp_reg1] "=&r" (temp_reg1),
            [temp_reg2] "=&r" (temp_reg2), [s1] "=&r" (s1), [s3] "=&r" (s3),
            [temp_reg3] "=&r" (temp_reg3), [temp_reg4] "=&r" (temp_reg4),
            [temp_reg5] "=&r" (temp_reg5), [temp_reg6] "=&r" (temp_reg6),
            [out] "+r" (out)
          : [tmp] "r" (tmp), [win] "r" (win), [buf] "r" (buf)
          : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
            "$ac3hi", "$ac3lo"
      );
  }
  
  static void ff_imdct36_blocks_mips_fixed(int *out, int *buf, int *in,
                                 int count, int switch_point, int block_type)
  {
      int j;
      for (j=0 ; j < count; j++) {
          /* apply window & overlap with previous buffer */
  
          /* select window */
          int win_idx = (switch_point && j < 2) ? 0 : block_type;
          int *win = ff_mdct_win_fixed[win_idx + (4 & -(j & 1))];
  
          imdct36_mips_fixed(out, buf, in, win);
  
          in  += 18;
          buf += ((j&3) != 3 ? 1 : (72-3));
          out++;
      }
  }
  
  #endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
  #endif /* HAVE_INLINE_ASM */
  
  void ff_mpadsp_init_mipsdsp(MPADSPContext *s)
  {
  #if HAVE_INLINE_ASM
  #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
      s->apply_window_fixed   = ff_mpadsp_apply_window_mips_fixed;
      s->imdct36_blocks_fixed = ff_imdct36_blocks_mips_fixed;
  #endif
  #endif
  }