~siretart/libav/trusty

« back to all changes in this revision

Viewing changes to libavcodec/dct-test.c

  • Committer: Reinhard Tartler
  • Date: 2013-10-23 03:04:17 UTC
  • mfrom: (1.3.36 sid)
  • Revision ID: siretart@tauware.de-20131023030417-1o6mpkl1l0raifjt
mergeĀ fromĀ debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 * Started from sample code by Juan J. Sierralta P.
26
26
 */
27
27
 
 
28
#include "config.h"
28
29
#include <stdlib.h>
29
30
#include <stdio.h>
30
31
#include <string.h>
31
 
#include <sys/time.h>
 
32
#if HAVE_UNISTD_H
32
33
#include <unistd.h>
 
34
#endif
33
35
#include <math.h>
34
36
 
35
37
#include "libavutil/cpu.h"
36
38
#include "libavutil/common.h"
37
39
#include "libavutil/lfg.h"
 
40
#include "libavutil/time.h"
38
41
 
39
42
#include "simple_idct.h"
40
43
#include "aandcttab.h"
45
48
 
46
49
#undef printf
47
50
 
48
 
void ff_mmx_idct(DCTELEM *data);
49
 
void ff_mmxext_idct(DCTELEM *data);
50
 
 
51
 
void odivx_idct_c(short *block);
52
 
 
53
51
// BFIN
54
52
void ff_bfin_idct(DCTELEM *block);
55
53
void ff_bfin_fdct(DCTELEM *block);
56
54
 
57
55
// ALTIVEC
58
 
void fdct_altivec(DCTELEM *block);
59
 
//void idct_altivec(DCTELEM *block);?? no routine
 
56
void ff_fdct_altivec(DCTELEM *block);
60
57
 
61
58
// ARM
62
59
void ff_j_rev_dct_arm(DCTELEM *data);
76
73
    int nonspec;
77
74
};
78
75
 
79
 
#ifndef FAAN_POSTSCALE
80
 
#define FAAN_SCALE SCALE_PERM
81
 
#else
82
 
#define FAAN_SCALE NO_PERM
83
 
#endif
84
 
 
85
76
static int cpu_flags;
86
77
 
87
78
static const struct algo fdct_tab[] = {
88
79
    { "REF-DBL",        ff_ref_fdct,           NO_PERM    },
89
 
    { "FAAN",           ff_faandct,            FAAN_SCALE },
90
 
    { "IJG-AAN-INT",    fdct_ifast,            SCALE_PERM },
 
80
    { "FAAN",           ff_faandct,            NO_PERM    },
 
81
    { "IJG-AAN-INT",    ff_fdct_ifast,         SCALE_PERM },
91
82
    { "IJG-LLM-INT",    ff_jpeg_fdct_islow_8,  NO_PERM    },
92
83
 
93
 
#if HAVE_MMX
 
84
#if HAVE_MMX_INLINE
94
85
    { "MMX",            ff_fdct_mmx,           NO_PERM,   AV_CPU_FLAG_MMX     },
95
 
    { "MMX2",           ff_fdct_mmx2,          NO_PERM,   AV_CPU_FLAG_MMX2    },
 
86
    { "MMXEXT",         ff_fdct_mmxext,        NO_PERM,   AV_CPU_FLAG_MMXEXT  },
96
87
    { "SSE2",           ff_fdct_sse2,          NO_PERM,   AV_CPU_FLAG_SSE2    },
97
88
#endif
98
89
 
99
90
#if HAVE_ALTIVEC
100
 
    { "altivecfdct",    fdct_altivec,          NO_PERM,   AV_CPU_FLAG_ALTIVEC },
 
91
    { "altivecfdct",    ff_fdct_altivec,       NO_PERM,   AV_CPU_FLAG_ALTIVEC },
101
92
#endif
102
93
 
103
94
#if ARCH_BFIN
110
101
static const struct algo idct_tab[] = {
111
102
    { "FAANI",          ff_faanidct,           NO_PERM  },
112
103
    { "REF-DBL",        ff_ref_idct,           NO_PERM  },
113
 
    { "INT",            j_rev_dct,             MMX_PERM },
 
104
    { "INT",            ff_j_rev_dct,          MMX_PERM },
114
105
    { "SIMPLE-C",       ff_simple_idct_8,      NO_PERM  },
115
106
 
116
 
#if HAVE_MMX
117
 
#if CONFIG_GPL
118
 
    { "LIBMPEG2-MMX",   ff_mmx_idct,           MMX_PERM,  AV_CPU_FLAG_MMX,  1 },
119
 
    { "LIBMPEG2-MMX2",  ff_mmxext_idct,        MMX_PERM,  AV_CPU_FLAG_MMX2, 1 },
120
 
#endif
 
107
#if HAVE_MMX_INLINE
121
108
    { "SIMPLE-MMX",     ff_simple_idct_mmx,  MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX },
122
109
    { "XVID-MMX",       ff_idct_xvid_mmx,      NO_PERM,   AV_CPU_FLAG_MMX,  1 },
123
 
    { "XVID-MMX2",      ff_idct_xvid_mmx2,     NO_PERM,   AV_CPU_FLAG_MMX2, 1 },
 
110
    { "XVID-MMXEXT",    ff_idct_xvid_mmxext,   NO_PERM,   AV_CPU_FLAG_MMXEXT, 1 },
124
111
    { "XVID-SSE2",      ff_idct_xvid_sse2,     SSE2_PERM, AV_CPU_FLAG_SSE2, 1 },
125
112
#endif
126
113
 
133
120
    { "INT-ARM",        ff_j_rev_dct_arm,      MMX_PERM },
134
121
#endif
135
122
#if HAVE_ARMV5TE
136
 
    { "SIMPLE-ARMV5TE", ff_simple_idct_armv5te,NO_PERM  },
 
123
    { "SIMPLE-ARMV5TE", ff_simple_idct_armv5te,NO_PERM,   AV_CPU_FLAG_ARMV5TE },
137
124
#endif
138
125
#if HAVE_ARMV6
139
 
    { "SIMPLE-ARMV6",   ff_simple_idct_armv6,  MMX_PERM },
 
126
    { "SIMPLE-ARMV6",   ff_simple_idct_armv6,  MMX_PERM,  AV_CPU_FLAG_ARMV6   },
140
127
#endif
141
128
#if HAVE_NEON
142
 
    { "SIMPLE-NEON",    ff_simple_idct_neon,   PARTTRANS_PERM },
 
129
    { "SIMPLE-NEON",    ff_simple_idct_neon, PARTTRANS_PERM, AV_CPU_FLAG_NEON },
143
130
#endif
144
131
 
145
132
#if ARCH_ALPHA
151
138
 
152
139
#define AANSCALE_BITS 12
153
140
 
154
 
static int64_t gettime(void)
155
 
{
156
 
    struct timeval tv;
157
 
    gettimeofday(&tv, NULL);
158
 
    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
159
 
}
160
 
 
161
141
#define NB_ITS 20000
162
142
#define NB_ITS_SPEED 50000
163
143
 
189
169
DECLARE_ALIGNED(16, static DCTELEM, block)[64];
190
170
DECLARE_ALIGNED(8,  static DCTELEM, block1)[64];
191
171
 
192
 
static inline void mmx_emms(void)
193
 
{
194
 
#if HAVE_MMX
195
 
    if (cpu_flags & AV_CPU_FLAG_MMX)
196
 
        __asm__ volatile ("emms\n\t");
197
 
#endif
198
 
}
199
 
 
200
172
static void init_block(DCTELEM block[64], int test, int is_idct, AVLFG *prng)
201
173
{
202
174
    int i, j;
271
243
        permute(block, block1, dct->format);
272
244
 
273
245
        dct->func(block);
274
 
        mmx_emms();
 
246
        emms_c();
275
247
 
276
248
        if (dct->format == SCALE_PERM) {
277
249
            for (i = 0; i < 64; i++) {
328
300
    init_block(block, test, is_idct, &prng);
329
301
    permute(block1, block, dct->format);
330
302
 
331
 
    ti = gettime();
 
303
    ti = av_gettime();
332
304
    it1 = 0;
333
305
    do {
334
306
        for (it = 0; it < NB_ITS_SPEED; it++) {
336
308
            dct->func(block);
337
309
        }
338
310
        it1 += NB_ITS_SPEED;
339
 
        ti1 = gettime() - ti;
 
311
        ti1 = av_gettime() - ti;
340
312
    } while (ti1 < 1000000);
341
 
    mmx_emms();
 
313
    emms_c();
342
314
 
343
315
    printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name,
344
316
           (double) it1 * 1000.0 / (double) ti1);
469
441
    if (!speed)
470
442
        return;
471
443
 
472
 
    ti = gettime();
 
444
    ti = av_gettime();
473
445
    it1 = 0;
474
446
    do {
475
447
        for (it = 0; it < NB_ITS_SPEED; it++) {
478
450
            idct248_put(img_dest, 8, block);
479
451
        }
480
452
        it1 += NB_ITS_SPEED;
481
 
        ti1 = gettime() - ti;
 
453
        ti1 = av_gettime() - ti;
482
454
    } while (ti1 < 1000000);
483
 
    mmx_emms();
 
455
    emms_c();
484
456
 
485
457
    printf("%s %s: %0.1f kdct/s\n", 1 ? "IDCT248" : "DCT248", name,
486
458
           (double) it1 * 1000.0 / (double) ti1);
497
469
           "-t          speed test\n");
498
470
}
499
471
 
 
472
#if !HAVE_GETOPT
 
473
#include "compat/getopt.c"
 
474
#endif
 
475
 
500
476
int main(int argc, char **argv)
501
477
{
502
478
    int test_idct = 0, test_248_dct = 0;