1437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/* 2f91c8768670386683a281cc39141e21bdda9c97fKun Wang * Copyright (c) 2011 Intel Corporation. All Rights Reserved. 33f3d1e8746d2b793c982ac19a73061e006b1b178Kun Wang * Copyright (c) Imagination Technologies Limited, UK 4437b3eda28a4bf098efa80598cab67f190275266Fei Jiang * 5f91c8768670386683a281cc39141e21bdda9c97fKun Wang * Permission is hereby granted, free of charge, to any person obtaining a 6f91c8768670386683a281cc39141e21bdda9c97fKun Wang * copy of this software and associated documentation files (the 7f91c8768670386683a281cc39141e21bdda9c97fKun Wang * "Software"), to deal in the Software without restriction, including 8f91c8768670386683a281cc39141e21bdda9c97fKun Wang * without limitation the rights to use, copy, modify, merge, publish, 9f91c8768670386683a281cc39141e21bdda9c97fKun Wang * distribute, sub license, and/or sell copies of the Software, and to 10f91c8768670386683a281cc39141e21bdda9c97fKun Wang * permit persons to whom the Software is furnished to do so, subject to 11f91c8768670386683a281cc39141e21bdda9c97fKun Wang * the following conditions: 123f3d1e8746d2b793c982ac19a73061e006b1b178Kun Wang * 13f91c8768670386683a281cc39141e21bdda9c97fKun Wang * The above copyright notice and this permission notice (including the 14f91c8768670386683a281cc39141e21bdda9c97fKun Wang * next paragraph) shall be included in all copies or substantial portions 15f91c8768670386683a281cc39141e21bdda9c97fKun Wang * of the Software. 163f3d1e8746d2b793c982ac19a73061e006b1b178Kun Wang * 17f91c8768670386683a281cc39141e21bdda9c97fKun Wang * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18f91c8768670386683a281cc39141e21bdda9c97fKun Wang * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19f91c8768670386683a281cc39141e21bdda9c97fKun Wang * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20f91c8768670386683a281cc39141e21bdda9c97fKun Wang * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 21f91c8768670386683a281cc39141e21bdda9c97fKun Wang * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22f91c8768670386683a281cc39141e21bdda9c97fKun Wang * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23f91c8768670386683a281cc39141e21bdda9c97fKun Wang * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun * 25bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang * Authors: 26bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang * Waldo Bastian <waldo.bastian@intel.com> 2706c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng * Li Zeng <li.zeng@intel.com> 28bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang * 29bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang */ 30437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 31437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "pnw_MPEG2.h" 3206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng#include "tng_vld_dec.h" 33437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "psb_def.h" 34c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang#include "psb_drv_debug.h" 35f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang#include "pnw_rotate.h" 36437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 37437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "hwdefs/reg_io2.h" 38437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "hwdefs/msvdx_offsets.h" 39437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "hwdefs/msvdx_cmds_io2.h" 40437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "hwdefs/msvdx_vec_reg_io2.h" 41437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "hwdefs/msvdx_vec_mpeg2_reg_io2.h" 42437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include "hwdefs/dxva_fw_ctrl.h" 43437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 44437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include <stdlib.h> 45437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include <stdint.h> 46437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#include <string.h> 47437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 48437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define GET_SURFACE_INFO_is_defined(psb_surface) ((int) (psb_surface->extra_info[0])) 49437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define SET_SURFACE_INFO_is_defined(psb_surface, val) psb_surface->extra_info[0] = (uint32_t) val; 50437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define GET_SURFACE_INFO_picture_structure(psb_surface) (psb_surface->extra_info[1]) 51437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define SET_SURFACE_INFO_picture_structure(psb_surface, val) psb_surface->extra_info[1] = val; 52437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define GET_SURFACE_INFO_picture_coding_type(psb_surface) ((int) (psb_surface->extra_info[2])) 53437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define SET_SURFACE_INFO_picture_coding_type(psb_surface, val) psb_surface->extra_info[2] = (uint32_t) val; 54437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 55437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define SLICEDATA_BUFFER_TYPE(type) ((type==VASliceDataBufferType)?"VASliceDataBufferType":"VAProtectedSliceDataBufferType") 56437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 57437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/* 58437b3eda28a4bf098efa80598cab67f190275266Fei Jiang * Frame types - format dependant! 59437b3eda28a4bf098efa80598cab67f190275266Fei Jiang */ 60437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define PICTURE_CODING_I 0x01 61437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define PICTURE_CODING_P 0x02 62437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define PICTURE_CODING_B 0x03 63dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun/* A special syntax is defined for D-pictures (picture_coding_type = 4). D-pictures are like I-pictures with only Intra-DC coefficients, 64437b3eda28a4bf098efa80598cab67f190275266Fei Jiang no End of Block, and a special end_of_macroblock code '1'. PICTURE_CODING_D is not allowed in MPEG2 */ 65dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun#define PICTURE_CODING_D 0x04 66437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 67f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang#define HW_SUPPORTED_MAX_PICTURE_WIDTH_MPEG2_MP 1920 68f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang#define HW_SUPPORTED_MAX_PICTURE_HEIGHT_MPEG2_MP 1088 69f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 70f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang#define HW_SUPPORTED_MAX_PICTURE_WIDTH_MPEG2_SP 352 71f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang#define HW_SUPPORTED_MAX_PICTURE_HEIGHT_MPEG2_SP 288 72f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 73f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang#define CACHE_REF_OFFSET 72 74f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang#define CACHE_ROW_OFFSET 4 75f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 76437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/************************************************************************************/ 77437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/* Variable length codes in 'packed' format */ 78437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/************************************************************************************/ 79437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 80437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/* Format is: opcode, width, symbol. All VLC tables are concatenated. Index */ 81437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/* infomation is stored in gui16mpeg2VlcIndexData[] */ 82dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun#define VLC_PACK(a,b,c) ( ( (a) << 12 ) | ( (b) << 9 ) | (c) ) 83e9f11f100c212e9aeb194337ae43bbfea6a130dbKun Wangstatic const IMG_UINT16 gaui16mpeg2VlcTableDataPacked[] = { 84dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(6 , 0 , 0) , 85dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 6) , 86dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 4) , 87dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 5) , 88dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 4 , 6) , 89dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 5 , 7) , 90dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(1 , 1 , 3) , 91dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 0 , 0) , 92dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 0 , 3) , 93dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 0 , 8) , 94dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 9) , 95dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 5) , 96dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 0) , 97dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 2) , 98dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 3) , 99dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 4) , 100dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 4 , 5) , 101dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 5 , 6) , 102dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(1 , 2 , 1) , 103dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 0 , 7) , 104dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 8) , 105dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 9) , 106dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 5) , 107dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 2 , 16) , 108dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 87) , 109dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 3 , 90) , 110dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 98) , 111dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 253) , 112dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 366) , 113dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 380) , 114dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 381) , 115dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 508) , 116dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 508) , 117dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 508) , 118dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 508) , 119dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 509) , 120dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 509) , 121dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 509) , 122dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 509) , 123dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 4 , 8) , 124dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 2 , 63) , 125dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 255) , 126dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 255) , 127dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 365) , 128dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 470) , 129dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 251) , 130dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 471) , 131dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 4 , 0) , 132dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 31) , 133dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 40) , 134dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 2 , 41) , 135dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 224) , 136dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 228) , 137dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 232) , 138dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 236) , 139dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 437) , 140dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 39) , 141dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 40) , 142dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 41) , 143dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 241) , 144dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 41) , 145dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 454) , 146dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 456) , 147dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 244) , 148dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 439) , 149dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 348) , 150dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 245) , 151dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 363) , 152dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 325) , 153dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 458) , 154dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 459) , 155dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 246) , 156dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 460) , 157dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 461) , 158dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 186) , 159dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 356) , 160dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 247) , 161dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 333) , 162dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 462) , 163dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 173) , 164dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 1 , 3) , 165dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(1 , 1 , 5) , 166dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 449) , 167dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 432) , 168dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 431) , 169dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 332) , 170dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 434) , 171dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 436) , 172dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 448) , 173dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 215) , 174dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 219) , 175dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 180) , 176dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 178) , 177dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 177) , 178dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 223) , 179dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 340) , 180dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 355) , 181dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 362) , 182dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 184) , 183dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 185) , 184dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 240) , 185dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 243) , 186dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 453) , 187dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 463) , 188dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 341) , 189dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 248) , 190dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 364) , 191dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 187) , 192dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 464) , 193dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 465) , 194dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 349) , 195dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 326) , 196dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 334) , 197dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 189) , 198dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 342) , 199dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 252) , 200dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 4) , 201dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 467) , 202dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 249) , 203dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 466) , 204dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 357) , 205dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 188) , 206dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 250) , 207dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 469) , 208dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 350) , 209dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 358) , 210dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 2 , 16) , 211dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 87) , 212dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 3 , 90) , 213dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 98) , 214dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 253) , 215dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 366) , 216dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 380) , 217dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 381) , 218dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 254) , 219dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 254) , 220dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 254) , 221dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 254) , 222dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 508) , 223dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 508) , 224dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 509) , 225dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 509) , 226dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 4 , 8) , 227dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 2 , 63) , 228dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 255) , 229dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 1 , 255) , 230dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 365) , 231dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 470) , 232dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 251) , 233dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 471) , 234dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 4 , 0) , 235dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 31) , 236dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 40) , 237dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 2 , 41) , 238dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 224) , 239dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 228) , 240dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 232) , 241dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 236) , 242dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 437) , 243dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 39) , 244dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 40) , 245dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 41) , 246dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 241) , 247dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 41) , 248dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 454) , 249dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 456) , 250dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 244) , 251dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 439) , 252dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 348) , 253dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 245) , 254dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 363) , 255dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 325) , 256dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 458) , 257dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 459) , 258dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 246) , 259dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 460) , 260dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 461) , 261dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 186) , 262dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 356) , 263dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 247) , 264dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 333) , 265dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 462) , 266dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 173) , 267dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 1 , 3) , 268dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(1 , 1 , 5) , 269dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 449) , 270dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 432) , 271dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 431) , 272dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 332) , 273dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 434) , 274dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 436) , 275dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 448) , 276dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 215) , 277dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 219) , 278dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 180) , 279dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 178) , 280dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 177) , 281dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 223) , 282dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 340) , 283dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 355) , 284dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 362) , 285dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 184) , 286dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 185) , 287dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 240) , 288dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 243) , 289dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 453) , 290dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 463) , 291dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 341) , 292dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 248) , 293dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 364) , 294dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 187) , 295dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 464) , 296dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 465) , 297dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 349) , 298dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 326) , 299dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 334) , 300dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 189) , 301dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 342) , 302dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 252) , 303dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 4) , 304dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 467) , 305dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 249) , 306dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 466) , 307dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 357) , 308dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 188) , 309dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 250) , 310dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 469) , 311dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 350) , 312dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 358) , 313dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 2 , 32) , 314dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 87) , 315dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 248) , 316dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 89) , 317dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(1 , 2 , 90) , 318dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 366) , 319dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 189) , 320dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 358) , 321dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 380) , 322dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 380) , 323dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 381) , 324dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 381) , 325dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 254) , 326dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 254) , 327dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 4 , 504) , 328dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 4 , 505) , 329dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 508) , 330dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 508) , 331dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 508) , 332dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 508) , 333dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 509) , 334dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 509) , 335dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 509) , 336dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 509) , 337dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 506) , 338dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 506) , 339dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 507) , 340dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 3 , 507) , 341dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 251) , 342dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 250) , 343dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 71) , 344dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 2 , 74) , 345dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 0 , 255) , 346dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 3) , 347dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 2 , 8) , 348dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 3 , 17) , 349dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 341) , 350dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 465) , 351dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 2) , 352dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 464) , 353dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 363) , 354dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 463) , 355dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 438) , 356dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 348) , 357dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 324) , 358dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 458) , 359dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 459) , 360dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 461) , 361dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 356) , 362dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 1) , 363dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 333) , 364dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 462) , 365dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 3 , 0) , 366dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 15) , 367dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 24) , 368dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 2 , 25) , 369dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 224) , 370dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 228) , 371dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 232) , 372dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 236) , 373dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 437) , 374dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 23) , 375dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 24) , 376dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 185) , 377dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 3 , 0) , 378dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 452) , 379dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 454) , 380dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 456) , 381dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 173) , 382dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 1 , 3) , 383dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(1 , 1 , 5) , 384dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 449) , 385dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 432) , 386dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 431) , 387dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 332) , 388dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 434) , 389dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 436) , 390dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 448) , 391dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 215) , 392dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 219) , 393dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 180) , 394dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 178) , 395dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 177) , 396dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 223) , 397dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 340) , 398dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 355) , 399dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 362) , 400dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 184) , 401dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 326) , 402dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 471) , 403dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 334) , 404dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 365) , 405dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 350) , 406dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 342) , 407dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 1 , 4) , 408dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 466) , 409dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 357) , 410dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 187) , 411dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 244) , 412dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 468) , 413dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 186) , 414dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 470) , 415dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 188) , 416dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 469) , 417dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 247) , 418dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 492) , 419dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 493) , 420dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 243) , 421dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 242) , 422dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 364) , 423dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 349) , 424dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 241) , 425dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 240) , 426dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 0 , 30) , 427dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 14) , 428dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 13) , 429dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 12) , 430dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 3) , 431dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 2 , 4) , 432dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 1 , 7) , 433dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 9) , 434dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 11) , 435dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 8) , 436dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 6) , 437dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 5) , 438dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 3) , 439dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 1 , 0) , 440dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 2 , 3) , 441dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 1 , 0) , 442dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 1 , 5) , 443dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 2 , 0) , 444dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 2 , 0) , 445dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 2 , 0) , 446dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 2 , 226) , 447dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 1) , 448dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 0) , 449dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 31) , 450dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(4 , 0 , 62) , 451dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 30) , 452dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 29) , 453dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 28) , 454dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(0 , 0 , 3) , 455dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(2 , 2 , 4) , 456dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(1 , 1 , 7) , 457dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 25) , 458dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 27) , 459dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 24) , 460dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 22) , 461dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 0 , 21) , 462dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 1 , 19) , 463dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 1 , 0) , 464dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(3 , 1 , 0) , 465dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun VLC_PACK(5 , 2 , 15) 466437b3eda28a4bf098efa80598cab67f190275266Fei Jiang}; 467437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 468437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define MAX_QUANT_TABLES (2) /* only 2 tables for 4:2:0 decode */ 469437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 470bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wangstatic int scan0[64] = { // spec, fig 7-2 471bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang /*u 0 ..... 7*/ 472437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 0, 1, 5, 6, 14, 15, 27, 28, /* v = 0 */ 473437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 2, 4, 7, 13, 16, 26, 29, 42, 474437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 3, 8, 12, 17, 25, 30, 41, 43, 475437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 9, 11, 18, 24, 31, 40, 44, 53, 476437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 10, 19, 23, 32, 39, 45, 52, 54, 477437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 20, 22, 33, 38, 46, 51, 55, 60, 478437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 21, 34, 37, 47, 50, 56, 59, 61, 479437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 35, 36, 48, 49, 57, 58, 62, 63 /* v = 7 */ 480437b3eda28a4bf098efa80598cab67f190275266Fei Jiang}; 481dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 482dc1209519284865899ca8d990b3a2c7dbca8ae08wangkuntypedef enum { 483437b3eda28a4bf098efa80598cab67f190275266Fei Jiang NONINTRA_LUMA_Q = 0, 484437b3eda28a4bf098efa80598cab67f190275266Fei Jiang INTRA_LUMA_Q = 1 485437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} QUANT_IDX; 486437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 487437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstruct context_MPEG2_s { 48806c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng struct context_DEC_s dec_ctx; 489437b3eda28a4bf098efa80598cab67f190275266Fei Jiang object_context_p obj_context; /* back reference */ 490437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 491437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Picture parameters */ 492437b3eda28a4bf098efa80598cab67f190275266Fei Jiang VAPictureParameterBufferMPEG2 *pic_params; 493437b3eda28a4bf098efa80598cab67f190275266Fei Jiang object_surface_p forward_ref_surface; 494437b3eda28a4bf098efa80598cab67f190275266Fei Jiang object_surface_p backward_ref_surface; 495437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 496437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t coded_picture_width; /* in pixels */ 497437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t coded_picture_height; /* in pixels */ 498437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 499437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t picture_width_mb; /* in macroblocks */ 500437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t picture_height_mb; /* in macroblocks */ 501437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t size_mb; /* in macroblocks */ 502437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 503437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t coded_picture_size; /* MSVDX format */ 504437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t display_picture_size; /* MSVDX format */ 505437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 506437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t BE_PPS0; 507437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t BE_PPS1; 508437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t BE_PPS2; 509437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t BE_SPS0; 510437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t BE_SPS1; 511437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t FE_PPS0; 512437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t FE_PPS1; 513437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 514f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang uint32_t slice_count; 515f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 516437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* IQ Matrix */ 517437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t qmatrix_data[MAX_QUANT_TABLES][16]; 518437b3eda28a4bf098efa80598cab67f190275266Fei Jiang int got_iq_matrix; 519437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 520437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* VLC packed data */ 521437b3eda28a4bf098efa80598cab67f190275266Fei Jiang struct psb_buffer_s vlc_packed_table; 522dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 523437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Misc */ 524437b3eda28a4bf098efa80598cab67f190275266Fei Jiang unsigned int previous_slice_vertical_position; 525437b3eda28a4bf098efa80598cab67f190275266Fei Jiang}; 526437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 527437b3eda28a4bf098efa80598cab67f190275266Fei Jiangtypedef struct context_MPEG2_s *context_MPEG2_p; 528437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 529437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define INIT_CONTEXT_MPEG2 context_MPEG2_p ctx = (context_MPEG2_p) obj_context->format_data; 530437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 531437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define SURFACE(id) ((object_surface_p) object_heap_lookup( &ctx->obj_context->driver_data->surface_heap, id )) 532437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 533437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 534437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void pnw_MPEG2_QueryConfigAttributes( 535cecb10be5449aa74cd1d9a2eb41c2a6a76d9ee79ywan VAProfile __maybe_unused profile, 536cecb10be5449aa74cd1d9a2eb41c2a6a76d9ee79ywan VAEntrypoint __maybe_unused entrypoint, 537cecb10be5449aa74cd1d9a2eb41c2a6a76d9ee79ywan VAConfigAttrib __maybe_unused * attrib_list, 538cecb10be5449aa74cd1d9a2eb41c2a6a76d9ee79ywan int __maybe_unused num_attribs) 539437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 540f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang int i; 541f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang drv_debug_msg(VIDEO_DEBUG_GENERAL, "pnw_MPEG2_QueryConfigAttributes\n"); 542f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 543f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang for (i = 0; i < num_attribs; i++) { 544f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang switch (attrib_list[i].type) { 545f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang case VAConfigAttribMaxPictureWidth: 546f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang if (entrypoint == VAEntrypointVLD) { 547f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang if (profile == VAProfileMPEG2Simple) 548f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_WIDTH_MPEG2_SP; 549f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang else if(profile == VAProfileMPEG2Main) 550f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_WIDTH_MPEG2_MP; 551f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang else 552f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; 553f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang } 554f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang else 555f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; 556f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang break; 557f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang case VAConfigAttribMaxPictureHeight: 558f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang if (entrypoint == VAEntrypointVLD) { 559f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang if (profile == VAProfileMPEG2Simple) 560f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_HEIGHT_MPEG2_SP; 561f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang else if(profile == VAProfileMPEG2Main) 562f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang attrib_list[i].value = HW_SUPPORTED_MAX_PICTURE_HEIGHT_MPEG2_MP; 563f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang } 564f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang else 565f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; 566f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang break; 567f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang default: 568f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang break; 569f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang } 570f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang } 571f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 572437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 573437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 574437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic VAStatus pnw_MPEG2_ValidateConfig( 575dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun object_config_p obj_config) 576437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 577437b3eda28a4bf098efa80598cab67f190275266Fei Jiang int i; 578437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Check all attributes */ 579dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun for (i = 0; i < obj_config->attrib_count; i++) { 580dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun switch (obj_config->attrib_list[i].type) { 581dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case VAConfigAttribRTFormat: 582dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* Ignore */ 583dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 584dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 585dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun default: 586dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; 587437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 588437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 589437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 590437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return VA_STATUS_SUCCESS; 591437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 592437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 593437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic VAStatus psb__MPEG2_check_legal_picture(object_context_p obj_context, object_config_p obj_config) 594437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 595437b3eda28a4bf098efa80598cab67f190275266Fei Jiang VAStatus vaStatus = VA_STATUS_SUCCESS; 596437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 5976d37ae34fcae80f2e898b61e2506ed8e887bd16anguo CHECK_CONTEXT(obj_context); 5986d37ae34fcae80f2e898b61e2506ed8e887bd16anguo CHECK_CONFIG(obj_config); 599437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 600437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* MSVDX decode capability for MPEG2: 601437b3eda28a4bf098efa80598cab67f190275266Fei Jiang * MP@HL 602437b3eda28a4bf098efa80598cab67f190275266Fei Jiang * 603dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun * Refer to Table 8-11 (Upper bounds for luminance sample rate) of ISO/IEC 13818-2: 1995(E), 604437b3eda28a4bf098efa80598cab67f190275266Fei Jiang * and the "MSVDX MPEG2 decode capability" table of "Poulsbo Media Software Overview" 605437b3eda28a4bf098efa80598cab67f190275266Fei Jiang */ 606437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 607dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun switch (obj_config->profile) { 608dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case VAProfileMPEG2Simple: 609dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if ((obj_context->picture_width <= 0) || (obj_context->picture_width > 352) 610bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang || (obj_context->picture_height <= 0) || (obj_context->picture_height > 288)) { 611dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun vaStatus = VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; 612dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } 613dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 614437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 615dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case VAProfileMPEG2Main: 616dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if ((obj_context->picture_width <= 0) || (obj_context->picture_width > 1920) 617bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang || (obj_context->picture_height <= 0) || (obj_context->picture_height > 1088)) { 618dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun vaStatus = VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; 619dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } 620dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 621437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 622dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun default: 623dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; 624dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 625437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 626437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 627437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return vaStatus; 628437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 629437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 630437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void pnw_MPEG2_DestroyContext(object_context_p obj_context); 63106c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic void psb__MPEG2_process_slice_data(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param); 63206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic void psb__MPEG2_end_slice(context_DEC_p dec_ctx); 63306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic void psb__MPEG2_begin_slice(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param); 63406c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic VAStatus pnw_MPEG2_process_buffer(context_DEC_p dec_ctx, object_buffer_p buffer); 635437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 636437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic VAStatus pnw_MPEG2_CreateContext( 637dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun object_context_p obj_context, 638dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun object_config_p obj_config) 639437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 640437b3eda28a4bf098efa80598cab67f190275266Fei Jiang VAStatus vaStatus = VA_STATUS_SUCCESS; 641437b3eda28a4bf098efa80598cab67f190275266Fei Jiang context_MPEG2_p ctx; 642437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Validate flag */ 643437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Validate picture dimensions */ 644437b3eda28a4bf098efa80598cab67f190275266Fei Jiang vaStatus = psb__MPEG2_check_legal_picture(obj_context, obj_config); 6456d37ae34fcae80f2e898b61e2506ed8e887bd16anguo CHECK_VASTATUS(); 6466d37ae34fcae80f2e898b61e2506ed8e887bd16anguo 6476d37ae34fcae80f2e898b61e2506ed8e887bd16anguo CHECK_INVALID_PARAM(obj_context->num_render_targets < 1); 648dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 6492befccec034c13d34746a9e87149889d59ac767bFei Jiang ctx = (context_MPEG2_p) calloc(1, sizeof(struct context_MPEG2_s)); 6506d37ae34fcae80f2e898b61e2506ed8e887bd16anguo CHECK_ALLOCATION(ctx); 6512befccec034c13d34746a9e87149889d59ac767bFei Jiang 652437b3eda28a4bf098efa80598cab67f190275266Fei Jiang obj_context->format_data = (void*) ctx; 653437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->obj_context = obj_context; 654437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->pic_params = NULL; 655437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->got_iq_matrix = FALSE; 656437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->previous_slice_vertical_position = ~1; 657dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 65806c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.begin_slice = psb__MPEG2_begin_slice; 65906c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.process_slice = psb__MPEG2_process_slice_data; 66006c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.end_slice = psb__MPEG2_end_slice; 66106c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.process_buffer = pnw_MPEG2_process_buffer; 66206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.preload_buffer = NULL; 663437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 664dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (vaStatus == VA_STATUS_SUCCESS) { 665dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun vaStatus = psb_buffer_create(obj_context->driver_data, 666dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun sizeof(gaui16mpeg2VlcTableDataPacked), 667dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_bt_cpu_vpu, 668dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun &ctx->vlc_packed_table); 669437b3eda28a4bf098efa80598cab67f190275266Fei Jiang DEBUG_FAILURE; 670437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 671dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (vaStatus == VA_STATUS_SUCCESS) { 672e9f11f100c212e9aeb194337ae43bbfea6a130dbKun Wang unsigned char *vlc_packed_data_address; 673dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (0 == psb_buffer_map(&ctx->vlc_packed_table, &vlc_packed_data_address)) { 674dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun memcpy(vlc_packed_data_address, gaui16mpeg2VlcTableDataPacked, sizeof(gaui16mpeg2VlcTableDataPacked)); 675dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_buffer_unmap(&ctx->vlc_packed_table); 676dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } else { 677437b3eda28a4bf098efa80598cab67f190275266Fei Jiang vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; 678437b3eda28a4bf098efa80598cab67f190275266Fei Jiang DEBUG_FAILURE; 679437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 680437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 681dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 68206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng if (vaStatus == VA_STATUS_SUCCESS) { 68306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng vaStatus = vld_dec_CreateContext(&ctx->dec_ctx, obj_context); 68406c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng DEBUG_FAILURE; 68506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng } 68606c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng 687dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (vaStatus != VA_STATUS_SUCCESS) { 688437b3eda28a4bf098efa80598cab67f190275266Fei Jiang pnw_MPEG2_DestroyContext(obj_context); 689437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 690437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 691437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return vaStatus; 692437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 693437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 694437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void pnw_MPEG2_DestroyContext( 695dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun object_context_p obj_context) 696437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 697437b3eda28a4bf098efa80598cab67f190275266Fei Jiang INIT_CONTEXT_MPEG2 698437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 69906c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng vld_dec_DestroyContext(&ctx->dec_ctx); 70006c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng 701dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_buffer_destroy(&ctx->vlc_packed_table); 702437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 703dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (ctx->pic_params) { 704437b3eda28a4bf098efa80598cab67f190275266Fei Jiang free(ctx->pic_params); 705437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->pic_params = NULL; 706437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 707437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 708437b3eda28a4bf098efa80598cab67f190275266Fei Jiang free(obj_context->format_data); 709437b3eda28a4bf098efa80598cab67f190275266Fei Jiang obj_context->format_data = NULL; 710437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 711437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 712437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic VAStatus psb__MPEG2_process_picture_param(context_MPEG2_p ctx, object_buffer_p obj_buffer) 713437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 71455dbfaffb153fbec01e82c471b7ea5bf7bcac5femahongpe object_surface_p obj_surface = ctx->obj_context->current_render_target; 715437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ASSERT(obj_buffer->type == VAPictureParameterBufferType); 716437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ASSERT(obj_buffer->num_elements == 1); 717437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ASSERT(obj_buffer->size == sizeof(VAPictureParameterBufferMPEG2)); 718dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 719437b3eda28a4bf098efa80598cab67f190275266Fei Jiang if ((obj_buffer->num_elements != 1) || 720bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang (obj_buffer->size != sizeof(VAPictureParameterBufferMPEG2))) { 721437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return VA_STATUS_ERROR_UNKNOWN; 722437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 723437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 724437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Transfer ownership of VAPictureParameterBufferMPEG2 data */ 725dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (ctx->pic_params) { 726437b3eda28a4bf098efa80598cab67f190275266Fei Jiang free(ctx->pic_params); 727437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 728437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->pic_params = (VAPictureParameterBufferMPEG2 *) obj_buffer->buffer_data; 729437b3eda28a4bf098efa80598cab67f190275266Fei Jiang obj_buffer->buffer_data = NULL; 730437b3eda28a4bf098efa80598cab67f190275266Fei Jiang obj_buffer->size = 0; 731437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 732437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Lookup surfaces for backward/forward references */ 733dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun switch (ctx->pic_params->picture_coding_type) { 734dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case PICTURE_CODING_I: 735dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ctx->forward_ref_surface = NULL; 736dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ctx->backward_ref_surface = NULL; 737dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 738dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 739dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case PICTURE_CODING_P: 740dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 741dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ctx->backward_ref_surface = NULL; 742dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (NULL == ctx->forward_ref_surface) { 743dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun return VA_STATUS_ERROR_INVALID_SURFACE; 744dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } 745dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 746dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 747dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case PICTURE_CODING_B: 748dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ctx->forward_ref_surface = SURFACE(ctx->pic_params->forward_reference_picture); 749dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ctx->backward_ref_surface = SURFACE(ctx->pic_params->backward_reference_picture); 750dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if ((NULL == ctx->forward_ref_surface) || 751bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang (NULL == ctx->backward_ref_surface)) { 752dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun return VA_STATUS_ERROR_INVALID_SURFACE; 753dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } 754dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 755dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 756dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun default: 757dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun return VA_STATUS_ERROR_UNKNOWN; 758437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 759437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 760437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->picture_width_mb = (ctx->pic_params->horizontal_size + 15) / 16; 761dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (ctx->obj_context->va_flags & VA_PROGRESSIVE) { 762437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->picture_height_mb = (ctx->pic_params->vertical_size + 15) / 16; 763dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } else { 764437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->picture_height_mb = (ctx->pic_params->vertical_size + 31) / 32; 765437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->picture_height_mb *= 2; 766437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 767437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->coded_picture_width = ctx->picture_width_mb * 16; 768437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->coded_picture_height = ctx->picture_height_mb * 16; 769437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 77055dbfaffb153fbec01e82c471b7ea5bf7bcac5femahongpe if (obj_surface->share_info) { 77155dbfaffb153fbec01e82c471b7ea5bf7bcac5femahongpe obj_surface->share_info->coded_width = ctx->coded_picture_width; 77220f2ef257b798a174166858314731050410e31f4mahongpe obj_surface->share_info->coded_height = ctx->coded_picture_height; 77355dbfaffb153fbec01e82c471b7ea5bf7bcac5femahongpe } 77455dbfaffb153fbec01e82c471b7ea5bf7bcac5femahongpe 775437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->size_mb = ctx->picture_width_mb * ctx->picture_height_mb; 776437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 777dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* Display picture size */ 778437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->display_picture_size = 0; 779dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* 780dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun * coded_picture_width/height is aligned to the size of a macroblock.. 781dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun * Both coded_picture_height or vertical_size can be used for DISPLAY_SIZE and both give correct results, 782dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun * however Vista driver / test app uses the aligned value that's in coded_picture_height so we do too. 783dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun * See e.g. low4.m2v for an example clip where vertical_size will differ from coded_picture_height 784dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun */ 785437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#if 0 786dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->display_picture_size, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_HEIGHT, ctx->pic_params->vertical_size - 1); 787dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->display_picture_size, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_WIDTH, ctx->pic_params->horizontal_size - 1); 788437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#else 789dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->display_picture_size, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_HEIGHT, ctx->coded_picture_height - 1); 790dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->display_picture_size, MSVDX_CMDS, DISPLAY_PICTURE_SIZE, DISPLAY_PICTURE_WIDTH, ctx->coded_picture_width - 1); 791437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#endif 792437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 793437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Coded picture size */ 794437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->coded_picture_size = 0; 795dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->coded_picture_size, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_HEIGHT, ctx->coded_picture_height - 1); 796dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->coded_picture_size, MSVDX_CMDS, CODED_PICTURE_SIZE, CODED_PICTURE_WIDTH, ctx->coded_picture_width - 1); 797dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 798437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->BE_SPS0 = 0; 799dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_SPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_SPS0, BE_HORIZONTAL_SIZE_MINUS1, ctx->picture_width_mb - 1); 800437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 801437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->BE_SPS1 = 0; 802dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_SPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_SPS1, BE_VERTICAL_SIZE_MINUS1, ctx->picture_height_mb); 803437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 804437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->FE_PPS0 = 0; 805dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_ALTERNATE_SCAN, !!(ctx->pic_params->picture_coding_extension.bits.alternate_scan)); 806dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_Q_SCALE_TYPE, !!(ctx->pic_params->picture_coding_extension.bits.q_scale_type)); 807dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_INTRA_DC_PRECISION, ctx->pic_params->picture_coding_extension.bits.intra_dc_precision); 808dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_TOP_FIELD_FIRST, !!(ctx->pic_params->picture_coding_extension.bits.top_field_first)); 809dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_CONCEALMENT_MOTION_VECTORS, !!(ctx->pic_params->picture_coding_extension.bits.concealment_motion_vectors)); 810dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_FRAME_PRED_FRAME_DCT, !!(ctx->pic_params->picture_coding_extension.bits.frame_pred_frame_dct)); 811dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_PICTURE_STRUCTURE, ctx->pic_params->picture_coding_extension.bits.picture_structure); 812dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0, FE_INTRA_VLC_FORMAT, !!(ctx->pic_params->picture_coding_extension.bits.intra_vlc_format)); 813437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 814437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->FE_PPS1 = 0; 815dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS1, FE_PICTURE_CODING_TYPE, ctx->pic_params->picture_coding_type); 816dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS1, FE_F_CODE00, (ctx->pic_params->f_code >> 12) & 0x0F); 817dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS1, FE_F_CODE01, (ctx->pic_params->f_code >> 8) & 0x0F); 818dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS1, FE_F_CODE10, (ctx->pic_params->f_code >> 4) & 0x0F); 819dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->FE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS1, FE_F_CODE11, (ctx->pic_params->f_code >> 0) & 0x0F); 820437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 821437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* VEC Control register: Back-End MPEG2 PPS0 */ 822437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->BE_PPS0 = 0; 823dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS0, BE_FRAME_PRED_FRAME_DCT, !!(ctx->pic_params->picture_coding_extension.bits.frame_pred_frame_dct)); 824dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS0, BE_INTRA_DC_PRECISION, ctx->pic_params->picture_coding_extension.bits.intra_dc_precision); 825dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS0, BE_Q_SCALE_TYPE, !!(ctx->pic_params->picture_coding_extension.bits.q_scale_type)); 826dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS0, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS0, BE_ALTERNATE_SCAN, !!(ctx->pic_params->picture_coding_extension.bits.alternate_scan)); 827437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 828437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->BE_PPS1 = 0; 829dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS1, BE_F_CODE00, (ctx->pic_params->f_code >> 12) & 0x0F); 830dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS1, BE_F_CODE01, (ctx->pic_params->f_code >> 8) & 0x0F); 831dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS1, BE_F_CODE10, (ctx->pic_params->f_code >> 4) & 0x0F); 832dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS1, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS1, BE_F_CODE11, (ctx->pic_params->f_code >> 0) & 0x0F); 833437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 834437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* VEC Control register: Back-End MPEG2 PPS2 */ 835437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->BE_PPS2 = 0; 836dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS2, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS2, BE_PICTURE_CODING_TYPE, ctx->pic_params->picture_coding_type); 837dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS2, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS2, BE_TOP_FIELD_FIRST, !!(ctx->pic_params->picture_coding_extension.bits.top_field_first)); 838dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS2, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS2, BE_CONCEALMENT_MOTION_VECTORS, !!(ctx->pic_params->picture_coding_extension.bits.concealment_motion_vectors)); 839dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->BE_PPS2, MSVDX_VEC_MPEG2, CR_VEC_MPEG2_BE_PPS2, BE_PICTURE_STRUCTURE, ctx->pic_params->picture_coding_extension.bits.picture_structure); 840437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 841437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->obj_context->operating_mode = 0; 842dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->obj_context->operating_mode, MSVDX_CMDS, OPERATING_MODE, CHROMA_INTERLEAVED, 0); 843dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->obj_context->operating_mode, MSVDX_CMDS, OPERATING_MODE, ROW_STRIDE, ctx->obj_context->current_render_target->psb_surface->stride_mode); 844dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->obj_context->operating_mode, MSVDX_CMDS, OPERATING_MODE, CODEC_PROFILE, 1); /* MPEG2 profile */ 845dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->obj_context->operating_mode, MSVDX_CMDS, OPERATING_MODE, CODEC_MODE, 3); /* MPEG2 mode */ 846dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->obj_context->operating_mode, MSVDX_CMDS, OPERATING_MODE, ASYNC_MODE, 1); /* VDMC only */ 847dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(ctx->obj_context->operating_mode, MSVDX_CMDS, OPERATING_MODE, CHROMA_FORMAT, 1); 848dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 849f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb_CheckInterlaceRotate(ctx->obj_context, (unsigned char*)ctx->pic_params); 850437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return VA_STATUS_SUCCESS; 851437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 852437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 853437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_convert_iq_matrix(uint32_t *dest32, unsigned char *src) 854437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 855437b3eda28a4bf098efa80598cab67f190275266Fei Jiang int i; 856437b3eda28a4bf098efa80598cab67f190275266Fei Jiang int *idx = scan0; 857437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint8_t *dest8 = (uint8_t*) dest32; 858dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 859dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun for (i = 0; i < 64; i++) { 860437b3eda28a4bf098efa80598cab67f190275266Fei Jiang *dest8++ = src[*idx++]; 861437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 862437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 863437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 864437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic VAStatus psb__MPEG2_process_iq_matrix(context_MPEG2_p ctx, object_buffer_p obj_buffer) 865437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 866437b3eda28a4bf098efa80598cab67f190275266Fei Jiang VAIQMatrixBufferMPEG2 *iq_matrix = (VAIQMatrixBufferMPEG2 *) obj_buffer->buffer_data; 867437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ASSERT(obj_buffer->type == VAIQMatrixBufferType); 868437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ASSERT(obj_buffer->num_elements == 1); 869437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ASSERT(obj_buffer->size == sizeof(VAIQMatrixBufferMPEG2)); 870437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 871437b3eda28a4bf098efa80598cab67f190275266Fei Jiang if ((obj_buffer->num_elements != 1) || 872bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang (obj_buffer->size != sizeof(VAIQMatrixBufferMPEG2))) { 873437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return VA_STATUS_ERROR_UNKNOWN; 874437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 875437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 876437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Only update the qmatrix data if the load flag is set */ 877dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (iq_matrix->load_non_intra_quantiser_matrix) { 878dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb__MPEG2_convert_iq_matrix(ctx->qmatrix_data[NONINTRA_LUMA_Q], iq_matrix->non_intra_quantiser_matrix); 879437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 880dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (iq_matrix->load_intra_quantiser_matrix) { 881dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb__MPEG2_convert_iq_matrix(ctx->qmatrix_data[INTRA_LUMA_Q], iq_matrix->intra_quantiser_matrix); 882437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 883437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* We ignore the Chroma tables because those are not supported with VA_RT_FORMAT_YUV420 */ 884437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->got_iq_matrix = TRUE; 885437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 886437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return VA_STATUS_SUCCESS; 887437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 888437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 889437b3eda28a4bf098efa80598cab67f190275266Fei Jiang/* Precalculated values */ 890437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define ADDR0 (0x00006000) 891437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define ADDR1 (0x0003f017) 892437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define ADDR2 (0x000ab0e5) 893437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define ADDR3 (0x0000016e) 894437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define WIDTH0 (0x0016c6ed) 895437b3eda28a4bf098efa80598cab67f190275266Fei Jiang#define OPCODE0 (0x00002805) 896437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 897437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_write_VLC_tables(context_MPEG2_p ctx) 898437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 899437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 900437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 901dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_skip_start_block(cmdbuf, SKIP_ON_CONTEXT_SWITCH); 9024b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo /* VLC Table */ 9034b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo /* Write a LLDMA Cmd to transfer VLD Table data */ 904680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang psb_cmdbuf_dma_write_cmdbuf(cmdbuf, &ctx->vlc_packed_table, 0, 905cecb10be5449aa74cd1d9a2eb41c2a6a76d9ee79ywan sizeof(gaui16mpeg2VlcTableDataPacked), 0, 906680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang DMA_TYPE_VLC_TABLE); 9074b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 908437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Write the vec registers with the index data for each of the tables and then write */ 909437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* the actual table data. */ 910680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang psb_cmdbuf_reg_start_block(cmdbuf, 0); 911dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR0), ADDR0); 912dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR1), ADDR1); 913dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR2), ADDR2); 914dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_ADDR3), ADDR3); 915dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_WIDTH0), WIDTH0); 916dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_VLC_TABLE_INITIAL_OPCODE0), OPCODE0); 917dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_end_block(cmdbuf); 918dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 919dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_skip_end_block(cmdbuf); 9204b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo} 9214b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 922437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_set_operating_mode(context_MPEG2_p ctx) 923437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 924437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 925437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 926437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 927dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, DISPLAY_PICTURE_SIZE)); 928dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->display_picture_size); 929dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->coded_picture_size); 930dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->obj_context->operating_mode); 931437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 932437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 933dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs); 934437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 935437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 936dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 937437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 938dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_end(cmdbuf); 939f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 940f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang vld_dec_setup_alternative_frame(ctx->obj_context); 941f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 942437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 943437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 944437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_set_reference_pictures(context_MPEG2_p ctx) 945437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 946437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 947437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 948437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 949f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang if (ctx->slice_count != 0) { 950f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb_cmdbuf_skip_start_block(cmdbuf, SKIP_ON_CONTEXT_SWITCH); 951f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang } 952dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES)); 953437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 954dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* In MPEG2, the registers at N=0 are always used to store the base address of the luma and chroma buffers 955dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun of the most recently decoded reference picture. The registers at N=1 are used to store the base address 956dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun of the luma and chroma buffers of the older reference picture, if more than one reference picture is used. 957437b3eda28a4bf098efa80598cab67f190275266Fei Jiang This means that when decoding a P picture the forward reference picture�s address is at index 0. 958437b3eda28a4bf098efa80598cab67f190275266Fei Jiang When decoding a B-picture the backward reference picture�s address is at index 0 and the address of the 959437b3eda28a4bf098efa80598cab67f190275266Fei Jiang forward reference picture � which was decoded earlier than the backward reference � is at index 1. 960437b3eda28a4bf098efa80598cab67f190275266Fei Jiang */ 961437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 962dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun switch (ctx->pic_params->picture_coding_type) { 963dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case PICTURE_CODING_I: 964c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang drv_debug_msg(VIDEO_DEBUG_GENERAL, " I-Frame\n"); 965dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* No reference pictures */ 966dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, 0); 967dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, 0); 968dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, 0); 969dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, 0); 970dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 971dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 972dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case PICTURE_CODING_P: 973c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang drv_debug_msg(VIDEO_DEBUG_GENERAL, " P-Frame\n"); 974dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (ctx->pic_params->picture_coding_extension.bits.is_first_field) { 975dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* forward reference picture */ 976dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 977dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface->buf.buffer_ofs); 978dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 979dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 980dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface\ 981dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ->buf.buffer_ofs + ctx->forward_ref_surface->psb_surface->chroma_offset); 982dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 983dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* No backward reference picture */ 984dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, 0); 985dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, 0); 986dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } else { 987dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* backward reference picture */ 988dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 989dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs); 990dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 991dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 992dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 993dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 994dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* forward reference picture */ 995dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 996dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface->buf.buffer_ofs); 997dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 998dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 999dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 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); 1000dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } 1001dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 1002dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1003dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun case PICTURE_CODING_B: 1004c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang drv_debug_msg(VIDEO_DEBUG_GENERAL, " B-Frame\n"); 1005dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* backward reference picture */ 1006dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1007dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->backward_ref_surface->psb_surface->buf, ctx->backward_ref_surface->psb_surface->buf.buffer_ofs); 1008dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1009dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1010dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 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); 1011dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1012dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* forward reference picture */ 1013dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1014dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write_address(cmdbuf, &ctx->forward_ref_surface->psb_surface->buf, ctx->forward_ref_surface->psb_surface->buf.buffer_ofs); 1015dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1016dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES */ 1017dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 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); 1018dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun break; 1019437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1020437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1021dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_end(cmdbuf); 1022f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 1023f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang if (ctx->slice_count != 0) { 1024f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb_cmdbuf_skip_end_block(cmdbuf); 1025f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang } 1026437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1027437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1028437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_set_picture_header(context_MPEG2_p ctx, VASliceParameterBufferMPEG2 *slice_param) 1029437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 1030437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1031437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 1032437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t FE_slice; 1033437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t BE_slice; 1034437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1035680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang psb_cmdbuf_reg_start_block(cmdbuf, 0); 1036437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1037437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* VEC Control register: Front-End MPEG2 PPS0 */ 1038dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS0) , ctx->FE_PPS0); 1039437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1040437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* VEC Control register: Front-End MPEG2 PPS1 */ 1041dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_PPS1) , ctx->FE_PPS1); 1042437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1043437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Slice level */ 1044437b3eda28a4bf098efa80598cab67f190275266Fei Jiang FE_slice = 0; 1045dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(FE_slice, 1046dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1047dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_FE_SLICE, 1048dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun FE_FIRST_IN_ROW, 1049dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun (ctx->previous_slice_vertical_position != slice_param->slice_vertical_position)); 1050437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1051dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(FE_slice, 1052dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1053dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_FE_SLICE, 1054dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun FE_SLICE_VERTICAL_POSITION_MINUS1, 1055dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun slice_param->slice_vertical_position); 1056437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1057dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(FE_slice, 1058dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1059dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_FE_SLICE, 1060dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun FE_QUANTISER_SCALE_CODE, 1061dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun slice_param->quantiser_scale_code); 1062437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1063dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_SLICE) , FE_slice); 1064437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1065f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang FE_slice = 0; 1066f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang REGIO_WRITE_FIELD_LITE(FE_slice, 1067f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang MSVDX_VEC_MPEG2, 1068f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang CR_VEC_MPEG2_FE_SPS0, 1069f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang FE_HORIZONTAL_SIZE_MINUS1, 1070f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang ctx->picture_width_mb - 1); 1071f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 1072f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC_MPEG2, CR_VEC_MPEG2_FE_SPS0) , FE_slice); 1073f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 1074dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_end_block(cmdbuf); 1075437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1076437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1077437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* BE Section */ 1078dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, MPEG2_CR_VEC_MPEG2_BE_SPS0)); 1079437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1080dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_SPS0); 1081dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_SPS1); 1082dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_PPS0); /* VEC Control register: Back-End MPEG2 PPS0 */ 1083dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_PPS1); /* VEC Control register: Back-End MPEG2 PPS1 */ 1084dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->BE_PPS2); /* VEC Control register: Back-End MPEG2 PPS2 */ 1085437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1086437b3eda28a4bf098efa80598cab67f190275266Fei Jiang BE_slice = 0; 1087dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (!ctx->pic_params->picture_coding_extension.bits.is_first_field) { 1088dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* 1089437b3eda28a4bf098efa80598cab67f190275266Fei Jiang BE_IP_PAIR_FLAG is 1 if the current picture_data is a P-coded field which is the 2nd field of a frame, 1090437b3eda28a4bf098efa80598cab67f190275266Fei Jiang and which uses the first field of the frame (which was I-coded) as a reference. 0 otherwise. 1091dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun BE_IP_PAIR_FLAG will only be 1 if BE_SECOND_FIELD_FLAG is 1, and the condition 1092437b3eda28a4bf098efa80598cab67f190275266Fei Jiang of "this is a P-field which uses the accompanying I-field as a reference" is met. 1093437b3eda28a4bf098efa80598cab67f190275266Fei Jiang */ 1094dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (ctx->pic_params->picture_coding_type == PICTURE_CODING_P) { 1095dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (GET_SURFACE_INFO_picture_coding_type(target_surface) == PICTURE_CODING_I) { 1096dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(BE_slice, 1097dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1098dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_BE_SLICE, 1099dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun BE_IP_PAIR_FLAG, 1); 1100437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1101437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1102437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1103437b3eda28a4bf098efa80598cab67f190275266Fei Jiang REGIO_WRITE_FIELD_LITE(BE_slice, 1104dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1105dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_BE_SLICE, 1106dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun BE_SECOND_FIELD_FLAG, 1); 1107437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1108dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun } else { 1109437b3eda28a4bf098efa80598cab67f190275266Fei Jiang // BE_IP_PAIR_FLAG = 0; 1110437b3eda28a4bf098efa80598cab67f190275266Fei Jiang // BE_SECOND_FIELD_FLAG = 0; 1111437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1112437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* Update with current settings first field */ 1113437b3eda28a4bf098efa80598cab67f190275266Fei Jiang SET_SURFACE_INFO_is_defined(target_surface, TRUE); 1114dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun SET_SURFACE_INFO_picture_structure(target_surface, ctx->pic_params->picture_coding_extension.bits.picture_structure); 1115dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun SET_SURFACE_INFO_picture_coding_type(target_surface, ctx->pic_params->picture_coding_type); 1116437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1117437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1118dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(BE_slice, 1119dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1120dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_BE_SLICE, 1121dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun BE_FIRST_IN_ROW, 1122dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun (ctx->previous_slice_vertical_position != slice_param->slice_vertical_position)); 1123dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1124dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(BE_slice, 1125dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1126dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_BE_SLICE, 1127dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun BE_SLICE_VERTICAL_POSITION_MINUS1, 1128dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun slice_param->slice_vertical_position); 1129437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1130dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(BE_slice, 1131dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC_MPEG2, 1132dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_MPEG2_BE_SLICE, 1133dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun BE_QUANTISER_SCALE_CODE, 1134dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun slice_param->quantiser_scale_code); 1135437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1136c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang drv_debug_msg(VIDEO_DEBUG_GENERAL, "BE_slice = %08x first_field = %d\n", BE_slice, ctx->pic_params->picture_coding_extension.bits.is_first_field); 1137437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1138dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, BE_slice); 1139437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1140dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_end(cmdbuf); 1141437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1142437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->previous_slice_vertical_position = slice_param->slice_vertical_position; 1143437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1144437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1145437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_set_slice_params(context_MPEG2_p ctx) 1146437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 1147437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1148437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1149437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t cmd_data; 1150437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1151dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, SLICE_PARAMS)); 1152437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1153437b3eda28a4bf098efa80598cab67f190275266Fei Jiang cmd_data = 0; /* Build slice parameters */ 1154dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(cmd_data, 1155dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_CMDS, 1156dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun SLICE_PARAMS, 1157dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun SLICE_FIELD_TYPE, 1158dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ctx->pic_params->picture_coding_extension.bits.picture_structure - 1); 1159dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1160dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(cmd_data, 1161dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_CMDS, 1162dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun SLICE_PARAMS, 1163dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun SLICE_CODE_TYPE, 1164dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun PICTURE_CODING_D == ctx->pic_params->picture_coding_type ? 0 : ctx->pic_params->picture_coding_type - 1); 1165dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1166dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, cmd_data); 1167437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 116806c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng *ctx->dec_ctx.p_slice_params = cmd_data; 1169437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1170dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_end(cmdbuf); 1171437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1172437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1173437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_write_qmatrices(context_MPEG2_p ctx) 1174437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 1175437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1176437b3eda28a4bf098efa80598cab67f190275266Fei Jiang int i; 1177437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1178dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun /* Since we only decode 4:2:0 We only need to the Intra tables. 1179437b3eda28a4bf098efa80598cab67f190275266Fei Jiang Chroma quant tables are only used in Mpeg 4:2:2 and 4:4:4. 1180437b3eda28a4bf098efa80598cab67f190275266Fei Jiang The hardware wants non-intra followed by intra */ 1181dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_start(cmdbuf, REG_MSVDX_VEC_IQRAM_OFFSET); 1182437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1183437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* todo : optimisation here is to only load the need table */ 1184437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1185437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* NONINTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + 0 */ 1186dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun for (i = 0; i < 16; i++) { 1187dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->qmatrix_data[NONINTRA_LUMA_Q][i]); 1188c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang// drv_debug_msg(VIDEO_DEBUG_GENERAL, "NONINTRA_LUMA_Q[i] = %08x\n", ctx->qmatrix_data[NONINTRA_LUMA_Q][i]); 1189437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1190437b3eda28a4bf098efa80598cab67f190275266Fei Jiang /* INTRA_LUMA_Q --> REG_MSVDX_VEC_IQRAM_OFFSET + (16*4) */ 1191dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun for (i = 0; i < 16; i++) { 1192dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, ctx->qmatrix_data[INTRA_LUMA_Q][i]); 1193c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang// drv_debug_msg(VIDEO_DEBUG_GENERAL, "INTRA_LUMA_Q[i] = %08x\n", ctx->qmatrix_data[INTRA_LUMA_Q][i]); 1194437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1195437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1196dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_end(cmdbuf); 1197437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1198437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1199437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic void psb__MPEG2_set_ent_dec(context_MPEG2_p ctx) 1200437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 1201437b3eda28a4bf098efa80598cab67f190275266Fei Jiang psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 1202437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1203437b3eda28a4bf098efa80598cab67f190275266Fei Jiang uint32_t cmd_data; 1204437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1205680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang psb_cmdbuf_reg_start_block(cmdbuf, 0); 1206437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1207437b3eda28a4bf098efa80598cab67f190275266Fei Jiang cmd_data = 0; /* Entdec Front-End controls */ 1208437b3eda28a4bf098efa80598cab67f190275266Fei Jiang REGIO_WRITE_FIELD_LITE(cmd_data, MSVDX_VEC, CR_VEC_ENTDEC_FE_CONTROL, ENTDEC_FE_PROFILE, 1); /* MPEG2 Main Profile */ 1209437b3eda28a4bf098efa80598cab67f190275266Fei Jiang REGIO_WRITE_FIELD_LITE(cmd_data, MSVDX_VEC, CR_VEC_ENTDEC_FE_CONTROL, ENTDEC_FE_MODE, 3); /* Set MPEG2 mode */ 1210437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1211dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_VEC, CR_VEC_ENTDEC_FE_CONTROL), cmd_data); 1212dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1213dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_end_block(cmdbuf); 1214437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1215dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_VEC, CR_VEC_ENTDEC_BE_CONTROL)); 1216437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1217437b3eda28a4bf098efa80598cab67f190275266Fei Jiang cmd_data = 0; /* Entdec Back-End controls */ 1218dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(cmd_data, 1219dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC, 1220dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_ENTDEC_BE_CONTROL, 1221dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ENTDEC_BE_PROFILE, 1222dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1); /* MPEG2 Main Profile */ 1223dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1224dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(cmd_data, 1225dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun MSVDX_VEC, 1226dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun CR_VEC_ENTDEC_BE_CONTROL, 1227dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ENTDEC_BE_MODE, 1228dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 3); /* Set MPEG2 mode */ 1229dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1230dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_write(cmdbuf, cmd_data); 1231dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1232dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_rendec_end(cmdbuf); 1233f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 1234f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb_cmdbuf_rendec_start(cmdbuf, RENDEC_REGISTER_OFFSET(MSVDX_CMDS, MC_CACHE_CONFIGURATION)); 1235f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang cmd_data = 0; 1236f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang REGIO_WRITE_FIELD_LITE(cmd_data, MSVDX_CMDS, MC_CACHE_CONFIGURATION, CONFIG_REF_OFFSET, CACHE_REF_OFFSET); 1237f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang REGIO_WRITE_FIELD_LITE(cmd_data, MSVDX_CMDS, MC_CACHE_CONFIGURATION, CONFIG_ROW_OFFSET, CACHE_ROW_OFFSET); 1238f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb_cmdbuf_rendec_write(cmdbuf, cmd_data); 1239f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb_cmdbuf_rendec_end(cmdbuf); 1240f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 1241437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1242437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 124306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic void psb__MPEG2_begin_slice(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param) 1244437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 124506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng VASliceParameterBufferMPEG2 *slice_param = (VASliceParameterBufferMPEG2 *) vld_slice_param; 124606c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng context_MPEG2_p ctx = (context_MPEG2_p)dec_ctx; 12474b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1248f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang psb__MPEG2_write_VLC_tables(ctx); 1249f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 125006c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng dec_ctx->bits_offset = slice_param->macroblock_offset; 1251f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang dec_ctx->SR_flags = CMD_SR_VERIFY_STARTCODE; 1252437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 125306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic void psb__MPEG2_process_slice_data(context_DEC_p dec_ctx, VASliceParameterBufferBase *vld_slice_param) 1254680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang{ 125506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng VASliceParameterBufferMPEG2 *slice_param = (VASliceParameterBufferMPEG2 *) vld_slice_param; 125606c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng context_MPEG2_p ctx = (context_MPEG2_p)dec_ctx; 125706c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng 1258f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang ctx->obj_context->first_mb = 0; 1259f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang ctx->obj_context->first_mb = slice_param->slice_vertical_position << 8; 1260f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 126106c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng psb__MPEG2_set_operating_mode(ctx); 126206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng psb__MPEG2_set_reference_pictures(ctx); 126306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng psb__MPEG2_set_picture_header(ctx, slice_param); 126406c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng psb__MPEG2_set_slice_params(ctx); 126506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng psb__MPEG2_write_qmatrices(ctx); 126606c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng psb__MPEG2_set_ent_dec(ctx); 1267680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang} 1268437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 126906c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic void psb__MPEG2_end_slice(context_DEC_p dec_ctx) 1270437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 127106c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng context_MPEG2_p ctx = (context_MPEG2_p)dec_ctx; 127206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->obj_context->flags = FW_VA_RENDER_IS_VLD_NOT_MC; 1273437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 127406c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng if (ctx->pic_params->picture_coding_extension.bits.progressive_frame) 127506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->obj_context->last_mb = ((ctx->picture_height_mb - 1) << 8) | (ctx->picture_width_mb - 1); 127606c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng else 127706c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->obj_context->last_mb = ((ctx->picture_height_mb / 2 - 1) << 8) | (ctx->picture_width_mb - 1); 1278dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 127906c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng *(ctx->dec_ctx.slice_first_pic_last) = (ctx->obj_context->first_mb << 16) | (ctx->obj_context->last_mb); 1280f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 1281f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang ctx->slice_count++; 1282437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1283437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 12844b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuostatic void psb__MEPG2_send_highlevel_cmd(context_MPEG2_p ctx) 12854b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo{ 12864b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo uint32_t cmd; 12874b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 12884b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb_surface_p target_surface = ctx->obj_context->current_render_target->psb_surface; 12894d06c1febaa800c6a9efb9908a2c6233472c7464Li Zeng psb_surface_p rotate_surface = ctx->obj_context->current_render_target->out_loop_surface; 12904b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1291680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang psb_cmdbuf_reg_start_block(cmdbuf, 0); 1292dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, DISPLAY_PICTURE_SIZE), ctx->display_picture_size); 1293dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, CODED_PICTURE_SIZE), ctx->coded_picture_size); 12944b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 12954b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo cmd = 0; 12964b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo REGIO_WRITE_FIELD(cmd, MSVDX_CMDS, OPERATING_MODE, CHROMA_FORMAT, 1); 12974b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo REGIO_WRITE_FIELD(cmd, MSVDX_CMDS, OPERATING_MODE, ASYNC_MODE, 1); // 0 = VDMC and VDEB active. 1 = VDEB pass-thru. 12984b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo REGIO_WRITE_FIELD(cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_MODE, 3); // MPEG2 12994b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo REGIO_WRITE_FIELD(cmd, MSVDX_CMDS, OPERATING_MODE, CODEC_PROFILE, 1); // MAIN 1300dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD(cmd, MSVDX_CMDS, OPERATING_MODE, ROW_STRIDE, target_surface->stride_mode); 1301dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, OPERATING_MODE), cmd); 13024b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1303dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, LUMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES), 13044b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo &target_surface->buf, target_surface->buf.buffer_ofs); 13054b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13064b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, CHROMA_RECONSTRUCTED_PICTURE_BASE_ADDRESSES), 1307dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 13084b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1309dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES) + (0 * 8), 13104b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo &target_surface->buf, target_surface->buf.buffer_ofs); 13114b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13124b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES) + 4 + (0 * 8), 1313dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 13144b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1315dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES) + (1 * 8), 13164b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo &target_surface->buf, target_surface->buf.buffer_ofs); 13174b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13184b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, REFERENCE_PICTURE_BASE_ADDRESSES) + 4 + (1 * 8), 1319dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun &target_surface->buf, target_surface->buf.buffer_ofs + target_surface->chroma_offset); 13204b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13214b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo cmd = 0; 13224b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo REGIO_WRITE_FIELD(cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_FIELD_TYPE, 2); /* FRAME PICTURE -- ui8SliceFldType */ 13234b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo REGIO_WRITE_FIELD(cmd, MSVDX_CMDS, SLICE_PARAMS, SLICE_CODE_TYPE, 1); /* P PICTURE -- (ui8PicType == WMF_PTYPE_BI) ? WMF_PTYPE_I : (ui8PicType & 0x3) */ 1324dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, SLICE_PARAMS), cmd); 132506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng *ctx->dec_ctx.p_slice_params = cmd; 1326dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_end_block(cmdbuf); 13274b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13284b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1329680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang psb_cmdbuf_reg_start_block(cmdbuf, 0); 1330dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, VC1_LUMA_RANGE_MAPPING_BASE_ADDRESS), 13314b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo &rotate_surface->buf, rotate_surface->buf.buffer_ofs); 13324b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1333dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set_RELOC(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, VC1_CHROMA_RANGE_MAPPING_BASE_ADDRESS), 1334dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun &rotate_surface->buf, rotate_surface->buf.buffer_ofs + rotate_surface->chroma_offset); 1335dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_end_block(cmdbuf); 13364b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 133706c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng RELOC(*ctx->dec_ctx.p_range_mapping_base0, rotate_surface->buf.buffer_ofs, &rotate_surface->buf); 133806c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng RELOC(*ctx->dec_ctx.p_range_mapping_base1, rotate_surface->buf.buffer_ofs + rotate_surface->chroma_offset, &rotate_surface->buf); 13394b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo} 13404b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13414b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuostatic void psb__MEPG2_send_blit_cmd(context_MPEG2_p ctx) 13424b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo{ 13434b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo uint32_t cmd; 13444b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 13454d06c1febaa800c6a9efb9908a2c6233472c7464Li Zeng psb_surface_p rotate_surface = ctx->obj_context->current_render_target->out_loop_surface; 13464b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1347680952832ef474a95bb0c4fee50c06e5126ad66dKun Wang psb_cmdbuf_reg_start_block(cmdbuf, 0); 13484b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo cmd = 0; 1349dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, ALTERNATIVE_OUTPUT_PICTURE_ROTATION , ALT_PICTURE_ENABLE, 1); 1350dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, ALTERNATIVE_OUTPUT_PICTURE_ROTATION , ROTATION_ROW_STRIDE, rotate_surface->stride_mode); 1351dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, ALTERNATIVE_OUTPUT_PICTURE_ROTATION , RECON_WRITE_DISABLE, 0); 1352ca7d98aa1e54c9ee6ee79eb46ad25e0b897e7c51Austin Yuan REGIO_WRITE_FIELD_LITE(cmd, MSVDX_CMDS, ALTERNATIVE_OUTPUT_PICTURE_ROTATION , ROTATION_MODE, GET_SURFACE_INFO_rotate(rotate_surface)); 1353dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_set(cmdbuf, REGISTER_OFFSET(MSVDX_CMDS, ALTERNATIVE_OUTPUT_PICTURE_ROTATION), cmd); 1354dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun psb_cmdbuf_reg_end_block(cmdbuf); 13554b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13564b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = 0x40000000; /* CMD_BLIT_CMD */ 13574b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = ctx->picture_width_mb; 13584b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = ctx->picture_height_mb; /* FIXME */ 13594b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = CMD_COMPLETION; 13604b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo} 13614b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1362dc1209519284865899ca8d990b3a2c7dbca8ae08wangkunstatic void psb__MPEG2_insert_blit_cmd_to_rotate(context_MPEG2_p ctx) 13634b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo{ 13644b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb_cmdbuf_p cmdbuf = ctx->obj_context->cmdbuf; 13654b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13664b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo /* See RENDER_BUFFER_HEADER */ 13674b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = CMD_HEADER_VC1; 13684b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 136906c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.p_range_mapping_base0 = cmdbuf->cmd_idx++; 137006c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.p_range_mapping_base1 = cmdbuf->cmd_idx++; 13714b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 137206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng *ctx->dec_ctx.p_range_mapping_base0 = 0; 137306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng *ctx->dec_ctx.p_range_mapping_base1 = 0; 13744b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 137506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.p_slice_params = cmdbuf->cmd_idx; 13764b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = 0; /* ui32SliceParams */ 13774b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13784b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = 0; /* skip two lldma addr field */ 13794b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo *cmdbuf->cmd_idx++ = 0; 13804b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 138106c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng ctx->dec_ctx.slice_first_pic_last = cmdbuf->cmd_idx++; 138206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng *ctx->dec_ctx.slice_first_pic_last = 0; 13834b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13844b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb__MEPG2_send_highlevel_cmd(ctx); 13854b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb__MEPG2_send_blit_cmd(ctx); 13864b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 13874b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo ctx->obj_context->video_op = psb_video_mc; 1388bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang ctx->obj_context->flags = FW_VA_RENDER_IS_LAST_SLICE; 13894b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1390dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (psb_context_submit_cmdbuf(ctx->obj_context)) { 1391dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun ASSERT(0); 13924b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo } 13934b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo} 13944b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1395437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic VAStatus pnw_MPEG2_BeginPicture( 1396dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun object_context_p obj_context) 1397437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 1398437b3eda28a4bf098efa80598cab67f190275266Fei Jiang INIT_CONTEXT_MPEG2 1399437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1400c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang drv_debug_msg(VIDEO_DEBUG_GENERAL, "pnw_MPEG2_BeginPicture\n"); 1401dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (ctx->pic_params) { 1402437b3eda28a4bf098efa80598cab67f190275266Fei Jiang free(ctx->pic_params); 1403437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->pic_params = NULL; 1404437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1405437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->previous_slice_vertical_position = ~1; 1406f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang ctx->slice_count = 0; 1407dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 1408437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return VA_STATUS_SUCCESS; 1409437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1410437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 141106c7c30796be2e6b18a6263956a0ca308616ecdeLi Zengstatic VAStatus pnw_MPEG2_process_buffer( 141206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng context_DEC_p dec_ctx, 141306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng object_buffer_p buffer) 1414437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 141506c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng context_MPEG2_p ctx = (context_MPEG2_p)dec_ctx; 1416437b3eda28a4bf098efa80598cab67f190275266Fei Jiang VAStatus vaStatus = VA_STATUS_SUCCESS; 141706c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng object_buffer_p obj_buffer = buffer; 1418dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 141906c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng switch (obj_buffer->type) { 142006c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng case VAPictureParameterBufferType: 142106c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng drv_debug_msg(VIDEO_DEBUG_GENERAL, "pnw_MPEG2_RenderPicture got VAPictureParameterBuffer\n"); 142206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng vaStatus = psb__MPEG2_process_picture_param(ctx, obj_buffer); 142306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng DEBUG_FAILURE; 142406c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng break; 1425dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 142606c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng case VAIQMatrixBufferType: 142706c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng drv_debug_msg(VIDEO_DEBUG_GENERAL,"pnw_MPEG2_RenderPicture got VAIQMatrixBufferType\n"); 142806c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng vaStatus = psb__MPEG2_process_iq_matrix(ctx, obj_buffer); 142906c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng DEBUG_FAILURE; 143006c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng break; 1431dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun 143206c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng default: 143306c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng vaStatus = VA_STATUS_ERROR_UNKNOWN; 143406c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng DEBUG_FAILURE; 1435437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1436437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1437437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return vaStatus; 1438437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1439437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1440437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstatic VAStatus pnw_MPEG2_EndPicture( 1441dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun object_context_p obj_context) 1442437b3eda28a4bf098efa80598cab67f190275266Fei Jiang{ 1443437b3eda28a4bf098efa80598cab67f190275266Fei Jiang VAStatus vaStatus = VA_STATUS_SUCCESS; 1444437b3eda28a4bf098efa80598cab67f190275266Fei Jiang INIT_CONTEXT_MPEG2 1445437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1446c60d5b7bdb5616ca37e0b912c10725bec4320f33Fei Jiang drv_debug_msg(VIDEO_DEBUG_GENERAL, "pnw_MPEG2_EndPicture\n"); 1447437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 14480da1930627209986e8db220799a690f816494401Austin Yuan if (CONTEXT_ROTATE(ctx->obj_context)) { 1449dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (!(ctx->pic_params->picture_coding_extension.bits.progressive_frame) && 1450bde3ed7517cc876cb2a6e174ea2a96a75938e787Kun Wang !(ctx->pic_params->picture_coding_extension.bits.is_first_field)) 14514b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo psb__MPEG2_insert_blit_cmd_to_rotate(ctx); 14524b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo } 14534b5b72d7dd3fe944d75029ff0ca6db1e74600e59Liu, Shuo 1454dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (psb_context_flush_cmdbuf(ctx->obj_context)) { 1455437b3eda28a4bf098efa80598cab67f190275266Fei Jiang vaStatus = VA_STATUS_ERROR_UNKNOWN; 1456437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1457437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1458dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun if (ctx->pic_params) { 1459437b3eda28a4bf098efa80598cab67f190275266Fei Jiang free(ctx->pic_params); 1460437b3eda28a4bf098efa80598cab67f190275266Fei Jiang ctx->pic_params = NULL; 1461437b3eda28a4bf098efa80598cab67f190275266Fei Jiang } 1462437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1463f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang ctx->slice_count = 0; 1464f4c11867384e8c010264c10f0703e720bf2eefcaYuanjun Huang 1465437b3eda28a4bf098efa80598cab67f190275266Fei Jiang return vaStatus; 1466437b3eda28a4bf098efa80598cab67f190275266Fei Jiang} 1467437b3eda28a4bf098efa80598cab67f190275266Fei Jiang 1468437b3eda28a4bf098efa80598cab67f190275266Fei Jiangstruct format_vtable_s pnw_MPEG2_vtable = { 1469dc1209519284865899ca8d990b3a2c7dbca8ae08wangkunqueryConfigAttributes: 1470dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun pnw_MPEG2_QueryConfigAttributes, 1471dc1209519284865899ca8d990b3a2c7dbca8ae08wangkunvalidateConfig: 1472dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun pnw_MPEG2_ValidateConfig, 1473dc1209519284865899ca8d990b3a2c7dbca8ae08wangkuncreateContext: 1474dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun pnw_MPEG2_CreateContext, 1475dc1209519284865899ca8d990b3a2c7dbca8ae08wangkundestroyContext: 1476dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun pnw_MPEG2_DestroyContext, 1477dc1209519284865899ca8d990b3a2c7dbca8ae08wangkunbeginPicture: 1478dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun pnw_MPEG2_BeginPicture, 1479dc1209519284865899ca8d990b3a2c7dbca8ae08wangkunrenderPicture: 148006c7c30796be2e6b18a6263956a0ca308616ecdeLi Zeng vld_dec_RenderPicture, 1481dc1209519284865899ca8d990b3a2c7dbca8ae08wangkunendPicture: 1482dc1209519284865899ca8d990b3a2c7dbca8ae08wangkun pnw_MPEG2_EndPicture 1483437b3eda28a4bf098efa80598cab67f190275266Fei Jiang}; 1484