summaryrefslogtreecommitdiffstats
path: root/libavcodec/mips/vp3dsp_idct_mmi.c
blob: c5c4cf31270aabf4e0e1c53866e39470c44dc1f5 (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
/*
 * Copyright (c) 2018 gxw <guxiwei-hf@loongson.cn>
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "vp3dsp_mips.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mips/mmiutils.h"
#include "libavutil/common.h"
#include "libavcodec/rnd_avg.h"

#define LOAD_CONST(dst, value)                        \
    "li     %[tmp1],      "#value"              \n\t" \
    "dmtc1  %[tmp1],      "#dst"                \n\t" \
    "pshufh "#dst",       "#dst",     %[ftmp10] \n\t"

static void idct_row_mmi(int16_t *input)
{
    double ftmp[23];
    uint64_t tmp[2];
    __asm__ volatile (
        "xor        %[ftmp10],      %[ftmp10],        %[ftmp10] \n\t"
        LOAD_CONST(%[csth_1], 1)
        "li         %[tmp0],        0x02                        \n\t"
        "1:                                                     \n\t"
        /* Load input */
        "ldc1       %[ftmp0],       0x00(%[input])              \n\t"
        "ldc1       %[ftmp1],       0x10(%[input])              \n\t"
        "ldc1       %[ftmp2],       0x20(%[input])              \n\t"
        "ldc1       %[ftmp3],       0x30(%[input])              \n\t"
        "ldc1       %[ftmp4],       0x40(%[input])              \n\t"
        "ldc1       %[ftmp5],       0x50(%[input])              \n\t"
        "ldc1       %[ftmp6],       0x60(%[input])              \n\t"
        "ldc1       %[ftmp7],       0x70(%[input])              \n\t"
        LOAD_CONST(%[ftmp8], 64277)
        LOAD_CONST(%[ftmp9], 12785)
        "pmulhh     %[A],           %[ftmp9],         %[ftmp7]  \n\t"
        "pcmpgth    %[C],           %[ftmp10],        %[ftmp1]  \n\t"
        "or         %[mask],        %[C],             %[csth_1] \n\t"
        "pmullh     %[B],           %[ftmp1],         %[mask]   \n\t"
        "pmulhuh    %[B],           %[ftmp8],         %[B]      \n\t"
        "pmullh     %[B],           %[B],             %[mask]   \n\t"
        "paddh      %[A],           %[A],             %[B]      \n\t"
        "paddh      %[A],           %[A],             %[C]      \n\t"
        "pcmpgth    %[D],           %[ftmp10],        %[ftmp7]  \n\t"
        "or         %[mask],        %[D],             %[csth_1] \n\t"
        "pmullh     %[ftmp7],       %[ftmp7],         %[mask]   \n\t"
        "pmulhuh    %[B],           %[ftmp8],         %[ftmp7]  \n\t"
        "pmullh     %[B],           %[B],             %[mask]   \n\t"
        "pmulhh     %[C],           %[ftmp9],         %[ftmp1]  \n\t"
        "psubh      %[B],           %[C],             %[B]      \n\t"
        "psubh      %[B],           %[B],             %[D]      \n\t"

        LOAD_CONST(%[ftmp8], 54491)
        LOAD_CONST(%[ftmp9], 36410)
        "pcmpgth    %[Ad],          %[ftmp10],        %[ftmp5]  \n\t"
        "or         %[mask],        %[Ad],            %[csth_1] \n\t"
        "pmullh     %[ftmp1],       %[ftmp5],         %[mask]   \n\t"
        "pmulhuh    %[C],           %[ftmp9],         %[ftmp1]  \n\t"
        "pmullh     %[C],           %[C],             %[mask]   \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],        %[ftmp3]  \n\t"
        "or         %[mask],        %[Bd],            %[csth_1] \n\t"
        "pmullh     %[D],           %[ftmp3],         %[mask]   \n\t"
        "pmulhuh    %[D],           %[ftmp8],         %[D]      \n\t"
        "pmullh     %[D],           %[D],             %[mask]   \n\t"
        "paddh      %[C],           %[C],             %[D]      \n\t"
        "paddh      %[C],           %[C],             %[Ad]     \n\t"
        "paddh      %[C],           %[C],             %[Bd]     \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],        %[ftmp3]  \n\t"
        "or         %[mask],        %[Bd],            %[csth_1] \n\t"
        "pmullh     %[ftmp1],       %[ftmp3],         %[mask]   \n\t"
        "pmulhuh    %[D],           %[ftmp9],         %[ftmp1]  \n\t"
        "pmullh     %[D],           %[D],             %[mask]   \n\t"
        "pcmpgth    %[Ed],          %[ftmp10],        %[ftmp5]  \n\t"
        "or         %[mask],        %[Ed],            %[csth_1] \n\t"
        "pmullh     %[Ad],          %[ftmp5],         %[mask]   \n\t"
        "pmulhuh    %[Ad],          %[ftmp8],         %[Ad]     \n\t"
        "pmullh     %[Ad],          %[Ad],            %[mask]   \n\t"
        "psubh      %[D],           %[Ad],            %[D]      \n\t"
        "paddh      %[D],           %[D],             %[Ed]     \n\t"
        "psubh      %[D],           %[D],             %[Bd]     \n\t"

        LOAD_CONST(%[ftmp8], 46341)
        "psubh      %[Ad],          %[A],             %[C]      \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],        %[Ad]     \n\t"
        "or         %[mask],        %[Bd],            %[csth_1] \n\t"
        "pmullh     %[Ad],          %[Ad],            %[mask]   \n\t"
        "pmulhuh    %[Ad],          %[ftmp8],         %[Ad]     \n\t"
        "pmullh     %[Ad],          %[Ad],            %[mask]   \n\t"
        "paddh      %[Ad],          %[Ad],            %[Bd]     \n\t"
        "psubh      %[Bd],          %[B],             %[D]      \n\t"
        "pcmpgth    %[Cd],          %[ftmp10],        %[Bd]     \n\t"
        "or         %[mask],        %[Cd],            %[csth_1] \n\t"
        "pmullh     %[Bd],          %[Bd],            %[mask]   \n\t"
        "pmulhuh    %[Bd],          %[ftmp8],         %[Bd]     \n\t"
        "pmullh     %[Bd],          %[Bd],            %[mask]   \n\t"
        "paddh      %[Bd],          %[Bd],            %[Cd]     \n\t"
        "paddh      %[Cd],          %[A],             %[C]      \n\t"
        "paddh      %[Dd],          %[B],             %[D]      \n\t"
        "paddh      %[A],           %[ftmp0],         %[ftmp4]  \n\t"
        "pcmpgth    %[B],           %[ftmp10],        %[A]      \n\t"
        "or         %[mask],        %[B],             %[csth_1] \n\t"
        "pmullh     %[A],           %[A],             %[mask]   \n\t"
        "pmulhuh    %[A],           %[ftmp8],         %[A]      \n\t"
        "pmullh     %[A],           %[A],             %[mask]   \n\t"
        "paddh      %[A],           %[A],             %[B]      \n\t"
        "psubh      %[B],           %[ftmp0],         %[ftmp4]  \n\t"
        "pcmpgth    %[C],           %[ftmp10],        %[B]      \n\t"
        "or         %[mask],        %[C],             %[csth_1] \n\t"
        "pmullh     %[B],           %[B],             %[mask]   \n\t"
        "pmulhuh    %[B],           %[ftmp8],         %[B]      \n\t"
        "pmullh     %[B],           %[B],             %[mask]   \n\t"
        "paddh      %[B],           %[B],             %[C]      \n\t"

        LOAD_CONST(%[ftmp8], 60547)
        LOAD_CONST(%[ftmp9], 25080)
        "pmulhh     %[C],           %[ftmp9],         %[ftmp6]  \n\t"
        "pcmpgth    %[D],           %[ftmp10],        %[ftmp2]  \n\t"
        "or         %[mask],        %[D],             %[csth_1] \n\t"
        "pmullh     %[Ed],          %[ftmp2],         %[mask]   \n\t"
        "pmulhuh    %[Ed],          %[ftmp8],         %[Ed]     \n\t"
        "pmullh     %[Ed],          %[Ed],            %[mask]   \n\t"
        "paddh      %[C],           %[C],             %[Ed]     \n\t"
        "paddh      %[C],           %[C],             %[D]      \n\t"
        "pcmpgth    %[Ed],          %[ftmp10],        %[ftmp6]  \n\t"
        "or         %[mask],        %[Ed],            %[csth_1] \n\t"
        "pmullh     %[ftmp6],       %[ftmp6],         %[mask]   \n\t"
        "pmulhuh    %[D],           %[ftmp8],         %[ftmp6]  \n\t"
        "pmullh     %[D],           %[D],             %[mask]   \n\t"
        "pmulhh     %[Gd],          %[ftmp9],         %[ftmp2]  \n\t"
        "psubh      %[D],           %[Gd],            %[D]      \n\t"
        "psubh      %[D],           %[D],             %[Ed]     \n\t"
        "psubh      %[Ed],          %[A],             %[C]      \n\t"
        "paddh      %[Gd],          %[A],             %[C]      \n\t"
        "paddh      %[A],           %[B],             %[Ad]     \n\t"
        "psubh      %[C],           %[B],             %[Ad]     \n\t"
        "psubh      %[B],           %[Bd],            %[D]      \n\t"
        "paddh      %[D],           %[Bd],            %[D]      \n\t"
        /* Final sequence of operations over-write original inputs */
        "paddh      %[ftmp0],       %[Gd],            %[Cd]     \n\t"
        "paddh      %[ftmp1],       %[A],             %[D]      \n\t"
        "psubh      %[ftmp2],       %[A],             %[D]      \n\t"
        "paddh      %[ftmp3],       %[Ed],            %[Dd]     \n\t"
        "psubh      %[ftmp4],       %[Ed],            %[Dd]     \n\t"
        "paddh      %[ftmp5],       %[C],             %[B]      \n\t"
        "psubh      %[ftmp6],       %[C],             %[B]      \n\t"
        "psubh      %[ftmp7],       %[Gd],            %[Cd]     \n\t"
        "sdc1       %[ftmp0],       0x00(%[input])              \n\t"
        "sdc1       %[ftmp1],       0x10(%[input])              \n\t"
        "sdc1       %[ftmp2],       0x20(%[input])              \n\t"
        "sdc1       %[ftmp3],       0x30(%[input])              \n\t"
        "sdc1       %[ftmp4],       0x40(%[input])              \n\t"
        "sdc1       %[ftmp5],       0x50(%[input])              \n\t"
        "sdc1       %[ftmp6],       0x60(%[input])              \n\t"
        "sdc1       %[ftmp7],       0x70(%[input])              \n\t"
        PTR_ADDU   "%[tmp0],        %[tmp0],          -0x01     \n\t"
        PTR_ADDIU  "%[input],       %[input],         0x08      \n\t"
        "bnez       %[tmp0],        1b                          \n\t"
        : [input]"+&r"(input), [tmp0]"=&r"(tmp[0]), [tmp1]"=&r"(tmp[1]),
          [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]),
          [ftmp3]"=&f"(ftmp[3]), [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
          [ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), [ftmp8]"=&f"(ftmp[8]),
          [ftmp9]"=&f"(ftmp[9]), [ftmp10]"=&f"(ftmp[10]), [mask]"=&f"(ftmp[11]),
          [A]"=&f"(ftmp[12]), [B]"=&f"(ftmp[13]), [C]"=&f"(ftmp[14]),
          [D]"=&f"(ftmp[15]), [Ad]"=&f"(ftmp[16]), [Bd]"=&f"(ftmp[17]),
          [Cd]"=&f"(ftmp[18]), [Dd]"=&f"(ftmp[19]), [Ed]"=&f"(ftmp[20]),
          [Gd]"=&f"(ftmp[21]), [csth_1]"=&f"(ftmp[22])
        :
        : "memory"
    );
}

static void idct_column_true_mmi(uint8_t *dst, int stride, int16_t *input)
{
    uint8_t temp_value[8];
    double ftmp[23];
    uint64_t tmp[2];
    for (int i = 0; i < 8; ++i)
        temp_value[i] = av_clip_uint8(128 + ((46341 * input[i << 3] + (8 << 16)) >> 20));
    __asm__ volatile (
        "xor        %[ftmp10],      %[ftmp10],          %[ftmp10] \n\t"
        "li         %[tmp0],        0x02                          \n\t"
        "1:                                                       \n\t"
        "ldc1       %[ftmp0],       0x00(%[input])                \n\t"
        "ldc1       %[ftmp4],       0x08(%[input])                \n\t"
        "ldc1       %[ftmp1],       0x10(%[input])                \n\t"
        "ldc1       %[ftmp5],       0x18(%[input])                \n\t"
        "ldc1       %[ftmp2],       0x20(%[input])                \n\t"
        "ldc1       %[ftmp6],       0x28(%[input])                \n\t"
        "ldc1       %[ftmp3],       0x30(%[input])                \n\t"
        "ldc1       %[ftmp7],       0x38(%[input])                \n\t"
        TRANSPOSE_4H(%[ftmp0], %[ftmp1], %[ftmp2], %[ftmp3],
                     %[A], %[B], %[C], %[D])
        TRANSPOSE_4H(%[ftmp4], %[ftmp5], %[ftmp6], %[ftmp7],
                     %[A], %[B], %[C], %[D])
        LOAD_CONST(%[ftmp8], 64277)
        LOAD_CONST(%[ftmp9], 12785)
        LOAD_CONST(%[Gd], 1)
        "pmulhh     %[A],           %[ftmp9],           %[ftmp7]  \n\t"
        "pcmpgth    %[C],           %[ftmp10],          %[ftmp1]  \n\t"
        "or         %[mask],        %[C],               %[Gd]     \n\t"
        "pmullh     %[B],           %[ftmp1],           %[mask]   \n\t"
        "pmulhuh    %[B],           %[ftmp8],           %[B]      \n\t"
        "pmullh     %[B],           %[B],               %[mask]   \n\t"
        "paddh      %[A],           %[A],               %[B]      \n\t"
        "paddh      %[A],           %[A],               %[C]      \n\t"
        "pcmpgth    %[D],           %[ftmp10],          %[ftmp7]  \n\t"
        "or         %[mask],        %[D],               %[Gd]     \n\t"
        "pmullh     %[Ad],          %[ftmp7],           %[mask]   \n\t"
        "pmulhuh    %[B],           %[ftmp8],           %[Ad]     \n\t"
        "pmullh     %[B],           %[B],               %[mask]   \n\t"
        "pmulhh     %[C],           %[ftmp9],           %[ftmp1]  \n\t"
        "psubh      %[B],           %[C],               %[B]      \n\t"
        "psubh      %[B],           %[B],               %[D]      \n\t"

        LOAD_CONST(%[ftmp8], 54491)
        LOAD_CONST(%[ftmp9], 36410)
        "pcmpgth    %[Ad],          %[ftmp10],          %[ftmp5]  \n\t"
        "or         %[mask],        %[Ad],              %[Gd]     \n\t"
        "pmullh     %[Cd],          %[ftmp5],           %[mask]   \n\t"
        "pmulhuh    %[C],           %[ftmp9],           %[Cd]     \n\t"
        "pmullh     %[C],           %[C],               %[mask]   \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],          %[ftmp3]  \n\t"
        "or         %[mask],        %[Bd],              %[Gd]     \n\t"
        "pmullh     %[D],           %[ftmp3],           %[mask]   \n\t"
        "pmulhuh    %[D],           %[ftmp8],           %[D]      \n\t"
        "pmullh     %[D],           %[D],               %[mask]   \n\t"
        "paddh      %[C],           %[C],               %[D]      \n\t"
        "paddh      %[C],           %[C],               %[Ad]     \n\t"
        "paddh      %[C],           %[C],               %[Bd]     \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],          %[ftmp3]  \n\t"
        "or         %[mask],        %[Bd],              %[Gd]     \n\t"
        "pmullh     %[Cd],          %[ftmp3],           %[mask]   \n\t"
        "pmulhuh    %[D],           %[ftmp9],           %[Cd]     \n\t"
        "pmullh     %[D],           %[D],               %[mask]   \n\t"
        "pcmpgth    %[Ed],          %[ftmp10],          %[ftmp5]  \n\t"
        "or         %[mask],        %[Ed],              %[Gd]     \n\t"
        "pmullh     %[Ad],          %[ftmp5],           %[mask]   \n\t"
        "pmulhuh    %[Ad],          %[ftmp8],           %[Ad]     \n\t"
        "pmullh     %[Ad],          %[Ad],              %[mask]   \n\t"
        "psubh      %[D],           %[Ad],              %[D]      \n\t"
        "paddh      %[D],           %[D],               %[Ed]     \n\t"
        "psubh      %[D],           %[D],               %[Bd]     \n\t"

        LOAD_CONST(%[ftmp8], 46341)
        "psubh      %[Ad],          %[A],             %[C]        \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],        %[Ad]       \n\t"
        "or         %[mask],        %[Bd],            %[Gd]       \n\t"
        "pmullh     %[Ad],          %[Ad],            %[mask]     \n\t"
        "pmulhuh    %[Ad],          %[ftmp8],         %[Ad]       \n\t"
        "pmullh     %[Ad],          %[Ad],            %[mask]     \n\t"
        "paddh      %[Ad],          %[Ad],            %[Bd]       \n\t"
        "psubh      %[Bd],          %[B],             %[D]        \n\t"
        "pcmpgth    %[Cd],          %[ftmp10],        %[Bd]       \n\t"
        "or         %[mask],        %[Cd],            %[Gd]       \n\t"
        "pmullh     %[Bd],          %[Bd],            %[mask]     \n\t"
        "pmulhuh    %[Bd],          %[ftmp8],         %[Bd]       \n\t"
        "pmullh     %[Bd],          %[Bd],            %[mask]     \n\t"
        "paddh      %[Bd],          %[Bd],            %[Cd]       \n\t"
        "paddh      %[Cd],          %[A],             %[C]        \n\t"
        "paddh      %[Dd],          %[B],             %[D]        \n\t"

        LOAD_CONST(%[Ed], 2056)
        "paddh      %[A],           %[ftmp0],         %[ftmp4]    \n\t"
        "pcmpgth    %[B],           %[ftmp10],        %[A]        \n\t"
        "or         %[mask],        %[B],             %[Gd]       \n\t"
        "pmullh     %[A],           %[A],             %[mask]     \n\t"
        "pmulhuh    %[A],           %[ftmp8],         %[A]        \n\t"
        "pmullh     %[A],           %[A],             %[mask]     \n\t"
        "paddh      %[A],           %[A],             %[B]        \n\t"
        "paddh      %[A],           %[A],             %[Ed]       \n\t"
        "psubh      %[B],           %[ftmp0],         %[ftmp4]    \n\t"
        "pcmpgth    %[C],           %[ftmp10],        %[B]        \n\t"
        "or         %[mask],        %[C],             %[Gd]       \n\t"
        "pmullh     %[B],           %[B],             %[mask]     \n\t"
        "pmulhuh    %[B],           %[ftmp8],         %[B]        \n\t"
        "pmullh     %[B],           %[B],             %[mask]     \n\t"
        "paddh      %[B],           %[B],             %[C]        \n\t"
        "paddh      %[B],           %[B],             %[Ed]       \n\t"

        LOAD_CONST(%[ftmp8], 60547)
        LOAD_CONST(%[ftmp9], 25080)
        "pmulhh     %[C],           %[ftmp9],         %[ftmp6]    \n\t"
        "pcmpgth    %[D],           %[ftmp10],        %[ftmp2]    \n\t"
        "or         %[mask],        %[D],             %[Gd]       \n\t"
        "pmullh     %[Ed],          %[ftmp2],         %[mask]     \n\t"
        "pmulhuh    %[Ed],          %[ftmp8],         %[Ed]       \n\t"
        "pmullh     %[Ed],          %[Ed],            %[mask]     \n\t"
        "paddh      %[C],           %[C],             %[Ed]       \n\t"
        "paddh      %[C],           %[C],             %[D]        \n\t"
        "pcmpgth    %[Ed],          %[ftmp10],        %[ftmp6]    \n\t"
        "or         %[mask],        %[Ed],            %[Gd]       \n\t"
        "pmullh     %[D],           %[ftmp6],         %[mask]     \n\t"
        "pmulhuh    %[D],           %[ftmp8],         %[D]        \n\t"
        "pmullh     %[D],           %[D],             %[mask]     \n\t"
        "pmulhh     %[Gd],          %[ftmp9],         %[ftmp2]    \n\t"
        "psubh      %[D],           %[Gd],            %[D]        \n\t"
        "psubh      %[D],           %[D],             %[Ed]       \n\t"
        "psubh      %[Ed],          %[A],             %[C]        \n\t"
        "paddh      %[Gd],          %[A],             %[C]        \n\t"
        "paddh      %[A],           %[B],             %[Ad]       \n\t"
        "psubh      %[C],           %[B],             %[Ad]       \n\t"
        "psubh      %[B],           %[Bd],            %[D]        \n\t"
        "paddh      %[D],           %[Bd],            %[D]        \n\t"
        "or         %[mask],        %[ftmp1],         %[ftmp2]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp3]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp4]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp5]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp6]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp7]    \n\t"
        "pcmpeqh    %[mask],        %[mask],          %[ftmp10]   \n\t"
        "packushb   %[mask],        %[mask],          %[ftmp10]   \n\t"
        "li         %[tmp1],        0x04                          \n\t"
        "dmtc1      %[tmp1],        %[ftmp8]                      \n\t"
        "paddh      %[ftmp0],       %[Gd],            %[Cd]       \n\t"
        "psrah      %[ftmp0],       %[ftmp0],         %[ftmp8]    \n\t"
        "paddh      %[ftmp1],       %[A],             %[D]        \n\t"
        "psrah      %[ftmp1],       %[ftmp1],         %[ftmp8]    \n\t"
        "psubh      %[ftmp2],       %[A],             %[D]        \n\t"
        "psrah      %[ftmp2],       %[ftmp2],         %[ftmp8]    \n\t"
        "paddh      %[ftmp3],       %[Ed],            %[Dd]       \n\t"
        "psrah      %[ftmp3],       %[ftmp3],         %[ftmp8]    \n\t"
        "psubh      %[ftmp4],       %[Ed],            %[Dd]       \n\t"
        "psrah      %[ftmp4],       %[ftmp4],         %[ftmp8]    \n\t"
        "paddh      %[ftmp5],       %[C],             %[B]        \n\t"
        "psrah      %[ftmp5],       %[ftmp5],         %[ftmp8]    \n\t"
        "psubh      %[ftmp6],       %[C],             %[B]        \n\t"
        "psrah      %[ftmp6],       %[ftmp6],         %[ftmp8]    \n\t"
        "psubh      %[ftmp7],       %[Gd],            %[Cd]       \n\t"
        "psrah      %[ftmp7],       %[ftmp7],         %[ftmp8]    \n\t"
        "pmaxsh     %[ftmp0],       %[ftmp0],         %[ftmp10]   \n\t"
        "packushb   %[ftmp0],       %[ftmp0],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp1],       %[ftmp1],         %[ftmp10]   \n\t"
        "packushb   %[ftmp1],       %[ftmp1],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp2],       %[ftmp2],         %[ftmp10]   \n\t"
        "packushb   %[ftmp2],       %[ftmp2],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp3],       %[ftmp3],         %[ftmp10]   \n\t"
        "packushb   %[ftmp3],       %[ftmp3],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp4],       %[ftmp4],         %[ftmp10]   \n\t"
        "packushb   %[ftmp4],       %[ftmp4],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp5],       %[ftmp5],         %[ftmp10]   \n\t"
        "packushb   %[ftmp5],       %[ftmp5],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp6],       %[ftmp6],         %[ftmp10]   \n\t"
        "packushb   %[ftmp6],       %[ftmp6],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp7],       %[ftmp7],         %[ftmp10]   \n\t"
        "packushb   %[ftmp7],       %[ftmp7],         %[ftmp10]   \n\t"

        "lwc1       %[Ed],          0x00(%[temp_value])           \n\t"
        "and        %[Ed],          %[Ed],            %[mask]     \n\t"
        "paddb      %[ftmp0],       %[ftmp0],         %[Ed]       \n\t"
        "paddb      %[ftmp1],       %[ftmp1],         %[Ed]       \n\t"
        "paddb      %[ftmp2],       %[ftmp2],         %[Ed]       \n\t"
        "paddb      %[ftmp3],       %[ftmp3],         %[Ed]       \n\t"
        "paddb      %[ftmp4],       %[ftmp4],         %[Ed]       \n\t"
        "paddb      %[ftmp5],       %[ftmp5],         %[Ed]       \n\t"
        "paddb      %[ftmp6],       %[ftmp6],         %[Ed]       \n\t"
        "paddb      %[ftmp7],       %[ftmp7],         %[Ed]       \n\t"
        "swc1       %[ftmp0],       0x00(%[dst])                  \n\t"
        PTR_ADDU   "%[tmp1],        %[dst],           %[stride]   \n\t"
        "swc1       %[ftmp1],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp2],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp3],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp4],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp5],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp6],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp7],       0x00(%[tmp1])                 \n\t"
        PTR_ADDIU  "%[dst],         %[dst],           0x04        \n\t"
        PTR_ADDIU  "%[input],       %[input],         0x40        \n\t"
        PTR_ADDIU  "%[temp_value],  %[temp_value],    0x04        \n\t"
        PTR_ADDIU  "%[tmp0],        %[tmp0],          -0x01       \n\t"
        "bnez       %[tmp0],        1b                            \n\t"
        : [dst]"+&r"(dst), [tmp0]"=&r"(tmp[0]), [tmp1]"=&r"(tmp[1]),
          [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]),
          [ftmp3]"=&f"(ftmp[3]), [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
          [ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), [ftmp8]"=&f"(ftmp[8]),
          [ftmp9]"=&f"(ftmp[9]), [ftmp10]"=&f"(ftmp[10]), [mask]"=&f"(ftmp[11]),
          [A]"=&f"(ftmp[12]), [B]"=&f"(ftmp[13]), [C]"=&f"(ftmp[14]),
          [D]"=&f"(ftmp[15]), [Ad]"=&f"(ftmp[16]), [Bd]"=&f"(ftmp[17]),
          [Cd]"=&f"(ftmp[18]), [Dd]"=&f"(ftmp[19]), [Ed]"=&f"(ftmp[20]),
          [Gd]"=&f"(ftmp[21]), [input]"+&r"(input)
        : [stride]"r"(stride), [temp_value]"r"(temp_value)
        : "memory"
    );
}

static void idct_column_false_mmi(uint8_t *dst, int stride, int16_t *input)
{
    int16_t temp_value[8];
    double ftmp[23];
    uint64_t tmp[2];
    for (int i = 0; i < 8; ++i)
        temp_value[i] = (46341 * input[i << 3] + (8 << 16)) >> 20;
    __asm__ volatile (
        "xor        %[ftmp10],      %[ftmp10],          %[ftmp10] \n\t"
        "li         %[tmp0],        0x02                          \n\t"
        "1:                                                       \n\t"
        "ldc1       %[ftmp0],       0x00(%[input])                \n\t"
        "ldc1       %[ftmp4],       0x08(%[input])                \n\t"
        "ldc1       %[ftmp1],       0x10(%[input])                \n\t"
        "ldc1       %[ftmp5],       0x18(%[input])                \n\t"
        "ldc1       %[ftmp2],       0x20(%[input])                \n\t"
        "ldc1       %[ftmp6],       0x28(%[input])                \n\t"
        "ldc1       %[ftmp3],       0x30(%[input])                \n\t"
        "ldc1       %[ftmp7],       0x38(%[input])                \n\t"
        TRANSPOSE_4H(%[ftmp0], %[ftmp1], %[ftmp2], %[ftmp3],
                     %[A], %[B], %[C], %[D])
        TRANSPOSE_4H(%[ftmp4], %[ftmp5], %[ftmp6], %[ftmp7],
                     %[A], %[B], %[C], %[D])
        LOAD_CONST(%[ftmp8], 64277)
        LOAD_CONST(%[ftmp9], 12785)
        LOAD_CONST(%[Gd], 1)
        "pmulhh     %[A],           %[ftmp9],           %[ftmp7]  \n\t"
        "pcmpgth    %[C],           %[ftmp10],          %[ftmp1]  \n\t"
        "or         %[mask],        %[C],               %[Gd]     \n\t"
        "pmullh     %[B],           %[ftmp1],           %[mask]   \n\t"
        "pmulhuh    %[B],           %[ftmp8],           %[B]      \n\t"
        "pmullh     %[B],           %[B],               %[mask]   \n\t"
        "paddh      %[A],           %[A],               %[B]      \n\t"
        "paddh      %[A],           %[A],               %[C]      \n\t"
        "pcmpgth    %[D],           %[ftmp10],          %[ftmp7]  \n\t"
        "or         %[mask],        %[D],               %[Gd]     \n\t"
        "pmullh     %[Ad],          %[ftmp7],           %[mask]   \n\t"
        "pmulhuh    %[B],           %[ftmp8],           %[Ad]     \n\t"
        "pmullh     %[B],           %[B],               %[mask]   \n\t"
        "pmulhh     %[C],           %[ftmp9],           %[ftmp1]  \n\t"
        "psubh      %[B],           %[C],               %[B]      \n\t"
        "psubh      %[B],           %[B],               %[D]      \n\t"

        LOAD_CONST(%[ftmp8], 54491)
        LOAD_CONST(%[ftmp9], 36410)
        "pcmpgth    %[Ad],          %[ftmp10],          %[ftmp5]  \n\t"
        "or         %[mask],        %[Ad],              %[Gd]     \n\t"
        "pmullh     %[Cd],          %[ftmp5],           %[mask]   \n\t"
        "pmulhuh    %[C],           %[ftmp9],           %[Cd]     \n\t"
        "pmullh     %[C],           %[C],               %[mask]   \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],          %[ftmp3]  \n\t"
        "or         %[mask],        %[Bd],              %[Gd]     \n\t"
        "pmullh     %[D],           %[ftmp3],           %[mask]   \n\t"
        "pmulhuh    %[D],           %[ftmp8],           %[D]      \n\t"
        "pmullh     %[D],           %[D],               %[mask]   \n\t"
        "paddh      %[C],           %[C],               %[D]      \n\t"
        "paddh      %[C],           %[C],               %[Ad]     \n\t"
        "paddh      %[C],           %[C],               %[Bd]     \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],          %[ftmp3]  \n\t"
        "or         %[mask],        %[Bd],              %[Gd]     \n\t"
        "pmullh     %[Cd],          %[ftmp3],           %[mask]   \n\t"
        "pmulhuh    %[D],           %[ftmp9],           %[Cd]     \n\t"
        "pmullh     %[D],           %[D],               %[mask]   \n\t"
        "pcmpgth    %[Ed],          %[ftmp10],          %[ftmp5]  \n\t"
        "or         %[mask],        %[Ed],              %[Gd]     \n\t"
        "pmullh     %[Ad],          %[ftmp5],           %[mask]   \n\t"
        "pmulhuh    %[Ad],          %[ftmp8],           %[Ad]     \n\t"
        "pmullh     %[Ad],          %[Ad],              %[mask]   \n\t"
        "psubh      %[D],           %[Ad],              %[D]      \n\t"
        "paddh      %[D],           %[D],               %[Ed]     \n\t"
        "psubh      %[D],           %[D],               %[Bd]     \n\t"

        LOAD_CONST(%[ftmp8], 46341)
        "psubh      %[Ad],          %[A],             %[C]        \n\t"
        "pcmpgth    %[Bd],          %[ftmp10],        %[Ad]       \n\t"
        "or         %[mask],        %[Bd],            %[Gd]       \n\t"
        "pmullh     %[Ad],          %[Ad],            %[mask]     \n\t"
        "pmulhuh    %[Ad],          %[ftmp8],         %[Ad]       \n\t"
        "pmullh     %[Ad],          %[Ad],            %[mask]     \n\t"
        "paddh      %[Ad],          %[Ad],            %[Bd]       \n\t"
        "psubh      %[Bd],          %[B],             %[D]        \n\t"
        "pcmpgth    %[Cd],          %[ftmp10],        %[Bd]       \n\t"
        "or         %[mask],        %[Cd],            %[Gd]       \n\t"
        "pmullh     %[Bd],          %[Bd],            %[mask]     \n\t"
        "pmulhuh    %[Bd],          %[ftmp8],         %[Bd]       \n\t"
        "pmullh     %[Bd],          %[Bd],            %[mask]     \n\t"
        "paddh      %[Bd],          %[Bd],            %[Cd]       \n\t"
        "paddh      %[Cd],          %[A],             %[C]        \n\t"
        "paddh      %[Dd],          %[B],             %[D]        \n\t"

        LOAD_CONST(%[Ed], 8)
        "paddh      %[A],           %[ftmp0],         %[ftmp4]    \n\t"
        "pcmpgth    %[B],           %[ftmp10],        %[A]        \n\t"
        "or         %[mask],        %[B],             %[Gd]       \n\t"
        "pmullh     %[A],           %[A],             %[mask]     \n\t"
        "pmulhuh    %[A],           %[ftmp8],         %[A]        \n\t"
        "pmullh     %[A],           %[A],             %[mask]     \n\t"
        "paddh      %[A],           %[A],             %[B]        \n\t"
        "paddh      %[A],           %[A],             %[Ed]       \n\t"
        "psubh      %[B],           %[ftmp0],         %[ftmp4]    \n\t"
        "pcmpgth    %[C],           %[ftmp10],        %[B]        \n\t"
        "or         %[mask],        %[C],             %[Gd]       \n\t"
        "pmullh     %[B],           %[B],             %[mask]     \n\t"
        "pmulhuh    %[B],           %[ftmp8],         %[B]        \n\t"
        "pmullh     %[B],           %[B],             %[mask]     \n\t"
        "paddh      %[B],           %[B],             %[C]        \n\t"
        "paddh      %[B],           %[B],             %[Ed]       \n\t"

        LOAD_CONST(%[ftmp8], 60547)
        LOAD_CONST(%[ftmp9], 25080)
        "pmulhh     %[C],           %[ftmp9],         %[ftmp6]    \n\t"
        "pcmpgth    %[D],           %[ftmp10],        %[ftmp2]    \n\t"
        "or         %[mask],        %[D],             %[Gd]       \n\t"
        "pmullh     %[Ed],          %[ftmp2],         %[mask]     \n\t"
        "pmulhuh    %[Ed],          %[ftmp8],         %[Ed]       \n\t"
        "pmullh     %[Ed],          %[Ed],            %[mask]     \n\t"
        "paddh      %[C],           %[C],             %[Ed]       \n\t"
        "paddh      %[C],           %[C],             %[D]        \n\t"
        "pcmpgth    %[Ed],          %[ftmp10],        %[ftmp6]    \n\t"
        "or         %[mask],        %[Ed],            %[Gd]       \n\t"
        "pmullh     %[D],           %[ftmp6],         %[mask]     \n\t"
        "pmulhuh    %[D],           %[ftmp8],         %[D]        \n\t"
        "pmullh     %[D],           %[D],             %[mask]     \n\t"
        "pmulhh     %[Gd],          %[ftmp9],         %[ftmp2]    \n\t"
        "psubh      %[D],           %[Gd],            %[D]        \n\t"
        "psubh      %[D],           %[D],             %[Ed]       \n\t"
        "psubh      %[Ed],          %[A],             %[C]        \n\t"
        "paddh      %[Gd],          %[A],             %[C]        \n\t"
        "paddh      %[A],           %[B],             %[Ad]       \n\t"
        "psubh      %[C],           %[B],             %[Ad]       \n\t"
        "psubh      %[B],           %[Bd],            %[D]        \n\t"
        "paddh      %[D],           %[Bd],            %[D]        \n\t"
        "or         %[mask],        %[ftmp1],         %[ftmp2]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp3]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp4]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp5]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp6]    \n\t"
        "or         %[mask],        %[mask],          %[ftmp7]    \n\t"
        "pcmpeqh    %[mask],        %[mask],          %[ftmp10]   \n\t"
        "li         %[tmp1],        0x04                          \n\t"
        "dmtc1      %[tmp1],        %[ftmp8]                      \n\t"
        "paddh      %[ftmp0],       %[Gd],            %[Cd]       \n\t"
        "psrah      %[ftmp0],       %[ftmp0],         %[ftmp8]    \n\t"
        "paddh      %[ftmp1],       %[A],             %[D]        \n\t"
        "psrah      %[ftmp1],       %[ftmp1],         %[ftmp8]    \n\t"
        "psubh      %[ftmp2],       %[A],             %[D]        \n\t"
        "psrah      %[ftmp2],       %[ftmp2],         %[ftmp8]    \n\t"
        "paddh      %[ftmp3],       %[Ed],            %[Dd]       \n\t"
        "psrah      %[ftmp3],       %[ftmp3],         %[ftmp8]    \n\t"
        "psubh      %[ftmp4],       %[Ed],            %[Dd]       \n\t"
        "psrah      %[ftmp4],       %[ftmp4],         %[ftmp8]    \n\t"
        "paddh      %[ftmp5],       %[C],             %[B]        \n\t"
        "psrah      %[ftmp5],       %[ftmp5],         %[ftmp8]    \n\t"
        "psubh      %[ftmp6],       %[C],             %[B]        \n\t"
        "psrah      %[ftmp6],       %[ftmp6],         %[ftmp8]    \n\t"
        "psubh      %[ftmp7],       %[Gd],            %[Cd]       \n\t"
        "psrah      %[ftmp7],       %[ftmp7],         %[ftmp8]    \n\t"

        /* Load from dst */
        "lwc1       %[A],           0x00(%[dst])                  \n\t"
        PTR_ADDU   "%[tmp1],        %[dst],           %[stride]   \n\t"
        "lwc1       %[B],           0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "lwc1       %[C],           0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "lwc1       %[D],           0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "lwc1       %[Ad],          0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "lwc1       %[Bd],          0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "lwc1       %[Cd],          0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "lwc1       %[Dd],          0x00(%[tmp1])                 \n\t"
        "punpcklbh  %[A],           %[A],             %[ftmp10]   \n\t"
        "punpcklbh  %[B],           %[B],             %[ftmp10]   \n\t"
        "punpcklbh  %[C],           %[C],             %[ftmp10]   \n\t"
        "punpcklbh  %[D],           %[D],             %[ftmp10]   \n\t"
        "punpcklbh  %[Ad],          %[Ad],            %[ftmp10]   \n\t"
        "punpcklbh  %[Bd],          %[Bd],            %[ftmp10]   \n\t"
        "punpcklbh  %[Cd],          %[Cd],            %[ftmp10]   \n\t"
        "punpcklbh  %[Dd],          %[Dd],            %[ftmp10]   \n\t"
        "ldc1       %[Ed],          0x00(%[temp_value])           \n\t"
        "and        %[Ed],          %[Ed],            %[mask]     \n\t"
        "nor        %[mask],        %[mask],          %[mask]     \n\t"
        "and        %[ftmp0],       %[ftmp0],         %[mask]     \n\t"
        "and        %[ftmp1],       %[ftmp1],         %[mask]     \n\t"
        "and        %[ftmp2],       %[ftmp2],         %[mask]     \n\t"
        "and        %[ftmp3],       %[ftmp3],         %[mask]     \n\t"
        "and        %[ftmp4],       %[ftmp4],         %[mask]     \n\t"
        "and        %[ftmp5],       %[ftmp5],         %[mask]     \n\t"
        "and        %[ftmp6],       %[ftmp6],         %[mask]     \n\t"
        "and        %[ftmp7],       %[ftmp7],         %[mask]     \n\t"
        "paddh      %[ftmp0],       %[ftmp0],         %[A]        \n\t"
        "paddh      %[ftmp1],       %[ftmp1],         %[B]        \n\t"
        "paddh      %[ftmp2],       %[ftmp2],         %[C]        \n\t"
        "paddh      %[ftmp3],       %[ftmp3],         %[D]        \n\t"
        "paddh      %[ftmp4],       %[ftmp4],         %[Ad]       \n\t"
        "paddh      %[ftmp5],       %[ftmp5],         %[Bd]       \n\t"
        "paddh      %[ftmp6],       %[ftmp6],         %[Cd]       \n\t"
        "paddh      %[ftmp7],       %[ftmp7],         %[Dd]       \n\t"
        "paddh      %[ftmp0],       %[ftmp0],         %[Ed]       \n\t"
        "paddh      %[ftmp1],       %[ftmp1],         %[Ed]       \n\t"
        "paddh      %[ftmp2],       %[ftmp2],         %[Ed]       \n\t"
        "paddh      %[ftmp3],       %[ftmp3],         %[Ed]       \n\t"
        "paddh      %[ftmp4],       %[ftmp4],         %[Ed]       \n\t"
        "paddh      %[ftmp5],       %[ftmp5],         %[Ed]       \n\t"
        "paddh      %[ftmp6],       %[ftmp6],         %[Ed]       \n\t"
        "paddh      %[ftmp7],       %[ftmp7],         %[Ed]       \n\t"
        "pmaxsh     %[ftmp0],       %[ftmp0],         %[ftmp10]   \n\t"
        "packushb   %[ftmp0],       %[ftmp0],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp1],       %[ftmp1],         %[ftmp10]   \n\t"
        "packushb   %[ftmp1],       %[ftmp1],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp2],       %[ftmp2],         %[ftmp10]   \n\t"
        "packushb   %[ftmp2],       %[ftmp2],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp3],       %[ftmp3],         %[ftmp10]   \n\t"
        "packushb   %[ftmp3],       %[ftmp3],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp4],       %[ftmp4],         %[ftmp10]   \n\t"
        "packushb   %[ftmp4],       %[ftmp4],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp5],       %[ftmp5],         %[ftmp10]   \n\t"
        "packushb   %[ftmp5],       %[ftmp5],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp6],       %[ftmp6],         %[ftmp10]   \n\t"
        "packushb   %[ftmp6],       %[ftmp6],         %[ftmp10]   \n\t"
        "pmaxsh     %[ftmp7],       %[ftmp7],         %[ftmp10]   \n\t"
        "packushb   %[ftmp7],       %[ftmp7],         %[ftmp10]   \n\t"
        "swc1       %[ftmp0],       0x00(%[dst])                  \n\t"
        PTR_ADDU   "%[tmp1],        %[dst],           %[stride]   \n\t"
        "swc1       %[ftmp1],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp2],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp3],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp4],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp5],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp6],       0x00(%[tmp1])                 \n\t"
        PTR_ADDU   "%[tmp1],        %[tmp1],          %[stride]   \n\t"
        "swc1       %[ftmp7],       0x00(%[tmp1])                 \n\t"
        PTR_ADDIU  "%[dst],         %[dst],           0x04        \n\t"
        PTR_ADDIU  "%[input],       %[input],         0x40        \n\t"
        PTR_ADDIU  "%[temp_value],  %[temp_value],    0x08        \n\t"
        PTR_ADDIU  "%[tmp0],        %[tmp0],          -0x01       \n\t"
        "bnez       %[tmp0],        1b                            \n\t"
        : [dst]"+&r"(dst), [tmp0]"=&r"(tmp[0]), [tmp1]"=&r"(tmp[1]),
          [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]),
          [ftmp3]"=&f"(ftmp[3]), [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
          [ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), [ftmp8]"=&f"(ftmp[8]),
          [ftmp9]"=&f"(ftmp[9]), [ftmp10]"=&f"(ftmp[10]), [mask]"=&f"(ftmp[11]),
          [A]"=&f"(ftmp[12]), [B]"=&f"(ftmp[13]), [C]"=&f"(ftmp[14]),
          [D]"=&f"(ftmp[15]), [Ad]"=&f"(ftmp[16]), [Bd]"=&f"(ftmp[17]),
          [Cd]"=&f"(ftmp[18]), [Dd]"=&f"(ftmp[19]), [Ed]"=&f"(ftmp[20]),
          [Gd]"=&f"(ftmp[21]), [input]"+&r"(input)
        : [stride]"r"(stride), [temp_value]"r"(temp_value)
        : "memory"
    );
}
static void idct_mmi(uint8_t *dst, int stride, int16_t *input, int type)
{
    idct_row_mmi(input);
    if (type == 1)
        idct_column_true_mmi(dst, stride, input);
    else
        idct_column_false_mmi(dst, stride, input);
}

void ff_vp3_idct_put_mmi(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
{
    idct_mmi(dest, line_size, block, 1);
    memset(block, 0, sizeof(*block) << 6);
}

void ff_vp3_idct_add_mmi(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
{
    idct_mmi(dest, line_size, block, 2);
    memset(block, 0, sizeof(*block) << 6);
}
void ff_vp3_idct_dc_add_mmi(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
{
    int dc = (block[0] + 15) >> 5;

    double ftmp[7];
    uint64_t tmp;
    __asm__ volatile (
        "xor        %[ftmp0],     %[ftmp0],           %[ftmp0]      \n\t"
        "mtc1       %[dc],        %[ftmp5]                          \n\t"
        "pshufh     %[ftmp5],     %[ftmp5],           %[ftmp0]      \n\t"
        "li         %[tmp0],      0x08                              \n\t"
        "1:                                                         \n\t"
        "ldc1       %[ftmp1],     0x00(%[dest])                     \n\t"
        "punpcklbh  %[ftmp2],     %[ftmp1],           %[ftmp0]      \n\t"
        "punpckhbh  %[ftmp3],     %[ftmp1],           %[ftmp0]      \n\t"
        "paddh      %[ftmp4],     %[ftmp2],           %[ftmp5]      \n\t"
        "paddh      %[ftmp6],     %[ftmp3],           %[ftmp5]      \n\t"
        "packushb   %[ftmp4],     %[ftmp4],           %[ftmp0]      \n\t"
        "packushb   %[ftmp6],     %[ftmp6],           %[ftmp0]      \n\t"
        "swc1       %[ftmp4],     0x00(%[dest])                     \n\t"
        "swc1       %[ftmp6],     0x04(%[dest])                     \n\t"
        PTR_ADDU   "%[dest],      %[dest],            %[line_size]  \n\t"
        PTR_ADDIU  "%[tmp0],      %[tmp0],            -0x01         \n\t"
        "bnez       %[tmp0],      1b                                \n\t"
        : [dest]"+&r"(dest), [block]"+&r"(block), [tmp0]"=&r"(tmp),
          [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]),
          [ftmp3]"=&f"(ftmp[3]), [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
          [ftmp6]"=&f"(ftmp[6])
        : [line_size]"r"(line_size), [dc]"r"(dc)
        : "memory"
    );
    block[0] = 0;
}

void ff_put_no_rnd_pixels_l2_mmi(uint8_t *dst, const uint8_t *src1,
                                 const uint8_t *src2, ptrdiff_t stride, int h)
{
    if (h == 8) {
        double ftmp[6];
        uint64_t tmp[2];
        __asm__ volatile (
            "li          %[tmp0],        0x08                            \n\t"
            "li          %[tmp1],        0xfefefefe                      \n\t"
            "dmtc1       %[tmp1],        %[ftmp4]                        \n\t"
            "punpcklwd   %[ftmp4],       %[ftmp4],             %[ftmp4]  \n\t"
            "li          %[tmp1],        0x01                            \n\t"
            "dmtc1       %[tmp1],        %[ftmp5]                        \n\t"
            "1:                                                          \n\t"
            "gsldlc1     %[ftmp1],       0x07(%[src1])                   \n\t"
            "gsldrc1     %[ftmp1],       0x00(%[src1])                   \n\t"
            "gsldlc1     %[ftmp2],       0x07(%[src2])                   \n\t"
            "gsldrc1     %[ftmp2],       0x00(%[src2])                   \n\t"
            "xor         %[ftmp3],       %[ftmp1],             %[ftmp2]  \n\t"
            "and         %[ftmp3],       %[ftmp3],             %[ftmp4]  \n\t"
            "psrlw       %[ftmp3],       %[ftmp3],             %[ftmp5]  \n\t"
            "and         %[ftmp6],       %[ftmp1],             %[ftmp2]  \n\t"
            "paddw       %[ftmp3],       %[ftmp3],             %[ftmp6]  \n\t"
            "sdc1        %[ftmp3],       0x00(%[dst])                    \n\t"
            PTR_ADDU    "%[src1],        %[src1],              %[stride] \n\t"
            PTR_ADDU    "%[src2],        %[src2],              %[stride] \n\t"
            PTR_ADDU    "%[dst],         %[dst],               %[stride] \n\t"
            PTR_ADDIU   "%[tmp0],        %[tmp0],              -0x01     \n\t"
            "bnez        %[tmp0],        1b                              \n\t"
            : [dst]"+&r"(dst), [src1]"+&r"(src1), [src2]"+&r"(src2),
              [ftmp1]"=&f"(ftmp[0]), [ftmp2]"=&f"(ftmp[1]), [ftmp3]"=&f"(ftmp[2]),
              [ftmp4]"=&f"(ftmp[3]), [ftmp5]"=&f"(ftmp[4]), [ftmp6]"=&f"(ftmp[5]),
              [tmp0]"=&r"(tmp[0]), [tmp1]"=&r"(tmp[1])
            : [stride]"r"(stride)
            : "memory"
        );
    } else {
        int i;

        for (i = 0; i < h; i++) {
            uint32_t a, b;

            a = AV_RN32(&src1[i * stride]);
            b = AV_RN32(&src2[i * stride]);
            AV_WN32A(&dst[i * stride], no_rnd_avg32(a, b));
            a = AV_RN32(&src1[i * stride + 4]);
            b = AV_RN32(&src2[i * stride + 4]);
            AV_WN32A(&dst[i * stride + 4], no_rnd_avg32(a, b));
        }
    }
}
OpenPOWER on IntegriCloud