38 for (y = 0; y <
height; y++) {
39 for (x = 0; x <
width; x++)
53 for (y = 0; y <
size; y++) {
54 for (x = 0; x <
size; x++) {
89 int16_t *coeffs = (int16_t *) _coeffs;
91 int size = 1 << log2_size;
95 for (y = 0; y < size - 1; y++) {
96 for (x = 0; x <
size; x++)
97 coeffs[x] += coeffs[x - size];
101 for (y = 0; y <
size; y++) {
102 for (x = 1; x <
size; x++)
103 coeffs[x] += coeffs[x - 1];
113 int size = 1 << log2_size;
114 int16_t *coeffs = _coeffs;
118 int offset = 1 << (shift - 1);
119 for (y = 0; y <
size; y++) {
120 for (x = 0; x <
size; x++) {
121 *coeffs = (*coeffs +
offset) >> shift;
126 for (y = 0; y <
size; y++) {
127 for (x = 0; x <
size; x++) {
128 *coeffs = *coeffs << -
shift;
135 #define SET(dst, x) (dst) = (x)
136 #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
137 #define ADD_AND_SCALE(dst, x) \
138 (dst) = av_clip_pixel((dst) + av_clip_int16(((x) + add) >> shift))
140 #define TR_4x4_LUMA(dst, src, step, assign) \
142 int c0 = src[0 * step] + src[2 * step]; \
143 int c1 = src[2 * step] + src[3 * step]; \
144 int c2 = src[0 * step] - src[3 * step]; \
145 int c3 = 74 * src[1 * step]; \
147 assign(dst[2 * step], 74 * (src[0 * step] - \
150 assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \
151 assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \
152 assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \
159 int add = 1 << (shift - 1);
160 int16_t *
src = coeffs;
162 for (i = 0; i < 4; i++) {
168 add = 1 << (shift - 1);
169 for (i = 0; i < 4; i++) {
177 #define TR_4(dst, src, dstep, sstep, assign, end) \
179 const int e0 = 64 * src[0 * sstep] + 64 * src[2 * sstep]; \
180 const int e1 = 64 * src[0 * sstep] - 64 * src[2 * sstep]; \
181 const int o0 = 83 * src[1 * sstep] + 36 * src[3 * sstep]; \
182 const int o1 = 36 * src[1 * sstep] - 83 * src[3 * sstep]; \
184 assign(dst[0 * dstep], e0 + o0); \
185 assign(dst[1 * dstep], e1 + o1); \
186 assign(dst[2 * dstep], e1 - o1); \
187 assign(dst[3 * dstep], e0 - o0); \
190 #define TR_8(dst, src, dstep, sstep, assign, end) \
194 int o_8[4] = { 0 }; \
195 for (i = 0; i < 4; i++) \
196 for (j = 1; j < end; j += 2) \
197 o_8[i] += transform[4 * j][i] * src[j * sstep]; \
198 TR_4(e_8, src, 1, 2 * sstep, SET, 4); \
200 for (i = 0; i < 4; i++) { \
201 assign(dst[i * dstep], e_8[i] + o_8[i]); \
202 assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \
206 #define TR_16(dst, src, dstep, sstep, assign, end) \
210 int o_16[8] = { 0 }; \
211 for (i = 0; i < 8; i++) \
212 for (j = 1; j < end; j += 2) \
213 o_16[i] += transform[2 * j][i] * src[j * sstep]; \
214 TR_8(e_16, src, 1, 2 * sstep, SET, 8); \
216 for (i = 0; i < 8; i++) { \
217 assign(dst[i * dstep], e_16[i] + o_16[i]); \
218 assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \
222 #define TR_32(dst, src, dstep, sstep, assign, end) \
226 int o_32[16] = { 0 }; \
227 for (i = 0; i < 16; i++) \
228 for (j = 1; j < end; j += 2) \
229 o_32[i] += transform[j][i] * src[j * sstep]; \
230 TR_16(e_32, src, 1, 2 * sstep, SET, end/2); \
232 for (i = 0; i < 16; i++) { \
233 assign(dst[i * dstep], e_32[i] + o_32[i]); \
234 assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \
238 #define IDCT_VAR4(H) \
239 int limit2 = FFMIN(col_limit + 4, H)
240 #define IDCT_VAR8(H) \
241 int limit = FFMIN(col_limit, H); \
242 int limit2 = FFMIN(col_limit + 4, H)
243 #define IDCT_VAR16(H) IDCT_VAR8(H)
244 #define IDCT_VAR32(H) IDCT_VAR8(H)
247 static void FUNC(idct_##H ##x ##H )( \
248 int16_t *coeffs, int col_limit) { \
251 int add = 1 << (shift - 1); \
252 int16_t *src = coeffs; \
255 for (i = 0; i < H; i++) { \
256 TR_ ## H(src, src, H, H, SCALE, limit2); \
257 if (limit2 < H && i%4 == 0 && !!i) \
262 shift = 20 - BIT_DEPTH; \
263 add = 1 << (shift - 1); \
264 for (i = 0; i < H; i++) { \
265 TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \
271 static void FUNC(idct_##H ##x ##H ##_dc)( \
274 int shift = 14 - BIT_DEPTH; \
275 int add = 1 << (shift - 1); \
276 int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \
278 for (j = 0; j < H; j++) { \
279 for (i = 0; i < H; i++) { \
280 coeffs[i+j*H] = coeff; \
305 ptrdiff_t stride_dst, ptrdiff_t stride_src,
SAOParams *sao,
314 int16_t *sao_offset_val = sao->offset_val[c_idx];
315 int sao_left_class = sao->band_position[c_idx];
317 stride_dst /=
sizeof(
pixel);
318 stride_src /=
sizeof(
pixel);
320 for (k = 0; k < 4; k++)
321 offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
322 for (y = 0; y <
height; y++) {
323 for (x = 0; x <
width; x++)
324 dst[x] =
av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
330 #define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
333 ptrdiff_t stride_dst, ptrdiff_t stride_src,
SAOParams *sao,
335 int c_idx,
int init_x,
int init_y) {
337 static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
338 static const int8_t pos[4][2][2] = {
339 { { -1, 0 }, { 1, 0 } },
340 { { 0, -1 }, { 0, 1 } },
341 { { -1, -1 }, { 1, 1 } },
342 { { 1, -1 }, { -1, 1 } },
344 int16_t *sao_offset_val = sao->offset_val[c_idx];
345 int sao_eo_class = sao->eo_class[c_idx];
349 int y_stride_src = init_y * stride_src;
350 int y_stride_dst = init_y * stride_dst;
351 int pos_0_0 = pos[sao_eo_class][0][0];
352 int pos_0_1 = pos[sao_eo_class][0][1];
353 int pos_1_0 = pos[sao_eo_class][1][0];
354 int pos_1_1 = pos[sao_eo_class][1][1];
357 int y_stride_0_1 = (init_y + pos_0_1) * stride_src;
358 int y_stride_1_1 = (init_y + pos_1_1) * stride_src;
359 for (y = init_y; y <
height; y++) {
360 for (x = init_x; x <
width; x++) {
361 int diff0 =
CMP(src[x + y_stride_src], src[x + pos_0_0 + y_stride_0_1]);
362 int diff1 =
CMP(src[x + y_stride_src], src[x + pos_1_0 + y_stride_1_1]);
364 dst[x + y_stride_dst] =
av_clip_pixel(src[x + y_stride_src] + sao_offset_val[offset_val]);
366 y_stride_src += stride_src;
367 y_stride_dst += stride_dst;
368 y_stride_0_1 += stride_src;
369 y_stride_1_1 += stride_src;
374 ptrdiff_t stride_dst, ptrdiff_t stride_src,
SAOParams *sao,
375 int *borders,
int _width,
int _height,
382 int16_t *sao_offset_val = sao->offset_val[c_idx];
383 int sao_eo_class = sao->eo_class[c_idx];
384 int init_x = 0, init_y = 0, width = _width, height = _height;
386 stride_dst /=
sizeof(
pixel);
387 stride_src /=
sizeof(
pixel);
392 for (y = 0; y <
height; y++) {
393 dst[y * stride_dst] =
av_clip_pixel(src[y * stride_src] + offset_val);
400 for (x = 0; x <
height; x++) {
409 for (x = init_x; x <
width; x++)
415 int y_stride_dst = stride_dst * (height - 1);
416 int y_stride_src = stride_src * (height - 1);
417 for (x = init_x; x <
width; x++)
418 dst[x + y_stride_dst] =
av_clip_pixel(src[x + y_stride_src] + offset_val);
427 ptrdiff_t stride_dst, ptrdiff_t stride_src,
SAOParams *sao,
428 int *borders,
int _width,
int _height,
435 int16_t *sao_offset_val = sao->offset_val[c_idx];
436 int sao_eo_class = sao->eo_class[c_idx];
437 int init_x = 0, init_y = 0, width = _width, height = _height;
439 stride_dst /=
sizeof(
pixel);
440 stride_src /=
sizeof(
pixel);
445 for (y = 0; y <
height; y++) {
446 dst[y * stride_dst] =
av_clip_pixel(src[y * stride_src] + offset_val);
453 for (x = 0; x <
height; x++) {
462 for (x = init_x; x <
width; x++)
468 int y_stride_dst = stride_dst * (height - 1);
469 int y_stride_src = stride_src * (height - 1);
470 for (x = init_x; x <
width; x++)
471 dst[x + y_stride_dst] =
av_clip_pixel(src[x + y_stride_src] + offset_val);
479 int save_upper_left = !diag_edge[0] && sao_eo_class ==
SAO_EO_135D && !borders[0] && !borders[1];
480 int save_upper_right = !diag_edge[1] && sao_eo_class ==
SAO_EO_45D && !borders[1] && !borders[2];
481 int save_lower_right = !diag_edge[2] && sao_eo_class ==
SAO_EO_135D && !borders[2] && !borders[3];
482 int save_lower_left = !diag_edge[3] && sao_eo_class ==
SAO_EO_45D && !borders[0] && !borders[3];
486 for(y = init_y+save_upper_left; y< height-save_lower_left; y++)
487 dst[y*stride_dst] = src[y*stride_src];
490 for(y = init_y+save_upper_right; y< height-save_lower_right; y++)
491 dst[y*stride_dst+width-1] = src[y*stride_src+width-1];
495 for(x = init_x+save_upper_left; x < width-save_upper_right; x++)
499 for(x = init_x+save_lower_left; x < width-save_lower_right; x++)
500 dst[(height-1)*stride_dst+x] = src[(height-1)*stride_src+x];
504 if(diag_edge[1] && sao_eo_class ==
SAO_EO_45D)
505 dst[width-1] = src[width-1];
507 dst[stride_dst*(height-1)+width-1] = src[stride_src*(height-1)+width-1];
508 if(diag_edge[3] && sao_eo_class ==
SAO_EO_45D)
509 dst[stride_dst*(height-1)] = src[stride_src*(height-1)];
520 uint8_t *_src, ptrdiff_t _srcstride,
525 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
527 for (y = 0; y <
height; y++) {
528 for (x = 0; x <
width; x++)
540 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
542 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
544 for (y = 0; y <
height; y++) {
545 memcpy(dst, src, width *
sizeof(
pixel));
557 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
559 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
563 int offset = 1 << (shift - 1);
568 for (y = 0; y <
height; y++) {
569 for (x = 0; x <
width; x++)
578 int height,
int denom,
int wx,
int ox, intptr_t mx, intptr_t my,
int width)
582 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
584 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
587 int offset = 1 << (shift - 1);
592 ox = ox * (1 << (BIT_DEPTH - 8));
593 for (y = 0; y <
height; y++) {
594 for (x = 0; x <
width; x++)
595 dst[x] =
av_clip_pixel((((src[x] << (14 - BIT_DEPTH)) * wx + offset) >> shift) + ox);
603 int height,
int denom,
int wx0,
int wx1,
604 int ox0,
int ox1, intptr_t mx, intptr_t my,
int width)
608 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
610 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
613 int log2Wd = denom + shift - 1;
617 for (y = 0; y <
height; y++) {
618 for (x = 0; x <
width; x++) {
619 dst[x] =
av_clip_pixel(( (src[x] << (14 -
BIT_DEPTH)) * wx1 + src2[x] * wx0 + ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
630 #define QPEL_FILTER(src, stride) \
631 (filter[0] * src[x - 3 * stride] + \
632 filter[1] * src[x - 2 * stride] + \
633 filter[2] * src[x - stride] + \
634 filter[3] * src[x ] + \
635 filter[4] * src[x + stride] + \
636 filter[5] * src[x + 2 * stride] + \
637 filter[6] * src[x + 3 * stride] + \
638 filter[7] * src[x + 4 * stride])
641 uint8_t *_src, ptrdiff_t _srcstride,
646 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
648 for (y = 0; y <
height; y++) {
649 for (x = 0; x <
width; x++)
657 uint8_t *_src, ptrdiff_t _srcstride,
662 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
664 for (y = 0; y <
height; y++) {
665 for (x = 0; x <
width; x++)
674 ptrdiff_t _srcstride,
676 intptr_t my,
int width)
681 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
683 int16_t *tmp = tmp_array;
688 for (x = 0; x <
width; x++)
696 for (y = 0; y <
height; y++) {
697 for (x = 0; x <
width; x++)
705 uint8_t *_src, ptrdiff_t _srcstride,
710 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
712 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
717 int offset = 1 << (shift - 1);
722 for (y = 0; y <
height; y++) {
723 for (x = 0; x <
width; x++)
736 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
738 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
744 int offset = 1 << (shift - 1);
749 for (y = 0; y <
height; y++) {
750 for (x = 0; x <
width; x++)
759 uint8_t *_src, ptrdiff_t _srcstride,
764 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
766 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
771 int offset = 1 << (shift - 1);
776 for (y = 0; y <
height; y++) {
777 for (x = 0; x <
width; x++)
791 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
793 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
799 int offset = 1 << (shift - 1);
804 for (y = 0; y <
height; y++) {
805 for (x = 0; x <
width; x++)
814 uint8_t *_src, ptrdiff_t _srcstride,
820 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
822 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
824 int16_t *tmp = tmp_array;
828 int offset = 1 << (shift - 1);
836 for (x = 0; x <
width; x++)
845 for (y = 0; y <
height; y++) {
846 for (x = 0; x <
width; x++)
860 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
862 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
864 int16_t *tmp = tmp_array;
867 int offset = 1 << (shift - 1);
875 for (x = 0; x <
width; x++)
884 for (y = 0; y <
height; y++) {
885 for (x = 0; x <
width; x++)
894 uint8_t *_src, ptrdiff_t _srcstride,
895 int height,
int denom,
int wx,
int ox,
896 intptr_t mx, intptr_t my,
int width)
900 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
902 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
906 int offset = 1 << (shift - 1);
911 ox = ox * (1 << (BIT_DEPTH - 8));
912 for (y = 0; y <
height; y++) {
913 for (x = 0; x <
width; x++)
922 int height,
int denom,
int wx0,
int wx1,
923 int ox0,
int ox1, intptr_t mx, intptr_t my,
int width)
927 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
929 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
934 int log2Wd = denom + shift - 1;
938 for (y = 0; y <
height; y++) {
939 for (x = 0; x <
width; x++)
941 ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
949 uint8_t *_src, ptrdiff_t _srcstride,
950 int height,
int denom,
int wx,
int ox,
951 intptr_t mx, intptr_t my,
int width)
955 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
957 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
961 int offset = 1 << (shift - 1);
966 ox = ox * (1 << (BIT_DEPTH - 8));
967 for (y = 0; y <
height; y++) {
968 for (x = 0; x <
width; x++)
977 int height,
int denom,
int wx0,
int wx1,
978 int ox0,
int ox1, intptr_t mx, intptr_t my,
int width)
982 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
984 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
989 int log2Wd = denom + shift - 1;
993 for (y = 0; y <
height; y++) {
994 for (x = 0; x <
width; x++)
996 ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
1004 uint8_t *_src, ptrdiff_t _srcstride,
1005 int height,
int denom,
int wx,
int ox,
1006 intptr_t mx, intptr_t my,
int width)
1011 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1013 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1015 int16_t *tmp = tmp_array;
1018 int offset = 1 << (shift - 1);
1026 for (x = 0; x <
width; x++)
1035 ox = ox * (1 << (BIT_DEPTH - 8));
1036 for (y = 0; y <
height; y++) {
1037 for (x = 0; x <
width; x++)
1046 int height,
int denom,
int wx0,
int wx1,
1047 int ox0,
int ox1, intptr_t mx, intptr_t my,
int width)
1052 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1054 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1056 int16_t *tmp = tmp_array;
1058 int log2Wd = denom + shift - 1;
1063 for (x = 0; x <
width; x++)
1074 for (y = 0; y <
height; y++) {
1075 for (x = 0; x <
width; x++)
1077 ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
1087 #define EPEL_FILTER(src, stride) \
1088 (filter[0] * src[x - stride] + \
1089 filter[1] * src[x] + \
1090 filter[2] * src[x + stride] + \
1091 filter[3] * src[x + 2 * stride])
1094 uint8_t *_src, ptrdiff_t _srcstride,
1099 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1101 for (y = 0; y <
height; y++) {
1102 for (x = 0; x <
width; x++)
1110 uint8_t *_src, ptrdiff_t _srcstride,
1115 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1118 for (y = 0; y <
height; y++) {
1119 for (x = 0; x <
width; x++)
1127 uint8_t *_src, ptrdiff_t _srcstride,
1132 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1135 int16_t *tmp = tmp_array;
1140 for (x = 0; x <
width; x++)
1149 for (y = 0; y <
height; y++) {
1150 for (x = 0; x <
width; x++)
1162 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1164 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1168 int offset = 1 << (shift - 1);
1173 for (y = 0; y <
height; y++) {
1174 for (x = 0; x <
width; x++)
1187 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1189 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1193 int offset = 1 << (shift - 1);
1198 for (y = 0; y <
height; y++) {
1199 for (x = 0; x <
width; x++) {
1213 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1215 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1219 int offset = 1 << (shift - 1);
1224 for (y = 0; y <
height; y++) {
1225 for (x = 0; x <
width; x++)
1238 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1241 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1244 int offset = 1 << (shift - 1);
1249 for (y = 0; y <
height; y++) {
1250 for (x = 0; x <
width; x++)
1263 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1265 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1268 int16_t *tmp = tmp_array;
1271 int offset = 1 << (shift - 1);
1279 for (x = 0; x <
width; x++)
1288 for (y = 0; y <
height; y++) {
1289 for (x = 0; x <
width; x++)
1302 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1304 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1307 int16_t *tmp = tmp_array;
1310 int offset = 1 << (shift - 1);
1318 for (x = 0; x <
width; x++)
1327 for (y = 0; y <
height; y++) {
1328 for (x = 0; x <
width; x++)
1337 int height,
int denom,
int wx,
int ox, intptr_t mx, intptr_t my,
int width)
1341 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1343 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1347 int offset = 1 << (shift - 1);
1352 ox = ox * (1 << (BIT_DEPTH - 8));
1353 for (y = 0; y <
height; y++) {
1354 for (x = 0; x <
width; x++) {
1364 int height,
int denom,
int wx0,
int wx1,
1365 int ox0,
int ox1, intptr_t mx, intptr_t my,
int width)
1369 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1371 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1374 int log2Wd = denom + shift - 1;
1378 for (y = 0; y <
height; y++) {
1379 for (x = 0; x <
width; x++)
1381 ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
1389 int height,
int denom,
int wx,
int ox, intptr_t mx, intptr_t my,
int width)
1393 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1395 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1399 int offset = 1 << (shift - 1);
1404 ox = ox * (1 << (BIT_DEPTH - 8));
1405 for (y = 0; y <
height; y++) {
1406 for (x = 0; x <
width; x++) {
1416 int height,
int denom,
int wx0,
int wx1,
1417 int ox0,
int ox1, intptr_t mx, intptr_t my,
int width)
1421 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1424 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1426 int log2Wd = denom + shift - 1;
1430 for (y = 0; y <
height; y++) {
1431 for (x = 0; x <
width; x++)
1433 ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
1441 int height,
int denom,
int wx,
int ox, intptr_t mx, intptr_t my,
int width)
1445 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1447 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1450 int16_t *tmp = tmp_array;
1453 int offset = 1 << (shift - 1);
1461 for (x = 0; x <
width; x++)
1470 ox = ox * (1 << (BIT_DEPTH - 8));
1471 for (y = 0; y <
height; y++) {
1472 for (x = 0; x <
width; x++)
1481 int height,
int denom,
int wx0,
int wx1,
1482 int ox0,
int ox1, intptr_t mx, intptr_t my,
int width)
1486 ptrdiff_t srcstride = _srcstride /
sizeof(
pixel);
1488 ptrdiff_t dststride = _dststride /
sizeof(
pixel);
1491 int16_t *tmp = tmp_array;
1493 int log2Wd = denom + shift - 1;
1498 for (x = 0; x <
width; x++)
1509 for (y = 0; y <
height; y++) {
1510 for (x = 0; x <
width; x++)
1512 ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
1518 #define P3 pix[-4 * xstride]
1519 #define P2 pix[-3 * xstride]
1520 #define P1 pix[-2 * xstride]
1521 #define P0 pix[-1 * xstride]
1522 #define Q0 pix[0 * xstride]
1523 #define Q1 pix[1 * xstride]
1524 #define Q2 pix[2 * xstride]
1525 #define Q3 pix[3 * xstride]
1528 #define TP3 pix[-4 * xstride + 3 * ystride]
1529 #define TP2 pix[-3 * xstride + 3 * ystride]
1530 #define TP1 pix[-2 * xstride + 3 * ystride]
1531 #define TP0 pix[-1 * xstride + 3 * ystride]
1532 #define TQ0 pix[0 * xstride + 3 * ystride]
1533 #define TQ1 pix[1 * xstride + 3 * ystride]
1534 #define TQ2 pix[2 * xstride + 3 * ystride]
1535 #define TQ3 pix[3 * xstride + 3 * ystride]
1538 ptrdiff_t _xstride, ptrdiff_t _ystride,
1544 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
1545 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
1549 for (j = 0; j < 2; j++) {
1550 const int dp0 = abs(
P2 - 2 *
P1 +
P0);
1551 const int dq0 = abs(
Q2 - 2 *
Q1 +
Q0);
1552 const int dp3 = abs(
TP2 - 2 *
TP1 +
TP0);
1553 const int dq3 = abs(
TQ2 - 2 *
TQ1 +
TQ0);
1554 const int d0 = dp0 + dq0;
1555 const int d3 = dp3 + dq3;
1557 const int no_p = _no_p[j];
1558 const int no_q = _no_q[j];
1560 if (d0 + d3 >= beta) {
1564 const int beta_3 = beta >> 3;
1565 const int beta_2 = beta >> 2;
1566 const int tc25 = ((tc * 5 + 1) >> 1);
1568 if (abs(
P3 -
P0) + abs(
Q3 -
Q0) < beta_3 && abs(
P0 -
Q0) < tc25 &&
1570 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
1572 const int tc2 = tc << 1;
1573 for (d = 0; d < 4; d++) {
1583 P0 = p0 + av_clip(((p2 + 2 * p1 + 2 * p0 + 2 * q0 + q1 + 4) >> 3) - p0, -tc2, tc2);
1584 P1 = p1 + av_clip(((p2 + p1 + p0 + q0 + 2) >> 2) - p1, -tc2, tc2);
1585 P2 = p2 + av_clip(((2 * p3 + 3 * p2 + p1 + p0 + q0 + 4) >> 3) - p2, -tc2, tc2);
1588 Q0 = q0 + av_clip(((p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3) - q0, -tc2, tc2);
1589 Q1 = q1 + av_clip(((p0 + q0 + q1 + q2 + 2) >> 2) - q1, -tc2, tc2);
1590 Q2 = q2 + av_clip(((2 * q3 + 3 * q2 + q1 + q0 + p0 + 4) >> 3) - q2, -tc2, tc2);
1597 const int tc_2 = tc >> 1;
1598 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
1600 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
1603 for (d = 0; d < 4; d++) {
1610 int delta0 = (9 * (q0 - p0) - 3 * (q1 - p1) + 8) >> 4;
1611 if (abs(delta0) < 10 *
tc) {
1612 delta0 = av_clip(delta0, -tc, tc);
1617 if (!no_p && nd_p > 1) {
1618 const int deltap1 = av_clip((((p2 + p0 + 1) >> 1) - p1 + delta0) >> 1, -tc_2, tc_2);
1621 if (!no_q && nd_q > 1) {
1622 const int deltaq1 = av_clip((((q2 + q0 + 1) >> 1) - q1 - delta0) >> 1, -tc_2, tc_2);
1634 ptrdiff_t _ystride,
int *_tc,
1637 int d, j, no_p, no_q;
1639 ptrdiff_t xstride = _xstride /
sizeof(
pixel);
1640 ptrdiff_t ystride = _ystride /
sizeof(
pixel);
1642 for (j = 0; j < 2; j++) {
1651 for (d = 0; d < 4; d++) {
1657 delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc);
1686 beta, tc, no_p, no_q);
1694 beta, tc, no_p, no_q);