30 #define op_scale1(x) block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom )
31 #define op_scale2(x) dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
32 #define H264_WEIGHT(W) \
33 static void FUNCC(weight_h264_pixels ## W)(uint8_t *_block, ptrdiff_t stride, int height, \
34 int log2_denom, int weight, int offset) \
37 pixel *block = (pixel*)_block; \
38 stride >>= sizeof(pixel)-1; \
39 offset = (unsigned)offset << (log2_denom + (BIT_DEPTH-8)); \
40 if(log2_denom) offset += 1<<(log2_denom-1); \
41 for (y = 0; y < height; y++, block += stride) { \
63 static void FUNCC(biweight_h264_pixels ## W)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride, int height, \
64 int log2_denom, int weightd, int weights, int offset) \
67 pixel *dst = (pixel*)_dst; \
68 pixel *src = (pixel*)_src; \
69 stride >>= sizeof(pixel)-1; \
70 offset = (unsigned)offset << (BIT_DEPTH-8); \
71 offset = (unsigned)((offset + 1) | 1) << log2_denom; \
72 for (y = 0; y < height; y++, dst += stride, src += stride) { \
108 xstride >>=
sizeof(
pixel)-1;
109 ystride >>=
sizeof(
pixel)-1;
112 for( i = 0; i < 4; i++ ) {
113 const int tc_orig = tc0[i] * (1 << (
BIT_DEPTH - 8));
115 pix += inner_iters*ystride;
118 for( d = 0; d < inner_iters; d++ ) {
119 const int p0 = pix[-1*xstride];
120 const int p1 = pix[-2*xstride];
121 const int p2 = pix[-3*xstride];
122 const int q0 = pix[0];
123 const int q1 = pix[1*xstride];
124 const int q2 = pix[2*xstride];
126 if(
FFABS( p0 - q0 ) < alpha &&
127 FFABS( p1 - p0 ) < beta &&
128 FFABS( q1 - q0 ) < beta ) {
133 if(
FFABS( p2 - p0 ) < beta ) {
135 pix[-2*xstride] = p1 + av_clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc_orig, tc_orig );
138 if(
FFABS( q2 - q0 ) < beta ) {
140 pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc_orig, tc_orig );
144 i_delta = av_clip( (((q0 - p0 ) * 4) + (p1 - q1) + 4) >> 3, -tc, tc );
169 xstride >>=
sizeof(
pixel)-1;
170 ystride >>=
sizeof(
pixel)-1;
173 for( d = 0; d < 4 * inner_iters; d++ ) {
174 const int p2 = pix[-3*xstride];
175 const int p1 = pix[-2*xstride];
176 const int p0 = pix[-1*xstride];
178 const int q0 = pix[ 0*xstride];
179 const int q1 = pix[ 1*xstride];
180 const int q2 = pix[ 2*xstride];
182 if(
FFABS( p0 - q0 ) < alpha &&
183 FFABS( p1 - p0 ) < beta &&
184 FFABS( q1 - q0 ) < beta ) {
186 if(
FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
187 if(
FFABS( p2 - p0 ) < beta)
189 const int p3 = pix[-4*xstride];
191 pix[-1*xstride] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
192 pix[-2*xstride] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
193 pix[-3*xstride] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
196 pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
198 if(
FFABS( q2 - q0 ) < beta)
200 const int q3 = pix[3*xstride];
202 pix[0*xstride] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
203 pix[1*xstride] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
204 pix[2*xstride] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
207 pix[0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
211 pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
212 pix[ 0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
237 xstride >>=
sizeof(
pixel)-1;
238 ystride >>=
sizeof(
pixel)-1;
239 for( i = 0; i < 4; i++ ) {
242 pix += inner_iters*ystride;
245 for( d = 0; d < inner_iters; d++ ) {
246 const int p0 = pix[-1*xstride];
247 const int p1 = pix[-2*xstride];
248 const int q0 = pix[0];
249 const int q1 = pix[1*xstride];
251 if(
FFABS( p0 - q0 ) < alpha &&
252 FFABS( p1 - p0 ) < beta &&
253 FFABS( q1 - q0 ) < beta ) {
255 int delta = av_clip( ((q0 - p0) * 4 + (p1 - q1) + 4) >> 3, -tc, tc );
289 xstride >>=
sizeof(
pixel)-1;
290 ystride >>=
sizeof(
pixel)-1;
293 for( d = 0; d < 4 * inner_iters; d++ ) {
294 const int p0 = pix[-1*xstride];
295 const int p1 = pix[-2*xstride];
296 const int q0 = pix[0];
297 const int q1 = pix[1*xstride];
299 if(
FFABS( p0 - q0 ) < alpha &&
300 FFABS( p1 - p0 ) < beta &&
301 FFABS( q1 - q0 ) < beta ) {
303 pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
304 pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
static void FUNCC() h264_v_loop_filter_luma(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_h_loop_filter_chroma_intra(uint8_t *pix, int stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_chroma422(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_h_loop_filter_luma_mbaff_intra(uint8_t *pix, int stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_chroma(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static av_always_inline av_flatten void FUNCC() h264_loop_filter_luma(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0)
static const uint8_t q1[256]
static void FUNCC() h264_v_loop_filter_luma_intra(uint8_t *pix, int stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_chroma_mbaff(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_v_loop_filter_chroma(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static double alpha(void *priv, double x, double y)
static void FUNCC() h264_h_loop_filter_chroma422_mbaff(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static const uint8_t q0[256]
static void FUNCC() h264_v_loop_filter_chroma_intra(uint8_t *pix, int stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_chroma422_intra(uint8_t *pix, int stride, int alpha, int beta)
static av_always_inline av_flatten void FUNCC() h264_loop_filter_chroma(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void FUNCC() h264_h_loop_filter_luma_intra(uint8_t *pix, int stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_luma_mbaff(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static av_always_inline av_flatten void FUNCC() h264_loop_filter_chroma_intra(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_luma(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_h_loop_filter_chroma422_mbaff_intra(uint8_t *pix, int stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_chroma_mbaff_intra(uint8_t *pix, int stride, int alpha, int beta)
static av_always_inline av_flatten void FUNCC() h264_loop_filter_luma_intra(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta)