[MPlayer-cvslog] r22395 - in trunk: libmpcodecs/vf_bmovl.c libmpcodecs/vf_unsharp.c libmpdemux/demux_gif.c libmpdemux/demux_mkv.c vobsub.c
reimar
subversion at mplayerhq.hu
Thu Mar 1 13:54:09 CET 2007
Author: reimar
Date: Thu Mar 1 13:54:08 2007
New Revision: 22395
Modified:
trunk/libmpcodecs/vf_bmovl.c
trunk/libmpcodecs/vf_unsharp.c
trunk/libmpdemux/demux_gif.c
trunk/libmpdemux/demux_mkv.c
trunk/vobsub.c
Log:
Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
Modified: trunk/libmpcodecs/vf_bmovl.c
==============================================================================
--- trunk/libmpcodecs/vf_bmovl.c (original)
+++ trunk/libmpcodecs/vf_bmovl.c Thu Mar 1 13:54:08 2007
@@ -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 @@ put_image(struct vf_instance_s* vf, mp_i
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 ) {
Modified: trunk/libmpcodecs/vf_unsharp.c
==============================================================================
--- trunk/libmpcodecs/vf_unsharp.c (original)
+++ trunk/libmpcodecs/vf_unsharp.c Thu Mar 1 13:54:08 2007
@@ -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 @@ static void parse( FilterParam *fp, char
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, ':' );
Modified: trunk/libmpdemux/demux_gif.c
==============================================================================
--- trunk/libmpdemux/demux_gif.c (original)
+++ trunk/libmpdemux/demux_gif.c Thu Mar 1 13:54:08 2007
@@ -160,10 +160,10 @@ static int demux_gif_fill_buffer(demuxer
{
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
Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c (original)
+++ trunk/libmpdemux/demux_mkv.c Thu Mar 1 13:54:08 2007
@@ -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 @@ vobsub_parse_palette (mkv_track_t *t, co
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))
Modified: trunk/vobsub.c
==============================================================================
--- trunk/vobsub.c (original)
+++ trunk/vobsub.c Thu Mar 1 13:54:08 2007
@@ -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 @@ vobsub_parse_palette(vobsub_t *vob, cons
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 @@ create_idx(vobsub_out_t *me, const unsig
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);
}
More information about the MPlayer-cvslog
mailing list