~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavcodec/ivi_common.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-30 14:27:42 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430142742-quvblxk1tj6adlh5
Tags: 4:0.7~b1-1ubuntu1
* Merge from debian. Remaining changes:
  - don't build against libfaad, libdirac, librtmp and libopenjpeg
    (all in universe)
  - explicitly --enable-pic on powerpc, cf. LP #654666
  - different arm configure bits that should probably better be
    merged into debian
* Cherry-picked from git: 
  - install doc/APIChanges and refer to them in NEWS.Debian (Closes: #623682)
  - don't try to install non-existing documentation, fixes FTBFS on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Copyright (c) 2009 Maxim Poliakovski
5
5
 *
6
 
 * This file is part of FFmpeg.
 
6
 * This file is part of Libav.
7
7
 *
8
 
 * FFmpeg is free software; you can redistribute it and/or
 
8
 * Libav is free software; you can redistribute it and/or
9
9
 * modify it under the terms of the GNU Lesser General Public
10
10
 * License as published by the Free Software Foundation; either
11
11
 * version 2.1 of the License, or (at your option) any later version.
12
12
 *
13
 
 * FFmpeg is distributed in the hope that it will be useful,
 
13
 * Libav is distributed in the hope that it will be useful,
14
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
16
 * Lesser General Public License for more details.
17
17
 *
18
18
 * You should have received a copy of the GNU Lesser General Public
19
 
 * License along with FFmpeg; if not, write to the Free Software
 
19
 * License along with Libav; if not, write to the Free Software
20
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
21
 */
22
22
 
68
68
 
69
69
 
70
70
/**
 
71
 *  Common scan patterns (defined in ivi_common.c)
 
72
 */
 
73
extern const uint8_t ff_ivi_vertical_scan_8x8[64];
 
74
extern const uint8_t ff_ivi_horizontal_scan_8x8[64];
 
75
extern const uint8_t ff_ivi_direct_scan_4x4[16];
 
76
 
 
77
 
 
78
/**
 
79
 *  Declare inverse transform function types
 
80
 */
 
81
typedef void (InvTransformPtr)(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags);
 
82
typedef void (DCTransformPtr) (const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
 
83
 
 
84
 
 
85
/**
71
86
 *  run-value (RLE) table descriptor
72
87
 */
73
88
typedef struct {
138
153
 
139
154
    IVIHuffTab      blk_vlc;        ///< vlc table for decoding block data
140
155
 
141
 
    uint16_t        *dequant_intra; ///< ptr to dequant tables for intra blocks
142
 
    uint16_t        *dequant_inter; ///< ptr dequant tables for inter blocks
143
156
    int             num_corr;       ///< number of correction entries
144
157
    uint8_t         corr[61*2];     ///< rvmap correction pairs
145
158
    int             rvmap_sel;      ///< rvmap table selector
146
159
    RVMapDesc       *rv_map;        ///< ptr to the RLE table for this band
147
160
    int             num_tiles;      ///< number of tiles in this band
148
161
    IVITile         *tiles;         ///< array of tile descriptors
149
 
    void (*inv_transform)(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags); ///< inverse transform function pointer
150
 
    void (*dc_transform) (const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);   ///< dc transform function pointer, it may be NULL
 
162
    InvTransformPtr *inv_transform;
 
163
    DCTransformPtr  *dc_transform;
151
164
    int             is_2d_trans;    ///< 1 indicates that the two-dimensional inverse transform is used
152
165
    int32_t         checksum;       ///< for debug purposes
153
166
    int             checksum_present;
154
167
    int             bufsize;        ///< band buffer size in bytes
155
 
    const uint8_t   *intra_base;    ///< quantization matrix for intra blocks
156
 
    const uint8_t   *inter_base;    ///< quantization matrix for inter blocks
 
168
    const uint16_t  *intra_base;    ///< quantization matrix for intra blocks
 
169
    const uint16_t  *inter_base;    ///< quantization matrix for inter blocks
157
170
    const uint8_t   *intra_scale;   ///< quantization coefficient for intra blocks
158
171
    const uint8_t   *inter_scale;   ///< quantization coefficient for inter blocks
159
172
} IVIBandDesc;
181
194
    uint8_t     chroma_bands;
182
195
} IVIPicConfig;
183
196
 
184
 
/** compares some properties of two pictures */
 
197
/** compare some properties of two pictures */
185
198
static inline int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2)
186
199
{
187
200
    return (str1->pic_width    != str2->pic_width    || str1->pic_height    != str2->pic_height    ||
200
213
/** convert unsigned values into signed ones (the sign is in the LSB) */
201
214
#define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
202
215
 
203
 
/** scales motion vector */
 
216
/** scale motion vector */
204
217
static inline int ivi_scale_mv(int mv, int mv_scale)
205
218
{
206
219
    return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
207
220
}
208
221
 
209
222
/**
210
 
 *  Generates a huffman codebook from the given descriptor
211
 
 *  and converts it into the FFmpeg VLC table.
 
223
 *  Generate a huffman codebook from the given descriptor
 
224
 *  and convert it into the Libav VLC table.
212
225
 *
213
 
 *  @param cb   [in]  pointer to codebook descriptor
214
 
 *  @param vlc  [out] where to place the generated VLC table
215
 
 *  @param flag [in]  flag: 1 - for static or 0 for dynamic tables
 
226
 *  @param[in]   cb    pointer to codebook descriptor
 
227
 *  @param[out]  vlc   where to place the generated VLC table
 
228
 *  @param[in]   flag  flag: 1 - for static or 0 for dynamic tables
216
229
 *  @return     result code: 0 - OK, -1 = error (invalid codebook descriptor)
217
230
 */
218
231
int  ff_ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag);
219
232
 
220
233
/**
221
 
 * Initializes static codes used for macroblock and block decoding.
 
234
 * Initialize static codes used for macroblock and block decoding.
222
235
 */
223
236
void ff_ivi_init_static_vlc(void);
224
237
 
225
238
/**
226
 
 *  Decodes a huffman codebook descriptor from the bitstream
227
 
 *  and selects specified huffman table.
 
239
 *  Decode a huffman codebook descriptor from the bitstream
 
240
 *  and select specified huffman table.
228
241
 *
229
 
 *  @param gb           [in,out] the GetBit context
230
 
 *  @param desc_coded   [in] flag signalling if table descriptor was coded
231
 
 *  @param which_tab    [in] codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
232
 
 *  @param huff_tab     [out] pointer to the descriptor of the selected table
233
 
 *  @param avctx        [in] AVCodecContext pointer
 
242
 *  @param[in,out]  gb          the GetBit context
 
243
 *  @param[in]      desc_coded  flag signalling if table descriptor was coded
 
244
 *  @param[in]      which_tab   codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
 
245
 *  @param[out]     huff_tab    pointer to the descriptor of the selected table
 
246
 *  @param[in]      avctx       AVCodecContext pointer
234
247
 *  @return             zero on success, negative value otherwise
235
248
 */
236
249
int  ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
237
250
                          IVIHuffTab *huff_tab, AVCodecContext *avctx);
238
251
 
239
252
/**
240
 
 *  Compares two huffman codebook descriptors.
 
253
 *  Compare two huffman codebook descriptors.
241
254
 *
242
 
 *  @param desc1    [in] ptr to the 1st descriptor to compare
243
 
 *  @param desc2    [in] ptr to the 2nd descriptor to compare
 
255
 *  @param[in]  desc1  ptr to the 1st descriptor to compare
 
256
 *  @param[in]  desc2  ptr to the 2nd descriptor to compare
244
257
 *  @return         comparison result: 0 - equal, 1 - not equal
245
258
 */
246
259
int  ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2);
247
260
 
248
261
/**
249
 
 *  Copies huffman codebook descriptors.
 
262
 *  Copy huffman codebook descriptors.
250
263
 *
251
 
 *  @param dst  [out] ptr to the destination descriptor
252
 
 *  @param src  [in]  ptr to the source descriptor
 
264
 *  @param[out]  dst  ptr to the destination descriptor
 
265
 *  @param[in]   src  ptr to the source descriptor
253
266
 */
254
267
void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src);
255
268
 
256
269
/**
257
 
 *  Initializes planes (prepares descriptors, allocates buffers etc).
 
270
 *  Initialize planes (prepares descriptors, allocates buffers etc).
258
271
 *
259
 
 *  @param planes       [in,out] pointer to the array of the plane descriptors
260
 
 *  @param cfg          [in] pointer to the ivi_pic_config structure describing picture layout
 
272
 *  @param[in,out]  planes  pointer to the array of the plane descriptors
 
273
 *  @param[in]      cfg     pointer to the ivi_pic_config structure describing picture layout
261
274
 *  @return             result code: 0 - OK
262
275
 */
263
276
int  ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg);
264
277
 
265
278
/**
266
 
 *  Frees planes, bands and macroblocks buffers.
 
279
 *  Free planes, bands and macroblocks buffers.
267
280
 *
268
 
 *  @param planes       [in] pointer to the array of the plane descriptors
 
281
 *  @param[in]  planes  pointer to the array of the plane descriptors
269
282
 */
270
283
void ff_ivi_free_buffers(IVIPlaneDesc *planes);
271
284
 
272
285
/**
273
 
 *  Initializes tile and macroblock descriptors.
 
286
 *  Initialize tile and macroblock descriptors.
274
287
 *
275
 
 *  @param planes       [in,out] pointer to the array of the plane descriptors
276
 
 *  @param tile_width   [in]     tile width
277
 
 *  @param tile_height  [in]     tile height
 
288
 *  @param[in,out]  planes       pointer to the array of the plane descriptors
 
289
 *  @param[in]      tile_width   tile width
 
290
 *  @param[in]      tile_height  tile height
278
291
 *  @return             result code: 0 - OK
279
292
 */
280
293
int  ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
281
294
 
282
295
/**
283
 
 *  Decodes size of the tile data.
 
296
 *  Decode size of the tile data.
284
297
 *  The size is stored as a variable-length field having the following format:
285
298
 *  if (tile_data_size < 255) than this field is only one byte long
286
299
 *  if (tile_data_size >= 255) than this field four is byte long: 0xFF X1 X2 X3
287
300
 *  where X1-X3 is size of the tile data
288
301
 *
289
 
 *  @param gb   [in,out] the GetBit context
 
302
 *  @param[in,out]  gb  the GetBit context
290
303
 *  @return     size of the tile data in bytes
291
304
 */
292
305
int  ff_ivi_dec_tile_data_size(GetBitContext *gb);
293
306
 
294
307
/**
295
 
 *  Decodes block data:
296
 
 *  extracts huffman-coded transform coefficients from the bitstream,
297
 
 *  dequantizes them, applies inverse transform and motion compensation
 
308
 *  Decode block data:
 
309
 *  extract huffman-coded transform coefficients from the bitstream,
 
310
 *  dequantize them, apply inverse transform and motion compensation
298
311
 *  in order to reconstruct the picture.
299
312
 *
300
 
 *  @param gb   [in,out] the GetBit context
301
 
 *  @param band [in]     pointer to the band descriptor
302
 
 *  @param tile [in]     pointer to the tile descriptor
 
313
 *  @param[in,out]  gb    the GetBit context
 
314
 *  @param[in]      band  pointer to the band descriptor
 
315
 *  @param[in]      tile  pointer to the tile descriptor
303
316
 *  @return     result code: 0 - OK, -1 = error (corrupted blocks data)
304
317
 */
305
318
int  ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile);
306
319
 
307
320
/**
308
 
 *  Handles empty tiles by performing data copying and motion
 
321
 *  Handle empty tiles by performing data copying and motion
309
322
 *  compensation respectively.
310
323
 *
311
 
 *  @param avctx    [in] ptr to the AVCodecContext
312
 
 *  @param band     [in] pointer to the band descriptor
313
 
 *  @param tile     [in] pointer to the tile descriptor
314
 
 *  @param mv_scale [in] scaling factor for motion vectors
 
324
 *  @param[in]  avctx     ptr to the AVCodecContext
 
325
 *  @param[in]  band      pointer to the band descriptor
 
326
 *  @param[in]  tile      pointer to the tile descriptor
 
327
 *  @param[in]  mv_scale  scaling factor for motion vectors
315
328
 */
316
329
void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
317
330
                               IVITile *tile, int32_t mv_scale);
318
331
 
319
332
/**
320
 
 *  Converts and outputs the current plane.
 
333
 *  Convert and output the current plane.
321
334
 *  This conversion is done by adding back the bias value of 128
322
335
 *  (subtracted in the encoder) and clipping the result.
323
336
 *
324
 
 *  @param plane        [in]  pointer to the descriptor of the plane being processed
325
 
 *  @param dst          [out] pointer to the buffer receiving converted pixels
326
 
 *  @param dst_pitch    [in]  pitch for moving to the next y line
 
337
 *  @param[in]   plane      pointer to the descriptor of the plane being processed
 
338
 *  @param[out]  dst        pointer to the buffer receiving converted pixels
 
339
 *  @param[in]   dst_pitch  pitch for moving to the next y line
327
340
 */
328
341
void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch);
329
342
 
330
343
#if IVI_DEBUG
331
344
/**
332
 
 *  Calculates band checksum from band data.
 
345
 *  Calculate band checksum from band data.
333
346
 */
334
347
uint16_t ivi_calc_band_checksum (IVIBandDesc *band);
335
348
 
336
349
/**
337
 
 *  Verifies that band data lies in range.
 
350
 *  Verify that band data lies in range.
338
351
 */
339
352
int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch);
340
353
#endif