diff options
Diffstat (limited to 'libavcodec/dct-test.c')
-rw-r--r-- | libavcodec/dct-test.c | 93 |
1 files changed, 70 insertions, 23 deletions
diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index f337576..30eca3e 100644 --- a/libavcodec/dct-test.c +++ b/libavcodec/dct-test.c @@ -2,20 +2,20 @@ * (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 */ @@ -65,10 +65,24 @@ static const struct algo fdct_tab[] = { #endif /* CONFIG_FAANDCT */ }; +static void ff_prores_idct_wrap(int16_t *dst){ + DECLARE_ALIGNED(16, static int16_t, qmat)[64]; + int i; + + for(i=0; i<64; i++){ + qmat[i]=4; + } + ff_prores_idct(dst, qmat); + for(i=0; i<64; i++) { + dst[i] -= 512; + } +} + static const struct algo idct_tab[] = { { "REF-DBL", ff_ref_idct, FF_IDCT_PERM_NONE }, { "INT", ff_j_rev_dct, FF_IDCT_PERM_LIBMPEG2 }, { "SIMPLE-C", ff_simple_idct_8, FF_IDCT_PERM_NONE }, + { "PR-C", ff_prores_idct_wrap, FF_IDCT_PERM_NONE, 0, 1 }, #if CONFIG_FAANIDCT { "FAANI", ff_faanidct, FF_IDCT_PERM_NONE }, #endif /* CONFIG_FAANIDCT */ @@ -84,8 +98,8 @@ static const struct algo idct_tab[] = { #elif ARCH_X86 #include "x86/dct-test.c" #else -static const struct algo fdct_tab_arch[] = { 0 }; -static const struct algo idct_tab_arch[] = { 0 }; +static const struct algo fdct_tab_arch[] = { { 0 } }; +static const struct algo idct_tab_arch[] = { { 0 } }; #endif #define AANSCALE_BITS 12 @@ -96,7 +110,7 @@ static const struct algo idct_tab_arch[] = { 0 }; DECLARE_ALIGNED(16, static int16_t, block)[64]; DECLARE_ALIGNED(8, static int16_t, block1)[64]; -static void init_block(int16_t block[64], int test, int is_idct, AVLFG *prng) +static void init_block(int16_t block[64], int test, int is_idct, AVLFG *prng, int vals) { int i, j; @@ -105,7 +119,7 @@ static void init_block(int16_t block[64], int test, int is_idct, AVLFG *prng) switch (test) { case 0: for (i = 0; i < 64; i++) - block[i] = (av_lfg_get(prng) % 512) - 256; + block[i] = (av_lfg_get(prng) % (2*vals)) -vals; if (is_idct) { ff_ref_fdct(block); for (i = 0; i < 64; i++) @@ -114,11 +128,13 @@ static void init_block(int16_t block[64], int test, int is_idct, AVLFG *prng) 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) % 512 - 256; + for (i = 0; i < j; i++) { + int idx = av_lfg_get(prng) % 64; + block[idx] = av_lfg_get(prng) % (2*vals) -vals; + } break; case 2: - block[ 0] = av_lfg_get(prng) % 4096 - 2048; + block[ 0] = av_lfg_get(prng) % (16*vals) - (8*vals); block[63] = (block[0] & 1) ^ 1; break; } @@ -143,6 +159,10 @@ static void permute(int16_t dst[64], const int16_t src[64], for (i = 0; i < 64; i++) dst[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = src[i]; break; + case FF_IDCT_PERM_TRANSPOSE: + for (i = 0; i < 64; i++) + dst[(i>>3) | ((i<<3)&0x38)] = src[i]; + break; default: for (i = 0; i < 64; i++) dst[i] = src[i]; @@ -150,7 +170,7 @@ static void permute(int16_t dst[64], const int16_t src[64], } } -static int dct_error(const struct algo *dct, int test, int is_idct, int speed) +static int dct_error(const struct algo *dct, int test, int is_idct, int speed, const int bits) { void (*ref)(int16_t *block) = is_idct ? ff_ref_idct : ff_ref_fdct; int it, i, scale; @@ -160,6 +180,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) int maxout = 0; int blockSumErrMax = 0, blockSumErr; AVLFG prng; + const int vals=1<<bits; double omse, ome; int spec_err; @@ -170,7 +191,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) for (i = 0; i < 64; i++) sysErr[i] = 0; for (it = 0; it < NB_ITS; it++) { - init_block(block1, test, is_idct, &prng); + init_block(block1, test, is_idct, &prng, vals); permute(block, block1, dct->perm_type); dct->func(block); @@ -184,6 +205,9 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) } ref(block1); + if (!strcmp(dct->name, "PR-SSE2")) + for (i = 0; i < 64; i++) + block1[i] = av_clip(block1[i], 4-512, 1019-512); blockSumErr = 0; for (i = 0; i < 64; i++) { @@ -216,7 +240,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) 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); @@ -228,7 +252,8 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) return 0; /* speed test */ - init_block(block, test, is_idct, &prng); + + init_block(block, test, is_idct, &prng, vals); permute(block1, block, dct->perm_type); ti = av_gettime_relative(); @@ -238,10 +263,10 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) memcpy(block, block1, sizeof(block)); dct->func(block); } + emms_c(); it1 += NB_ITS_SPEED; ti1 = av_gettime_relative() - ti; } while (ti1 < 1000000); - emms_c(); printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name, (double) it1 * 1000.0 / (double) ti1); @@ -366,6 +391,25 @@ static void idct248_error(const char *name, 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); @@ -380,10 +424,10 @@ static void idct248_error(const char *name, block[i] = block1[i]; idct248_put(img_dest, 8, block); } + emms_c(); it1 += NB_ITS_SPEED; ti1 = av_gettime_relative() - ti; } while (ti1 < 1000000); - emms_c(); printf("%s %s: %0.1f kdct/s\n", 1 ? "IDCT248" : "DCT248", name, (double) it1 * 1000.0 / (double) ti1); @@ -391,10 +435,11 @@ static void idct248_error(const char *name, 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"); @@ -411,6 +456,7 @@ int main(int argc, char **argv) int test = 1; int speed = 0; int err = 0; + int bits=8; ff_ref_dct_init(); @@ -437,8 +483,9 @@ int main(int argc, char **argv) if (optind < argc) test = atoi(argv[optind]); + if(optind+1 < argc) bits= atoi(argv[optind+1]); - printf("Libav DCT/IDCT test\n"); + printf("ffmpeg DCT/IDCT test\n"); if (test_248_dct) { idct248_error("SIMPLE-C", ff_simple_idct248_put, speed); @@ -446,20 +493,20 @@ int main(int argc, char **argv) const int cpu_flags = av_get_cpu_flags(); if (test_idct) { for (i = 0; i < FF_ARRAY_ELEMS(idct_tab); i++) - err |= dct_error(&idct_tab[i], test, test_idct, speed); + err |= dct_error(&idct_tab[i], test, test_idct, speed, bits); for (i = 0; idct_tab_arch[i].name; i++) if (!(~cpu_flags & idct_tab_arch[i].cpu_flag)) - err |= dct_error(&idct_tab_arch[i], test, test_idct, speed); + err |= dct_error(&idct_tab_arch[i], test, test_idct, speed, bits); } #if CONFIG_FDCTDSP else { for (i = 0; i < FF_ARRAY_ELEMS(fdct_tab); i++) - err |= dct_error(&fdct_tab[i], test, test_idct, speed); + err |= dct_error(&fdct_tab[i], test, test_idct, speed, bits); for (i = 0; fdct_tab_arch[i].name; i++) if (!(~cpu_flags & fdct_tab_arch[i].cpu_flag)) - err |= dct_error(&fdct_tab_arch[i], test, test_idct, speed); + err |= dct_error(&fdct_tab_arch[i], test, test_idct, speed, bits); } #endif /* CONFIG_FDCTDSP */ } |