pnw_MPEG4.c revision 2befccec034c13d34746a9e87149889d59ac767b
1/* 2 * INTEL CONFIDENTIAL 3 * Copyright 2007 Intel Corporation. All Rights Reserved. 4 * Copyright 2005-2007 Imagination Technologies Limited. All Rights Reserved. 5 * 6 * The source code contained or described herein and all documents related to 7 * the source code ("Material") are owned by Intel Corporation or its suppliers 8 * or licensors. Title to the Material remains with Intel Corporation or its 9 * suppliers and licensors. The Material may contain trade secrets and 10 * proprietary and confidential information of Intel Corporation and its 11 * suppliers and licensors, and is protected by worldwide copyright and trade 12 * secret laws and treaty provisions. No part of the Material may be used, 13 * copied, reproduced, modified, published, uploaded, posted, transmitted, 14 * distributed, or disclosed in any way without Intel's prior express written 15 * permission. 16 * 17 * No license under any patent, copyright, trade secret or other intellectual 18 * property right is granted to or conferred upon you by disclosure or delivery 19 * of the Materials, either expressly, by implication, inducement, estoppel or 20 * otherwise. Any license under such intellectual property rights must be 21 * express and approved by Intel in writing. 22 */ 23 24 25#include "pnw_MPEG4.h" 26#include "psb_def.h" 27#include "psb_surface.h" 28#include "psb_cmdbuf.h" 29 30#include "hwdefs/reg_io2.h" 31#include "hwdefs/msvdx_offsets.h" 32#include "hwdefs/msvdx_cmds_io2.h" 33#include "hwdefs/msvdx_vec_reg_io2.h" 34#include "hwdefs/msvdx_vec_mpeg4_reg_io2.h" 35#include "hwdefs/dxva_fw_ctrl.h" 36 37#include <stdlib.h> 38#include <stdint.h> 39#include <string.h> 40 41#define GET_SURFACE_INFO_is_defined(psb_surface) ((int) (psb_surface->extra_info[0])) 42#define SET_SURFACE_INFO_is_defined(psb_surface, val) psb_surface->extra_info[0] = (uint32_t) val; 43#define GET_SURFACE_INFO_picture_structure(psb_surface) (psb_surface->extra_info[1]) 44#define SET_SURFACE_INFO_picture_structure(psb_surface, val) psb_surface->extra_info[1] = val; 45#define GET_SURFACE_INFO_picture_coding_type(psb_surface) ((int) (psb_surface->extra_info[2])) 46#define SET_SURFACE_INFO_picture_coding_type(psb_surface, val) psb_surface->extra_info[2] = (uint32_t) val; 47#define GET_SURFACE_INFO_colocated_index(psb_surface) ((int) (psb_surface->extra_info[3])) 48#define SET_SURFACE_INFO_colocated_index(psb_surface, val) psb_surface->extra_info[3] = (uint32_t) val; 49 50#define SLICEDATA_BUFFER_TYPE(type) ((type==VASliceDataBufferType)?"VASliceDataBufferType":"VAProtectedSliceDataBufferType") 51 52#define PIXELS_TO_MB(x) ((x + 15) / 16) 53 54/* 55 * Frame types - format dependant! 56 */ 57#define PICTURE_CODING_I 0x00 58#define PICTURE_CODING_P 0x01 59#define PICTURE_CODING_B 0x02 60#define PICTURE_CODING_S 0x03 61 62 63#define FE_STATE_BUFFER_SIZE 4096 64#define FE_STATE_SAVE_SIZE ( 0xB40 - 0x700 ) 65 66#define MPEG4_PROFILE_SIMPLE 0 67#define MPEG4_PROFILE_ASP 2 68 69/* Table V2-2 ISO/IEC 14496-2:2001(E) - sprite enable codewords */ 70typedef enum 71{ 72 SPRITE_NOT_USED = 0, 73 STATIC, 74 GMC, 75} MPEG4_eSpriteEnable; 76 77 78#define MAX_QUANT_TABLES (2) /* only 2 tables for 4:2:0 decode */ 79 80static int scan0[64] = // spec, fig 7-2 81{/*u 0 ..... 7*/ 82 0, 1, 5, 6, 14, 15, 27, 28, /* v = 0 */ 83 2, 4, 7, 13, 16, 26, 29, 42, 84 3, 8, 12, 17, 25, 30, 41, 43, 85 9, 11, 18, 24, 31, 40, 44, 53, 86 10, 19, 23, 32, 39, 45, 52, 54, 87 20, 22, 33, 38, 46, 51, 55, 60, 88 21, 34, 37, 47, 50, 56, 59, 61, 89 35, 36, 48, 49, 57, 58, 62, 63 /* v = 7 */ 90}; 91 92typedef enum 93{ 94 NONINTRA_LUMA_Q = 0, 95 INTRA_LUMA_Q = 1 96} QUANT_IDX; 97 98/************************************************************************************/ 99/* Variable length codes in 'packed' format */ 100/************************************************************************************/ 101 102/* Format is: opcode, width, symbol. All VLC tables are concatenated. */ 103#define VLC_PACK(a,b,c) ( ( (a) << 12 ) | ( (b) << 9 ) | (c) ) 104const static IMG_UINT16 gaui16mpeg4VlcTableDataPacked[] = 105{ 106 VLC_PACK( 4 , 0 , 12 ), VLC_PACK( 5 , 0 , 7 ), VLC_PACK( 4 , 2 , 13 ), VLC_PACK( 4 , 3 , 16 ), VLC_PACK( 5 , 0 , 9 ), VLC_PACK( 4 , 5 , 17 ), 107 VLC_PACK( 2 , 2 , 1 ), VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 4 , 2 , 36 ), VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 4 , 0 , 0 ), 108 VLC_PACK( 0 , 0 , 6 ), VLC_PACK( 0 , 0 , 7 ), VLC_PACK( 2 , 1 , 8 ), VLC_PACK( 0 , 1 , 10 ), VLC_PACK( 2 , 1 , 13 ), VLC_PACK( 0 , 2 , 15 ), 109 VLC_PACK( 4 , 0 , 8 ), VLC_PACK( 4 , 0 , 4 ), VLC_PACK( 4 , 0 , 2 ), VLC_PACK( 4 , 0 , 1 ), VLC_PACK( 4 , 0 , 12 ), VLC_PACK( 4 , 1 , 3 ), 110 VLC_PACK( 4 , 1 , 16 ), VLC_PACK( 4 , 1 , 10 ), VLC_PACK( 4 , 1 , 9 ), VLC_PACK( 4 , 1 , 6 ), VLC_PACK( 4 , 1 , 5 ), VLC_PACK( 4 , 0 , 15 ), 111 VLC_PACK( 4 , 1 , 11 ), VLC_PACK( 4 , 1 , 13 ), VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 4 , 2 , 36 ), VLC_PACK( 4 , 2 , 19 ), VLC_PACK( 4 , 2 , 18 ), 112 VLC_PACK( 4 , 2 , 17 ), VLC_PACK( 4 , 2 , 7 ), VLC_PACK( 4 , 1 , 14 ), VLC_PACK( 4 , 1 , 14 ), VLC_PACK( 1 , 1 , 16 ), VLC_PACK( 0 , 0 , 18 ), 113 VLC_PACK( 0 , 0 , 19 ), VLC_PACK( 4 , 3 , 0 ), VLC_PACK( 4 , 3 , 12 ), VLC_PACK( 4 , 3 , 10 ), VLC_PACK( 4 , 3 , 14 ), VLC_PACK( 4 , 3 , 5 ), 114 VLC_PACK( 4 , 3 , 13 ), VLC_PACK( 4 , 3 , 3 ), VLC_PACK( 4 , 3 , 11 ), VLC_PACK( 4 , 3 , 7 ), VLC_PACK( 4 , 1 , 15 ), VLC_PACK( 4 , 1 , 15 ), 115 VLC_PACK( 4 , 1 , 15 ), VLC_PACK( 4 , 1 , 15 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 4 , 1 , 6 ), VLC_PACK( 4 , 1 , 9 ), VLC_PACK( 4 , 0 , 8 ), 116 VLC_PACK( 4 , 0 , 4 ), VLC_PACK( 4 , 0 , 2 ), VLC_PACK( 4 , 0 , 1 ), VLC_PACK( 1 , 1 , 16 ), VLC_PACK( 0 , 0 , 18 ), VLC_PACK( 6 , 0 , 6 ), 117 VLC_PACK( 4 , 3 , 15 ), VLC_PACK( 4 , 3 , 3 ), VLC_PACK( 4 , 3 , 5 ), VLC_PACK( 4 , 3 , 1 ), VLC_PACK( 4 , 3 , 10 ), VLC_PACK( 4 , 3 , 2 ), 118 VLC_PACK( 4 , 3 , 12 ), VLC_PACK( 4 , 3 , 4 ), VLC_PACK( 4 , 3 , 8 ), VLC_PACK( 4 , 1 , 0 ), VLC_PACK( 4 , 1 , 0 ), VLC_PACK( 4 , 1 , 0 ), 119 VLC_PACK( 4 , 1 , 0 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 4 , 1 , 9 ), VLC_PACK( 4 , 1 , 6 ), VLC_PACK( 4 , 0 , 7 ), VLC_PACK( 4 , 0 , 11 ), 120 VLC_PACK( 4 , 0 , 0 ), VLC_PACK( 4 , 1 , 1 ), VLC_PACK( 4 , 1 , 2 ), VLC_PACK( 4 , 0 , 0 ), VLC_PACK( 4 , 1 , 1 ), VLC_PACK( 4 , 2 , 2 ), 121 VLC_PACK( 4 , 3 , 3 ), VLC_PACK( 3 , 3 , 0 ), VLC_PACK( 4 , 0 , 0 ), VLC_PACK( 4 , 1 , 4 ), VLC_PACK( 4 , 1 , 2 ), VLC_PACK( 4 , 0 , 0 ), 122 VLC_PACK( 5 , 0 , 1 ), VLC_PACK( 5 , 0 , 2 ), VLC_PACK( 5 , 0 , 3 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 2 , 3 , 5 ), VLC_PACK( 0 , 3 , 11 ), 123 VLC_PACK( 5 , 0 , 4 ), VLC_PACK( 5 , 0 , 5 ), VLC_PACK( 5 , 0 , 6 ), VLC_PACK( 5 , 0 , 7 ), VLC_PACK( 0 , 0 , 4 ), VLC_PACK( 5 , 0 , 10 ), 124 VLC_PACK( 5 , 0 , 11 ), VLC_PACK( 5 , 0 , 12 ), VLC_PACK( 5 , 0 , 9 ), VLC_PACK( 5 , 0 , 8 ), VLC_PACK( 1 , 1 , 16 ), VLC_PACK( 0 , 0 , 18 ), 125 VLC_PACK( 0 , 0 , 19 ), VLC_PACK( 0 , 0 , 20 ), VLC_PACK( 5 , 0 , 24 ), VLC_PACK( 5 , 0 , 23 ), VLC_PACK( 5 , 0 , 22 ), VLC_PACK( 5 , 0 , 21 ), 126 VLC_PACK( 5 , 0 , 20 ), VLC_PACK( 5 , 0 , 19 ), VLC_PACK( 5 , 0 , 18 ), VLC_PACK( 5 , 0 , 17 ), VLC_PACK( 5 , 0 , 16 ), VLC_PACK( 5 , 0 , 15 ), 127 VLC_PACK( 5 , 0 , 14 ), VLC_PACK( 5 , 0 , 13 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 32 ), VLC_PACK( 5 , 0 , 31 ), VLC_PACK( 5 , 0 , 30 ), 128 VLC_PACK( 5 , 0 , 29 ), VLC_PACK( 5 , 0 , 28 ), VLC_PACK( 5 , 0 , 27 ), VLC_PACK( 5 , 0 , 26 ), VLC_PACK( 5 , 0 , 25 ), VLC_PACK( 2 , 5 , 4 ), 129 VLC_PACK( 0 , 0 , 14 ), VLC_PACK( 4 , 1 , 2 ), VLC_PACK( 4 , 1 , 1 ), VLC_PACK( 4 , 0 , 4 ), VLC_PACK( 4 , 1 , 5 ), VLC_PACK( 4 , 2 , 6 ), 130 VLC_PACK( 4 , 3 , 7 ), VLC_PACK( 4 , 4 , 8 ), VLC_PACK( 4 , 5 , 9 ), VLC_PACK( 2 , 2 , 1 ), VLC_PACK( 4 , 0 , 10 ), VLC_PACK( 4 , 1 , 11 ), 131 VLC_PACK( 4 , 2 , 12 ), VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 4 , 0 , 3 ), VLC_PACK( 4 , 0 , 0 ), VLC_PACK( 2 , 5 , 4 ), VLC_PACK( 4 , 1 , 2 ), 132 VLC_PACK( 4 , 1 , 1 ), VLC_PACK( 4 , 1 , 0 ), VLC_PACK( 4 , 0 , 3 ), VLC_PACK( 4 , 1 , 4 ), VLC_PACK( 4 , 2 , 5 ), VLC_PACK( 4 , 3 , 6 ), 133 VLC_PACK( 4 , 4 , 7 ), VLC_PACK( 4 , 5 , 8 ), VLC_PACK( 2 , 3 , 1 ), VLC_PACK( 4 , 0 , 9 ), VLC_PACK( 4 , 1 , 10 ), VLC_PACK( 4 , 2 , 11 ), 134 VLC_PACK( 4 , 3 , 12 ), VLC_PACK( 3 , 3 , 0 ), VLC_PACK( 2 , 1 , 16 ), VLC_PACK( 0 , 3 , 77 ), VLC_PACK( 0 , 2 , 96 ), VLC_PACK( 0 , 1 , 103 ), 135 VLC_PACK( 2 , 1 , 106 ), VLC_PACK( 2 , 1 , 108 ), VLC_PACK( 5 , 1 , 250 ), VLC_PACK( 7 , 0 , 254 ), VLC_PACK( 4 , 2 , 508 ), VLC_PACK( 4 , 2 , 508 ), 136 VLC_PACK( 4 , 2 , 509 ), VLC_PACK( 4 , 2 , 509 ), VLC_PACK( 4 , 3 , 506 ), VLC_PACK( 4 , 3 , 507 ), VLC_PACK( 5 , 0 , 222 ), VLC_PACK( 5 , 0 , 252 ), 137 VLC_PACK( 0 , 3 , 3 ), VLC_PACK( 2 , 1 , 18 ), VLC_PACK( 0 , 3 , 44 ), VLC_PACK( 5 , 1 , 237 ), VLC_PACK( 7 , 0 , 433 ), VLC_PACK( 7 , 0 , 434 ), 138 VLC_PACK( 7 , 0 , 435 ), VLC_PACK( 7 , 0 , 436 ), VLC_PACK( 7 , 0 , 437 ), VLC_PACK( 7 , 0 , 221 ), VLC_PACK( 7 , 0 , 251 ), VLC_PACK( 5 , 0 , 435 ), 139 VLC_PACK( 5 , 0 , 436 ), VLC_PACK( 5 , 0 , 29 ), VLC_PACK( 5 , 0 , 61 ), VLC_PACK( 5 , 0 , 93 ), VLC_PACK( 5 , 0 , 156 ), VLC_PACK( 5 , 0 , 188 ), 140 VLC_PACK( 5 , 0 , 217 ), VLC_PACK( 4 , 0 , 255 ), VLC_PACK( 0 , 3 , 2 ), VLC_PACK( 0 , 2 , 17 ), VLC_PACK( 5 , 0 , 230 ), VLC_PACK( 5 , 0 , 229 ), 141 VLC_PACK( 5 , 0 , 228 ), VLC_PACK( 5 , 0 , 214 ), VLC_PACK( 5 , 0 , 60 ), VLC_PACK( 5 , 0 , 213 ), VLC_PACK( 5 , 0 , 186 ), VLC_PACK( 5 , 0 , 28 ), 142 VLC_PACK( 5 , 0 , 433 ), VLC_PACK( 7 , 0 , 247 ), VLC_PACK( 7 , 0 , 93 ), VLC_PACK( 7 , 0 , 61 ), VLC_PACK( 7 , 0 , 430 ), VLC_PACK( 7 , 0 , 429 ), 143 VLC_PACK( 7 , 0 , 428 ), VLC_PACK( 7 , 0 , 427 ), VLC_PACK( 5 , 0 , 232 ), VLC_PACK( 5 , 0 , 231 ), VLC_PACK( 5 , 0 , 215 ), VLC_PACK( 5 , 0 , 374 ), 144 VLC_PACK( 7 , 0 , 157 ), VLC_PACK( 7 , 0 , 125 ), VLC_PACK( 7 , 0 , 432 ), VLC_PACK( 7 , 0 , 431 ), VLC_PACK( 3 , 3 , 0 ), VLC_PACK( 3 , 3 , 0 ), 145 VLC_PACK( 7 , 1 , 248 ), VLC_PACK( 5 , 1 , 233 ), VLC_PACK( 7 , 0 , 189 ), VLC_PACK( 7 , 0 , 220 ), VLC_PACK( 7 , 0 , 250 ), VLC_PACK( 5 , 0 , 434 ), 146 VLC_PACK( 5 , 0 , 92 ), VLC_PACK( 5 , 0 , 375 ), VLC_PACK( 5 , 0 , 124 ), VLC_PACK( 5 , 0 , 155 ), VLC_PACK( 5 , 0 , 187 ), VLC_PACK( 5 , 0 , 216 ), 147 VLC_PACK( 5 , 0 , 235 ), VLC_PACK( 5 , 0 , 236 ), VLC_PACK( 0 , 0 , 16 ), VLC_PACK( 0 , 0 , 17 ), VLC_PACK( 5 , 1 , 241 ), VLC_PACK( 7 , 0 , 439 ), 148 VLC_PACK( 7 , 0 , 30 ), VLC_PACK( 7 , 0 , 62 ), VLC_PACK( 7 , 0 , 252 ), VLC_PACK( 5 , 0 , 437 ), VLC_PACK( 5 , 0 , 438 ), VLC_PACK( 5 , 0 , 439 ), 149 VLC_PACK( 7 , 0 , 438 ), VLC_PACK( 5 , 0 , 157 ), VLC_PACK( 5 , 0 , 219 ), VLC_PACK( 5 , 0 , 243 ), VLC_PACK( 5 , 0 , 244 ), VLC_PACK( 5 , 0 , 245 ), 150 VLC_PACK( 5 , 0 , 218 ), VLC_PACK( 5 , 0 , 239 ), VLC_PACK( 5 , 0 , 125 ), VLC_PACK( 5 , 0 , 240 ), VLC_PACK( 7 , 0 , 126 ), VLC_PACK( 7 , 0 , 158 ), 151 VLC_PACK( 5 , 0 , 62 ), VLC_PACK( 7 , 0 , 94 ), VLC_PACK( 5 , 0 , 30 ), VLC_PACK( 5 , 0 , 189 ), VLC_PACK( 5 , 0 , 220 ), VLC_PACK( 5 , 0 , 246 ), 152 VLC_PACK( 7 , 0 , 253 ), VLC_PACK( 5 , 0 , 94 ), VLC_PACK( 7 , 0 , 190 ), VLC_PACK( 7 , 0 , 222 ), VLC_PACK( 5 , 1 , 247 ), VLC_PACK( 5 , 0 , 158 ), 153 VLC_PACK( 5 , 0 , 126 ), VLC_PACK( 5 , 0 , 190 ), VLC_PACK( 5 , 0 , 249 ), VLC_PACK( 5 , 0 , 221 ), VLC_PACK( 2 , 4 , 16 ), VLC_PACK( 2 , 3 , 68 ), 154 VLC_PACK( 0 , 2 , 84 ), VLC_PACK( 0 , 1 , 91 ), VLC_PACK( 1 , 1 , 94 ), VLC_PACK( 2 , 1 , 96 ), VLC_PACK( 0 , 0 , 98 ), VLC_PACK( 7 , 0 , 254 ), 155 VLC_PACK( 4 , 2 , 508 ), VLC_PACK( 4 , 2 , 508 ), VLC_PACK( 4 , 2 , 509 ), VLC_PACK( 4 , 2 , 509 ), VLC_PACK( 4 , 3 , 444 ), VLC_PACK( 4 , 3 , 445 ), 156 VLC_PACK( 5 , 0 , 190 ), VLC_PACK( 5 , 0 , 253 ), VLC_PACK( 2 , 3 , 6 ), VLC_PACK( 2 , 1 , 14 ), VLC_PACK( 0 , 2 , 40 ), VLC_PACK( 7 , 2 , 419 ), 157 VLC_PACK( 2 , 1 , 46 ), VLC_PACK( 3 , 4 , 0 ), VLC_PACK( 2 , 2 , 5 ), VLC_PACK( 7 , 2 , 426 ), VLC_PACK( 7 , 1 , 424 ), VLC_PACK( 7 , 0 , 423 ), 158 VLC_PACK( 5 , 1 , 246 ), VLC_PACK( 5 , 2 , 427 ), VLC_PACK( 5 , 1 , 425 ), VLC_PACK( 7 , 0 , 253 ), VLC_PACK( 7 , 0 , 430 ), VLC_PACK( 4 , 0 , 255 ), 159 VLC_PACK( 0 , 3 , 2 ), VLC_PACK( 0 , 2 , 17 ), VLC_PACK( 5 , 0 , 217 ), VLC_PACK( 5 , 0 , 187 ), VLC_PACK( 5 , 0 , 124 ), VLC_PACK( 5 , 0 , 92 ), 160 VLC_PACK( 5 , 0 , 60 ), VLC_PACK( 5 , 0 , 373 ), VLC_PACK( 5 , 0 , 422 ), VLC_PACK( 5 , 0 , 421 ), VLC_PACK( 7 , 0 , 414 ), VLC_PACK( 7 , 0 , 413 ), 161 VLC_PACK( 7 , 0 , 412 ), VLC_PACK( 7 , 0 , 411 ), VLC_PACK( 7 , 0 , 410 ), VLC_PACK( 7 , 0 , 409 ), VLC_PACK( 7 , 0 , 408 ), VLC_PACK( 7 , 0 , 407 ), 162 VLC_PACK( 5 , 0 , 243 ), VLC_PACK( 5 , 0 , 218 ), VLC_PACK( 5 , 0 , 424 ), VLC_PACK( 5 , 0 , 423 ), VLC_PACK( 7 , 0 , 418 ), VLC_PACK( 7 , 0 , 417 ), 163 VLC_PACK( 7 , 0 , 416 ), VLC_PACK( 7 , 0 , 415 ), VLC_PACK( 5 , 0 , 374 ), VLC_PACK( 5 , 0 , 375 ), VLC_PACK( 5 , 0 , 29 ), VLC_PACK( 5 , 0 , 61 ), 164 VLC_PACK( 5 , 0 , 93 ), VLC_PACK( 5 , 0 , 156 ), VLC_PACK( 5 , 0 , 188 ), VLC_PACK( 5 , 0 , 219 ), VLC_PACK( 5 , 1 , 244 ), VLC_PACK( 7 , 0 , 252 ), 165 VLC_PACK( 7 , 0 , 221 ), VLC_PACK( 0 , 2 , 5 ), VLC_PACK( 7 , 2 , 432 ), VLC_PACK( 0 , 0 , 11 ), VLC_PACK( 0 , 0 , 12 ), VLC_PACK( 5 , 1 , 431 ), 166 VLC_PACK( 7 , 0 , 436 ), VLC_PACK( 7 , 0 , 437 ), VLC_PACK( 7 , 0 , 438 ), VLC_PACK( 5 , 0 , 433 ), VLC_PACK( 5 , 0 , 434 ), VLC_PACK( 5 , 0 , 189 ), 167 VLC_PACK( 5 , 0 , 220 ), VLC_PACK( 5 , 0 , 250 ), VLC_PACK( 5 , 1 , 248 ), VLC_PACK( 7 , 0 , 431 ), VLC_PACK( 5 , 0 , 125 ), VLC_PACK( 5 , 0 , 157 ), 168 VLC_PACK( 7 , 0 , 439 ), VLC_PACK( 7 , 0 , 30 ), VLC_PACK( 7 , 0 , 62 ), VLC_PACK( 7 , 0 , 94 ), VLC_PACK( 5 , 0 , 435 ), VLC_PACK( 5 , 0 , 436 ), 169 VLC_PACK( 5 , 0 , 437 ), VLC_PACK( 5 , 0 , 251 ), VLC_PACK( 7 , 0 , 126 ), VLC_PACK( 7 , 0 , 158 ), VLC_PACK( 7 , 0 , 190 ), VLC_PACK( 7 , 0 , 222 ), 170 VLC_PACK( 5 , 1 , 438 ), VLC_PACK( 5 , 0 , 30 ), VLC_PACK( 5 , 0 , 62 ), VLC_PACK( 5 , 0 , 94 ), VLC_PACK( 5 , 0 , 252 ), VLC_PACK( 5 , 0 , 221 ), 171 VLC_PACK( 5 , 0 , 126 ), VLC_PACK( 5 , 0 , 158 ), VLC_PACK( 5 , 0 , 255 ), VLC_PACK( 5 , 0 , 222 ), VLC_PACK( 0 , 0 , 14 ), VLC_PACK( 0 , 1 , 15 ), 172 VLC_PACK( 0 , 0 , 44 ), VLC_PACK( 0 , 1 , 45 ), VLC_PACK( 0 , 1 , 74 ), VLC_PACK( 0 , 2 , 103 ), VLC_PACK( 0 , 1 , 230 ), VLC_PACK( 0 , 0 , 256 ), 173 VLC_PACK( 5 , 0 , 252 ), VLC_PACK( 7 , 0 , 254 ), VLC_PACK( 4 , 3 , 508 ), VLC_PACK( 4 , 3 , 509 ), VLC_PACK( 4 , 3 , 506 ), VLC_PACK( 4 , 3 , 507 ), 174 VLC_PACK( 5 , 0 , 190 ), VLC_PACK( 5 , 0 , 158 ), VLC_PACK( 5 , 0 , 126 ), VLC_PACK( 5 , 0 , 94 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), 175 VLC_PACK( 5 , 0 , 62 ), VLC_PACK( 5 , 0 , 30 ), VLC_PACK( 5 , 0 , 439 ), VLC_PACK( 5 , 0 , 438 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), 176 VLC_PACK( 5 , 0 , 437 ), VLC_PACK( 5 , 0 , 93 ), VLC_PACK( 5 , 0 , 436 ), VLC_PACK( 5 , 0 , 435 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), 177 VLC_PACK( 5 , 0 , 434 ), VLC_PACK( 5 , 0 , 374 ), VLC_PACK( 5 , 0 , 373 ), VLC_PACK( 5 , 0 , 123 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), 178 VLC_PACK( 5 , 0 , 433 ), VLC_PACK( 5 , 0 , 432 ), VLC_PACK( 5 , 0 , 431 ), VLC_PACK( 5 , 0 , 430 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), 179 VLC_PACK( 5 , 0 , 228 ), VLC_PACK( 5 , 0 , 150 ), VLC_PACK( 5 , 0 , 221 ), VLC_PACK( 5 , 0 , 251 ), VLC_PACK( 5 , 0 , 250 ), VLC_PACK( 5 , 0 , 249 ), 180 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 189 ), VLC_PACK( 5 , 0 , 220 ), VLC_PACK( 5 , 0 , 157 ), VLC_PACK( 5 , 0 , 125 ), 181 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 188 ), VLC_PACK( 5 , 0 , 156 ), VLC_PACK( 5 , 0 , 61 ), VLC_PACK( 5 , 0 , 29 ), 182 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 92 ), VLC_PACK( 5 , 0 , 60 ), VLC_PACK( 5 , 0 , 91 ), VLC_PACK( 5 , 0 , 59 ), 183 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 372 ), VLC_PACK( 5 , 0 , 311 ), VLC_PACK( 5 , 0 , 429 ), VLC_PACK( 5 , 0 , 503 ), 184 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 58 ), VLC_PACK( 5 , 0 , 26 ), VLC_PACK( 7 , 0 , 158 ), VLC_PACK( 7 , 0 , 126 ), 185 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 248 ), VLC_PACK( 7 , 0 , 30 ), VLC_PACK( 5 , 0 , 219 ), VLC_PACK( 5 , 0 , 218 ), 186 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 217 ), VLC_PACK( 5 , 0 , 245 ), VLC_PACK( 5 , 0 , 375 ), VLC_PACK( 5 , 0 , 124 ), 187 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 28 ), VLC_PACK( 5 , 0 , 155 ), VLC_PACK( 5 , 0 , 154 ), VLC_PACK( 5 , 0 , 122 ), 188 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 310 ), VLC_PACK( 5 , 0 , 27 ), VLC_PACK( 5 , 0 , 90 ), VLC_PACK( 5 , 0 , 121 ), 189 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 502 ), VLC_PACK( 5 , 0 , 371 ), VLC_PACK( 7 , 0 , 439 ), VLC_PACK( 7 , 0 , 438 ), 190 VLC_PACK( 0 , 0 , 6 ), VLC_PACK( 0 , 1 , 7 ), VLC_PACK( 0 , 0 , 27 ), VLC_PACK( 0 , 1 , 28 ), VLC_PACK( 0 , 1 , 48 ), VLC_PACK( 0 , 2 , 68 ), 191 VLC_PACK( 5 , 0 , 247 ), VLC_PACK( 5 , 0 , 246 ), VLC_PACK( 5 , 0 , 244 ), VLC_PACK( 7 , 0 , 221 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), 192 VLC_PACK( 5 , 0 , 187 ), VLC_PACK( 5 , 0 , 216 ), VLC_PACK( 5 , 0 , 186 ), VLC_PACK( 5 , 0 , 185 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), 193 VLC_PACK( 5 , 0 , 213 ), VLC_PACK( 5 , 0 , 237 ), VLC_PACK( 5 , 0 , 153 ), VLC_PACK( 5 , 0 , 184 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), 194 VLC_PACK( 5 , 0 , 89 ), VLC_PACK( 5 , 0 , 152 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 218 ), VLC_PACK( 5 , 0 , 428 ), VLC_PACK( 7 , 0 , 253 ), 195 VLC_PACK( 7 , 0 , 435 ), VLC_PACK( 7 , 0 , 432 ), VLC_PACK( 7 , 0 , 431 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 243 ), 196 VLC_PACK( 5 , 0 , 242 ), VLC_PACK( 5 , 0 , 215 ), VLC_PACK( 5 , 0 , 214 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 236 ), 197 VLC_PACK( 5 , 0 , 233 ), VLC_PACK( 5 , 0 , 183 ), VLC_PACK( 5 , 0 , 182 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 5 , 0 , 151 ), 198 VLC_PACK( 5 , 0 , 181 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 370 ), VLC_PACK( 7 , 0 , 188 ), VLC_PACK( 7 , 0 , 430 ), VLC_PACK( 7 , 0 , 429 ), 199 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 241 ), VLC_PACK( 7 , 0 , 426 ), VLC_PACK( 5 , 0 , 240 ), VLC_PACK( 5 , 0 , 239 ), 200 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 7 , 0 , 220 ), VLC_PACK( 7 , 0 , 157 ), VLC_PACK( 5 , 0 , 212 ), VLC_PACK( 5 , 0 , 235 ), 201 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 5 , 0 , 180 ), VLC_PACK( 5 , 0 , 211 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 405 ), 202 VLC_PACK( 7 , 0 , 406 ), VLC_PACK( 7 , 0 , 425 ), VLC_PACK( 7 , 0 , 424 ), VLC_PACK( 0 , 0 , 6 ), VLC_PACK( 0 , 1 , 7 ), VLC_PACK( 0 , 0 , 18 ), 203 VLC_PACK( 0 , 1 , 19 ), VLC_PACK( 0 , 1 , 27 ), VLC_PACK( 2 , 2 , 35 ), VLC_PACK( 5 , 0 , 238 ), VLC_PACK( 7 , 0 , 252 ), VLC_PACK( 7 , 0 , 125 ), 204 VLC_PACK( 7 , 0 , 418 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 234 ), VLC_PACK( 5 , 0 , 232 ), VLC_PACK( 5 , 0 , 210 ), 205 VLC_PACK( 5 , 0 , 231 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 404 ), VLC_PACK( 7 , 0 , 403 ), VLC_PACK( 7 , 0 , 189 ), 206 VLC_PACK( 7 , 0 , 421 ), VLC_PACK( 7 , 0 , 417 ), VLC_PACK( 7 , 0 , 416 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 7 , 0 , 251 ), 207 VLC_PACK( 7 , 0 , 93 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 229 ), VLC_PACK( 5 , 0 , 230 ), VLC_PACK( 7 , 0 , 415 ), VLC_PACK( 7 , 0 , 414 ), 208 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 7 , 0 , 61 ), VLC_PACK( 7 , 0 , 29 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 219 ), 209 VLC_PACK( 7 , 0 , 250 ), VLC_PACK( 2 , 2 , 4 ), VLC_PACK( 2 , 1 , 7 ), VLC_PACK( 7 , 0 , 374 ), VLC_PACK( 7 , 0 , 375 ), VLC_PACK( 3 , 2 , 0 ), 210 VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 7 , 0 , 409 ), VLC_PACK( 7 , 0 , 371 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 372 ), VLC_PACK( 7 , 0 , 373 ), 211 VLC_PACK( 0 , 1 , 4 ), VLC_PACK( 0 , 0 , 24 ), VLC_PACK( 7 , 0 , 94 ), VLC_PACK( 7 , 0 , 62 ), VLC_PACK( 0 , 1 , 4 ), VLC_PACK( 0 , 0 , 18 ), 212 VLC_PACK( 7 , 0 , 434 ), VLC_PACK( 7 , 0 , 433 ), VLC_PACK( 0 , 1 , 4 ), VLC_PACK( 0 , 0 , 12 ), VLC_PACK( 7 , 0 , 423 ), VLC_PACK( 7 , 0 , 422 ), 213 VLC_PACK( 1 , 1 , 4 ), VLC_PACK( 0 , 0 , 6 ), VLC_PACK( 7 , 0 , 413 ), VLC_PACK( 7 , 0 , 412 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 408 ), 214 VLC_PACK( 7 , 0 , 407 ), VLC_PACK( 7 , 0 , 411 ), VLC_PACK( 7 , 0 , 410 ), VLC_PACK( 7 , 0 , 420 ), VLC_PACK( 7 , 0 , 419 ), VLC_PACK( 7 , 0 , 428 ), 215 VLC_PACK( 7 , 0 , 427 ), VLC_PACK( 7 , 0 , 437 ), VLC_PACK( 7 , 0 , 436 ), VLC_PACK( 7 , 0 , 222 ), VLC_PACK( 7 , 0 , 190 ), VLC_PACK( 5 , 0 , 255 ), 216 VLC_PACK( 5 , 0 , 253 ), VLC_PACK( 0 , 0 , 14 ), VLC_PACK( 0 , 1 , 15 ), VLC_PACK( 0 , 0 , 44 ), VLC_PACK( 0 , 1 , 45 ), VLC_PACK( 0 , 1 , 74 ), 217 VLC_PACK( 0 , 2 , 103 ), VLC_PACK( 0 , 1 , 230 ), VLC_PACK( 0 , 0 , 256 ), VLC_PACK( 5 , 0 , 190 ), VLC_PACK( 7 , 0 , 254 ), VLC_PACK( 4 , 3 , 508 ), 218 VLC_PACK( 4 , 3 , 509 ), VLC_PACK( 4 , 3 , 444 ), VLC_PACK( 4 , 3 , 445 ), VLC_PACK( 5 , 0 , 252 ), VLC_PACK( 5 , 0 , 158 ), VLC_PACK( 5 , 0 , 221 ), 219 VLC_PACK( 5 , 0 , 62 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 251 ), VLC_PACK( 5 , 0 , 189 ), VLC_PACK( 5 , 0 , 250 ), 220 VLC_PACK( 5 , 0 , 249 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 248 ), VLC_PACK( 5 , 0 , 219 ), VLC_PACK( 5 , 0 , 247 ), 221 VLC_PACK( 5 , 0 , 246 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 245 ), VLC_PACK( 5 , 0 , 244 ), VLC_PACK( 5 , 0 , 243 ), 222 VLC_PACK( 5 , 0 , 216 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 242 ), VLC_PACK( 5 , 0 , 241 ), VLC_PACK( 5 , 0 , 238 ), 223 VLC_PACK( 5 , 0 , 237 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 236 ), VLC_PACK( 5 , 0 , 152 ), VLC_PACK( 5 , 0 , 126 ), 224 VLC_PACK( 5 , 0 , 94 ), VLC_PACK( 5 , 0 , 30 ), VLC_PACK( 5 , 0 , 439 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 438 ), 225 VLC_PACK( 5 , 0 , 437 ), VLC_PACK( 5 , 0 , 220 ), VLC_PACK( 5 , 0 , 157 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 188 ), 226 VLC_PACK( 5 , 0 , 93 ), VLC_PACK( 5 , 0 , 218 ), VLC_PACK( 5 , 0 , 156 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 217 ), 227 VLC_PACK( 5 , 0 , 187 ), VLC_PACK( 5 , 0 , 186 ), VLC_PACK( 5 , 0 , 155 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 240 ), 228 VLC_PACK( 5 , 0 , 239 ), VLC_PACK( 5 , 0 , 214 ), VLC_PACK( 5 , 0 , 213 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 122 ), 229 VLC_PACK( 5 , 0 , 27 ), VLC_PACK( 7 , 0 , 158 ), VLC_PACK( 7 , 0 , 126 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 436 ), 230 VLC_PACK( 7 , 0 , 30 ), VLC_PACK( 5 , 0 , 125 ), VLC_PACK( 5 , 0 , 435 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 432 ), 231 VLC_PACK( 5 , 0 , 431 ), VLC_PACK( 5 , 0 , 61 ), VLC_PACK( 5 , 0 , 29 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 124 ), 232 VLC_PACK( 5 , 0 , 92 ), VLC_PACK( 5 , 0 , 60 ), VLC_PACK( 5 , 0 , 28 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 215 ), 233 VLC_PACK( 5 , 0 , 154 ), VLC_PACK( 5 , 0 , 185 ), VLC_PACK( 5 , 0 , 184 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 366 ), 234 VLC_PACK( 5 , 0 , 410 ), VLC_PACK( 7 , 0 , 439 ), VLC_PACK( 7 , 0 , 438 ), VLC_PACK( 0 , 0 , 6 ), VLC_PACK( 0 , 1 , 7 ), VLC_PACK( 0 , 0 , 27 ), 235 VLC_PACK( 0 , 1 , 28 ), VLC_PACK( 0 , 1 , 48 ), VLC_PACK( 0 , 2 , 68 ), VLC_PACK( 5 , 0 , 434 ), VLC_PACK( 5 , 0 , 433 ), VLC_PACK( 5 , 0 , 430 ), 236 VLC_PACK( 7 , 0 , 221 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 375 ), VLC_PACK( 5 , 0 , 374 ), VLC_PACK( 5 , 0 , 373 ), 237 VLC_PACK( 5 , 0 , 426 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 372 ), VLC_PACK( 5 , 0 , 420 ), VLC_PACK( 5 , 0 , 123 ), 238 VLC_PACK( 5 , 0 , 91 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 5 , 0 , 153 ), VLC_PACK( 5 , 0 , 59 ), VLC_PACK( 3 , 1 , 0 ), 239 VLC_PACK( 7 , 0 , 218 ), VLC_PACK( 5 , 0 , 409 ), VLC_PACK( 7 , 0 , 253 ), VLC_PACK( 7 , 0 , 435 ), VLC_PACK( 7 , 0 , 432 ), VLC_PACK( 7 , 0 , 431 ), 240 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 429 ), VLC_PACK( 5 , 0 , 428 ), VLC_PACK( 5 , 0 , 425 ), VLC_PACK( 5 , 0 , 424 ), 241 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 419 ), VLC_PACK( 5 , 0 , 418 ), VLC_PACK( 5 , 0 , 311 ), VLC_PACK( 5 , 0 , 371 ), 242 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 5 , 0 , 310 ), VLC_PACK( 5 , 0 , 370 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 370 ), 243 VLC_PACK( 7 , 0 , 188 ), VLC_PACK( 7 , 0 , 430 ), VLC_PACK( 7 , 0 , 429 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 5 , 0 , 427 ), 244 VLC_PACK( 7 , 0 , 426 ), VLC_PACK( 5 , 0 , 423 ), VLC_PACK( 5 , 0 , 422 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), VLC_PACK( 7 , 0 , 220 ), 245 VLC_PACK( 7 , 0 , 157 ), VLC_PACK( 5 , 0 , 417 ), VLC_PACK( 5 , 0 , 416 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 5 , 0 , 369 ), 246 VLC_PACK( 5 , 0 , 368 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 405 ), VLC_PACK( 7 , 0 , 406 ), VLC_PACK( 7 , 0 , 425 ), VLC_PACK( 7 , 0 , 424 ), 247 VLC_PACK( 0 , 0 , 6 ), VLC_PACK( 0 , 1 , 7 ), VLC_PACK( 0 , 0 , 18 ), VLC_PACK( 0 , 1 , 19 ), VLC_PACK( 0 , 1 , 27 ), VLC_PACK( 2 , 2 , 35 ), 248 VLC_PACK( 5 , 0 , 421 ), VLC_PACK( 7 , 0 , 252 ), VLC_PACK( 7 , 0 , 125 ), VLC_PACK( 7 , 0 , 418 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 0 , 1 , 3 ), 249 VLC_PACK( 5 , 0 , 415 ), VLC_PACK( 5 , 0 , 414 ), VLC_PACK( 5 , 0 , 367 ), VLC_PACK( 5 , 0 , 413 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 3 , 1 , 0 ), 250 VLC_PACK( 7 , 0 , 404 ), VLC_PACK( 7 , 0 , 403 ), VLC_PACK( 7 , 0 , 189 ), VLC_PACK( 7 , 0 , 421 ), VLC_PACK( 7 , 0 , 417 ), VLC_PACK( 7 , 0 , 416 ), 251 VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 7 , 0 , 251 ), VLC_PACK( 7 , 0 , 93 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 5 , 0 , 411 ), 252 VLC_PACK( 5 , 0 , 412 ), VLC_PACK( 7 , 0 , 415 ), VLC_PACK( 7 , 0 , 414 ), VLC_PACK( 0 , 0 , 2 ), VLC_PACK( 2 , 1 , 3 ), VLC_PACK( 7 , 0 , 61 ), 253 VLC_PACK( 7 , 0 , 29 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 219 ), VLC_PACK( 7 , 0 , 250 ), VLC_PACK( 2 , 2 , 4 ), VLC_PACK( 2 , 1 , 7 ), 254 VLC_PACK( 7 , 0 , 374 ), VLC_PACK( 7 , 0 , 375 ), VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 3 , 2 , 0 ), VLC_PACK( 7 , 0 , 409 ), VLC_PACK( 7 , 0 , 371 ), 255 VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 372 ), VLC_PACK( 7 , 0 , 373 ), VLC_PACK( 0 , 1 , 4 ), VLC_PACK( 0 , 0 , 24 ), VLC_PACK( 7 , 0 , 94 ), 256 VLC_PACK( 7 , 0 , 62 ), VLC_PACK( 0 , 1 , 4 ), VLC_PACK( 0 , 0 , 18 ), VLC_PACK( 7 , 0 , 434 ), VLC_PACK( 7 , 0 , 433 ), VLC_PACK( 0 , 1 , 4 ), 257 VLC_PACK( 0 , 0 , 12 ), VLC_PACK( 7 , 0 , 423 ), VLC_PACK( 7 , 0 , 422 ), VLC_PACK( 1 , 1 , 4 ), VLC_PACK( 0 , 0 , 6 ), VLC_PACK( 7 , 0 , 413 ), 258 VLC_PACK( 7 , 0 , 412 ), VLC_PACK( 3 , 1 , 0 ), VLC_PACK( 7 , 0 , 408 ), VLC_PACK( 7 , 0 , 407 ), VLC_PACK( 7 , 0 , 411 ), VLC_PACK( 7 , 0 , 410 ), 259 VLC_PACK( 7 , 0 , 420 ), VLC_PACK( 7 , 0 , 419 ), VLC_PACK( 7 , 0 , 428 ), VLC_PACK( 7 , 0 , 427 ), VLC_PACK( 7 , 0 , 437 ), VLC_PACK( 7 , 0 , 436 ), 260 VLC_PACK( 7 , 0 , 222 ), VLC_PACK( 7 , 0 , 190 ), VLC_PACK( 4 , 0 , 0 ), VLC_PACK( 5 , 0 , 1 ), VLC_PACK( 5 , 0 , 2 ), VLC_PACK( 5 , 0 , 3 ), 261 VLC_PACK( 5 , 0 , 4 ), VLC_PACK( 5 , 0 , 5 ), VLC_PACK( 1 , 5 , 1 ), VLC_PACK( 5 , 0 , 6 ), VLC_PACK( 5 , 0 , 7 ), VLC_PACK( 5 , 0 , 8 ), 262 VLC_PACK( 5 , 0 , 9 ), VLC_PACK( 5 , 0 , 10 ), VLC_PACK( 5 , 0 , 11 ), VLC_PACK( 1 , 3 , 1 ), VLC_PACK( 5 , 0 , 12 ), VLC_PACK( 5 , 0 , 13 ), 263 VLC_PACK( 5 , 0 , 14 ), VLC_PACK( 5 , 0 , 15 ), VLC_PACK( 5 , 1 , 16 ), VLC_PACK( 5 , 0 , 1 ), VLC_PACK( 5 , 0 , 2 ), VLC_PACK( 5 , 0 , 3 ), 264 VLC_PACK( 5 , 0 , 4 ), VLC_PACK( 5 , 0 , 5 ), VLC_PACK( 5 , 0 , 6 ), VLC_PACK( 1 , 5 , 1 ), VLC_PACK( 5 , 0 , 7 ), VLC_PACK( 5 , 0 , 8 ), 265 VLC_PACK( 5 , 0 , 9 ), VLC_PACK( 5 , 0 , 10 ), VLC_PACK( 5 , 0 , 11 ), VLC_PACK( 5 , 0 , 12 ), VLC_PACK( 1 , 2 , 1 ), VLC_PACK( 5 , 0 , 13 ), 266 VLC_PACK( 5 , 0 , 14 ), VLC_PACK( 5 , 0 , 15 ), VLC_PACK( 5 , 1 , 16 ), VLC_PACK( 4 , 0 , 1 ), VLC_PACK( 4 , 1 , 2 ), VLC_PACK( 4 , 1 , 4 ), 267 VLC_PACK( 0 , 0 , 2 ), 268}; 269 270 271struct context_MPEG4_s { 272 object_context_p obj_context; /* back reference */ 273 274 uint32_t profile; 275 276 /* Picture parameters */ 277 VAPictureParameterBufferMPEG4 *pic_params; 278 object_surface_p forward_ref_surface; 279 object_surface_p backward_ref_surface; 280 281 uint32_t display_picture_width; /* in pixels */ 282 uint32_t display_picture_height; /* in pixels */ 283 284 uint32_t coded_picture_width; /* in pixels */ 285 uint32_t coded_picture_height; /* in pixels */ 286 287 uint32_t picture_width_mb; /* in macroblocks */ 288 uint32_t picture_height_mb; /* in macroblocks */ 289 uint32_t size_mb; /* in macroblocks */ 290 291 uint32_t FEControl; 292 uint32_t FE_SPS0; 293 uint32_t FE_VOP_PPS0; 294 uint32_t FE_VOP_SPS0; 295 uint32_t FE_PICSH_PPS0; 296 297 uint32_t BE_SPS0; 298 uint32_t BE_SPS1; 299 uint32_t BE_VOP_PPS0; 300 uint32_t BE_VOP_SPS0; 301 uint32_t BE_VOP_SPS1; 302 uint32_t BE_PICSH_PPS0; 303 304 /* IQ Matrix */ 305 uint32_t qmatrix_data[MAX_QUANT_TABLES][16]; 306 int load_non_intra_quant_mat; 307 int load_intra_quant_mat; 308 309 /* Split buffers */ 310 int split_buffer_pending; 311 312 /* List of VASliceParameterBuffers */ 313 object_buffer_p *slice_param_list; 314 int slice_param_list_size; 315 int slice_param_list_idx; 316 317 /* VLC packed data */ 318 struct psb_buffer_s vlc_packed_table; 319 320 /* FE state buffer */ 321 struct psb_buffer_s FE_state_buffer; 322 323 /* CoLocated buffers */ 324 struct psb_buffer_s *colocated_buffers; 325 int colocated_buffers_size; 326 int colocated_buffers_idx; 327 328 uint32_t *p_slice_params; /* pointer to ui32SliceParams in CMD_HEADER */ 329}; 330 331typedef struct context_MPEG4_s *context_MPEG4_p; 332 333#define INIT_CONTEXT_MPEG4 context_MPEG4_p ctx = (context_MPEG4_p) obj_context->format_data; 334 335#define SURFACE(id) ((object_surface_p) object_heap_lookup( &ctx->obj_context->driver_data->surface_heap, id )) 336 337static const char *psb__debug_picture_coding_str(unsigned char vop_coding_type) 338{ 339 switch (vop_coding_type) 340 { 341 case PICTURE_CODING_I: return ("PICTURE_CODING_I"); 342 case PICTURE_CODING_P: return ("PICTURE_CODING_P"); 343 case PICTURE_CODING_B: return ("PICTURE_CODING_B"); 344 case PICTURE_CODING_S: return ("PICTURE_CODING_S"); 345 } 346 return ("UNKNOWN!!!"); 347} 348 349 350static void pnw_MPEG4_QueryConfigAttributes( 351 VAProfile profile, 352 VAEntrypoint entrypoint, 353 VAConfigAttrib *attrib_list, 354 int num_attribs ) 355{ 356 /* No MPEG4 specific attributes */ 357} 358 359static VAStatus pnw_MPEG4_ValidateConfig( 360 object_config_p obj_config ) 361{ 362 int i; 363 /* Check all attributes */ 364 for(i = 0; i < obj_config->attrib_count; i++) 365 { 366 switch (obj_config->attrib_list[i].type) 367 { 368 case VAConfigAttribRTFormat: 369 /* Ignore */ 370 break; 371 372 default: 373 return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; 374 } 375 } 376 377 return VA_STATUS_SUCCESS; 378} 379 380static VAStatus psb__MPEG4_check_legal_picture(object_context_p obj_context, object_config_p obj_config) 381{ 382 VAStatus vaStatus = VA_STATUS_SUCCESS; 383 384 if (NULL == obj_context) 385 { 386 vaStatus = VA_STATUS_ERROR_INVALID_CONTEXT; 387 DEBUG_FAILURE; 388 return vaStatus; 389 } 390 391 if (NULL == obj_config) 392 { 393 vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; 394 DEBUG_FAILURE; 395 return vaStatus; 396 } 397 398 /* MSVDX decode capability for MPEG4: 399 * SP@L3 400 * ASP@L5 401 * 402 * Refer to the "MSVDX MPEG4 decode capability" table of "Poulsbo Media Software Overview". 403 */ 404 switch (obj_config->profile) 405 { 406 case VAProfileMPEG4Simple: 407 case VAProfileMPEG4AdvancedSimple: 408 if ((obj_context->picture_width <= 0) || (obj_context->picture_height <= 0)) 409 { 410 vaStatus = VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; 411 } 412 break; 413 414 default: 415 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; 416 break; 417 } 418 419 return vaStatus; 420} 421 422static void pnw_MPEG4_DestroyContext(object_context_p obj_context); 423 424static VAStatus pnw_MPEG4_CreateContext( 425 object_context_p obj_context, 426 object_config_p obj_config ) 427{ 428 VAStatus vaStatus = VA_STATUS_SUCCESS; 429 context_MPEG4_p ctx; 430 /* Validate flag */ 431 /* Validate picture dimensions */ 432 vaStatus = psb__MPEG4_check_legal_picture(obj_context, obj_config); 433 if (VA_STATUS_SUCCESS != vaStatus) 434 { 435 DEBUG_FAILURE; 436 return vaStatus; 437 } 438 439 ctx = (context_MPEG4_p) calloc(1, sizeof(struct context_MPEG4_s)); 440 if (NULL == ctx) 441 { 442 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 443 DEBUG_FAILURE; 444 return vaStatus; 445 } 446 obj_context->format_data = (void*) ctx; 447 ctx->obj_context = obj_context; 448 ctx->pic_params = NULL; 449 ctx->load_non_intra_quant_mat = FALSE; 450 ctx->load_intra_quant_mat = FALSE; 451 452 ctx->split_buffer_pending = FALSE; 453 454 ctx->slice_param_list_size = 8; 455 ctx->slice_param_list = (object_buffer_p*) calloc(1, sizeof(object_buffer_p)*ctx->slice_param_list_size); 456 ctx->slice_param_list_idx = 0; 457 458 if (NULL == ctx->slice_param_list) 459 { 460 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 461 DEBUG_FAILURE; 462 } 463 464 ctx->colocated_buffers_size = obj_context->num_render_targets; 465 ctx->colocated_buffers_idx = 0; 466 ctx->colocated_buffers = (psb_buffer_p) calloc(1, sizeof(struct psb_buffer_s)*ctx->colocated_buffers_size); 467 if (NULL == ctx->colocated_buffers) 468 { 469 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 470 DEBUG_FAILURE; 471 } 472 473 switch (obj_config->profile ) 474 { 475 case VAProfileMPEG4Simple: 476 psb__information_message("MPEG4_PROFILE_SIMPLE\n"); 477 ctx->profile = MPEG4_PROFILE_SIMPLE; 478 break; 479 480 case VAProfileMPEG4AdvancedSimple: 481 psb__information_message("MPEG4_PROFILE_ASP\n"); 482 ctx->profile = MPEG4_PROFILE_ASP; 483 break; 484 485 default: 486 ASSERT(0 == 1); 487 vaStatus = VA_STATUS_ERROR_UNKNOWN; 488 } 489 490 // TODO 491 492 if (vaStatus == VA_STATUS_SUCCESS) 493 { 494 vaStatus = psb_buffer_create( obj_context->driver_data, 495 FE_STATE_BUFFER_SIZE, 496 psb_bt_vpu_only, 497 &ctx->FE_state_buffer ); 498 DEBUG_FAILURE; 499 } 500 501 if (vaStatus == VA_STATUS_SUCCESS) 502 { 503 vaStatus = psb_buffer_create( obj_context->driver_data, 504 sizeof(gaui16mpeg4VlcTableDataPacked), 505 psb_bt_cpu_vpu, 506 &ctx->vlc_packed_table ); 507 DEBUG_FAILURE; 508 } 509 if (vaStatus == VA_STATUS_SUCCESS) 510 { 511 void *vlc_packed_data_address; 512 if (0 == psb_buffer_map( &ctx->vlc_packed_table, &vlc_packed_data_address )) 513 { 514 memcpy( vlc_packed_data_address, gaui16mpeg4VlcTableDataPacked, sizeof(gaui16mpeg4VlcTableDataPacked)); 515 psb_buffer_unmap( &ctx->vlc_packed_table ); 516 } 517 else 518 { 519 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 520 DEBUG_FAILURE; 521 } 522 } 523 524 if (vaStatus != VA_STATUS_SUCCESS) 525 { 526 pnw_MPEG4_DestroyContext(obj_context); 527 } 528 529 return vaStatus; 530} 531 532static void pnw_MPEG4_DestroyContext( 533 object_context_p obj_context) 534{ 535 INIT_CONTEXT_MPEG4 536 int i; 537 538 psb_buffer_destroy( &ctx->vlc_packed_table ); 539 psb_buffer_destroy( &ctx->FE_state_buffer ); 540 541 if (ctx->pic_params) 542 { 543 free(ctx->pic_params); 544 ctx->pic_params = NULL; 545 } 546 547 if (ctx->colocated_buffers) 548 { 549 for (i = 0; i < ctx->colocated_buffers_idx; ++i) 550 psb_buffer_destroy(&(ctx->colocated_buffers[i])); 551 552 free(ctx->colocated_buffers); 553 ctx->colocated_buffers = NULL; 554 } 555 if (ctx->slice_param_list) 556 { 557 free(ctx->slice_param_list); 558 ctx->slice_param_list = NULL; 559 } 560 561 free(obj_context->format_data); 562 obj_context->format_data = NULL; 563} 564 565static VAStatus psb__MPEG4_allocate_colocated_buffer(context_MPEG4_p ctx, object_surface_p obj_surface, uint32_t size){ 566 psb_surface_p surface = obj_surface->psb_surface; 567 568 if (!GET_SURFACE_INFO_colocated_index(surface)) 569 { 570 VAStatus vaStatus; 571 psb_buffer_p buf; 572 int index = ctx->colocated_buffers_idx; 573 if (index >= ctx->colocated_buffers_size) 574 { 575 return VA_STATUS_ERROR_UNKNOWN; 576 } 577 buf = &(ctx->colocated_buffers[index]); 578 vaStatus = psb_buffer_create( ctx->obj_context->driver_data, size, psb_bt_vpu_only, buf); 579 if (VA_STATUS_SUCCESS != vaStatus) 580 { 581 return vaStatus; 582 } 583 ctx->colocated_buffers_idx++; 584 SET_SURFACE_INFO_colocated_index(surface, index+1); /* 0 means unset, index is offset by 1 */ 585 } 586 return VA_STATUS_SUCCESS; 587} 588 589static psb_buffer_p psb__MPEG4_lookup_colocated_buffer(context_MPEG4_p ctx, psb_surface_p surface) 590{ 591 int index = GET_SURFACE_INFO_colocated_index(surface); 592 if (!index) 593 { 594 return NULL; 595 } 596 return &(ctx->colocated_buffers[index-1]); /* 0 means unset, index is offset by 1 */ 597} 598 599static VAStatus psb__MPEG4_process_picture_param(context_MPEG4_p ctx, object_buffer_p obj_buffer) 600{ 601 VAStatus vaStatus; 602 ASSERT(obj_buffer->type == VAPictureParameterBufferType); 603 ASSERT(obj_buffer->num_elements == 1); 604 ASSERT(obj_buffer->size == sizeof(VAPictureParameterBufferMPEG4)); 605 606 if ((obj_buffer->num_elements != 1) || 607 (obj_buffer->size != sizeof(VAPictureParameterBufferMPEG4))) 608 { 609 return VA_STATUS_ERROR_UNKNOWN; 610 } 611 612 /* Transfer ownership of VAPictureParameterBufferMPEG4 data */ 613 if (ctx->pic_params) 614 { 615 free(ctx->pic_params); 616 } 617 ctx->pic_params = (VAPictureParameterBufferMPEG4 *) obj_buffer->buffer_data; 618 obj_buffer->buffer_data = NULL; 619 obj_buffer->size = 0; 620 621 622 /* Lookup surfaces for backward/forward references */ 623 /* Lookup surfaces for backward/forward references */ 624 switch (ctx->pic_params->vop_fields.bits.vop_coding_type) 625 { 626 case PICTURE_CODING_I: 627 ctx->forward_ref_surface = NULL; 628 ctx->backward_ref_surface = NULL; 629psb__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 ); 630psb__information_message("Forward ref = NULL\n"); 631psb__information_message("Backward ref = NULL\n"); 632 break; 633 634 case PICTURE_CODING_P: 635 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 636 ctx->backward_ref_surface = NULL; 637 if (NULL == ctx->forward_ref_surface) 638 { 639 return VA_STATUS_ERROR_INVALID_SURFACE; 640 } 641psb__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 ); 642psb__information_message("Forward ref = %08x (%08x)\n", ctx->forward_ref_surface->psb_surface, ctx->pic_params->forward_reference_picture); 643psb__information_message("Backward ref = NULL\n"); 644 break; 645 646 case PICTURE_CODING_B: 647 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 648 ctx->backward_ref_surface = SURFACE(ctx->pic_params->backward_reference_picture); 649 if ((NULL == ctx->forward_ref_surface) || 650 (NULL == ctx->backward_ref_surface)) 651 { 652 return VA_STATUS_ERROR_INVALID_SURFACE; 653 } 654psb__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 ); 655psb__information_message("Forward ref = %08x (%08x)\n", ctx->forward_ref_surface->psb_surface, ctx->pic_params->forward_reference_picture); 656psb__information_message("Backward ref = %08x (%08x)\n", ctx->backward_ref_surface->psb_surface, ctx->pic_params->backward_reference_picture); 657 break; 658 659 case PICTURE_CODING_S: 660 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 661 ctx->backward_ref_surface = SURFACE(ctx->pic_params->backward_reference_picture); 662psb__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 ); 663psb__information_message("Forward ref = %08x (%08x)\n", ctx->forward_ref_surface ? ctx->forward_ref_surface->psb_surface : 0, ctx->pic_params->forward_reference_picture); 664psb__information_message("Backward ref = %08x (%08x)\n", ctx->backward_ref_surface ? ctx->backward_ref_surface->psb_surface : 0, ctx->pic_params->backward_reference_picture); 665 break; 666 667 default: 668 psb__error_message("Unhandled MPEG4 vop_coding_type '%d'\n", ctx->pic_params->vop_fields.bits.vop_coding_type); 669 return VA_STATUS_ERROR_UNKNOWN; 670 } 671 672 if (NULL == ctx->forward_ref_surface) 673 { 674 /* for mmu fault protection */ 675 ctx->forward_ref_surface = ctx->obj_context->current_render_target; 676 } 677 if (NULL == ctx->backward_ref_surface) 678 { 679 /* for mmu fault protection */ 680 ctx->backward_ref_surface = ctx->obj_context->current_render_target; 681 } 682 683 ctx->display_picture_width = ctx->pic_params->vop_width; 684 ctx->display_picture_height = ctx->pic_params->vop_height; 685 ctx->picture_width_mb = PIXELS_TO_MB(ctx->display_picture_width); 686 ctx->picture_height_mb = PIXELS_TO_MB(ctx->display_picture_height); 687 ctx->coded_picture_width = ctx->picture_width_mb * 16; 688 ctx->coded_picture_height = ctx->picture_height_mb * 16; 689 ctx->size_mb = ctx->picture_width_mb * ctx->picture_height_mb; 690 691 uint32_t mbInPic= ctx->picture_width_mb * ctx->picture_height_mb; 692 693 mbInPic += 4; 694 695 uint32_t colocated_size = ((mbInPic * 200) + 0xfff) & ~0xfff; 696 697 vaStatus = psb__MPEG4_allocate_colocated_buffer(ctx, ctx->obj_context->current_render_target, colocated_size); 698 if (VA_STATUS_SUCCESS != vaStatus) 699 { 700 DEBUG_FAILURE; 701 return vaStatus; 702 } 703 vaStatus = psb__MPEG4_allocate_colocated_buffer(ctx, ctx->forward_ref_surface, colocated_size); 704 if (VA_STATUS_SUCCESS != vaStatus) 705 { 706 DEBUG_FAILURE; 707 return vaStatus; 708 } 709 710 ctx->FEControl = 0; 711 REGIO_WRITE_FIELD_LITE (ctx->FEControl , 712 MSVDX_VEC, 713 CR_VEC_ENTDEC_FE_CONTROL, 714 ENTDEC_FE_PROFILE, 715 ctx->profile); /* MPEG4 SP / ASP profile */ 716 717 REGIO_WRITE_FIELD_LITE (ctx->FEControl , 718 MSVDX_VEC, 719 CR_VEC_ENTDEC_FE_CONTROL, 720 ENTDEC_FE_MODE, 721 4); /* Set MPEG4 mode */ 722 723 /* FE_SPS0 */ 724 ctx->FE_SPS0 = 0; 725 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 ); 726 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); 727 REGIO_WRITE_FIELD_LITE (ctx->FE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0, FE_PROFILE, ctx->profile ); 728 729 /* FE_VOP_SPS0 */ 730 ctx->FE_VOP_SPS0 = 0; 731 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 ); 732 REGIO_WRITE_FIELD_LITE (ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, QUANT_PRECISION, ctx->pic_params->quant_precision); 733 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); 734 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) ); 735 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); 736 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); 737 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); 738 739 if (ctx->pic_params->vol_fields.bits.short_video_header) 740 { 741 /* FE_PICSH_PPS0 */ 742 ctx->FE_PICSH_PPS0 = 0; 743 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); 744 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); 745 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); 746 } 747 748 /* FE_VOP_PPS0 */ 749 ctx->FE_VOP_PPS0 = 0; 750 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); 751 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); 752 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); 753 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); 754 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); 755 756 /* BE_SPS0 */ 757 /* Common for VOPs and pictures with short header */ 758 ctx->BE_SPS0 = 0; 759 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); 760 REGIO_WRITE_FIELD_LITE( ctx->BE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SPS0, BE_PROFILE, ctx->profile); 761 762 /* BE_SPS1 */ 763 /* Common for VOPs and pictures with short header */ 764 ctx->BE_SPS1 = 0; 765 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); 766 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); 767 768 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) 769 { 770 /* BE_VOP_SPS0 */ 771 ctx->BE_VOP_SPS0 = 0; 772 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); 773 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); 774 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); 775 776 /* BE_VOP_SPS1 */ 777 ctx->BE_VOP_SPS1 = 0; 778 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); 779 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); 780 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)); 781 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); 782 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); 783 784 /* BE_VOP_PPS0 */ 785 ctx->BE_VOP_PPS0 = 0; 786 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); 787 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); 788 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); 789 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); 790 REGIO_WRITE_FIELD_LITE (ctx->BE_VOP_PPS0, 791 MSVDX_VEC_MPEG4, 792 CR_VEC_MPEG4_BE_VOP_PPS0, 793 ROUNDING_TYPE, 794 ((PICTURE_CODING_I == ctx->pic_params->vop_fields.bits.vop_coding_type || 795 PICTURE_CODING_B == ctx->pic_params->vop_fields.bits.vop_coding_type) ? 796 0 : ctx->pic_params->vop_fields.bits.vop_rounding_type)); 797 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); 798 } 799 else 800 { 801 /* BE_VOP_PPS0 */ 802 ctx->BE_VOP_PPS0 = 0; 803 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 804 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); 805 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); 806 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 807 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); 808 809 /* BE_PICSH_PPS0 */ 810 ctx->BE_PICSH_PPS0 = 0; 811 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); 812 } 813 814 return VA_STATUS_SUCCESS; 815} 816 817static void psb__MPEG4_convert_iq_matrix(uint32_t *dest32, unsigned char *src) 818{ 819 int i; 820 int *idx = scan0; 821 uint8_t *dest8 = (uint8_t*) dest32; 822 823 for (i = 0; i < 64; i++) 824 { 825 *dest8++ = src[*idx++]; 826 } 827} 828 829static VAStatus psb__MPEG4_process_iq_matrix(context_MPEG4_p ctx, object_buffer_p obj_buffer) 830{ 831 VAIQMatrixBufferMPEG4 *iq_matrix = (VAIQMatrixBufferMPEG4 *) obj_buffer->buffer_data; 832 ASSERT(obj_buffer->type == VAIQMatrixBufferType); 833 ASSERT(obj_buffer->num_elements == 1); 834 ASSERT(obj_buffer->size == sizeof(VAIQMatrixBufferMPEG4)); 835 836 if ((obj_buffer->num_elements != 1) || 837 (obj_buffer->size != sizeof(VAIQMatrixBufferMPEG4))) 838 { 839 return VA_STATUS_ERROR_UNKNOWN; 840 } 841 842 if (iq_matrix->load_non_intra_quant_mat) 843 { 844 psb__MPEG4_convert_iq_matrix( ctx->qmatrix_data[NONINTRA_LUMA_Q], iq_matrix->non_intra_quant_mat ); 845 } 846 if (iq_matrix->load_intra_quant_mat) 847 { 848 psb__MPEG4_convert_iq_matrix( ctx->qmatrix_data[INTRA_LUMA_Q], iq_matrix->intra_quant_mat ); 849 } 850 ctx->load_non_intra_quant_mat = iq_matrix->load_non_intra_quant_mat; 851 ctx->load_intra_quant_mat = iq_matrix->load_intra_quant_mat; 852 853 return VA_STATUS_SUCCESS; 854} 855 856static void psb__MPEG4_write_qmatrices(context_MPEG4_p ctx) 857{ 858 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 859 int i; 860 861 // TODO: Verify that this is indeed the same as MPEG2 862 863 /* Since we only decode 4:2:0 We only need to the Intra tables. 864 Chroma quant tables are only used in Mpeg 4:2:2 and 4:4:4. 865 The hardware wants non-intra followed by intra */ 866 psb_cmdbuf_rendec_start_block( cmdbuf ); 867 psb_cmdbuf_rendec_start_chunk( cmdbuf, REG_MSVDX_VEC_IQRAM_OFFSET ); 868 869 /* todo : optimisation here is to only load the need table */ 870 if (ctx->load_non_intra_quant_mat) 871 { 872 /* NONINTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + 0 */ 873 for (i = 0; i < 16; i++) 874 { 875 psb_cmdbuf_rendec_write( cmdbuf, ctx->qmatrix_data[NONINTRA_LUMA_Q][i] ); 876 } 877 } 878 else 879 { 880 for (i = 0; i < 16; i++) 881 { 882 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 883 } 884 } 885 if (ctx->load_intra_quant_mat) 886 { 887 /* INTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + (16*4) */ 888 for (i = 0; i < 16; i++) 889 { 890 psb_cmdbuf_rendec_write( cmdbuf, ctx->qmatrix_data[INTRA_LUMA_Q][i] ); 891 } 892 } 893 else 894 { 895 for (i = 0; i < 16; i++) 896 { 897 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 898 } 899 } 900 901 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 902 psb_cmdbuf_rendec_end_block( cmdbuf ); 903} 904 905 906/* 907 * Adds a VASliceParameterBuffer to the list of slice params 908 */ 909static VAStatus psb__MPEG4_add_slice_param(context_MPEG4_p ctx, object_buffer_p obj_buffer) 910{ 911 ASSERT(obj_buffer->type == VASliceParameterBufferType); 912 if (ctx->slice_param_list_idx >= ctx->slice_param_list_size) 913 { 914 void *new_list; 915 ctx->slice_param_list_size += 8; 916 new_list = realloc(ctx->slice_param_list, 917 sizeof(object_buffer_p)*ctx->slice_param_list_size); 918 if (NULL == new_list) 919 { 920 return VA_STATUS_ERROR_ALLOCATION_FAILED; 921 } 922 ctx->slice_param_list = (object_buffer_p*) new_list; 923 } 924 ctx->slice_param_list[ctx->slice_param_list_idx] = obj_buffer; 925 ctx->slice_param_list_idx++; 926 return VA_STATUS_SUCCESS; 927} 928 929/* Precalculated values */ 930#define ADDR0 (0x00005800) 931#define ADDR1 (0x0001f828) 932#define ADDR2 (0x0002b854) 933#define ADDR3 (0x0002f85c) 934#define ADDR4 (0x0004d089) 935#define ADDR5 (0x0008f0aa) 936#define ADDR6 (0x00149988) 937#define ADDR7 (0x001d8b9e) 938#define ADDR8 (0x000003c3) 939#define WIDTH0 (0x09a596ed) 940#define WIDTH1 (0x0006d6db) 941#define OPCODE0 (0x50009a0a) 942#define OPCODE1 (0x00000001) 943 944static void psb__MPEG4_write_VLC_tables(context_MPEG4_p ctx) 945{ 946 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 947 948 /* Write the vec registers with the index data for each of the tables and then write */ 949 /* the actual table data. */ 950 psb_cmdbuf_reg_start_block( cmdbuf ); 951 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR0), ADDR0 ); 952 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR1), ADDR1 ); 953 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR2), ADDR2 ); 954 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR3), ADDR3 ); 955 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR4), ADDR4 ); 956 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR5), ADDR5 ); 957 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR6), ADDR6 ); 958 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR7), ADDR7 ); 959 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR8), ADDR8 ); 960 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_WIDTH0), WIDTH0 ); 961 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_WIDTH1), WIDTH1 ); 962 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_OPCODE0), OPCODE0 ); 963 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_OPCODE1), OPCODE1 ); 964 psb_cmdbuf_reg_end_block( cmdbuf ); 965 966 /* VLC Table */ 967 /* Write a LLDMA Cmd to transfer VLD Table data */ 968 psb_cmdbuf_lldma_write_cmdbuf( cmdbuf, &ctx->vlc_packed_table, 0, 969 sizeof(gaui16mpeg4VlcTableDataPacked), 970 0, LLDMA_TYPE_VLC_TABLE ); 971} 972 973 974static void psb__MPEG4_write_kick(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 975{ 976 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 977 978 (void) slice_param; /* Unused for now */ 979 980 *cmdbuf->cmd_idx++ = CMD_COMPLETION; 981} 982 983static void psb__MPEG4_set_picture_params(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 984{ 985 uint32_t cmd; 986 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 987 psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 988 989 psb_buffer_p colocated_target_buffer = psb__MPEG4_lookup_colocated_buffer(ctx, target_surface); 990 psb_buffer_p colocated_ref_buffer = psb__MPEG4_lookup_colocated_buffer(ctx, ctx->forward_ref_surface->psb_surface); 991 ASSERT(colocated_target_buffer); 992 ASSERT(colocated_ref_buffer); 993 994 psb_cmdbuf_rendec_start_block( cmdbuf ); 995 996 /* BE_PARAM_BASE_ADDR */ 997 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_PARAM_BASE_ADDR) ); 998 if (colocated_target_buffer) 999 { 1000 psb_cmdbuf_rendec_write_address( cmdbuf, colocated_target_buffer, 0); 1001 } 1002 else 1003 { 1004 /* This is an error */ 1005 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1006 } 1007 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1008 1009 /* PARAM_BASE_ADDRESS */ 1010 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_COLPARAM_BASE_ADDR) ); 1011 if (colocated_ref_buffer) 1012 { 1013 psb_cmdbuf_rendec_write_address( cmdbuf, colocated_ref_buffer, 0 ); 1014 } 1015 else 1016 { 1017 /* This is an error */ 1018 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1019 } 1020 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1021 1022 /* Send VDMC and VDEB commands */ 1023 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, DISPLAY_PICTURE_SIZE) ); 1024 1025 /* Display picture size cmd */ 1026 cmd = 0; 1027 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_HEIGHT, ctx->display_picture_height - 1); 1028 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_WIDTH, ctx->display_picture_width - 1); 1029 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1030 1031 /* Coded picture size cmd */ 1032 cmd = 0; 1033 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_HEIGHT, ctx->coded_picture_height - 1); 1034 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_WIDTH, ctx->coded_picture_width - 1); 1035 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1036 1037 /* Operating mode cmd */ 1038 cmd = 0; 1039 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CHROMA_INTERLEAVED, 0); /* 0 = CbCr, 1 = CrCb */ 1040 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, ROW_STRIDE, ctx->obj_context->current_render_target->psb_surface->stride_mode); 1041 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_PROFILE, ctx->profile);/* MPEG4 SP / ASP profile */ 1042 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_MODE, 4); /* MPEG4 */ 1043 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, ASYNC_MODE, 1); /* VDMC only */ 1044 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CHROMA_FORMAT, 1); 1045 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, INTERLACED, ctx->pic_params->vol_fields.bits.interlaced); 1046 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1047 ctx->obj_context->operating_mode = cmd; 1048 1049 psb__information_message(" vop_coding_type = %s\n", psb__debug_picture_coding_str(ctx->pic_params->vop_fields.bits.vop_coding_type)); 1050 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)); 1051 1052 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1053 psb_cmdbuf_rendec_write_address( cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs); 1054 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1055 psb_cmdbuf_rendec_write_address( cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 1056 1057 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1058 1059 /* Reference pictures base addresses */ 1060 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES) ); 1061 1062//psb__information_message("Target surface = %08x\n", target_surface); 1063//psb__information_message("Forward ref = %08x\n", ctx->forward_ref_surface->psb_surface); 1064//psb__information_message("Backward ref = %08x\n", ctx->backward_ref_surface->psb_surface); 1065 1066 /* forward reference picture */ 1067 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1068 psb_cmdbuf_rendec_write_address( cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface->buf.buffer_ofs); 1069 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1070 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); 1071 1072 /* backward reference picture */ 1073 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1074 psb_cmdbuf_rendec_write_address( cmdbuf, &ctx->backward_ref_surface->psb_surface->buf, ctx->backward_ref_surface->psb_surface->buf.buffer_ofs); 1075 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1076 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); 1077 1078 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1079 psb_cmdbuf_rendec_end_block( cmdbuf ); 1080} 1081 1082static void psb__MPEG4_set_backend_registers(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 1083{ 1084 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1085 uint32_t cmd; 1086 unsigned short width_mb = PIXELS_TO_MB(ctx->pic_params->vop_width); 1087 1088 psb_cmdbuf_rendec_start_block( cmdbuf ); 1089 1090 /* Write Back-End EntDec registers */ 1091 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_SPS0) ); 1092 /* BE_SPS0 */ 1093 /* Common for VOPs and pictures with short header */ 1094 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_SPS0 ); 1095 /* BE_SPS1 */ 1096 /* Common for VOPs and pictures with short header */ 1097 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_SPS1 ); 1098 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1099 1100 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_VOP_SPS0) ); 1101 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) 1102 { 1103 /* BE_VOP_SPS0 */ 1104 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_SPS0 ); 1105 /* BE_VOP_SPS1 */ 1106 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_SPS1 ); 1107 /* BE_VOP_PPS0 */ 1108 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_PPS0 ); 1109 } 1110 else /* Short-header mode */ 1111 { 1112 /* BE_VOP_SPS0 */ 1113 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1114 /* BE_VOP_SPS1 */ 1115 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1116 /* BE_VOP_PPS0 */ 1117 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_PPS0 ); 1118 /* BE_PICSH_PPS0 */ 1119 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_PICSH_PPS0 ); 1120 } 1121 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1122 1123 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) { 1124 if ((GMC == ctx->pic_params->vol_fields.bits.sprite_enable) && 1125 (PICTURE_CODING_S == ctx->pic_params->vop_fields.bits.vop_coding_type)) 1126 { 1127 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_GMC_X) ); 1128 1129 /* TODO: GMC Motion Vectors */ 1130 /* It is still needed to specify the precision of the motion vectors (should they be in */ 1131 /* half-sample, quarter-sample...?) and how much processing is done on the firmware on */ 1132 /* the values of the warping points. */ 1133 1134 // TODO: Which index to use? 1135 int sprite_index = (ctx->pic_params->sprite_trajectory_du[0] || ctx->pic_params->sprite_trajectory_dv[0]) ? 0 : 1; 1136 1137 /* BE_GMC_X */ 1138 cmd = 0; 1139 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); 1140 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1141 1142 /* BE_GMC_Y */ 1143 cmd = 0; 1144 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); 1145 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1146 1147 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1148 } 1149 } 1150 1151 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_SLICE0) ); 1152 1153 /* BE_SLICE0 */ 1154 cmd = 0; 1155 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); 1156 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); 1157 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1158 1159 /* CR_VEC_MPEG4_BE_VOP_TR */ 1160 cmd = 0; 1161 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_TRB, BE_TRB, ctx->pic_params->TRB); 1162 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1163 1164 cmd = 0; 1165 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_TRD, BE_TRD, ctx->pic_params->TRD); 1166 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1167 1168 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1169 1170 1171 /* Send Slice Data for every slice */ 1172 /* MUST be the last slice sent */ 1173 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, SLICE_PARAMS) ); 1174 1175 /* Slice params command */ 1176 cmd = 0; 1177 REGIO_WRITE_FIELD_LITE (cmd, 1178 MSVDX_CMDS, 1179 SLICE_PARAMS, 1180 RND_CTL_BIT, 1181 ((PICTURE_CODING_I == ctx->pic_params->vop_fields.bits.vop_coding_type || 1182 PICTURE_CODING_B == ctx->pic_params->vop_fields.bits.vop_coding_type) ? 1183 0 : ctx->pic_params->vop_fields.bits.vop_rounding_type)); 1184 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, MODE_CONFIG, ctx->pic_params->vol_fields.bits.sprite_warping_accuracy); 1185 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, SUBPEL_FILTER_MODE, ctx->pic_params->vol_fields.bits.quarter_sample); 1186 /* SP and ASP profiles don't support field coding in different VOPs */ 1187 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_FIELD_TYPE, 2); 1188 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_CODE_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1189 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1190 1191 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1192 1193 *ctx->p_slice_params = cmd; 1194 1195 /* CHUNK: Entdec back-end profile and level */ 1196 psb_cmdbuf_rendec_start_chunk( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL) ); 1197 1198 cmd = 0; 1199 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL, ENTDEC_BE_PROFILE, ctx->profile); /* MPEG4 SP / ASP profile*/ 1200 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL, ENTDEC_BE_MODE, 4); /* 4 - MPEG4 */ 1201 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1202 1203 psb_cmdbuf_rendec_end_chunk( cmdbuf ); 1204 psb_cmdbuf_rendec_end_block( cmdbuf ); 1205 1206 /* Send IQ matrices to Rendec */ 1207 psb__MPEG4_write_qmatrices(ctx); 1208} 1209 1210static void psb__MPEG4_set_frontend_registers(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 1211{ 1212 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1213 uint32_t FE_slice0; 1214 unsigned short width_mb = PIXELS_TO_MB(ctx->pic_params->vop_width); 1215 1216 psb_cmdbuf_reg_start_block( cmdbuf ); 1217 1218 /* FE_SLICE0 */ 1219 FE_slice0 = 0; 1220 REGIO_WRITE_FIELD_LITE (FE_slice0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0, FE_VOP_QUANT, slice_param->quant_scale); 1221 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); 1222 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); 1223 1224 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0) , FE_slice0 ); 1225 1226 /* Entdec Front-End controls*/ 1227 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_ENTDEC_FE_CONTROL) , ctx->FEControl ); 1228 1229 /* FE_SPS0 */ 1230 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0) , ctx->FE_SPS0 ); 1231 1232 /* FE_VOP_SPS0 */ 1233 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0) , ctx->FE_VOP_SPS0 ); 1234 1235 1236 if (ctx->pic_params->vol_fields.bits.short_video_header) 1237 { 1238 /* FE_PICSH_PPS0 */ 1239 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_PICSH_PPS0) , ctx->FE_PICSH_PPS0 ); 1240 } 1241 1242 /* FE_VOP_PPS0 */ 1243 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0) , ctx->FE_VOP_PPS0 ); 1244 1245 psb_cmdbuf_reg_end_block( cmdbuf ); 1246} 1247 1248static void psb__MPEG4_FE_state(context_MPEG4_p ctx) 1249{ 1250 uint32_t lldma_record_offset; 1251 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1252 1253 /* See RENDER_BUFFER_HEADER */ 1254 *cmdbuf->cmd_idx++ = CMD_HEADER; 1255 1256 ctx->p_slice_params = cmdbuf->cmd_idx; 1257 *cmdbuf->cmd_idx++ = 0; /* ui32SliceParams */ 1258 1259 lldma_record_offset = psb_cmdbuf_lldma_create( cmdbuf, &(ctx->FE_state_buffer), 0, 1260 FE_STATE_SAVE_SIZE, 0, LLDMA_TYPE_MPEG4_FESTATE_SAVE ); 1261 RELOC(*cmdbuf->cmd_idx, lldma_record_offset, &(cmdbuf->buf)); 1262 cmdbuf->cmd_idx++; 1263 1264 lldma_record_offset = psb_cmdbuf_lldma_create( cmdbuf, &(ctx->FE_state_buffer), 0, 1265 FE_STATE_SAVE_SIZE, 0, LLDMA_TYPE_MPEG4_FESTATE_RESTORE ); 1266 RELOC(*cmdbuf->cmd_idx, lldma_record_offset, &(cmdbuf->buf)); 1267 cmdbuf->cmd_idx++; 1268} 1269 1270static VAStatus psb__MPEG4_process_slice(context_MPEG4_p ctx, 1271 VASliceParameterBufferMPEG4 *slice_param, 1272 object_buffer_p obj_buffer) 1273{ 1274 VAStatus vaStatus = VA_STATUS_SUCCESS; 1275 1276 ASSERT((obj_buffer->type == VASliceDataBufferType) || (obj_buffer->type == VAProtectedSliceDataBufferType)); 1277 1278 psb__information_message("MPEG4 process slice\n"); 1279 psb__information_message(" size = %08x offset = %08x\n", slice_param->slice_data_size, slice_param->slice_data_offset); 1280 psb__information_message(" macroblock nr = %d offset = %d\n", slice_param->macroblock_number, slice_param->macroblock_offset); 1281 psb__information_message(" slice_data_flag = %d\n", slice_param->slice_data_flag); 1282 psb__information_message(" interlaced = %d\n", ctx->pic_params->vol_fields.bits.interlaced); 1283 psb__information_message(" coded size = %dx%d\n", ctx->picture_width_mb, ctx->picture_height_mb); 1284 1285 if ((slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_BEGIN) || 1286 (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_ALL)) 1287 { 1288 if (0 == slice_param->slice_data_size) 1289 { 1290 vaStatus = VA_STATUS_ERROR_UNKNOWN; 1291 DEBUG_FAILURE; 1292 return vaStatus; 1293 } 1294 ASSERT( !ctx->split_buffer_pending ); 1295 1296 /* Initialise the command buffer */ 1297 /* TODO: Reuse current command buffer until full */ 1298 psb_context_get_next_cmdbuf(ctx->obj_context); 1299 1300 psb_cmdbuf_lldma_write_bitstream(ctx->obj_context->cmdbuf, 1301 obj_buffer->psb_buffer, 1302 obj_buffer->psb_buffer->buffer_ofs + slice_param->slice_data_offset, 1303 slice_param->slice_data_size, 1304 slice_param->macroblock_offset, 1305 0); 1306 1307 if (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_BEGIN) 1308 { 1309 ctx->split_buffer_pending = TRUE; 1310 } 1311 } 1312 else 1313 { 1314 ASSERT( ctx->split_buffer_pending ); 1315 ASSERT(0 == slice_param->slice_data_offset); 1316 /* Create LLDMA chain to continue buffer */ 1317 if (slice_param->slice_data_size) 1318 { 1319 psb_cmdbuf_lldma_write_bitstream_chained(ctx->obj_context->cmdbuf, 1320 obj_buffer->psb_buffer, 1321 slice_param->slice_data_size); 1322 } 1323 } 1324 1325 if ((slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_ALL) || 1326 (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_END)) 1327 { 1328 if (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_END) 1329 { 1330 ASSERT( ctx->split_buffer_pending ); 1331 } 1332 1333 psb__MPEG4_FE_state(ctx); 1334 1335 psb__MPEG4_write_VLC_tables(ctx); 1336 1337 psb__MPEG4_set_picture_params(ctx, slice_param); 1338 1339 psb__MPEG4_set_frontend_registers(ctx, slice_param); 1340 1341 psb__MPEG4_set_backend_registers(ctx, slice_param); 1342 1343 psb__MPEG4_write_kick(ctx, slice_param); 1344 1345 ctx->split_buffer_pending = FALSE; 1346 ctx->obj_context->video_op = psb_video_vld; 1347 ctx->obj_context->flags = 0; 1348 ctx->obj_context->first_mb = 0; 1349 ctx->obj_context->last_mb = ((ctx->picture_height_mb - 1) << 8) | (ctx->picture_width_mb - 1); 1350 if (psb_context_submit_cmdbuf(ctx->obj_context)) 1351 { 1352 vaStatus = VA_STATUS_ERROR_UNKNOWN; 1353 } 1354 } 1355 return vaStatus; 1356} 1357 1358static VAStatus psb__MPEG4_process_slice_data(context_MPEG4_p ctx, object_buffer_p obj_buffer) 1359{ 1360 VAStatus vaStatus = VA_STATUS_SUCCESS; 1361 VASliceParameterBufferMPEG4 *slice_param; 1362 int buffer_idx = 0; 1363 int element_idx = 0; 1364 1365 1366 ASSERT((obj_buffer->type == VASliceDataBufferType) || (obj_buffer->type == VAProtectedSliceDataBufferType)); 1367 1368 ASSERT(ctx->pic_params); 1369 ASSERT(ctx->slice_param_list_idx); 1370 1371 if (!ctx->pic_params) 1372 { 1373 /* Picture params missing */ 1374 return VA_STATUS_ERROR_UNKNOWN; 1375 } 1376 if ((NULL == obj_buffer->psb_buffer) || 1377 (0 == obj_buffer->size)) 1378 { 1379 /* We need to have data in the bitstream buffer */ 1380 return VA_STATUS_ERROR_UNKNOWN; 1381 } 1382 1383 while(buffer_idx < ctx->slice_param_list_idx) 1384 { 1385 object_buffer_p slice_buf = ctx->slice_param_list[buffer_idx]; 1386 if (element_idx >= slice_buf->num_elements) 1387 { 1388 /* Move to next buffer */ 1389 element_idx = 0; 1390 buffer_idx++; 1391 continue; 1392 } 1393 1394 slice_param = (VASliceParameterBufferMPEG4 *) slice_buf->buffer_data; 1395 slice_param += element_idx; 1396 element_idx++; 1397 vaStatus = psb__MPEG4_process_slice(ctx, slice_param, obj_buffer); 1398 if (vaStatus != VA_STATUS_SUCCESS) 1399 { DEBUG_FAILURE; 1400 break; 1401 } 1402 } 1403 ctx->slice_param_list_idx = 0; 1404 1405 return vaStatus; 1406} 1407 1408static VAStatus pnw_MPEG4_BeginPicture( 1409 object_context_p obj_context) 1410{ 1411 INIT_CONTEXT_MPEG4 1412 1413 if (ctx->pic_params) 1414 { 1415 free(ctx->pic_params); 1416 ctx->pic_params = NULL; 1417 } 1418 ctx->load_non_intra_quant_mat = FALSE; 1419 ctx->load_intra_quant_mat = FALSE; 1420 1421 return VA_STATUS_SUCCESS; 1422} 1423 1424static VAStatus pnw_MPEG4_RenderPicture( 1425 object_context_p obj_context, 1426 object_buffer_p *buffers, 1427 int num_buffers) 1428{ 1429 int i; 1430 INIT_CONTEXT_MPEG4 1431 VAStatus vaStatus = VA_STATUS_SUCCESS; 1432 1433 for(i = 0; i < num_buffers; i++) 1434 { 1435 object_buffer_p obj_buffer = buffers[i]; 1436 1437 switch( obj_buffer->type) 1438 { 1439 case VAPictureParameterBufferType: 1440 psb__information_message("pnw_MPEG4_RenderPicture got VAPictureParameterBuffer\n"); 1441 vaStatus = psb__MPEG4_process_picture_param(ctx, obj_buffer); 1442 DEBUG_FAILURE; 1443 break; 1444 1445 case VAIQMatrixBufferType: 1446 psb__information_message("pnw_MPEG4_RenderPicture got VAIQMatrixBufferType\n"); 1447 vaStatus = psb__MPEG4_process_iq_matrix(ctx, obj_buffer); 1448 DEBUG_FAILURE; 1449 break; 1450 1451 case VASliceParameterBufferType: 1452 psb__information_message("pnw_MPEG4_RenderPicture got VASliceParameterBufferType\n"); 1453 vaStatus = psb__MPEG4_add_slice_param(ctx, obj_buffer); 1454 DEBUG_FAILURE; 1455 break; 1456 1457 case VASliceDataBufferType: 1458 case VAProtectedSliceDataBufferType: 1459 1460 psb__information_message("pnw_MPEG4_RenderPicture got %s\n", SLICEDATA_BUFFER_TYPE(obj_buffer->type)); 1461 vaStatus = psb__MPEG4_process_slice_data(ctx, obj_buffer); 1462 DEBUG_FAILURE; 1463 break; 1464 1465 default: 1466 vaStatus = VA_STATUS_ERROR_UNKNOWN; 1467 DEBUG_FAILURE; 1468 } 1469 if (vaStatus != VA_STATUS_SUCCESS) 1470 { 1471 break; 1472 } 1473 } 1474 1475 return vaStatus; 1476} 1477 1478static VAStatus pnw_MPEG4_EndPicture( 1479 object_context_p obj_context) 1480{ 1481 INIT_CONTEXT_MPEG4 1482 1483 if (psb_context_flush_cmdbuf(ctx->obj_context)) 1484 { 1485 return VA_STATUS_ERROR_UNKNOWN; 1486 } 1487 1488 if (ctx->pic_params) 1489 { 1490 free(ctx->pic_params); 1491 ctx->pic_params = NULL; 1492 } 1493 1494 return VA_STATUS_SUCCESS; 1495} 1496 1497struct format_vtable_s pnw_MPEG4_vtable = { 1498 queryConfigAttributes: pnw_MPEG4_QueryConfigAttributes, 1499 validateConfig: pnw_MPEG4_ValidateConfig, 1500 createContext: pnw_MPEG4_CreateContext, 1501 destroyContext: pnw_MPEG4_DestroyContext, 1502 beginPicture: pnw_MPEG4_BeginPicture, 1503 renderPicture: pnw_MPEG4_RenderPicture, 1504 endPicture: pnw_MPEG4_EndPicture 1505}; 1506