comparison armv4l/mpegvideo_armv5te.c @ 8197:06acc3ab4bdc libavcodec

ARM: move dct_unquantize_h263_*_armv5te asm to separate file
author mru
date Sun, 23 Nov 2008 19:11:44 +0000
parents eebc7209c47f
children cf4d575b1982
comparison
equal deleted inserted replaced
8196:2717c68de07f 8197:06acc3ab4bdc
21 21
22 #include "libavcodec/avcodec.h" 22 #include "libavcodec/avcodec.h"
23 #include "libavcodec/dsputil.h" 23 #include "libavcodec/dsputil.h"
24 #include "libavcodec/mpegvideo.h" 24 #include "libavcodec/mpegvideo.h"
25 25
26 extern void ff_dct_unquantize_h263_armv5te(DCTELEM *block, int qmul, int qadd,
27 int count);
26 28
27 #ifdef ENABLE_ARM_TESTS 29 #ifdef ENABLE_ARM_TESTS
28 /** 30 /**
29 * h263 dequantizer supplementary function, it is performance critical and needs to 31 * h263 dequantizer supplementary function, it is performance critical and needs to
30 * have optimized implementations for each architecture. Is also used as a reference 32 * have optimized implementations for each architecture. Is also used as a reference
44 block[i] = level; 46 block[i] = level;
45 } 47 }
46 } 48 }
47 } 49 }
48 #endif 50 #endif
49
50 /* GCC 3.1 or higher is required to support symbolic names in assembly code */
51 #if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
52
53 /**
54 * Special optimized version of dct_unquantize_h263_helper_c, it requires the block
55 * to be at least 8 bytes aligned, and may process more elements than requested.
56 * But it is guaranteed to never process more than 64 elements provided that
57 * xxcount argument is <= 64, so it is safe. This macro is optimized for a common
58 * distribution of values for nCoeffs (they are mostly multiple of 8 plus one or
59 * two extra elements). So this macro processes data as 8 elements per loop iteration
60 * and contains optional 2 elements processing in the end.
61 *
62 * Inner loop should take 6 cycles per element on arm926ej-s (Nokia 770)
63 */
64 #define dct_unquantize_h263_special_helper_armv5te(xxblock, xxqmul, xxqadd, xxcount) \
65 ({ DCTELEM *xblock = xxblock; \
66 int xqmul = xxqmul, xqadd = xxqadd, xcount = xxcount, xtmp; \
67 int xdata1, xdata2; \
68 __asm__ volatile( \
69 "subs %[count], %[count], #2 \n\t" \
70 "ble 2f \n\t" \
71 "ldrd r4, [%[block], #0] \n\t" \
72 "1: \n\t" \
73 "ldrd r6, [%[block], #8] \n\t" \
74 \
75 "rsbs %[data1], %[zero], r4, asr #16 \n\t" \
76 "addgt %[data1], %[qadd], #0 \n\t" \
77 "rsblt %[data1], %[qadd], #0 \n\t" \
78 "smlatbne %[data1], r4, %[qmul], %[data1] \n\t" \
79 \
80 "rsbs %[data2], %[zero], r5, asr #16 \n\t" \
81 "addgt %[data2], %[qadd], #0 \n\t" \
82 "rsblt %[data2], %[qadd], #0 \n\t" \
83 "smlatbne %[data2], r5, %[qmul], %[data2] \n\t" \
84 \
85 "rsbs %[tmp], %[zero], r4, asl #16 \n\t" \
86 "addgt %[tmp], %[qadd], #0 \n\t" \
87 "rsblt %[tmp], %[qadd], #0 \n\t" \
88 "smlabbne r4, r4, %[qmul], %[tmp] \n\t" \
89 \
90 "rsbs %[tmp], %[zero], r5, asl #16 \n\t" \
91 "addgt %[tmp], %[qadd], #0 \n\t" \
92 "rsblt %[tmp], %[qadd], #0 \n\t" \
93 "smlabbne r5, r5, %[qmul], %[tmp] \n\t" \
94 \
95 "strh r4, [%[block]], #2 \n\t" \
96 "strh %[data1], [%[block]], #2 \n\t" \
97 "strh r5, [%[block]], #2 \n\t" \
98 "strh %[data2], [%[block]], #2 \n\t" \
99 \
100 "rsbs %[data1], %[zero], r6, asr #16 \n\t" \
101 "addgt %[data1], %[qadd], #0 \n\t" \
102 "rsblt %[data1], %[qadd], #0 \n\t" \
103 "smlatbne %[data1], r6, %[qmul], %[data1] \n\t" \
104 \
105 "rsbs %[data2], %[zero], r7, asr #16 \n\t" \
106 "addgt %[data2], %[qadd], #0 \n\t" \
107 "rsblt %[data2], %[qadd], #0 \n\t" \
108 "smlatbne %[data2], r7, %[qmul], %[data2] \n\t" \
109 \
110 "rsbs %[tmp], %[zero], r6, asl #16 \n\t" \
111 "addgt %[tmp], %[qadd], #0 \n\t" \
112 "rsblt %[tmp], %[qadd], #0 \n\t" \
113 "smlabbne r6, r6, %[qmul], %[tmp] \n\t" \
114 \
115 "rsbs %[tmp], %[zero], r7, asl #16 \n\t" \
116 "addgt %[tmp], %[qadd], #0 \n\t" \
117 "rsblt %[tmp], %[qadd], #0 \n\t" \
118 "smlabbne r7, r7, %[qmul], %[tmp] \n\t" \
119 \
120 "strh r6, [%[block]], #2 \n\t" \
121 "strh %[data1], [%[block]], #2 \n\t" \
122 "strh r7, [%[block]], #2 \n\t" \
123 "strh %[data2], [%[block]], #2 \n\t" \
124 \
125 "subs %[count], %[count], #8 \n\t" \
126 "ldrgtd r4, [%[block], #0] \n\t" /* load data early to avoid load/use pipeline stall */ \
127 "bgt 1b \n\t" \
128 \
129 "adds %[count], %[count], #2 \n\t" \
130 "ble 3f \n\t" \
131 "2: \n\t" \
132 "ldrsh %[data1], [%[block], #0] \n\t" \
133 "ldrsh %[data2], [%[block], #2] \n\t" \
134 "mov %[tmp], %[qadd] \n\t" \
135 "cmp %[data1], #0 \n\t" \
136 "rsblt %[tmp], %[qadd], #0 \n\t" \
137 "smlabbne %[data1], %[data1], %[qmul], %[tmp] \n\t" \
138 "mov %[tmp], %[qadd] \n\t" \
139 "cmp %[data2], #0 \n\t" \
140 "rsblt %[tmp], %[qadd], #0 \n\t" \
141 "smlabbne %[data2], %[data2], %[qmul], %[tmp] \n\t" \
142 "strh %[data1], [%[block]], #2 \n\t" \
143 "strh %[data2], [%[block]], #2 \n\t" \
144 "3: \n\t" \
145 : [block] "+&r" (xblock), [count] "+&r" (xcount), [tmp] "=&r" (xtmp), \
146 [data1] "=&r" (xdata1), [data2] "=&r" (xdata2) \
147 : [qmul] "r" (xqmul), [qadd] "r" (xqadd), [zero] "r" (0) \
148 : "r4", "r5", "r6", "r7", "cc", "memory" \
149 ); \
150 })
151 51
152 static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s, 52 static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s,
153 DCTELEM *block, int n, int qscale) 53 DCTELEM *block, int n, int qscale)
154 { 54 {
155 int level, qmul, qadd; 55 int level, qmul, qadd;
172 if(s->ac_pred) 72 if(s->ac_pred)
173 nCoeffs=63; 73 nCoeffs=63;
174 else 74 else
175 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; 75 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
176 76
177 dct_unquantize_h263_special_helper_armv5te(block, qmul, qadd, nCoeffs + 1); 77 ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
178 block[0] = level; 78 block[0] = level;
179 } 79 }
180 80
181 static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s, 81 static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s,
182 DCTELEM *block, int n, int qscale) 82 DCTELEM *block, int n, int qscale)
189 qadd = (qscale - 1) | 1; 89 qadd = (qscale - 1) | 1;
190 qmul = qscale << 1; 90 qmul = qscale << 1;
191 91
192 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; 92 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
193 93
194 dct_unquantize_h263_special_helper_armv5te(block, qmul, qadd, nCoeffs + 1); 94 ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
195 } 95 }
196
197 #define HAVE_DCT_UNQUANTIZE_H263_ARMV5TE_OPTIMIZED
198
199 #endif
200 96
201 void MPV_common_init_armv5te(MpegEncContext *s) 97 void MPV_common_init_armv5te(MpegEncContext *s)
202 { 98 {
203 #ifdef HAVE_DCT_UNQUANTIZE_H263_ARMV5TE_OPTIMIZED
204 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_armv5te; 99 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_armv5te;
205 s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_armv5te; 100 s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_armv5te;
206 #endif
207 } 101 }