1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/*------------------------------------------------------------------------------ 18 19 Table of contents 20 21 1. Include headers 22 2. Module defines 23 3. Data types 24 4. Function prototypes 25 26------------------------------------------------------------------------------*/ 27 28#ifndef H264SWDEC_MACROBLOCK_LAYER_H 29#define H264SWDEC_MACROBLOCK_LAYER_H 30 31/*------------------------------------------------------------------------------ 32 1. Include headers 33------------------------------------------------------------------------------*/ 34 35#include "basetype.h" 36#include "h264bsd_stream.h" 37#include "h264bsd_image.h" 38#include "h264bsd_dpb.h" 39 40/*------------------------------------------------------------------------------ 41 2. Module defines 42------------------------------------------------------------------------------*/ 43 44/* Macro to determine if a mb is an intra mb */ 45#define IS_INTRA_MB(a) ((a).mbType > 5) 46 47/* Macro to determine if a mb is an I_PCM mb */ 48#define IS_I_PCM_MB(a) ((a).mbType == 31) 49 50typedef enum { 51 P_Skip = 0, 52 P_L0_16x16 = 1, 53 P_L0_L0_16x8 = 2, 54 P_L0_L0_8x16 = 3, 55 P_8x8 = 4, 56 P_8x8ref0 = 5, 57 I_4x4 = 6, 58 I_16x16_0_0_0 = 7, 59 I_16x16_1_0_0 = 8, 60 I_16x16_2_0_0 = 9, 61 I_16x16_3_0_0 = 10, 62 I_16x16_0_1_0 = 11, 63 I_16x16_1_1_0 = 12, 64 I_16x16_2_1_0 = 13, 65 I_16x16_3_1_0 = 14, 66 I_16x16_0_2_0 = 15, 67 I_16x16_1_2_0 = 16, 68 I_16x16_2_2_0 = 17, 69 I_16x16_3_2_0 = 18, 70 I_16x16_0_0_1 = 19, 71 I_16x16_1_0_1 = 20, 72 I_16x16_2_0_1 = 21, 73 I_16x16_3_0_1 = 22, 74 I_16x16_0_1_1 = 23, 75 I_16x16_1_1_1 = 24, 76 I_16x16_2_1_1 = 25, 77 I_16x16_3_1_1 = 26, 78 I_16x16_0_2_1 = 27, 79 I_16x16_1_2_1 = 28, 80 I_16x16_2_2_1 = 29, 81 I_16x16_3_2_1 = 30, 82 I_PCM = 31 83} mbType_e; 84 85typedef enum { 86 P_L0_8x8 = 0, 87 P_L0_8x4 = 1, 88 P_L0_4x8 = 2, 89 P_L0_4x4 = 3 90} subMbType_e; 91 92typedef enum { 93 MB_P_16x16 = 0, 94 MB_P_16x8, 95 MB_P_8x16, 96 MB_P_8x8 97} mbPartMode_e; 98 99typedef enum { 100 MB_SP_8x8 = 0, 101 MB_SP_8x4, 102 MB_SP_4x8, 103 MB_SP_4x4 104} subMbPartMode_e; 105 106typedef enum { 107 PRED_MODE_INTRA4x4 = 0, 108 PRED_MODE_INTRA16x16 , 109 PRED_MODE_INTER 110} mbPartPredMode_e; 111 112/*------------------------------------------------------------------------------ 113 3. Data types 114------------------------------------------------------------------------------*/ 115 116typedef struct 117{ 118 /* MvPrediction16x16 assumes that MVs are 16bits */ 119 i16 hor; 120 i16 ver; 121} mv_t; 122 123typedef struct 124{ 125 u32 prevIntra4x4PredModeFlag[16]; 126 u32 remIntra4x4PredMode[16]; 127 u32 intraChromaPredMode; 128 u32 refIdxL0[4]; 129 mv_t mvdL0[4]; 130} mbPred_t; 131 132typedef struct 133{ 134 subMbType_e subMbType[4]; 135 u32 refIdxL0[4]; 136 mv_t mvdL0[4][4]; 137} subMbPred_t; 138 139typedef struct 140{ 141#ifdef H264DEC_OMXDL 142 u8 posCoefBuf[27*16*3]; 143 u8 totalCoeff[27]; 144#else 145 i16 totalCoeff[27]; 146#endif 147 i32 level[26][16]; 148 u32 coeffMap[24]; 149} residual_t; 150 151typedef struct 152{ 153 mbType_e mbType; 154 u32 codedBlockPattern; 155 i32 mbQpDelta; 156 mbPred_t mbPred; 157 subMbPred_t subMbPred; 158 residual_t residual; 159} macroblockLayer_t; 160 161typedef struct mbStorage 162{ 163 mbType_e mbType; 164 u32 sliceId; 165 u32 disableDeblockingFilterIdc; 166 i32 filterOffsetA; 167 i32 filterOffsetB; 168 u32 qpY; 169 i32 chromaQpIndexOffset; 170#ifdef H264DEC_OMXDL 171 u8 totalCoeff[27]; 172#else 173 i16 totalCoeff[27]; 174#endif 175 u8 intra4x4PredMode[16]; 176 u32 refPic[4]; 177 u8* refAddr[4]; 178 mv_t mv[16]; 179 u32 decoded; 180 struct mbStorage *mbA; 181 struct mbStorage *mbB; 182 struct mbStorage *mbC; 183 struct mbStorage *mbD; 184} mbStorage_t; 185 186/*------------------------------------------------------------------------------ 187 4. Function prototypes 188------------------------------------------------------------------------------*/ 189 190u32 h264bsdDecodeMacroblockLayer(strmData_t *pStrmData, 191 macroblockLayer_t *pMbLayer, mbStorage_t *pMb, u32 sliceType, 192 u32 numRefIdxActive); 193 194u32 h264bsdNumMbPart(mbType_e mbType); 195u32 h264bsdNumSubMbPart(subMbType_e subMbType); 196 197subMbPartMode_e h264bsdSubMbPartMode(subMbType_e subMbType); 198 199u32 h264bsdDecodeMacroblock(mbStorage_t *pMb, macroblockLayer_t *pMbLayer, 200 image_t *currImage, dpbStorage_t *dpb, i32 *qpY, u32 mbNum, 201 u32 constrainedIntraPredFlag, u8* data); 202 203u32 h264bsdPredModeIntra16x16(mbType_e mbType); 204 205mbPartPredMode_e h264bsdMbPartPredMode(mbType_e mbType); 206#ifdef H264DEC_NEON 207u32 h264bsdClearMbLayer(macroblockLayer_t *pMbLayer, u32 size); 208#endif 209 210#endif /* #ifdef H264SWDEC_MACROBLOCK_LAYER_H */ 211 212 213