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