~ubuntu-branches/ubuntu/trusty/libav/trusty-proposed

« back to all changes in this revision

Viewing changes to libavcodec/celp_math.c

  • 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:
26
26
 
27
27
#include "avcodec.h"
28
28
#include "celp_math.h"
29
 
 
30
 
/**
31
 
 * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
32
 
 */
33
 
static const int16_t tab_cos[65] =
34
 
{
35
 
  32767,  32738,  32617,  32421,  32145,  31793,  31364,  30860,
36
 
  30280,  29629,  28905,  28113,  27252,  26326,  25336,  24285,
37
 
  23176,  22011,  20793,  19525,  18210,  16851,  15451,  14014,
38
 
  12543,  11043,   9515,   7965,   6395,   4810,   3214,   1609,
39
 
      1,  -1607,  -3211,  -4808,  -6393,  -7962,  -9513, -11040,
40
 
 -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009,
41
 
 -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627,
42
 
 -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768,
43
 
};
 
29
#include "libavutil/common.h"
44
30
 
45
31
static const uint16_t exp2a[]=
46
32
{
58
44
 17176, 17898, 18620, 19343, 20066, 20790, 21514, 22238,
59
45
};
60
46
 
61
 
int16_t ff_cos(uint16_t arg)
62
 
{
63
 
    uint8_t offset= arg;
64
 
    uint8_t ind = arg >> 8;
65
 
 
66
 
    assert(arg <= 0x3fff);
67
 
 
68
 
    return tab_cos[ind] + (offset * (tab_cos[ind+1] - tab_cos[ind]) >> 8);
69
 
}
70
 
 
71
47
int ff_exp2(uint16_t power)
72
48
{
73
49
    unsigned int result= exp2a[power>>10] + 0x10000;
91
67
  26457,  27294,  28116,  28924,  29719,  30500,  31269,  32025,  32769,
92
68
};
93
69
 
94
 
int ff_log2(uint32_t value)
 
70
int ff_log2_q15(uint32_t value)
95
71
{
96
72
    uint8_t  power_int;
97
73
    uint8_t  frac_x0;
110
86
 
111
87
    return (power_int << 15) + value;
112
88
}
113
 
 
114
 
float ff_dot_productf(const float* a, const float* b, int length)
115
 
{
116
 
    float sum = 0;
117
 
    int i;
118
 
 
119
 
    for(i=0; i<length; i++)
120
 
        sum += a[i] * b[i];
121
 
 
122
 
    return sum;
123
 
}