[mythtv] #define MAX
Paul Andreassen
paulx at andreassen.com.au
Mon Dec 12 05:03:49 EST 2005
Hi,
While writing a patch, I needed a max function and so wrote a simple marco as
any c programmer does. Thinking about it further I realised that not only
does MythTv use c++ but also QT, so surely there must already be a max
function. Sure enough QT has one called QMAX defined in qglobal.h. Better
yet c++ has one called max as a template in <limits>
By greping MythTv source there are multiple definations. The worst is the
#define max(a,b) ((a < b) ? b : a) which has to be fixed.
$ grep -ir "max(" * | grep "define" | grep -v ".svn" | sed"s/:#/:\n#/"
libs/libmythtv/minilzo.cpp:
#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
libs/libmythtv/minilzo.cpp:
#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
libs/libmythtv/minilzo.cpp:
#define LZO_STYPE_MAX(b) (((1l << (8*(b)-2)) - 1l) + (1l << (8*(b)-2)))
libs/libmythtv/minilzo.cpp:
#define LZO_UTYPE_MAX(b) (((1ul << (8*(b)-1)) - 1ul) + (1ul << (8*(b)-1)))
libs/libmythtv/minilzo.cpp:
# define SIZE_T_MAX LZO_UTYPE_MAX(SIZEOF_SIZE_T)
libs/libmythsoundtouch/TDStretch.cpp:
#define max(a,b) ((a < b) ? b : a)
libs/libmythsoundtouch/RateTransposer.cpp:
#define max(a,b) ((a < b) ? b : a)
libs/libmythsamplerate/common.h:
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
libs/libmyth/bio2jack.c:
#define max(a,b) (((a) < (b)) ? (b) : (a))
libs/libavcodec/i386/mpegvideo_mmx_template.c:
#define PMAX(a,b) \
libs/libavcodec/i386/mpegvideo_mmx_template.c:
#define PMAX(a,b) \
libs/libavcodec/libpostproc/postprocess_template.c:
#define REAL_FIND_MIN_MAX(addr)\
libs/libavcodec/libpostproc/postprocess_template.c:
#define REAL_FIND_MIN_MAX(addr)\
libs/libavcodec/libpostproc/postprocess_template.c:
#define FIND_MIN_MAX(addr) REAL_FIND_MIN_MAX(addr)
libs/libavcodec/libpostproc/postprocess.c:
#define MAX(a,b) ((a) < (b) ? (b) : (a))
libs/libavcodec/dct-test.c:
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
libs/libavutil/common.h:
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
What is the correct max function to use?
Paul
--
More information about the mythtv-dev
mailing list