~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/g726.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 */
24
24
#include <limits.h>
25
25
#include "avcodec.h"
26
 
#include "common.h"
27
26
#include "bitstream.h"
28
27
 
29
28
/**
65
64
 
66
65
typedef struct G726Tables {
67
66
    int  bits;          /**< bits per sample */
68
 
    int* quant;         /**< quantization table */
69
 
    int* iquant;        /**< inverse quantization table */
70
 
    int* W;             /**< special table #1 ;-) */
71
 
    int* F;             /**< special table #2 */
 
67
    const int* quant;         /**< quantization table */
 
68
    const int* iquant;        /**< inverse quantization table */
 
69
    const int* W;             /**< special table #1 ;-) */
 
70
    const int* F;             /**< special table #2 */
72
71
} G726Tables;
73
72
 
74
73
typedef struct G726Context {
75
 
    G726Tables* tbls;   /**< static tables needed for computation */
 
74
    const G726Tables* tbls;   /**< static tables needed for computation */
76
75
 
77
76
    Float11 sr[2];      /**< prev. reconstructed samples */
78
77
    Float11 dq[6];      /**< prev. difference */
92
91
    int y;              /**< quantizer scaling factor for the next iteration */
93
92
} G726Context;
94
93
 
95
 
static int quant_tbl16[] =                  /**< 16kbit/s 2bits per sample */
 
94
static const int quant_tbl16[] =                  /**< 16kbit/s 2bits per sample */
96
95
           { 260, INT_MAX };
97
 
static int iquant_tbl16[] =
 
96
static const int iquant_tbl16[] =
98
97
           { 116, 365, 365, 116 };
99
 
static int W_tbl16[] =
 
98
static const int W_tbl16[] =
100
99
           { -22, 439, 439, -22 };
101
 
static int F_tbl16[] =
 
100
static const int F_tbl16[] =
102
101
           { 0, 7, 7, 0 };
103
102
 
104
 
static int quant_tbl24[] =                  /**< 24kbit/s 3bits per sample */
 
103
static const int quant_tbl24[] =                  /**< 24kbit/s 3bits per sample */
105
104
           {  7, 217, 330, INT_MAX };
106
 
static int iquant_tbl24[] =
 
105
static const int iquant_tbl24[] =
107
106
           { INT_MIN, 135, 273, 373, 373, 273, 135, INT_MIN };
108
 
static int W_tbl24[] =
 
107
static const int W_tbl24[] =
109
108
           { -4,  30, 137, 582, 582, 137,  30, -4 };
110
 
static int F_tbl24[] =
 
109
static const int F_tbl24[] =
111
110
           { 0, 1, 2, 7, 7, 2, 1, 0 };
112
111
 
113
 
static int quant_tbl32[] =                  /**< 32kbit/s 4bits per sample */
 
112
static const int quant_tbl32[] =                  /**< 32kbit/s 4bits per sample */
114
113
           { -125,  79, 177, 245, 299, 348, 399, INT_MAX };
115
 
static int iquant_tbl32[] =
 
114
static const int iquant_tbl32[] =
116
115
           { INT_MIN,   4, 135, 213, 273, 323, 373, 425,
117
116
                 425, 373, 323, 273, 213, 135,   4, INT_MIN };
118
 
static int W_tbl32[] =
 
117
static const int W_tbl32[] =
119
118
           { -12,  18,  41,  64, 112, 198, 355, 1122,
120
119
            1122, 355, 198, 112,  64,  41,  18, -12};
121
 
static int F_tbl32[] =
 
120
static const int F_tbl32[] =
122
121
           { 0, 0, 0, 1, 1, 1, 3, 7, 7, 3, 1, 1, 1, 0, 0, 0 };
123
122
 
124
 
static int quant_tbl40[] =                  /**< 40kbit/s 5bits per sample */
 
123
static const int quant_tbl40[] =                  /**< 40kbit/s 5bits per sample */
125
124
           { -122, -16,  67, 138, 197, 249, 297, 338,
126
125
              377, 412, 444, 474, 501, 527, 552, INT_MAX };
127
 
static int iquant_tbl40[] =
 
126
static const int iquant_tbl40[] =
128
127
           { INT_MIN, -66,  28, 104, 169, 224, 274, 318,
129
128
                 358, 395, 429, 459, 488, 514, 539, 566,
130
129
                 566, 539, 514, 488, 459, 429, 395, 358,
131
130
                 318, 274, 224, 169, 104,  28, -66, INT_MIN };
132
 
static int W_tbl40[] =
 
131
static const int W_tbl40[] =
133
132
           {   14,  14,  24,  39,  40,  41,   58,  100,
134
133
              141, 179, 219, 280, 358, 440,  529,  696,
135
134
              696, 529, 440, 358, 280, 219,  179,  141,
136
135
              100,  58,  41,  40,  39,  24,   14,   14 };
137
 
static int F_tbl40[] =
 
136
static const int F_tbl40[] =
138
137
           { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 6,
139
138
             6, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
140
139
 
141
 
static G726Tables G726Tables_pool[] =
 
140
static const G726Tables G726Tables_pool[] =
142
141
           {{ 2, quant_tbl16, iquant_tbl16, W_tbl16, F_tbl16 },
143
142
            { 3, quant_tbl24, iquant_tbl24, W_tbl24, F_tbl24 },
144
143
            { 4, quant_tbl32, iquant_tbl32, W_tbl32, F_tbl32 },
267
266
    return av_clip(re_signal << 2, -0xffff, 0xffff);
268
267
}
269
268
 
270
 
static int g726_reset(G726Context* c, int bit_rate)
 
269
static av_cold int g726_reset(G726Context* c, int bit_rate)
271
270
{
272
271
    int i;
273
272
 
320
319
    int code_size;
321
320
} AVG726Context;
322
321
 
323
 
static int g726_init(AVCodecContext * avctx)
 
322
static av_cold int g726_init(AVCodecContext * avctx)
324
323
{
325
324
    AVG726Context* c = (AVG726Context*)avctx->priv_data;
326
325
 
347
346
    return 0;
348
347
}
349
348
 
350
 
static int g726_close(AVCodecContext *avctx)
 
349
static av_cold int g726_close(AVCodecContext *avctx)
351
350
{
352
351
    av_freep(&avctx->coded_frame);
353
352
    return 0;
374
373
 
375
374
static int g726_decode_frame(AVCodecContext *avctx,
376
375
                             void *data, int *data_size,
377
 
                             uint8_t *buf, int buf_size)
 
376
                             const uint8_t *buf, int buf_size)
378
377
{
379
378
    AVG726Context *c = avctx->priv_data;
380
379
    short *samples = data;
388
387
    mask = (1<<c->code_size) - 1;
389
388
    init_get_bits(&gb, buf, buf_size * 8);
390
389
    if (c->bits_left) {
391
 
        int s = c->code_size - c->bits_left;;
 
390
        int s = c->code_size - c->bits_left;
392
391
        code = (c->bit_buffer << s) | get_bits(&gb, s);
393
392
        *samples++ = g726_decode(&c->c, code & mask);
394
393
    }
414
413
    g726_encode_frame,
415
414
    g726_close,
416
415
    NULL,
 
416
    .long_name = "G.726 ADPCM",
417
417
};
418
418
#endif //CONFIG_ENCODERS
419
419
 
426
426
    NULL,
427
427
    g726_close,
428
428
    g726_decode_frame,
 
429
    .long_name = "G.726 ADPCM",
429
430
};