2 * ARMv4L optimized DSP utils
3 * Copyright (c) 2001 Lionel Ulmer.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "../dsputil.h"
25 extern void dsputil_init_iwmmxt(DSPContext
* c
, AVCodecContext
*avctx
);
27 extern void j_rev_dct_ARM(DCTELEM
*data
);
28 extern void simple_idct_ARM(DCTELEM
*data
);
31 static void (*ff_put_pixels_clamped
)(const DCTELEM
*block
, uint8_t *pixels
, int line_size
);
32 static void (*ff_add_pixels_clamped
)(const DCTELEM
*block
, uint8_t *pixels
, int line_size
);
34 void put_pixels8_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
35 void put_pixels8_x2_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
36 void put_pixels8_y2_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
37 void put_pixels8_xy2_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
39 void put_no_rnd_pixels8_x2_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
40 void put_no_rnd_pixels8_y2_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
41 void put_no_rnd_pixels8_xy2_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
43 void put_pixels16_arm(uint8_t *block
, const uint8_t *pixels
, int line_size
, int h
);
45 CALL_2X_PIXELS(put_pixels16_x2_arm
, put_pixels8_x2_arm
, 8)
46 CALL_2X_PIXELS(put_pixels16_y2_arm
, put_pixels8_y2_arm
, 8)
47 CALL_2X_PIXELS(put_pixels16_xy2_arm
, put_pixels8_xy2_arm
, 8)
48 CALL_2X_PIXELS(put_no_rnd_pixels16_x2_arm
, put_no_rnd_pixels8_x2_arm
, 8)
49 CALL_2X_PIXELS(put_no_rnd_pixels16_y2_arm
, put_no_rnd_pixels8_y2_arm
, 8)
50 CALL_2X_PIXELS(put_no_rnd_pixels16_xy2_arm
, put_no_rnd_pixels8_xy2_arm
, 8)
52 static void add_pixels_clamped_ARM(short *block
, unsigned char *dest
, int line_size
)
61 /* block[0] and block[1]*/
63 "ldrsh r7, [%0, #2] \n\t"
64 "and r6, r4, #0xFF \n\t"
65 "and r8, r4, #0xFF00 \n\t"
67 "add r8, r7, r8, lsr #8 \n\t"
71 "movne r6, r5, lsr #24 \n\t"
73 "movne r8, r7, lsr #24 \n\t"
75 "ldrsh r5, [%0, #4] \n\t" /* moved form [A] */
76 "orr r9, r9, r8, lsl #8 \n\t"
77 /* block[2] and block[3] */
79 "ldrsh r7, [%0, #6] \n\t"
80 "and r6, r4, #0xFF0000 \n\t"
81 "and r8, r4, #0xFF000000 \n\t"
82 "add r6, r5, r6, lsr #16 \n\t"
83 "add r8, r7, r8, lsr #24 \n\t"
87 "movne r6, r5, lsr #24 \n\t"
89 "movne r8, r7, lsr #24 \n\t"
90 "orr r9, r9, r6, lsl #16 \n\t"
91 "ldr r4, [%1, #4] \n\t" /* moved form [B] */
92 "orr r9, r9, r8, lsl #24 \n\t"
94 "ldrsh r5, [%0, #8] \n\t" /* moved form [C] */
99 /* block[4] and block[5] */
101 "ldrsh r7, [%0, #10] \n\t"
102 "and r6, r4, #0xFF \n\t"
103 "and r8, r4, #0xFF00 \n\t"
104 "add r6, r5, r6 \n\t"
105 "add r8, r7, r8, lsr #8 \n\t"
108 "tst r6, #0x100 \n\t"
109 "movne r6, r5, lsr #24 \n\t"
110 "tst r8, #0x100 \n\t"
111 "movne r8, r7, lsr #24 \n\t"
113 "ldrsh r5, [%0, #12] \n\t" /* moved from [D] */
114 "orr r9, r9, r8, lsl #8 \n\t"
115 /* block[6] and block[7] */
117 "ldrsh r7, [%0, #14] \n\t"
118 "and r6, r4, #0xFF0000 \n\t"
119 "and r8, r4, #0xFF000000 \n\t"
120 "add r6, r5, r6, lsr #16 \n\t"
121 "add r8, r7, r8, lsr #24 \n\t"
124 "tst r6, #0x100 \n\t"
125 "movne r6, r5, lsr #24 \n\t"
126 "tst r8, #0x100 \n\t"
127 "movne r8, r7, lsr #24 \n\t"
128 "orr r9, r9, r6, lsl #16 \n\t"
129 "add %0, %0, #16 \n\t" /* moved from [E] */
130 "orr r9, r9, r8, lsl #24 \n\t"
131 "subs r10, r10, #1 \n\t" /* moved from [F] */
133 "str r9, [%1, #4] \n\t"
137 "add %1, %1, %2 \n\t"
142 : "r4", "r5", "r6", "r7", "r8", "r9", "r10", "cc", "memory" );
145 /* XXX: those functions should be suppressed ASAP when all IDCTs are
147 static void j_rev_dct_ARM_put(uint8_t *dest
, int line_size
, DCTELEM
*block
)
149 j_rev_dct_ARM (block
);
150 ff_put_pixels_clamped(block
, dest
, line_size
);
152 static void j_rev_dct_ARM_add(uint8_t *dest
, int line_size
, DCTELEM
*block
)
154 j_rev_dct_ARM (block
);
155 ff_add_pixels_clamped(block
, dest
, line_size
);
157 static void simple_idct_ARM_put(uint8_t *dest
, int line_size
, DCTELEM
*block
)
159 simple_idct_ARM (block
);
160 ff_put_pixels_clamped(block
, dest
, line_size
);
162 static void simple_idct_ARM_add(uint8_t *dest
, int line_size
, DCTELEM
*block
)
164 simple_idct_ARM (block
);
165 ff_add_pixels_clamped(block
, dest
, line_size
);
167 static void simple_idct_ipp(DCTELEM
*block
)
170 ippiDCT8x8Inv_Video_16s_C1I(block
);
173 static void simple_idct_ipp_put(uint8_t *dest
, int line_size
, DCTELEM
*block
)
176 ippiDCT8x8Inv_Video_16s8u_C1R(block
, dest
, line_size
);
180 void add_pixels_clamped_iwmmxt(const DCTELEM
*block
, uint8_t *pixels
, int line_size
);
182 static void simple_idct_ipp_add(uint8_t *dest
, int line_size
, DCTELEM
*block
)
185 ippiDCT8x8Inv_Video_16s_C1I(block
);
187 add_pixels_clamped_iwmmxt(block
, dest
, line_size
);
189 add_pixels_clamped_ARM(block
, dest
, line_size
);
194 void dsputil_init_armv4l(DSPContext
* c
, AVCodecContext
*avctx
)
196 const int idct_algo
= avctx
->idct_algo
;
198 ff_put_pixels_clamped
= c
->put_pixels_clamped
;
199 ff_add_pixels_clamped
= c
->add_pixels_clamped
;
202 if(idct_algo
==FF_IDCT_ARM
){
204 if(idct_algo
==FF_IDCT_AUTO
|| idct_algo
==FF_IDCT_ARM
){
206 c
->idct_put
= j_rev_dct_ARM_put
;
207 c
->idct_add
= j_rev_dct_ARM_add
;
208 c
->idct
= j_rev_dct_ARM
;
209 c
->idct_permutation_type
= FF_LIBMPEG2_IDCT_PERM
;/* FF_NO_IDCT_PERM */
210 } else if (idct_algo
==FF_IDCT_SIMPLEARM
){
211 c
->idct_put
= simple_idct_ARM_put
;
212 c
->idct_add
= simple_idct_ARM_add
;
213 c
->idct
= simple_idct_ARM
;
214 c
->idct_permutation_type
= FF_NO_IDCT_PERM
;
216 } else if (idct_algo
==FF_IDCT_AUTO
|| idct_algo
==FF_IDCT_IPP
){
218 } else if (idct_algo
==FF_IDCT_IPP
){
220 c
->idct_put
= simple_idct_ipp_put
;
221 c
->idct_add
= simple_idct_ipp_add
;
222 c
->idct
= simple_idct_ipp
;
223 c
->idct_permutation_type
= FF_NO_IDCT_PERM
;
226 /* c->put_pixels_tab[0][0] = put_pixels16_arm; */ // NG!
227 c
->put_pixels_tab
[0][1] = put_pixels16_x2_arm
; //OK!
228 c
->put_pixels_tab
[0][2] = put_pixels16_y2_arm
; //OK!
229 /* c->put_pixels_tab[0][3] = put_pixels16_xy2_arm; /\* NG *\/ */
230 /* c->put_no_rnd_pixels_tab[0][0] = put_pixels16_arm; // ?(»È¤ï¤ì¤Ê¤¤) */
231 c
->put_no_rnd_pixels_tab
[0][1] = put_no_rnd_pixels16_x2_arm
; // OK
232 c
->put_no_rnd_pixels_tab
[0][2] = put_no_rnd_pixels16_y2_arm
; //OK
233 /* c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_arm; //NG */
234 c
->put_pixels_tab
[1][0] = put_pixels8_arm
; //OK
235 c
->put_pixels_tab
[1][1] = put_pixels8_x2_arm
; //OK
236 /* c->put_pixels_tab[1][2] = put_pixels8_y2_arm; //NG */
237 /* c->put_pixels_tab[1][3] = put_pixels8_xy2_arm; //NG */
238 c
->put_no_rnd_pixels_tab
[1][0] = put_pixels8_arm
;//OK
239 c
->put_no_rnd_pixels_tab
[1][1] = put_no_rnd_pixels8_x2_arm
; //OK
240 c
->put_no_rnd_pixels_tab
[1][2] = put_no_rnd_pixels8_y2_arm
; //OK
241 /* c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_arm;//NG */
244 dsputil_init_iwmmxt(c
, avctx
);