diff options
Diffstat (limited to 'libavcodec/dct-test.c')
-rw-r--r-- | libavcodec/dct-test.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c index 689aef8fa9..4bc59d3370 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 */ @@ -200,7 +200,8 @@ static inline void mmx_emms(void) #endif } -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)(DCTELEM *block) = is_idct ? ff_ref_idct : ff_ref_fdct; int it, i, scale; @@ -210,6 +211,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; @@ -225,7 +227,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) switch (test) { case 0: for (i = 0; i < 64; i++) - block1[i] = (av_lfg_get(&prng) % 512) - 256; + block1[i] = (av_lfg_get(&prng) % (2*vals)) -vals; if (is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) @@ -235,12 +237,11 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) 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; + block1[av_lfg_get(&prng) % 64] = av_lfg_get(&prng) % (2*vals) -vals; } break; case 2: - block1[0] = av_lfg_get(&prng) % 4096 - 2048; + block1[0] = av_lfg_get(&prng) % (16*vals) - (8*vals); block1[63] = (block1[0] & 1) ^ 1; break; } @@ -326,7 +327,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) switch (test) { case 0: for (i = 0; i < 64; i++) - block1[i] = av_lfg_get(&prng) % 512 - 256; + block1[i] = av_lfg_get(&prng) % (2*vals) -vals; if (is_idct) { ff_ref_fdct(block1); for (i = 0; i < 64; i++) @@ -335,10 +336,10 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed) 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; + block1[0] = av_lfg_get(&prng) % (2*vals) -vals; + block1[1] = av_lfg_get(&prng) % (2*vals) -vals; + block1[2] = av_lfg_get(&prng) % (2*vals) -vals; + block1[3] = av_lfg_get(&prng) % (2*vals) -vals; break; } @@ -489,6 +490,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); @@ -530,6 +550,7 @@ int main(int argc, char **argv) int test = 1; int speed = 0; int err = 0; + int bits=8; cpu_flags = av_get_cpu_flags(); @@ -566,6 +587,7 @@ int main(int argc, char **argv) if (optind < argc) test = atoi(argv[optind]); + if(optind+1 < argc) bits= atoi(argv[optind+1]); printf("ffmpeg DCT/IDCT test\n"); @@ -575,7 +597,7 @@ int main(int argc, char **argv) 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); } } |