~ubuntu-branches/ubuntu/vivid/libav/vivid

« back to all changes in this revision

Viewing changes to libavcodec/mathops.h

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2013-10-22 23:24:08 UTC
  • mfrom: (1.3.36 sid)
  • Revision ID: package-import@ubuntu.com-20131022232408-b8tvvn4pyzri9mi3
Tags: 6:9.10-1ubuntu1
* Build all -extra flavors from this source package, as libav got demoted
  from main to universe, cf LP: #1243235
* Simplify debian/rules to follow exactly the code that debian executes
* New upstream (LP: #1180288) fixes lots of security issues (LP: #1242802)
* Merge from unstable, remaining changes:
  - build-depend on libtiff5-dev rather than libtiff4-dev,
    avoids FTBFS caused by imlib
  - follow the regular debian codepaths

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#ifndef AVCODEC_MATHOPS_H
23
23
#define AVCODEC_MATHOPS_H
24
24
 
 
25
#include <stdint.h>
 
26
 
25
27
#include "libavutil/common.h"
26
28
#include "config.h"
27
29
 
 
30
extern const uint32_t ff_inverse[257];
 
31
extern const uint8_t  ff_reverse[256];
 
32
extern const uint8_t ff_sqrt_tab[256];
 
33
 
28
34
#if   ARCH_ARM
29
35
#   include "arm/mathops.h"
30
36
#elif ARCH_AVR32
138
144
}
139
145
#endif
140
146
 
 
147
#ifndef MASK_ABS
 
148
#define MASK_ABS(mask, level) do {              \
 
149
        mask  = level >> 31;                    \
 
150
        level = (level ^ mask) - mask;          \
 
151
    } while (0)
 
152
#endif
 
153
 
141
154
#ifndef NEG_SSR32
142
155
#   define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
143
156
#endif
178
191
#   define PACK_2S16(a,b)    PACK_2U16((a)&0xffff, (b)&0xffff)
179
192
#endif
180
193
 
 
194
#ifndef FASTDIV
 
195
#   define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
 
196
#endif /* FASTDIV */
 
197
 
 
198
static inline av_const unsigned int ff_sqrt(unsigned int a)
 
199
{
 
200
    unsigned int b;
 
201
 
 
202
    if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4;
 
203
    else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2;
 
204
#if !CONFIG_SMALL
 
205
    else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1;
 
206
    else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8]   ;
 
207
#endif
 
208
    else {
 
209
        int s = av_log2_16bit(a >> 16) >> 1;
 
210
        unsigned int c = a >> (s + 2);
 
211
        b = ff_sqrt_tab[c >> (s + 8)];
 
212
        b = FASTDIV(c,b) + (b << s);
 
213
    }
 
214
 
 
215
    return b - (a < b * b);
 
216
}
 
217
 
181
218
#endif /* AVCODEC_MATHOPS_H */
182