46 #define area4 (8 + 8 + 1)
47 #define area5 (8 + 8 + 1 + 8)
48 #define area6 (8 + 8 + 1 + 16)
66 ptrdiff_t
stride,
int *range,
75 if ((edges & 3) == 3) {
76 *psum = 0x80 * (8 + 1 + 8 + 2);
78 memset(dst, 0x80, 16 + 1 + 16 + 8);
91 for (i = 7; i >= 0; i--) {
97 min_pix =
FFMIN(min_pix, c);
98 max_pix =
FFMAX(max_pix, c);
107 for (i = 0; i < 8; i++) {
110 min_pix =
FFMIN(min_pix, c);
111 max_pix =
FFMAX(max_pix, c);
114 memset(dst +
area5, c, 8);
115 memcpy(dst +
area4, ptr, 8);
117 memcpy(dst +
area4, ptr, 16);
120 memcpy(dst +
area6, ptr - stride, 8);
124 int avg = (sum + 4) >> 3;
127 memset(dst +
area1, avg, 8 + 8 + 1);
129 memset(dst +
area3, avg, 1 + 16 + 8);
139 *range = max_pix - min_pix;
145 640, 640, 669, 480, 708, 354, 748, 257,
146 792, 198, 760, 143, 808, 101, 772, 72,
147 480, 669, 537, 537, 598, 416, 661, 316,
148 719, 250, 707, 185, 768, 134, 745, 97,
149 354, 708, 416, 598, 488, 488, 564, 388,
150 634, 317, 642, 241, 716, 179, 706, 132,
151 257, 748, 316, 661, 388, 564, 469, 469,
152 543, 395, 571, 311, 655, 238, 660, 180,
153 198, 792, 250, 719, 317, 634, 395, 543,
154 469, 469, 507, 380, 597, 299, 616, 231,
155 161, 855, 206, 788, 266, 710, 340, 623,
156 411, 548, 455, 455, 548, 366, 576, 288,
157 122, 972, 159, 914, 211, 842, 276, 758,
158 341, 682, 389, 584, 483, 483, 520, 390,
159 110, 1172, 144, 1107, 193, 1028, 254, 932,
160 317, 846, 366, 731, 458, 611, 499, 499,
169 uint16_t left_sum[2][8] = { { 0 } };
170 uint16_t top_sum[2][8] = { { 0 } };
172 for (i = 0; i < 8; i++) {
173 a = src[
area2 + 7 - i] << 4;
174 for (j = 0; j < 8; j++) {
176 left_sum[p & 1][j] += a >> (p >> 1);
180 for (i = 0; i < 8; i++) {
181 a = src[
area4 + i] << 4;
182 for (j = 0; j < 8; j++) {
184 top_sum[p & 1][j] += a >> (p >> 1);
187 for (; i < 10; i++) {
188 a = src[
area4 + i] << 4;
189 for (j = 5; j < 8; j++) {
191 top_sum[p & 1][j] += a >> (p >> 1);
194 for (; i < 12; i++) {
195 a = src[
area4 + i] << 4;
196 for (j = 7; j < 8; j++) {
198 top_sum[p & 1][j] += a >> (p >> 1);
202 for (i = 0; i < 8; i++) {
203 top_sum[0][i] += (top_sum[1][i] * 181 + 128) >> 8;
204 left_sum[0][i] += (left_sum[1][i] * 181 + 128) >> 8;
206 for (y = 0; y < 8; y++) {
207 for (x = 0; x < 8; x++)
219 for (y = 0; y < 8; y++) {
220 for (x = 0; x < 8; x++)
221 dst[x] = src[
area4 +
FFMIN(2 * y + x + 2, 15)];
230 for (y = 0; y < 8; y++) {
231 for (x = 0; x < 8; x++)
232 dst[x] = src[
area4 + 1 + y + x];
241 for (y = 0; y < 8; y++) {
242 for (x = 0; x < 8; x++)
243 dst[x] = src[
area4 + ((y + 1) >> 1) + x];
252 for (y = 0; y < 8; y++) {
253 for (x = 0; x < 8; x++)
254 dst[x] = (src[
area4 + x] + src[
area6 + x] + 1) >> 1;
263 for (y = 0; y < 8; y++) {
264 for (x = 0; x < 8; x++) {
266 dst[x] = src[
area2 + 9 + 2 * x - y];
268 dst[x] = src[
area4 + x - ((y + 1) >> 1)];
278 for (y = 0; y < 8; y++) {
279 for (x = 0; x < 8; x++)
280 dst[x] = src[
area3 + x - y];
289 for (y = 0; y < 8; y++) {
290 for (x = 0; x < 8; x++) {
292 dst[x] = (src[
area3 - 1 + x - 2 * y] + src[
area3 + x - 2 * y] + 1) >> 1;
294 dst[x] = src[
area2 + 8 - y + (x >> 1)];
304 for (y = 0; y < 8; y++) {
305 for (x = 0; x < 8; x++)
306 dst[x] = (src[
area1 + 7 - y] + src[
area2 + 7 - y] + 1) >> 1;
315 for (y = 0; y < 8; y++) {
316 for (x = 0; x < 8; x++)
326 for (y = 0; y < 8; y++) {
327 for (x = 0; x < 8; x++)
328 dst[x] = (src[
area2 + 7 - y] * (8 - x) + src[
area4 + x] * x + 4) >> 3;
337 for (y = 0; y < 8; y++) {
338 for (x = 0; x < 8; x++)
339 dst[x] = (src[
area2 + 7 - y] * y + src[
area4 + x] * (8 - y) + 4) >> 3;
345 const ptrdiff_t b_stride,
int quant)
348 int p0, p1, p2, p3, p4, p5, p6, p7, p8, p9;
349 int ql = (quant + 10) >> 3;
351 for (i = 0; i < 8; i++, ptr += b_stride) {
352 p0 = ptr[-5 * a_stride];
353 p1 = ptr[-4 * a_stride];
354 p2 = ptr[-3 * a_stride];
355 p3 = ptr[-2 * a_stride];
356 p4 = ptr[-1 * a_stride];
358 p6 = ptr[1 * a_stride];
359 p7 = ptr[2 * a_stride];
360 p8 = ptr[3 * a_stride];
361 p9 = ptr[4 * a_stride];
363 t = (
FFABS(p1 - p2) <= ql) +
364 (
FFABS(p2 - p3) <= ql) +
365 (
FFABS(p3 - p4) <= ql) +
366 (
FFABS(p4 - p5) <= ql);
370 t += (
FFABS(p5 - p6) <= ql) +
371 (
FFABS(p6 - p7) <= ql) +
372 (
FFABS(p7 - p8) <= ql) +
373 (
FFABS(p8 - p9) <= ql) +
374 (
FFABS(p0 - p1) <= ql);
379 min =
FFMIN(min, p3);
380 max =
FFMAX(max, p3);
381 min =
FFMIN(min, p5);
382 max =
FFMAX(max, p5);
383 min =
FFMIN(min, p8);
384 max =
FFMAX(max, p8);
385 if (max - min < 2 * quant) {
386 min =
FFMIN(min, p2);
387 max =
FFMAX(max, p2);
388 min =
FFMIN(min, p4);
389 max =
FFMAX(max, p4);
390 min =
FFMIN(min, p6);
391 max =
FFMAX(max, p6);
392 min =
FFMIN(min, p7);
393 max =
FFMAX(max, p7);
394 if (max - min < 2 * quant) {
395 ptr[-2 * a_stride] = (4 * p2 + 3 * p3 + 1 * p7 + 4) >> 3;
396 ptr[-1 * a_stride] = (3 * p2 + 3 * p4 + 2 * p7 + 4) >> 3;
397 ptr[0] = (2 * p2 + 3 * p5 + 3 * p7 + 4) >> 3;
398 ptr[1 * a_stride] = (1 * p2 + 3 * p6 + 4 * p7 + 4) >> 3;
408 x0 = (2 * p3 - 5 * p4 + 5 * p5 - 2 * p6 + 4) >> 3;
410 x1 = (2 * p1 - 5 * p2 + 5 * p3 - 2 * p4 + 4) >> 3;
411 x2 = (2 * p5 - 5 * p6 + 5 * p7 - 2 * p8 + 4) >> 3;
416 if (x > 0 && (m ^ x0) < 0) {
420 m = (m ^ sign) - sign;
428 x = (x ^ sign) - sign;
430 ptr[-1 * a_stride] -= x;
static void spatial_compensation_7(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void spatial_compensation_10(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
void(* setup_spatial_compensation)(uint8_t *src, uint8_t *dst, ptrdiff_t stride, int *range, int *sum, int edges)
static const uint16_t zero_prediction_weights[64 *2]
static void x8_loop_filter(uint8_t *ptr, const ptrdiff_t a_stride, const ptrdiff_t b_stride, int quant)
static void spatial_compensation_3(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void spatial_compensation_5(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void spatial_compensation_0(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void x8_setup_spatial_compensation(uint8_t *src, uint8_t *dst, ptrdiff_t stride, int *range, int *psum, int edges)
Collect statistics and prepare the edge pixels required by the other spatial compensation functions...
static void spatial_compensation_4(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void spatial_compensation_11(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void spatial_compensation_6(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void x8_v_loop_filter(uint8_t *src, ptrdiff_t stride, int qscale)
void(* h_loop_filter)(uint8_t *src, ptrdiff_t stride, int qscale)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
void(* v_loop_filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static void spatial_compensation_8(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
void(* spatial_compensation[12])(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
av_cold void ff_intrax8dsp_init(IntraX8DSPContext *dsp)
static void x8_h_loop_filter(uint8_t *src, ptrdiff_t stride, int qscale)
static void spatial_compensation_9(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
GLint GLenum GLboolean GLsizei stride
common internal and external API header
static void spatial_compensation_1(uint8_t *src, uint8_t *dst, ptrdiff_t stride)
static void spatial_compensation_2(uint8_t *src, uint8_t *dst, ptrdiff_t stride)