1/* 2 * Indeo Video Interactive 4 compatible decoder 3 * Copyright (c) 2009-2010 Maxim Poliakovski 4 * 5 * This file is part of FFmpeg. 6 * 7 * FFmpeg is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * FFmpeg is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with FFmpeg; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22/** 23 * @file 24 * This file contains data needed for the Indeo 4 decoder. 25 */ 26 27#ifndef AVCODEC_INDEO4DATA_H 28#define AVCODEC_INDEO4DATA_H 29 30#include <stdint.h> 31 32#include "ivi_common.h" 33#include "mathops.h" 34 35/** 36 * standard picture dimensions 37 */ 38static const uint16_t ivi4_common_pic_sizes[14] = { 39 640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144 40}; 41 42/** 43 * Indeo 4 8x8 scan (zigzag) patterns 44 */ 45static const uint8_t ivi4_alternate_scan_8x8[64] = { 46 0, 8, 1, 9, 16, 24, 2, 3, 17, 25, 10, 11, 32, 40, 48, 56, 47 4, 5, 6, 7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15, 48 34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28, 49 36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60 50}; 51 52static const uint8_t ivi4_alternate_scan_4x4[16] = { 53 0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15 54}; 55 56static const uint8_t ivi4_vertical_scan_4x4[16] = { 57 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15 58}; 59 60static const uint8_t ivi4_horizontal_scan_4x4[16] = { 61 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 62}; 63 64static const uint8_t *scan_index_to_tab[15] = { 65 // for 8x8 transforms 66 ff_zigzag_direct, 67 ivi4_alternate_scan_8x8, 68 ff_ivi_horizontal_scan_8x8, 69 ff_ivi_vertical_scan_8x8, 70 ff_zigzag_direct, 71 72 // for 4x4 transforms 73 ff_ivi_direct_scan_4x4, 74 ivi4_alternate_scan_4x4, 75 ivi4_vertical_scan_4x4, 76 ivi4_horizontal_scan_4x4, 77 ff_ivi_direct_scan_4x4, 78 79 // TODO: check if those are needed 80 ff_ivi_horizontal_scan_8x8, 81 ff_ivi_horizontal_scan_8x8, 82 ff_ivi_horizontal_scan_8x8, 83 ff_ivi_horizontal_scan_8x8, 84 ff_ivi_horizontal_scan_8x8 85}; 86 87/** 88 * Indeo 4 dequant tables 89 */ 90static const uint16_t ivi4_quant_8x8_intra[9][64] = { 91 { 92 43, 342, 385, 470, 555, 555, 598, 726, 93 342, 342, 470, 513, 555, 598, 726, 769, 94 385, 470, 555, 555, 598, 726, 726, 811, 95 470, 470, 555, 555, 598, 726, 769, 854, 96 470, 555, 555, 598, 683, 726, 854, 1025, 97 555, 555, 598, 683, 726, 854, 1025, 1153, 98 555, 555, 598, 726, 811, 982, 1195, 1451, 99 555, 598, 726, 811, 982, 1195, 1451, 1793 100 }, 101 { 102 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865, 103 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865, 104 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827, 105 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827, 106 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827, 107 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827, 108 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827, 109 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827 110 }, 111 { 112 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835, 113 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835, 114 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835, 115 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835, 116 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835, 117 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835, 118 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835, 119 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835 120 }, 121 { 122 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414, 123 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414, 124 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414, 125 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414, 126 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414, 127 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414, 128 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414, 129 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414 130 }, 131 { 132 897, 897, 897, 897, 897, 897, 897, 897, 133 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 134 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 135 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409, 136 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 137 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750, 138 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 139 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091 140 }, 141 { 142 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 143 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 144 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 145 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 146 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 147 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 148 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 149 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414 150 }, 151 { 152 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390, 153 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390, 154 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390, 155 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390, 156 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390, 157 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390, 158 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390, 159 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390 160 }, 161 { 162 22, 171, 214, 257, 257, 299, 299, 342, 163 171, 171, 257, 257, 299, 299, 342, 385, 164 214, 257, 257, 299, 299, 342, 342, 385, 165 257, 257, 257, 299, 299, 342, 385, 427, 166 257, 257, 299, 299, 342, 385, 427, 513, 167 257, 299, 299, 342, 385, 427, 513, 598, 168 299, 299, 299, 385, 385, 470, 598, 726, 169 299, 299, 385, 385, 470, 598, 726, 897 170 }, 171 { 172 86, 598, 1195, 1195, 2390, 2390, 2390, 2390, 173 598, 598, 1195, 1195, 2390, 2390, 2390, 2390, 174 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414, 175 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414, 176 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414, 177 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414, 178 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414, 179 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414 180 } 181}; 182 183static const uint16_t ivi4_quant_8x8_inter[9][64] = { 184 { 185 427, 427, 470, 427, 427, 427, 470, 470, 186 427, 427, 470, 427, 427, 427, 470, 470, 187 470, 470, 470, 470, 470, 470, 470, 470, 188 427, 427, 470, 470, 427, 427, 470, 470, 189 427, 427, 470, 427, 427, 427, 470, 470, 190 427, 427, 470, 427, 427, 427, 470, 470, 191 470, 470, 470, 470, 470, 470, 470, 470, 192 470, 470, 470, 470, 470, 470, 470, 470 193 }, 194 { 195 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414, 196 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414, 197 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822, 198 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822, 199 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414, 200 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414, 201 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414, 202 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414 203 }, 204 { 205 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281, 206 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281, 207 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281, 208 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281, 209 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281, 210 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281, 211 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281, 212 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281 213 }, 214 { 215 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433, 216 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433, 217 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433, 218 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433, 219 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433, 220 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433, 221 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433, 222 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433 223 }, 224 { 225 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 226 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 227 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281, 228 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 229 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 230 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 231 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281, 232 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281 233 }, 234 { 235 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 236 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 237 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 238 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 239 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 240 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 241 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 242 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433 243 }, 244 { 245 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 246 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 247 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 248 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 249 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 250 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 251 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 252 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707 253 }, 254 { 255 86, 171, 171, 214, 214, 214, 214, 257, 256 171, 171, 214, 214, 214, 214, 257, 257, 257 171, 214, 214, 214, 214, 257, 257, 257, 258 214, 214, 214, 214, 257, 257, 257, 299, 259 214, 214, 214, 257, 257, 257, 299, 299, 260 214, 214, 257, 257, 257, 299, 299, 299, 261 214, 257, 257, 257, 299, 299, 299, 342, 262 257, 257, 257, 299, 299, 299, 342, 342 263 }, 264 { 265 854, 854, 1195, 1195, 1707, 1707, 1707, 1707, 266 854, 854, 1195, 1195, 1707, 1707, 1707, 1707, 267 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390, 268 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390, 269 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707, 270 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707, 271 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707, 272 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707 273 } 274}; 275 276static const uint16_t ivi4_quant_4x4_intra[5][16] = { 277 { 278 22, 214, 257, 299, 279 214, 257, 299, 342, 280 257, 299, 342, 427, 281 299, 342, 427, 513 282 }, 283 { 284 129, 1025, 1451, 1451, 285 1025, 1025, 1451, 1451, 286 1451, 1451, 2049, 2049, 287 1451, 1451, 2049, 2049 288 }, 289 { 290 43, 171, 171, 171, 291 43, 171, 171, 171, 292 43, 171, 171, 171, 293 43, 171, 171, 171 294 }, 295 { 296 43, 43, 43, 43, 297 171, 171, 171, 171, 298 171, 171, 171, 171, 299 171, 171, 171, 171 300 }, 301 { 302 43, 43, 43, 43, 303 43, 43, 43, 43, 304 43, 43, 43, 43, 305 43, 43, 43, 43 306 } 307}; 308 309static const uint16_t ivi4_quant_4x4_inter[5][16] = { 310 { 311 107, 214, 257, 299, 312 214, 257, 299, 299, 313 257, 299, 299, 342, 314 299, 299, 342, 342 315 }, 316 { 317 513, 1025, 1238, 1238, 318 1025, 1025, 1238, 1238, 319 1238, 1238, 1451, 1451, 320 1238, 1238, 1451, 1451 321 }, 322 { 323 43, 171, 171, 171, 324 43, 171, 171, 171, 325 43, 171, 171, 171, 326 43, 171, 171, 171 327 }, 328 { 329 43, 43, 43, 43, 330 171, 171, 171, 171, 331 171, 171, 171, 171, 332 171, 171, 171, 171 333 }, 334 { 335 43, 43, 43, 43, 336 43, 43, 43, 43, 337 43, 43, 43, 43, 338 43, 43, 43, 43 339 } 340}; 341 342/** 343 * Table for mapping quant matrix index from the bitstream 344 * into internal quant table number. 345 */ 346static const uint8_t quant_index_to_tab[22] = { 347 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes 348 0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes 349}; 350 351#endif /* AVCODEC_INDEO4DATA_H */ 352