Revision 9abd87bb libavcodec/h264idct_internal.h

View differences:

libavcodec/h264idct_internal.h
42 42
};
43 43
#endif
44 44

  
45
static av_always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){
45
#define pixel  uint8_t
46
#define dctcoef DCTELEM
47
#define INIT_CLIP uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
48
#define CLIP(a) cm[a]
49
#define FUNCC(a) a ## _c
50

  
51
static av_always_inline void FUNCC(idct_internal)(uint8_t *p_dst, DCTELEM *p_block, int stride, int block_stride, int shift, int add){
46 52
    int i;
47
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
53
    INIT_CLIP
54
    pixel *dst = (pixel*)p_dst;
55
    dctcoef *block = (dctcoef*)p_block;
56
    stride >>= sizeof(pixel)-1;
48 57

  
49 58
    block[0] += 1<<(shift-1);
50 59

  
......
66 75
        const int z2= (block[1 + block_stride*i]>>1) -  block[3 + block_stride*i];
67 76
        const int z3=  block[1 + block_stride*i]     + (block[3 + block_stride*i]>>1);
68 77

  
69
        dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ];
70
        dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ];
71
        dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ];
72
        dst[i + 3*stride]= cm[ add*dst[i + 3*stride] + ((z0 - z3) >> shift) ];
78
        dst[i + 0*stride]= CLIP(add*dst[i + 0*stride] + ((z0 + z3) >> shift));
79
        dst[i + 1*stride]= CLIP(add*dst[i + 1*stride] + ((z1 + z2) >> shift));
80
        dst[i + 2*stride]= CLIP(add*dst[i + 2*stride] + ((z1 - z2) >> shift));
81
        dst[i + 3*stride]= CLIP(add*dst[i + 3*stride] + ((z0 - z3) >> shift));
73 82
    }
74 83
}
75 84

  
76
void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride){
77
    idct_internal(dst, block, stride, 4, 6, 1);
85
void FUNCC(ff_h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride){
86
    FUNCC(idct_internal)(dst, block, stride, 4, 6, 1);
78 87
}
79 88

  
80
void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block){
81
    idct_internal(dst, block, stride, 8, 3, 1);
89
void FUNCC(ff_h264_lowres_idct_add)(uint8_t *dst, int stride, DCTELEM *block){
90
    FUNCC(idct_internal)(dst, block, stride, 8, 3, 1);
82 91
}
83 92

  
84
void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block){
85
    idct_internal(dst, block, stride, 8, 3, 0);
93
void FUNCC(ff_h264_lowres_idct_put)(uint8_t *dst, int stride, DCTELEM *block){
94
    FUNCC(idct_internal)(dst, block, stride, 8, 3, 0);
86 95
}
87 96

  
88
void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride){
97
void FUNCC(ff_h264_idct8_add)(uint8_t *p_dst, DCTELEM *p_block, int stride){
89 98
    int i;
90
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
99
    INIT_CLIP
100
    pixel *dst = (pixel*)p_dst;
101
    dctcoef *block = (dctcoef*)p_block;
102
    stride >>= sizeof(pixel)-1;
91 103

  
92 104
    block[0] += 32;
93 105

  
......
144 156
        const int b5 = (a3>>2) - a5;
145 157
        const int b7 =  a7 - (a1>>2);
146 158

  
147
        dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b7) >> 6) ];
148
        dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b2 + b5) >> 6) ];
149
        dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b4 + b3) >> 6) ];
150
        dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b6 + b1) >> 6) ];
151
        dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b6 - b1) >> 6) ];
152
        dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b4 - b3) >> 6) ];
153
        dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b2 - b5) >> 6) ];
154
        dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b7) >> 6) ];
159
        dst[i + 0*stride] = CLIP( dst[i + 0*stride] + ((b0 + b7) >> 6) );
160
        dst[i + 1*stride] = CLIP( dst[i + 1*stride] + ((b2 + b5) >> 6) );
161
        dst[i + 2*stride] = CLIP( dst[i + 2*stride] + ((b4 + b3) >> 6) );
162
        dst[i + 3*stride] = CLIP( dst[i + 3*stride] + ((b6 + b1) >> 6) );
163
        dst[i + 4*stride] = CLIP( dst[i + 4*stride] + ((b6 - b1) >> 6) );
164
        dst[i + 5*stride] = CLIP( dst[i + 5*stride] + ((b4 - b3) >> 6) );
165
        dst[i + 6*stride] = CLIP( dst[i + 6*stride] + ((b2 - b5) >> 6) );
166
        dst[i + 7*stride] = CLIP( dst[i + 7*stride] + ((b0 - b7) >> 6) );
155 167
    }
156 168
}
157 169

  
158 170
// assumes all AC coefs are 0
159
void ff_h264_idct_dc_add_c(uint8_t *dst, DCTELEM *block, int stride){
171
void FUNCC(ff_h264_idct_dc_add)(uint8_t *p_dst, DCTELEM *block, int stride){
160 172
    int i, j;
161
    int dc = (block[0] + 32) >> 6;
162
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc;
173
    int dc = (((dctcoef*)block)[0] + 32) >> 6;
174
    INIT_CLIP
175
    pixel *dst = (pixel*)p_dst;
176
    stride >>= sizeof(pixel)-1;
163 177
    for( j = 0; j < 4; j++ )
164 178
    {
165 179
        for( i = 0; i < 4; i++ )
166
            dst[i] = cm[ dst[i] ];
180
            dst[i] = CLIP( dst[i] + dc );
167 181
        dst += stride;
168 182
    }
169 183
}
170 184

  
171
void ff_h264_idct8_dc_add_c(uint8_t *dst, DCTELEM *block, int stride){
185
void FUNCC(ff_h264_idct8_dc_add)(uint8_t *p_dst, DCTELEM *block, int stride){
172 186
    int i, j;
173
    int dc = (block[0] + 32) >> 6;
174
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc;
187
    int dc = (((dctcoef*)block)[0] + 32) >> 6;
188
    INIT_CLIP
189
    pixel *dst = (pixel*)p_dst;
190
    stride >>= sizeof(pixel)-1;
175 191
    for( j = 0; j < 8; j++ )
176 192
    {
177 193
        for( i = 0; i < 8; i++ )
178
            dst[i] = cm[ dst[i] ];
194
            dst[i] = CLIP( dst[i] + dc );
179 195
        dst += stride;
180 196
    }
181 197
}
182 198

  
183
void ff_h264_idct_add16_c(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
199
void FUNCC(ff_h264_idct_add16)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
184 200
    int i;
185 201
    for(i=0; i<16; i++){
186 202
        int nnz = nnzc[ scan8[i] ];
187 203
        if(nnz){
188
            if(nnz==1 && block[i*16]) ff_h264_idct_dc_add_c(dst + block_offset[i], block + i*16, stride);
189
            else                      idct_internal        (dst + block_offset[i], block + i*16, stride, 4, 6, 1);
204
            if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
205
            else                                  FUNCC(idct_internal      )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1);
190 206
        }
191 207
    }
192 208
}
193 209

  
194
void ff_h264_idct_add16intra_c(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
210
void FUNCC(ff_h264_idct_add16intra)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
195 211
    int i;
196 212
    for(i=0; i<16; i++){
197
        if(nnzc[ scan8[i] ]) idct_internal        (dst + block_offset[i], block + i*16, stride, 4, 6, 1);
198
        else if(block[i*16]) ff_h264_idct_dc_add_c(dst + block_offset[i], block + i*16, stride);
213
        if(nnzc[ scan8[i] ])             FUNCC(idct_internal      )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1);
214
        else if(((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
199 215
    }
200 216
}
201 217

  
202
void ff_h264_idct8_add4_c(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
218
void FUNCC(ff_h264_idct8_add4)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
203 219
    int i;
204 220
    for(i=0; i<16; i+=4){
205 221
        int nnz = nnzc[ scan8[i] ];
206 222
        if(nnz){
207
            if(nnz==1 && block[i*16]) ff_h264_idct8_dc_add_c(dst + block_offset[i], block + i*16, stride);
208
            else                      ff_h264_idct8_add_c   (dst + block_offset[i], block + i*16, stride);
223
            if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct8_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
224
            else                                  FUNCC(ff_h264_idct8_add   )(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
209 225
        }
210 226
    }
211 227
}
212 228

  
213
void ff_h264_idct_add8_c(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
229
void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
214 230
    int i;
215 231
    for(i=16; i<16+8; i++){
216 232
        if(nnzc[ scan8[i] ])
217
            ff_h264_idct_add_c   (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
218
        else if(block[i*16])
219
            ff_h264_idct_dc_add_c(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
233
            FUNCC(ff_h264_idct_add   )(dest[(i&4)>>2] + block_offset[i], block + i*16*sizeof(pixel), stride);
234
        else if(((dctcoef*)block)[i*16])
235
            FUNCC(ff_h264_idct_dc_add)(dest[(i&4)>>2] + block_offset[i], block + i*16*sizeof(pixel), stride);
220 236
    }
221 237
}
222 238
/**
223 239
 * IDCT transforms the 16 dc values and dequantizes them.
224 240
 * @param qp quantization parameter
225 241
 */
226
void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul){
242
void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *p_output, DCTELEM *p_input, int qmul){
227 243
#define stride 16
228 244
    int i;
229 245
    int temp[16];
230 246
    static const uint8_t x_offset[4]={0, 2*stride, 8*stride, 10*stride};
247
    dctcoef *input = (dctcoef*)p_input;
248
    dctcoef *output = (dctcoef*)p_output;
231 249

  
232 250
    for(i=0; i<4; i++){
233 251
        const int z0= input[4*i+0] + input[4*i+1];
......
256 274
#undef stride
257 275
}
258 276

  
259
void ff_h264_chroma_dc_dequant_idct_c(DCTELEM *block, int qmul){
277
void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *p_block, int qmul){
260 278
    const int stride= 16*2;
261 279
    const int xStride= 16;
262 280
    int a,b,c,d,e;
281
    dctcoef *block = (dctcoef*)p_block;
263 282

  
264 283
    a= block[stride*0 + xStride*0];
265 284
    b= block[stride*0 + xStride*1];

Also available in: Unified diff