31static const uint32_t
pixel_mask[5] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff, 0x0fff0fff, 0x3fff3fff };
32static const uint32_t
pixel_mask_lf[3] = { 0xff0fff0f, 0x01ff000f, 0x03ff000f };
34#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
35#define SIZEOF_COEF (2 * ((bit_depth + 7) / 8))
36#define PIXEL_STRIDE 16
38#define randomize_buffers(idx) \
41 uint32_t mask = pixel_mask[(idx)]; \
42 for (y = 0; y < sz; y++) { \
43 for (x = 0; x < PIXEL_STRIDE; x += 4) { \
44 AV_WN32A(src + y * PIXEL_STRIDE + x, rnd() & mask); \
45 AV_WN32A(dst + y * PIXEL_STRIDE + x, rnd() & mask); \
47 for (x = 0; x < sz; x++) { \
48 if (bit_depth == 8) { \
49 coef[y * sz + x] = src[y * PIXEL_STRIDE + x] - \
50 dst[y * PIXEL_STRIDE + x]; \
52 ((int32_t *)coef)[y * sz + x] = \
53 ((uint16_t *)src)[y * (PIXEL_STRIDE/2) + x] - \
54 ((uint16_t *)dst)[y * (PIXEL_STRIDE/2) + x]; \
60#define dct4x4_impl(size, dctcoef) \
61static void dct4x4_##size(dctcoef *coef) \
65 for (i = 0; i < 4; i++) { \
66 const int z0 = coef[i*4 + 0] + coef[i*4 + 3]; \
67 const int z1 = coef[i*4 + 1] + coef[i*4 + 2]; \
68 const int z2 = coef[i*4 + 0] - coef[i*4 + 3]; \
69 const int z3 = coef[i*4 + 1] - coef[i*4 + 2]; \
70 tmp[i + 4*0] = z0 + z1; \
71 tmp[i + 4*1] = 2*z2 + z3; \
72 tmp[i + 4*2] = z0 - z1; \
73 tmp[i + 4*3] = z2 - 2*z3; \
75 for (i = 0; i < 4; i++) { \
76 const int z0 = tmp[i*4 + 0] + tmp[i*4 + 3]; \
77 const int z1 = tmp[i*4 + 1] + tmp[i*4 + 2]; \
78 const int z2 = tmp[i*4 + 0] - tmp[i*4 + 3]; \
79 const int z3 = tmp[i*4 + 1] - tmp[i*4 + 2]; \
80 coef[i*4 + 0] = z0 + z1; \
81 coef[i*4 + 1] = 2*z2 + z3; \
82 coef[i*4 + 2] = z0 - z1; \
83 coef[i*4 + 3] = z2 - 2*z3; \
85 for (y = 0; y < 4; y++) { \
86 for (x = 0; x < 4; x++) { \
87 const int64_t scale[] = { 13107 * 10, 8066 * 13, 5243 * 16 }; \
88 const int idx = (y & 1) + (x & 1); \
89 coef[y*4 + x] = (coef[y*4 + x] * scale[idx] + (1 << 14)) >> 15; \
94#define DCT8_1D(src, srcstride, dst, dststride) do { \
95 const int a0 = (src)[srcstride * 0] + (src)[srcstride * 7]; \
96 const int a1 = (src)[srcstride * 0] - (src)[srcstride * 7]; \
97 const int a2 = (src)[srcstride * 1] + (src)[srcstride * 6]; \
98 const int a3 = (src)[srcstride * 1] - (src)[srcstride * 6]; \
99 const int a4 = (src)[srcstride * 2] + (src)[srcstride * 5]; \
100 const int a5 = (src)[srcstride * 2] - (src)[srcstride * 5]; \
101 const int a6 = (src)[srcstride * 3] + (src)[srcstride * 4]; \
102 const int a7 = (src)[srcstride * 3] - (src)[srcstride * 4]; \
103 const int b0 = a0 + a6; \
104 const int b1 = a2 + a4; \
105 const int b2 = a0 - a6; \
106 const int b3 = a2 - a4; \
107 const int b4 = a3 + a5 + (a1 + (a1 >> 1)); \
108 const int b5 = a1 - a7 - (a5 + (a5 >> 1)); \
109 const int b6 = a1 + a7 - (a3 + (a3 >> 1)); \
110 const int b7 = a3 - a5 + (a7 + (a7 >> 1)); \
111 (dst)[dststride * 0] = b0 + b1; \
112 (dst)[dststride * 1] = b4 + (b7 >> 2); \
113 (dst)[dststride * 2] = b2 + (b3 >> 1); \
114 (dst)[dststride * 3] = b5 + (b6 >> 2); \
115 (dst)[dststride * 4] = b0 - b1; \
116 (dst)[dststride * 5] = b6 - (b5 >> 2); \
117 (dst)[dststride * 6] = (b2 >> 1) - b3; \
118 (dst)[dststride * 7] = (b4 >> 2) - b7; \
121#define dct8x8_impl(size, dctcoef) \
122static void dct8x8_##size(dctcoef *coef) \
126 for (i = 0; i < 8; i++) \
127 DCT8_1D(coef + i, 8, tmp + i, 8); \
129 for (i = 0; i < 8; i++) \
130 DCT8_1D(tmp + 8*i, 1, coef + i, 8); \
132 for (y = 0; y < 8; y++) { \
133 for (x = 0; x < 8; x++) { \
134 static const int scale[] = { \
135 13107 * 20, 11428 * 18, 20972 * 32, \
136 12222 * 19, 16777 * 25, 15481 * 24, \
138 static const int idxmap[] = { \
144 const int idx = idxmap[(y & 3) * 4 + (x & 3)]; \
145 coef[y*8 + x] = ((int64_t)coef[y*8 + x] * \
146 scale[idx] + (1 << 17)) >> 18; \
177 static const int depths[5] = { 8, 9, 10, 12, 14 };
193 for (dc = 0; dc <= 2; dc++) {
194 for (sz = 4; sz <= 8; sz += 4) {
195 void (*
idct)(uint8_t *, int16_t *, ptrdiff_t) =
NULL;
196 const char fmts[3][28] = {
197 "idct%d_add_%dbpp",
"idct%d_dc_add_%dbpp",
198 "add_pixels%d_%dbpp",
208 switch ((sz << 2) | dc) {
209 case (4 << 2) | 0:
idct =
h.idct_add;
break;
210 case (4 << 2) | 1:
idct =
h.idct_dc_add;
break;
211 case (4 << 2) | 2:
idct =
h.add_pixels4_clear;
break;
212 case (8 << 2) | 0:
idct =
h.idct8_add;
break;
213 case (8 << 2) | 1:
idct =
h.idct8_dc_add;
break;
214 case (8 << 2) | 2:
idct =
h.add_pixels8_clear;
break;
219 uint8_t *dst1 = dst1_base +
align;
258 void (*
idct)(uint8_t *,
const int *, int16_t *, ptrdiff_t,
const uint8_t[]) =
NULL;
260 int sz = 4, intra = 0;
261 int block_offset[16] = { 0 };
268 idct =
h.idct_add16intra;
269 name =
"idct_add16intra";
278 memset(nnzc, 0, 15 * 8);
280 for (
i = 0;
i < 16 * 16;
i += sz * sz) {
281 uint8_t
src[8 * 8 * 2];
282 uint8_t
dst[8 * 8 * 2];
283 int16_t coef[8 * 8 * 2];
285 int block_y = (
index / 16) * sz;
286 int block_x =
index % 16;
296 for (y = 0; y < sz; y++)
305 if (intra && nnz == 1)
308 nnzc[
scan8[
i / 16]] = nnz;
330 static const int depths[5] = { 8, 9, 10, 12, 14 };
339 declare_func(
void, int16_t *output, int16_t *input,
int qmul);
347 void *
src, *dst_ref, *dst_new;
352 for (
int j = 0; j < 16; j++)
353 src16[j] = (
rnd() % 512) - 256;
358 for (
int j = 0; j < 16; j++)
385 int alphas[
N], betas[
N];
389 int alpha,
int beta, int8_t *tc0);
394 for (
int i =
N,
a = 255,
c = 250; --
i >= 0;) {
397 tc0[
i][0] = tc0[
i][3] = (
c + 6) / 10;
398 tc0[
i][1] = (
c + 7) / 15;
399 tc0[
i][2] = (
c + 9) / 20;
404#define CHECK_LOOP_FILTER(name, align, idc) \
406 if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \
407 for (int j = 0; j < N; ++j) { \
408 intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \
409 for (int i = 0; i < 1024; i += 4) { \
410 AV_WN32A(dst + i, rnd() & mask); \
412 memcpy(dst0, dst, 32 * 16 * 2); \
413 memcpy(dst1, dst, 32 * 16 * 2); \
415 call_ref(dst0 + off, 32, alphas[j], betas[j], tc0[j]); \
416 call_new(dst1 + off, 32, alphas[j], betas[j], tc0[j]); \
417 if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \
418 fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d " \
419 "tc0:{%d,%d,%d,%d}\n", j, alphas[j], betas[j], \
420 tc0[j][0], tc0[j][1], tc0[j][2], tc0[j][3]); \
423 bench_new(dst1 + off, 32, alphas[j], betas[j], tc0[j]);\
438#undef CHECK_LOOP_FILTER
452 int alphas[
N], betas[
N];
455 int alpha,
int beta);
460 for (
int i =
N,
a = 255; --
i >= 0;) {
466#define CHECK_LOOP_FILTER(name, align, idc) \
468 if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \
469 for (int j = 0; j < N; ++j) { \
470 intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \
471 for (int i = 0; i < 1024; i += 4) { \
472 AV_WN32A(dst + i, rnd() & mask); \
474 memcpy(dst0, dst, 32 * 16 * 2); \
475 memcpy(dst1, dst, 32 * 16 * 2); \
477 call_ref(dst0 + off, 32, alphas[j], betas[j]); \
478 call_new(dst1 + off, 32, alphas[j], betas[j]); \
479 if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \
480 fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d\n", \
481 j, alphas[j], betas[j]); \
484 bench_new(dst1 + off, 32, alphas[j], betas[j]); \
499#undef CHECK_LOOP_FILTER
514 report(
"loop_filter_intra");
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
static const uint8_t *BS_FUNC align(BSCTX *bc)
Skip bits to a byte boundary.
#define i(width, name, range_min, range_max)
#define checkasm_check_dctcoef(buf1, stride1, buf2, stride2,...)
common internal and external API header
#define declare_func_emms
H.264 decoder/parser shared code.
static const uint8_t scan8[16 *3+3]
static const int16_t alpha[]
static void idct(int16_t block[64])
av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
#define AV_CPU_FLAG_MMX
standard MMX
static const uint16_t mask[17]
#define LOCAL_ALIGNED_16(t, v,...)
#define FF_ARRAY_ELEMS(a)
Context for storing H.264 DSP functions.
void checkasm_check_h264dsp(void)
static void check_loop_filter(void)
static const uint32_t pixel_mask[5]
static void check_idct_multiple(void)
static void check_loop_filter_intra(void)
static void check_idct_dequant(void)
static const uint32_t pixel_mask_lf[3]
static void check_idct(void)
#define CHECK_LOOP_FILTER(name, align, idc)
static void dct8x8(int16_t *coef, int bit_depth)
#define dct4x4_impl(size, dctcoef)
#define dct8x8_impl(size, dctcoef)
#define randomize_buffers(idx)
static void dct4x4(int16_t *coef)