~ubuntu-branches/ubuntu/lucid/vlc/lucid-security

« back to all changes in this revision

Viewing changes to modules/stream_out/transrate/putvlc.h

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2009-09-25 14:44:17 UTC
  • mfrom: (3.5.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090925144417-87vomt575d0agvqa
Tags: 1.0.2-1ubuntu1
* Merge from Debian unstable (LP: #435524), remaining changes:
  - build against xulrunner-dev instead of iceape-dev
  - build against libx264-dev and install libx264 plugin
  - add Xb-Npp header to vlc package
  - recommend vlc-plugin-pulse for vlc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* vlc.h, variable length code tables (used by routines in putvlc.c)        */
2
 
 
3
 
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
4
 
 
5
 
/*
6
 
 * Disclaimer of Warranty
7
 
 *
8
 
 * These software programs are available to the user without any license fee or
9
 
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
10
 
 * any and all warranties, whether express, implied, or statuary, including any
11
 
 * implied warranties or merchantability or of fitness for a particular
12
 
 * purpose.  In no event shall the copyright-holder be liable for any
13
 
 * incidental, punitive, or consequential damages of any kind whatsoever
14
 
 * arising from the use of these programs.
15
 
 *
16
 
 * This disclaimer of warranty extends to the user of these programs and user's
17
 
 * customers, employees, agents, transferees, successors, and assigns.
18
 
 *
19
 
 * The MPEG Software Simulation Group does not represent or warrant that the
20
 
 * programs furnished hereunder are free of infringement of any third-party
21
 
 * patents.
22
 
 *
23
 
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
24
 
 * are subject to royalty fees to patent holders.  Many of these patents are
25
 
 * general enough such that they are unavoidable regardless of implementation
26
 
 * design.
27
 
 *
28
 
 */
29
 
 
30
 
/* type definitions for variable length code table entries */
31
 
 
32
 
typedef struct
33
 
{
34
 
  unsigned char code; /* right justified */
35
 
  char len;
36
 
} VLCtable;
37
 
 
38
 
/* for codes longer than 8 bits (excluding leading zeroes) */
39
 
typedef struct
40
 
{
41
 
  unsigned short code; /* right justified */
42
 
  char len;
43
 
} sVLCtable;
44
 
 
45
 
 
46
 
/* data from ISO/IEC 13818-2 DIS, Annex B, variable length code tables */
47
 
 
48
 
/* Table B-1, variable length codes for macroblock_address_increment
49
 
 *
50
 
 * indexed by [macroblock_address_increment-1]
51
 
 * 'macroblock_escape' is treated elsewhere
52
 
 */
53
 
 
54
 
static const VLCtable addrinctab[33]=
55
 
{
56
 
  {0x01,1},  {0x03,3},  {0x02,3},  {0x03,4},
57
 
  {0x02,4},  {0x03,5},  {0x02,5},  {0x07,7},
58
 
  {0x06,7},  {0x0b,8},  {0x0a,8},  {0x09,8},
59
 
  {0x08,8},  {0x07,8},  {0x06,8},  {0x17,10},
60
 
  {0x16,10}, {0x15,10}, {0x14,10}, {0x13,10},
61
 
  {0x12,10}, {0x23,11}, {0x22,11}, {0x21,11},
62
 
  {0x20,11}, {0x1f,11}, {0x1e,11}, {0x1d,11},
63
 
  {0x1c,11}, {0x1b,11}, {0x1a,11}, {0x19,11},
64
 
  {0x18,11}
65
 
};
66
 
 
67
 
 
68
 
/* Table B-2, B-3, B-4 variable length codes for macroblock_type
69
 
 *
70
 
 * indexed by [macroblock_type]
71
 
 */
72
 
 
73
 
static const VLCtable mbtypetab[3][32]=
74
 
{
75
 
 /* I */
76
 
 {
77
 
  {0,0}, {1,1}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
78
 
  {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
79
 
  {0,0}, {1,2}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
80
 
  {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}
81
 
 },
82
 
 /* P */
83
 
 {
84
 
  {0,0}, {3,5}, {1,2}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
85
 
  {1,3}, {0,0}, {1,1}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
86
 
  {0,0}, {1,6}, {1,5}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
87
 
  {0,0}, {0,0}, {2,5}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}
88
 
 },
89
 
 /* B */
90
 
 {
91
 
  {0,0}, {3,5}, {0,0}, {0,0}, {2,3}, {0,0}, {3,3}, {0,0},
92
 
  {2,4}, {0,0}, {3,4}, {0,0}, {2,2}, {0,0}, {3,2}, {0,0},
93
 
  {0,0}, {1,6}, {0,0}, {0,0}, {0,0}, {0,0}, {2,6}, {0,0},
94
 
  {0,0}, {0,0}, {3,6}, {0,0}, {0,0}, {0,0}, {2,5}, {0,0}
95
 
 }
96
 
};
97
 
 
98
 
 
99
 
/* Table B-5 ... B-8 variable length codes for macroblock_type in
100
 
 *  scalable sequences
101
 
 *
102
 
 * not implemented
103
 
 */
104
 
 
105
 
/* Table B-9, variable length codes for coded_block_pattern
106
 
 *
107
 
 * indexed by [coded_block_pattern]
108
 
 */
109
 
 
110
 
static const VLCtable cbptable[64]=
111
 
{
112
 
  {0x01,9}, {0x0b,5}, {0x09,5}, {0x0d,6},
113
 
  {0x0d,4}, {0x17,7}, {0x13,7}, {0x1f,8},
114
 
  {0x0c,4}, {0x16,7}, {0x12,7}, {0x1e,8},
115
 
  {0x13,5}, {0x1b,8}, {0x17,8}, {0x13,8},
116
 
  {0x0b,4}, {0x15,7}, {0x11,7}, {0x1d,8},
117
 
  {0x11,5}, {0x19,8}, {0x15,8}, {0x11,8},
118
 
  {0x0f,6}, {0x0f,8}, {0x0d,8}, {0x03,9},
119
 
  {0x0f,5}, {0x0b,8}, {0x07,8}, {0x07,9},
120
 
  {0x0a,4}, {0x14,7}, {0x10,7}, {0x1c,8},
121
 
  {0x0e,6}, {0x0e,8}, {0x0c,8}, {0x02,9},
122
 
  {0x10,5}, {0x18,8}, {0x14,8}, {0x10,8},
123
 
  {0x0e,5}, {0x0a,8}, {0x06,8}, {0x06,9},
124
 
  {0x12,5}, {0x1a,8}, {0x16,8}, {0x12,8},
125
 
  {0x0d,5}, {0x09,8}, {0x05,8}, {0x05,9},
126
 
  {0x0c,5}, {0x08,8}, {0x04,8}, {0x04,9},
127
 
  {0x07,3}, {0x0a,5}, {0x08,5}, {0x0c,6}
128
 
};
129
 
 
130
 
 
131
 
/* Table B-14, DCT coefficients table zero
132
 
 *
133
 
 * indexed by [run][level-1]
134
 
 * split into two tables (dct_code_tab1, dct_code_tab2) to reduce size
135
 
 * 'first DCT coefficient' condition and 'End of Block' are treated elsewhere
136
 
 * codes do not include s (sign bit)
137
 
 */
138
 
 
139
 
static const VLCtable dct_code_tab1[2][40]=
140
 
{
141
 
 /* run = 0, level = 1...40 */
142
 
 {
143
 
  {0x03, 2}, {0x04, 4}, {0x05, 5}, {0x06, 7},
144
 
  {0x26, 8}, {0x21, 8}, {0x0a,10}, {0x1d,12},
145
 
  {0x18,12}, {0x13,12}, {0x10,12}, {0x1a,13},
146
 
  {0x19,13}, {0x18,13}, {0x17,13}, {0x1f,14},
147
 
  {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
148
 
  {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
149
 
  {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
150
 
  {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
151
 
  {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
152
 
  {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15}
153
 
 },
154
 
 /* run = 1, level = 1...18 */
155
 
 {
156
 
  {0x03, 3}, {0x06, 6}, {0x25, 8}, {0x0c,10},
157
 
  {0x1b,12}, {0x16,13}, {0x15,13}, {0x1f,15},
158
 
  {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
159
 
  {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
160
 
  {0x11,16}, {0x10,16}, {0x00, 0}, {0x00, 0},
161
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
162
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
163
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
164
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
165
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}
166
 
 }
167
 
};
168
 
 
169
 
static const VLCtable dct_code_tab2[30][5]=
170
 
{
171
 
  /* run = 2...31, level = 1...5 */
172
 
  {{0x05, 4}, {0x04, 7}, {0x0b,10}, {0x14,12}, {0x14,13}},
173
 
  {{0x07, 5}, {0x24, 8}, {0x1c,12}, {0x13,13}, {0x00, 0}},
174
 
  {{0x06, 5}, {0x0f,10}, {0x12,12}, {0x00, 0}, {0x00, 0}},
175
 
  {{0x07, 6}, {0x09,10}, {0x12,13}, {0x00, 0}, {0x00, 0}},
176
 
  {{0x05, 6}, {0x1e,12}, {0x14,16}, {0x00, 0}, {0x00, 0}},
177
 
  {{0x04, 6}, {0x15,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
178
 
  {{0x07, 7}, {0x11,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
179
 
  {{0x05, 7}, {0x11,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
180
 
  {{0x27, 8}, {0x10,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
181
 
  {{0x23, 8}, {0x1a,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
182
 
  {{0x22, 8}, {0x19,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
183
 
  {{0x20, 8}, {0x18,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
184
 
  {{0x0e,10}, {0x17,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
185
 
  {{0x0d,10}, {0x16,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
186
 
  {{0x08,10}, {0x15,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
187
 
  {{0x1f,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
188
 
  {{0x1a,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
189
 
  {{0x19,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
190
 
  {{0x17,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
191
 
  {{0x16,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
192
 
  {{0x1f,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
193
 
  {{0x1e,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
194
 
  {{0x1d,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
195
 
  {{0x1c,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
196
 
  {{0x1b,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
197
 
  {{0x1f,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
198
 
  {{0x1e,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
199
 
  {{0x1d,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
200
 
  {{0x1c,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
201
 
  {{0x1b,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}}
202
 
};
203
 
 
204
 
 
205
 
/* Table B-15, DCT coefficients table one
206
 
 *
207
 
 * indexed by [run][level-1]
208
 
 * split into two tables (dct_code_tab1a, dct_code_tab2a) to reduce size
209
 
 * 'End of Block' is treated elsewhere
210
 
 * codes do not include s (sign bit)
211
 
 */
212
 
 
213
 
static const VLCtable dct_code_tab1a[2][40]=
214
 
{
215
 
 /* run = 0, level = 1...40 */
216
 
 {
217
 
  {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
218
 
  {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
219
 
  {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
220
 
  {0xfb, 8}, {0xfe, 8}, {0xff, 8}, {0x1f,14},
221
 
  {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
222
 
  {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
223
 
  {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
224
 
  {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
225
 
  {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
226
 
  {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15}
227
 
 },
228
 
 /* run = 1, level = 1...18 */
229
 
 {
230
 
  {0x02, 3}, {0x06, 5}, {0x79, 7}, {0x27, 8},
231
 
  {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15},
232
 
  {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
233
 
  {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
234
 
  {0x11,16}, {0x10,16}, {0x00, 0}, {0x00, 0},
235
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
236
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
237
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
238
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
239
 
  {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}
240
 
 }
241
 
};
242
 
 
243
 
static const VLCtable dct_code_tab2a[30][5]=
244
 
{
245
 
  /* run = 2...31, level = 1...5 */
246
 
  {{0x05, 5}, {0x07, 7}, {0xfc, 8}, {0x0c,10}, {0x14,13}},
247
 
  {{0x07, 5}, {0x26, 8}, {0x1c,12}, {0x13,13}, {0x00, 0}},
248
 
  {{0x06, 6}, {0xfd, 8}, {0x12,12}, {0x00, 0}, {0x00, 0}},
249
 
  {{0x07, 6}, {0x04, 9}, {0x12,13}, {0x00, 0}, {0x00, 0}},
250
 
  {{0x06, 7}, {0x1e,12}, {0x14,16}, {0x00, 0}, {0x00, 0}},
251
 
  {{0x04, 7}, {0x15,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
252
 
  {{0x05, 7}, {0x11,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
253
 
  {{0x78, 7}, {0x11,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
254
 
  {{0x7a, 7}, {0x10,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
255
 
  {{0x21, 8}, {0x1a,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
256
 
  {{0x25, 8}, {0x19,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
257
 
  {{0x24, 8}, {0x18,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
258
 
  {{0x05, 9}, {0x17,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
259
 
  {{0x07, 9}, {0x16,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
260
 
  {{0x0d,10}, {0x15,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
261
 
  {{0x1f,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
262
 
  {{0x1a,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
263
 
  {{0x19,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
264
 
  {{0x17,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
265
 
  {{0x16,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
266
 
  {{0x1f,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
267
 
  {{0x1e,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
268
 
  {{0x1d,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
269
 
  {{0x1c,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
270
 
  {{0x1b,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
271
 
  {{0x1f,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
272
 
  {{0x1e,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
273
 
  {{0x1d,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
274
 
  {{0x1c,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
275
 
  {{0x1b,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}}
276
 
};
277
 
 
278
 
/* MPEG-4 matrices */
279
 
static const uint8_t mpeg4_default_intra_matrix[64] = {
280
 
  8, 17, 18, 19, 21, 23, 25, 27,
281
 
 17, 18, 19, 21, 23, 25, 27, 28,
282
 
 20, 21, 22, 23, 24, 26, 28, 30,
283
 
 21, 22, 23, 24, 26, 28, 30, 32,
284
 
 22, 23, 24, 26, 28, 30, 32, 35,
285
 
 23, 24, 26, 28, 30, 32, 35, 38,
286
 
 25, 26, 28, 30, 32, 35, 38, 41,
287
 
 27, 28, 30, 32, 35, 38, 41, 45,
288
 
};
289
 
 
290
 
static const uint8_t mpeg4_default_non_intra_matrix[64] = {
291
 
 16, 17, 18, 19, 20, 21, 22, 23,
292
 
 17, 18, 19, 20, 21, 22, 23, 24,
293
 
 18, 19, 20, 21, 22, 23, 24, 25,
294
 
 19, 20, 21, 22, 23, 24, 26, 27,
295
 
 20, 21, 22, 23, 25, 26, 27, 28,
296
 
 21, 22, 23, 24, 26, 27, 28, 30,
297
 
 22, 23, 24, 26, 27, 28, 30, 31,
298
 
 23, 24, 25, 27, 28, 30, 31, 33,
299
 
};
300