From 6f209cb54994160ed90f9c07033bbddef05064bc Mon Sep 17 00:00:00 2001 From: Luca Abeni Date: Wed, 26 Jul 2006 13:19:02 +0000 Subject: [PATCH] Replace MIN() and MAX() with FFMIN() and FFMAX() Originally committed as revision 19186 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale --- libswscale/swscale.c | 31 ++++++++++++++----------------- libswscale/swscale_altivec_template.c | 12 ++++++------ libswscale/swscale_template.c | 2 +- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 9fcb44c..0cb5337 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -151,9 +151,6 @@ add BGR4 output support write special BGR->BGR scaler */ -#define MIN(a,b) ((a) > (b) ? (b) : (a)) -#define MAX(a,b) ((a) < (b) ? (b) : (a)) - #if defined(ARCH_X86) || defined(ARCH_X86_64) static uint64_t attribute_used __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL; static uint64_t attribute_used __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL; @@ -252,7 +249,7 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt for(j=0; j>19, 0), 255); + dest[i]= FFMIN(FFMAX(val>>19, 0), 255); } if(uDest != NULL) @@ -267,8 +264,8 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt v += chrSrc[j][i + 2048] * chrFilter[j]; } - uDest[i]= MIN(MAX(u>>19, 0), 255); - vDest[i]= MIN(MAX(v>>19, 0), 255); + uDest[i]= FFMIN(FFMAX(u>>19, 0), 255); + vDest[i]= FFMIN(FFMAX(v>>19, 0), 255); } } @@ -285,7 +282,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil for(j=0; j>19, 0), 255); + dest[i]= FFMIN(FFMAX(val>>19, 0), 255); } if(uDest == NULL) @@ -303,8 +300,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil v += chrSrc[j][i + 2048] * chrFilter[j]; } - uDest[2*i]= MIN(MAX(u>>19, 0), 255); - uDest[2*i+1]= MIN(MAX(v>>19, 0), 255); + uDest[2*i]= FFMIN(FFMAX(u>>19, 0), 255); + uDest[2*i+1]= FFMIN(FFMAX(v>>19, 0), 255); } else for(i=0; i>19, 0), 255); - uDest[2*i+1]= MIN(MAX(u>>19, 0), 255); + uDest[2*i]= FFMIN(FFMAX(v>>19, 0), 255); + uDest[2*i+1]= FFMIN(FFMAX(u>>19, 0), 255); } } @@ -1168,7 +1165,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF // Move filter coeffs left to compensate for filterPos for(j=1; j=0; j--) { - int right= MIN(j + shift, filterSize-1); + int right= FFMIN(j + shift, filterSize-1); filter[i*filterSize +right] += filter[i*filterSize +j]; filter[i*filterSize +j]=0; } @@ -1404,7 +1401,7 @@ static void globalInit(void){ // generating tables: int i; for(i=0; i<768; i++){ - int c= MIN(MAX(i-256, 0), 255); + int c= FFMIN(FFMAX(i-256, 0), 255); clip_table[i]=c; } } @@ -2163,7 +2160,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int for(i=0; ichrDstH / dstH; - int nextSlice= MAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1, + int nextSlice= FFMAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1, ((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<chrSrcVSubSample)); nextSlice>>= c->chrSrcVSubSample; @@ -2515,7 +2512,7 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b){ } static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b){ - int length= MAX(a->length, b->length); + int length= FFMAX(a->length, b->length); double *coeff= av_malloc(length*sizeof(double)); int i; SwsVector *vec= av_malloc(sizeof(SwsVector)); @@ -2532,7 +2529,7 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b){ } static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b){ - int length= MAX(a->length, b->length); + int length= FFMAX(a->length, b->length); double *coeff= av_malloc(length*sizeof(double)); int i; SwsVector *vec= av_malloc(sizeof(SwsVector)); diff --git a/libswscale/swscale_altivec_template.c b/libswscale/swscale_altivec_template.c index d4a3820..a19888c 100644 --- a/libswscale/swscale_altivec_template.c +++ b/libswscale/swscale_altivec_template.c @@ -1,4 +1,4 @@ -/* +FF/* AltiVec-enhanced yuv2yuvX Copyright (C) 2004 Romain Dolbeau @@ -223,7 +223,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int for(j=0; j>7), (1<<15)-1); + dst[i] = FFMIN(FFMAX(0, val>>7), (1<<15)-1); } } else @@ -261,7 +261,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int vector signed int val_vEven = vec_mule(src_v, filter_v); vector signed int val_s = vec_sums(val_vEven, vzero); vec_st(val_s, 0, tempo); - dst[i] = MIN(MAX(0, tempo[3]>>7), (1<<15)-1); + dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); } } break; @@ -286,7 +286,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int vector signed int val_v = vec_msums(src_v, filter_v, (vector signed int)vzero); vector signed int val_s = vec_sums(val_v, vzero); vec_st(val_s, 0, tempo); - dst[i] = MIN(MAX(0, tempo[3]>>7), (1<<15)-1); + dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); } } break; @@ -315,7 +315,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int vector signed int val_s = vec_sums(val_v, vzero); vec_st(val_s, 0, tempo); - dst[i] = MIN(MAX(0, tempo[3]>>7), (1<<15)-1); + dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); } } break; @@ -376,7 +376,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int vector signed int val_s = vec_sums(val_v, vzero); vec_st(val_s, 0, tempo); - dst[i] = MIN(MAX(0, tempo[3]>>7), (1<<15)-1); + dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); } } diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index afb4318..8588820 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -2405,7 +2405,7 @@ static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW val += ((int)src[srcPos + j])*filter[filterSize*i + j]; } // filter += hFilterSize; - dst[i] = MIN(MAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ... + dst[i] = FFMIN(FFMAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ... // dst[i] = val>>7; } #endif -- 2.7.4