2
* MMI optimized DSP utils
3
* Copyright (c) 2000, 2001 Fabrice Bellard
5
* MMI optimization by Leon van Stuivenberg
6
* clear_blocks_mmi() by BroadQ
8
* This file is part of Libav.
10
* Libav is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public
12
* License as published by the Free Software Foundation; either
13
* version 2.1 of the License, or (at your option) any later version.
15
* Libav is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
* Lesser General Public License for more details.
20
* You should have received a copy of the GNU Lesser General Public
21
* License along with Libav; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
#include "libavcodec/dsputil.h"
28
void ff_mmi_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
29
void ff_mmi_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
30
void ff_mmi_idct(DCTELEM *block);
32
static void clear_blocks_mmi(DCTELEM * blocks)
36
"addiu $9, %0, 768 \n"
48
: "+r" (blocks) :: "$8", "$9", "memory" );
52
static void get_pixels_mmi(DCTELEM *block, const uint8_t *pixels, int line_size)
62
"pextlb $8, $0, $8 \n\t"
66
"pextlb $9, $0, $9 \n\t"
70
"pextlb $10, $0, $10 \n\t"
74
"pextlb $8, $0, $8 \n\t"
78
"pextlb $9, $0, $9 \n\t"
82
"pextlb $10, $0, $10 \n\t"
84
"pextlb $8, $0, $8 \n\t"
86
"pextlb $9, $0, $9 \n\t"
89
: "+r" (pixels) : "r" (block), "r" (line_size) : "$8", "$9", "$10", "memory" );
93
static void put_pixels8_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
100
"addiu %2, %2, -1 \n\t"
102
"add %1, %1, %3 \n\t"
104
"add %0, %0, %3 \n\t"
107
: "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
112
static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
119
"add $11, %1, %3 \n\t"
121
"add $10, %0, %3 \n\t"
123
"ldl $9, 15(%1) \n\t"
124
"ldr $12, 0($11) \n\t"
125
"add %1, $11, %3 \n\t"
126
"ldl $12, 7($11) \n\t"
127
"pcpyld $8, $9, $8 \n\t"
129
"ldr $13, 8($11) \n\t"
130
"addiu %2, %2, -2 \n\t"
131
"ldl $13, 15($11) \n\t"
132
"add %0, $10, %3 \n\t"
133
"pcpyld $12, $13, $12 \n\t"
134
"sq $12, 0($10) \n\t"
137
: "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
138
: "$8", "$9", "$10", "$11", "$12", "$13", "memory" );
142
void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
144
const int idct_algo= avctx->idct_algo;
145
const int high_bit_depth = avctx->bits_per_raw_sample > 8;
147
if (!high_bit_depth) {
148
c->clear_blocks = clear_blocks_mmi;
150
c->put_pixels_tab[1][0] = put_pixels8_mmi;
151
c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;
153
c->put_pixels_tab[0][0] = put_pixels16_mmi;
154
c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
156
c->get_pixels = get_pixels_mmi;
159
if (avctx->bits_per_raw_sample <= 8 &&
160
(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2)) {
161
c->idct_put= ff_mmi_idct_put;
162
c->idct_add= ff_mmi_idct_add;
163
c->idct = ff_mmi_idct;
164
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;