if (a1->op == ACTION_IF || a1->op == ACTION_JUMP)
{
- *(U16*)(a1->data) = SWAP16(len);
+ *(U16*)(a1->data) = LE_16_TO_NATIVE(len);
}
else if(a1->op == ACTION_WAITFORFRAME)
{
ActionTAG* action_GotoFrame(ActionTAG*atag, U16 frame)
{
atag = swf_AddActionTAG(atag, ACTION_GOTOFRAME, 0, 2);
- *(U16*)atag->tmp = SWAP16(frame);
+ *(U16*)atag->tmp = LE_16_TO_NATIVE(frame);
return atag;
}
ActionTAG* action_Jump(ActionTAG*atag, U16 branch)
{
atag = swf_AddActionTAG(atag, ACTION_JUMP, 0, 2);
- *(U16*)atag->tmp = SWAP16(branch);
+ *(U16*)atag->tmp = LE_16_TO_NATIVE(branch);
return atag;
}
ActionTAG* action_If(ActionTAG*atag, U16 branch)
{
atag = swf_AddActionTAG(atag, ACTION_IF, 0, 2);
- *(U16*)atag->tmp = SWAP16(branch);
+ *(U16*)atag->tmp = LE_16_TO_NATIVE(branch);
return atag;
}
ActionTAG* action_StoreRegister(ActionTAG*atag, U8 reg)
ActionTAG* action_WaitForFrame(ActionTAG*atag, U16 frame, U8 skip)
{
atag = swf_AddActionTAG(atag, ACTION_WAITFORFRAME, 0, 3);
- *(U16*)atag->tmp = SWAP16(frame);
+ *(U16*)atag->tmp = LE_16_TO_NATIVE(frame);
*(U8*)&atag->tmp[2] = skip;
return atag;
}
int id;
if (reader->read(reader, &raw, 2) !=2 ) return NULL;
- raw = SWAP16(raw);
+ raw = LE_16_TO_NATIVE(raw);
len = raw&0x3f;
id = raw>>6;
#endif
if (short_tag)
- { raw[0] = SWAP16(len|((t->id&0x3ff)<<6));
+ { raw[0] = LE_16_TO_NATIVE(len|((t->id&0x3ff)<<6));
if (writer->write(writer,raw,2)!=2)
{
#ifdef DEBUG_RFXSWF
}
else
{
- raw[0] = SWAP16((t->id<<6)|0x3f);
+ raw[0] = LE_16_TO_NATIVE((t->id<<6)|0x3f);
if (writer->write(writer,raw,2)!=2)
{
#ifdef DEBUG_RFXSWF
reader_GetRect(reader, &swf->movieSize);
reader->read(reader, &swf->frameRate, 2);
- swf->frameRate = SWAP16(swf->frameRate);
+ swf->frameRate = LE_16_TO_NATIVE(swf->frameRate);
reader->read(reader, &swf->frameCount, 2);
- swf->frameCount = SWAP16(swf->frameCount);
+ swf->frameCount = LE_16_TO_NATIVE(swf->frameCount);
/* read tags and connect to list */
t1.next = 0;
#define GET32(ptr) (((U16)(((U8*)(ptr))[0]))+(((U16)(((U8*)(ptr))[1]))<<8)+(((U16)(((U8*)(ptr))[2]))<<16)+(((U16)(((U8*)(ptr))[3]))<<24))
#ifdef WORDS_BIGENDIAN
-#define SWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
-#define SWAP32(s) (SWAP16(((s)>>16)&0x0000ffff)|((SWAP16(s)<<16)&0xffff0000))
-#define REVERSESWAP16(x) (x)
-#define REVERSESWAP32(x) (x)
+#define LE_16_TO_NATIVE(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
+#define LE_32_TO_NATIVE(s) (LE_16_TO_NATIVE(((s)>>16)&0x0000ffff)|((LE_16_TO_NATIVE(s)<<16)&0xffff0000))
+#define BE_16_TO_NATIVE(x) (x)
+#define BE_32_TO_NATIVE(x) (x)
#else
-#define SWAP16(x) (x)
-#define SWAP32(x) (x)
-#define REVERSESWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
-#define REVERSESWAP32(s) (REVERSESWAP16(((s)>>16)&0x0000ffff)|((REVERSESWAP16(s)<<16)&0xffff0000))
+#define LE_16_TO_NATIVE(x) (x)
+#define LE_32_TO_NATIVE(x) (x)
+#define BE_16_TO_NATIVE(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
+#define BE_32_TO_NATIVE(s) (BE_16_TO_NATIVE(((s)>>16)&0x0000ffff)|((BE_16_TO_NATIVE(s)<<16)&0xffff0000))
#endif
// SWF Types
return 0;
if(!fread(head, 4, 1, fi))
return 0;
- len = REVERSESWAP32(len);
+ len = BE_32_TO_NATIVE(len);
if(destlen) *destlen = len;
if(destdata) {
if(len)
{
unsigned int a;
fread(&a,4,1,fi);
- return REVERSESWAP32(a);
+ return BE_32_TO_NATIVE(a);
}
struct png_header
if(!strncasecmp(id, "IHDR", 4)) {
char a,b,c,f,i;
if(len < 8) exit(1);
- header->width = REVERSESWAP32(*(U32*)&data[0]);
- header->height = REVERSESWAP32(*(U32*)&data[4]);
+ header->width = BE_32_TO_NATIVE(*(U32*)&data[0]);
+ header->height = BE_32_TO_NATIVE(*(U32*)&data[4]);
a = data[8]; // should be 8
b = data[9]; // should be 3(indexed), 2(rgb), 0(grayscale) or 6(truecolor+alpha)
static void png_start_chunk(FILE*fi, char*type, int len)
{
U8 mytype[4]={0,0,0,0};
- U32 mylen = REVERSESWAP32(len);
+ U32 mylen = BE_32_TO_NATIVE(len);
memcpy(mytype,type,strlen(type));
fwrite(&mylen, 4, 1, fi);
mycrc32=0xffffffff;
}
static void png_end_chunk(FILE*fi)
{
- U32 tmp = REVERSESWAP32((mycrc32^0xffffffff));
+ U32 tmp = BE_32_TO_NATIVE((mycrc32^0xffffffff));
fwrite(&tmp,4,1,fi);
}