auxFormat.c 2.24 KB
Newer Older
Zhao Xuefeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include"auxFormat.h"
void ROUND384_Three(unsigned int *s, unsigned char *c, int lunnum) {
	unsigned int t, t1, t2;
	u32 rci;
	rci = c[0];
	ROUND384_1(rci);
	t = 1;
	while (lunnum--) {
		rci = c[t];
		ROUND384_2(rci);
		t++;
		rci = c[t];
		ROUND384_3(rci);
		t++;
		rci = c[t];
		ROUND384_4(rci);
		t++;
	}
}
void packU96FormatToThreePacket(u32 *out, u8 *in) {
Wentao Zhang committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34
	u32 t0 = U32BIG(((u32*)in)[0]), t1 = U32BIG(((u32*)in)[1]), t2 = U32BIG(((u32*)in)[2]);	\
	puckU32ToThree_3(t0);	\
	puckU32ToThree_3(t1);	\
	puckU32ToThree_3(t2);	\
	out[0] = ((((t2 >> 21) & 0x400) | (((t2 >> 18) & 0x300)) | ((t2 & 0xff00) >> 8)) << 21) |										\
		     ((((t1 >> 20) & 0x400) | ((t1 >> 16) & 0x300) | (t1 & 0xff))        << 10) |									\
			 (((t0 >> 20) & 0x300) | ((t0 & 0xff0000) >> 16));								\
	out[1] = ((((t2 >> 20) & 0x400) | ((t2 >> 16) & 0x300)   | (t2 & 0xff))          << 21) |										\
		     ((((t1 >> 20) & 0x300) | ((t1 & 0xff0000) >> 16))                   << 11) |									\
		     (((t0 >> 21) & 0x400) | ((t0 >> 18) & 0x300) | ((t0 & 0xff00) >> 8));									\
	out[2] = ((((t2 >> 20) & 0x300) | ((t2 & 0xff0000) >> 16))                       << 22) |										\
		     ((((t1 >> 21) & 0x400) | ((t1 >> 18) & 0x300)|((t1 & 0xff00) >> 8)) << 11) |									\
		     (((t0 >> 20) & 0x400) | ((t0 >> 16) & 0x300) | (t0 & 0xff));									\

Zhao Xuefeng committed
35 36
}
void unpackU96FormatToThreePacket(u8 *out, u32 *in) {
Wentao Zhang committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
	u32 t[3] = { 0 } ;\
u32 t0 = in[0], t1 = in[1], t2 = in[2];		 \
t[0] = ((t1 & 0x400) << 21) | ((t2 & 0x400) << 20) |		 \
((t0 & 0x300) << 20) | ((t1 & 0x300) << 18) | ((t2 & 0x300) << 16) |		 \
((t0 & 0xff) << 16) | ((t1 & 0xff) << 8) | (t2 & 0xff);		 \
t[1] = ((t2 & 0x200000) << 10) | ((t0 & 0x100000) << 10) | ((t1 & 0x180000) << 9) | ((t2 & 0x180000) << 7) |		 \
((t0 & 0xc0000) << 6) | ((t1 & 0x7f800) << 5) | ((t2 & 0x7f800) >> 3) |		 \
((t0 & 0x3fc00) >> 10);		 \
t[2] = ((t0 & 0x80000000)) | ((t1 & 0x80000000) >> 1) | ((t2 & 0xc0000000) >> 2) |		 \
((t0 & 0x60000000) >> 3) | ((t1 & 0x60000000) >> 5) | ((t2 & 0x3fc00000) >> 6) |		 \
((t0 & 0x1fe00000) >> 13) | ((t1 & 0x1fe00000) >> 21);		 \
unpuckU32ToThree_3(t[0]);		 \
unpuckU32ToThree_3(t[1]);		 \
unpuckU32ToThree_3(t[2]);		 \
memcpy(out, t, 12 * sizeof(unsigned char));		 \
Zhao Xuefeng committed
52
}
Wentao Zhang committed
53