From 3f1ed7cee623b64fd66fc60db62275df23177966 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Thu, 3 Nov 2005 20:16:56 +0000 Subject: [PATCH] cosmetics: XCHG macro git-svn-id: svn://svn.videolan.org/x264/trunk@359 df754926-b1dd-0310-bc7b-ec298dee348c --- common/common.h | 26 +++++++++++++++----------- common/dct.c | 2 +- common/i386/dct-c.c | 1 - encoder/encoder.c | 20 ++++---------------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/common/common.h b/common/common.h index 66203413..57c037c8 100644 --- a/common/common.h +++ b/common/common.h @@ -36,6 +36,21 @@ #define X264_VERSION "" // no configure script for msvc #endif +/**************************************************************************** + * Macros + ****************************************************************************/ +#define X264_MIN(a,b) ( (a)<(b) ? (a) : (b) ) +#define X264_MAX(a,b) ( (a)>(b) ? (a) : (b) ) +#define X264_MIN3(a,b,c) X264_MIN((a),X264_MIN((b),(c))) +#define X264_MAX3(a,b,c) X264_MAX((a),X264_MAX((b),(c))) +#define X264_MIN4(a,b,c,d) X264_MIN((a),X264_MIN3((b),(c),(d))) +#define X264_MAX4(a,b,c,d) X264_MAX((a),X264_MAX3((b),(c),(d))) +#define XCHG(type,a,b) { type t = a; a = b; b = t; } +#define FIX8(f) ((int)(f*(1<<8)+.5)) + +/**************************************************************************** + * Includes + ****************************************************************************/ #include "x264.h" #include "bs.h" #include "set.h" @@ -48,17 +63,6 @@ #include "csp.h" #include "quant.h" -/**************************************************************************** - * Macros - ****************************************************************************/ -#define X264_MIN(a,b) ( (a)<(b) ? (a) : (b) ) -#define X264_MAX(a,b) ( (a)>(b) ? (a) : (b) ) -#define X264_MIN3(a,b,c) X264_MIN((a),X264_MIN((b),(c))) -#define X264_MAX3(a,b,c) X264_MAX((a),X264_MAX((b),(c))) -#define X264_MIN4(a,b,c,d) X264_MIN((a),X264_MIN3((b),(c),(d))) -#define X264_MAX4(a,b,c,d) X264_MAX((a),X264_MAX3((b),(c),(d))) -#define FIX8(f) ((int)(f*(1<<8)+.5)) - /**************************************************************************** * Generals functions ****************************************************************************/ diff --git a/common/dct.c b/common/dct.c index df06084e..012fac80 100644 --- a/common/dct.c +++ b/common/dct.c @@ -31,7 +31,7 @@ #include "x264.h" -#include "dct.h" +#include "common.h" #ifdef HAVE_MMXEXT # include "i386/dct.h" #endif diff --git a/common/i386/dct-c.c b/common/i386/dct-c.c index ea191085..d43c2d78 100644 --- a/common/i386/dct-c.c +++ b/common/i386/dct-c.c @@ -31,7 +31,6 @@ #include "x264.h" -#include "common/dct.h" #include "dct.h" diff --git a/encoder/encoder.c b/encoder/encoder.c index 623bcd39..c57555f2 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -706,9 +706,7 @@ static void x264_frame_sort( x264_frame_t *list[X264_BFRAME_MAX+1], int b_dts ) : dtime > 0; if( swap ) { - x264_frame_t *tmp = list[i+1]; - list[i+1] = list[i]; - list[i] = tmp; + XCHG( x264_frame_t*, list[i], list[i+1] ); b_ok = 0; } } @@ -748,10 +746,7 @@ static inline void x264_reference_build_list( x264_t *h, int i_poc, int i_slice_ { if( h->fref0[i]->i_poc < h->fref0[i+1]->i_poc ) { - x264_frame_t *tmp = h->fref0[i+1]; - - h->fref0[i+1] = h->fref0[i]; - h->fref0[i] = tmp; + XCHG( x264_frame_t*, h->fref0[i], h->fref0[i+1] ); b_ok = 0; break; } @@ -765,10 +760,7 @@ static inline void x264_reference_build_list( x264_t *h, int i_poc, int i_slice_ { if( h->fref1[i]->i_poc > h->fref1[i+1]->i_poc ) { - x264_frame_t *tmp = h->fref1[i+1]; - - h->fref1[i+1] = h->fref1[i]; - h->fref1[i] = tmp; + XCHG( x264_frame_t*, h->fref1[i], h->fref1[i+1] ); b_ok = 0; break; } @@ -816,11 +808,7 @@ static inline void x264_reference_update( x264_t *h ) /* move lowres copy of the image to the ref frame */ for( i = 0; i < 4; i++) - { - uint8_t *tmp = h->fdec->lowres[i]; - h->fdec->lowres[i] = h->fenc->lowres[i]; - h->fenc->lowres[i] = tmp; - } + XCHG( uint8_t*, h->fdec->lowres[i], h->fenc->lowres[i] ); /* adaptive B decision needs a pointer, since it can't use the ref lists */ if( h->sh.i_type != SLICE_TYPE_B ) -- 2.47.3