?? encodecodeword.h
字號:
#include "bppmask.h"
#include "bigendian.h"
/* UWAGA fullbytes podaje wynik w bajtach, ale funkcja dziala slowami */
/* czyli i compressedrow i fullbytes jest wielokrotnoscia 4, bitsused<32 */
#define ENCODE_START(compressedrow, fullbytes, bitsused) \
{ \
unsigned int bitword=0; /* kompletowane slowo */ \ unsigned int * writeptr=(unsigned int *)(compressedrow+*fullbytes); \
/* indeks miejsca w buforze na slowo po skompletowaniu */ \
unsigned int emptybits; /* ile bitow w bitword jest jeszcze nie zapisane */ \
\
assert(((*fullbytes) % 4)==0); \
/* konieczne, dla inicjalizacji writeptr i inicjalizacji w ciele funkcji */ \
assert((((BYTE *)NULL-compressedrow) % 4) == 0); \
/* bufor zapisu zaczyna sie od wielokrotnosci 4-ch bajtow */ \
if(*bitsused) \
{ \
assert(*bitsused<32); \
BE_LOAD_WORD(writeptr, bitword); \
assert(!(bitword & bppmask[32-*bitsused])); /* czy niezapisane bity rzeczywiscie puste*/ \
} \
emptybits=32-*bitsused; \
assert(emptybits!=0);
#define ENCODE(codeword, bits) \
{ \
assert( bits<=32 ); \
assert( bits!=0 ); \
assert( !(codeword & ~bppmask[bits]) ); \
\
if (emptybits>bits) /* zmiesci sie i nie zajmie calosci, przes. w lewo i OR */ \
{ \
emptybits-=bits; \
bitword|=codeword<<emptybits; \
} \
else /* zajmie calosc, lub wiecej, konieczny zapis */ \
{ \
const unsigned int fullbits=bits-emptybits; /* ile bitow sie nie zmiesci */ \
const unsigned int towrite=bitword|(codeword>>fullbits); \
\
assert(codeword==(codeword>>0)); \
emptybits=32-fullbits; \
if(fullbits) \
bitword=codeword<<emptybits; \
else \
bitword=0; \
\
BE_STORE_WORD(writeptr++, towrite); \
} \
\
assert(emptybits!=0); \
assert(emptybits<=32); \
assert((bitword&bppmask[emptybits])==0); \
}
#define ENCODE_STOP(compressedrow, fullbytes, bitsused) \
if(emptybits!=32) \
BE_STORE_WORD(writeptr, bitword); \
\
*fullbytes=(unsigned int)((BYTE*)writeptr-compressedrow); \
*bitsused=32-emptybits; \
\
assert(!*bitsused || !(bitword & bppmask[emptybits])); \
/* czy niezapisane bity rzeczywiscie puste */ \
}
#if 0
/* wersja po wstepnej optymalizacji, moze polaczenie tego z kodowaniem */
/* da wyrazny speedup */
void encodecodewords(const thecodeword precompressedrow[], BYTE compressedrow[],
const unsigned int width,
unsigned int * fullbytes, unsigned int * bitsused)
{
unsigned int i; /* indeks kodowanego slowa */
ENCODE_START(compressedrow, fullbytes, bitsused);
for(i=0; i<width; i++)
ENCODE(precompressedrow[i].codeword, precompressedrow[i].codewordlen);
ENCODE_STOP(compressedrow, fullbytes, bitsused);
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -