32 #define randomize_buffers(buf, size) \
35 for (j = 0; j < size; j+=4) \
36 AV_WN32(buf + j, rnd()); \
40 const int16_t **
src, uint8_t *dest,
int dstW,
45 for (
i = 0;
i < dstW;
i++) {
48 for (j = 0; j < filterSize; j++)
55 #define CMP_FUNC(bits) \
56 static int cmp_off_by_n_##bits(const uint##bits##_t *ref, const uint##bits##_t *test, \
57 size_t n, int accuracy) \
59 for (size_t i = 0; i < n; i++) { \
60 if (abs((int)ref[i] - (int)test[i]) > accuracy) \
69 #define SHOW_DIFF_FUNC(bits) \
70 static void print_data_##bits(const uint##bits##_t *p, size_t len, size_t offset) \
73 for (; i < len; i++) { \
75 printf("0x%04zx: ", i+offset); \
77 printf("0x%02x ", (uint32_t) p[i]); \
86 static size_t show_differences_##bits(const uint##bits##_t *a, const uint##bits##_t *b, \
89 for (size_t i = 0; i < len; i++) { \
91 size_t offset_of_mismatch = i; \
95 printf("test a:\n"); \
96 print_data_##bits(&a[offset], 32, offset); \
97 printf("\ntest b:\n"); \
98 print_data_##bits(&b[offset], 32, offset); \
100 return offset_of_mismatch; \
116 const int input_sizes[] = {8, 24, 128, 144, 256, 512};
117 #define LARGEST_INPUT_SIZE 512
119 const int offsets[] = {0, 3, 8, 11, 16, 19};
121 const char *accurate_str = (accurate) ?
"accurate" :
"approximate";
124 const int16_t *
src, uint8_t *dest,
144 for (osi = 0; osi < OFFSET_SIZES; osi++) {
152 if (cmp_off_by_n_8(dst0, dst1, dstW *
sizeof(dst0[0]), accurate ? 0 : 2)) {
154 printf(
"failed: yuv2yuv1_%d_%di_%s\n",
offset, dstW, accurate_str);
156 printf(
"failing values: src: 0x%04x dither: 0x%02x dst-c: %02x dst-asm: %02x\n",
157 (
int) src_pixels[fail_offset],
158 (
int)
dither[(fail_offset + fail_offset) & 7],
159 (
int) dst0[fail_offset],
160 (
int) dst1[fail_offset]);
174 int fsi, osi, isi,
i, j;
176 #define LARGEST_FILTER 16
178 const int filter_sizes[] = {2, 4, 8, 16};
179 const int FILTER_SIZES =
sizeof(filter_sizes)/
sizeof(filter_sizes[0]);
180 #define LARGEST_INPUT_SIZE 512
181 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
182 const char *accurate_str = (accurate) ?
"accurate" :
"approximate";
185 int filterSize,
const int16_t **
src, uint8_t *dest,
198 uint8_t d_val =
rnd();
213 for(osi = 0; osi < 64; osi += 16){
228 for (
i = 0;
i < filter_sizes[fsi]; ++
i)
229 filter_coeff[
i] = -((1 << 12) / (filter_sizes[fsi] - 1));
230 filter_coeff[
rnd() % filter_sizes[fsi]] = (1 << 13) - 1;
233 vFilterData =
av_malloc((filter_sizes[fsi] + 2) *
sizeof(
union VFilterData));
234 memset(vFilterData, 0, (filter_sizes[fsi] + 2) *
sizeof(
union VFilterData));
235 for (
i = 0;
i < filter_sizes[fsi]; ++
i) {
237 vFilterData[
i].src =
src[
i] - osi;
238 for(j = 0; j < 4; ++j)
239 vFilterData[
i].
coeff[j + 4] = filter_coeff[
i];
241 if (
check_func(
c->yuv2planeX,
"yuv2yuvX_%d%s_%d_%d_%d_%s",
bit_depth, (
bit_depth == 8) ?
"" : (
isBE(dst_pix_format) ?
"BE" :
"LE"), filter_sizes[fsi], osi, dstW, accurate_str)) {
243 const int16_t *
filter =
c->use_mmx_vfilter ? (
const int16_t*)vFilterData : &filter_coeff[0];
247 if (
c->dstBpc == 8) {
254 if (cmp_off_by_n_8((uint8_t*)dst0, (uint8_t*)dst1,
LARGEST_INPUT_SIZE, accurate ? 0 : 2)) {
256 printf(
"failed: yuv2yuvX_%d_%d_%d_%d_%s\n",
bit_depth, filter_sizes[fsi], osi, dstW, accurate_str);
260 call_ref(&filter_coeff[0], filter_sizes[fsi],
src, (uint8_t*)dst0, dstW - osi,
dither, osi);
261 call_new(&filter_coeff[0], filter_sizes[fsi],
src, (uint8_t*)dst1, dstW - osi,
dither, osi);
265 printf(
"failed: yuv2yuvX_%d%s_%d_%d_%d_%s\n",
bit_depth,
isBE(dst_pix_format) ?
"BE" :
"LE", filter_sizes[fsi], osi, dstW, accurate_str);
286 #define LARGEST_FILTER 16
287 const int filter_sizes[] = {2, 4, 8, 16};
288 #define LARGEST_INPUT_SIZE 512
289 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
290 const char *accurate_str = (accurate) ?
"accurate" :
"approximate";
293 const uint8_t *chrDither,
const int16_t *chrFilter,
294 int chrFilterSize,
const int16_t **chrUSrc,
295 const int16_t **chrVSrc, uint8_t *dest,
int dstW);
304 uint8_t d_val =
rnd();
325 const int filter_size = filter_sizes[fsi];
326 for (
int i = 0;
i < filter_size;
i++)
327 filter_coeff[
i] = -((1 << 12) / (filter_size - 1));
328 filter_coeff[
rnd() % filter_size] = (1 << 13) - 1;
330 if (
check_func(
c->yuv2nv12cX,
"yuv2nv12cX_%d_%d_%s", filter_size, dstW, accurate_str)){
337 if (cmp_off_by_n_8(dst0, dst1, dstW * 2 *
sizeof(dst0[0]), accurate ? 0 : 2)) {
339 printf(
"failed: yuv2nv12wX_%d_%d_%s\n", filter_size, dstW, accurate_str);
340 show_differences_8(dst0, dst1, dstW * 2 *
sizeof(dst0[0]));
350 #undef LARGEST_FILTER
351 #undef LARGEST_INPUT_SIZE
354 #define SRC_PIXELS 512
358 #define MAX_FILTER_WIDTH 40
359 #define FILTER_SIZES 6
360 static const int filter_sizes[
FILTER_SIZES] = { 4, 8, 12, 16, 32, 40 };
362 #define HSCALE_PAIRS 2
368 #define LARGEST_INPUT_SIZE 512
369 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
371 int i, j, fsi, hpi,
width, dstWi;
389 const uint8_t *
src,
const int16_t *
filter,
390 const int32_t *filterPos,
int filterSize);
402 width = filter_sizes[fsi];
404 c->srcBpc = hscale_pairs[hpi][0];
405 c->dstBpc = hscale_pairs[hpi][1];
406 c->hLumFilterSize =
c->hChrFilterSize =
width;
425 for (j = 0; j <
width; j++) {
445 memset(dst0, 0,
SRC_PIXELS *
sizeof(dst0[0]));
446 memset(dst1, 0,
SRC_PIXELS *
sizeof(dst1[0]));
450 if (memcmp(dst0, dst1,
sws->
dst_w *
sizeof(dst0[0])))