示例#1
0
		private int DecodeSignificantAbsLevel(CAdaptiveHuffman pAHexpt)
		{
			int iFixed, iLevel;

			uint iIndex = (uint)pAHexpt.GetHuff(bitIO);
			System.Diagnostics.Debug.Assert( iIndex <= 6 );

			pAHexpt.m_iDiscriminant += pAHexpt.m_pDelta[iIndex];
			if (iIndex < 2)
			{
				iLevel = (int)(iIndex + 2);
			}
			else if (iIndex < 6)
			{
				iFixed = (int)Constant.aFixedLength[iIndex];
				iLevel = (int)Constant.aRemap[iIndex] + bitIO.GetBit16((uint)iFixed);
			}
			else
			{
				iFixed = (int)bitIO.GetBit16(4) + 4;
				if (iFixed == 19)
				{
					iFixed += bitIO.GetBit16(2);
					if (iFixed == 22)
					{
						iFixed += bitIO.GetBit16(3);
					}
				}
				iLevel = 2 + (1 << (byte)iFixed);
				iIndex = bitIO.GetBit32((uint)iFixed);
				iLevel += (int)iIndex;
			}

			return iLevel;
		}
示例#2
0
		private void DecodeFirstIndex(out int pIndex, out int pSign, CAdaptiveHuffman pAHexpt)
		{
			pIndex = pAHexpt.GetHuff(bitIO);
			pAHexpt.m_iDiscriminant  += pAHexpt.m_pDelta[(uint)pIndex];
			pAHexpt.m_iDiscriminant1 += pAHexpt.m_pDelta1[(uint)pIndex];
			pSign = -bitIO.GetBit16(1);
		}
示例#3
0
		private void DecodeIndex(out int pIndex, out int pSign, int iLoc, CAdaptiveHuffman pAHexpt)
		{
			if (iLoc < 15)
			{
				pIndex = pAHexpt.GetHuffShort(bitIO);
				pAHexpt.m_iDiscriminant  += pAHexpt.m_pDelta[(uint)pIndex];
				pAHexpt.m_iDiscriminant1 += pAHexpt.m_pDelta1[(uint)pIndex];
				pSign = -bitIO.GetBit16(1);
			}
			else 
				if (iLoc == 15)
				{
					if (!bitIO.GetBool16())
					{
						pIndex = 0;
					}
					else
						if (!bitIO.GetBool16())
						{
							pIndex = 2;
						}
						else
						{
							pIndex = 1 + 2 * bitIO.GetBit16(1);
						}
					pSign = -bitIO.GetBit16(1);
				}
			else { //if (iLoc == 16) { /* deterministic */
				int iSL = bitIO.GetBit16(1 + 1);
				pIndex = iSL >> 1;
				pSign = -(iSL & 1);
			}
		}
示例#4
0
		/*************************************************************************
			Experimental code -- decodeBlock
			SR = <0 1 2> == <last, nonsignificant, significant run>
			alphabet 12:
				pAHexpt[0] == <SR', SL, SR | first symbol>
			alphabet 6:
				pAHexpt[1] == <SR', SL | continuous>
				pAHexpt[2] == <SR', SL | continuous>
			alphabet 4:
				pAHexpt[3] == <SR', SL | 2 free slots> (SR may be last or insignificant only)
			alphabet f(run) (this can be extended to 6 contexts - SL and SR')
				pAHexpt[4] == <run | continuous>
			alphabet f(lev) (this can be extended to 9 contexts)
				pAHexpt[5-6] == <lev | continuous> first symbol
				pAHexpt[7-8] == <lev | continuous> condition on SRn no use
		*************************************************************************/
		private int DecodeSignificantRun(int iMaxRun, CAdaptiveHuffman pAHexpt)
		{
			if (iMaxRun < 5)
			{
				if (iMaxRun == 1 || bitIO.GetBool16())
				{
					return 1;
				}
				else
					if (iMaxRun == 2 || bitIO.GetBool16())
					{
						return 2;
					}
					else
						if (iMaxRun == 3 || bitIO.GetBool16())
						{
							return 3;
						}
				return 4;
			}

			int iIndex = pAHexpt.GetHuffShort(bitIO);
			//this always uses table 0
			iIndex += (int)Constant.gSignificantRunBin[iMaxRun] * 5;
			int iRun = Constant.aRemap2[iIndex];
			uint iFLC = Constant.gSignificantRunFixedLength[iIndex];
			if (iFLC != 0)
			{
				iRun += bitIO.GetBit16(iFLC);
			}
			
			return iRun;
		}