Browse code

Indeo 5 decoder

Originally committed as revision 21695 to svn://svn.ffmpeg.org/ffmpeg/trunk

Kostya Shishkov authored on 2010/02/09 16:55:07
Showing 8 changed files
... ...
@@ -55,6 +55,7 @@ version <next>:
55 55
 - enable symbol versioning by default for linkers that support it
56 56
 - IFF PBM/ILBM bitmap decoder
57 57
 - concat protocol
58
+- Indeo 5 decoder
58 59
 
59 60
 
60 61
 
... ...
@@ -136,7 +136,9 @@ Codecs:
136 136
   idcinvideo.c                          Mike Melanson
137 137
   imc*                                  Benjamin Larsson
138 138
   indeo2*                               Kostya Shishkov
139
+  indeo5*                               Kostya Shishkov
139 140
   interplayvideo.c                      Mike Melanson
141
+  ivi*                                  Kostya Shishkov
140 142
   jpeg_ls.c                             Kostya Shishkov
141 143
   kmvc.c                                Kostya Shishkov
142 144
   lcl*.c                                Roberto Togni, Reimar Doeffinger
... ...
@@ -394,6 +394,7 @@ following image formats are supported:
394 394
 @item Intel H.263            @tab     @tab  X
395 395
 @item Intel Indeo 2          @tab     @tab  X
396 396
 @item Intel Indeo 3          @tab     @tab  X
397
+@item Intel Indeo 5          @tab     @tab  X
397 398
 @item Interplay C93          @tab     @tab  X
398 399
     @tab Used in the game Cyberia from Interplay.
399 400
 @item Interplay MVE video    @tab     @tab  X
... ...
@@ -149,6 +149,7 @@ OBJS-$(CONFIG_IFF_ILBM_DECODER)        += iff.o
149 149
 OBJS-$(CONFIG_IMC_DECODER)             += imc.o
150 150
 OBJS-$(CONFIG_INDEO2_DECODER)          += indeo2.o
151 151
 OBJS-$(CONFIG_INDEO3_DECODER)          += indeo3.o
152
+OBJS-$(CONFIG_INDEO5_DECODER)          += indeo5.o ivi_common.o ivi_dsp.o
152 153
 OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER)  += dpcm.o
153 154
 OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
154 155
 OBJS-$(CONFIG_JPEGLS_DECODER)          += jpeglsdec.o jpegls.o \
... ...
@@ -118,6 +118,7 @@ void avcodec_register_all(void)
118 118
     REGISTER_DECODER (IFF_ILBM, iff_ilbm);
119 119
     REGISTER_DECODER (INDEO2, indeo2);
120 120
     REGISTER_DECODER (INDEO3, indeo3);
121
+    REGISTER_DECODER (INDEO5, indeo5);
121 122
     REGISTER_DECODER (INTERPLAY_VIDEO, interplay_video);
122 123
     REGISTER_ENCDEC  (JPEGLS, jpegls);
123 124
     REGISTER_DECODER (KMVC, kmvc);
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/avutil.h"
31 31
 
32 32
 #define LIBAVCODEC_VERSION_MAJOR 52
33
-#define LIBAVCODEC_VERSION_MINOR 52
33
+#define LIBAVCODEC_VERSION_MINOR 53
34 34
 #define LIBAVCODEC_VERSION_MICRO  0
35 35
 
36 36
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
37 37
new file mode 100644
... ...
@@ -0,0 +1,885 @@
0
+/*
1
+ * Indeo Video Interactive v5 compatible decoder
2
+ * Copyright (c) 2009 Maxim Poliakovski
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+/**
22
+ * @file libavcodec/indeo5.c
23
+ * Indeo Video Interactive version 5 decoder
24
+ *
25
+ * Indeo5 data is usually transported within .avi or .mov files.
26
+ * Known FOURCCs: 'IV50'
27
+ */
28
+
29
+#define ALT_BITSTREAM_READER_LE
30
+#include "avcodec.h"
31
+#include "get_bits.h"
32
+#include "ivi_dsp.h"
33
+#include "ivi_common.h"
34
+#include "indeo5data.h"
35
+
36
+/**
37
+ *  Indeo5 frame types.
38
+ */
39
+enum {
40
+    FRAMETYPE_INTRA       = 0,
41
+    FRAMETYPE_INTER       = 1,  ///< non-droppable P-frame
42
+    FRAMETYPE_INTER_SCAL  = 2,  ///< droppable P-frame used in the scalability mode
43
+    FRAMETYPE_INTER_NOREF = 3,  ///< droppable P-frame
44
+    FRAMETYPE_NULL        = 4   ///< empty frame with no data
45
+};
46
+
47
+#define IVI5_PIC_SIZE_ESC       15
48
+
49
+#define IVI5_IS_PROTECTED       0x20
50
+
51
+typedef struct {
52
+    GetBitContext   gb;
53
+    AVFrame         frame;
54
+    RVMapDesc       rvmap_tabs[9];   ///< local corrected copy of the static rvmap tables
55
+    IVIPlaneDesc    planes[3];       ///< color planes
56
+    const uint8_t   *frame_data;     ///< input frame data pointer
57
+    int             buf_switch;      ///< used to switch between three buffers
58
+    int             dst_buf;
59
+    int             ref_buf;
60
+    uint32_t        frame_size;      ///< frame size in bytes
61
+    int             frame_type;
62
+    int             prev_frame_type; ///< frame type of the previous frame
63
+    int             frame_num;
64
+    uint32_t        pic_hdr_size;    ///< picture header size in bytes
65
+    uint8_t         frame_flags;
66
+    uint16_t        checksum;        ///< frame checksum
67
+
68
+    int16_t         mb_huff_sel;     ///< MB huffman table selector
69
+    IVIHuffDesc     mb_huff_desc;    ///< MB table descriptor associated with the selector above
70
+    VLC             *mb_vlc;         ///< ptr to the vlc table for decoding macroblock data
71
+    VLC             mb_vlc_cust;     ///< custom macroblock vlc table
72
+
73
+    uint16_t        gop_hdr_size;
74
+    uint8_t         gop_flags;
75
+    int             is_scalable;
76
+    uint32_t        lock_word;
77
+    IVIPicConfig    pic_conf;
78
+} IVI5DecContext;
79
+
80
+//! static vlc tables (initialized at startup)
81
+static VLC mb_vlc_tabs [8];
82
+static VLC blk_vlc_tabs[8];
83
+
84
+
85
+/**
86
+ *  Decodes Indeo5 GOP (Group of pictures) header.
87
+ *  This header is present in key frames only.
88
+ *  It defines parameters for all frames in a GOP.
89
+ *
90
+ *  @param ctx      [in,out] ptr to the decoder context
91
+ *  @param avctx    [in] ptr to the AVCodecContext
92
+ *  @return         result code: 0 = OK, -1 = error
93
+ */
94
+static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx)
95
+{
96
+    int             result, i, p, tile_size, pic_size_indx, mb_size, blk_size, blk_size_changed = 0;
97
+    IVIBandDesc     *band, *band1, *band2;
98
+    IVIPicConfig    pic_conf;
99
+
100
+    ctx->gop_flags = get_bits(&ctx->gb, 8);
101
+
102
+    ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0;
103
+
104
+    if (ctx->gop_flags & IVI5_IS_PROTECTED)
105
+        ctx->lock_word = get_bits_long(&ctx->gb, 32);
106
+
107
+    tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
108
+    if (tile_size > 256) {
109
+        av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
110
+        return -1;
111
+    }
112
+
113
+    /* decode number of wavelet bands */
114
+    /* num_levels * 3 + 1 */
115
+    pic_conf.luma_bands   = get_bits(&ctx->gb, 2) * 3 + 1;
116
+    pic_conf.chroma_bands = get_bits1(&ctx->gb)   * 3 + 1;
117
+    ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
118
+    if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
119
+        av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
120
+               pic_conf.luma_bands, pic_conf.chroma_bands);
121
+        return -1;
122
+    }
123
+
124
+    pic_size_indx = get_bits(&ctx->gb, 4);
125
+    if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
126
+        pic_conf.pic_height = get_bits(&ctx->gb, 13);
127
+        pic_conf.pic_width  = get_bits(&ctx->gb, 13);
128
+    } else {
129
+        pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
130
+        pic_conf.pic_width  = ivi5_common_pic_sizes[pic_size_indx * 2    ] << 2;
131
+    }
132
+
133
+    if (ctx->gop_flags & 2) {
134
+        av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n");
135
+        return -1;
136
+    }
137
+
138
+    pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
139
+    pic_conf.chroma_width  = (pic_conf.pic_width  + 3) >> 2;
140
+
141
+    if (!tile_size) {
142
+        pic_conf.tile_height = pic_conf.pic_height;
143
+        pic_conf.tile_width  = pic_conf.pic_width;
144
+    } else {
145
+        pic_conf.tile_height = pic_conf.tile_width = tile_size;
146
+    }
147
+
148
+    /* check if picture layout was changed and reallocate buffers */
149
+    if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
150
+        result = ff_ivi_init_planes(ctx->planes, &pic_conf);
151
+        if (result) {
152
+            av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
153
+            return -1;
154
+        }
155
+        ctx->pic_conf = pic_conf;
156
+        blk_size_changed = 1; /* force reallocation of the internal structures */
157
+    }
158
+
159
+    for (p = 0; p <= 1; p++) {
160
+        for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
161
+            band = &ctx->planes[p].bands[i];
162
+
163
+            band->is_halfpel = get_bits1(&ctx->gb);
164
+
165
+            mb_size  = get_bits1(&ctx->gb);
166
+            blk_size = 8 >> get_bits1(&ctx->gb);
167
+            mb_size  = blk_size << !mb_size;
168
+
169
+            blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size;
170
+            if (blk_size_changed) {
171
+                band->mb_size  = mb_size;
172
+                band->blk_size = blk_size;
173
+            }
174
+
175
+            if (get_bits1(&ctx->gb)) {
176
+                av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n");
177
+                return -1;
178
+            }
179
+
180
+            /* select transform function and scan pattern according to plane and band number */
181
+            switch ((p << 2) + i) {
182
+            case 0:
183
+                band->inv_transform = ff_ivi_inverse_slant_8x8;
184
+                band->dc_transform  = ff_ivi_dc_slant_2d;
185
+                band->scan          = ivi5_scans8x8[0];
186
+                break;
187
+
188
+            case 1:
189
+                band->inv_transform = ff_ivi_row_slant8;
190
+                band->dc_transform  = ff_ivi_dc_row_slant;
191
+                band->scan          = ivi5_scans8x8[1];
192
+                break;
193
+
194
+            case 2:
195
+                band->inv_transform = ff_ivi_col_slant8;
196
+                band->dc_transform  = ff_ivi_dc_col_slant;
197
+                band->scan          = ivi5_scans8x8[2];
198
+                break;
199
+
200
+            case 3:
201
+                band->inv_transform = ff_ivi_put_pixels_8x8;
202
+                band->dc_transform  = ff_ivi_put_dc_pixel_8x8;
203
+                band->scan          = ivi5_scans8x8[2];
204
+                break;
205
+
206
+            case 4:
207
+                band->inv_transform = ff_ivi_inverse_slant_4x4;
208
+                band->dc_transform  = ff_ivi_dc_slant_2d;
209
+                band->scan          = ivi5_scan4x4;
210
+                break;
211
+            }
212
+
213
+            band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 ||
214
+                                band->inv_transform == ff_ivi_inverse_slant_4x4;
215
+
216
+            /* select dequant matrix according to plane and band number */
217
+            if (!p) {
218
+                band->quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
219
+            } else {
220
+                band->quant_mat = 5;
221
+            }
222
+
223
+            if (get_bits(&ctx->gb, 2)) {
224
+                av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
225
+                return -1;
226
+            }
227
+        }
228
+    }
229
+
230
+    /* copy chroma parameters into the 2nd chroma plane */
231
+    for (i = 0; i < pic_conf.chroma_bands; i++) {
232
+        band1 = &ctx->planes[1].bands[i];
233
+        band2 = &ctx->planes[2].bands[i];
234
+
235
+        band2->width         = band1->width;
236
+        band2->height        = band1->height;
237
+        band2->mb_size       = band1->mb_size;
238
+        band2->blk_size      = band1->blk_size;
239
+        band2->is_halfpel    = band1->is_halfpel;
240
+        band2->quant_mat     = band1->quant_mat;
241
+        band2->scan          = band1->scan;
242
+        band2->inv_transform = band1->inv_transform;
243
+        band2->dc_transform  = band1->dc_transform;
244
+        band2->is_2d_trans   = band1->is_2d_trans;
245
+    }
246
+
247
+    /* reallocate internal structures if needed */
248
+    if (blk_size_changed) {
249
+        result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
250
+                                   pic_conf.tile_height);
251
+        if (result) {
252
+            av_log(avctx, AV_LOG_ERROR,
253
+                   "Couldn't reallocate internal structures!\n");
254
+            return -1;
255
+        }
256
+    }
257
+
258
+    if (ctx->gop_flags & 8) {
259
+        if (get_bits(&ctx->gb, 3)) {
260
+            av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
261
+            return -1;
262
+        }
263
+
264
+        if (get_bits1(&ctx->gb))
265
+            skip_bits_long(&ctx->gb, 24); /* skip transparency fill color */
266
+    }
267
+
268
+    align_get_bits(&ctx->gb);
269
+
270
+    skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */
271
+
272
+    /* skip GOP extension if any */
273
+    if (get_bits1(&ctx->gb)) {
274
+        do {
275
+            i = get_bits(&ctx->gb, 16);
276
+        } while (i & 0x8000);
277
+    }
278
+
279
+    align_get_bits(&ctx->gb);
280
+
281
+    return 0;
282
+}
283
+
284
+
285
+/**
286
+ *  Skips a header extension.
287
+ *
288
+ *  @param gb   [in,out] the GetBit context
289
+ */
290
+static inline void skip_hdr_extension(GetBitContext *gb)
291
+{
292
+    int i, len;
293
+
294
+    do {
295
+        len = get_bits(gb, 8);
296
+        for (i = 0; i < len; i++) skip_bits(gb, 8);
297
+    } while(len);
298
+}
299
+
300
+
301
+/**
302
+ *  Decodes Indeo5 picture header.
303
+ *
304
+ *  @param ctx      [in,out] ptr to the decoder context
305
+ *  @param avctx    [in] ptr to the AVCodecContext
306
+ *  @return         result code: 0 = OK, -1 = error
307
+ */
308
+static int decode_pic_hdr(IVI5DecContext *ctx, AVCodecContext *avctx)
309
+{
310
+    int         result;
311
+    IVIHuffDesc new_huff;
312
+
313
+    if (get_bits(&ctx->gb, 5) != 0x1F) {
314
+        av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
315
+        return -1;
316
+    }
317
+
318
+    ctx->prev_frame_type = ctx->frame_type;
319
+    ctx->frame_type      = get_bits(&ctx->gb, 3);
320
+    if (ctx->frame_type >= 5) {
321
+        av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
322
+        return -1;
323
+    }
324
+
325
+    ctx->frame_num = get_bits(&ctx->gb, 8);
326
+
327
+    if (ctx->frame_type == FRAMETYPE_INTRA) {
328
+        if (decode_gop_header(ctx, avctx))
329
+            return -1;
330
+    }
331
+
332
+    if (ctx->frame_type != FRAMETYPE_NULL) {
333
+        ctx->frame_flags = get_bits(&ctx->gb, 8);
334
+
335
+        ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits_long(&ctx->gb, 24) : 0;
336
+
337
+        ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
338
+
339
+        /* skip unknown extension if any */
340
+        if (ctx->frame_flags & 0x20)
341
+            skip_hdr_extension(&ctx->gb); /* XXX: untested */
342
+
343
+        /* decode macroblock huffman codebook */
344
+        if (ctx->frame_flags & 0x40) {
345
+            ctx->mb_huff_sel = ff_ivi_dec_huff_desc(&ctx->gb, &new_huff);
346
+            if (ctx->mb_huff_sel != 7) {
347
+                ctx->mb_vlc = &mb_vlc_tabs[ctx->mb_huff_sel];
348
+            } else {
349
+                if (ff_ivi_huff_desc_cmp(&new_huff, &ctx->mb_huff_desc)) {
350
+                    ff_ivi_huff_desc_copy(&ctx->mb_huff_desc, &new_huff);
351
+
352
+                    if (ctx->mb_vlc_cust.table)
353
+                        free_vlc(&ctx->mb_vlc_cust);
354
+                    result = ff_ivi_create_huff_from_desc(&ctx->mb_huff_desc,
355
+                                                          &ctx->mb_vlc_cust, 0);
356
+                    if (result) {
357
+                        av_log(avctx, AV_LOG_ERROR, "Error while initializing custom macroblock vlc table!\n");
358
+                        return -1;
359
+                    }
360
+                }
361
+                ctx->mb_vlc = &ctx->mb_vlc_cust;
362
+            }
363
+        } else {
364
+            ctx->mb_vlc = &mb_vlc_tabs[7]; /* select the default macroblock huffman table */
365
+        }
366
+
367
+        skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
368
+    }
369
+
370
+    align_get_bits(&ctx->gb);
371
+
372
+    return 0;
373
+}
374
+
375
+
376
+/**
377
+ *  Decodes Indeo5 band header.
378
+ *
379
+ *  @param ctx      [in,out] ptr to the decoder context
380
+ *  @param band     [in,out] ptr to the band descriptor
381
+ *  @param avctx    [in] ptr to the AVCodecContext
382
+ *  @return         result code: 0 = OK, -1 = error
383
+ */
384
+static int decode_band_hdr(IVI5DecContext *ctx, IVIBandDesc *band,
385
+                           AVCodecContext *avctx)
386
+{
387
+    int         i, result;
388
+    uint8_t     band_flags;
389
+    IVIHuffDesc new_huff;
390
+
391
+    band_flags = get_bits(&ctx->gb, 8);
392
+
393
+    if (band_flags & 1) {
394
+        band->is_empty = 1;
395
+        return 0;
396
+    }
397
+
398
+    band->data_size = (ctx->frame_flags & 0x80) ? get_bits_long(&ctx->gb, 24) : 0;
399
+
400
+    band->inherit_mv     = band_flags & 2;
401
+    band->inherit_qdelta = band_flags & 8;
402
+    band->qdelta_present = band_flags & 4;
403
+    if (!band->qdelta_present) band->inherit_qdelta = 1;
404
+
405
+    /* decode rvmap probability corrections if any */
406
+    band->num_corr = 0; /* there are no corrections */
407
+    if (band_flags & 0x10) {
408
+        band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
409
+        if (band->num_corr > 61) {
410
+            av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
411
+                   band->num_corr);
412
+            return -1;
413
+        }
414
+
415
+        /* read correction pairs */
416
+        for (i = 0; i < band->num_corr * 2; i++)
417
+            band->corr[i] = get_bits(&ctx->gb, 8);
418
+    }
419
+
420
+    /* select appropriate rvmap table for this band */
421
+    band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
422
+
423
+    /* decode block huffman codebook */
424
+    if (band_flags & 0x80) {
425
+        band->huff_sel = ff_ivi_dec_huff_desc(&ctx->gb, &new_huff);
426
+        if (band->huff_sel != 7) {
427
+            band->blk_vlc = &blk_vlc_tabs[band->huff_sel];
428
+        } else {
429
+            if (ff_ivi_huff_desc_cmp(&new_huff, &band->huff_desc)) {
430
+                ff_ivi_huff_desc_copy(&band->huff_desc, &new_huff);
431
+
432
+                if (band->blk_vlc_cust.table)
433
+                    free_vlc(&band->blk_vlc_cust);
434
+                result = ff_ivi_create_huff_from_desc(&band->huff_desc,
435
+                                                      &band->blk_vlc_cust, 0);
436
+                if (result) {
437
+                    av_log(avctx, AV_LOG_ERROR, "Error while initializing custom block vlc table!\n");
438
+                    return -1;
439
+                }
440
+            }
441
+            band->blk_vlc = &band->blk_vlc_cust;
442
+        }
443
+    } else {
444
+        band->blk_vlc = &blk_vlc_tabs[7]; /* select the default macroblock huffman table */
445
+    }
446
+
447
+    band->checksum_present = get_bits1(&ctx->gb);
448
+    if (band->checksum_present)
449
+        band->checksum = get_bits(&ctx->gb, 16);
450
+
451
+    band->glob_quant = get_bits(&ctx->gb, 5);
452
+
453
+    /* skip unknown extension if any */
454
+    if (band_flags & 0x20) { /* XXX: untested */
455
+        align_get_bits(&ctx->gb);
456
+        skip_hdr_extension(&ctx->gb);
457
+    }
458
+
459
+    align_get_bits(&ctx->gb);
460
+
461
+    return 0;
462
+}
463
+
464
+
465
+/**
466
+ *  Decodes info (block type, cbp, quant delta, motion vector)
467
+ *  for all macroblocks in the current tile.
468
+ *
469
+ *  @param ctx      [in,out] ptr to the decoder context
470
+ *  @param band     [in,out] ptr to the band descriptor
471
+ *  @param tile     [in,out] ptr to the tile descriptor
472
+ *  @param avctx    [in] ptr to the AVCodecContext
473
+ *  @return         result code: 0 = OK, -1 = error
474
+ */
475
+static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band,
476
+                          IVITile *tile, AVCodecContext *avctx)
477
+{
478
+    int         x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
479
+                mv_scale, blks_per_mb;
480
+    IVIMbInfo   *mb, *ref_mb;
481
+    int         row_offset = band->mb_size * band->pitch;
482
+
483
+    mb     = tile->mbs;
484
+    ref_mb = tile->ref_mbs;
485
+    offs   = tile->ypos * band->pitch + tile->xpos;
486
+
487
+    /* scale factor for motion vectors */
488
+    mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
489
+    mv_x = mv_y = 0;
490
+
491
+    for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
492
+        mb_offset = offs;
493
+
494
+        for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
495
+            mb->xpos     = x;
496
+            mb->ypos     = y;
497
+            mb->buf_offs = mb_offset;
498
+
499
+            if (get_bits1(&ctx->gb)) {
500
+                if (ctx->frame_type == FRAMETYPE_INTRA) {
501
+                    av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
502
+                    return -1;
503
+                }
504
+                mb->type = 1; /* empty macroblocks are always INTER */
505
+                mb->cbp  = 0; /* all blocks are empty */
506
+
507
+                mb->q_delta = 0;
508
+                if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
509
+                    mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc->table,
510
+                                           IVI_VLC_BITS, 1);
511
+                    mb->q_delta = IVI_TOSIGNED(mb->q_delta);
512
+                }
513
+
514
+                mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
515
+                if (band->inherit_mv){
516
+                    /* motion vector inheritance */
517
+                    if (mv_scale) {
518
+                        mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
519
+                        mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
520
+                    } else {
521
+                        mb->mv_x = ref_mb->mv_x;
522
+                        mb->mv_y = ref_mb->mv_y;
523
+                    }
524
+                }
525
+            } else {
526
+                if (band->inherit_mv) {
527
+                    mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
528
+                } else if (ctx->frame_type == FRAMETYPE_INTRA) {
529
+                    mb->type = 0; /* mb_type is always INTRA for intra-frames */
530
+                } else {
531
+                    mb->type = get_bits1(&ctx->gb);
532
+                }
533
+
534
+                blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
535
+                mb->cbp = get_bits(&ctx->gb, blks_per_mb);
536
+
537
+                mb->q_delta = 0;
538
+                if (band->qdelta_present) {
539
+                    if (band->inherit_qdelta) {
540
+                        if (ref_mb) mb->q_delta = ref_mb->q_delta;
541
+                    } else if (mb->cbp || (!band->plane && !band->band_num &&
542
+                                           (ctx->frame_flags & 8))) {
543
+                        mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc->table,
544
+                                               IVI_VLC_BITS, 1);
545
+                        mb->q_delta = IVI_TOSIGNED(mb->q_delta);
546
+                    }
547
+                }
548
+
549
+                if (!mb->type) {
550
+                    mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
551
+                } else {
552
+                    if (band->inherit_mv){
553
+                        /* motion vector inheritance */
554
+                        if (mv_scale) {
555
+                            mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
556
+                            mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
557
+                        } else {
558
+                            mb->mv_x = ref_mb->mv_x;
559
+                            mb->mv_y = ref_mb->mv_y;
560
+                        }
561
+                    } else {
562
+                        /* decode motion vector deltas */
563
+                        mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc->table,
564
+                                            IVI_VLC_BITS, 1);
565
+                        mv_y += IVI_TOSIGNED(mv_delta);
566
+                        mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc->table,
567
+                                            IVI_VLC_BITS, 1);
568
+                        mv_x += IVI_TOSIGNED(mv_delta);
569
+                        mb->mv_x = mv_x;
570
+                        mb->mv_y = mv_y;
571
+                    }
572
+                }
573
+            }
574
+
575
+            mb++;
576
+            if (ref_mb)
577
+                ref_mb++;
578
+            mb_offset += band->mb_size;
579
+        }
580
+
581
+        offs += row_offset;
582
+    }
583
+
584
+    align_get_bits(&ctx->gb);
585
+
586
+    return 0;
587
+}
588
+
589
+
590
+/**
591
+ *  Decodes an Indeo5 band.
592
+ *
593
+ *  @param ctx      [in,out] ptr to the decoder context
594
+ *  @param band     [in,out] ptr to the band descriptor
595
+ *  @param avctx    [in] ptr to the AVCodecContext
596
+ *  @return         result code: 0 = OK, -1 = error
597
+ */
598
+static int decode_band(IVI5DecContext *ctx, int plane_num,
599
+                       IVIBandDesc *band, AVCodecContext *avctx)
600
+{
601
+    int         result, i, t, idx1, idx2;
602
+    IVITile     *tile;
603
+    uint16_t    chksum;
604
+
605
+    band->buf     = band->bufs[ctx->dst_buf];
606
+    band->ref_buf = band->bufs[ctx->ref_buf];
607
+    band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3);
608
+
609
+    result = decode_band_hdr(ctx, band, avctx);
610
+    if (result) {
611
+        av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n",
612
+               result);
613
+        return -1;
614
+    }
615
+
616
+    if (band->is_empty) {
617
+        av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n");
618
+        return -1;
619
+    }
620
+
621
+    band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel];
622
+
623
+    /* apply corrections to the selected rvmap table if present */
624
+    for (i = 0; i < band->num_corr; i++) {
625
+        idx1 = band->corr[i*2];
626
+        idx2 = band->corr[i*2+1];
627
+        FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
628
+        FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
629
+    }
630
+
631
+    for (t = 0; t < band->num_tiles; t++) {
632
+        tile = &band->tiles[t];
633
+
634
+        tile->is_empty = get_bits1(&ctx->gb);
635
+        if (tile->is_empty) {
636
+            ff_ivi_process_empty_tile(avctx, band, tile,
637
+                                      (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
638
+            align_get_bits(&ctx->gb);
639
+        } else {
640
+            tile->data_size = ff_ivi_dec_tile_data_size(&ctx->gb);
641
+
642
+            result = decode_mb_info(ctx, band, tile, avctx);
643
+            if (result < 0)
644
+                break;
645
+
646
+            if (band->blk_size == 8) {
647
+                band->intra_base  = &ivi5_base_quant_8x8_intra[band->quant_mat][0];
648
+                band->inter_base  = &ivi5_base_quant_8x8_inter[band->quant_mat][0];
649
+                band->intra_scale = &ivi5_scale_quant_8x8_intra[band->quant_mat][0];
650
+                band->inter_scale = &ivi5_scale_quant_8x8_inter[band->quant_mat][0];
651
+            } else {
652
+                band->intra_base  = ivi5_base_quant_4x4_intra;
653
+                band->inter_base  = ivi5_base_quant_4x4_inter;
654
+                band->intra_scale = ivi5_scale_quant_4x4_intra;
655
+                band->inter_scale = ivi5_scale_quant_4x4_inter;
656
+            }
657
+
658
+            result = ff_ivi_decode_blocks(&ctx->gb, band, tile);
659
+            if (result < 0) {
660
+                av_log(avctx, AV_LOG_ERROR, "Corrupted blocks data encountered!\n");
661
+                break;
662
+            }
663
+        }
664
+    }
665
+
666
+    /* restore the selected rvmap table by applying its corrections in reverse order */
667
+    for (i = band->num_corr-1; i >= 0; i--) {
668
+        idx1 = band->corr[i*2];
669
+        idx2 = band->corr[i*2+1];
670
+        FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
671
+        FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
672
+    }
673
+
674
+    if (IVI_DEBUG && band->checksum_present) {
675
+        chksum = ivi_calc_band_checksum(band);
676
+        if (chksum != band->checksum) {
677
+            av_log(avctx, AV_LOG_ERROR,
678
+                   "Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n",
679
+                   band->plane, band->band_num, band->checksum, chksum);
680
+        }
681
+    }
682
+
683
+    return result;
684
+}
685
+
686
+
687
+/**
688
+ *  Switches buffers.
689
+ *
690
+ *  @param ctx      [in,out] ptr to the decoder context
691
+ *  @param avctx    [in] ptr to the AVCodecContext
692
+ */
693
+static void switch_buffers(IVI5DecContext *ctx, AVCodecContext *avctx)
694
+{
695
+    switch (ctx->frame_type) {
696
+    case FRAMETYPE_INTRA:
697
+        ctx->buf_switch = 0;
698
+        ctx->dst_buf    = 0;
699
+        ctx->ref_buf    = 0;
700
+        break;
701
+    case FRAMETYPE_INTER:
702
+        ctx->buf_switch &= 1;
703
+        /* swap buffers only if there were no droppable frames */
704
+        if (ctx->prev_frame_type != FRAMETYPE_INTER_NOREF &&
705
+            ctx->prev_frame_type != FRAMETYPE_INTER_SCAL)
706
+            ctx->buf_switch ^= 1;
707
+        ctx->dst_buf = ctx->buf_switch;
708
+        ctx->ref_buf = ctx->buf_switch ^ 1;
709
+        break;
710
+    case FRAMETYPE_INTER_SCAL:
711
+        if (ctx->prev_frame_type == FRAMETYPE_INTER_NOREF)
712
+            break;
713
+        if (ctx->prev_frame_type != FRAMETYPE_INTER_SCAL) {
714
+            ctx->buf_switch ^= 1;
715
+            ctx->dst_buf     = ctx->buf_switch;
716
+            ctx->ref_buf     = ctx->buf_switch ^ 1;
717
+        } else {
718
+            ctx->buf_switch ^= 2;
719
+            ctx->dst_buf = 2;
720
+            ctx->ref_buf = ctx->buf_switch & 1;
721
+            if (!(ctx->buf_switch & 2))
722
+                FFSWAP(int, ctx->dst_buf, ctx->ref_buf);
723
+        }
724
+        break;
725
+    case FRAMETYPE_INTER_NOREF:
726
+        if (ctx->prev_frame_type == FRAMETYPE_INTER_SCAL) {
727
+            ctx->buf_switch ^= 2;
728
+            ctx->dst_buf = 2;
729
+            ctx->ref_buf = ctx->buf_switch & 1;
730
+            if (!(ctx->buf_switch & 2))
731
+                FFSWAP(int, ctx->dst_buf, ctx->ref_buf);
732
+        } else {
733
+            ctx->buf_switch ^= 1;
734
+            ctx->dst_buf     =  ctx->buf_switch & 1;
735
+            ctx->ref_buf     = (ctx->buf_switch & 1) ^ 1;
736
+        }
737
+        break;
738
+    case FRAMETYPE_NULL:
739
+        return;
740
+    default:
741
+        av_log(avctx, AV_LOG_ERROR, "unsupported frame type: %d\n", ctx->frame_type);
742
+    }
743
+}
744
+
745
+
746
+/**
747
+ *  Initializes Indeo5 decoder.
748
+ */
749
+static av_cold int decode_init(AVCodecContext *avctx)
750
+{
751
+    IVI5DecContext  *ctx = avctx->priv_data;
752
+    int             i, result;
753
+
754
+    /* initialize static vlc tables for macroblock/block signals */
755
+    for (i = 0; i < 8; i++) {
756
+        ff_ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i],  &mb_vlc_tabs[i],  1);
757
+        ff_ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &blk_vlc_tabs[i], 1);
758
+    }
759
+
760
+    /* copy rvmap tables in our context so we can apply changes to them */
761
+    memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));
762
+
763
+    /* set the initial picture layout according to the basic profile:
764
+       there is only one band per plane (no scalability), only one tile (no local decoding)
765
+       and picture format = YVU9 */
766
+    ctx->pic_conf.pic_width     = avctx->width;
767
+    ctx->pic_conf.pic_height    = avctx->height;
768
+    ctx->pic_conf.chroma_width  = (avctx->width  + 3) >> 2;
769
+    ctx->pic_conf.chroma_height = (avctx->height + 3) >> 2;
770
+    ctx->pic_conf.tile_width    = avctx->width;
771
+    ctx->pic_conf.tile_height   = avctx->height;
772
+    ctx->pic_conf.luma_bands    = ctx->pic_conf.chroma_bands = 1;
773
+
774
+    result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf);
775
+    if (result) {
776
+        av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
777
+        return -1;
778
+    }
779
+
780
+    avctx->pix_fmt = PIX_FMT_YUV410P;
781
+
782
+    return 0;
783
+}
784
+
785
+
786
+/**
787
+ *  main decoder function
788
+ */
789
+static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
790
+                        AVPacket *avpkt)
791
+{
792
+    IVI5DecContext  *ctx = avctx->priv_data;
793
+    const uint8_t   *buf = avpkt->data;
794
+    int             buf_size = avpkt->size;
795
+    int             result, p, b;
796
+
797
+    init_get_bits(&ctx->gb, buf, buf_size * 8);
798
+    ctx->frame_data = buf;
799
+    ctx->frame_size = buf_size;
800
+
801
+    result = decode_pic_hdr(ctx, avctx);
802
+    if (result) {
803
+        av_log(avctx, AV_LOG_ERROR,
804
+               "Error while decoding picture header: %d\n", result);
805
+        return -1;
806
+    }
807
+
808
+    if (ctx->gop_flags & IVI5_IS_PROTECTED) {
809
+        av_log(avctx, AV_LOG_ERROR, "Password-protected clip!\n");
810
+        return -1;
811
+    }
812
+
813
+    switch_buffers(ctx, avctx);
814
+
815
+    //START_TIMER;
816
+
817
+    if (ctx->frame_type == FRAMETYPE_NULL) {
818
+        ctx->frame_type = ctx->prev_frame_type;
819
+    } else {
820
+        for (p = 0; p < 3; p++) {
821
+            for (b = 0; b < ctx->planes[p].num_bands; b++) {
822
+                result = decode_band(ctx, p, &ctx->planes[p].bands[b], avctx);
823
+                if (result) {
824
+                    av_log(avctx, AV_LOG_ERROR,
825
+                           "Error while decoding band: %d, plane: %d\n", b, p);
826
+                    return -1;
827
+                }
828
+            }
829
+        }
830
+    }
831
+
832
+    //STOP_TIMER("decode_planes");
833
+
834
+    if (ctx->frame.data[0])
835
+        avctx->release_buffer(avctx, &ctx->frame);
836
+
837
+    ctx->frame.reference = 0;
838
+    if (avctx->get_buffer(avctx, &ctx->frame) < 0) {
839
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
840
+        return -1;
841
+    }
842
+
843
+    if (ctx->is_scalable) {
844
+        ff_ivi_recompose53 (&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0], 4);
845
+    } else {
846
+        ff_ivi_output_plane(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
847
+    }
848
+
849
+    ff_ivi_output_plane(&ctx->planes[2], ctx->frame.data[1], ctx->frame.linesize[1]);
850
+    ff_ivi_output_plane(&ctx->planes[1], ctx->frame.data[2], ctx->frame.linesize[2]);
851
+
852
+    *data_size = sizeof(AVFrame);
853
+    *(AVFrame*)data = ctx->frame;
854
+
855
+    return buf_size;
856
+}
857
+
858
+
859
+/**
860
+ *  Closes Indeo5 decoder and cleans up its context.
861
+ */
862
+static av_cold int decode_close(AVCodecContext *avctx)
863
+{
864
+    IVI5DecContext *ctx = avctx->priv_data;
865
+
866
+    ff_ivi_free_buffers(&ctx->planes[0]);
867
+
868
+    if (ctx->frame.data[0])
869
+        avctx->release_buffer(avctx, &ctx->frame);
870
+
871
+    return 0;
872
+}
873
+
874
+
875
+AVCodec indeo5_decoder = {
876
+    .name           = "indeo5",
877
+    .type           = CODEC_TYPE_VIDEO,
878
+    .id             = CODEC_ID_INDEO5,
879
+    .priv_data_size = sizeof(IVI5DecContext),
880
+    .init           = decode_init,
881
+    .close          = decode_close,
882
+    .decode         = decode_frame,
883
+    .long_name      = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 5"),
884
+};
0 885
new file mode 100644
... ...
@@ -0,0 +1,190 @@
0
+/*
1
+ * Indeo Video Interactive 5 compatible decoder
2
+ * Copyright (c) 2009 Maxim Poliakovski
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+/**
22
+ * @file libavcodec/indeo5data.h
23
+ * This file contains data needed for the Indeo5 decoder.
24
+ */
25
+
26
+#ifndef AVCODEC_INDEO5DATA_H
27
+#define AVCODEC_INDEO5DATA_H
28
+
29
+#include <stdint.h>
30
+
31
+/**
32
+ *  standard picture dimensions (width, height divided by 4)
33
+ */
34
+static const uint8_t ivi5_common_pic_sizes[30] = {
35
+    160, 120, 80, 60, 40, 30, 176, 120, 88, 60, 88, 72, 44, 36, 60, 45, 160, 60,
36
+    176,  60, 20, 15, 22, 18,   0,   0,  0,  0,  0,  0
37
+};
38
+
39
+/**
40
+ *  Indeo5 8x8 scan (zigzag) patterns
41
+ */
42
+static const uint8_t ivi5_scans8x8[3][64] = {
43
+    {0,  1,  8, 16,  9,  2,  3, 10, 17, 24, 32, 25, 18, 11,  4,  5,
44
+    12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13,  6,  7, 14, 21, 28,
45
+    35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
46
+    58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
47
+    },
48
+    {0,  8, 16, 24, 32, 40, 48, 56,  1,  9, 17, 25, 33, 41, 49, 57,
49
+     2, 10, 18, 26, 34, 42, 50, 58,  3, 11, 19, 27, 35, 43, 51, 59,
50
+     4, 12, 20, 28, 36, 44, 52, 60,  5, 13, 21, 29, 37, 45, 53, 61,
51
+     6, 14, 22, 30, 38, 46, 54, 62,  7, 15, 23, 31, 39, 47, 55, 63
52
+    },
53
+    {0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
54
+    16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
55
+    32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
56
+    48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
57
+    }
58
+};
59
+
60
+/**
61
+ *  Indeo5 4x4 scan (zigzag) pattern
62
+ */
63
+static const uint8_t ivi5_scan4x4[16] = {
64
+    0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
65
+};
66
+
67
+
68
+/**
69
+ *  Indeo5 dequantization matrixes consist of two tables: base table
70
+ *  and scale table. The base table defines the dequantization matrix
71
+ *  itself and the scale table tells how this matrix should be scaled
72
+ *  for a particular quant level (0...24).
73
+ *
74
+ *  ivi5_base_quant_bbb_ttt  - base  tables for block size 'bbb' of type 'ttt'
75
+ *  ivi5_scale_quant_bbb_ttt - scale tables for block size 'bbb' of type 'ttt'
76
+ */
77
+static const uint8_t ivi5_base_quant_8x8_inter[5][64] = {
78
+    {0x13, 0x1d, 0x1f, 0x23, 0x25, 0x27, 0x29, 0x2d, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x2b, 0x2f,
79
+     0x1f, 0x21, 0x23, 0x24, 0x26, 0x29, 0x2d, 0x31, 0x23, 0x23, 0x24, 0x25, 0x27, 0x2b, 0x2f, 0x33,
80
+     0x25, 0x25, 0x26, 0x27, 0x29, 0x2d, 0x31, 0x35, 0x27, 0x27, 0x29, 0x2b, 0x2d, 0x2f, 0x33, 0x37,
81
+     0x29, 0x2b, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x39, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b
82
+    },
83
+    {0x13, 0x1d, 0x1f, 0x23, 0x25, 0x27, 0x29, 0x2d, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x2b, 0x2f,
84
+     0x1f, 0x21, 0x23, 0x24, 0x26, 0x29, 0x2d, 0x31, 0x23, 0x23, 0x24, 0x25, 0x27, 0x2b, 0x2f, 0x33,
85
+     0x25, 0x25, 0x26, 0x27, 0x29, 0x2d, 0x31, 0x35, 0x27, 0x27, 0x29, 0x2b, 0x2d, 0x2f, 0x33, 0x37,
86
+     0x29, 0x2b, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x39, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b
87
+    },
88
+    {0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61,
89
+     0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61,
90
+     0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61,
91
+     0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61
92
+    },
93
+    {0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
94
+     0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a,
95
+     0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61,
96
+     0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61
97
+    },
98
+    {0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
99
+     0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
100
+     0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
101
+     0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f
102
+    }
103
+};
104
+
105
+static const uint8_t ivi5_base_quant_8x8_intra[5][64] = {
106
+    {0x0d, 0x17, 0x1b, 0x21, 0x23, 0x25, 0x27, 0x2d, 0x17, 0x19, 0x1f, 0x21, 0x23, 0x27, 0x2b, 0x35,
107
+     0x1b, 0x1f, 0x1f, 0x22, 0x25, 0x2a, 0x33, 0x39, 0x21, 0x21, 0x22, 0x25, 0x29, 0x31, 0x36, 0x3d,
108
+     0x23, 0x23, 0x25, 0x29, 0x2f, 0x33, 0x39, 0x47, 0x25, 0x27, 0x2a, 0x31, 0x33, 0x37, 0x43, 0x53,
109
+     0x27, 0x2b, 0x33, 0x36, 0x39, 0x43, 0x4d, 0x65, 0x2d, 0x35, 0x39, 0x3d, 0x47, 0x53, 0x65, 0x7f
110
+    },
111
+    {0x13, 0x1d, 0x1f, 0x23, 0x25, 0x27, 0x29, 0x2d, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x2b, 0x2f,
112
+     0x1f, 0x21, 0x23, 0x24, 0x26, 0x29, 0x2d, 0x31, 0x23, 0x23, 0x24, 0x25, 0x27, 0x2b, 0x2f, 0x33,
113
+     0x25, 0x25, 0x26, 0x27, 0x29, 0x2d, 0x31, 0x35, 0x27, 0x27, 0x29, 0x2b, 0x2d, 0x2f, 0x33, 0x37,
114
+     0x29, 0x2b, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x39, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b
115
+    },
116
+    {0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61,
117
+     0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61,
118
+     0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61,
119
+     0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61
120
+    },
121
+    {0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
122
+     0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a,
123
+     0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61,
124
+     0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61
125
+    },
126
+    {0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
127
+     0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
128
+     0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
129
+     0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f
130
+    }
131
+};
132
+
133
+static const uint8_t ivi5_base_quant_4x4_inter[16] = {
134
+    0x0f, 0x1f, 0x25, 0x29, 0x1f, 0x25, 0x29, 0x2b, 0x25, 0x29, 0x2b, 0x2f, 0x29, 0x2b, 0x2f, 0x33
135
+};
136
+
137
+static const uint8_t ivi5_base_quant_4x4_intra[16] = {
138
+    0x0f, 0x1f, 0x25, 0x29, 0x1f, 0x25, 0x29, 0x2f, 0x25, 0x29, 0x2f, 0x3d, 0x29, 0x2f, 0x3d, 0x49
139
+};
140
+
141
+
142
+static const uint8_t ivi5_scale_quant_8x8_inter[5][24] = {
143
+    {0x0b, 0x11, 0x13, 0x14, 0x15, 0x16, 0x18, 0x1a, 0x1b, 0x1d, 0x20, 0x22,
144
+     0x23, 0x25, 0x28, 0x2a, 0x2e, 0x32, 0x35, 0x39, 0x3d, 0x41, 0x44, 0x4a,
145
+    },
146
+    {0x07, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
147
+     0x3a, 0x3f, 0x44, 0x4a, 0x50, 0x56, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x7e,
148
+    },
149
+    {0x15, 0x25, 0x28, 0x2d, 0x30, 0x34, 0x3a, 0x3d, 0x42, 0x48, 0x4c, 0x51,
150
+     0x56, 0x5b, 0x60, 0x65, 0x6b, 0x70, 0x76, 0x7c, 0x82, 0x88, 0x8f, 0x97,
151
+    },
152
+    {0x13, 0x1f, 0x20, 0x22, 0x25, 0x28, 0x2b, 0x2d, 0x30, 0x33, 0x36, 0x39,
153
+     0x3c, 0x3f, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x62,
154
+    },
155
+    {0x3c, 0x52, 0x58, 0x5d, 0x63, 0x68, 0x68, 0x6d, 0x73, 0x78, 0x7c, 0x80,
156
+     0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa3, 0xa9, 0xad, 0xb1, 0xb5, 0xba,
157
+    },
158
+};
159
+
160
+static const uint8_t ivi5_scale_quant_8x8_intra[5][24] = {
161
+    {0x0b, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20,
162
+     0x22, 0x24, 0x27, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x34, 0x37, 0x39, 0x3c,
163
+    },
164
+    {0x01, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x28, 0x2c,
165
+     0x30, 0x34, 0x38, 0x3d, 0x42, 0x47, 0x4c, 0x52, 0x58, 0x5e, 0x65, 0x6c,
166
+    },
167
+    {0x13, 0x22, 0x27, 0x2a, 0x2d, 0x33, 0x36, 0x3c, 0x41, 0x45, 0x49, 0x4e,
168
+     0x53, 0x58, 0x5d, 0x63, 0x69, 0x6f, 0x75, 0x7c, 0x82, 0x88, 0x8e, 0x95,
169
+    },
170
+    {0x13, 0x1f, 0x21, 0x24, 0x27, 0x29, 0x2d, 0x2f, 0x34, 0x37, 0x3a, 0x3d,
171
+     0x40, 0x44, 0x48, 0x4c, 0x4f, 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6b,
172
+    },
173
+    {0x31, 0x42, 0x47, 0x47, 0x4d, 0x52, 0x58, 0x58, 0x5d, 0x63, 0x67, 0x6b,
174
+     0x6f, 0x73, 0x78, 0x7c, 0x80, 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa4,
175
+    }
176
+};
177
+
178
+static const uint8_t ivi5_scale_quant_4x4_inter[24] = {
179
+    0x0b, 0x0d, 0x0d, 0x0e, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
180
+    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
181
+};
182
+
183
+static const uint8_t ivi5_scale_quant_4x4_intra[24] = {
184
+    0x01, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14,
185
+    0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
186
+};
187
+
188
+
189
+#endif /* AVCODEC_INDEO5DATA_H */