~ubuntu-branches/ubuntu/vivid/ffmpeg/vivid

« back to all changes in this revision

Viewing changes to libavutil/timer.h

  • Committer: Package Import Robot
  • Author(s): Andreas Cadhalpun
  • Date: 2014-11-05 01:18:23 UTC
  • mfrom: (0.2.17 sid)
  • Revision ID: package-import@ubuntu.com-20141105011823-xsbeceffs43wtkn7
Tags: 7:2.4.3-1
* Import new upstream bugfix release 2.4.3.
   - Refresh Change-symbol-versioning.patch.
   - Add new symbols to the libavdevice symbols file.
* Enable libbs2b on arm64, since it is now available.
* Disable frei0r and libx264 on x32, libsoxr and openal on sparc64
  and libopencv on m68k, sh4, sparc64 and x32, because they are not
  (yet) avialable there.
* Disable assembler optimizations on x32, as they wouldn't work there.
* Include config.log in the build-log, when compiling fails.
* Add fix-hppa-tests.patch to work around a gcc bug on hppa.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * @file
3
 
 * high precision timer, useful to profile code
4
 
 *
 
1
/*
5
2
 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
6
3
 *
7
4
 * This file is part of FFmpeg.
21
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
19
 */
23
20
 
 
21
/**
 
22
 * @file
 
23
 * high precision timer, useful to profile code
 
24
 */
 
25
 
24
26
#ifndef AVUTIL_TIMER_H
25
27
#define AVUTIL_TIMER_H
26
28
 
27
29
#include <stdlib.h>
28
30
#include <stdint.h>
 
31
#include <inttypes.h>
 
32
 
29
33
#include "config.h"
30
34
 
 
35
#if HAVE_MACH_MACH_TIME_H
 
36
#include <mach/mach_time.h>
 
37
#endif
 
38
 
 
39
#include "log.h"
 
40
 
31
41
#if   ARCH_ARM
32
42
#   include "arm/timer.h"
33
 
#elif ARCH_BFIN
34
 
#   include "bfin/timer.h"
35
43
#elif ARCH_PPC
36
44
#   include "ppc/timer.h"
37
45
#elif ARCH_X86
38
46
#   include "x86/timer.h"
39
47
#endif
40
48
 
41
 
#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
42
 
#   define AV_READ_TIME gethrtime
 
49
#if !defined(AV_READ_TIME)
 
50
#   if HAVE_GETHRTIME
 
51
#       define AV_READ_TIME gethrtime
 
52
#   elif HAVE_MACH_ABSOLUTE_TIME
 
53
#       define AV_READ_TIME mach_absolute_time
 
54
#   endif
 
55
#endif
 
56
 
 
57
#ifndef FF_TIMER_UNITS
 
58
#   define FF_TIMER_UNITS "UNITS"
43
59
#endif
44
60
 
45
61
#ifdef AV_READ_TIME
46
 
#define START_TIMER \
47
 
uint64_t tend;\
48
 
uint64_t tstart= AV_READ_TIME();\
 
62
#define START_TIMER                             \
 
63
    uint64_t tend;                              \
 
64
    uint64_t tstart = AV_READ_TIME();           \
49
65
 
50
 
#define STOP_TIMER(id) \
51
 
tend= AV_READ_TIME();\
52
 
{\
53
 
    static uint64_t tsum=0;\
54
 
    static int tcount=0;\
55
 
    static int tskip_count=0;\
56
 
    if(tcount<2 || tend - tstart < 8*tsum/tcount || tend - tstart < 2000){\
57
 
        tsum+= tend - tstart;\
58
 
        tcount++;\
59
 
    }else\
60
 
        tskip_count++;\
61
 
    if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\
62
 
        av_log(NULL, AV_LOG_ERROR, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n",\
63
 
               tsum*10/tcount, id, tcount, tskip_count);\
64
 
    }\
65
 
}
 
66
#define STOP_TIMER(id)                                                    \
 
67
    tend = AV_READ_TIME();                                                \
 
68
    {                                                                     \
 
69
        static uint64_t tsum   = 0;                                       \
 
70
        static int tcount      = 0;                                       \
 
71
        static int tskip_count = 0;                                       \
 
72
        if (tcount < 2                        ||                          \
 
73
            tend - tstart < 8 * tsum / tcount ||                          \
 
74
            tend - tstart < 2000) {                                       \
 
75
            tsum+= tend - tstart;                                         \
 
76
            tcount++;                                                     \
 
77
        } else                                                            \
 
78
            tskip_count++;                                                \
 
79
        if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0) { \
 
80
            av_log(NULL, AV_LOG_ERROR,                                    \
 
81
                   "%"PRIu64" " FF_TIMER_UNITS " in %s, %d runs, %d skips\n",          \
 
82
                   tsum * 10 / tcount, id, tcount, tskip_count);          \
 
83
        }                                                                 \
 
84
    }
66
85
#else
67
86
#define START_TIMER
68
 
#define STOP_TIMER(id) {}
 
87
#define STOP_TIMER(id) { }
69
88
#endif
70
89
 
71
90
#endif /* AVUTIL_TIMER_H */