Exemplo n.º 1
0
void	decode_patch_header(LLBitPack &bitpack, LLPatchHeader *ph)
{
	U8 retvalu8;

	retvalu8 = 0;
	bitpack.bitUnpack(&retvalu8, 8);
	ph->quant_wbits = retvalu8;

	if (END_OF_PATCHES == ph->quant_wbits)
	{
		// End of data, blitz the rest.
		ph->dc_offset = 0;
		ph->range = 0;
		ph->patchids = 0;
		return;
	}

	U32 retvalu32 = 0;
#ifdef LL_BIG_ENDIAN
	U8 *ret = (U8 *)&retvalu32;
	bitpack.bitUnpack(&(ret[3]), 8);
	bitpack.bitUnpack(&(ret[2]), 8);
	bitpack.bitUnpack(&(ret[1]), 8);
	bitpack.bitUnpack(&(ret[0]), 8);
#else
	bitpack.bitUnpack((U8 *)&retvalu32, 32);
#endif
	ph->dc_offset = *(F32 *)&retvalu32;

	U16 retvalu16 = 0;
#ifdef LL_BIG_ENDIAN
	ret = (U8 *)&retvalu16;
	bitpack.bitUnpack(&(ret[1]), 8);
	bitpack.bitUnpack(&(ret[0]), 8);
#else
	bitpack.bitUnpack((U8 *)&retvalu16, 16);
#endif
	ph->range = retvalu16;

	retvalu16 = 0;
#ifdef LL_BIG_ENDIAN
	ret = (U8 *)&retvalu16;
	bitpack.bitUnpack(&(ret[1]), 8);
	bitpack.bitUnpack(&(ret[0]), 2);
#else
	bitpack.bitUnpack((U8 *)&retvalu16, 10);
#endif
	ph->patchids = retvalu16;

	gWordBits = (ph->quant_wbits & 0xf) + 2;
}
Exemplo n.º 2
0
void	decode_patch_group_header(LLBitPack &bitpack, LLGroupHeader *gopp)
{
	U16 retvalu16;

	retvalu16 = 0;
#ifdef LL_BIG_ENDIAN
	U8 *ret = (U8 *)&retvalu16;
	bitpack.bitUnpack(&(ret[1]), 8);
	bitpack.bitUnpack(&(ret[0]), 8);
#else
	bitpack.bitUnpack((U8 *)&retvalu16, 16);
#endif
	gopp->stride = retvalu16;

	U8 retvalu8 = 0;
	bitpack.bitUnpack(&retvalu8, 8);
	gopp->patch_size = retvalu8;

	retvalu8 = 0;
	bitpack.bitUnpack(&retvalu8, 8);
	gopp->layer_type = retvalu8;

	gPatchSize = gopp->patch_size; 
}
Exemplo n.º 3
0
void	decode_patch(LLBitPack &bitpack, S32 *patches)
{
#ifdef LL_BIG_ENDIAN
	S32		i, j, patch_size = gPatchSize, wbits = gWordBits;
	U8		tempu8;
	U16		tempu16;
	U32		tempu32;
	for (i = 0; i < patch_size*patch_size; i++)
	{
		bitpack.bitUnpack((U8 *)&tempu8, 1);
		if (tempu8)
		{
			// either 0 EOB or Value
			bitpack.bitUnpack((U8 *)&tempu8, 1);
			if (tempu8)
			{
				// value
				bitpack.bitUnpack((U8 *)&tempu8, 1);
				if (tempu8)
				{
					// negative
					patches[i] = -1;
				}
				else
				{
					// positive
					patches[i] = 1;
				}
				if (wbits <= 8)
				{
					bitpack.bitUnpack((U8 *)&tempu8, wbits);
					patches[i] *= tempu8;
				}
				else if (wbits <= 16)
				{
					tempu16 = 0;
					U8 *ret = (U8 *)&tempu16;
					bitpack.bitUnpack(&(ret[1]), 8);
					bitpack.bitUnpack(&(ret[0]), wbits - 8);
					patches[i] *= tempu16;
				}
				else if (wbits <= 24)
				{
					tempu32 = 0;
					U8 *ret = (U8 *)&tempu32;
					bitpack.bitUnpack(&(ret[2]), 8);
					bitpack.bitUnpack(&(ret[1]), 8);
					bitpack.bitUnpack(&(ret[0]), wbits - 16);
					patches[i] *= tempu32;
				}
				else if (wbits <= 32)
				{
					tempu32 = 0;
					U8 *ret = (U8 *)&tempu32;
					bitpack.bitUnpack(&(ret[3]), 8);
					bitpack.bitUnpack(&(ret[2]), 8);
					bitpack.bitUnpack(&(ret[1]), 8);
					bitpack.bitUnpack(&(ret[0]), wbits - 24);
					patches[i] *= tempu32;
				}
			}
			else
			{
				for (j = i; j < patch_size*patch_size; j++)
				{
					patches[j] = 0;
				}
				return;
			}
		}
		else
		{
			patches[i] = 0;
		}
	}
#else
	S32		i, j, patch_size = gPatchSize, wbits = gWordBits;
	U32		temp;
	for (i = 0; i < patch_size*patch_size; i++)
	{
		temp = 0;
		bitpack.bitUnpack((U8 *)&temp, 1);
		if (temp)
		{
			// either 0 EOB or Value
			temp = 0;
			bitpack.bitUnpack((U8 *)&temp, 1);
			if (temp)
			{
				// value
				temp = 0;
				bitpack.bitUnpack((U8 *)&temp, 1);
				if (temp)
				{
					// negative
					temp = 0;
					bitpack.bitUnpack((U8 *)&temp, wbits);
					patches[i] = temp;
					patches[i] *= -1;
				}
				else
				{
					// positive
					temp = 0;
					bitpack.bitUnpack((U8 *)&temp, wbits);
					patches[i] = temp;
				}
			}
			else
			{
				for (j = i; j < patch_size*patch_size; j++)
				{
					patches[j] = 0;
				}
				return;
			}
		}
		else
		{
			patches[i] = 0;
		}
	}
#endif
}
Exemplo n.º 4
0
// <FS:CR> Aurora Sim
//void	decode_patch_header(LLBitPack &bitpack, LLPatchHeader *ph)
void	decode_patch_header(LLBitPack &bitpack, LLPatchHeader *ph, bool b_large_patch)
// </FS:CR> Aurora Sim
{
	U8 retvalu8;

	retvalu8 = 0;
	bitpack.bitUnpack(&retvalu8, 8);
	ph->quant_wbits = retvalu8;

	if (END_OF_PATCHES == ph->quant_wbits)
	{
		// End of data, blitz the rest.
		ph->dc_offset = 0;
		ph->range = 0;
		ph->patchids = 0;
		return;
	}

	U32 retvalu32 = 0;
#ifdef LL_BIG_ENDIAN
	U8 *ret = (U8 *)&retvalu32;
	bitpack.bitUnpack(&(ret[3]), 8);
	bitpack.bitUnpack(&(ret[2]), 8);
	bitpack.bitUnpack(&(ret[1]), 8);
	bitpack.bitUnpack(&(ret[0]), 8);
#else
	bitpack.bitUnpack((U8 *)&retvalu32, 32);
#endif
	ph->dc_offset = *(F32 *)&retvalu32;

	U16 retvalu16 = 0;
#ifdef LL_BIG_ENDIAN
	ret = (U8 *)&retvalu16;
	bitpack.bitUnpack(&(ret[1]), 8);
	bitpack.bitUnpack(&(ret[0]), 8);
#else
	bitpack.bitUnpack((U8 *)&retvalu16, 16);
#endif
	ph->range = retvalu16;

// <FS:CR> Aurora Sim
	//retvalu16 = 0;
	retvalu32 = 0;
#ifdef LL_BIG_ENDIAN
	//ret = (U8 *)&retvalu16;
	ret = (U8*)&retvalu32;
// </FS:CR> Aurora Sim
	if (b_large_patch)
	{
		bitpack.bitUnpack(&(ret[3]), 8);
		bitpack.bitUnpack(&(ret[2]), 8);
		bitpack.bitUnpack(&(ret[1]), 8);
		bitpack.bitUnpack(&(ret[0]), 8);
	}
	else
	{
		bitpack.bitUnpack(&(ret[1]), 8);
		bitpack.bitUnpack(&(ret[0]), 2);
	}
#else
// <FS:CR> Aurora Sim
	//bitpack.bitUnpack((U8 *)&retvalu16, 10);
	bitpack.bitUnpack((U8*)&retvalu32, b_large_patch ? 32 : 10);
#endif
	//ph->patchids = retvalu16;
	ph->patchids = retvalu32;
// </FS:CR> Aurora Sim

	gWordBits = (ph->quant_wbits & 0xf) + 2;
}