aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dct-test.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-21 21:25:43 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-21 21:25:43 +0200
commit3e1a7ae44a97f20bbc9da0eba000663ef74e1890 (patch)
tree75bfd6ad30f1b24aa7d29c3a3081875c14b5dab5 /libavcodec/dct-test.c
parent358d837dad4e2fbe010553990383d0ca4d5937cf (diff)
parent05fc9e40a4e4f808d457512420b887f458d216bc (diff)
downloadffmpeg-3e1a7ae44a97f20bbc9da0eba000663ef74e1890.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: swfdec: Add support for sample_rate_code 0 (5512 Hz) dct-test: factor out some common code and do whas was likely intended doc: library versions need to be bumped in version.h Revert "ffmpeg: get rid of useless AVInputStream.nb_streams." Remove some forgotten AVCodecContext.palctrl usage. lavc/utils: move avcodec_init() higher in the file. lavc: replace some deprecated FF_*_TYPE with AV_PICTURE_TYPE_* ac3dec: actually use drc_scale private option lavc: undeprecate AVPALETTE_SIZE and AVPALETTE_COUNT macros alsa: add missing header msmpeg4: remove leftover unused debug variable declaration Fix assert() calls that need updates after FF_COMMON_FRAME macro elimination. Fix av_dlog invocations with wrong or missing logging context. vf_yadif: add support to yuva420p vf_yadif: correct documentation on the parity parameter vf_yadif: copy buffer properties like aspect for second frame as well oma: support for encrypted files id3v2: add support for non-text and GEOB type tag frames des: add possibility to calculate DES-CBC-MAC with small buffer Conflicts: ffmpeg.c libavcodec/dct-test.c libavformat/mpegts.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dct-test.c')
-rw-r--r--libavcodec/dct-test.c127
1 files changed, 54 insertions, 73 deletions
diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c
index 9e1e99672b..2222cd5144 100644
--- a/libavcodec/dct-test.c
+++ b/libavcodec/dct-test.c
@@ -199,6 +199,55 @@ static inline void mmx_emms(void)
#endif
}
+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)
{
@@ -221,46 +270,8 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
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) % (2*vals)) -vals;
- 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) % (2*vals) -vals;
- }
- break;
- case 2:
- block1[0] = av_lfg_get(&prng) % (16*vals) - (8*vals);
- 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();
@@ -317,45 +328,15 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
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) % (2*vals) -vals;
- 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) % (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;
- }
- 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;