1 /* 2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved. 3 * Copyright (c) Imagination Technologies Limited, UK 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portions 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 * 25 * Authors: 26 * Waldo Bastian <waldo.bastian (at) intel.com> 27 * Li Zeng <li.zeng (at) intel.com> 28 * 29 */ 30 31 #include "pnw_MPEG4.h" 32 #include "tng_vld_dec.h" 33 #include "psb_def.h" 34 #include "psb_drv_debug.h" 35 36 #include "hwdefs/reg_io2.h" 37 #include "hwdefs/msvdx_offsets.h" 38 #include "hwdefs/msvdx_cmds_io2.h" 39 #include "hwdefs/msvdx_vec_reg_io2.h" 40 #include "hwdefs/msvdx_vec_mpeg4_reg_io2.h" 41 #include "hwdefs/dxva_fw_ctrl.h" 42 43 #include <stdlib.h> 44 #include <stdint.h> 45 #include <string.h> 46 47 #define GET_SURFACE_INFO_is_defined(psb_surface) ((int) (psb_surface->extra_info[0])) 48 #define SET_SURFACE_INFO_is_defined(psb_surface, val) psb_surface->extra_info[0] = (uint32_t) val; 49 #define GET_SURFACE_INFO_picture_structure(psb_surface) (psb_surface->extra_info[1]) 50 #define SET_SURFACE_INFO_picture_structure(psb_surface, val) psb_surface->extra_info[1] = val; 51 #define GET_SURFACE_INFO_picture_coding_type(psb_surface) ((int) (psb_surface->extra_info[2])) 52 #define SET_SURFACE_INFO_picture_coding_type(psb_surface, val) psb_surface->extra_info[2] = (uint32_t) val; 53 54 #define SLICEDATA_BUFFER_TYPE(type) ((type==VASliceDataBufferType)?"VASliceDataBufferType":"VAProtectedSliceDataBufferType") 55 56 #define PIXELS_TO_MB(x) ((x + 15) / 16) 57 58 /* 59 * Frame types - format dependant! 60 */ 61 #define PICTURE_CODING_I 0x00 62 #define PICTURE_CODING_P 0x01 63 #define PICTURE_CODING_B 0x02 64 #define PICTURE_CODING_S 0x03 65 66 67 #define FE_STATE_BUFFER_SIZE 4096 68 #define FE_STATE_SAVE_SIZE ( 0xB40 - 0x700 ) 69 70 #define MPEG4_PROFILE_SIMPLE 0 71 #define MPEG4_PROFILE_ASP 2 72 73 #define HW_SUPPORTED_MAX_PICTURE_WIDTH_MPEG4 1920 74 #define HW_SUPPORTED_MAX_PICTURE_HEIGHT_MPEG4 1088 75 #define HW_SUPPORTED_MAX_PICTURE_WIDTH_H263 720 76 #define HW_SUPPORTED_MAX_PICTURE_HEIGHT_H263 576 77 78 /* Table V2-2 ISO/IEC 14496-2:2001(E) - sprite enable codewords */ 79 typedef enum { 80 SPRITE_NOT_USED = 0, 81 STATIC, 82 GMC, 83 } MPEG4_eSpriteEnable; 84 85 86 #define MAX_QUANT_TABLES (2) /* only 2 tables for 4:2:0 decode */ 87 88 static int scan0[64] = { // spec, fig 7-2 89 /*u 0 ..... 7*/ 90 0, 1, 5, 6, 14, 15, 27, 28, /* v = 0 */ 91 2, 4, 7, 13, 16, 26, 29, 42, 92 3, 8, 12, 17, 25, 30, 41, 43, 93 9, 11, 18, 24, 31, 40, 44, 53, 94 10, 19, 23, 32, 39, 45, 52, 54, 95 20, 22, 33, 38, 46, 51, 55, 60, 96 21, 34, 37, 47, 50, 56, 59, 61, 97 35, 36, 48, 49, 57, 58, 62, 63 /* v = 7 */ 98 }; 99 100 typedef enum { 101 NONINTRA_LUMA_Q = 0, 102 INTRA_LUMA_Q = 1 103 } QUANT_IDX; 104 105 /************************************************************************************/ 106 /* Variable length codes in 'packed' format */ 107 /************************************************************************************/ 108 109 /* Format is: opcode, width, symbol. All VLC tables are concatenated. */ 110 #define VLC_PACK(a,b,c) ( ( (a) << 12 ) | ( (b) << 9 ) | (c) ) 111 static const IMG_UINT16 gaui16mpeg4VlcTableDataPacked[] = 112 { 113 /* B6_mcbpc_i_s_vops_piece.out */ 114 VLC_PACK( 4 , 0 , 12 ) , 115 VLC_PACK( 5 , 0 , 7 ) , 116 VLC_PACK( 4 , 2 , 13 ) , 117 VLC_PACK( 4 , 3 , 16 ) , 118 VLC_PACK( 5 , 0 , 9 ) , 119 VLC_PACK( 4 , 5 , 17 ) , 120 VLC_PACK( 2 , 2 , 1 ) , 121 VLC_PACK( 3 , 2 , 0 ) , 122 VLC_PACK( 3 , 2 , 0 ) , 123 VLC_PACK( 4 , 2 , 36 ) , 124 VLC_PACK( 3 , 2 , 0 ) , 125 /* B7_mcbpc_p_s_vops_update.out */ 126 VLC_PACK( 4 , 0 , 0 ) , 127 VLC_PACK( 0 , 0 , 6 ) , 128 VLC_PACK( 0 , 0 , 7 ) , 129 VLC_PACK( 2 , 1 , 8 ) , 130 VLC_PACK( 0 , 1 , 10 ) , 131 VLC_PACK( 2 , 1 , 13 ) , 132 VLC_PACK( 0 , 2 , 15 ) , 133 VLC_PACK( 4 , 0 , 8 ) , 134 VLC_PACK( 4 , 0 , 4 ) , 135 VLC_PACK( 4 , 0 , 2 ) , 136 VLC_PACK( 4 , 0 , 1 ) , 137 VLC_PACK( 4 , 0 , 12 ) , 138 VLC_PACK( 4 , 1 , 3 ) , 139 VLC_PACK( 4 , 1 , 16 ) , 140 VLC_PACK( 4 , 1 , 10 ) , 141 VLC_PACK( 4 , 1 , 9 ) , 142 VLC_PACK( 4 , 1 , 6 ) , 143 VLC_PACK( 4 , 1 , 5 ) , 144 VLC_PACK( 4 , 0 , 15 ) , 145 VLC_PACK( 4 , 1 , 11 ) , 146 VLC_PACK( 4 , 1 , 13 ) , 147 VLC_PACK( 3 , 2 , 0 ) , 148 VLC_PACK( 4 , 2 , 36 ) , 149 VLC_PACK( 4 , 2 , 19 ) , 150 VLC_PACK( 4 , 2 , 18 ) , 151 VLC_PACK( 4 , 2 , 17 ) , 152 VLC_PACK( 4 , 2 , 7 ) , 153 VLC_PACK( 4 , 1 , 14 ) , 154 VLC_PACK( 4 , 1 , 14 ) , 155 /* B8_cbpy_intra.out */ 156 VLC_PACK( 1 , 1 , 16 ) , 157 VLC_PACK( 0 , 0 , 18 ) , 158 VLC_PACK( 0 , 0 , 19 ) , 159 VLC_PACK( 4 , 3 , 0 ) , 160 VLC_PACK( 4 , 3 , 12 ) , 161 VLC_PACK( 4 , 3 , 10 ) , 162 VLC_PACK( 4 , 3 , 14 ) , 163 VLC_PACK( 4 , 3 , 5 ) , 164 VLC_PACK( 4 , 3 , 13 ) , 165 VLC_PACK( 4 , 3 , 3 ) , 166 VLC_PACK( 4 , 3 , 11 ) , 167 VLC_PACK( 4 , 3 , 7 ) , 168 VLC_PACK( 4 , 1 , 15 ) , 169 VLC_PACK( 4 , 1 , 15 ) , 170 VLC_PACK( 4 , 1 , 15 ) , 171 VLC_PACK( 4 , 1 , 15 ) , 172 VLC_PACK( 3 , 1 , 0 ) , 173 VLC_PACK( 4 , 1 , 6 ) , 174 VLC_PACK( 4 , 1 , 9 ) , 175 VLC_PACK( 4 , 0 , 8 ) , 176 VLC_PACK( 4 , 0 , 4 ) , 177 VLC_PACK( 4 , 0 , 2 ) , 178 VLC_PACK( 4 , 0 , 1 ) , 179 /* B8_cbpy_inter.out */ 180 VLC_PACK( 1 , 1 , 16 ) , 181 VLC_PACK( 0 , 0 , 18 ) , 182 VLC_PACK( 6 , 0 , 6 ) , 183 VLC_PACK( 4 , 3 , 15 ) , 184 VLC_PACK( 4 , 3 , 3 ) , 185 VLC_PACK( 4 , 3 , 5 ) , 186 VLC_PACK( 4 , 3 , 1 ) , 187 VLC_PACK( 4 , 3 , 10 ) , 188 VLC_PACK( 4 , 3 , 2 ) , 189 VLC_PACK( 4 , 3 , 12 ) , 190 VLC_PACK( 4 , 3 , 4 ) , 191 VLC_PACK( 4 , 3 , 8 ) , 192 VLC_PACK( 4 , 1 , 0 ) , 193 VLC_PACK( 4 , 1 , 0 ) , 194 VLC_PACK( 4 , 1 , 0 ) , 195 VLC_PACK( 4 , 1 , 0 ) , 196 VLC_PACK( 3 , 1 , 0 ) , 197 VLC_PACK( 4 , 1 , 9 ) , 198 VLC_PACK( 4 , 1 , 6 ) , 199 VLC_PACK( 4 , 0 , 7 ) , 200 VLC_PACK( 4 , 0 , 11 ) , 201 /* B3_modb.out */ 202 VLC_PACK( 4 , 0 , 0 ) , 203 VLC_PACK( 4 , 1 , 1 ) , 204 VLC_PACK( 4 , 1 , 2 ) , 205 /* B4_mb_type.out */ 206 VLC_PACK( 4 , 0 , 0 ) , 207 VLC_PACK( 4 , 1 , 1 ) , 208 VLC_PACK( 4 , 2 , 2 ) , 209 VLC_PACK( 4 , 3 , 3 ) , 210 VLC_PACK( 3 , 3 , 0 ) , 211 /* 6_33_dbquant.out */ 212 VLC_PACK( 4 , 0 , 0 ) , 213 VLC_PACK( 4 , 1 , 6 ) , 214 VLC_PACK( 4 , 1 , 2 ) , 215 /* B12_mvd.out */ 216 VLC_PACK( 4 , 0 , 0 ) , 217 VLC_PACK( 5 , 0 , 1 ) , 218 VLC_PACK( 5 , 0 , 2 ) , 219 VLC_PACK( 5 , 0 , 3 ) , 220 VLC_PACK( 2 , 1 , 3 ) , 221 VLC_PACK( 2 , 3 , 5 ) , 222 VLC_PACK( 0 , 3 , 11 ) , 223 VLC_PACK( 5 , 0 , 4 ) , 224 VLC_PACK( 5 , 0 , 5 ) , 225 VLC_PACK( 5 , 0 , 6 ) , 226 VLC_PACK( 5 , 0 , 7 ) , 227 VLC_PACK( 0 , 0 , 4 ) , 228 VLC_PACK( 5 , 0 , 10 ) , 229 VLC_PACK( 5 , 0 , 11 ) , 230 VLC_PACK( 5 , 0 , 12 ) , 231 VLC_PACK( 5 , 0 , 9 ) , 232 VLC_PACK( 5 , 0 , 8 ) , 233 VLC_PACK( 1 , 1 , 16 ) , 234 VLC_PACK( 0 , 0 , 18 ) , 235 VLC_PACK( 0 , 0 , 19 ) , 236 VLC_PACK( 0 , 0 , 20 ) , 237 VLC_PACK( 5 , 0 , 24 ) , 238 VLC_PACK( 5 , 0 , 23 ) , 239 VLC_PACK( 5 , 0 , 22 ) , 240 VLC_PACK( 5 , 0 , 21 ) , 241 VLC_PACK( 5 , 0 , 20 ) , 242 VLC_PACK( 5 , 0 , 19 ) , 243 VLC_PACK( 5 , 0 , 18 ) , 244 VLC_PACK( 5 , 0 , 17 ) , 245 VLC_PACK( 5 , 0 , 16 ) , 246 VLC_PACK( 5 , 0 , 15 ) , 247 VLC_PACK( 5 , 0 , 14 ) , 248 VLC_PACK( 5 , 0 , 13 ) , 249 VLC_PACK( 3 , 1 , 0 ) , 250 VLC_PACK( 5 , 0 , 32 ) , 251 VLC_PACK( 5 , 0 , 31 ) , 252 VLC_PACK( 5 , 0 , 30 ) , 253 VLC_PACK( 5 , 0 , 29 ) , 254 VLC_PACK( 5 , 0 , 28 ) , 255 VLC_PACK( 5 , 0 , 27 ) , 256 VLC_PACK( 5 , 0 , 26 ) , 257 VLC_PACK( 5 , 0 , 25 ) , 258 /* B13_dct_dc_size_luminance.out */ 259 VLC_PACK( 2 , 5 , 4 ) , 260 VLC_PACK( 0 , 0 , 14 ) , 261 VLC_PACK( 4 , 1 , 2 ) , 262 VLC_PACK( 4 , 1 , 1 ) , 263 VLC_PACK( 4 , 0 , 4 ) , 264 VLC_PACK( 4 , 1 , 5 ) , 265 VLC_PACK( 4 , 2 , 6 ) , 266 VLC_PACK( 4 , 3 , 7 ) , 267 VLC_PACK( 4 , 4 , 8 ) , 268 VLC_PACK( 4 , 5 , 9 ) , 269 VLC_PACK( 2 , 2 , 1 ) , 270 VLC_PACK( 4 , 0 , 10 ) , 271 VLC_PACK( 4 , 1 , 11 ) , 272 VLC_PACK( 4 , 2 , 12 ) , 273 VLC_PACK( 3 , 2 , 0 ) , 274 VLC_PACK( 4 , 0 , 3 ) , 275 VLC_PACK( 4 , 0 , 0 ) , 276 /* B14_dct_dc_size_chrominance.out */ 277 VLC_PACK( 2 , 5 , 4 ) , 278 VLC_PACK( 4 , 1 , 2 ) , 279 VLC_PACK( 4 , 1 , 1 ) , 280 VLC_PACK( 4 , 1 , 0 ) , 281 VLC_PACK( 4 , 0 , 3 ) , 282 VLC_PACK( 4 , 1 , 4 ) , 283 VLC_PACK( 4 , 2 , 5 ) , 284 VLC_PACK( 4 , 3 , 6 ) , 285 VLC_PACK( 4 , 4 , 7 ) , 286 VLC_PACK( 4 , 5 , 8 ) , 287 VLC_PACK( 2 , 3 , 1 ) , 288 VLC_PACK( 4 , 0 , 9 ) , 289 VLC_PACK( 4 , 1 , 10 ) , 290 VLC_PACK( 4 , 2 , 11 ) , 291 VLC_PACK( 4 , 3 , 12 ) , 292 VLC_PACK( 3 , 3 , 0 ) , 293 /* B16_intra_tcoeff.out */ 294 VLC_PACK( 2 , 1 , 16 ) , 295 VLC_PACK( 0 , 3 , 77 ) , 296 VLC_PACK( 0 , 2 , 96 ) , 297 VLC_PACK( 0 , 1 , 103 ) , 298 VLC_PACK( 2 , 1 , 106 ) , 299 VLC_PACK( 2 , 1 , 108 ) , 300 VLC_PACK( 5 , 1 , 250 ) , 301 VLC_PACK( 7 , 0 , 254 ) , 302 VLC_PACK( 4 , 2 , 508 ) , 303 VLC_PACK( 4 , 2 , 508 ) , 304 VLC_PACK( 4 , 2 , 509 ) , 305 VLC_PACK( 4 , 2 , 509 ) , 306 VLC_PACK( 4 , 3 , 506 ) , 307 VLC_PACK( 4 , 3 , 507 ) , 308 VLC_PACK( 5 , 0 , 222 ) , 309 VLC_PACK( 5 , 0 , 252 ) , 310 VLC_PACK( 0 , 3 , 3 ) , 311 VLC_PACK( 2 , 1 , 18 ) , 312 VLC_PACK( 0 , 3 , 44 ) , 313 VLC_PACK( 5 , 1 , 237 ) , 314 VLC_PACK( 7 , 0 , 433 ) , 315 VLC_PACK( 7 , 0 , 434 ) , 316 VLC_PACK( 7 , 0 , 435 ) , 317 VLC_PACK( 7 , 0 , 436 ) , 318 VLC_PACK( 7 , 0 , 437 ) , 319 VLC_PACK( 7 , 0 , 221 ) , 320 VLC_PACK( 7 , 0 , 251 ) , 321 VLC_PACK( 5 , 0 , 435 ) , 322 VLC_PACK( 5 , 0 , 436 ) , 323 VLC_PACK( 5 , 0 , 29 ) , 324 VLC_PACK( 5 , 0 , 61 ) , 325 VLC_PACK( 5 , 0 , 93 ) , 326 VLC_PACK( 5 , 0 , 156 ) , 327 VLC_PACK( 5 , 0 , 188 ) , 328 VLC_PACK( 5 , 0 , 217 ) , 329 VLC_PACK( 4 , 0 , 255 ) , 330 VLC_PACK( 0 , 3 , 2 ) , 331 VLC_PACK( 0 , 2 , 17 ) , 332 VLC_PACK( 5 , 0 , 230 ) , 333 VLC_PACK( 5 , 0 , 229 ) , 334 VLC_PACK( 5 , 0 , 228 ) , 335 VLC_PACK( 5 , 0 , 214 ) , 336 VLC_PACK( 5 , 0 , 60 ) , 337 VLC_PACK( 5 , 0 , 213 ) , 338 VLC_PACK( 5 , 0 , 186 ) , 339 VLC_PACK( 5 , 0 , 28 ) , 340 VLC_PACK( 5 , 0 , 433 ) , 341 VLC_PACK( 7 , 0 , 247 ) , 342 VLC_PACK( 7 , 0 , 93 ) , 343 VLC_PACK( 7 , 0 , 61 ) , 344 VLC_PACK( 7 , 0 , 430 ) , 345 VLC_PACK( 7 , 0 , 429 ) , 346 VLC_PACK( 7 , 0 , 428 ) , 347 VLC_PACK( 7 , 0 , 427 ) , 348 VLC_PACK( 5 , 0 , 232 ) , 349 VLC_PACK( 5 , 0 , 231 ) , 350 VLC_PACK( 5 , 0 , 215 ) , 351 VLC_PACK( 5 , 0 , 374 ) , 352 VLC_PACK( 7 , 0 , 157 ) , 353 VLC_PACK( 7 , 0 , 125 ) , 354 VLC_PACK( 7 , 0 , 432 ) , 355 VLC_PACK( 7 , 0 , 431 ) , 356 VLC_PACK( 3 , 3 , 0 ) , 357 VLC_PACK( 3 , 3 , 0 ) , 358 VLC_PACK( 7 , 1 , 248 ) , 359 VLC_PACK( 5 , 1 , 233 ) , 360 VLC_PACK( 7 , 0 , 189 ) , 361 VLC_PACK( 7 , 0 , 220 ) , 362 VLC_PACK( 7 , 0 , 250 ) , 363 VLC_PACK( 5 , 0 , 434 ) , 364 VLC_PACK( 5 , 0 , 92 ) , 365 VLC_PACK( 5 , 0 , 375 ) , 366 VLC_PACK( 5 , 0 , 124 ) , 367 VLC_PACK( 5 , 0 , 155 ) , 368 VLC_PACK( 5 , 0 , 187 ) , 369 VLC_PACK( 5 , 0 , 216 ) , 370 VLC_PACK( 5 , 0 , 235 ) , 371 VLC_PACK( 5 , 0 , 236 ) , 372 VLC_PACK( 0 , 0 , 16 ) , 373 VLC_PACK( 0 , 0 , 17 ) , 374 VLC_PACK( 5 , 1 , 241 ) , 375 VLC_PACK( 7 , 0 , 439 ) , 376 VLC_PACK( 7 , 0 , 30 ) , 377 VLC_PACK( 7 , 0 , 62 ) , 378 VLC_PACK( 7 , 0 , 252 ) , 379 VLC_PACK( 5 , 0 , 437 ) , 380 VLC_PACK( 5 , 0 , 438 ) , 381 VLC_PACK( 5 , 0 , 439 ) , 382 VLC_PACK( 7 , 0 , 438 ) , 383 VLC_PACK( 5 , 0 , 157 ) , 384 VLC_PACK( 5 , 0 , 219 ) , 385 VLC_PACK( 5 , 0 , 243 ) , 386 VLC_PACK( 5 , 0 , 244 ) , 387 VLC_PACK( 5 , 0 , 245 ) , 388 VLC_PACK( 5 , 0 , 218 ) , 389 VLC_PACK( 5 , 0 , 239 ) , 390 VLC_PACK( 5 , 0 , 125 ) , 391 VLC_PACK( 5 , 0 , 240 ) , 392 VLC_PACK( 7 , 0 , 126 ) , 393 VLC_PACK( 7 , 0 , 158 ) , 394 VLC_PACK( 5 , 0 , 62 ) , 395 VLC_PACK( 7 , 0 , 94 ) , 396 VLC_PACK( 5 , 0 , 30 ) , 397 VLC_PACK( 5 , 0 , 189 ) , 398 VLC_PACK( 5 , 0 , 220 ) , 399 VLC_PACK( 5 , 0 , 246 ) , 400 VLC_PACK( 7 , 0 , 253 ) , 401 VLC_PACK( 5 , 0 , 94 ) , 402 VLC_PACK( 7 , 0 , 190 ) , 403 VLC_PACK( 7 , 0 , 222 ) , 404 VLC_PACK( 5 , 1 , 247 ) , 405 VLC_PACK( 5 , 0 , 158 ) , 406 VLC_PACK( 5 , 0 , 126 ) , 407 VLC_PACK( 5 , 0 , 190 ) , 408 VLC_PACK( 5 , 0 , 249 ) , 409 VLC_PACK( 5 , 0 , 221 ) , 410 /* B17_inter_tcoeff.out */ 411 VLC_PACK( 2 , 4 , 16 ) , 412 VLC_PACK( 2 , 3 , 68 ) , 413 VLC_PACK( 0 , 2 , 84 ) , 414 VLC_PACK( 0 , 1 , 91 ) , 415 VLC_PACK( 1 , 1 , 94 ) , 416 VLC_PACK( 2 , 1 , 96 ) , 417 VLC_PACK( 0 , 0 , 98 ) , 418 VLC_PACK( 7 , 0 , 254 ) , 419 VLC_PACK( 4 , 2 , 508 ) , 420 VLC_PACK( 4 , 2 , 508 ) , 421 VLC_PACK( 4 , 2 , 509 ) , 422 VLC_PACK( 4 , 2 , 509 ) , 423 VLC_PACK( 4 , 3 , 444 ) , 424 VLC_PACK( 4 , 3 , 445 ) , 425 VLC_PACK( 5 , 0 , 190 ) , 426 VLC_PACK( 5 , 0 , 253 ) , 427 VLC_PACK( 2 , 3 , 6 ) , 428 VLC_PACK( 2 , 1 , 14 ) , 429 VLC_PACK( 0 , 2 , 40 ) , 430 VLC_PACK( 7 , 2 , 419 ) , 431 VLC_PACK( 2 , 1 , 46 ) , 432 VLC_PACK( 3 , 4 , 0 ) , 433 VLC_PACK( 2 , 2 , 5 ) , 434 VLC_PACK( 7 , 2 , 426 ) , 435 VLC_PACK( 7 , 1 , 424 ) , 436 VLC_PACK( 7 , 0 , 423 ) , 437 VLC_PACK( 5 , 1 , 246 ) , 438 VLC_PACK( 5 , 2 , 427 ) , 439 VLC_PACK( 5 , 1 , 425 ) , 440 VLC_PACK( 7 , 0 , 253 ) , 441 VLC_PACK( 7 , 0 , 430 ) , 442 VLC_PACK( 4 , 0 , 255 ) , 443 VLC_PACK( 0 , 3 , 2 ) , 444 VLC_PACK( 0 , 2 , 17 ) , 445 VLC_PACK( 5 , 0 , 217 ) , 446 VLC_PACK( 5 , 0 , 187 ) , 447 VLC_PACK( 5 , 0 , 124 ) , 448 VLC_PACK( 5 , 0 , 92 ) , 449 VLC_PACK( 5 , 0 , 60 ) , 450 VLC_PACK( 5 , 0 , 373 ) , 451 VLC_PACK( 5 , 0 , 422 ) , 452 VLC_PACK( 5 , 0 , 421 ) , 453 VLC_PACK( 7 , 0 , 414 ) , 454 VLC_PACK( 7 , 0 , 413 ) , 455 VLC_PACK( 7 , 0 , 412 ) , 456 VLC_PACK( 7 , 0 , 411 ) , 457 VLC_PACK( 7 , 0 , 410 ) , 458 VLC_PACK( 7 , 0 , 409 ) , 459 VLC_PACK( 7 , 0 , 408 ) , 460 VLC_PACK( 7 , 0 , 407 ) , 461 VLC_PACK( 5 , 0 , 243 ) , 462 VLC_PACK( 5 , 0 , 218 ) , 463 VLC_PACK( 5 , 0 , 424 ) , 464 VLC_PACK( 5 , 0 , 423 ) , 465 VLC_PACK( 7 , 0 , 418 ) , 466 VLC_PACK( 7 , 0 , 417 ) , 467 VLC_PACK( 7 , 0 , 416 ) , 468 VLC_PACK( 7 , 0 , 415 ) , 469 VLC_PACK( 5 , 0 , 374 ) , 470 VLC_PACK( 5 , 0 , 375 ) , 471 VLC_PACK( 5 , 0 , 29 ) , 472 VLC_PACK( 5 , 0 , 61 ) , 473 VLC_PACK( 5 , 0 , 93 ) , 474 VLC_PACK( 5 , 0 , 156 ) , 475 VLC_PACK( 5 , 0 , 188 ) , 476 VLC_PACK( 5 , 0 , 219 ) , 477 VLC_PACK( 5 , 1 , 244 ) , 478 VLC_PACK( 7 , 0 , 252 ) , 479 VLC_PACK( 7 , 0 , 221 ) , 480 VLC_PACK( 0 , 2 , 5 ) , 481 VLC_PACK( 7 , 2 , 432 ) , 482 VLC_PACK( 0 , 0 , 11 ) , 483 VLC_PACK( 0 , 0 , 12 ) , 484 VLC_PACK( 5 , 1 , 431 ) , 485 VLC_PACK( 7 , 0 , 436 ) , 486 VLC_PACK( 7 , 0 , 437 ) , 487 VLC_PACK( 7 , 0 , 438 ) , 488 VLC_PACK( 5 , 0 , 433 ) , 489 VLC_PACK( 5 , 0 , 434 ) , 490 VLC_PACK( 5 , 0 , 189 ) , 491 VLC_PACK( 5 , 0 , 220 ) , 492 VLC_PACK( 5 , 0 , 250 ) , 493 VLC_PACK( 5 , 1 , 248 ) , 494 VLC_PACK( 7 , 0 , 431 ) , 495 VLC_PACK( 5 , 0 , 125 ) , 496 VLC_PACK( 5 , 0 , 157 ) , 497 VLC_PACK( 7 , 0 , 439 ) , 498 VLC_PACK( 7 , 0 , 30 ) , 499 VLC_PACK( 7 , 0 , 62 ) , 500 VLC_PACK( 7 , 0 , 94 ) , 501 VLC_PACK( 5 , 0 , 435 ) , 502 VLC_PACK( 5 , 0 , 436 ) , 503 VLC_PACK( 5 , 0 , 437 ) , 504 VLC_PACK( 5 , 0 , 251 ) , 505 VLC_PACK( 7 , 0 , 126 ) , 506 VLC_PACK( 7 , 0 , 158 ) , 507 VLC_PACK( 7 , 0 , 190 ) , 508 VLC_PACK( 7 , 0 , 222 ) , 509 VLC_PACK( 5 , 1 , 438 ) , 510 VLC_PACK( 5 , 0 , 30 ) , 511 VLC_PACK( 5 , 0 , 62 ) , 512 VLC_PACK( 5 , 0 , 94 ) , 513 VLC_PACK( 5 , 0 , 252 ) , 514 VLC_PACK( 5 , 0 , 221 ) , 515 VLC_PACK( 5 , 0 , 126 ) , 516 VLC_PACK( 5 , 0 , 158 ) , 517 /* B23_rvlc_tcoeff_0.out */ 518 VLC_PACK( 5 , 0 , 255 ) , 519 VLC_PACK( 5 , 0 , 222 ) , 520 VLC_PACK( 0 , 0 , 14 ) , 521 VLC_PACK( 0 , 1 , 15 ) , 522 VLC_PACK( 0 , 0 , 44 ) , 523 VLC_PACK( 0 , 1 , 45 ) , 524 VLC_PACK( 0 , 1 , 74 ) , 525 VLC_PACK( 0 , 2 , 103 ) , 526 VLC_PACK( 0 , 1 , 230 ) , 527 VLC_PACK( 0 , 0 , 256 ) , 528 VLC_PACK( 5 , 0 , 252 ) , 529 VLC_PACK( 7 , 0 , 254 ) , 530 VLC_PACK( 4 , 3 , 508 ) , 531 VLC_PACK( 4 , 3 , 509 ) , 532 VLC_PACK( 4 , 3 , 506 ) , 533 VLC_PACK( 4 , 3 , 507 ) , 534 VLC_PACK( 5 , 0 , 190 ) , 535 VLC_PACK( 5 , 0 , 158 ) , 536 VLC_PACK( 5 , 0 , 126 ) , 537 VLC_PACK( 5 , 0 , 94 ) , 538 VLC_PACK( 0 , 0 , 2 ) , 539 VLC_PACK( 0 , 1 , 3 ) , 540 VLC_PACK( 5 , 0 , 62 ) , 541 VLC_PACK( 5 , 0 , 30 ) , 542 VLC_PACK( 5 , 0 , 439 ) , 543 VLC_PACK( 5 , 0 , 438 ) , 544 VLC_PACK( 0 , 0 , 2 ) , 545 VLC_PACK( 0 , 1 , 3 ) , 546 VLC_PACK( 5 , 0 , 437 ) , 547 VLC_PACK( 5 , 0 , 93 ) , 548 VLC_PACK( 5 , 0 , 436 ) , 549 VLC_PACK( 5 , 0 , 435 ) , 550 VLC_PACK( 0 , 0 , 2 ) , 551 VLC_PACK( 0 , 1 , 3 ) , 552 VLC_PACK( 5 , 0 , 434 ) , 553 VLC_PACK( 5 , 0 , 374 ) , 554 VLC_PACK( 5 , 0 , 373 ) , 555 VLC_PACK( 5 , 0 , 123 ) , 556 VLC_PACK( 0 , 0 , 2 ) , 557 VLC_PACK( 0 , 1 , 3 ) , 558 VLC_PACK( 5 , 0 , 433 ) , 559 VLC_PACK( 5 , 0 , 432 ) , 560 VLC_PACK( 5 , 0 , 431 ) , 561 VLC_PACK( 5 , 0 , 430 ) , 562 VLC_PACK( 0 , 0 , 2 ) , 563 VLC_PACK( 3 , 1 , 0 ) , 564 VLC_PACK( 5 , 0 , 228 ) , 565 VLC_PACK( 5 , 0 , 150 ) , 566 VLC_PACK( 5 , 0 , 221 ) , 567 VLC_PACK( 5 , 0 , 251 ) , 568 VLC_PACK( 5 , 0 , 250 ) , 569 VLC_PACK( 5 , 0 , 249 ) , 570 VLC_PACK( 0 , 0 , 2 ) , 571 VLC_PACK( 0 , 1 , 3 ) , 572 VLC_PACK( 5 , 0 , 189 ) , 573 VLC_PACK( 5 , 0 , 220 ) , 574 VLC_PACK( 5 , 0 , 157 ) , 575 VLC_PACK( 5 , 0 , 125 ) , 576 VLC_PACK( 0 , 0 , 2 ) , 577 VLC_PACK( 0 , 1 , 3 ) , 578 VLC_PACK( 5 , 0 , 188 ) , 579 VLC_PACK( 5 , 0 , 156 ) , 580 VLC_PACK( 5 , 0 , 61 ) , 581 VLC_PACK( 5 , 0 , 29 ) , 582 VLC_PACK( 0 , 0 , 2 ) , 583 VLC_PACK( 0 , 1 , 3 ) , 584 VLC_PACK( 5 , 0 , 92 ) , 585 VLC_PACK( 5 , 0 , 60 ) , 586 VLC_PACK( 5 , 0 , 91 ) , 587 VLC_PACK( 5 , 0 , 59 ) , 588 VLC_PACK( 0 , 0 , 2 ) , 589 VLC_PACK( 0 , 1 , 3 ) , 590 VLC_PACK( 5 , 0 , 372 ) , 591 VLC_PACK( 5 , 0 , 311 ) , 592 VLC_PACK( 5 , 0 , 429 ) , 593 VLC_PACK( 5 , 0 , 503 ) , 594 VLC_PACK( 0 , 0 , 2 ) , 595 VLC_PACK( 3 , 1 , 0 ) , 596 VLC_PACK( 5 , 0 , 58 ) , 597 VLC_PACK( 5 , 0 , 26 ) , 598 VLC_PACK( 7 , 0 , 158 ) , 599 VLC_PACK( 7 , 0 , 126 ) , 600 VLC_PACK( 0 , 0 , 2 ) , 601 VLC_PACK( 0 , 1 , 3 ) , 602 VLC_PACK( 5 , 0 , 248 ) , 603 VLC_PACK( 7 , 0 , 30 ) , 604 VLC_PACK( 5 , 0 , 219 ) , 605 VLC_PACK( 5 , 0 , 218 ) , 606 VLC_PACK( 0 , 0 , 2 ) , 607 VLC_PACK( 0 , 1 , 3 ) , 608 VLC_PACK( 5 , 0 , 217 ) , 609 VLC_PACK( 5 , 0 , 245 ) , 610 VLC_PACK( 5 , 0 , 375 ) , 611 VLC_PACK( 5 , 0 , 124 ) , 612 VLC_PACK( 0 , 0 , 2 ) , 613 VLC_PACK( 0 , 1 , 3 ) , 614 VLC_PACK( 5 , 0 , 28 ) , 615 VLC_PACK( 5 , 0 , 155 ) , 616 VLC_PACK( 5 , 0 , 154 ) , 617 VLC_PACK( 5 , 0 , 122 ) , 618 VLC_PACK( 0 , 0 , 2 ) , 619 VLC_PACK( 0 , 1 , 3 ) , 620 VLC_PACK( 5 , 0 , 310 ) , 621 VLC_PACK( 5 , 0 , 27 ) , 622 VLC_PACK( 5 , 0 , 90 ) , 623 VLC_PACK( 5 , 0 , 121 ) , 624 VLC_PACK( 0 , 0 , 2 ) , 625 VLC_PACK( 3 , 1 , 0 ) , 626 VLC_PACK( 5 , 0 , 502 ) , 627 VLC_PACK( 5 , 0 , 371 ) , 628 VLC_PACK( 7 , 0 , 439 ) , 629 VLC_PACK( 7 , 0 , 438 ) , 630 VLC_PACK( 0 , 0 , 6 ) , 631 VLC_PACK( 0 , 1 , 7 ) , 632 VLC_PACK( 0 , 0 , 27 ) , 633 VLC_PACK( 0 , 1 , 28 ) , 634 VLC_PACK( 0 , 1 , 48 ) , 635 VLC_PACK( 0 , 2 , 68 ) , 636 VLC_PACK( 5 , 0 , 247 ) , 637 VLC_PACK( 5 , 0 , 246 ) , 638 VLC_PACK( 5 , 0 , 244 ) , 639 VLC_PACK( 7 , 0 , 221 ) , 640 VLC_PACK( 0 , 0 , 2 ) , 641 VLC_PACK( 0 , 1 , 3 ) , 642 VLC_PACK( 5 , 0 , 187 ) , 643 VLC_PACK( 5 , 0 , 216 ) , 644 VLC_PACK( 5 , 0 , 186 ) , 645 VLC_PACK( 5 , 0 , 185 ) , 646 VLC_PACK( 0 , 0 , 2 ) , 647 VLC_PACK( 0 , 1 , 3 ) , 648 VLC_PACK( 5 , 0 , 213 ) , 649 VLC_PACK( 5 , 0 , 237 ) , 650 VLC_PACK( 5 , 0 , 153 ) , 651 VLC_PACK( 5 , 0 , 184 ) , 652 VLC_PACK( 0 , 0 , 2 ) , 653 VLC_PACK( 2 , 1 , 3 ) , 654 VLC_PACK( 5 , 0 , 89 ) , 655 VLC_PACK( 5 , 0 , 152 ) , 656 VLC_PACK( 3 , 1 , 0 ) , 657 VLC_PACK( 7 , 0 , 218 ) , 658 VLC_PACK( 5 , 0 , 428 ) , 659 VLC_PACK( 7 , 0 , 253 ) , 660 VLC_PACK( 7 , 0 , 435 ) , 661 VLC_PACK( 7 , 0 , 432 ) , 662 VLC_PACK( 7 , 0 , 431 ) , 663 VLC_PACK( 0 , 0 , 2 ) , 664 VLC_PACK( 0 , 1 , 3 ) , 665 VLC_PACK( 5 , 0 , 243 ) , 666 VLC_PACK( 5 , 0 , 242 ) , 667 VLC_PACK( 5 , 0 , 215 ) , 668 VLC_PACK( 5 , 0 , 214 ) , 669 VLC_PACK( 0 , 0 , 2 ) , 670 VLC_PACK( 0 , 1 , 3 ) , 671 VLC_PACK( 5 , 0 , 236 ) , 672 VLC_PACK( 5 , 0 , 233 ) , 673 VLC_PACK( 5 , 0 , 183 ) , 674 VLC_PACK( 5 , 0 , 182 ) , 675 VLC_PACK( 0 , 0 , 2 ) , 676 VLC_PACK( 2 , 1 , 3 ) , 677 VLC_PACK( 5 , 0 , 151 ) , 678 VLC_PACK( 5 , 0 , 181 ) , 679 VLC_PACK( 3 , 1 , 0 ) , 680 VLC_PACK( 7 , 0 , 370 ) , 681 VLC_PACK( 7 , 0 , 188 ) , 682 VLC_PACK( 7 , 0 , 430 ) , 683 VLC_PACK( 7 , 0 , 429 ) , 684 VLC_PACK( 0 , 0 , 2 ) , 685 VLC_PACK( 0 , 1 , 3 ) , 686 VLC_PACK( 5 , 0 , 241 ) , 687 VLC_PACK( 7 , 0 , 426 ) , 688 VLC_PACK( 5 , 0 , 240 ) , 689 VLC_PACK( 5 , 0 , 239 ) , 690 VLC_PACK( 0 , 0 , 2 ) , 691 VLC_PACK( 0 , 1 , 3 ) , 692 VLC_PACK( 7 , 0 , 220 ) , 693 VLC_PACK( 7 , 0 , 157 ) , 694 VLC_PACK( 5 , 0 , 212 ) , 695 VLC_PACK( 5 , 0 , 235 ) , 696 VLC_PACK( 0 , 0 , 2 ) , 697 VLC_PACK( 2 , 1 , 3 ) , 698 VLC_PACK( 5 , 0 , 180 ) , 699 VLC_PACK( 5 , 0 , 211 ) , 700 VLC_PACK( 3 , 1 , 0 ) , 701 VLC_PACK( 7 , 0 , 405 ) , 702 VLC_PACK( 7 , 0 , 406 ) , 703 VLC_PACK( 7 , 0 , 425 ) , 704 VLC_PACK( 7 , 0 , 424 ) , 705 VLC_PACK( 0 , 0 , 6 ) , 706 VLC_PACK( 0 , 1 , 7 ) , 707 VLC_PACK( 0 , 0 , 18 ) , 708 VLC_PACK( 0 , 1 , 19 ) , 709 VLC_PACK( 0 , 1 , 27 ) , 710 VLC_PACK( 2 , 2 , 35 ) , 711 VLC_PACK( 5 , 0 , 238 ) , 712 VLC_PACK( 7 , 0 , 252 ) , 713 VLC_PACK( 7 , 0 , 125 ) , 714 VLC_PACK( 7 , 0 , 418 ) , 715 VLC_PACK( 0 , 0 , 2 ) , 716 VLC_PACK( 0 , 1 , 3 ) , 717 VLC_PACK( 5 , 0 , 234 ) , 718 VLC_PACK( 5 , 0 , 232 ) , 719 VLC_PACK( 5 , 0 , 210 ) , 720 VLC_PACK( 5 , 0 , 231 ) , 721 VLC_PACK( 0 , 0 , 2 ) , 722 VLC_PACK( 3 , 1 , 0 ) , 723 VLC_PACK( 7 , 0 , 404 ) , 724 VLC_PACK( 7 , 0 , 403 ) , 725 VLC_PACK( 7 , 0 , 189 ) , 726 VLC_PACK( 7 , 0 , 421 ) , 727 VLC_PACK( 7 , 0 , 417 ) , 728 VLC_PACK( 7 , 0 , 416 ) , 729 VLC_PACK( 0 , 0 , 2 ) , 730 VLC_PACK( 2 , 1 , 3 ) , 731 VLC_PACK( 7 , 0 , 251 ) , 732 VLC_PACK( 7 , 0 , 93 ) , 733 VLC_PACK( 3 , 1 , 0 ) , 734 VLC_PACK( 5 , 0 , 229 ) , 735 VLC_PACK( 5 , 0 , 230 ) , 736 VLC_PACK( 7 , 0 , 415 ) , 737 VLC_PACK( 7 , 0 , 414 ) , 738 VLC_PACK( 0 , 0 , 2 ) , 739 VLC_PACK( 2 , 1 , 3 ) , 740 VLC_PACK( 7 , 0 , 61 ) , 741 VLC_PACK( 7 , 0 , 29 ) , 742 VLC_PACK( 3 , 1 , 0 ) , 743 VLC_PACK( 7 , 0 , 219 ) , 744 VLC_PACK( 7 , 0 , 250 ) , 745 VLC_PACK( 2 , 2 , 4 ) , 746 VLC_PACK( 2 , 1 , 7 ) , 747 VLC_PACK( 7 , 0 , 374 ) , 748 VLC_PACK( 7 , 0 , 375 ) , 749 VLC_PACK( 3 , 2 , 0 ) , 750 VLC_PACK( 3 , 2 , 0 ) , 751 VLC_PACK( 7 , 0 , 409 ) , 752 VLC_PACK( 7 , 0 , 371 ) , 753 VLC_PACK( 3 , 1 , 0 ) , 754 VLC_PACK( 7 , 0 , 372 ) , 755 VLC_PACK( 7 , 0 , 373 ) , 756 VLC_PACK( 0 , 1 , 4 ) , 757 VLC_PACK( 0 , 0 , 24 ) , 758 VLC_PACK( 7 , 0 , 94 ) , 759 VLC_PACK( 7 , 0 , 62 ) , 760 VLC_PACK( 0 , 1 , 4 ) , 761 VLC_PACK( 0 , 0 , 18 ) , 762 VLC_PACK( 7 , 0 , 434 ) , 763 VLC_PACK( 7 , 0 , 433 ) , 764 VLC_PACK( 0 , 1 , 4 ) , 765 VLC_PACK( 0 , 0 , 12 ) , 766 VLC_PACK( 7 , 0 , 423 ) , 767 VLC_PACK( 7 , 0 , 422 ) , 768 VLC_PACK( 1 , 1 , 4 ) , 769 VLC_PACK( 0 , 0 , 6 ) , 770 VLC_PACK( 7 , 0 , 413 ) , 771 VLC_PACK( 7 , 0 , 412 ) , 772 VLC_PACK( 3 , 1 , 0 ) , 773 VLC_PACK( 7 , 0 , 408 ) , 774 VLC_PACK( 7 , 0 , 407 ) , 775 VLC_PACK( 7 , 0 , 411 ) , 776 VLC_PACK( 7 , 0 , 410 ) , 777 VLC_PACK( 7 , 0 , 420 ) , 778 VLC_PACK( 7 , 0 , 419 ) , 779 VLC_PACK( 7 , 0 , 428 ) , 780 VLC_PACK( 7 , 0 , 427 ) , 781 VLC_PACK( 7 , 0 , 437 ) , 782 VLC_PACK( 7 , 0 , 436 ) , 783 VLC_PACK( 7 , 0 , 222 ) , 784 VLC_PACK( 7 , 0 , 190 ) , 785 /* B23_rvlc_tcoeff_1.out */ 786 VLC_PACK( 5 , 0 , 255 ) , 787 VLC_PACK( 5 , 0 , 253 ) , 788 VLC_PACK( 0 , 0 , 14 ) , 789 VLC_PACK( 0 , 1 , 15 ) , 790 VLC_PACK( 0 , 0 , 44 ) , 791 VLC_PACK( 0 , 1 , 45 ) , 792 VLC_PACK( 0 , 1 , 74 ) , 793 VLC_PACK( 0 , 2 , 103 ) , 794 VLC_PACK( 0 , 1 , 230 ) , 795 VLC_PACK( 0 , 0 , 256 ) , 796 VLC_PACK( 5 , 0 , 190 ) , 797 VLC_PACK( 7 , 0 , 254 ) , 798 VLC_PACK( 4 , 3 , 508 ) , 799 VLC_PACK( 4 , 3 , 509 ) , 800 VLC_PACK( 4 , 3 , 444 ) , 801 VLC_PACK( 4 , 3 , 445 ) , 802 VLC_PACK( 5 , 0 , 252 ) , 803 VLC_PACK( 5 , 0 , 158 ) , 804 VLC_PACK( 5 , 0 , 221 ) , 805 VLC_PACK( 5 , 0 , 62 ) , 806 VLC_PACK( 0 , 0 , 2 ) , 807 VLC_PACK( 0 , 1 , 3 ) , 808 VLC_PACK( 5 , 0 , 251 ) , 809 VLC_PACK( 5 , 0 , 189 ) , 810 VLC_PACK( 5 , 0 , 250 ) , 811 VLC_PACK( 5 , 0 , 249 ) , 812 VLC_PACK( 0 , 0 , 2 ) , 813 VLC_PACK( 0 , 1 , 3 ) , 814 VLC_PACK( 5 , 0 , 248 ) , 815 VLC_PACK( 5 , 0 , 219 ) , 816 VLC_PACK( 5 , 0 , 247 ) , 817 VLC_PACK( 5 , 0 , 246 ) , 818 VLC_PACK( 0 , 0 , 2 ) , 819 VLC_PACK( 0 , 1 , 3 ) , 820 VLC_PACK( 5 , 0 , 245 ) , 821 VLC_PACK( 5 , 0 , 244 ) , 822 VLC_PACK( 5 , 0 , 243 ) , 823 VLC_PACK( 5 , 0 , 216 ) , 824 VLC_PACK( 0 , 0 , 2 ) , 825 VLC_PACK( 0 , 1 , 3 ) , 826 VLC_PACK( 5 , 0 , 242 ) , 827 VLC_PACK( 5 , 0 , 241 ) , 828 VLC_PACK( 5 , 0 , 238 ) , 829 VLC_PACK( 5 , 0 , 237 ) , 830 VLC_PACK( 0 , 0 , 2 ) , 831 VLC_PACK( 3 , 1 , 0 ) , 832 VLC_PACK( 5 , 0 , 236 ) , 833 VLC_PACK( 5 , 0 , 152 ) , 834 VLC_PACK( 5 , 0 , 126 ) , 835 VLC_PACK( 5 , 0 , 94 ) , 836 VLC_PACK( 5 , 0 , 30 ) , 837 VLC_PACK( 5 , 0 , 439 ) , 838 VLC_PACK( 0 , 0 , 2 ) , 839 VLC_PACK( 0 , 1 , 3 ) , 840 VLC_PACK( 5 , 0 , 438 ) , 841 VLC_PACK( 5 , 0 , 437 ) , 842 VLC_PACK( 5 , 0 , 220 ) , 843 VLC_PACK( 5 , 0 , 157 ) , 844 VLC_PACK( 0 , 0 , 2 ) , 845 VLC_PACK( 0 , 1 , 3 ) , 846 VLC_PACK( 5 , 0 , 188 ) , 847 VLC_PACK( 5 , 0 , 93 ) , 848 VLC_PACK( 5 , 0 , 218 ) , 849 VLC_PACK( 5 , 0 , 156 ) , 850 VLC_PACK( 0 , 0 , 2 ) , 851 VLC_PACK( 0 , 1 , 3 ) , 852 VLC_PACK( 5 , 0 , 217 ) , 853 VLC_PACK( 5 , 0 , 187 ) , 854 VLC_PACK( 5 , 0 , 186 ) , 855 VLC_PACK( 5 , 0 , 155 ) , 856 VLC_PACK( 0 , 0 , 2 ) , 857 VLC_PACK( 0 , 1 , 3 ) , 858 VLC_PACK( 5 , 0 , 240 ) , 859 VLC_PACK( 5 , 0 , 239 ) , 860 VLC_PACK( 5 , 0 , 214 ) , 861 VLC_PACK( 5 , 0 , 213 ) , 862 VLC_PACK( 0 , 0 , 2 ) , 863 VLC_PACK( 3 , 1 , 0 ) , 864 VLC_PACK( 5 , 0 , 122 ) , 865 VLC_PACK( 5 , 0 , 27 ) , 866 VLC_PACK( 7 , 0 , 158 ) , 867 VLC_PACK( 7 , 0 , 126 ) , 868 VLC_PACK( 0 , 0 , 2 ) , 869 VLC_PACK( 0 , 1 , 3 ) , 870 VLC_PACK( 5 , 0 , 436 ) , 871 VLC_PACK( 7 , 0 , 30 ) , 872 VLC_PACK( 5 , 0 , 125 ) , 873 VLC_PACK( 5 , 0 , 435 ) , 874 VLC_PACK( 0 , 0 , 2 ) , 875 VLC_PACK( 0 , 1 , 3 ) , 876 VLC_PACK( 5 , 0 , 432 ) , 877 VLC_PACK( 5 , 0 , 431 ) , 878 VLC_PACK( 5 , 0 , 61 ) , 879 VLC_PACK( 5 , 0 , 29 ) , 880 VLC_PACK( 0 , 0 , 2 ) , 881 VLC_PACK( 0 , 1 , 3 ) , 882 VLC_PACK( 5 , 0 , 124 ) , 883 VLC_PACK( 5 , 0 , 92 ) , 884 VLC_PACK( 5 , 0 , 60 ) , 885 VLC_PACK( 5 , 0 , 28 ) , 886 VLC_PACK( 0 , 0 , 2 ) , 887 VLC_PACK( 0 , 1 , 3 ) , 888 VLC_PACK( 5 , 0 , 215 ) , 889 VLC_PACK( 5 , 0 , 154 ) , 890 VLC_PACK( 5 , 0 , 185 ) , 891 VLC_PACK( 5 , 0 , 184 ) , 892 VLC_PACK( 0 , 0 , 2 ) , 893 VLC_PACK( 3 , 1 , 0 ) , 894 VLC_PACK( 5 , 0 , 366 ) , 895 VLC_PACK( 5 , 0 , 410 ) , 896 VLC_PACK( 7 , 0 , 439 ) , 897 VLC_PACK( 7 , 0 , 438 ) , 898 VLC_PACK( 0 , 0 , 6 ) , 899 VLC_PACK( 0 , 1 , 7 ) , 900 VLC_PACK( 0 , 0 , 27 ) , 901 VLC_PACK( 0 , 1 , 28 ) , 902 VLC_PACK( 0 , 1 , 48 ) , 903 VLC_PACK( 0 , 2 , 68 ) , 904 VLC_PACK( 5 , 0 , 434 ) , 905 VLC_PACK( 5 , 0 , 433 ) , 906 VLC_PACK( 5 , 0 , 430 ) , 907 VLC_PACK( 7 , 0 , 221 ) , 908 VLC_PACK( 0 , 0 , 2 ) , 909 VLC_PACK( 0 , 1 , 3 ) , 910 VLC_PACK( 5 , 0 , 375 ) , 911 VLC_PACK( 5 , 0 , 374 ) , 912 VLC_PACK( 5 , 0 , 373 ) , 913 VLC_PACK( 5 , 0 , 426 ) , 914 VLC_PACK( 0 , 0 , 2 ) , 915 VLC_PACK( 0 , 1 , 3 ) , 916 VLC_PACK( 5 , 0 , 372 ) , 917 VLC_PACK( 5 , 0 , 420 ) , 918 VLC_PACK( 5 , 0 , 123 ) , 919 VLC_PACK( 5 , 0 , 91 ) , 920 VLC_PACK( 0 , 0 , 2 ) , 921 VLC_PACK( 2 , 1 , 3 ) , 922 VLC_PACK( 5 , 0 , 153 ) , 923 VLC_PACK( 5 , 0 , 59 ) , 924 VLC_PACK( 3 , 1 , 0 ) , 925 VLC_PACK( 7 , 0 , 218 ) , 926 VLC_PACK( 5 , 0 , 409 ) , 927 VLC_PACK( 7 , 0 , 253 ) , 928 VLC_PACK( 7 , 0 , 435 ) , 929 VLC_PACK( 7 , 0 , 432 ) , 930 VLC_PACK( 7 , 0 , 431 ) , 931 VLC_PACK( 0 , 0 , 2 ) , 932 VLC_PACK( 0 , 1 , 3 ) , 933 VLC_PACK( 5 , 0 , 429 ) , 934 VLC_PACK( 5 , 0 , 428 ) , 935 VLC_PACK( 5 , 0 , 425 ) , 936 VLC_PACK( 5 , 0 , 424 ) , 937 VLC_PACK( 0 , 0 , 2 ) , 938 VLC_PACK( 0 , 1 , 3 ) , 939 VLC_PACK( 5 , 0 , 419 ) , 940 VLC_PACK( 5 , 0 , 418 ) , 941 VLC_PACK( 5 , 0 , 311 ) , 942 VLC_PACK( 5 , 0 , 371 ) , 943 VLC_PACK( 0 , 0 , 2 ) , 944 VLC_PACK( 2 , 1 , 3 ) , 945 VLC_PACK( 5 , 0 , 310 ) , 946 VLC_PACK( 5 , 0 , 370 ) , 947 VLC_PACK( 3 , 1 , 0 ) , 948 VLC_PACK( 7 , 0 , 370 ) , 949 VLC_PACK( 7 , 0 , 188 ) , 950 VLC_PACK( 7 , 0 , 430 ) , 951 VLC_PACK( 7 , 0 , 429 ) , 952 VLC_PACK( 0 , 0 , 2 ) , 953 VLC_PACK( 0 , 1 , 3 ) , 954 VLC_PACK( 5 , 0 , 427 ) , 955 VLC_PACK( 7 , 0 , 426 ) , 956 VLC_PACK( 5 , 0 , 423 ) , 957 VLC_PACK( 5 , 0 , 422 ) , 958 VLC_PACK( 0 , 0 , 2 ) , 959 VLC_PACK( 0 , 1 , 3 ) , 960 VLC_PACK( 7 , 0 , 220 ) , 961 VLC_PACK( 7 , 0 , 157 ) , 962 VLC_PACK( 5 , 0 , 417 ) , 963 VLC_PACK( 5 , 0 , 416 ) , 964 VLC_PACK( 0 , 0 , 2 ) , 965 VLC_PACK( 2 , 1 , 3 ) , 966 VLC_PACK( 5 , 0 , 369 ) , 967 VLC_PACK( 5 , 0 , 368 ) , 968 VLC_PACK( 3 , 1 , 0 ) , 969 VLC_PACK( 7 , 0 , 405 ) , 970 VLC_PACK( 7 , 0 , 406 ) , 971 VLC_PACK( 7 , 0 , 425 ) , 972 VLC_PACK( 7 , 0 , 424 ) , 973 VLC_PACK( 0 , 0 , 6 ) , 974 VLC_PACK( 0 , 1 , 7 ) , 975 VLC_PACK( 0 , 0 , 18 ) , 976 VLC_PACK( 0 , 1 , 19 ) , 977 VLC_PACK( 0 , 1 , 27 ) , 978 VLC_PACK( 2 , 2 , 35 ) , 979 VLC_PACK( 5 , 0 , 421 ) , 980 VLC_PACK( 7 , 0 , 252 ) , 981 VLC_PACK( 7 , 0 , 125 ) , 982 VLC_PACK( 7 , 0 , 418 ) , 983 VLC_PACK( 0 , 0 , 2 ) , 984 VLC_PACK( 0 , 1 , 3 ) , 985 VLC_PACK( 5 , 0 , 415 ) , 986 VLC_PACK( 5 , 0 , 414 ) , 987 VLC_PACK( 5 , 0 , 367 ) , 988 VLC_PACK( 5 , 0 , 413 ) , 989 VLC_PACK( 0 , 0 , 2 ) , 990 VLC_PACK( 3 , 1 , 0 ) , 991 VLC_PACK( 7 , 0 , 404 ) , 992 VLC_PACK( 7 , 0 , 403 ) , 993 VLC_PACK( 7 , 0 , 189 ) , 994 VLC_PACK( 7 , 0 , 421 ) , 995 VLC_PACK( 7 , 0 , 417 ) , 996 VLC_PACK( 7 , 0 , 416 ) , 997 VLC_PACK( 0 , 0 , 2 ) , 998 VLC_PACK( 2 , 1 , 3 ) , 999 VLC_PACK( 7 , 0 , 251 ) , 1000 VLC_PACK( 7 , 0 , 93 ) , 1001 VLC_PACK( 3 , 1 , 0 ) , 1002 VLC_PACK( 5 , 0 , 411 ) , 1003 VLC_PACK( 5 , 0 , 412 ) , 1004 VLC_PACK( 7 , 0 , 415 ) , 1005 VLC_PACK( 7 , 0 , 414 ) , 1006 VLC_PACK( 0 , 0 , 2 ) , 1007 VLC_PACK( 2 , 1 , 3 ) , 1008 VLC_PACK( 7 , 0 , 61 ) , 1009 VLC_PACK( 7 , 0 , 29 ) , 1010 VLC_PACK( 3 , 1 , 0 ) , 1011 VLC_PACK( 7 , 0 , 219 ) , 1012 VLC_PACK( 7 , 0 , 250 ) , 1013 VLC_PACK( 2 , 2 , 4 ) , 1014 VLC_PACK( 2 , 1 , 7 ) , 1015 VLC_PACK( 7 , 0 , 374 ) , 1016 VLC_PACK( 7 , 0 , 375 ) , 1017 VLC_PACK( 3 , 2 , 0 ) , 1018 VLC_PACK( 3 , 2 , 0 ) , 1019 VLC_PACK( 7 , 0 , 409 ) , 1020 VLC_PACK( 7 , 0 , 371 ) , 1021 VLC_PACK( 3 , 1 , 0 ) , 1022 VLC_PACK( 7 , 0 , 372 ) , 1023 VLC_PACK( 7 , 0 , 373 ) , 1024 VLC_PACK( 0 , 1 , 4 ) , 1025 VLC_PACK( 0 , 0 , 24 ) , 1026 VLC_PACK( 7 , 0 , 94 ) , 1027 VLC_PACK( 7 , 0 , 62 ) , 1028 VLC_PACK( 0 , 1 , 4 ) , 1029 VLC_PACK( 0 , 0 , 18 ) , 1030 VLC_PACK( 7 , 0 , 434 ) , 1031 VLC_PACK( 7 , 0 , 433 ) , 1032 VLC_PACK( 0 , 1 , 4 ) , 1033 VLC_PACK( 0 , 0 , 12 ) , 1034 VLC_PACK( 7 , 0 , 423 ) , 1035 VLC_PACK( 7 , 0 , 422 ) , 1036 VLC_PACK( 1 , 1 , 4 ) , 1037 VLC_PACK( 0 , 0 , 6 ) , 1038 VLC_PACK( 7 , 0 , 413 ) , 1039 VLC_PACK( 7 , 0 , 412 ) , 1040 VLC_PACK( 3 , 1 , 0 ) , 1041 VLC_PACK( 7 , 0 , 408 ) , 1042 VLC_PACK( 7 , 0 , 407 ) , 1043 VLC_PACK( 7 , 0 , 411 ) , 1044 VLC_PACK( 7 , 0 , 410 ) , 1045 VLC_PACK( 7 , 0 , 420 ) , 1046 VLC_PACK( 7 , 0 , 419 ) , 1047 VLC_PACK( 7 , 0 , 428 ) , 1048 VLC_PACK( 7 , 0 , 427 ) , 1049 VLC_PACK( 7 , 0 , 437 ) , 1050 VLC_PACK( 7 , 0 , 436 ) , 1051 VLC_PACK( 7 , 0 , 222 ) , 1052 VLC_PACK( 7 , 0 , 190 ) , 1053 /* B29_MVDs.out */ 1054 VLC_PACK( 4 , 0 , 0 ) , 1055 VLC_PACK( 5 , 0 , 1 ) , 1056 VLC_PACK( 5 , 0 , 2 ) , 1057 VLC_PACK( 5 , 0 , 3 ) , 1058 VLC_PACK( 5 , 0 , 4 ) , 1059 VLC_PACK( 5 , 0 , 5 ) , 1060 VLC_PACK( 1 , 5 , 1 ) , 1061 VLC_PACK( 5 , 0 , 6 ) , 1062 VLC_PACK( 5 , 0 , 7 ) , 1063 VLC_PACK( 5 , 0 , 8 ) , 1064 VLC_PACK( 5 , 0 , 9 ) , 1065 VLC_PACK( 5 , 0 , 10 ) , 1066 VLC_PACK( 5 , 0 , 11 ) , 1067 VLC_PACK( 1 , 3 , 1 ) , 1068 VLC_PACK( 5 , 0 , 12 ) , 1069 VLC_PACK( 5 , 0 , 13 ) , 1070 VLC_PACK( 5 , 0 , 14 ) , 1071 VLC_PACK( 5 , 0 , 15 ) , 1072 VLC_PACK( 5 , 1 , 16 ) , 1073 /* B30_MVDs.out */ 1074 VLC_PACK( 5 , 0 , 1 ) , 1075 VLC_PACK( 5 , 0 , 2 ) , 1076 VLC_PACK( 5 , 0 , 3 ) , 1077 VLC_PACK( 5 , 0 , 4 ) , 1078 VLC_PACK( 5 , 0 , 5 ) , 1079 VLC_PACK( 5 , 0 , 6 ) , 1080 VLC_PACK( 1 , 5 , 1 ) , 1081 VLC_PACK( 5 , 0 , 7 ) , 1082 VLC_PACK( 5 , 0 , 8 ) , 1083 VLC_PACK( 5 , 0 , 9 ) , 1084 VLC_PACK( 5 , 0 , 10 ) , 1085 VLC_PACK( 5 , 0 , 11 ) , 1086 VLC_PACK( 5 , 0 , 12 ) , 1087 VLC_PACK( 1 , 2 , 1 ) , 1088 VLC_PACK( 5 , 0 , 13 ) , 1089 VLC_PACK( 5 , 0 , 14 ) , 1090 VLC_PACK( 5 , 0 , 15 ) , 1091 VLC_PACK( 5 , 1 , 16 ) , 1092 /* B31_conv_ratio.out */ 1093 VLC_PACK( 4 , 0 , 1 ) , 1094 VLC_PACK( 4 , 1 , 2 ) , 1095 VLC_PACK( 4 , 1 , 4 ) , 1096 }; 1097 1098 1099 struct context_MPEG4_s { 1100 struct context_DEC_s dec_ctx; 1101 object_context_p obj_context; /* back reference */ 1102 1103 uint32_t profile; 1104 1105 /* Picture parameters */ 1106 VAPictureParameterBufferMPEG4 *pic_params; 1107 object_surface_p forward_ref_surface; 1108 object_surface_p backward_ref_surface; 1109 1110 uint32_t display_picture_width; /* in pixels */ 1111 uint32_t display_picture_height; /* in pixels */ 1112 1113 uint32_t coded_picture_width; /* in pixels */ 1114 uint32_t coded_picture_height; /* in pixels */ 1115 1116 uint32_t picture_width_mb; /* in macroblocks */ 1117 uint32_t picture_height_mb; /* in macroblocks */ 1118 uint32_t size_mb; /* in macroblocks */ 1119 1120 uint32_t FEControl; 1121 uint32_t FE_SPS0; 1122 uint32_t FE_VOP_PPS0; 1123 uint32_t FE_VOP_SPS0; 1124 uint32_t FE_PICSH_PPS0; 1125 1126 uint32_t BE_SPS0; 1127 uint32_t BE_SPS1; 1128 uint32_t BE_VOP_PPS0; 1129 uint32_t BE_VOP_SPS0; 1130 uint32_t BE_VOP_SPS1; 1131 uint32_t BE_PICSH_PPS0; 1132 1133 /* IQ Matrix */ 1134 uint32_t qmatrix_data[MAX_QUANT_TABLES][16]; 1135 int load_non_intra_quant_mat; 1136 int load_intra_quant_mat; 1137 1138 /* VLC packed data */ 1139 struct psb_buffer_s vlc_packed_table; 1140 1141 /* FE state buffer */ 1142 struct psb_buffer_s preload_buffer; 1143 1144 struct psb_buffer_s *data_partition_buffer0; 1145 struct psb_buffer_s *data_partition_buffer1; 1146 1147 uint32_t field_type; 1148 }; 1149 1150 typedef struct context_MPEG4_s *context_MPEG4_p; 1151 1152 #define INIT_CONTEXT_MPEG4 context_MPEG4_p ctx = (context_MPEG4_p) obj_context->format_data; 1153 1154 #define SURFACE(id) ((object_surface_p) object_heap_lookup( &ctx->obj_context->driver_data->surface_heap, id )) 1155 1156 static const char *psb__debug_picture_coding_str(unsigned char vop_coding_type) 1157 { 1158 switch (vop_coding_type) { 1159 case PICTURE_CODING_I: 1160 return ("PICTURE_CODING_I"); 1161 case PICTURE_CODING_P: 1162 return ("PICTURE_CODING_P"); 1163 case PICTURE_CODING_B: 1164 return ("PICTURE_CODING_B"); 1165 case PICTURE_CODING_S: 1166 return ("PICTURE_CODING_S"); 1167 } 1168 return ("UNKNOWN!!!"); 1169 } 1170 1171 1172 static void pnw_MPEG4_QueryConfigAttributes( 1173 VAProfile profile, 1174 VAEntrypoint entrypoint, 1175 VAConfigAttrib *attrib_list, 1176 int num_attribs) 1177 { 1178 int i; 1179 drv_debug_msg(VIDEO_DEBUG_GENERAL, "pnw_MPEG4_QueryConfigAttributes\n"); 1180 1181 for (i = 0; i < num_attribs; i++) { 1182 switch (attrib_list[i].type) { 1183 case VAConfigAttribMaxPictureWidth: 1184 if (entrypoint == VAEntrypointVLD) { 1185 if (profile == VAProfileMPEG4AdvancedSimple) 1186 attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_WIDTH_MPEG4; 1187 else if(profile == VAProfileH263Baseline) 1188 attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_WIDTH_H263; 1189 else 1190 attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; 1191 } 1192 else 1193 attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; 1194 break; 1195 case VAConfigAttribMaxPictureHeight: 1196 if (entrypoint == VAEntrypointVLD) { 1197 if (profile == VAProfileMPEG4AdvancedSimple) 1198 attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_HEIGHT_MPEG4; 1199 else if(profile == VAProfileH263Baseline) 1200 attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_HEIGHT_H263; 1201 } 1202 else 1203 attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; 1204 break; 1205 default: 1206 break; 1207 } 1208 } 1209 } 1210 1211 static VAStatus pnw_MPEG4_ValidateConfig( 1212 object_config_p obj_config) 1213 { 1214 int i; 1215 /* Check all attributes */ 1216 for (i = 0; i < obj_config->attrib_count; i++) { 1217 switch (obj_config->attrib_list[i].type) { 1218 case VAConfigAttribRTFormat: 1219 /* Ignore */ 1220 break; 1221 1222 default: 1223 return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; 1224 } 1225 } 1226 1227 return VA_STATUS_SUCCESS; 1228 } 1229 1230 static VAStatus psb__MPEG4_check_legal_picture(object_context_p obj_context, object_config_p obj_config) 1231 { 1232 VAStatus vaStatus = VA_STATUS_SUCCESS; 1233 1234 CHECK_CONTEXT(obj_context); 1235 1236 CHECK_CONFIG(obj_config); 1237 1238 /* MSVDX decode capability for MPEG4: 1239 * SP@L3 1240 * ASP@L5 1241 * 1242 * Refer to the "MSVDX MPEG4 decode capability" table of "Poulsbo Media Software Overview". 1243 */ 1244 switch (obj_config->profile) { 1245 case VAProfileMPEG4Simple: 1246 case VAProfileMPEG4AdvancedSimple: 1247 if ((obj_context->picture_width <= 0) || (obj_context->picture_height <= 0)) { 1248 vaStatus = VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; 1249 } 1250 break; 1251 1252 default: 1253 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; 1254 break; 1255 } 1256 1257 return vaStatus; 1258 } 1259 1260 static void pnw_MPEG4_DestroyContext(object_context_p obj_context); 1261 static void psb__MPEG4_process_slice_data(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param); 1262 static void psb__MPEG4_end_slice(context_DEC_p dec_ctx); 1263 static void psb__MPEG4_begin_slice(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param); 1264 static VAStatus pnw_MPEG4_process_buffer(context_DEC_p dec_ctx, object_buffer_p buffer); 1265 1266 static VAStatus pnw_MPEG4_CreateContext( 1267 object_context_p obj_context, 1268 object_config_p obj_config) 1269 { 1270 VAStatus vaStatus = VA_STATUS_SUCCESS; 1271 context_MPEG4_p ctx; 1272 /* Validate flag */ 1273 /* Validate picture dimensions */ 1274 vaStatus = psb__MPEG4_check_legal_picture(obj_context, obj_config); 1275 CHECK_VASTATUS(); 1276 1277 ctx = (context_MPEG4_p) calloc(1, sizeof(struct context_MPEG4_s)); 1278 CHECK_ALLOCATION(ctx); 1279 1280 obj_context->format_data = (void*) ctx; 1281 ctx->obj_context = obj_context; 1282 ctx->pic_params = NULL; 1283 ctx->load_non_intra_quant_mat = FALSE; 1284 ctx->load_intra_quant_mat = FALSE; 1285 1286 ctx->dec_ctx.begin_slice = psb__MPEG4_begin_slice; 1287 ctx->dec_ctx.process_slice = psb__MPEG4_process_slice_data; 1288 ctx->dec_ctx.end_slice = psb__MPEG4_end_slice; 1289 ctx->dec_ctx.process_buffer = pnw_MPEG4_process_buffer; 1290 1291 ctx->data_partition_buffer0 = NULL; 1292 ctx->data_partition_buffer1 = NULL; 1293 1294 switch (obj_config->profile) { 1295 case VAProfileMPEG4Simple: 1296 drv_debug_msg(VIDEO_DEBUG_GENERAL, "MPEG4_PROFILE_SIMPLE\n"); 1297 ctx->profile = MPEG4_PROFILE_SIMPLE; 1298 break; 1299 1300 case VAProfileMPEG4AdvancedSimple: 1301 drv_debug_msg(VIDEO_DEBUG_GENERAL, "MPEG4_PROFILE_ASP\n"); 1302 ctx->profile = MPEG4_PROFILE_ASP; 1303 break; 1304 1305 default: 1306 ASSERT(0 == 1); 1307 vaStatus = VA_STATUS_ERROR_UNKNOWN; 1308 } 1309 1310 // TODO 1311 1312 if (vaStatus == VA_STATUS_SUCCESS) { 1313 vaStatus = psb_buffer_create(obj_context->driver_data, 1314 FE_STATE_BUFFER_SIZE, 1315 psb_bt_vpu_only, 1316 &ctx->preload_buffer); 1317 DEBUG_FAILURE; 1318 } 1319 ctx->dec_ctx.preload_buffer = &ctx->preload_buffer; 1320 1321 if (vaStatus == VA_STATUS_SUCCESS) { 1322 vaStatus = psb_buffer_create(obj_context->driver_data, 1323 sizeof(gaui16mpeg4VlcTableDataPacked), 1324 psb_bt_cpu_vpu, 1325 &ctx->vlc_packed_table); 1326 DEBUG_FAILURE; 1327 } 1328 if (vaStatus == VA_STATUS_SUCCESS) { 1329 unsigned char *vlc_packed_data_address; 1330 if (0 == psb_buffer_map(&ctx->vlc_packed_table, &vlc_packed_data_address)) { 1331 memcpy(vlc_packed_data_address, gaui16mpeg4VlcTableDataPacked, sizeof(gaui16mpeg4VlcTableDataPacked)); 1332 psb_buffer_unmap(&ctx->vlc_packed_table); 1333 } else { 1334 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 1335 DEBUG_FAILURE; 1336 } 1337 } 1338 1339 if (vaStatus == VA_STATUS_SUCCESS) { 1340 vaStatus = vld_dec_CreateContext(&ctx->dec_ctx, obj_context); 1341 DEBUG_FAILURE; 1342 } 1343 1344 ctx->field_type = 2; 1345 1346 if (vaStatus != VA_STATUS_SUCCESS) { 1347 pnw_MPEG4_DestroyContext(obj_context); 1348 } 1349 1350 return vaStatus; 1351 } 1352 1353 static void pnw_MPEG4_DestroyContext( 1354 object_context_p obj_context) 1355 { 1356 INIT_CONTEXT_MPEG4 1357 int i; 1358 1359 vld_dec_DestroyContext(&ctx->dec_ctx); 1360 1361 psb_buffer_destroy(&ctx->vlc_packed_table); 1362 psb_buffer_destroy(&ctx->preload_buffer); 1363 1364 if(ctx->data_partition_buffer0) 1365 psb_buffer_destroy(ctx->data_partition_buffer0); 1366 1367 if(ctx->data_partition_buffer1) 1368 psb_buffer_destroy(ctx->data_partition_buffer1); 1369 1370 ctx->data_partition_buffer0 = NULL; 1371 ctx->data_partition_buffer1 = NULL; 1372 1373 if (ctx->pic_params) { 1374 free(ctx->pic_params); 1375 ctx->pic_params = NULL; 1376 } 1377 1378 free(obj_context->format_data); 1379 obj_context->format_data = NULL; 1380 } 1381 1382 static VAStatus psb__MPEG4_process_picture_param(context_MPEG4_p ctx, object_buffer_p obj_buffer) 1383 { 1384 VAStatus vaStatus; 1385 object_surface_p obj_surface = ctx->obj_context->current_render_target; 1386 1387 ASSERT(obj_buffer->type == VAPictureParameterBufferType); 1388 ASSERT(obj_buffer->num_elements == 1); 1389 ASSERT(obj_buffer->size == sizeof(VAPictureParameterBufferMPEG4)); 1390 1391 if ((obj_buffer->num_elements != 1) || 1392 (obj_buffer->size != sizeof(VAPictureParameterBufferMPEG4))) { 1393 return VA_STATUS_ERROR_UNKNOWN; 1394 } 1395 1396 /* Transfer ownership of VAPictureParameterBufferMPEG4 data */ 1397 if (ctx->pic_params) { 1398 free(ctx->pic_params); 1399 } 1400 ctx->pic_params = (VAPictureParameterBufferMPEG4 *) obj_buffer->buffer_data; 1401 obj_buffer->buffer_data = NULL; 1402 obj_buffer->size = 0; 1403 1404 1405 /* Lookup surfaces for backward/forward references */ 1406 /* Lookup surfaces for backward/forward references */ 1407 switch (ctx->pic_params->vop_fields.bits.vop_coding_type) { 1408 case PICTURE_CODING_I: 1409 ctx->forward_ref_surface = NULL; 1410 ctx->backward_ref_surface = NULL; 1411 drv_debug_msg(VIDEO_DEBUG_GENERAL, "PICTURE_CODING_I\nTarget surface = %08x (%08x)\n", ctx->obj_context->current_render_target->psb_surface, ctx->obj_context->current_render_target->base.id); 1412 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Forward ref = NULL\n"); 1413 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Backward ref = NULL\n"); 1414 break; 1415 1416 case PICTURE_CODING_P: 1417 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 1418 ctx->backward_ref_surface = NULL; 1419 1420 if (ctx->pic_params->forward_reference_picture == VA_INVALID_SURFACE) 1421 ctx->forward_ref_surface = NULL; 1422 if (NULL == ctx->forward_ref_surface && ctx->pic_params->forward_reference_picture != VA_INVALID_SURFACE) { 1423 return VA_STATUS_ERROR_INVALID_SURFACE; 1424 } 1425 drv_debug_msg(VIDEO_DEBUG_GENERAL, "PICTURE_CODING_P\nTarget surface = %08x (%08x)\n", ctx->obj_context->current_render_target->psb_surface, ctx->obj_context->current_render_target->base.id); 1426 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Forward ref = %08x (%08x)\n", (ctx->forward_ref_surface ? ctx->forward_ref_surface->psb_surface : 0), ctx->pic_params->forward_reference_picture); 1427 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Backward ref = NULL\n"); 1428 break; 1429 1430 case PICTURE_CODING_B: 1431 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 1432 ctx->backward_ref_surface = SURFACE(ctx->pic_params->backward_reference_picture); 1433 if ((NULL == ctx->forward_ref_surface) || 1434 (NULL == ctx->backward_ref_surface)) { 1435 return VA_STATUS_ERROR_INVALID_SURFACE; 1436 } 1437 drv_debug_msg(VIDEO_DEBUG_GENERAL, "PICTURE_CODING_B\nTarget surface = %08x (%08x)\n", ctx->obj_context->current_render_target->psb_surface, ctx->obj_context->current_render_target->base.id); 1438 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Forward ref = %08x (%08x)\n", ctx->forward_ref_surface->psb_surface, ctx->pic_params->forward_reference_picture); 1439 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Backward ref = %08x (%08x)\n", ctx->backward_ref_surface->psb_surface, ctx->pic_params->backward_reference_picture); 1440 break; 1441 1442 case PICTURE_CODING_S: 1443 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 1444 ctx->backward_ref_surface = SURFACE(ctx->pic_params->backward_reference_picture); 1445 drv_debug_msg(VIDEO_DEBUG_GENERAL, "PICTURE_CODING_S\nTarget surface = %08x (%08x)\n", ctx->obj_context->current_render_target->psb_surface, ctx->obj_context->current_render_target->base.id); 1446 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Forward ref = %08x (%08x)\n", ctx->forward_ref_surface ? ctx->forward_ref_surface->psb_surface : 0, ctx->pic_params->forward_reference_picture); 1447 drv_debug_msg(VIDEO_DEBUG_GENERAL, "Backward ref = %08x (%08x)\n", ctx->backward_ref_surface ? ctx->backward_ref_surface->psb_surface : 0, ctx->pic_params->backward_reference_picture); 1448 break; 1449 1450 default: 1451 drv_debug_msg(VIDEO_DEBUG_ERROR, "Unhandled MPEG4 vop_coding_type '%d'\n", ctx->pic_params->vop_fields.bits.vop_coding_type); 1452 return VA_STATUS_ERROR_UNKNOWN; 1453 } 1454 1455 if (NULL == ctx->forward_ref_surface) { 1456 /* for mmu fault protection */ 1457 ctx->forward_ref_surface = ctx->obj_context->current_render_target; 1458 } 1459 if (NULL == ctx->backward_ref_surface) { 1460 /* for mmu fault protection */ 1461 ctx->backward_ref_surface = ctx->obj_context->current_render_target; 1462 } 1463 1464 ctx->display_picture_width = ctx->pic_params->vop_width; 1465 ctx->display_picture_height = ctx->pic_params->vop_height; 1466 ctx->picture_width_mb = PIXELS_TO_MB(ctx->display_picture_width); 1467 ctx->picture_height_mb = PIXELS_TO_MB(ctx->display_picture_height); 1468 ctx->coded_picture_width = ctx->picture_width_mb * 16; 1469 ctx->coded_picture_height = ctx->picture_height_mb * 16; 1470 ctx->size_mb = ctx->picture_width_mb * ctx->picture_height_mb; 1471 1472 if (obj_surface->share_info) { 1473 obj_surface->share_info->coded_width = ctx->coded_picture_width; 1474 obj_surface->share_info->coded_height = ctx->coded_picture_height; 1475 } 1476 1477 uint32_t mbInPic = ctx->picture_width_mb * ctx->picture_height_mb; 1478 1479 mbInPic += 4; 1480 1481 uint32_t colocated_size = ((mbInPic * 200) + 0xfff) & ~0xfff; 1482 1483 vaStatus = vld_dec_allocate_colocated_buffer(&ctx->dec_ctx, ctx->obj_context->current_render_target, colocated_size); 1484 CHECK_VASTATUS(); 1485 1486 vaStatus = vld_dec_allocate_colocated_buffer(&ctx->dec_ctx, ctx->forward_ref_surface, colocated_size); 1487 CHECK_VASTATUS(); 1488 1489 ctx->FEControl = 0; 1490 REGIO_WRITE_FIELD_LITE(ctx->FEControl , 1491 MSVDX_VEC, 1492 CR_VEC_ENTDEC_FE_CONTROL, 1493 ENTDEC_FE_PROFILE, 1494 ctx->profile); /* MPEG4 SP / ASP profile */ 1495 1496 REGIO_WRITE_FIELD_LITE(ctx->FEControl , 1497 MSVDX_VEC, 1498 CR_VEC_ENTDEC_FE_CONTROL, 1499 ENTDEC_FE_MODE, 1500 4); /* Set MPEG4 mode */ 1501 1502 /* FE_SPS0 */ 1503 ctx->FE_SPS0 = 0; 1504 REGIO_WRITE_FIELD_LITE(ctx->FE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0, FE_VOP_WIDTH_IN_MBS_LESS_1, ctx->picture_width_mb - 1); 1505 REGIO_WRITE_FIELD_LITE(ctx->FE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0, FE_SHORT_HEADER_FLAG, ctx->pic_params->vol_fields.bits.short_video_header); 1506 REGIO_WRITE_FIELD_LITE(ctx->FE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0, FE_PROFILE, ctx->profile); 1507 1508 /* FE_VOP_SPS0 */ 1509 ctx->FE_VOP_SPS0 = 0; 1510 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, FE_VOP_HEIGHT_IN_MBS_LESS_1, ctx->picture_height_mb - 1); 1511 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, QUANT_PRECISION, ctx->pic_params->quant_precision); 1512 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, FE_NO_OF_GMC_WARPING_POINTS, ((ctx->pic_params->no_of_sprite_warping_points) ? 1 : 0)); 1513 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, FE_GMC_ENABLE, (ctx->pic_params->vol_fields.bits.sprite_enable == GMC)); 1514 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, REVERSIBLE_VLC, ctx->pic_params->vol_fields.bits.reversible_vlc); 1515 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, FE_DATA_PARTITIONED, ctx->pic_params->vol_fields.bits.data_partitioned); 1516 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, FE_INTERLACED, ctx->pic_params->vol_fields.bits.interlaced); 1517 1518 if (ctx->pic_params->vol_fields.bits.short_video_header) { 1519 /* FE_PICSH_PPS0 */ 1520 ctx->FE_PICSH_PPS0 = 0; 1521 REGIO_WRITE_FIELD_LITE(ctx->FE_PICSH_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_PICSH_PPS0, NUM_MBS_IN_GOB, ctx->pic_params->num_macroblocks_in_gob); 1522 REGIO_WRITE_FIELD_LITE(ctx->FE_PICSH_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_PICSH_PPS0, NUM_GOBS_IN_VOP, ctx->pic_params->num_gobs_in_vop); 1523 REGIO_WRITE_FIELD_LITE(ctx->FE_PICSH_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_PICSH_PPS0, FE_PICSH_CODING_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1524 } 1525 1526 /* FE_VOP_PPS0 */ 1527 ctx->FE_VOP_PPS0 = 0; 1528 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0, BACKWARD_REF_VOP_CODING_TYPE, ctx->pic_params->vop_fields.bits.backward_reference_vop_coding_type); 1529 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0, FE_FCODE_BACKWARD, ctx->pic_params->vop_fcode_backward); 1530 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0, FE_FCODE_FORWARD, ctx->pic_params->vop_fcode_forward); 1531 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0, INTRA_DC_VLC_THR, ctx->pic_params->vop_fields.bits.intra_dc_vlc_thr); 1532 REGIO_WRITE_FIELD_LITE(ctx->FE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0, FE_VOP_CODING_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1533 1534 /* BE_SPS0 */ 1535 /* Common for VOPs and pictures with short header */ 1536 ctx->BE_SPS0 = 0; 1537 REGIO_WRITE_FIELD_LITE(ctx->BE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SPS0, BE_SHORT_HEADER_FLAG, ctx->pic_params->vol_fields.bits.short_video_header); 1538 REGIO_WRITE_FIELD_LITE(ctx->BE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SPS0, BE_PROFILE, ctx->profile); 1539 1540 /* BE_SPS1 */ 1541 /* Common for VOPs and pictures with short header */ 1542 ctx->BE_SPS1 = 0; 1543 REGIO_WRITE_FIELD_LITE(ctx->BE_SPS1, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SPS1, BE_VOP_WIDTH_IN_MBS_LESS_1, ctx->picture_width_mb - 1); 1544 REGIO_WRITE_FIELD_LITE(ctx->BE_SPS1, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SPS1, VOP_HEIGHT_IN_MBS_LESS_1, ctx->picture_height_mb - 1); 1545 1546 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) { 1547 /* BE_VOP_SPS0 */ 1548 ctx->BE_VOP_SPS0 = 0; 1549 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS0, QUANT_TYPE, ctx->pic_params->vol_fields.bits.quant_type); 1550 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS0, OBMC_DISABLE, ctx->pic_params->vol_fields.bits.obmc_disable); 1551 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS0, QUARTER_SAMPLE, ctx->pic_params->vol_fields.bits.quarter_sample); 1552 1553 /* BE_VOP_SPS1 */ 1554 ctx->BE_VOP_SPS1 = 0; 1555 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS1, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS1, GMC_WARPING_ACCURACY, ctx->pic_params->vol_fields.bits.sprite_warping_accuracy); 1556 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS1, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS1, BE_NO_OF_GMC_WARPING_POINTS, ((ctx->pic_params->no_of_sprite_warping_points) ? 1 : 0)); 1557 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS1, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS1, BE_GMC_ENABLE, (ctx->pic_params->vol_fields.bits.sprite_enable == GMC)); 1558 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS1, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS1, BE_DATA_PARTITIONED, ctx->pic_params->vol_fields.bits.data_partitioned); 1559 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_SPS1, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_SPS1, BE_INTERLACED, ctx->pic_params->vol_fields.bits.interlaced); 1560 1561 /* BE_VOP_PPS0 */ 1562 ctx->BE_VOP_PPS0 = 0; 1563 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, BE_FCODE_BACKWARD, ctx->pic_params->vop_fcode_backward); 1564 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, BE_FCODE_FORWARD, ctx->pic_params->vop_fcode_forward); 1565 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, ALTERNATE_VERTICAL_SCAN_FLAG, ctx->pic_params->vop_fields.bits.alternate_vertical_scan_flag); 1566 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, TOP_FIELD_FIRST, ctx->pic_params->vop_fields.bits.top_field_first); 1567 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, 1568 MSVDX_VEC_MPEG4, 1569 CR_VEC_MPEG4_BE_VOP_PPS0, 1570 ROUNDING_TYPE, 1571 ((PICTURE_CODING_I == ctx->pic_params->vop_fields.bits.vop_coding_type || 1572 PICTURE_CODING_B == ctx->pic_params->vop_fields.bits.vop_coding_type) ? 1573 0 : ctx->pic_params->vop_fields.bits.vop_rounding_type)); 1574 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, BE_VOP_CODING_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1575 } else { 1576 /* BE_VOP_PPS0 */ 1577 ctx->BE_VOP_PPS0 = 0; 1578 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, BE_FCODE_FORWARD, 1); // Always 1 in short header mode 6.3.5.2 1579 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, ALTERNATE_VERTICAL_SCAN_FLAG, ctx->pic_params->vop_fields.bits.alternate_vertical_scan_flag); 1580 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, TOP_FIELD_FIRST, ctx->pic_params->vop_fields.bits.top_field_first); 1581 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, ROUNDING_TYPE, 0); // Always 0 in short header mode 6.3.5.2 1582 REGIO_WRITE_FIELD_LITE(ctx->BE_VOP_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_PPS0, BE_VOP_CODING_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1583 1584 /* BE_PICSH_PPS0 */ 1585 ctx->BE_PICSH_PPS0 = 0; 1586 REGIO_WRITE_FIELD_LITE(ctx->BE_PICSH_PPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_PICSH_PPS0, BE_PICSH_CODING_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1587 } 1588 1589 if(ctx->pic_params->vol_fields.bits.data_partitioned) { 1590 if(!ctx->data_partition_buffer0) { 1591 int size = 16 * ctx->size_mb; 1592 ctx->data_partition_buffer0 = (psb_buffer_p) calloc(1, sizeof(struct psb_buffer_s)); 1593 CHECK_ALLOCATION(ctx->data_partition_buffer0); 1594 size = (size + 0xfff) & (~0xfff); 1595 vaStatus = psb_buffer_create(ctx->obj_context->driver_data, size, psb_bt_vpu_only, ctx->data_partition_buffer0); 1596 CHECK_VASTATUS(); 1597 } 1598 if(!ctx->data_partition_buffer1) { 1599 int size = 16 * ctx->size_mb; 1600 ctx->data_partition_buffer1 = (psb_buffer_p) calloc(1, sizeof(struct psb_buffer_s)); 1601 CHECK_ALLOCATION(ctx->data_partition_buffer1); 1602 size = (size + 0xfff) & (~0xfff); 1603 vaStatus = psb_buffer_create(ctx->obj_context->driver_data, size, psb_bt_vpu_only, ctx->data_partition_buffer1); 1604 CHECK_VASTATUS(); 1605 } 1606 } 1607 1608 return VA_STATUS_SUCCESS; 1609 } 1610 1611 static void psb__MPEG4_convert_iq_matrix(uint32_t *dest32, unsigned char *src) 1612 { 1613 int i; 1614 int *idx = scan0; 1615 uint8_t *dest8 = (uint8_t*) dest32; 1616 1617 for (i = 0; i < 64; i++) { 1618 *dest8++ = src[*idx++]; 1619 } 1620 } 1621 1622 static VAStatus psb__MPEG4_process_iq_matrix(context_MPEG4_p ctx, object_buffer_p obj_buffer) 1623 { 1624 VAIQMatrixBufferMPEG4 *iq_matrix = (VAIQMatrixBufferMPEG4 *) obj_buffer->buffer_data; 1625 ASSERT(obj_buffer->type == VAIQMatrixBufferType); 1626 ASSERT(obj_buffer->num_elements == 1); 1627 ASSERT(obj_buffer->size == sizeof(VAIQMatrixBufferMPEG4)); 1628 1629 if ((obj_buffer->num_elements != 1) || 1630 (obj_buffer->size != sizeof(VAIQMatrixBufferMPEG4))) { 1631 return VA_STATUS_ERROR_UNKNOWN; 1632 } 1633 1634 if (iq_matrix->load_non_intra_quant_mat) { 1635 psb__MPEG4_convert_iq_matrix(ctx->qmatrix_data[NONINTRA_LUMA_Q], iq_matrix->non_intra_quant_mat); 1636 } 1637 if (iq_matrix->load_intra_quant_mat) { 1638 psb__MPEG4_convert_iq_matrix(ctx->qmatrix_data[INTRA_LUMA_Q], iq_matrix->intra_quant_mat); 1639 } 1640 ctx->load_non_intra_quant_mat = iq_matrix->load_non_intra_quant_mat; 1641 ctx->load_intra_quant_mat = iq_matrix->load_intra_quant_mat; 1642 1643 return VA_STATUS_SUCCESS; 1644 } 1645 1646 static void psb__MPEG4_write_qmatrices(context_MPEG4_p ctx) 1647 { 1648 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1649 int i; 1650 1651 // TODO: Verify that this is indeed the same as MPEG2 1652 1653 /* Since we only decode 4:2:0 We only need to the Intra tables. 1654 Chroma quant tables are only used in Mpeg 4:2:2 and 4:4:4. 1655 The hardware wants non-intra followed by intra */ 1656 /* psb_cmdbuf_rendec_start_block( cmdbuf ); */ 1657 psb_cmdbuf_rendec_start(cmdbuf, REG_MSVDX_VEC_IQRAM_OFFSET); 1658 1659 /* todo : optimisation here is to only load the need table */ 1660 if (ctx->load_non_intra_quant_mat) { 1661 /* NONINTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + 0 */ 1662 for (i = 0; i < 16; i++) { 1663 psb_cmdbuf_rendec_write(cmdbuf, ctx->qmatrix_data[NONINTRA_LUMA_Q][i]); 1664 } 1665 } else { 1666 for (i = 0; i < 16; i++) { 1667 psb_cmdbuf_rendec_write(cmdbuf, 0); 1668 } 1669 } 1670 if (ctx->load_intra_quant_mat) { 1671 /* INTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + (16*4) */ 1672 for (i = 0; i < 16; i++) { 1673 psb_cmdbuf_rendec_write(cmdbuf, ctx->qmatrix_data[INTRA_LUMA_Q][i]); 1674 } 1675 } else { 1676 for (i = 0; i < 16; i++) { 1677 psb_cmdbuf_rendec_write(cmdbuf, 0); 1678 } 1679 } 1680 1681 psb_cmdbuf_rendec_end(cmdbuf); 1682 /* psb_cmdbuf_rendec_end_block( cmdbuf ); */ 1683 } 1684 1685 /* Precalculated values */ 1686 #define ADDR0 (0x00005800) 1687 #define ADDR1 (0x0001f828) 1688 #define ADDR2 (0x0002b854) 1689 #define ADDR3 (0x0002f85c) 1690 #define ADDR4 (0x0004d089) 1691 #define ADDR5 (0x0008f0aa) 1692 #define ADDR6 (0x00149988) 1693 #define ADDR7 (0x001d8b9e) 1694 #define ADDR8 (0x000003c3) 1695 #define WIDTH0 (0x09a596ed) 1696 #define WIDTH1 (0x0006d6db) 1697 #define OPCODE0 (0x50009a0a) 1698 #define OPCODE1 (0x00000001) 1699 1700 static void psb__MPEG4_write_VLC_tables(context_MPEG4_p ctx) 1701 { 1702 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1703 1704 psb_cmdbuf_skip_start_block(cmdbuf, SKIP_ON_CONTEXT_SWITCH); 1705 /* VLC Table */ 1706 /* Write a LLDMA Cmd to transfer VLD Table data */ 1707 psb_cmdbuf_dma_write_cmdbuf(cmdbuf, &ctx->vlc_packed_table, 0, 1708 sizeof(gaui16mpeg4VlcTableDataPacked), 0, 1709 DMA_TYPE_VLC_TABLE); 1710 1711 /* Write the vec registers with the index data for each of the tables and then write */ 1712 /* the actual table data. */ 1713 psb_cmdbuf_reg_start_block(cmdbuf, 0); 1714 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR0), ADDR0); 1715 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR1), ADDR1); 1716 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR2), ADDR2); 1717 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR3), ADDR3); 1718 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR4), ADDR4); 1719 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR5), ADDR5); 1720 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR6), ADDR6); 1721 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR7), ADDR7); 1722 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR8), ADDR8); 1723 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_WIDTH0), WIDTH0); 1724 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_WIDTH1), WIDTH1); 1725 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_OPCODE0), OPCODE0); 1726 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_OPCODE1), OPCODE1); 1727 psb_cmdbuf_reg_end_block(cmdbuf); 1728 1729 psb_cmdbuf_skip_end_block(cmdbuf); 1730 } 1731 1732 static void psb__MPEG4_set_picture_params(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 __maybe_unused * slice_param) 1733 { 1734 uint32_t cmd; 1735 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1736 psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 1737 1738 psb_buffer_p colocated_target_buffer = vld_dec_lookup_colocated_buffer(&ctx->dec_ctx, target_surface); 1739 psb_buffer_p colocated_ref_buffer = vld_dec_lookup_colocated_buffer(&ctx->dec_ctx, ctx->forward_ref_surface->psb_surface); /* FIXME DE2.0 use backward ref surface */ 1740 ASSERT(colocated_target_buffer); 1741 ASSERT(colocated_ref_buffer); 1742 1743 /* psb_cmdbuf_rendec_start_block( cmdbuf ); */ 1744 1745 /* BE_PARAM_BASE_ADDR */ 1746 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_PARAM_BASE_ADDR)); 1747 if (colocated_target_buffer) { 1748 psb_cmdbuf_rendec_write_address(cmdbuf, colocated_target_buffer, 0); 1749 } else { 1750 /* This is an error */ 1751 psb_cmdbuf_rendec_write(cmdbuf, 0); 1752 } 1753 psb_cmdbuf_rendec_end(cmdbuf); 1754 1755 /* PARAM_BASE_ADDRESS */ 1756 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_COLPARAM_BASE_ADDR)); 1757 if (colocated_ref_buffer) { 1758 psb_cmdbuf_rendec_write_address(cmdbuf, colocated_ref_buffer, 0); 1759 } else { 1760 /* This is an error */ 1761 psb_cmdbuf_rendec_write(cmdbuf, 0); 1762 } 1763 psb_cmdbuf_rendec_end(cmdbuf); 1764 1765 vld_dec_setup_alternative_frame(ctx->obj_context); 1766 1767 /* Send VDMC and VDEB commands */ 1768 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, DISPLAY_PICTURE_SIZE)); 1769 1770 /* Display picture size cmd */ 1771 cmd = 0; 1772 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_HEIGHT, ctx->coded_picture_height - 1); 1773 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_WIDTH, ctx->coded_picture_width - 1); 1774 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1775 1776 /* Coded picture size cmd */ 1777 cmd = 0; 1778 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_HEIGHT, ctx->coded_picture_height - 1); 1779 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_WIDTH, ctx->coded_picture_width - 1); 1780 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1781 1782 /* Operating mode cmd */ 1783 cmd = 0; 1784 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, OPERATING_MODE, CHROMA_INTERLEAVED, 0); /* 0 = CbCr, 1 = CrCb */ 1785 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, OPERATING_MODE, ROW_STRIDE, ctx->obj_context->current_render_target->psb_surface->stride_mode); 1786 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_PROFILE, ctx->profile); /* MPEG4 SP / ASP profile */ 1787 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_MODE, 4); /* MPEG4 */ 1788 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, OPERATING_MODE, ASYNC_MODE, 1); /* VDMC only */ 1789 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, OPERATING_MODE, CHROMA_FORMAT, 1); 1790 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, OPERATING_MODE, INTERLACED, ctx->pic_params->vol_fields.bits.interlaced); 1791 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1792 ctx->obj_context->operating_mode = cmd; 1793 1794 drv_debug_msg(VIDEO_DEBUG_GENERAL, " vop_coding_type = %s\n", psb__debug_picture_coding_str(ctx->pic_params->vop_fields.bits.vop_coding_type)); 1795 drv_debug_msg(VIDEO_DEBUG_GENERAL, " backward ref vop_coding_type = %s\n", psb__debug_picture_coding_str(ctx->pic_params->vop_fields.bits.backward_reference_vop_coding_type)); 1796 1797 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1798 psb_cmdbuf_rendec_write_address(cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs); 1799 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1800 psb_cmdbuf_rendec_write_address(cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 1801 1802 psb_cmdbuf_rendec_end(cmdbuf); 1803 1804 /* Reference pictures base addresses */ 1805 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES)); 1806 1807 //drv_debug_msg(VIDEO_DEBUG_GENERAL, "Target surface = %08x\n", target_surface); 1808 //drv_debug_msg(VIDEO_DEBUG_GENERAL, "Forward ref = %08x\n", ctx->forward_ref_surface->psb_surface); 1809 //drv_debug_msg(VIDEO_DEBUG_GENERAL, "Backward ref = %08x\n", ctx->backward_ref_surface->psb_surface); 1810 1811 /* forward reference picture */ 1812 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1813 psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface->buf.buffer_ofs); 1814 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1815 psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface->buf.buffer_ofs + ctx->forward_ref_surface->psb_surface->chroma_offset); 1816 1817 /* backward reference picture */ 1818 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1819 psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->backward_ref_surface->psb_surface->buf, ctx->backward_ref_surface->psb_surface->buf.buffer_ofs); 1820 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1821 psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->backward_ref_surface->psb_surface->buf, ctx->backward_ref_surface->psb_surface->buf.buffer_ofs + ctx->backward_ref_surface->psb_surface->chroma_offset); 1822 1823 psb_cmdbuf_rendec_end(cmdbuf); 1824 /* psb_cmdbuf_rendec_end_block( cmdbuf ); */ 1825 } 1826 1827 static void psb__MPEG4_set_backend_registers(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 1828 { 1829 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1830 uint32_t cmd; 1831 unsigned short width_mb = PIXELS_TO_MB(ctx->pic_params->vop_width); 1832 1833 /* psb_cmdbuf_rendec_start_block( cmdbuf ); */ 1834 1835 /* Write Back-End EntDec registers */ 1836 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_SPS0)); 1837 /* BE_SPS0 */ 1838 /* Common for VOPs and pictures with short header */ 1839 psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_SPS0); 1840 /* BE_SPS1 */ 1841 /* Common for VOPs and pictures with short header */ 1842 psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_SPS1); 1843 psb_cmdbuf_rendec_end(cmdbuf); 1844 1845 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_VOP_SPS0)); 1846 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) { 1847 /* BE_VOP_SPS0 */ 1848 psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_VOP_SPS0); 1849 /* BE_VOP_SPS1 */ 1850 psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_VOP_SPS1); 1851 /* BE_VOP_PPS0 */ 1852 psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_VOP_PPS0); 1853 } else { /* Short-header mode */ 1854 /* BE_VOP_SPS0 */ 1855 psb_cmdbuf_rendec_write(cmdbuf, 0); 1856 /* BE_VOP_SPS1 */ 1857 psb_cmdbuf_rendec_write(cmdbuf, 0); 1858 /* BE_VOP_PPS0 */ 1859 psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_VOP_PPS0); 1860 /* BE_PICSH_PPS0 */ 1861 psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_PICSH_PPS0); 1862 } 1863 psb_cmdbuf_rendec_end(cmdbuf); 1864 1865 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) { 1866 if ((GMC == ctx->pic_params->vol_fields.bits.sprite_enable) && 1867 (PICTURE_CODING_S == ctx->pic_params->vop_fields.bits.vop_coding_type)) { 1868 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_GMC_X)); 1869 1870 /* TODO: GMC Motion Vectors */ 1871 /* It is still needed to specify the precision of the motion vectors (should they be in */ 1872 /* half-sample, quarter-sample...?) and how much processing is done on the firmware on */ 1873 /* the values of the warping points. */ 1874 1875 // TODO: Which index to use? 1876 int sprite_index = 0; 1877 while (sprite_index < 3) { 1878 if (ctx->pic_params->sprite_trajectory_du[sprite_index] || ctx->pic_params->sprite_trajectory_dv[sprite_index]) 1879 break; 1880 sprite_index++; 1881 } 1882 if (sprite_index >= 3) 1883 sprite_index = 0; 1884 1885 /* BE_GMC_X */ 1886 cmd = 0; 1887 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_GMC_X, GMC_X, ctx->pic_params->sprite_trajectory_du[sprite_index] & 0x3FFF); 1888 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1889 1890 /* BE_GMC_Y */ 1891 cmd = 0; 1892 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_GMC_Y, GMC_Y, ctx->pic_params->sprite_trajectory_dv[sprite_index] & 0x3FFF); 1893 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1894 1895 psb_cmdbuf_rendec_end(cmdbuf); 1896 } 1897 } 1898 1899 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_SLICE0)); 1900 1901 /* BE_SLICE0 */ 1902 cmd = 0; 1903 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SLICE0, BE_FIRST_MB_IN_SLICE_Y, slice_param->macroblock_number / width_mb); 1904 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SLICE0, BE_FIRST_MB_IN_SLICE_X, slice_param->macroblock_number % width_mb); 1905 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1906 1907 /* CR_VEC_MPEG4_BE_VOP_TR */ 1908 cmd = 0; 1909 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_TRB, BE_TRB, ctx->pic_params->TRB); 1910 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1911 1912 cmd = 0; 1913 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_TRD, BE_TRD, ctx->pic_params->TRD); 1914 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1915 1916 psb_cmdbuf_rendec_end(cmdbuf); 1917 1918 1919 /* Send Slice Data for every slice */ 1920 /* MUST be the last slice sent */ 1921 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, SLICE_PARAMS)); 1922 1923 /* Slice params command */ 1924 cmd = 0; 1925 REGIO_WRITE_FIELD_LITE(cmd, 1926 MSVDX_CMDS, 1927 SLICE_PARAMS, 1928 RND_CTL_BIT, 1929 ((PICTURE_CODING_I == ctx->pic_params->vop_fields.bits.vop_coding_type || 1930 PICTURE_CODING_B == ctx->pic_params->vop_fields.bits.vop_coding_type) ? 1931 0 : ctx->pic_params->vop_fields.bits.vop_rounding_type)); 1932 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, SLICE_PARAMS, MODE_CONFIG, ctx->pic_params->vol_fields.bits.sprite_warping_accuracy); 1933 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, SLICE_PARAMS, SUBPEL_FILTER_MODE, ctx->pic_params->vol_fields.bits.quarter_sample); 1934 /* SP and ASP profiles don't support field coding in different VOPs */ 1935 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_FIELD_TYPE, 2); 1936 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_CODE_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1937 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1938 1939 psb_cmdbuf_rendec_end(cmdbuf); 1940 1941 *ctx->dec_ctx.p_slice_params = cmd; 1942 1943 /* CHUNK: Entdec back-end profile and level */ 1944 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL)); 1945 1946 cmd = 0; 1947 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL, ENTDEC_BE_PROFILE, ctx->profile); /* MPEG4 SP / ASP profile*/ 1948 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL, ENTDEC_BE_MODE, 4); /* 4 - MPEG4 */ 1949 psb_cmdbuf_rendec_write(cmdbuf, cmd); 1950 1951 psb_cmdbuf_rendec_end(cmdbuf); 1952 /* psb_cmdbuf_rendec_end_block( cmdbuf ); */ 1953 if (ctx->pic_params->vol_fields.bits.data_partitioned) 1954 { 1955 /*set buffer pointer to store the parsed data-partition data */ 1956 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_DATAPARTITION0_BASE_ADDR)); 1957 psb_cmdbuf_rendec_write_address(cmdbuf, ctx->data_partition_buffer0, ctx->data_partition_buffer0->buffer_ofs); 1958 psb_cmdbuf_rendec_end(cmdbuf); 1959 1960 psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_DATAPARTITION1_BASE_ADDR)); 1961 psb_cmdbuf_rendec_write_address(cmdbuf, ctx->data_partition_buffer1, ctx->data_partition_buffer1->buffer_ofs); 1962 psb_cmdbuf_rendec_end(cmdbuf); 1963 } 1964 1965 /* Send IQ matrices to Rendec */ 1966 psb__MPEG4_write_qmatrices(ctx); 1967 } 1968 1969 static void psb__MPEG4_set_frontend_registers(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 1970 { 1971 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1972 uint32_t FE_slice0; 1973 unsigned short width_mb = PIXELS_TO_MB(ctx->pic_params->vop_width); 1974 1975 psb_cmdbuf_reg_start_block(cmdbuf, 0); 1976 1977 /* FE_SLICE0 */ 1978 FE_slice0 = 0; 1979 REGIO_WRITE_FIELD_LITE(FE_slice0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0, FE_VOP_QUANT, slice_param->quant_scale); 1980 REGIO_WRITE_FIELD_LITE(FE_slice0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0, FE_FIRST_MB_IN_SLICE_Y, slice_param->macroblock_number / width_mb); 1981 REGIO_WRITE_FIELD_LITE(FE_slice0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0, FE_FIRST_MB_IN_SLICE_X, slice_param->macroblock_number % width_mb); 1982 1983 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0) , FE_slice0); 1984 1985 /* Entdec Front-End controls*/ 1986 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_ENTDEC_FE_CONTROL) , ctx->FEControl); 1987 1988 /* FE_SPS0 */ 1989 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0) , ctx->FE_SPS0); 1990 1991 /* FE_VOP_SPS0 */ 1992 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0) , ctx->FE_VOP_SPS0); 1993 1994 1995 if (ctx->pic_params->vol_fields.bits.short_video_header) { 1996 /* FE_PICSH_PPS0 */ 1997 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_PICSH_PPS0) , ctx->FE_PICSH_PPS0); 1998 } 1999 2000 /* FE_VOP_PPS0 */ 2001 psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0) , ctx->FE_VOP_PPS0); 2002 2003 psb_cmdbuf_reg_end_block(cmdbuf); 2004 2005 if (ctx->pic_params->vol_fields.bits.data_partitioned) 2006 { 2007 /*set buffer pointer to store the parsed data-partition data */ 2008 psb_cmdbuf_reg_start_block(cmdbuf, 0); 2009 psb_cmdbuf_reg_set_address(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_DATAPARTITION0_BASE_ADDR), 2010 ctx->data_partition_buffer0, ctx->data_partition_buffer0->buffer_ofs); 2011 psb_cmdbuf_reg_end_block(cmdbuf); 2012 2013 psb_cmdbuf_reg_start_block(cmdbuf, 0); 2014 psb_cmdbuf_reg_set_address(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_DATAPARTITION1_BASE_ADDR), 2015 ctx->data_partition_buffer1, ctx->data_partition_buffer1->buffer_ofs); 2016 psb_cmdbuf_reg_end_block(cmdbuf); 2017 } 2018 } 2019 2020 static void psb__MPEG4_begin_slice(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param) 2021 { 2022 VASliceParameterBufferMPEG4 *slice_param = (VASliceParameterBufferMPEG4 *) vld_slice_param; 2023 2024 dec_ctx->bits_offset = slice_param->macroblock_offset; 2025 /* dec_ctx->SR_flags = 0; */ 2026 } 2027 2028 static void psb__MPEG4_process_slice_data(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param) 2029 { 2030 VASliceParameterBufferMPEG4 *slice_param = (VASliceParameterBufferMPEG4 *) vld_slice_param; 2031 context_MPEG4_p ctx = (context_MPEG4_p)dec_ctx; 2032 2033 psb__MPEG4_write_VLC_tables(ctx); 2034 psb__MPEG4_set_picture_params(ctx, slice_param); 2035 psb__MPEG4_set_frontend_registers(ctx, slice_param); 2036 psb__MPEG4_set_backend_registers(ctx, slice_param); 2037 } 2038 2039 static void psb__MPEG4_end_slice(context_DEC_p dec_ctx) 2040 { 2041 context_MPEG4_p ctx = (context_MPEG4_p)dec_ctx; 2042 2043 #ifdef PSBVIDEO_MSVDX_EC 2044 if (ctx->obj_context->driver_data->ec_enabled) 2045 ctx->obj_context->flags |= (FW_ERROR_DETECTION_AND_RECOVERY); /* FW_ERROR_DETECTION_AND_RECOVERY */ 2046 #endif 2047 2048 ctx->obj_context->first_mb = 0; 2049 ctx->obj_context->last_mb = ((ctx->picture_height_mb - 1) << 8) | (ctx->picture_width_mb - 1); 2050 *(ctx->dec_ctx.slice_first_pic_last) = (ctx->obj_context->first_mb << 16) | (ctx->obj_context->last_mb); 2051 } 2052 2053 #ifdef PSBVIDEO_MSVDX_EC 2054 static void psb__MPEG4_choose_ec_frames(context_MPEG4_p ctx) 2055 { 2056 if (ctx->pic_params == NULL) 2057 return; 2058 int is_inter = (ctx->pic_params->vop_fields.bits.vop_coding_type == PICTURE_CODING_P || 2059 ctx->pic_params->vop_fields.bits.vop_coding_type == PICTURE_CODING_B); 2060 2061 ctx->obj_context->ec_target = NULL; 2062 2063 /* choose forward ref frame as possible */ 2064 if (is_inter && ctx->forward_ref_surface) 2065 ctx->obj_context->ec_target = ctx->forward_ref_surface; 2066 2067 /* Otherwise we conceal from the previous I or P frame*/ 2068 if (!ctx->obj_context->ec_target) 2069 { 2070 ctx->obj_context->ec_target = ctx->obj_context->ec_candidate; 2071 } 2072 2073 if (ctx->pic_params->vop_fields.bits.vop_coding_type != PICTURE_CODING_B) 2074 { 2075 ctx->obj_context->ec_candidate = ctx->obj_context->current_render_target; /* in case the next frame is an I frame we will need this */ 2076 } 2077 if (!ctx->obj_context->ec_target) { 2078 ctx->obj_context->ec_target = ctx->obj_context->current_render_target; 2079 } 2080 } 2081 #endif 2082 2083 static VAStatus pnw_MPEG4_BeginPicture( 2084 object_context_p obj_context) 2085 { 2086 INIT_CONTEXT_MPEG4 2087 2088 if (ctx->pic_params) { 2089 free(ctx->pic_params); 2090 ctx->pic_params = NULL; 2091 } 2092 ctx->load_non_intra_quant_mat = FALSE; 2093 ctx->load_intra_quant_mat = FALSE; 2094 2095 return VA_STATUS_SUCCESS; 2096 } 2097 2098 static VAStatus pnw_MPEG4_process_buffer( 2099 context_DEC_p dec_ctx, 2100 object_buffer_p buffer) 2101 { 2102 VAStatus vaStatus = VA_STATUS_SUCCESS; 2103 context_MPEG4_p ctx = (context_MPEG4_p)dec_ctx; 2104 object_buffer_p obj_buffer = buffer; 2105 2106 switch (obj_buffer->type) { 2107 case VAPictureParameterBufferType: 2108 drv_debug_msg(VIDEO_DEBUG_GENERAL, "pnw_MPEG4_RenderPicture got VAPictureParameterBuffer\n"); 2109 vaStatus = psb__MPEG4_process_picture_param(ctx, obj_buffer); 2110 DEBUG_FAILURE; 2111 break; 2112 2113 case VAIQMatrixBufferType: 2114 drv_debug_msg(VIDEO_DEBUG_GENERAL, "pnw_MPEG4_RenderPicture got VAIQMatrixBufferType\n"); 2115 vaStatus = psb__MPEG4_process_iq_matrix(ctx, obj_buffer); 2116 DEBUG_FAILURE; 2117 break; 2118 2119 default: 2120 vaStatus = VA_STATUS_ERROR_UNKNOWN; 2121 DEBUG_FAILURE; 2122 } 2123 2124 return vaStatus; 2125 } 2126 2127 static VAStatus pnw_MPEG4_EndPicture( 2128 object_context_p obj_context) 2129 { 2130 INIT_CONTEXT_MPEG4 2131 psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 2132 psb_driver_data_p driver_data = obj_context->driver_data; 2133 VAStatus vaStatus = VA_STATUS_SUCCESS; 2134 2135 #ifdef PSBVIDEO_MSVDX_EC 2136 /* Sent the HOST_BE_OPP command to detect slice error */ 2137 if (ctx->pic_params && ctx->pic_params->vol_fields.bits.interlaced) 2138 driver_data->ec_enabled = 0; 2139 2140 if (driver_data->ec_enabled) { 2141 uint32_t rotation_flags = 0; 2142 uint32_t ext_stride_a = 0; 2143 object_surface_p ec_target; 2144 2145 psb__MPEG4_choose_ec_frames(ctx); 2146 ec_target = ctx->obj_context->ec_target; 2147 REGIO_WRITE_FIELD_LITE(ext_stride_a, MSVDX_CMDS, EXTENDED_ROW_STRIDE, EXT_ROW_STRIDE, target_surface->stride / 64); 2148 2149 /* FIXME ec ignor rotate condition */ 2150 if(ec_target) { 2151 if (psb_context_get_next_cmdbuf(ctx->obj_context)) { 2152 vaStatus = VA_STATUS_ERROR_UNKNOWN; 2153 DEBUG_FAILURE; 2154 return vaStatus; 2155 } 2156 2157 if (psb_context_submit_host_be_opp(ctx->obj_context, 2158 &target_surface->buf, 2159 &ec_target->psb_surface->buf, 2160 NULL, 2161 ctx->picture_width_mb, 2162 ctx->picture_height_mb, 2163 rotation_flags, 2164 ctx->field_type, 2165 ext_stride_a, 2166 target_surface->chroma_offset + target_surface->buf.buffer_ofs, 2167 ec_target->psb_surface->chroma_offset + ec_target->psb_surface->buf.buffer_ofs)) { 2168 return VA_STATUS_ERROR_UNKNOWN; 2169 } 2170 } 2171 } 2172 #endif 2173 2174 if (psb_context_flush_cmdbuf(ctx->obj_context)) { 2175 return VA_STATUS_ERROR_UNKNOWN; 2176 } 2177 2178 if (ctx->pic_params) { 2179 free(ctx->pic_params); 2180 ctx->pic_params = NULL; 2181 } 2182 2183 return VA_STATUS_SUCCESS; 2184 } 2185 2186 struct format_vtable_s pnw_MPEG4_vtable = { 2187 queryConfigAttributes: 2188 pnw_MPEG4_QueryConfigAttributes, 2189 validateConfig: 2190 pnw_MPEG4_ValidateConfig, 2191 createContext: 2192 pnw_MPEG4_CreateContext, 2193 destroyContext: 2194 pnw_MPEG4_DestroyContext, 2195 beginPicture: 2196 pnw_MPEG4_BeginPicture, 2197 renderPicture: 2198 vld_dec_RenderPicture, 2199 endPicture: 2200 pnw_MPEG4_EndPicture 2201 }; 2202