91 #if CONFIG_MPEG4_DECODER
107 #define AANSCALE_BITS 12
110 #define NB_ITS_SPEED 50000
119 memset(block, 0, 64 *
sizeof(*block));
123 for (i = 0; i < 64; i++)
124 block[i] = (
av_lfg_get(prng) % (2*vals)) -vals;
127 for (i = 0; i < 64; i++)
133 for (i = 0; i < j; i++) {
135 block[idx] =
av_lfg_get(prng) % (2*vals) -vals;
139 block[ 0] =
av_lfg_get(prng) % (16*vals) - (8*vals);
140 block[63] = (block[0] & 1) ^ 1;
157 for (i = 0; i < 64; i++)
158 dst[(i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2)] = src[i];
161 for (i = 0; i < 64; i++)
162 dst[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = src[i];
165 for (i = 0; i < 64; i++)
166 dst[(i>>3) | ((i<<3)&0x38)] = src[i];
169 for (i = 0; i < 64; i++)
180 int64_t err2, ti, ti1, it1, err_sum = 0;
181 int64_t sysErr[64], sysErrMax = 0;
183 int blockSumErrMax = 0, blockSumErr;
185 const int vals=1<<
bits;
193 for (i = 0; i < 64; i++)
195 for (it = 0; it <
NB_ITS; it++) {
202 if (!strcmp(dct->
name,
"IJG-AAN-INT")) {
203 for (i = 0; i < 64; i++) {
210 if (!strcmp(dct->
name,
"PR-SSE2"))
211 for (i = 0; i < 64; i++)
215 for (i = 0; i < 64; i++) {
222 sysErr[i] +=
block[i] - block1[i];
224 if (abs(
block[i]) > maxout)
225 maxout = abs(
block[i]);
227 if (blockSumErrMax < blockSumErr)
228 blockSumErrMax = blockSumErr;
230 for (i = 0; i < 64; i++)
231 sysErrMax =
FFMAX(sysErrMax,
FFABS(sysErr[i]));
233 for (i = 0; i < 64; i++) {
236 printf(
"%7d ", (
int) sysErr[i]);
240 omse = (double) err2 / NB_ITS / 64;
241 ome = (double) err_sum / NB_ITS / 64;
243 spec_err = is_idct && (err_inf > 1 || omse > 0.02 || fabs(ome) > 0.0015);
245 printf(
"%s %s: max_err=%d omse=%0.8f ome=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n",
246 is_idct ?
"IDCT" :
"DCT", dct->
name, err_inf,
247 omse, ome, (
double) sysErrMax / NB_ITS,
248 maxout, blockSumErrMax);
250 if (spec_err && !dct->
nonspec) {
273 }
while (ti1 < 1000000);
275 printf(
"%s %s: %0.1f kdct/s\n", is_idct ?
"IDCT" :
"DCT", dct->
name,
276 (
double) it1 * 1000.0 / (
double) ti1);
287 static double c8[8][8];
288 static double c4[4][4];
289 double block1[64], block2[64], block3[64];
296 for (i = 0; i < 8; i++) {
298 for (j = 0; j < 8; j++) {
299 s = (i == 0) ? sqrt(1.0 / 8.0) : sqrt(1.0 / 4.0);
300 c8[i][j] = s * cos(
M_PI * i * (j + 0.5) / 8.0);
301 sum += c8[i][j] * c8[i][j];
305 for (i = 0; i < 4; i++) {
307 for (j = 0; j < 4; j++) {
308 s = (i == 0) ? sqrt(1.0 / 4.0) : sqrt(1.0 / 2.0);
309 c4[i][j] = s * cos(
M_PI * i * (j + 0.5) / 4.0);
310 sum += c4[i][j] * c4[i][j];
317 for (i = 0; i < 4; i++) {
318 for (j = 0; j < 8; j++) {
319 block1[8 * (2 * i) + j] =
320 (block[8 * (2 * i) + j] + block[8 * (2 * i + 1) + j]) *
s;
321 block1[8 * (2 * i + 1) + j] =
322 (block[8 * (2 * i) + j] - block[8 * (2 * i + 1) + j]) *
s;
327 for (i = 0; i < 8; i++) {
328 for (j = 0; j < 8; j++) {
330 for (k = 0; k < 8; k++)
331 sum += c8[k][j] * block1[8 * i + k];
332 block2[8 * i + j] = sum;
337 for (i = 0; i < 8; i++) {
338 for (j = 0; j < 4; j++) {
341 for (k = 0; k < 4; k++)
342 sum += c4[k][j] * block2[8 * (2 * k) + i];
343 block3[8 * (2 * j) + i] = sum;
347 for (k = 0; k < 4; k++)
348 sum += c4[k][j] * block2[8 * (2 * k + 1) + i];
349 block3[8 * (2 * j + 1) + i] = sum;
354 for (i = 0; i < 8; i++) {
355 for (j = 0; j < 8; j++) {
356 v = block3[8 * i + j];
358 else if (v > 255) v = 255;
359 dest[i * linesize + j] = (int)
rint(v);
365 void (*idct248_put)(
uint8_t *dest,
int line_size,
369 int it, i, it1, ti, ti1, err_max, v;
377 for (it = 0; it <
NB_ITS; it++) {
379 for (i = 0; i < 64; i++)
383 for (i = 0; i < 64; i++)
387 for (i = 0; i < 64; i++)
391 for (i = 0; i < 64; i++) {
418 printf(
"%s %s: err_inf=%d\n", 1 ?
"IDCT248" :
"DCT248", name, err_max);
427 for (i = 0; i < 64; i++)
434 }
while (ti1 < 1000000);
436 printf(
"%s %s: %0.1f kdct/s\n", 1 ?
"IDCT248" :
"DCT248", name,
437 (
double) it1 * 1000.0 / (
double) ti1);
442 printf(
"dct-test [-i] [<test-number>] [<bits>]\n"
443 "test-number 0 -> test with random matrixes\n"
444 " 1 -> test with random sparse matrixes\n"
445 " 2 -> do 3. test from mpeg4 std\n"
446 "bits Number of time domain bits to use, 8 is default\n"
447 "-i test IDCT implementations\n"
448 "-4 test IDCT248 implementations\n"
456 int main(
int argc,
char **argv)
458 int test_idct = 0, test_248_dct = 0;
468 c =
getopt(argc, argv,
"ih4t");
489 test = atoi(argv[
optind]);
490 if(optind+1 < argc) bits= atoi(argv[optind+1]);
492 printf(
"ffmpeg DCT/IDCT test\n");
500 err |=
dct_error(&idct_tab[i], test, test_idct, speed, bits);
502 for (i = 0; idct_tab_arch[i].
name; i++)
503 if (!(~cpu_flags & idct_tab_arch[i].
cpu_flag))
504 err |=
dct_error(&idct_tab_arch[i], test, test_idct, speed, bits);
509 err |=
dct_error(&fdct_tab[i], test, test_idct, speed, bits);
511 for (i = 0; fdct_tab_arch[i].
name; i++)
512 if (!(~cpu_flags & fdct_tab_arch[i].
cpu_flag))
513 err |=
dct_error(&fdct_tab_arch[i], test, test_idct, speed, bits);
519 printf(
"Error: %d.\n", err);
void ff_fdct_ifast(int16_t *data)
static const struct algo idct_tab[]
static uint8_t img_dest[64]
static av_cold int init(AVCodecContext *avctx)
static const struct algo fdct_tab_arch[]
#define DECLARE_ALIGNED(n, t, v)
int main(int argc, char **argv)
static int permute_x86(int16_t dst[64], const int16_t src[64], enum idct_permutation_type perm_type)
av_cold void ff_ref_dct_init(void)
Initialize the double precision discrete cosine transform functions fdct & idct.
void ff_faanidct(int16_t block[64])
void ff_simple_idct248_put(uint8_t *dest, int line_size, int16_t *block)
const uint16_t ff_aanscales[64]
static void permute(int16_t dst[64], const int16_t src[64], enum idct_permutation_type perm_type)
void ff_prores_idct(int16_t *block, const int16_t *qmat)
Special version of ff_simple_idct_10() which does dequantization and scales by a factor of 2 more bet...
static int dct_error(const struct algo *dct, int test, int is_idct, int speed, const int bits)
static const struct algo fdct_tab[]
static void idct248_ref(uint8_t *dest, int linesize, int16_t *block)
static void test(const char *pattern, const char *host)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void ff_prores_idct_wrap(int16_t *dst)
void ff_simple_idct_10(int16_t *block)
#define FF_ARRAY_ELEMS(a)
void ff_jpeg_fdct_islow_8(int16_t *data)
void ff_j_rev_dct(int16_t *data)
void ff_faandct(int16_t *data)
void ff_simple_idct_12(int16_t *block)
static int getopt(int argc, char *argv[], char *opts)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
void ff_ref_fdct(short *block)
Transform 8x8 block of data with a double precision forward DCT This is a reference implementation...
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
void ff_xvid_idct(int16_t *const in)
static int16_t block1[64]
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
AAN (Arai, Agui and Nakajima) (I)DCT tables.
static uint8_t img_dest1[64]
common internal and external API header
static int ref[MAX_W *MAX_W]
#define LOCAL_ALIGNED(a, t, v,...)
enum idct_permutation_type perm_type
static void idct248_error(const char *name, void(*idct248_put)(uint8_t *dest, int line_size, int16_t *block), int speed)
void ff_ref_idct(short *block)
Transform 8x8 block of data with a double precision inverse DCT This is a reference implementation...
static const struct algo idct_tab_arch[]
void(* func)(int16_t *block)
static void init_block(int16_t block[64], int test, int is_idct, AVLFG *prng, int vals)
void ff_simple_idct_8(int16_t *block)