* (c) 2001 Fabrice Bellard
* 2007 Marc Hoffman <marc.hoffman@analog.com>
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
{ "REF-DBL", ff_ref_fdct, NO_PERM },
{ "FAAN", ff_faandct, FAAN_SCALE },
{ "IJG-AAN-INT", fdct_ifast, SCALE_PERM },
- { "IJG-LLM-INT", ff_jpeg_fdct_islow, NO_PERM },
+ { "IJG-LLM-INT", ff_jpeg_fdct_islow_8, NO_PERM },
#if HAVE_MMX
{ "MMX", ff_fdct_mmx, NO_PERM, AV_CPU_FLAG_MMX },
#endif
}
-static int dct_error(const struct algo *dct, int test, int is_idct, int speed)
+static void init_block(DCTELEM block[64], int test, int is_idct, AVLFG *prng, int vals)
+{
+ int i, j;
+
+ memset(block, 0, 64 * sizeof(*block));
+
+ switch (test) {
+ case 0:
+ for (i = 0; i < 64; i++)
+ block[i] = (av_lfg_get(prng) % (2*vals)) -vals;
+ if (is_idct) {
+ ff_ref_fdct(block);
+ for (i = 0; i < 64; i++)
+ block[i] >>= 3;
+ }
+ break;
+ case 1:
+ j = av_lfg_get(prng) % 10 + 1;
+ for (i = 0; i < j; i++)
+ block[av_lfg_get(prng) % 64] = av_lfg_get(prng) % (2*vals) -vals;
+ break;
+ case 2:
+ block[ 0] = av_lfg_get(prng) % (16*vals) - (8*vals);
+ block[63] = (block[0] & 1) ^ 1;
+ break;
+ }
+}
+
+static void permute(DCTELEM dst[64], const DCTELEM src[64], int perm)
+{
+ int i;
+
+ if (perm == MMX_PERM) {
+ for (i = 0; i < 64; i++)
+ dst[idct_mmx_perm[i]] = src[i];
+ } else if (perm == MMX_SIMPLE_PERM) {
+ for (i = 0; i < 64; i++)
+ dst[idct_simple_mmx_perm[i]] = src[i];
+ } else if (perm == SSE2_PERM) {
+ for (i = 0; i < 64; i++)
+ dst[(i & 0x38) | idct_sse2_row_perm[i & 7]] = src[i];
+ } else if (perm == PARTTRANS_PERM) {
+ for (i = 0; i < 64; i++)
+ dst[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = src[i];
+ } else {
+ for (i = 0; i < 64; i++)
+ dst[i] = src[i];
+ }
+}
+
+static int dct_error(const struct algo *dct, int test, int is_idct, int speed, const int bits)
{
void (*ref)(DCTELEM *block) = is_idct ? ff_ref_idct : ff_ref_fdct;
int it, i, scale;
int maxout = 0;
int blockSumErrMax = 0, blockSumErr;
AVLFG prng;
+ const int vals=1<<bits;
double omse, ome;
int spec_err;
for (i = 0; i < 64; i++)
sysErr[i] = 0;
for (it = 0; it < NB_ITS; it++) {
- for (i = 0; i < 64; i++)
- block1[i] = 0;
- switch (test) {
- case 0:
- for (i = 0; i < 64; i++)
- block1[i] = (av_lfg_get(&prng) % 512) - 256;
- if (is_idct) {
- ff_ref_fdct(block1);
- for (i = 0; i < 64; i++)
- block1[i] >>= 3;
- }
- break;
- case 1: {
- int num = av_lfg_get(&prng) % 10 + 1;
- for (i = 0; i < num; i++)
- block1[av_lfg_get(&prng) % 64] =
- av_lfg_get(&prng) % 512 - 256;
- }
- break;
- case 2:
- block1[0] = av_lfg_get(&prng) % 4096 - 2048;
- block1[63] = (block1[0] & 1) ^ 1;
- break;
- }
-
- if (dct->format == MMX_PERM) {
- for (i = 0; i < 64; i++)
- block[idct_mmx_perm[i]] = block1[i];
- } else if (dct->format == MMX_SIMPLE_PERM) {
- for (i = 0; i < 64; i++)
- block[idct_simple_mmx_perm[i]] = block1[i];
- } else if (dct->format == SSE2_PERM) {
- for (i = 0; i < 64; i++)
- block[(i & 0x38) | idct_sse2_row_perm[i & 7]] = block1[i];
- } else if (dct->format == PARTTRANS_PERM) {
- for (i = 0; i < 64; i++)
- block[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = block1[i];
- } else {
- for (i = 0; i < 64; i++)
- block[i] = block1[i];
- }
+ init_block(block1, test, is_idct, &prng, vals);
+ permute(block, block1, dct->format);
dct->func(block);
mmx_emms();
spec_err = is_idct && (err_inf > 1 || omse > 0.02 || fabs(ome) > 0.0015);
- printf("%s %s: ppe=%d omse=%0.8f ome=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n",
+ printf("%s %s: max_err=%d omse=%0.8f ome=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n",
is_idct ? "IDCT" : "DCT", dct->name, err_inf,
omse, ome, (double) sysErrMax / NB_ITS,
maxout, blockSumErrMax);
return 0;
/* speed test */
- for (i = 0; i < 64; i++)
- block1[i] = 0;
- switch (test) {
- case 0:
- for (i = 0; i < 64; i++)
- block1[i] = av_lfg_get(&prng) % 512 - 256;
- if (is_idct) {
- ff_ref_fdct(block1);
- for (i = 0; i < 64; i++)
- block1[i] >>= 3;
- }
- break;
- case 1:
- case 2:
- block1[0] = av_lfg_get(&prng) % 512 - 256;
- block1[1] = av_lfg_get(&prng) % 512 - 256;
- block1[2] = av_lfg_get(&prng) % 512 - 256;
- block1[3] = av_lfg_get(&prng) % 512 - 256;
- break;
- }
-
- if (dct->format == MMX_PERM) {
- for (i = 0; i < 64; i++)
- block[idct_mmx_perm[i]] = block1[i];
- } else if (dct->format == MMX_SIMPLE_PERM) {
- for (i = 0; i < 64; i++)
- block[idct_simple_mmx_perm[i]] = block1[i];
- } else {
- for (i = 0; i < 64; i++)
- block[i] = block1[i];
- }
+ init_block(block, test, is_idct, &prng, vals);
+ permute(block1, block, dct->format);
ti = gettime();
it1 = 0;
do {
for (it = 0; it < NB_ITS_SPEED; it++) {
- for (i = 0; i < 64; i++)
- block[i] = block1[i];
+ memcpy(block, block1, sizeof(block));
dct->func(block);
}
it1 += NB_ITS_SPEED;
if (v > err_max)
err_max = v;
}
+#if 0
+ printf("ref=\n");
+ for(i=0;i<8;i++) {
+ int j;
+ for(j=0;j<8;j++) {
+ printf(" %3d", img_dest1[i*8+j]);
+ }
+ printf("\n");
+ }
+
+ printf("out=\n");
+ for(i=0;i<8;i++) {
+ int j;
+ for(j=0;j<8;j++) {
+ printf(" %3d", img_dest[i*8+j]);
+ }
+ printf("\n");
+ }
+#endif
}
printf("%s %s: err_inf=%d\n", 1 ? "IDCT248" : "DCT248", name, err_max);
static void help(void)
{
- printf("dct-test [-i] [<test-number>]\n"
+ printf("dct-test [-i] [<test-number>] [<bits>]\n"
"test-number 0 -> test with random matrixes\n"
" 1 -> test with random sparse matrixes\n"
" 2 -> do 3. test from mpeg4 std\n"
+ "bits Number of time domain bits to use, 8 is default\n"
"-i test IDCT implementations\n"
"-4 test IDCT248 implementations\n"
"-t speed test\n");
int test = 1;
int speed = 0;
int err = 0;
+ int bits=8;
cpu_flags = av_get_cpu_flags();
if (optind < argc)
test = atoi(argv[optind]);
+ if(optind+1 < argc) bits= atoi(argv[optind+1]);
printf("ffmpeg DCT/IDCT test\n");
const struct algo *algos = test_idct ? idct_tab : fdct_tab;
for (i = 0; algos[i].name; i++)
if (!(~cpu_flags & algos[i].mm_support)) {
- err |= dct_error(&algos[i], test, test_idct, speed);
+ err |= dct_error(&algos[i], test, test_idct, speed, bits);
}
}