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