On Mon, Feb  7, 2011 at 10:52:43 +0100, Fabian Greffrath wrote:

> +--- libmms.orig/src/bswap.h
> ++++ libmms/src/bswap.h
> +@@ -21,23 +21,50 @@
> +  */
> + 
> + 
> +-/* Go cheap now, will rip out glib later. *Sigh* */
> +-#include <glib.h>
> ++#include <stdint.h>
> + 
> +-/* NOTE:
> +- * Now, to clear up confusion: LE_XX means "from LE to native, XX bits wide"
> +- * I know it's not very clear naming (tell me about it, I
> +- * misinterpreted in first version and caused bad nasty bug, *sigh*),
> +- * but that's inherited code, will clean up as things go
> +- * Oh, and one more thing -- they take *pointers*, not actual ints
> +- */
> +-
> +-#define LE_16(val) (GINT16_FROM_LE (*((u_int16_t*)(val))))
> +-#define BE_16(val) (GINT16_FROM_BE (*((u_int16_t*)(val))))
> +-#define LE_32(val) (GINT32_FROM_LE (*((u_int32_t*)(val))))
> +-#define BE_32(val) (GINT32_FROM_BE (*((u_int32_t*)(val))))
> +-
> +-#define LE_64(val) (GINT64_FROM_LE (*((u_int64_t*)(val))))
> +-#define BE_64(val) (GINT64_FROM_BE (*((u_int64_t*)(val))))
> ++#define SWAP_ENDIAN_16(val) \
> ++    (val[1] | (val[0] << 8))

So this looks weird to me.  That macro looks like it's doing big endian
to native, not swap.  And the SAME_ENDIAN_* macros smell like little
endian to native.  Which means this is broken on BE.  Am I missing
something?

> ++#define SWAP_ENDIAN_32(val) \
> ++    (val[3] | (val[2] << 8) | (val[1] << 16) | (val[0] << 24))
> ++#define SWAP_ENDIAN_64(val) \
> ++    (val[7] | (val[6] << 8) | (val[5] << 16) | (val[4] << 24) | \
> ++    ((uint64_t)val[3] << 32) | ((uint64_t)val[2] << 40) | \
> ++    ((uint64_t)val[1] << 48) | ((uint64_t)val[0] << 56))
> ++
> ++#define SAME_ENDIAN_16(val) \
> ++    (val[0] | (val[1] << 8))
> ++#define SAME_ENDIAN_32(val) \
> ++    (val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24))
> ++#define SAME_ENDIAN_64(val) \
> ++    (val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24) | \
> ++    ((uint64_t)val[4] << 32) | ((uint64_t)val[5] << 40) | \
> ++    ((uint64_t)val[6] << 48) | ((uint64_t)val[7] << 56))
> ++

Cheers,
Julien

_______________________________________________
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-multimedia-maintainers

Reply via email to