Mercurial > mplayer.hg
changeset 22377:fd54975f9135
Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
author | reimar |
---|---|
date | Thu, 01 Mar 2007 12:54:08 +0000 |
parents | 6c1fe779b704 |
children | dc9d2940fc05 |
files | libmpcodecs/vf_bmovl.c libmpcodecs/vf_unsharp.c libmpdemux/demux_gif.c libmpdemux/demux_mkv.c vobsub.c |
diffstat | 5 files changed, 22 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/vf_bmovl.c Thu Mar 01 12:51:33 2007 +0000 +++ b/libmpcodecs/vf_bmovl.c Thu Mar 01 12:54:08 2007 +0000 @@ -71,6 +71,7 @@ #ifndef HAVE_NO_POSIX_SELECT #include "mp_msg.h" +#include "libavutil/common.h" #include "libvo/fastmemcpy.h" @@ -89,8 +90,6 @@ #define TRUE 1 #define FALSE 0 -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define INRANGE(a,b,c) ( ((a) < (b)) ? (b) : ( ((a) > (c)) ? (c) : (a) ) ) #define rgb2y(R,G,B) ( (( 263*R + 516*G + 100*B) >> 10) + 16 ) @@ -298,10 +297,10 @@ vf->priv->x2 = vf->priv->y2 = 0; } // Define how much of our bitmap that contains graphics! - vf->priv->x1 = MAX( 0, MIN(vf->priv->x1, imgx) ); - vf->priv->y1 = MAX( 0, MIN(vf->priv->y1, imgy) ); - vf->priv->x2 = MIN( vf->priv->w, MAX(vf->priv->x2, ( imgx + imgw)) ); - vf->priv->y2 = MIN( vf->priv->h, MAX(vf->priv->y2, ( imgy + imgh)) ); + vf->priv->x1 = av_clip(imgx, 0, vf->priv->x1); + vf->priv->y1 = av_clip(imgy, 0, vf->priv->y1); + vf->priv->x2 = av_clip(imgx + imgw, vf->priv->x2, vf->priv->w); + vf->priv->y2 = av_clip(imgy + imgh, vf->priv->y2, vf->priv->h); } if( command == CMD_CLEAR ) {
--- a/libmpcodecs/vf_unsharp.c Thu Mar 01 12:51:33 2007 +0000 +++ b/libmpcodecs/vf_unsharp.c Thu Mar 01 12:54:08 2007 +0000 @@ -35,13 +35,7 @@ #include "mp_image.h" #include "vf.h" #include "libvo/fastmemcpy.h" - -#ifndef MIN -#define MIN(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef MAX -#define MAX(a,b) (((a)>(b))?(a):(b)) -#endif +#include "libavutil/common.h" //===========================================================================// @@ -258,8 +252,8 @@ fp->msizeY = ( z && z+1<max ) ? atoi( pos=z+1 ) : fp->msizeX; // min/max & odd - fp->msizeX = 1 | MIN( MAX( fp->msizeX, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); - fp->msizeY = 1 | MIN( MAX( fp->msizeY, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); + fp->msizeX = 1 | av_clip(fp->msizeX, MIN_MATRIX_SIZE, MAX_MATRIX_SIZE); + fp->msizeY = 1 | av_clip(fp->msizeY, MIN_MATRIX_SIZE, MAX_MATRIX_SIZE); // parse amount pos = strchr( pos+1, ':' );
--- a/libmpdemux/demux_gif.c Thu Mar 01 12:51:33 2007 +0000 +++ b/libmpdemux/demux_gif.c Thu Mar 01 12:54:08 2007 +0000 @@ -160,10 +160,10 @@ { int y; int cnt = FFMIN(effective_map->ColorCount, 256); - int l = FFMAX(FFMIN(gif->Image.Left, priv->w), 0); - int t = FFMAX(FFMIN(gif->Image.Top, priv->h), 0); - int w = FFMAX(FFMIN(gif->Image.Width, priv->w - l), 0); - int h = FFMAX(FFMIN(gif->Image.Height, priv->h - t), 0); + int l = av_clip(gif->Image.Left, 0, priv->w); + int t = av_clip(gif->Image.Top, 0, priv->h); + int w = av_clip(gif->Image.Width, 0, priv->w - l); + int h = av_clip(gif->Image.Height, 0, priv->h - t); unsigned char *dest = dp->buffer + priv->w * t + l; // copy the palette
--- a/libmpdemux/demux_mkv.c Thu Mar 01 12:51:33 2007 +0000 +++ b/libmpdemux/demux_mkv.c Thu Mar 01 12:54:08 2007 +0000 @@ -42,13 +42,6 @@ #include "libavutil/lzo.h" #endif -#if !defined(MIN) -#define MIN(a, b) ((a)<(b)?(a):(b)) -#endif -#if !defined(MAX) -#define MAX(a, b) ((a)>(b)?(a):(b)) -#endif - static unsigned char sipr_swaps[38][2]={ {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68}, {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46}, @@ -389,12 +382,9 @@ r = tmp >> 16 & 0xff; g = tmp >> 8 & 0xff; b = tmp & 0xff; - y = MIN(MAX((int)(0.1494 * r + 0.6061 * g + 0.2445 * b), 0), - 0xff); - u = MIN(MAX((int)(0.6066 * r - 0.4322 * g - 0.1744 * b) + 128, - 0), 0xff); - v = MIN(MAX((int)(-0.08435 * r - 0.3422 * g + 0.4266 * b) + - 128, 0), 0xff); + y = av_clip_uint8( 0.1494 * r + 0.6061 * g + 0.2445 * b); + u = av_clip_uint8( 0.6066 * r - 0.4322 * g - 0.1744 * b + 128); + v = av_clip_uint8(-0.08435 * r - 0.3422 * g + 0.4266 * b + 128); t->sh_sub.palette[i] = y << 16 | u << 8 | v; start += 6; while ((*start == ',') || isspace(*start))
--- a/vobsub.c Thu Mar 01 12:51:33 2007 +0000 +++ b/vobsub.c Thu Mar 01 12:54:08 2007 +0000 @@ -23,9 +23,7 @@ #ifdef USE_UNRARLIB #include "unrarlib.h" #endif - -#define MIN(a, b) ((a)<(b)?(a):(b)) -#define MAX(a, b) ((a)>(b)?(a):(b)) +#include "libavutil/common.h" extern int vobsub_id; @@ -820,9 +818,9 @@ r = tmp >> 16 & 0xff; g = tmp >> 8 & 0xff; b = tmp & 0xff; - y = MIN(MAX((int)(0.1494 * r + 0.6061 * g + 0.2445 * b), 0), 0xff); - u = MIN(MAX((int)(0.6066 * r - 0.4322 * g - 0.1744 * b) + 128, 0), 0xff); - v = MIN(MAX((int)(-0.08435 * r - 0.3422 * g + 0.4266 * b) + 128, 0), 0xff); + y = av_clip_uint8( 0.1494 * r + 0.6061 * g + 0.2445 * b); + u = av_clip_uint8( 0.6066 * r - 0.4322 * g - 0.1744 * b + 128); + v = av_clip_uint8(-0.08435 * r - 0.3422 * g + 0.4266 * b + 128); vob->palette[n++] = y << 16 | u << 8 | v; if (n == 16) break; @@ -1332,9 +1330,9 @@ if (i) putc(',', me->fidx); fprintf(me->fidx, " %02x%02x%02x", - MIN(MAX((int)(y + 1.4022 * u), 0), 0xff), - MIN(MAX((int)(y - 0.3456 * u - 0.7145 * v), 0), 0xff), - MIN(MAX((int)(y + 1.7710 * v), 0), 0xff)); + av_clip_uint8(y + 1.4022 * u), + av_clip_uint8(y - 0.3456 * u - 0.7145 * v), + av_clip_uint8(y + 1.7710 * v)); } putc('\n', me->fidx); }