1/* 2 * Copyright (C) 2007-2008 ARM Limited 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 * File Name: armVCM4P2_DecodeVLCZigzag_intra.c 20 * OpenMAX DL: v1.0.2 21 * Revision: 9641 22 * Date: Thursday, February 7, 2008 23 * 24 * 25 * 26 * 27 * Description: 28 * Contains modules for filling of the coefficient buffer 29 * 30 */ 31 32#include "omxtypes.h" 33#include "armOMX.h" 34#include "omxVC.h" 35 36#include "armVC.h" 37#include "armCOMM_Bitstream.h" 38#include "armCOMM.h" 39#include "armVCM4P2_Huff_Tables_VLC.h" 40#include "armVCM4P2_ZigZag_Tables.h" 41 42 43 44/** 45 * Function: armVCM4P2_DecodeVLCZigzag_Intra 46 * 47 * Description: 48 * Performs VLC decoding and inverse zigzag scan for one intra coded block. 49 * 50 * Remarks: 51 * 52 * Parameters: 53 * [in] ppBitStream pointer to the pointer to the current byte in 54 * the bitstream buffer 55 * [in] pBitOffset pointer to the bit position in the byte pointed 56 * to by *ppBitStream. *pBitOffset is valid within 57 * [0-7]. 58 * [in] predDir AC prediction direction which is used to decide 59 * the zigzag scan pattern. It takes one of the 60 * following values: 61 * OMX_VC_NONE AC prediction not used; 62 * perform classical zigzag scan; 63 * OMX_VC_HORIZONTAL Horizontal prediction; 64 * perform alternate-vertical 65 * zigzag scan; 66 * OMX_VC_VERTICAL Vertical prediction; 67 * thus perform 68 * alternate-horizontal 69 * zigzag scan. 70 * [in] start start indicates whether the encoding begins with 0th element 71 * or 1st. 72 * [out] ppBitStream *ppBitStream is updated after the block is 73 * decoded, so that it points to the current byte 74 * in the bit stream buffer 75 * [out] pBitOffset *pBitOffset is updated so that it points to the 76 * current bit position in the byte pointed by 77 * *ppBitStream 78 * [out] pDst pointer to the coefficient buffer of current 79 * block. Should be 32-bit aligned 80 * 81 * Return Value: 82 * Standard OMXResult result. See enumeration for possible result codes. 83 * 84 */ 85 86OMXResult armVCM4P2_DecodeVLCZigzag_Intra( 87 const OMX_U8 ** ppBitStream, 88 OMX_INT * pBitOffset, 89 OMX_S16 * pDst, 90 OMX_U8 predDir, 91 OMX_INT shortVideoHeader, 92 OMX_U8 start 93) 94{ 95 OMX_U8 last = 0; 96 const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan; 97 OMXResult errorCode; 98 99 /* Argument error checks */ 100 armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr); 101 armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr); 102 armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr); 103 armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 104 armRetArgErrIf(!armIs4ByteAligned(pDst), OMX_Sts_BadArgErr); 105 armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr); 106 armRetArgErrIf((predDir > 2), OMX_Sts_BadArgErr); 107 108 switch (predDir) 109 { 110 case OMX_VC_NONE: 111 { 112 pZigzagTable = armVCM4P2_aClassicalZigzagScan; 113 break; 114 } 115 116 case OMX_VC_HORIZONTAL: 117 { 118 pZigzagTable = armVCM4P2_aVerticalZigzagScan; 119 break; 120 } 121 122 case OMX_VC_VERTICAL: 123 { 124 pZigzagTable = armVCM4P2_aHorizontalZigzagScan; 125 break; 126 } 127 } 128 129 errorCode = armVCM4P2_GetVLCBits ( 130 ppBitStream, 131 pBitOffset, 132 pDst, 133 shortVideoHeader, 134 start, 135 &last, 136 10, 137 62, 138 7, 139 21, 140 armVCM4P2_IntraL0RunIdx, 141 armVCM4P2_IntraVlcL0, 142 armVCM4P2_IntraL1RunIdx, 143 armVCM4P2_IntraVlcL1, 144 armVCM4P2_IntraL0LMAX, 145 armVCM4P2_IntraL1LMAX, 146 armVCM4P2_IntraL0RMAX, 147 armVCM4P2_IntraL1RMAX, 148 pZigzagTable ); 149 armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 150 151 if (last == 0) 152 { 153 return OMX_Sts_Err; 154 } 155 return OMX_Sts_NoErr; 156} 157 158/* End of file */ 159 160