Revision 21a7c936 libavcodec/h264dsp_internal.h

View differences:

libavcodec/h264dsp_internal.h
27 27

  
28 28
#include "dsputil.h"
29 29

  
30
#define op_scale1(x)  block[x] = av_clip_uint8( (block[x]*weight + offset) >> log2_denom )
31
#define op_scale2(x)  dst[x] = av_clip_uint8( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
30
#define BIT_DEPTH 8
31
#define pixel uint8_t
32
#define av_clip_pixel av_clip_uint8
33
#define FUNCC(a) a ## _c
34

  
35
#define op_scale1(x)  block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom )
36
#define op_scale2(x)  dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
32 37
#define H264_WEIGHT(W,H) \
33
static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, int log2_denom, int weight, int offset){ \
38
static void FUNCC(weight_h264_pixels ## W ## x ## H)(uint8_t *p_block, int stride, int log2_denom, int weight, int offset){ \
34 39
    int y; \
35
    offset <<= log2_denom; \
40
    pixel *block = (pixel*)p_block; \
41
    stride >>= sizeof(pixel)-1; \
42
    offset <<= (log2_denom + (BIT_DEPTH-8)); \
36 43
    if(log2_denom) offset += 1<<(log2_denom-1); \
37 44
    for(y=0; y<H; y++, block += stride){ \
38 45
        op_scale1(0); \
......
56 63
        op_scale1(15); \
57 64
    } \
58 65
} \
59
static void biweight_h264_pixels ## W ## x ## H ## _c(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset){ \
66
static void FUNCC(biweight_h264_pixels ## W ## x ## H)(uint8_t *p_dst, uint8_t *p_src, int stride, int log2_denom, int weightd, int weights, int offset){ \
60 67
    int y; \
68
    pixel *dst = (pixel*)p_dst; \
69
    pixel *src = (pixel*)p_src; \
70
    stride >>= sizeof(pixel)-1; \
61 71
    offset = ((offset + 1) | 1) << log2_denom; \
62 72
    for(y=0; y<H; y++, dst += stride, src += stride){ \
63 73
        op_scale2(0); \
......
97 107
#undef op_scale2
98 108
#undef H264_WEIGHT
99 109

  
100
static av_always_inline av_flatten void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)
110
static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma)(uint8_t *p_pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)
101 111
{
112
    pixel *pix = (pixel*)p_pix;
102 113
    int i, d;
114
    xstride >>= sizeof(pixel)-1;
115
    ystride >>= sizeof(pixel)-1;
103 116
    for( i = 0; i < 4; i++ ) {
104 117
        if( tc0[i] < 0 ) {
105 118
            pix += 4*ystride;
......
132 145
                }
133 146

  
134 147
                i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
135
                pix[-xstride] = av_clip_uint8( p0 + i_delta );    /* p0' */
136
                pix[0]        = av_clip_uint8( q0 - i_delta );    /* q0' */
148
                pix[-xstride] = av_clip_pixel( p0 + i_delta );    /* p0' */
149
                pix[0]        = av_clip_pixel( q0 - i_delta );    /* q0' */
137 150
            }
138 151
            pix += ystride;
139 152
        }
140 153
    }
141 154
}
142
static void h264_v_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
155
static void FUNCC(h264_v_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
143 156
{
144
    h264_loop_filter_luma_c(pix, stride, 1, alpha, beta, tc0);
157
    FUNCC(h264_loop_filter_luma)(pix, stride, sizeof(pixel), alpha, beta, tc0);
145 158
}
146
static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
159
static void FUNCC(h264_h_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
147 160
{
148
    h264_loop_filter_luma_c(pix, 1, stride, alpha, beta, tc0);
161
    FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, alpha, beta, tc0);
149 162
}
150 163

  
151
static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta)
164
static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma_intra)(uint8_t *p_pix, int xstride, int ystride, int alpha, int beta)
152 165
{
166
    pixel *pix = (pixel*)p_pix;
153 167
    int d;
168
    xstride >>= sizeof(pixel)-1;
169
    ystride >>= sizeof(pixel)-1;
154 170
    for( d = 0; d < 16; d++ ) {
155 171
        const int p2 = pix[-3*xstride];
156 172
        const int p1 = pix[-2*xstride];
......
196 212
        pix += ystride;
197 213
    }
198 214
}
199
static void h264_v_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
215
static void FUNCC(h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta)
200 216
{
201
    h264_loop_filter_luma_intra_c(pix, stride, 1, alpha, beta);
217
    FUNCC(h264_loop_filter_luma_intra)(pix, stride, sizeof(pixel), alpha, beta);
202 218
}
203
static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
219
static void FUNCC(h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta)
204 220
{
205
    h264_loop_filter_luma_intra_c(pix, 1, stride, alpha, beta);
221
    FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), stride, alpha, beta);
206 222
}
207 223

  
208
static av_always_inline av_flatten void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)
224
static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma)(uint8_t *p_pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)
209 225
{
226
    pixel *pix = (pixel*)p_pix;
210 227
    int i, d;
228
    xstride >>= sizeof(pixel)-1;
229
    ystride >>= sizeof(pixel)-1;
211 230
    for( i = 0; i < 4; i++ ) {
212 231
        const int tc = tc0[i];
213 232
        if( tc <= 0 ) {
......
226 245

  
227 246
                int delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
228 247

  
229
                pix[-xstride] = av_clip_uint8( p0 + delta );    /* p0' */
230
                pix[0]        = av_clip_uint8( q0 - delta );    /* q0' */
248
                pix[-xstride] = av_clip_pixel( p0 + delta );    /* p0' */
249
                pix[0]        = av_clip_pixel( q0 - delta );    /* q0' */
231 250
            }
232 251
            pix += ystride;
233 252
        }
234 253
    }
235 254
}
236
static void h264_v_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
255
static void FUNCC(h264_v_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
237 256
{
238
    h264_loop_filter_chroma_c(pix, stride, 1, alpha, beta, tc0);
257
    FUNCC(h264_loop_filter_chroma)(pix, stride, sizeof(pixel), alpha, beta, tc0);
239 258
}
240
static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
259
static void FUNCC(h264_h_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
241 260
{
242
    h264_loop_filter_chroma_c(pix, 1, stride, alpha, beta, tc0);
261
    FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, alpha, beta, tc0);
243 262
}
244 263

  
245
static av_always_inline av_flatten void h264_loop_filter_chroma_intra_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta)
264
static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma_intra)(uint8_t *p_pix, int xstride, int ystride, int alpha, int beta)
246 265
{
266
    pixel *pix = (pixel*)p_pix;
247 267
    int d;
268
    xstride >>= sizeof(pixel)-1;
269
    ystride >>= sizeof(pixel)-1;
248 270
    for( d = 0; d < 8; d++ ) {
249 271
        const int p0 = pix[-1*xstride];
250 272
        const int p1 = pix[-2*xstride];
......
261 283
        pix += ystride;
262 284
    }
263 285
}
264
static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
286
static void FUNCC(h264_v_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta)
265 287
{
266
    h264_loop_filter_chroma_intra_c(pix, stride, 1, alpha, beta);
288
    FUNCC(h264_loop_filter_chroma_intra)(pix, stride, sizeof(pixel), alpha, beta);
267 289
}
268
static void h264_h_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
290
static void FUNCC(h264_h_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta)
269 291
{
270
    h264_loop_filter_chroma_intra_c(pix, 1, stride, alpha, beta);
292
    FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, alpha, beta);
271 293
}

Also available in: Unified diff