diff --git a/inc/byteswapdefs.h b/inc/byteswapdefs.h index 9c9d1ac..83cc6d1 100644 --- a/inc/byteswapdefs.h +++ b/inc/byteswapdefs.h @@ -10,16 +10,6 @@ static inline unsigned int swapx(unsigned int word) { return (((word >> 16) & 0xffff) | ((word & 0xffff) << 16)); } -/****************************************************************/ -/* */ -/* Byte-swap a single 2-byte word */ -/* */ -/****************************************************************/ -static inline unsigned short byte_swap_word(unsigned short word) { - return ((word >> 8) | (unsigned short)((word & 0xff) << 8)); -} - -void byte_swap_page(unsigned short *page, int wordcount); void word_swap_page(unsigned short *page, int longwordcount); void bit_reverse_region(unsigned short *top, int width, int height, int rasterwidth); #ifdef RESWAPPEDCODESTREAM diff --git a/src/byteswap.c b/src/byteswap.c index 51f7c2c..ae52456 100644 --- a/src/byteswap.c +++ b/src/byteswap.c @@ -19,33 +19,18 @@ /* */ /***************************************************************************/ +#include #include "byteswapdefs.h" #include "lsptypes.h" -/****************************************************************/ -/* */ -/* Byte-swap a region wordcount words long */ -/* This does NOT swap words in a long-word! */ -/* */ -/****************************************************************/ -void byte_swap_page(unsigned short *page, int wordcount) { - int i; - for (i = 0; i < wordcount; i++) { *(page + i) = byte_swap_word(*(page + i)); } -} - /****************************************************************/ /* */ /* Byte- & word-swap a region wordcount long-words long */ /* */ /****************************************************************/ void word_swap_page(unsigned short *page, int longwordcount) { - int i; - unsigned int *longpage; - longpage = (unsigned int *)page; - for (i = 0; i < (longwordcount + longwordcount); i++) { - *(page + i) = byte_swap_word(*(page + i)); - } - for (i = 0; i < longwordcount; i++) { *(longpage + i) = swapx(*(longpage + i)); } + unsigned int *longpage = (unsigned int *)page; + for (int i = 0; i < longwordcount; i++) { *(longpage + i) = ntohl(*(longpage + i)); } } /****************************************************************/