pnw_MPEG4.c revision 4b5b72d7dd3fe944d75029ff0ca6db1e74600e59
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_range_mapping_base0; 329 uint32_t *p_range_mapping_base1; 330 uint32_t *p_slice_params; /* pointer to ui32SliceParams in CMD_HEADER */ 331 uint32_t *slice_first_pic_last; 332 uint32_t *alt_output_flags; 333}; 334 335typedef struct context_MPEG4_s *context_MPEG4_p; 336 337#define INIT_CONTEXT_MPEG4 context_MPEG4_p ctx = (context_MPEG4_p) obj_context->format_data; 338 339#define SURFACE(id) ((object_surface_p) object_heap_lookup( &ctx->obj_context->driver_data->surface_heap, id )) 340 341static const char *psb__debug_picture_coding_str(unsigned char vop_coding_type) 342{ 343 switch (vop_coding_type) 344 { 345 case PICTURE_CODING_I: return ("PICTURE_CODING_I"); 346 case PICTURE_CODING_P: return ("PICTURE_CODING_P"); 347 case PICTURE_CODING_B: return ("PICTURE_CODING_B"); 348 case PICTURE_CODING_S: return ("PICTURE_CODING_S"); 349 } 350 return ("UNKNOWN!!!"); 351} 352 353 354static void pnw_MPEG4_QueryConfigAttributes( 355 VAProfile profile, 356 VAEntrypoint entrypoint, 357 VAConfigAttrib *attrib_list, 358 int num_attribs ) 359{ 360 /* No MPEG4 specific attributes */ 361} 362 363static VAStatus pnw_MPEG4_ValidateConfig( 364 object_config_p obj_config ) 365{ 366 int i; 367 /* Check all attributes */ 368 for(i = 0; i < obj_config->attrib_count; i++) 369 { 370 switch (obj_config->attrib_list[i].type) 371 { 372 case VAConfigAttribRTFormat: 373 /* Ignore */ 374 break; 375 376 default: 377 return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; 378 } 379 } 380 381 return VA_STATUS_SUCCESS; 382} 383 384static VAStatus psb__MPEG4_check_legal_picture(object_context_p obj_context, object_config_p obj_config) 385{ 386 VAStatus vaStatus = VA_STATUS_SUCCESS; 387 388 if (NULL == obj_context) 389 { 390 vaStatus = VA_STATUS_ERROR_INVALID_CONTEXT; 391 DEBUG_FAILURE; 392 return vaStatus; 393 } 394 395 if (NULL == obj_config) 396 { 397 vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; 398 DEBUG_FAILURE; 399 return vaStatus; 400 } 401 402 /* MSVDX decode capability for MPEG4: 403 * SP@L3 404 * ASP@L5 405 * 406 * Refer to the "MSVDX MPEG4 decode capability" table of "Poulsbo Media Software Overview". 407 */ 408 switch (obj_config->profile) 409 { 410 case VAProfileMPEG4Simple: 411 case VAProfileMPEG4AdvancedSimple: 412 if ((obj_context->picture_width <= 0) || (obj_context->picture_height <= 0)) 413 { 414 vaStatus = VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; 415 } 416 break; 417 418 default: 419 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; 420 break; 421 } 422 423 return vaStatus; 424} 425 426static void pnw_MPEG4_DestroyContext(object_context_p obj_context); 427 428static VAStatus pnw_MPEG4_CreateContext( 429 object_context_p obj_context, 430 object_config_p obj_config ) 431{ 432 VAStatus vaStatus = VA_STATUS_SUCCESS; 433 context_MPEG4_p ctx; 434 /* Validate flag */ 435 /* Validate picture dimensions */ 436 vaStatus = psb__MPEG4_check_legal_picture(obj_context, obj_config); 437 if (VA_STATUS_SUCCESS != vaStatus) 438 { 439 DEBUG_FAILURE; 440 return vaStatus; 441 } 442 443 ctx = (context_MPEG4_p) calloc(1, sizeof(struct context_MPEG4_s)); 444 if (NULL == ctx) 445 { 446 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 447 DEBUG_FAILURE; 448 return vaStatus; 449 } 450 obj_context->format_data = (void*) ctx; 451 ctx->obj_context = obj_context; 452 ctx->pic_params = NULL; 453 ctx->load_non_intra_quant_mat = FALSE; 454 ctx->load_intra_quant_mat = FALSE; 455 456 ctx->split_buffer_pending = FALSE; 457 458 ctx->slice_param_list_size = 8; 459 ctx->slice_param_list = (object_buffer_p*) calloc(1, sizeof(object_buffer_p)*ctx->slice_param_list_size); 460 ctx->slice_param_list_idx = 0; 461 462 if (NULL == ctx->slice_param_list) 463 { 464 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 465 DEBUG_FAILURE; 466 free(ctx); 467 return vaStatus; 468 } 469 470 ctx->colocated_buffers_size = obj_context->num_render_targets; 471 ctx->colocated_buffers_idx = 0; 472 ctx->colocated_buffers = (psb_buffer_p) calloc(1, sizeof(struct psb_buffer_s)*ctx->colocated_buffers_size); 473 if (NULL == ctx->colocated_buffers) 474 { 475 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 476 DEBUG_FAILURE; 477 free(ctx->slice_param_list); 478 free(ctx); 479 return vaStatus; 480 } 481 482 switch (obj_config->profile ) 483 { 484 case VAProfileMPEG4Simple: 485 psb__information_message("MPEG4_PROFILE_SIMPLE\n"); 486 ctx->profile = MPEG4_PROFILE_SIMPLE; 487 break; 488 489 case VAProfileMPEG4AdvancedSimple: 490 psb__information_message("MPEG4_PROFILE_ASP\n"); 491 ctx->profile = MPEG4_PROFILE_ASP; 492 break; 493 494 default: 495 ASSERT(0 == 1); 496 vaStatus = VA_STATUS_ERROR_UNKNOWN; 497 } 498 499 // TODO 500 501 if (vaStatus == VA_STATUS_SUCCESS) 502 { 503 vaStatus = psb_buffer_create( obj_context->driver_data, 504 FE_STATE_BUFFER_SIZE, 505 psb_bt_vpu_only, 506 &ctx->FE_state_buffer ); 507 DEBUG_FAILURE; 508 } 509 510 if (vaStatus == VA_STATUS_SUCCESS) 511 { 512 vaStatus = psb_buffer_create( obj_context->driver_data, 513 sizeof(gaui16mpeg4VlcTableDataPacked), 514 psb_bt_cpu_vpu, 515 &ctx->vlc_packed_table ); 516 DEBUG_FAILURE; 517 } 518 if (vaStatus == VA_STATUS_SUCCESS) 519 { 520 void *vlc_packed_data_address; 521 if (0 == psb_buffer_map( &ctx->vlc_packed_table, &vlc_packed_data_address )) 522 { 523 memcpy( vlc_packed_data_address, gaui16mpeg4VlcTableDataPacked, sizeof(gaui16mpeg4VlcTableDataPacked)); 524 psb_buffer_unmap( &ctx->vlc_packed_table ); 525 } 526 else 527 { 528 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 529 DEBUG_FAILURE; 530 } 531 } 532 533 if (vaStatus != VA_STATUS_SUCCESS) 534 { 535 pnw_MPEG4_DestroyContext(obj_context); 536 } 537 538 return vaStatus; 539} 540 541static void pnw_MPEG4_DestroyContext( 542 object_context_p obj_context) 543{ 544 INIT_CONTEXT_MPEG4 545 int i; 546 547 psb_buffer_destroy( &ctx->vlc_packed_table ); 548 psb_buffer_destroy( &ctx->FE_state_buffer ); 549 550 if (ctx->pic_params) 551 { 552 free(ctx->pic_params); 553 ctx->pic_params = NULL; 554 } 555 556 if (ctx->colocated_buffers) 557 { 558 for (i = 0; i < ctx->colocated_buffers_idx; ++i) 559 psb_buffer_destroy(&(ctx->colocated_buffers[i])); 560 561 free(ctx->colocated_buffers); 562 ctx->colocated_buffers = NULL; 563 } 564 if (ctx->slice_param_list) 565 { 566 free(ctx->slice_param_list); 567 ctx->slice_param_list = NULL; 568 } 569 570 free(obj_context->format_data); 571 obj_context->format_data = NULL; 572} 573 574static VAStatus psb__MPEG4_allocate_colocated_buffer(context_MPEG4_p ctx, object_surface_p obj_surface, uint32_t size){ 575 psb_surface_p surface = obj_surface->psb_surface; 576 577 if (!GET_SURFACE_INFO_colocated_index(surface)) 578 { 579 VAStatus vaStatus; 580 psb_buffer_p buf; 581 int index = ctx->colocated_buffers_idx; 582 if (index >= ctx->colocated_buffers_size) 583 { 584 return VA_STATUS_ERROR_UNKNOWN; 585 } 586 buf = &(ctx->colocated_buffers[index]); 587 vaStatus = psb_buffer_create( ctx->obj_context->driver_data, size, psb_bt_vpu_only, buf); 588 if (VA_STATUS_SUCCESS != vaStatus) 589 { 590 return vaStatus; 591 } 592 ctx->colocated_buffers_idx++; 593 SET_SURFACE_INFO_colocated_index(surface, index+1); /* 0 means unset, index is offset by 1 */ 594 } 595 return VA_STATUS_SUCCESS; 596} 597 598static psb_buffer_p psb__MPEG4_lookup_colocated_buffer(context_MPEG4_p ctx, psb_surface_p surface) 599{ 600 int index = GET_SURFACE_INFO_colocated_index(surface); 601 if (!index) 602 { 603 return NULL; 604 } 605 return &(ctx->colocated_buffers[index-1]); /* 0 means unset, index is offset by 1 */ 606} 607 608static VAStatus psb__MPEG4_process_picture_param(context_MPEG4_p ctx, object_buffer_p obj_buffer) 609{ 610 VAStatus vaStatus; 611 ASSERT(obj_buffer->type == VAPictureParameterBufferType); 612 ASSERT(obj_buffer->num_elements == 1); 613 ASSERT(obj_buffer->size == sizeof(VAPictureParameterBufferMPEG4)); 614 615 if ((obj_buffer->num_elements != 1) || 616 (obj_buffer->size != sizeof(VAPictureParameterBufferMPEG4))) 617 { 618 return VA_STATUS_ERROR_UNKNOWN; 619 } 620 621 /* Transfer ownership of VAPictureParameterBufferMPEG4 data */ 622 if (ctx->pic_params) 623 { 624 free(ctx->pic_params); 625 } 626 ctx->pic_params = (VAPictureParameterBufferMPEG4 *) obj_buffer->buffer_data; 627 obj_buffer->buffer_data = NULL; 628 obj_buffer->size = 0; 629 630 631 /* Lookup surfaces for backward/forward references */ 632 /* Lookup surfaces for backward/forward references */ 633 switch (ctx->pic_params->vop_fields.bits.vop_coding_type) 634 { 635 case PICTURE_CODING_I: 636 ctx->forward_ref_surface = NULL; 637 ctx->backward_ref_surface = NULL; 638psb__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 ); 639psb__information_message("Forward ref = NULL\n"); 640psb__information_message("Backward ref = NULL\n"); 641 break; 642 643 case PICTURE_CODING_P: 644 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 645 ctx->backward_ref_surface = NULL; 646 if (NULL == ctx->forward_ref_surface) 647 { 648 return VA_STATUS_ERROR_INVALID_SURFACE; 649 } 650psb__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 ); 651psb__information_message("Forward ref = %08x (%08x)\n", ctx->forward_ref_surface->psb_surface, ctx->pic_params->forward_reference_picture); 652psb__information_message("Backward ref = NULL\n"); 653 break; 654 655 case PICTURE_CODING_B: 656 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 657 ctx->backward_ref_surface = SURFACE(ctx->pic_params->backward_reference_picture); 658 if ((NULL == ctx->forward_ref_surface) || 659 (NULL == ctx->backward_ref_surface)) 660 { 661 return VA_STATUS_ERROR_INVALID_SURFACE; 662 } 663psb__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 ); 664psb__information_message("Forward ref = %08x (%08x)\n", ctx->forward_ref_surface->psb_surface, ctx->pic_params->forward_reference_picture); 665psb__information_message("Backward ref = %08x (%08x)\n", ctx->backward_ref_surface->psb_surface, ctx->pic_params->backward_reference_picture); 666 break; 667 668 case PICTURE_CODING_S: 669 ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 670 ctx->backward_ref_surface = SURFACE(ctx->pic_params->backward_reference_picture); 671psb__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 ); 672psb__information_message("Forward ref = %08x (%08x)\n", ctx->forward_ref_surface ? ctx->forward_ref_surface->psb_surface : 0, ctx->pic_params->forward_reference_picture); 673psb__information_message("Backward ref = %08x (%08x)\n", ctx->backward_ref_surface ? ctx->backward_ref_surface->psb_surface : 0, ctx->pic_params->backward_reference_picture); 674 break; 675 676 default: 677 psb__error_message("Unhandled MPEG4 vop_coding_type '%d'\n", ctx->pic_params->vop_fields.bits.vop_coding_type); 678 return VA_STATUS_ERROR_UNKNOWN; 679 } 680 681 if (NULL == ctx->forward_ref_surface) 682 { 683 /* for mmu fault protection */ 684 ctx->forward_ref_surface = ctx->obj_context->current_render_target; 685 } 686 if (NULL == ctx->backward_ref_surface) 687 { 688 /* for mmu fault protection */ 689 ctx->backward_ref_surface = ctx->obj_context->current_render_target; 690 } 691 692 ctx->display_picture_width = ctx->pic_params->vop_width; 693 ctx->display_picture_height = ctx->pic_params->vop_height; 694 ctx->picture_width_mb = PIXELS_TO_MB(ctx->display_picture_width); 695 ctx->picture_height_mb = PIXELS_TO_MB(ctx->display_picture_height); 696 ctx->coded_picture_width = ctx->picture_width_mb * 16; 697 ctx->coded_picture_height = ctx->picture_height_mb * 16; 698 ctx->size_mb = ctx->picture_width_mb * ctx->picture_height_mb; 699 700 uint32_t mbInPic= ctx->picture_width_mb * ctx->picture_height_mb; 701 702 mbInPic += 4; 703 704 uint32_t colocated_size = ((mbInPic * 200) + 0xfff) & ~0xfff; 705 706 vaStatus = psb__MPEG4_allocate_colocated_buffer(ctx, ctx->obj_context->current_render_target, colocated_size); 707 if (VA_STATUS_SUCCESS != vaStatus) 708 { 709 DEBUG_FAILURE; 710 return vaStatus; 711 } 712 vaStatus = psb__MPEG4_allocate_colocated_buffer(ctx, ctx->forward_ref_surface, colocated_size); 713 if (VA_STATUS_SUCCESS != vaStatus) 714 { 715 DEBUG_FAILURE; 716 return vaStatus; 717 } 718 719 ctx->FEControl = 0; 720 REGIO_WRITE_FIELD_LITE (ctx->FEControl , 721 MSVDX_VEC, 722 CR_VEC_ENTDEC_FE_CONTROL, 723 ENTDEC_FE_PROFILE, 724 ctx->profile); /* MPEG4 SP / ASP profile */ 725 726 REGIO_WRITE_FIELD_LITE (ctx->FEControl , 727 MSVDX_VEC, 728 CR_VEC_ENTDEC_FE_CONTROL, 729 ENTDEC_FE_MODE, 730 4); /* Set MPEG4 mode */ 731 732 /* FE_SPS0 */ 733 ctx->FE_SPS0 = 0; 734 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 ); 735 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); 736 REGIO_WRITE_FIELD_LITE (ctx->FE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0, FE_PROFILE, ctx->profile ); 737 738 /* FE_VOP_SPS0 */ 739 ctx->FE_VOP_SPS0 = 0; 740 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 ); 741 REGIO_WRITE_FIELD_LITE (ctx->FE_VOP_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0, QUANT_PRECISION, ctx->pic_params->quant_precision); 742 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); 743 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) ); 744 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); 745 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); 746 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); 747 748 if (ctx->pic_params->vol_fields.bits.short_video_header) 749 { 750 /* FE_PICSH_PPS0 */ 751 ctx->FE_PICSH_PPS0 = 0; 752 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); 753 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); 754 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); 755 } 756 757 /* FE_VOP_PPS0 */ 758 ctx->FE_VOP_PPS0 = 0; 759 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); 760 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); 761 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); 762 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); 763 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); 764 765 /* BE_SPS0 */ 766 /* Common for VOPs and pictures with short header */ 767 ctx->BE_SPS0 = 0; 768 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); 769 REGIO_WRITE_FIELD_LITE( ctx->BE_SPS0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_SPS0, BE_PROFILE, ctx->profile); 770 771 /* BE_SPS1 */ 772 /* Common for VOPs and pictures with short header */ 773 ctx->BE_SPS1 = 0; 774 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); 775 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); 776 777 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) 778 { 779 /* BE_VOP_SPS0 */ 780 ctx->BE_VOP_SPS0 = 0; 781 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); 782 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); 783 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); 784 785 /* BE_VOP_SPS1 */ 786 ctx->BE_VOP_SPS1 = 0; 787 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); 788 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); 789 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)); 790 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); 791 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); 792 793 /* BE_VOP_PPS0 */ 794 ctx->BE_VOP_PPS0 = 0; 795 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); 796 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); 797 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); 798 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); 799 REGIO_WRITE_FIELD_LITE (ctx->BE_VOP_PPS0, 800 MSVDX_VEC_MPEG4, 801 CR_VEC_MPEG4_BE_VOP_PPS0, 802 ROUNDING_TYPE, 803 ((PICTURE_CODING_I == ctx->pic_params->vop_fields.bits.vop_coding_type || 804 PICTURE_CODING_B == ctx->pic_params->vop_fields.bits.vop_coding_type) ? 805 0 : ctx->pic_params->vop_fields.bits.vop_rounding_type)); 806 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); 807 } 808 else 809 { 810 /* BE_VOP_PPS0 */ 811 ctx->BE_VOP_PPS0 = 0; 812 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 813 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); 814 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); 815 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 816 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); 817 818 /* BE_PICSH_PPS0 */ 819 ctx->BE_PICSH_PPS0 = 0; 820 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); 821 } 822 823 return VA_STATUS_SUCCESS; 824} 825 826static void psb__MPEG4_convert_iq_matrix(uint32_t *dest32, unsigned char *src) 827{ 828 int i; 829 int *idx = scan0; 830 uint8_t *dest8 = (uint8_t*) dest32; 831 832 for (i = 0; i < 64; i++) 833 { 834 *dest8++ = src[*idx++]; 835 } 836} 837 838static VAStatus psb__MPEG4_process_iq_matrix(context_MPEG4_p ctx, object_buffer_p obj_buffer) 839{ 840 VAIQMatrixBufferMPEG4 *iq_matrix = (VAIQMatrixBufferMPEG4 *) obj_buffer->buffer_data; 841 ASSERT(obj_buffer->type == VAIQMatrixBufferType); 842 ASSERT(obj_buffer->num_elements == 1); 843 ASSERT(obj_buffer->size == sizeof(VAIQMatrixBufferMPEG4)); 844 845 if ((obj_buffer->num_elements != 1) || 846 (obj_buffer->size != sizeof(VAIQMatrixBufferMPEG4))) 847 { 848 return VA_STATUS_ERROR_UNKNOWN; 849 } 850 851 if (iq_matrix->load_non_intra_quant_mat) 852 { 853 psb__MPEG4_convert_iq_matrix( ctx->qmatrix_data[NONINTRA_LUMA_Q], iq_matrix->non_intra_quant_mat ); 854 } 855 if (iq_matrix->load_intra_quant_mat) 856 { 857 psb__MPEG4_convert_iq_matrix( ctx->qmatrix_data[INTRA_LUMA_Q], iq_matrix->intra_quant_mat ); 858 } 859 ctx->load_non_intra_quant_mat = iq_matrix->load_non_intra_quant_mat; 860 ctx->load_intra_quant_mat = iq_matrix->load_intra_quant_mat; 861 862 return VA_STATUS_SUCCESS; 863} 864 865static void psb__MPEG4_write_qmatrices(context_MPEG4_p ctx) 866{ 867 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 868 int i; 869 870 // TODO: Verify that this is indeed the same as MPEG2 871 872 /* Since we only decode 4:2:0 We only need to the Intra tables. 873 Chroma quant tables are only used in Mpeg 4:2:2 and 4:4:4. 874 The hardware wants non-intra followed by intra */ 875 /* psb_cmdbuf_rendec_start_block( cmdbuf ); */ 876 psb_cmdbuf_rendec_start( cmdbuf, REG_MSVDX_VEC_IQRAM_OFFSET ); 877 878 /* todo : optimisation here is to only load the need table */ 879 if (ctx->load_non_intra_quant_mat) 880 { 881 /* NONINTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + 0 */ 882 for (i = 0; i < 16; i++) 883 { 884 psb_cmdbuf_rendec_write( cmdbuf, ctx->qmatrix_data[NONINTRA_LUMA_Q][i] ); 885 } 886 } 887 else 888 { 889 for (i = 0; i < 16; i++) 890 { 891 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 892 } 893 } 894 if (ctx->load_intra_quant_mat) 895 { 896 /* INTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + (16*4) */ 897 for (i = 0; i < 16; i++) 898 { 899 psb_cmdbuf_rendec_write( cmdbuf, ctx->qmatrix_data[INTRA_LUMA_Q][i] ); 900 } 901 } 902 else 903 { 904 for (i = 0; i < 16; i++) 905 { 906 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 907 } 908 } 909 910 psb_cmdbuf_rendec_end( cmdbuf ); 911 /* psb_cmdbuf_rendec_end_block( cmdbuf ); */ 912} 913 914 915/* 916 * Adds a VASliceParameterBuffer to the list of slice params 917 */ 918static VAStatus psb__MPEG4_add_slice_param(context_MPEG4_p ctx, object_buffer_p obj_buffer) 919{ 920 ASSERT(obj_buffer->type == VASliceParameterBufferType); 921 if (ctx->slice_param_list_idx >= ctx->slice_param_list_size) 922 { 923 void *new_list; 924 ctx->slice_param_list_size += 8; 925 new_list = realloc(ctx->slice_param_list, 926 sizeof(object_buffer_p)*ctx->slice_param_list_size); 927 if (NULL == new_list) 928 { 929 return VA_STATUS_ERROR_ALLOCATION_FAILED; 930 } 931 ctx->slice_param_list = (object_buffer_p*) new_list; 932 } 933 ctx->slice_param_list[ctx->slice_param_list_idx] = obj_buffer; 934 ctx->slice_param_list_idx++; 935 return VA_STATUS_SUCCESS; 936} 937 938/* Precalculated values */ 939#define ADDR0 (0x00005800) 940#define ADDR1 (0x0001f828) 941#define ADDR2 (0x0002b854) 942#define ADDR3 (0x0002f85c) 943#define ADDR4 (0x0004d089) 944#define ADDR5 (0x0008f0aa) 945#define ADDR6 (0x00149988) 946#define ADDR7 (0x001d8b9e) 947#define ADDR8 (0x000003c3) 948#define WIDTH0 (0x09a596ed) 949#define WIDTH1 (0x0006d6db) 950#define OPCODE0 (0x50009a0a) 951#define OPCODE1 (0x00000001) 952 953static void psb__MPEG4_write_VLC_tables(context_MPEG4_p ctx) 954{ 955 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 956 957 /* Write the vec registers with the index data for each of the tables and then write */ 958 /* the actual table data. */ 959 psb_cmdbuf_reg_start_block( cmdbuf ); 960 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR0), ADDR0 ); 961 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR1), ADDR1 ); 962 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR2), ADDR2 ); 963 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR3), ADDR3 ); 964 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR4), ADDR4 ); 965 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR5), ADDR5 ); 966 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR6), ADDR6 ); 967 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR7), ADDR7 ); 968 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR8), ADDR8 ); 969 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_WIDTH0), WIDTH0 ); 970 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_WIDTH1), WIDTH1 ); 971 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_OPCODE0), OPCODE0 ); 972 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_OPCODE1), OPCODE1 ); 973 psb_cmdbuf_reg_end_block( cmdbuf ); 974 975 /* VLC Table */ 976 /* Write a LLDMA Cmd to transfer VLD Table data */ 977 psb_cmdbuf_lldma_write_cmdbuf( cmdbuf, &ctx->vlc_packed_table, 0, 978 sizeof(gaui16mpeg4VlcTableDataPacked), 979 0, LLDMA_TYPE_VLC_TABLE ); 980} 981 982 983static void psb__MPEG4_write_kick(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 984{ 985 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 986 987 (void) slice_param; /* Unused for now */ 988 989 *cmdbuf->cmd_idx++ = CMD_COMPLETION; 990} 991 992/* Programme the Alt output if there is a rotation*/ 993static void psb__MPEG4_setup_alternative_frame( context_MPEG4_p ctx ) 994{ 995 uint32_t cmd; 996 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 997 psb_surface_p rotate_surface = ctx->obj_context->current_render_target->psb_surface_rotate; 998 object_context_p obj_context = ctx->obj_context; 999 1000 if(rotate_surface->extra_info[5] != obj_context->rotate) 1001 psb__error_message("Display rotate mode does not match surface rotate mode!\n"); 1002 1003 1004 /* CRendecBlock RendecBlk( mCtrlAlloc , RENDEC_REGISTER_OFFSET(MSVDX_CMDS, VC1_LUMA_RANGE_MAPPING_BASE_ADDRESS) ); */ 1005 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, VC1_LUMA_RANGE_MAPPING_BASE_ADDRESS) ); 1006 1007 psb_cmdbuf_rendec_write_address( cmdbuf, &rotate_surface->buf, rotate_surface->buf.buffer_ofs); 1008 psb_cmdbuf_rendec_write_address( cmdbuf, &rotate_surface->buf, rotate_surface->buf.buffer_ofs + rotate_surface->chroma_offset); 1009 1010 psb_cmdbuf_rendec_end( cmdbuf ); 1011 1012 /* Set the rotation registers */ 1013 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, ALTERNATIVE_OUTPUT_PICTURE_ROTATION) ); 1014 cmd = 0; 1015 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS,ALTERNATIVE_OUTPUT_PICTURE_ROTATION ,ALT_PICTURE_ENABLE,1 ); 1016 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS,ALTERNATIVE_OUTPUT_PICTURE_ROTATION ,ROTATION_ROW_STRIDE, rotate_surface->stride_mode); 1017 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS,ALTERNATIVE_OUTPUT_PICTURE_ROTATION ,RECON_WRITE_DISABLE, 0); /* FIXME Always generate Rec */ 1018 REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS,ALTERNATIVE_OUTPUT_PICTURE_ROTATION ,ROTATION_MODE, rotate_surface->extra_info[5]); 1019 1020 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1021 1022 psb_cmdbuf_rendec_end( cmdbuf ); 1023 1024 *ctx->alt_output_flags = cmd; 1025 RELOC(*ctx->p_range_mapping_base0, rotate_surface->buf.buffer_ofs, &rotate_surface->buf); 1026 RELOC(*ctx->p_range_mapping_base1, rotate_surface->buf.buffer_ofs + rotate_surface->chroma_offset, &rotate_surface->buf); 1027} 1028 1029 1030static void psb__MPEG4_set_picture_params(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 1031{ 1032 uint32_t cmd; 1033 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1034 psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 1035 1036 psb_buffer_p colocated_target_buffer = psb__MPEG4_lookup_colocated_buffer(ctx, target_surface); 1037 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 */ 1038 ASSERT(colocated_target_buffer); 1039 ASSERT(colocated_ref_buffer); 1040 1041 /* psb_cmdbuf_rendec_start_block( cmdbuf ); */ 1042 1043 /* BE_PARAM_BASE_ADDR */ 1044 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_PARAM_BASE_ADDR) ); 1045 if (colocated_target_buffer) 1046 { 1047 psb_cmdbuf_rendec_write_address( cmdbuf, colocated_target_buffer, 0); 1048 } 1049 else 1050 { 1051 /* This is an error */ 1052 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1053 } 1054 psb_cmdbuf_rendec_end( cmdbuf ); 1055 1056 /* PARAM_BASE_ADDRESS */ 1057 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_COLPARAM_BASE_ADDR) ); 1058 if (colocated_ref_buffer) 1059 { 1060 psb_cmdbuf_rendec_write_address( cmdbuf, colocated_ref_buffer, 0 ); 1061 } 1062 else 1063 { 1064 /* This is an error */ 1065 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1066 } 1067 psb_cmdbuf_rendec_end( cmdbuf ); 1068 1069 if(ctx->obj_context->rotate != VA_ROTATION_NONE) 1070 psb__MPEG4_setup_alternative_frame( ctx ); 1071 1072 /* Send VDMC and VDEB commands */ 1073 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, DISPLAY_PICTURE_SIZE) ); 1074 1075 /* Display picture size cmd */ 1076 cmd = 0; 1077 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_HEIGHT, ctx->display_picture_height - 1); 1078 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_WIDTH, ctx->display_picture_width - 1); 1079 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1080 1081 /* Coded picture size cmd */ 1082 cmd = 0; 1083 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_HEIGHT, ctx->coded_picture_height - 1); 1084 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_WIDTH, ctx->coded_picture_width - 1); 1085 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1086 1087 /* Operating mode cmd */ 1088 cmd = 0; 1089 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CHROMA_INTERLEAVED, 0); /* 0 = CbCr, 1 = CrCb */ 1090 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, ROW_STRIDE, ctx->obj_context->current_render_target->psb_surface->stride_mode); 1091 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_PROFILE, ctx->profile);/* MPEG4 SP / ASP profile */ 1092 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_MODE, 4); /* MPEG4 */ 1093 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, ASYNC_MODE, 1); /* VDMC only */ 1094 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, CHROMA_FORMAT, 1); 1095 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, OPERATING_MODE, INTERLACED, ctx->pic_params->vol_fields.bits.interlaced); 1096 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1097 ctx->obj_context->operating_mode = cmd; 1098 1099 psb__information_message(" vop_coding_type = %s\n", psb__debug_picture_coding_str(ctx->pic_params->vop_fields.bits.vop_coding_type)); 1100 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)); 1101 1102 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1103 psb_cmdbuf_rendec_write_address( cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs); 1104 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1105 psb_cmdbuf_rendec_write_address( cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 1106 1107 psb_cmdbuf_rendec_end( cmdbuf ); 1108 1109 /* Reference pictures base addresses */ 1110 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES) ); 1111 1112//psb__information_message("Target surface = %08x\n", target_surface); 1113//psb__information_message("Forward ref = %08x\n", ctx->forward_ref_surface->psb_surface); 1114//psb__information_message("Backward ref = %08x\n", ctx->backward_ref_surface->psb_surface); 1115 1116 /* forward reference picture */ 1117 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1118 psb_cmdbuf_rendec_write_address( cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface->buf.buffer_ofs); 1119 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1120 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); 1121 1122 /* backward reference picture */ 1123 /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1124 psb_cmdbuf_rendec_write_address( cmdbuf, &ctx->backward_ref_surface->psb_surface->buf, ctx->backward_ref_surface->psb_surface->buf.buffer_ofs); 1125 /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1126 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); 1127 1128 psb_cmdbuf_rendec_end( cmdbuf ); 1129 /* psb_cmdbuf_rendec_end_block( cmdbuf ); */ 1130} 1131 1132static void psb__MPEG4_set_backend_registers(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 1133{ 1134 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1135 uint32_t cmd; 1136 unsigned short width_mb = PIXELS_TO_MB(ctx->pic_params->vop_width); 1137 1138 /* psb_cmdbuf_rendec_start_block( cmdbuf ); */ 1139 1140 /* Write Back-End EntDec registers */ 1141 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_SPS0) ); 1142 /* BE_SPS0 */ 1143 /* Common for VOPs and pictures with short header */ 1144 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_SPS0 ); 1145 /* BE_SPS1 */ 1146 /* Common for VOPs and pictures with short header */ 1147 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_SPS1 ); 1148 psb_cmdbuf_rendec_end( cmdbuf ); 1149 1150 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_VOP_SPS0) ); 1151 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) 1152 { 1153 /* BE_VOP_SPS0 */ 1154 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_SPS0 ); 1155 /* BE_VOP_SPS1 */ 1156 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_SPS1 ); 1157 /* BE_VOP_PPS0 */ 1158 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_PPS0 ); 1159 } 1160 else /* Short-header mode */ 1161 { 1162 /* BE_VOP_SPS0 */ 1163 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1164 /* BE_VOP_SPS1 */ 1165 psb_cmdbuf_rendec_write( cmdbuf, 0 ); 1166 /* BE_VOP_PPS0 */ 1167 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_VOP_PPS0 ); 1168 /* BE_PICSH_PPS0 */ 1169 psb_cmdbuf_rendec_write( cmdbuf, ctx->BE_PICSH_PPS0 ); 1170 } 1171 psb_cmdbuf_rendec_end( cmdbuf ); 1172 1173 if (0 == ctx->pic_params->vol_fields.bits.short_video_header) { 1174 if ((GMC == ctx->pic_params->vol_fields.bits.sprite_enable) && 1175 (PICTURE_CODING_S == ctx->pic_params->vop_fields.bits.vop_coding_type)) 1176 { 1177 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_GMC_X) ); 1178 1179 /* TODO: GMC Motion Vectors */ 1180 /* It is still needed to specify the precision of the motion vectors (should they be in */ 1181 /* half-sample, quarter-sample...?) and how much processing is done on the firmware on */ 1182 /* the values of the warping points. */ 1183 1184 // TODO: Which index to use? 1185 int sprite_index = (ctx->pic_params->sprite_trajectory_du[0] || ctx->pic_params->sprite_trajectory_dv[0]) ? 0 : 1; 1186 1187 /* BE_GMC_X */ 1188 cmd = 0; 1189 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); 1190 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1191 1192 /* BE_GMC_Y */ 1193 cmd = 0; 1194 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); 1195 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1196 1197 psb_cmdbuf_rendec_end( cmdbuf ); 1198 } 1199 } 1200 1201 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG4_CR_VEC_MPEG4_BE_SLICE0) ); 1202 1203 /* BE_SLICE0 */ 1204 cmd = 0; 1205 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); 1206 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); 1207 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1208 1209 /* CR_VEC_MPEG4_BE_VOP_TR */ 1210 cmd = 0; 1211 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_TRB, BE_TRB, ctx->pic_params->TRB); 1212 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1213 1214 cmd = 0; 1215 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_BE_VOP_TRD, BE_TRD, ctx->pic_params->TRD); 1216 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1217 1218 psb_cmdbuf_rendec_end( cmdbuf ); 1219 1220 1221 /* Send Slice Data for every slice */ 1222 /* MUST be the last slice sent */ 1223 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, SLICE_PARAMS) ); 1224 1225 /* Slice params command */ 1226 cmd = 0; 1227 REGIO_WRITE_FIELD_LITE (cmd, 1228 MSVDX_CMDS, 1229 SLICE_PARAMS, 1230 RND_CTL_BIT, 1231 ((PICTURE_CODING_I == ctx->pic_params->vop_fields.bits.vop_coding_type || 1232 PICTURE_CODING_B == ctx->pic_params->vop_fields.bits.vop_coding_type) ? 1233 0 : ctx->pic_params->vop_fields.bits.vop_rounding_type)); 1234 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, MODE_CONFIG, ctx->pic_params->vol_fields.bits.sprite_warping_accuracy); 1235 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, SUBPEL_FILTER_MODE, ctx->pic_params->vol_fields.bits.quarter_sample); 1236 /* SP and ASP profiles don't support field coding in different VOPs */ 1237 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_FIELD_TYPE, 2); 1238 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_CODE_TYPE, ctx->pic_params->vop_fields.bits.vop_coding_type); 1239 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1240 1241 psb_cmdbuf_rendec_end( cmdbuf ); 1242 1243 *ctx->p_slice_params = cmd; 1244 1245 /* CHUNK: Entdec back-end profile and level */ 1246 psb_cmdbuf_rendec_start( cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL) ); 1247 1248 cmd = 0; 1249 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL, ENTDEC_BE_PROFILE, ctx->profile); /* MPEG4 SP / ASP profile*/ 1250 REGIO_WRITE_FIELD_LITE (cmd, MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL, ENTDEC_BE_MODE, 4); /* 4 - MPEG4 */ 1251 psb_cmdbuf_rendec_write( cmdbuf, cmd ); 1252 1253 psb_cmdbuf_rendec_end( cmdbuf ); 1254 /* psb_cmdbuf_rendec_end_block( cmdbuf ); */ 1255 1256 /* Send IQ matrices to Rendec */ 1257 psb__MPEG4_write_qmatrices(ctx); 1258} 1259 1260static void psb__MPEG4_set_frontend_registers(context_MPEG4_p ctx, VASliceParameterBufferMPEG4 *slice_param) 1261{ 1262 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1263 uint32_t FE_slice0; 1264 unsigned short width_mb = PIXELS_TO_MB(ctx->pic_params->vop_width); 1265 1266 psb_cmdbuf_reg_start_block( cmdbuf ); 1267 1268 /* FE_SLICE0 */ 1269 FE_slice0 = 0; 1270 REGIO_WRITE_FIELD_LITE (FE_slice0, MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0, FE_VOP_QUANT, slice_param->quant_scale); 1271 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); 1272 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); 1273 1274 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SLICE0) , FE_slice0 ); 1275 1276 /* Entdec Front-End controls*/ 1277 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC, CR_VEC_ENTDEC_FE_CONTROL) , ctx->FEControl ); 1278 1279 /* FE_SPS0 */ 1280 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_SPS0) , ctx->FE_SPS0 ); 1281 1282 /* FE_VOP_SPS0 */ 1283 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_SPS0) , ctx->FE_VOP_SPS0 ); 1284 1285 1286 if (ctx->pic_params->vol_fields.bits.short_video_header) 1287 { 1288 /* FE_PICSH_PPS0 */ 1289 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_PICSH_PPS0) , ctx->FE_PICSH_PPS0 ); 1290 } 1291 1292 /* FE_VOP_PPS0 */ 1293 psb_cmdbuf_reg_set( cmdbuf, REGISTER_OFFSET (MSVDX_VEC_MPEG4, CR_VEC_MPEG4_FE_VOP_PPS0) , ctx->FE_VOP_PPS0 ); 1294 1295 psb_cmdbuf_reg_end_block( cmdbuf ); 1296} 1297 1298/* 1299static void psb__MPEG4_FE_state(context_MPEG4_p ctx) 1300{ 1301 uint32_t lldma_record_offset; 1302 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1303 1304 *cmdbuf->cmd_idx++ = CMD_HEADER_VC1; 1305 1306 ctx->p_range_mapping_base0 = cmdbuf->cmd_idx++; 1307 ctx->p_range_mapping_base1 = cmdbuf->cmd_idx++; 1308 ctx->p_slice_params = cmdbuf->cmd_idx; 1309 *cmdbuf->cmd_idx++ = 0; 1310 1311 lldma_record_offset = psb_cmdbuf_lldma_create( cmdbuf, &(ctx->FE_state_buffer), 0, 1312 FE_STATE_SAVE_SIZE, 0, LLDMA_TYPE_MPEG4_FESTATE_SAVE ); 1313 RELOC(*cmdbuf->cmd_idx, lldma_record_offset, &(cmdbuf->buf)); 1314 cmdbuf->cmd_idx++; 1315 1316 lldma_record_offset = psb_cmdbuf_lldma_create( cmdbuf, &(ctx->FE_state_buffer), 0, 1317 FE_STATE_SAVE_SIZE, 0, LLDMA_TYPE_MPEG4_FESTATE_RESTORE ); 1318 RELOC(*cmdbuf->cmd_idx, lldma_record_offset, &(cmdbuf->buf)); 1319 cmdbuf->cmd_idx++; 1320 1321 ctx->slice_first_pic_last = cmdbuf->cmd_idx++; 1322} 1323*/ 1324static void psb__MPEG4_FE_state(context_MPEG4_p ctx) 1325{ 1326 uint32_t lldma_record_offset; 1327 psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1328 1329 *cmdbuf->cmd_idx++ = CMD_HEADER_VC1; 1330 ctx->p_slice_params = cmdbuf->cmd_idx; 1331 *cmdbuf->cmd_idx++ = 0; 1332 1333 1334 lldma_record_offset = psb_cmdbuf_lldma_create( cmdbuf, &(ctx->FE_state_buffer), 0, 1335 FE_STATE_SAVE_SIZE, 0, LLDMA_TYPE_MPEG4_FESTATE_SAVE ); 1336 RELOC(*cmdbuf->cmd_idx, lldma_record_offset, &(cmdbuf->buf)); 1337 cmdbuf->cmd_idx++; 1338 1339 lldma_record_offset = psb_cmdbuf_lldma_create( cmdbuf, &(ctx->FE_state_buffer), 0, 1340 FE_STATE_SAVE_SIZE, 0, LLDMA_TYPE_MPEG4_FESTATE_RESTORE ); 1341 RELOC(*cmdbuf->cmd_idx, lldma_record_offset, &(cmdbuf->buf)); 1342 cmdbuf->cmd_idx++; 1343 1344 ctx->slice_first_pic_last = cmdbuf->cmd_idx++; 1345 1346 ctx->p_range_mapping_base0 = cmdbuf->cmd_idx++; 1347 ctx->p_range_mapping_base1 = cmdbuf->cmd_idx++; 1348 1349 ctx->alt_output_flags = cmdbuf->cmd_idx++; 1350 *ctx->alt_output_flags = 0; 1351} 1352 1353static VAStatus psb__MPEG4_process_slice(context_MPEG4_p ctx, 1354 VASliceParameterBufferMPEG4 *slice_param, 1355 object_buffer_p obj_buffer) 1356{ 1357 VAStatus vaStatus = VA_STATUS_SUCCESS; 1358 1359 ASSERT((obj_buffer->type == VASliceDataBufferType) || (obj_buffer->type == VAProtectedSliceDataBufferType)); 1360 1361 psb__information_message("MPEG4 process slice\n"); 1362 psb__information_message(" size = %08x offset = %08x\n", slice_param->slice_data_size, slice_param->slice_data_offset); 1363 psb__information_message(" macroblock nr = %d offset = %d\n", slice_param->macroblock_number, slice_param->macroblock_offset); 1364 psb__information_message(" slice_data_flag = %d\n", slice_param->slice_data_flag); 1365 psb__information_message(" interlaced = %d\n", ctx->pic_params->vol_fields.bits.interlaced); 1366 psb__information_message(" coded size = %dx%d\n", ctx->picture_width_mb, ctx->picture_height_mb); 1367 1368 if ((slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_BEGIN) || 1369 (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_ALL)) 1370 { 1371 if (0 == slice_param->slice_data_size) 1372 { 1373 vaStatus = VA_STATUS_ERROR_UNKNOWN; 1374 DEBUG_FAILURE; 1375 return vaStatus; 1376 } 1377 ASSERT( !ctx->split_buffer_pending ); 1378 1379 /* Initialise the command buffer */ 1380 /* TODO: Reuse current command buffer until full */ 1381 psb_context_get_next_cmdbuf(ctx->obj_context); 1382 1383 psb_cmdbuf_lldma_write_bitstream(ctx->obj_context->cmdbuf, 1384 obj_buffer->psb_buffer, 1385 obj_buffer->psb_buffer->buffer_ofs + slice_param->slice_data_offset, 1386 slice_param->slice_data_size, 1387 slice_param->macroblock_offset, 1388 0); 1389 1390 if (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_BEGIN) 1391 { 1392 ctx->split_buffer_pending = TRUE; 1393 } 1394 } 1395 else 1396 { 1397 ASSERT( ctx->split_buffer_pending ); 1398 ASSERT(0 == slice_param->slice_data_offset); 1399 /* Create LLDMA chain to continue buffer */ 1400 if (slice_param->slice_data_size) 1401 { 1402 psb_cmdbuf_lldma_write_bitstream_chained(ctx->obj_context->cmdbuf, 1403 obj_buffer->psb_buffer, 1404 slice_param->slice_data_size); 1405 } 1406 } 1407 1408 if ((slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_ALL) || 1409 (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_END)) 1410 { 1411 if (slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_END) 1412 { 1413 ASSERT( ctx->split_buffer_pending ); 1414 } 1415 1416 psb__MPEG4_FE_state(ctx); 1417 1418 psb__MPEG4_write_VLC_tables(ctx); 1419 1420 psb__MPEG4_set_picture_params(ctx, slice_param); 1421 1422 psb__MPEG4_set_frontend_registers(ctx, slice_param); 1423 1424 psb__MPEG4_set_backend_registers(ctx, slice_param); 1425 1426 psb__MPEG4_write_kick(ctx, slice_param); 1427 1428 ctx->split_buffer_pending = FALSE; 1429 ctx->obj_context->video_op = psb_video_vld; 1430 ctx->obj_context->flags = 0; 1431 ctx->obj_context->first_mb = 0; 1432 ctx->obj_context->last_mb = ((ctx->picture_height_mb - 1) << 8) | (ctx->picture_width_mb - 1); 1433 1434 *ctx->slice_first_pic_last = (ctx->obj_context->first_mb << 16) | (ctx->obj_context->last_mb); 1435 1436 if (psb_context_submit_cmdbuf(ctx->obj_context)) 1437 { 1438 vaStatus = VA_STATUS_ERROR_UNKNOWN; 1439 } 1440 } 1441 return vaStatus; 1442} 1443 1444static VAStatus psb__MPEG4_process_slice_data(context_MPEG4_p ctx, object_buffer_p obj_buffer) 1445{ 1446 VAStatus vaStatus = VA_STATUS_SUCCESS; 1447 VASliceParameterBufferMPEG4 *slice_param; 1448 int buffer_idx = 0; 1449 int element_idx = 0; 1450 1451 1452 ASSERT((obj_buffer->type == VASliceDataBufferType) || (obj_buffer->type == VAProtectedSliceDataBufferType)); 1453 1454 ASSERT(ctx->pic_params); 1455 ASSERT(ctx->slice_param_list_idx); 1456 1457 if (!ctx->pic_params) 1458 { 1459 /* Picture params missing */ 1460 return VA_STATUS_ERROR_UNKNOWN; 1461 } 1462 if ((NULL == obj_buffer->psb_buffer) || 1463 (0 == obj_buffer->size)) 1464 { 1465 /* We need to have data in the bitstream buffer */ 1466 return VA_STATUS_ERROR_UNKNOWN; 1467 } 1468 1469 while(buffer_idx < ctx->slice_param_list_idx) 1470 { 1471 object_buffer_p slice_buf = ctx->slice_param_list[buffer_idx]; 1472 if (element_idx >= slice_buf->num_elements) 1473 { 1474 /* Move to next buffer */ 1475 element_idx = 0; 1476 buffer_idx++; 1477 continue; 1478 } 1479 1480 slice_param = (VASliceParameterBufferMPEG4 *) slice_buf->buffer_data; 1481 slice_param += element_idx; 1482 element_idx++; 1483 vaStatus = psb__MPEG4_process_slice(ctx, slice_param, obj_buffer); 1484 if (vaStatus != VA_STATUS_SUCCESS) 1485 { DEBUG_FAILURE; 1486 break; 1487 } 1488 } 1489 ctx->slice_param_list_idx = 0; 1490 1491 return vaStatus; 1492} 1493 1494static VAStatus pnw_MPEG4_BeginPicture( 1495 object_context_p obj_context) 1496{ 1497 INIT_CONTEXT_MPEG4 1498 1499 if (ctx->pic_params) 1500 { 1501 free(ctx->pic_params); 1502 ctx->pic_params = NULL; 1503 } 1504 ctx->load_non_intra_quant_mat = FALSE; 1505 ctx->load_intra_quant_mat = FALSE; 1506 1507 return VA_STATUS_SUCCESS; 1508} 1509 1510static VAStatus pnw_MPEG4_RenderPicture( 1511 object_context_p obj_context, 1512 object_buffer_p *buffers, 1513 int num_buffers) 1514{ 1515 int i; 1516 INIT_CONTEXT_MPEG4 1517 VAStatus vaStatus = VA_STATUS_SUCCESS; 1518 1519 for(i = 0; i < num_buffers; i++) 1520 { 1521 object_buffer_p obj_buffer = buffers[i]; 1522 1523 switch( obj_buffer->type) 1524 { 1525 case VAPictureParameterBufferType: 1526 psb__information_message("pnw_MPEG4_RenderPicture got VAPictureParameterBuffer\n"); 1527 vaStatus = psb__MPEG4_process_picture_param(ctx, obj_buffer); 1528 DEBUG_FAILURE; 1529 break; 1530 1531 case VAIQMatrixBufferType: 1532 psb__information_message("pnw_MPEG4_RenderPicture got VAIQMatrixBufferType\n"); 1533 vaStatus = psb__MPEG4_process_iq_matrix(ctx, obj_buffer); 1534 DEBUG_FAILURE; 1535 break; 1536 1537 case VASliceParameterBufferType: 1538 psb__information_message("pnw_MPEG4_RenderPicture got VASliceParameterBufferType\n"); 1539 vaStatus = psb__MPEG4_add_slice_param(ctx, obj_buffer); 1540 DEBUG_FAILURE; 1541 break; 1542 1543 case VASliceDataBufferType: 1544 case VAProtectedSliceDataBufferType: 1545 1546 psb__information_message("pnw_MPEG4_RenderPicture got %s\n", SLICEDATA_BUFFER_TYPE(obj_buffer->type)); 1547 vaStatus = psb__MPEG4_process_slice_data(ctx, obj_buffer); 1548 DEBUG_FAILURE; 1549 break; 1550 1551 default: 1552 vaStatus = VA_STATUS_ERROR_UNKNOWN; 1553 DEBUG_FAILURE; 1554 } 1555 if (vaStatus != VA_STATUS_SUCCESS) 1556 { 1557 break; 1558 } 1559 } 1560 1561 return vaStatus; 1562} 1563 1564static VAStatus pnw_MPEG4_EndPicture( 1565 object_context_p obj_context) 1566{ 1567 INIT_CONTEXT_MPEG4 1568 1569 if (psb_context_flush_cmdbuf(ctx->obj_context)) 1570 { 1571 return VA_STATUS_ERROR_UNKNOWN; 1572 } 1573 1574 if (ctx->pic_params) 1575 { 1576 free(ctx->pic_params); 1577 ctx->pic_params = NULL; 1578 } 1579 1580 return VA_STATUS_SUCCESS; 1581} 1582 1583struct format_vtable_s pnw_MPEG4_vtable = { 1584 queryConfigAttributes: pnw_MPEG4_QueryConfigAttributes, 1585 validateConfig: pnw_MPEG4_ValidateConfig, 1586 createContext: pnw_MPEG4_CreateContext, 1587 destroyContext: pnw_MPEG4_DestroyContext, 1588 beginPicture: pnw_MPEG4_BeginPicture, 1589 renderPicture: pnw_MPEG4_RenderPicture, 1590 endPicture: pnw_MPEG4_EndPicture 1591}; 1592