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