[Ffmpeg-devel] [PATCH] move BE/LE macros to libavutil
Reimar Döffinger
Reimar.Doeffinger
Sun Nov 19 12:44:24 CET 2006
Hello,
do you think this is okay, as in the attached patch? I already know a
few place in MPlayer that could avoid code duplication with that.
Though I also wonder if they should have a FF prefix (though they seem
to be constructed to allow them to be overridden by defines in system
headers?).
Any comments?
Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavutil/common.h
===================================================================
--- libavutil/common.h (revision 7124)
+++ libavutil/common.h (working copy)
@@ -171,6 +171,20 @@
# include "internal.h"
#endif
+/* endian macros */
+#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
+#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
+ (((uint8_t*)(x))[1] << 16) | \
+ (((uint8_t*)(x))[2] << 8) | \
+ ((uint8_t*)(x))[3])
+#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
+#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
+ (((uint8_t*)(x))[2] << 16) | \
+ (((uint8_t*)(x))[1] << 8) | \
+ ((uint8_t*)(x))[0])
+#endif
+
//rounded divison & shift
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
/* assume b>0 */
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h (revision 7124)
+++ libavcodec/avcodec.h (working copy)
@@ -2683,20 +2683,6 @@
int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
int padtop, int padbottom, int padleft, int padright, int *color);
-/* endian macros */
-#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
-#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
-#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
- (((uint8_t*)(x))[1] << 16) | \
- (((uint8_t*)(x))[2] << 8) | \
- ((uint8_t*)(x))[3])
-#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
-#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
- (((uint8_t*)(x))[2] << 16) | \
- (((uint8_t*)(x))[1] << 8) | \
- ((uint8_t*)(x))[0])
-#endif
-
extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
#ifdef __cplusplus
More information about the ffmpeg-devel
mailing list