Revision 6544f48f

View differences:

libavutil/adler32.h
24 24
#include <stdint.h>
25 25

  
26 26
unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
27
                                unsigned int len);
27
                                unsigned int len) av_pure;
28 28

  
29 29
#endif /* FFMPEG_ADLER32_H */
libavutil/bswap.h
40 40
#  define LEGACY_REGS "=q"
41 41
#endif
42 42

  
43
static av_always_inline uint16_t bswap_16(uint16_t x)
43
static av_always_inline av_const uint16_t bswap_16(uint16_t x)
44 44
{
45 45
#if defined(ARCH_X86)
46 46
    __asm("rorw $8, %0"   :
......
54 54
    return x;
55 55
}
56 56

  
57
static av_always_inline uint32_t bswap_32(uint32_t x)
57
static av_always_inline av_const uint32_t bswap_32(uint32_t x)
58 58
{
59 59
#if defined(ARCH_X86)
60 60
#ifdef HAVE_BSWAP
......
93 93
    return x;
94 94
}
95 95

  
96
static inline uint64_t bswap_64(uint64_t x)
96
static inline uint64_t av_const bswap_64(uint64_t x)
97 97
{
98 98
#if 0
99 99
    x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
libavutil/common.h
57 57
#endif
58 58
#endif
59 59

  
60
#ifndef av_pure
61
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
62
#    define av_pure __attribute__((pure))
63
#else
64
#    define av_pure
65
#endif
66
#endif
67

  
68
#ifndef av_const
69
#if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 5)
70
#    define av_const __attribute__((const))
71
#else
72
#    define av_const
73
#endif
74
#endif
75

  
60 76
#ifdef HAVE_AV_CONFIG_H
61 77
#    include "internal.h"
62 78
#endif /* HAVE_AV_CONFIG_H */
......
94 110
/* misc math functions */
95 111
extern const uint8_t ff_log2_tab[256];
96 112

  
97
static inline int av_log2(unsigned int v)
113
static inline av_const int av_log2(unsigned int v)
98 114
{
99 115
    int n = 0;
100 116
    if (v & 0xffff0000) {
......
110 126
    return n;
111 127
}
112 128

  
113
static inline int av_log2_16bit(unsigned int v)
129
static inline av_const int av_log2_16bit(unsigned int v)
114 130
{
115 131
    int n = 0;
116 132
    if (v & 0xff00) {
......
123 139
}
124 140

  
125 141
/* median of 3 */
126
static inline int mid_pred(int a, int b, int c)
142
static inline av_const int mid_pred(int a, int b, int c)
127 143
{
128 144
#ifdef HAVE_CMOV
129 145
    int i=b;
......
170 186
 * @param amax maximum value of the clip range
171 187
 * @return clipped value
172 188
 */
173
static inline int av_clip(int a, int amin, int amax)
189
static inline av_const int av_clip(int a, int amin, int amax)
174 190
{
175 191
    if      (a < amin) return amin;
176 192
    else if (a > amax) return amax;
......
182 198
 * @param a value to clip
183 199
 * @return clipped value
184 200
 */
185
static inline uint8_t av_clip_uint8(int a)
201
static inline av_const uint8_t av_clip_uint8(int a)
186 202
{
187 203
    if (a&(~255)) return (-a)>>31;
188 204
    else          return a;
......
193 209
 * @param a value to clip
194 210
 * @return clipped value
195 211
 */
196
static inline int16_t av_clip_int16(int a)
212
static inline av_const int16_t av_clip_int16(int a)
197 213
{
198 214
    if ((a+32768) & ~65535) return (a>>31) ^ 32767;
199 215
    else                    return a;
200 216
}
201 217

  
202 218
/* math */
203
int64_t ff_gcd(int64_t a, int64_t b);
219
int64_t av_const ff_gcd(int64_t a, int64_t b);
204 220

  
205 221
/**
206 222
 * converts fourcc string to int
207 223
 */
208
static inline int ff_get_fourcc(const char *s){
224
static inline av_pure int ff_get_fourcc(const char *s){
209 225
#ifdef HAVE_AV_CONFIG_H
210 226
    assert( strlen(s)==4 );
211 227
#endif
libavutil/crc.h
37 37

  
38 38
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
39 39
const AVCRC *av_crc_get_table(AVCRCId crc_id);
40
uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length);
40
uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length) av_pure;
41 41

  
42 42
#endif /* FFMPEG_CRC_H */
43 43

  
libavutil/des.c
19 19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
 */
21 21
#include <inttypes.h>
22
#include "common.h"
22 23
#include "des.h"
23 24

  
24 25
#define T(a, b, c, d, e, f, g, h) 64-a,64-b,64-c,64-d,64-e,64-f,64-g,64-h
libavutil/des.h
34 34
 * If your input data is in 8-bit blocks treat it as big-endian
35 35
 * (use e.g. AV_RB64 and AV_WB64).
36 36
 */
37
uint64_t ff_des_encdec(uint64_t in, uint64_t key, int decrypt);
37
uint64_t ff_des_encdec(uint64_t in, uint64_t key, int decrypt) av_const;
38 38

  
39 39
#endif /* FFMPEG_DES_H */
libavutil/integer.h
36 36
    uint16_t v[AV_INTEGER_SIZE];
37 37
} AVInteger;
38 38

  
39
AVInteger av_add_i(AVInteger a, AVInteger b);
40
AVInteger av_sub_i(AVInteger a, AVInteger b);
39
AVInteger av_add_i(AVInteger a, AVInteger b) av_const;
40
AVInteger av_sub_i(AVInteger a, AVInteger b) av_const;
41 41

  
42 42
/**
43 43
 * returns the rounded down value of the logarithm of base 2 of the given AVInteger.
44 44
 * this is simply the index of the most significant bit which is 1. Or 0 of all bits are 0
45 45
 */
46
int av_log2_i(AVInteger a);
47
AVInteger av_mul_i(AVInteger a, AVInteger b);
46
int av_log2_i(AVInteger a) av_const;
47
AVInteger av_mul_i(AVInteger a, AVInteger b) av_const;
48 48

  
49 49
/**
50 50
 * returns 0 if a==b, 1 if a>b and -1 if a<b.
51 51
 */
52
int av_cmp_i(AVInteger a, AVInteger b);
52
int av_cmp_i(AVInteger a, AVInteger b) av_const;
53 53

  
54 54
/**
55 55
 * bitwise shift.
56 56
 * @param s the number of bits by which the value should be shifted right, may be negative for shifting left
57 57
 */
58
AVInteger av_shr_i(AVInteger a, int s);
58
AVInteger av_shr_i(AVInteger a, int s) av_const;
59 59

  
60 60
/**
61 61
 * returns a % b.
......
66 66
/**
67 67
 * returns a/b.
68 68
 */
69
AVInteger av_div_i(AVInteger a, AVInteger b);
69
AVInteger av_div_i(AVInteger a, AVInteger b) av_const;
70 70

  
71 71
/**
72 72
 * converts the given int64_t to an AVInteger.
73 73
 */
74
AVInteger av_int2i(int64_t a);
74
AVInteger av_int2i(int64_t a) av_const;
75 75

  
76 76
/**
77 77
 * converts the given AVInteger to an int64_t.
78 78
 * if the AVInteger is too large to fit into an int64_t,
79 79
 * then only the least significant 64bit will be used
80 80
 */
81
int64_t av_i2int(AVInteger a);
81
int64_t av_i2int(AVInteger a) av_const;
82 82

  
83 83
#endif /* FFMPEG_INTEGER_H */
libavutil/internal.h
172 172

  
173 173
static inline int av_log2_16bit(unsigned int v);
174 174

  
175
static inline unsigned int ff_sqrt(unsigned int a)
175
static inline av_const unsigned int ff_sqrt(unsigned int a)
176 176
{
177 177
    unsigned int b;
178 178

  
......
267 267
}
268 268

  
269 269
#ifndef HAVE_LLRINT
270
static av_always_inline long long llrint(double x)
270
static av_always_inline av_const long long llrint(double x)
271 271
{
272 272
    return rint(x);
273 273
}
274 274
#endif /* HAVE_LLRINT */
275 275

  
276 276
#ifndef HAVE_LRINT
277
static av_always_inline long int lrint(double x)
277
static av_always_inline av_const long int lrint(double x)
278 278
{
279 279
    return rint(x);
280 280
}
281 281
#endif /* HAVE_LRINT */
282 282

  
283 283
#ifndef HAVE_LRINTF
284
static av_always_inline long int lrintf(float x)
284
static av_always_inline av_const long int lrintf(float x)
285 285
{
286 286
    return (int)(rint(x));
287 287
}
288 288
#endif /* HAVE_LRINTF */
289 289

  
290 290
#ifndef HAVE_ROUND
291
static av_always_inline double round(double x)
291
static av_always_inline av_const double round(double x)
292 292
{
293 293
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
294 294
}
295 295
#endif /* HAVE_ROUND */
296 296

  
297 297
#ifndef HAVE_ROUNDF
298
static av_always_inline float roundf(float x)
298
static av_always_inline av_const float roundf(float x)
299 299
{
300 300
    return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
301 301
}
libavutil/intfloat_readwrite.h
30 30
    uint8_t mantissa[8];
31 31
} AVExtFloat;
32 32

  
33
double av_int2dbl(int64_t v);
34
float av_int2flt(int32_t v);
35
double av_ext2dbl(const AVExtFloat ext);
36
int64_t av_dbl2int(double d);
37
int32_t av_flt2int(float d);
38
AVExtFloat av_dbl2ext(double d);
33
double av_int2dbl(int64_t v) av_const;
34
float av_int2flt(int32_t v) av_const;
35
double av_ext2dbl(const AVExtFloat ext) av_const;
36
int64_t av_dbl2int(double d) av_const;
37
int32_t av_flt2int(float d) av_const;
38
AVExtFloat av_dbl2ext(double d) av_const;
39 39

  
40 40
#endif /* FFMPEG_INTFLOAT_READWRITE_H */
libavutil/mathematics.h
36 36
 * rescale a 64bit integer with rounding to nearest.
37 37
 * a simple a*b/c isn't possible as it can overflow
38 38
 */
39
int64_t av_rescale(int64_t a, int64_t b, int64_t c);
39
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
40 40

  
41 41
/**
42 42
 * rescale a 64bit integer with specified rounding.
43 43
 * a simple a*b/c isn't possible as it can overflow
44 44
 */
45
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
45
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
46 46

  
47 47
/**
48 48
 * rescale a 64bit integer by 2 rational numbers.
49 49
 */
50
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
50
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
51 51

  
52 52
#endif /* FFMPEG_MATHEMATICS_H */
libavutil/mem.h
42 42
    #define DECLARE_ASM_CONST(n,t,v)    static const t v
43 43
#endif
44 44

  
45
#ifdef __GNUC__
46
    #define av_malloc_attrib __attribute__((__malloc__))
47
#else
48
    #define av_malloc_attrib
49
#endif
50

  
45 51
/**
46 52
 * Allocate a block of \p size bytes with alignment suitable for all
47 53
 * memory accesses (including vectors if available on the CPU).
......
50 56
 * it.
51 57
 * @see av_mallocz()
52 58
 */
53
void *av_malloc(unsigned int size);
59
void *av_malloc(unsigned int size) av_malloc_attrib;
54 60

  
55 61
/**
56 62
 * Allocate or reallocate a block of memory.
......
85 91
 * it.
86 92
 * @see av_malloc()
87 93
 */
88
void *av_mallocz(unsigned int size);
94
void *av_mallocz(unsigned int size) av_malloc_attrib;
89 95

  
90 96
/**
91 97
 * Duplicate the string \p s.
......
93 99
 * @return Pointer to a newly allocated string containing a
94 100
 * copy of \p s or NULL if it cannot be allocated.
95 101
 */
96
char *av_strdup(const char *s);
102
char *av_strdup(const char *s) av_malloc_attrib;
97 103

  
98 104
/**
99 105
 * Free a memory block which has been allocated with av_malloc(z)() or
libavutil/rational.h
78 78
 * @param c second rational.
79 79
 * @return b*c.
80 80
 */
81
AVRational av_mul_q(AVRational b, AVRational c);
81
AVRational av_mul_q(AVRational b, AVRational c) av_const;
82 82

  
83 83
/**
84 84
 * Divides one rational by another.
......
86 86
 * @param c second rational.
87 87
 * @return b/c.
88 88
 */
89
AVRational av_div_q(AVRational b, AVRational c);
89
AVRational av_div_q(AVRational b, AVRational c) av_const;
90 90

  
91 91
/**
92 92
 * Adds two rationals.
......
94 94
 * @param c second rational.
95 95
 * @return b+c.
96 96
 */
97
AVRational av_add_q(AVRational b, AVRational c);
97
AVRational av_add_q(AVRational b, AVRational c) av_const;
98 98

  
99 99
/**
100 100
 * Subtracts one rational from another.
......
102 102
 * @param c second rational.
103 103
 * @return b-c.
104 104
 */
105
AVRational av_sub_q(AVRational b, AVRational c);
105
AVRational av_sub_q(AVRational b, AVRational c) av_const;
106 106

  
107 107
/**
108 108
 * Converts a double precision floating point number to a rational.
......
110 110
 * @param max the maximum allowed numerator and denominator
111 111
 * @return (AVRational) d.
112 112
 */
113
AVRational av_d2q(double d, int max);
113
AVRational av_d2q(double d, int max) av_const;
114 114

  
115 115
#endif /* FFMPEG_RATIONAL_H */
libavutil/softfloat.h
32 32
    int32_t mant;
33 33
}SoftFloat;
34 34

  
35
static SoftFloat av_normalize_sf(SoftFloat a){
35
static av_const SoftFloat av_normalize_sf(SoftFloat a){
36 36
    if(a.mant){
37 37
#if 1
38 38
        while((a.mant + 0x20000000U)<0x40000000U){
......
54 54
    return a;
55 55
}
56 56

  
57
static inline SoftFloat av_normalize1_sf(SoftFloat a){
57
static inline av_const SoftFloat av_normalize1_sf(SoftFloat a){
58 58
#if 1
59 59
    if(a.mant + 0x40000000 < 0){
60 60
        a.exp++;
......
76 76
 *         normalized then the output wont be worse then the other input
77 77
 *         if both are normalized then the output will be normalized
78 78
 */
79
static inline SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){
79
static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){
80 80
    a.exp += b.exp;
81 81
    a.mant = (a.mant * (int64_t)b.mant) >> ONE_BITS;
82 82
    return av_normalize1_sf(a);
......
87 87
 * b has to be normalized and not zero
88 88
 * @return will not be more denormalized then a
89 89
 */
90
static SoftFloat av_div_sf(SoftFloat a, SoftFloat b){
90
static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){
91 91
    a.exp -= b.exp+1;
92 92
    a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant;
93 93
    return av_normalize1_sf(a);
94 94
}
95 95

  
96
static inline int av_cmp_sf(SoftFloat a, SoftFloat b){
96
static inline av_const int av_cmp_sf(SoftFloat a, SoftFloat b){
97 97
    int t= a.exp - b.exp;
98 98
    if(t<0) return (a.mant >> (-t)) -  b.mant      ;
99 99
    else    return  a.mant          - (b.mant >> t);
100 100
}
101 101

  
102
static inline SoftFloat av_add_sf(SoftFloat a, SoftFloat b){
102
static inline av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b){
103 103
    int t= a.exp - b.exp;
104 104
    if(t<0) return av_normalize1_sf((SoftFloat){b.exp, b.mant + (a.mant >> (-t))});
105 105
    else    return av_normalize1_sf((SoftFloat){a.exp, a.mant + (b.mant >>   t )});
106 106
}
107 107

  
108
static inline SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){
108
static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){
109 109
    return av_add_sf(a, (SoftFloat){b.exp, -b.mant});
110 110
}
111 111

  
112 112
//FIXME sqrt, log, exp, pow, sin, cos
113 113

  
114
static inline SoftFloat av_int2sf(int v, int frac_bits){
114
static inline av_const SoftFloat av_int2sf(int v, int frac_bits){
115 115
    return av_normalize_sf((SoftFloat){ONE_BITS-frac_bits, v});
116 116
}
117 117

  
......
119 119
 *
120 120
 * rounding is to -inf
121 121
 */
122
static inline int av_sf2int(SoftFloat v, int frac_bits){
122
static inline av_const int av_sf2int(SoftFloat v, int frac_bits){
123 123
    v.exp += frac_bits - ONE_BITS;
124 124
    if(v.exp >= 0) return v.mant <<  v.exp ;
125 125
    else           return v.mant >>(-v.exp);

Also available in: Unified diff