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