1 /** 2 * 3 * File Name: armVCM4P2_CheckVLCEscapeMode.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 module for VLC escape mode check 14 * 15 */ 16 17 #include "omxtypes.h" 18 #include "armOMX.h" 19 20 #include "armVC.h" 21 #include "armCOMM.h" 22 23 /** 24 * Function: armVCM4P2_CheckVLCEscapeMode 25 * 26 * Description: 27 * Performs escape mode decision based on the run, run+, level, level+ and 28 * last combinations. 29 * 30 * Remarks: 31 * 32 * Parameters: 33 * [in] run Run value (count of zeros) to be encoded 34 * [in] level Level value (non-zero value) to be encoded 35 * [in] runPlus Calculated as runPlus = run - (RMAX + 1) 36 * [in] levelPlus Calculated as 37 * levelPlus = sign(level)*[abs(level) - LMAX] 38 * [in] maxStoreRun Max store possible (considering last and inter/intra) 39 * [in] maxRunForMultipleEntries 40 * The run value after which level 41 * will be equal to 1: 42 * (considering last and inter/intra status) 43 * [in] pRunIndexTable Run Index table defined in 44 * armVCM4P2_Huff_Tables_VLC.c 45 * (considering last and inter/intra status) 46 * 47 * 48 * Return Value: 49 * Returns an Escape mode which can take values from 0 to 3 50 * 0 --> no escape mode, 1 --> escape type 1, 51 * 1 --> escape type 2, 3 --> escape type 3, check section 7.4.1.3 52 * in the MPEG ISO standard. 53 * 54 */ 55 56 OMX_U8 armVCM4P2_CheckVLCEscapeMode( 57 OMX_U32 run, 58 OMX_U32 runPlus, 59 OMX_S16 level, 60 OMX_S16 levelPlus, 61 OMX_U8 maxStoreRun, 62 OMX_U8 maxRunForMultipleEntries, 63 OMX_INT shortVideoHeader, 64 const OMX_U8 *pRunIndexTable 65 ) 66 { 67 OMX_U8 escape = 0, fMode = 0, entries; 68 69 level = armAbs (level); 70 levelPlus = armAbs (levelPlus); 71 72 /* Check for a valid entry with run, level and Last combination 73 Mode 0 check */ 74 if (run <= maxStoreRun) 75 { 76 entries = pRunIndexTable[run + 1] 77 - pRunIndexTable[run]; 78 if (run > maxRunForMultipleEntries) 79 { 80 entries = 1; 81 } 82 if (level > entries) 83 { 84 escape = 1; 85 } 86 } 87 else 88 { 89 escape = 1; 90 } 91 if(escape && shortVideoHeader) 92 { 93 escape = 0; 94 fMode = 4; 95 } 96 /* Check for a valid entry with run, levelPlus and Last combination 97 Mode 1 check */ 98 if (escape) 99 { 100 escape = 0; 101 fMode = 1; 102 if (run <= maxStoreRun) 103 { 104 entries = pRunIndexTable[run + 1] 105 - pRunIndexTable[run]; 106 if (run > maxRunForMultipleEntries) 107 { 108 entries = 1; 109 } 110 if (levelPlus > entries) 111 { 112 escape = 1; 113 } 114 } 115 else 116 { 117 escape = 1; 118 } 119 } 120 121 /* Check for a valid entry with runPlus, level and Last combination 122 Mode 2 check */ 123 if (escape) 124 { 125 escape = 0; 126 fMode = 2; 127 if (runPlus <= maxStoreRun) 128 { 129 entries = pRunIndexTable[runPlus + 1] 130 - pRunIndexTable[runPlus]; 131 if (runPlus > maxRunForMultipleEntries) 132 { 133 entries = 1; 134 } 135 if (level > entries) 136 { 137 escape = 1; 138 } 139 } 140 else 141 { 142 escape = 1; 143 } 144 } 145 146 /* select mode 3 --> FLC */ 147 if (escape) 148 { 149 fMode = 3; 150 } 151 152 return fMode; 153 } 154 155 /*End of File*/ 156 157