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