[MPlayer-dev-eng] [PATCH] Re: min() and max() macro definitions

adland adland123 at yahoo.com
Sat Mar 19 09:05:49 CET 2005


> muxer_mpeg.c:996:1: warning: "max" redefined
> In file included from muxer_mpeg.c:13:
> aviheader.h:16:1: warning: this is the location of the previous definition
> muxer_mpeg.c:997:1: warning: "min" redefined
> aviheader.h:12:1: warning: this is the location of the previous definition
> 
> Could we have just one set of definitions in a common header?
> These are different, so some other changes in code may be necessary, too. 

here is what I found 

HEADERS
aviheader defines both   MIN and min 
                                         MIN(a,b) (((a)<(b))?(a):(b))
                                         min(a,b) (((a)<(b))?(a):(b))
                                         but not MAX just max
                                         max(a,b) (((a)>(b))?(a):(b))


there is also definition 
MIN  in  asf.h surrounded by #ifndef
               MIN(a,b) (((a)<(b))?(a):(b))


C FILES
MAX in demux_mkv.c:#if !defined(MAX) or #if !defined(MIN)
               MAX(a, b)   ((a)>(b)?(a):(b))
               MIN(a, b)       ((a)<(b)?(a):(b))

MIN in aviheader.c
               #define MIN(a,b) (((a)<(b))?(a):(b))
             

dvbin.c:#define min(a, b) ((a) <= (b) ? (a) : (b))
mpeg_hdr.c:#define min(a, b) ((a) <= (b) ? (a) : (b))
muxer_mpeg.c: #define both min and max

just a note that MIN1(a,b) (((a)<(b))?(a):(b))
             and MIN2(a,b) ((a) <= (b) ? (a) : (b))

are equivalent macros because if a==b then either value is minimal 
with MIN1 we would return b and MIN2 returns a  - the values are same.
simmilar with MAX

so yes we can consolidate the macros in one header file
say called macros.h

deleted all other definitions of MIN,min,MAX,max
replaced all instances of min with MIN
replaced all instance of max with MAX
added includes for macros.h in C files where needed.
make distclean
configure
compiled
tested

here is the patch

--- main/macros.h	1969-12-31 19:00:00.000000000 -0500
+++ updated/macros.h	2005-03-19 01:20:59.000000000 -0500
@@ -0,0 +1,19 @@
+
+#ifdef max
+#undef max
+#endif
+
+#ifdef min
+#undef min
+#endif
+
+#ifdef MAX
+#undef MAX
+#endif
+
+#ifdef MIN
+#undef MIN
+#endif
+
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#define MIN(a,b) (((a)<(b))?(a):(b))
--- main/vobsub.c	2004-12-25 18:58:53.000000000 -0500
+++ updated/vobsub.c	2005-03-19 01:20:53.000000000 -0500
@@ -24,8 +24,7 @@
#include "unrarlib.h"
#endif

-#define MIN(a, b)	((a)<(b)?(a):(b))
-#define MAX(a, b)	((a)>(b)?(a):(b))
+#include "macros.h"

extern int vobsub_id;

--- main/spudec.c	2005-01-13 09:32:26.000000000 -0500
+++ updated/spudec.c	2005-03-19 01:24:08.000000000 -0500
@@ -24,8 +24,7 @@
#include "libvo/video_out.h"
#include "spudec.h"
#include "postproc/swscale.h"
-
-#define MIN(a, b)	((a)<(b)?(a):(b))
+#include "macros.h"

/* Valid values for spu_aamode:
0: none (fastest, most ugly)
--- main/subreader.c	2005-02-19 13:04:04.000000000 -0500
+++ updated/subreader.c	2005-03-19 01:26:11.000000000 -0500
@@ -1179,9 +1179,7 @@
#endif

#ifdef USE_FRIBIDI
-#ifndef max
-#define max(a,b)  (((a)>(b))?(a):(b))
-#endif
+#include "macros.h"
subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
{
   FriBidiChar logical[LINE_LEN+1], visual[LINE_LEN+1]; // Hopefully these two 
won't smash the stack
@@ -1216,7 +1214,7 @@
if(log2vis) {
len = fribidi_remove_bidi_marks (visual, len, NULL, NULL,
NULL);
-      if((op = (char*)malloc(sizeof(char)*(max(2*orig_len,2*len) + 1))) == NUL
L) {
+      if((op = (char*)malloc(sizeof(char)*(MAX(2*orig_len,2*len) + 1))) == NUL
L) {
mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n");
l++;
break;
--- main/libmpdemux/aviheader.h	2004-07-12 12:57:05.000000000 -0400
+++ updated/libmpdemux/aviheader.h	2005-03-19 00:35:47.000000000 -0500
@@ -4,18 +4,6 @@
//#include "config.h"	/* get correct definition WORDS_BIGENDIAN */
#include "bswap.h"

-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
-#ifndef min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-
-#ifndef max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
#ifndef mmioFOURCC
#define mmioFOURCC( ch0, ch1, ch2, ch3 )				\
( (uint32_t)(uint8_t)(ch0) | ( (uint32_t)(uint8_t)(ch1) << 8 ) |	\
--- main/libmpdemux/asf.h	2003-01-15 06:16:31.000000000 -0500
+++ updated/libmpdemux/asf.h	2005-03-19 00:38:27.000000000 -0500
@@ -5,10 +5,6 @@
#include <inttypes.h>
#include "bswap.h"

-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
///////////////////////
// MS GUID definition
///////////////////////
--- main/libmpdemux/asf_streaming.c	2005-02-04 10:28:02.000000000 -0500
+++ updated/libmpdemux/asf_streaming.c	2005-03-19 02:34:42.000000000 -0500
@@ -6,6 +6,7 @@
#include <limits.h>

#include "config.h"
+#include "../macros.h"

#ifndef HAVE_WINSOCK2
#define closesocket close
--- main/libmpdemux/aviheader.c	2005-02-23 11:50:50.000000000 -0500
+++ updated/libmpdemux/aviheader.c	2005-03-19 01:21:42.000000000 -0500
@@ -14,9 +14,7 @@
#include "bswap.h"
#include "aviheader.h"

-#define MIN(a,b) (((a)<(b))?(a):(b))
-
-
+#include "../macros.h"
static MainAVIHeader avih;

extern void print_avih(MainAVIHeader *h);
@@ -701,6 +699,5 @@
}
}

-#undef MIN


--- main/libmpdemux/dvbin.c	2005-01-13 09:32:32.000000000 -0500
+++ updated/libmpdemux/dvbin.c	2005-03-19 01:22:10.000000000 -0500
@@ -44,11 +44,10 @@
#include "../m_struct.h"

#include "dvbin.h"
-
+#include "../macros.h"

#define MAX_CHANNELS 8
#define CHANNEL_LINE_LEN 256
-#define min(a, b) ((a) <= (b) ? (a) : (b))


//TODO: CAMBIARE list_ptr e da globale a per_priv
--- main/libmpdemux/demux_mkv.c	2005-03-04 12:27:50.000000000 -0500
+++ updated/libmpdemux/demux_mkv.c	2005-03-19 01:21:56.000000000 -0500
@@ -19,6 +19,7 @@
#include "ebml.h"
#include "matroska.h"
#include "bswap.h"
+#include "../macros.h"

#include "../subreader.h"
#include "../libvo/sub.h"
@@ -37,13 +38,6 @@
#include "../libmpcodecs/native/minilzo.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
-
typedef struct
{
uint32_t order, type, scope;
--- main/libmpdemux/mpeg_hdr.c	2005-03-04 12:27:50.000000000 -0500
+++ updated/libmpdemux/mpeg_hdr.c	2005-03-19 01:22:30.000000000 -0500
@@ -7,6 +7,7 @@

#include "config.h"
#include "mpeg_hdr.h"
+#include "../macros.h"

static int frameratecode2framerate[16] = {
0,
@@ -212,8 +213,6 @@
n = read_timeinc(picture, buffer, n);
}

-#define min(a, b) ((a) <= (b) ? (a) : (b))
-
static unsigned int read_golomb(unsigned char *buffer, unsigned int *init)
{
unsigned int x, v = 0, v2 = 0, m, len = 0, n = *init;
@@ -224,7 +223,7 @@
x = len + n;
while(n < x)
{
-    m = min(x - n, 8);
+    m = MIN(x - n, 8);
v |= getbits(buffer, n, m);
n += m;
if(x - n > 8)
--- main/libmpdemux/muxer_mpeg.c	2005-03-07 11:43:01.000000000 -0500
+++ updated/libmpdemux/muxer_mpeg.c	2005-03-19 02:33:26.000000000 -0500
@@ -19,6 +19,7 @@
#include "stheader.h"
#include "../m_option.h"
#include "mpeg_hdr.h"
+#include "../macros.h"

#define PACK_HEADER_START_CODE 0x01ba
#define SYSTEM_HEADER_START_CODE 0x01bb
@@ -870,10 +871,10 @@
stflen = spriv->min_pes_hlen - pes_hlen;
}

-		if((len >= priv->packet_size - pack_hlen - max(pes_hlen, spriv->min_pes_hlen
)))
+		if((len >= priv->packet_size - pack_hlen - MAX(pes_hlen, spriv->min_pes_hlen
)))
stuffing_len = 0;
else
-			stuffing_len = priv->packet_size - pack_hlen - max(pes_hlen, spriv->min_pes
_hlen) - len;
+			stuffing_len = priv->packet_size - pack_hlen - MAX(pes_hlen, spriv->min_pes
_hlen) - len;

if(stuffing_len > 0)
{
@@ -896,7 +897,7 @@
 		if(priv->skip_padding)	//variable packet size, just for fun and to reduce fi
le size
{
stuffing_len = 0;
-			len = min(len, priv->packet_size - pack_hlen - pes_hlen - stflen);
+			len = MIN(len, priv->packet_size - pack_hlen - pes_hlen - stflen);
}
else
len = priv->packet_size - pack_hlen - pes_hlen - stflen - stuffing_len;
@@ -993,9 +994,6 @@
}


-#define max(a, b) ((a) >= (b) ? (a) : (b))
-#define min(a, b) ((a) <= (b) ? (a) : (b))
-

 static uint32_t get_audio_frame_size(muxer_headers_t *spriv, uint8_t *buf, int
format, int samples_ps)
{
@@ -1133,7 +1131,7 @@
return 0;
}

-	abytes = min(abytes, as->b_buffer_len);			//available bytes
+	abytes = MIN(abytes, as->b_buffer_len);			//available bytes
if(! abytes)
return 0;

@@ -1224,7 +1222,7 @@
size1 = (div) * apriv->frame_size;

 	fprintf(stderr, "SIZE1: %llu, LEN: %llu\n", size1, (uint64_t)as->b_buffer_len
);
-	size1 = min(size1, as->b_buffer_len);
+	size1 = MIN(size1, as->b_buffer_len);
memmove(as->b_buffer, &(as->b_buffer[size]), as->b_buffer_len - size1);
as->b_buffer_len -= size1;

@@ -1351,8 +1349,8 @@
maxtr = vpriv->framebuf[0].temp_ref;
for(i = 0; i < n; i++)
{
-		mintr = min(vpriv->framebuf[i].temp_ref, mintr);
-		maxtr = max(vpriv->framebuf[i].temp_ref, maxtr);
+		mintr = MIN(vpriv->framebuf[i].temp_ref, mintr);
+		maxtr = MAX(vpriv->framebuf[i].temp_ref, maxtr);
}
if(maxtr - mintr > 600)	//there must be a temp_ref wraparound
{
@@ -1431,7 +1429,7 @@
{
uint64_t dpts;

-	dpts = max(vpriv->last_saved_pts, vpriv->pts) - min(vpriv->last_saved_pts, vp
riv->pts);
+	dpts = MAX(vpriv->last_saved_pts, vpriv->pts) - MIN(vpriv->last_saved_pts, vp
riv->pts);
dpts += vpriv->framebuf[i].idur;

if((!priv->ts_allframes) && (
@@ -1664,7 +1662,7 @@

while((tmp_offset < target_size) && (i < n))
{
-						pl_size = min(target_size - tmp_offset, vbytes);
+						pl_size = MIN(target_size - tmp_offset, vbytes);
 						memcpy(&(tmp[tmp_offset]), &(vpriv->framebuf[i].buffer[offset]), pl_size
);
tmp_offset += pl_size;
offset += pl_size;
@@ -1702,20 +1700,20 @@
}

/* this is needed to calculate SCR */
-				frame_bytes = max(vpriv->framebuf[i].size, priv->packet_size) + priv->pack
et_size;
+				frame_bytes = MAX(vpriv->framebuf[i].size, priv->packet_size) + priv->pack
et_size;
if(abytes > 0)
-					//frame_bytes += min(apriv->max_pl_size, priv->packet_size) + audio_rest;
-					frame_bytes += min(apriv->max_pl_size, abytes) + audio_rest;
+					//frame_bytes += MIN(apriv->max_pl_size, priv->packet_size) + audio_rest;
+					frame_bytes += MIN(apriv->max_pl_size, abytes) + audio_rest;

if(priv->ts_allframes)
{
tot = frame_bytes;
-					mult = (double) vpriv->framebuf[min(i, n-1)].idur;
+					mult = (double) vpriv->framebuf[MIN(i, n-1)].idur;
}
else
{
tot = bytes;
-					//mult = (double) (max(iduration, iaduration));
+					//mult = (double) (MAX(iduration, iaduration));
mult = (double) (iduration);
}
update_scr(priv, pl_size, tot, mult);
@@ -1990,7 +1988,7 @@
case 2: // predictive
if (s->ipb[0]) {
sz = len + s->ipb[0];
-			    s->ipb[0] = max(s->ipb[0], s->ipb[2]);
+			    s->ipb[0] = MAX(s->ipb[0], s->ipb[2]);
s->ipb[2] = 0;
} else if (s->ipb[2]) {
sz = len + s->ipb[2];
@@ -2273,7 +2271,7 @@
}
}

-	sz = max(len, 2 * priv->packet_size);
+	sz = MAX(len, 2 * priv->packet_size);
}

if (s->h.dwSampleSize) {
--- main/libmpdemux/demux_ts.c	2005-02-25 20:01:41.000000000 -0500
+++ updated/libmpdemux/demux_ts.c	2005-03-19 02:27:06.000000000 -0500
@@ -36,6 +36,7 @@

#include "bswap.h"
#include "../unrarlib.h"
+#include "../macros.h"

#define TS_PH_PACKET_SIZE 192
#define TS_FEC_PACKET_SIZE 204
@@ -1224,7 +1225,7 @@
}

if(priv->pat.skip)
-		    m = min(priv->pat.skip, size);
+		    m = MIN(priv->pat.skip, size);

priv->pat.skip -= m;
if(m == size)
@@ -1234,7 +1235,7 @@
{
priv->pat.buffer_len = 0;
skip = buff[0]+1;
-		m = min(skip, size);
+		m = MIN(skip, size);

priv->pat.skip = skip - m;

@@ -1463,7 +1464,7 @@
}

if(pmt->skip)
-		    m = min(pmt->skip, size);
+		    m = MIN(pmt->skip, size);

pmt->skip -= m;
if(m == size)
@@ -1473,7 +1474,7 @@
{
pmt->buffer_len = 0;
skip = buff[0] + 1;
-		m = min(skip, size);
+		m = MIN(skip, size);

pmt->skip = skip - m;

@@ -1811,7 +1812,7 @@
c = stream_read_char(stream);
buf_size--;

-				c = min(c, buf_size);
+				c = MIN(c, buf_size);
stream_skip(stream, c);
buf_size -= c;
if(buf_size == 0)
@@ -2101,7 +2102,7 @@

if(tss->payload_size > 0)
{
-				sz = min(tss->payload_size, buf_size);
+				sz = MIN(tss->payload_size, buf_size);
tss->payload_size -= sz;
es->size = sz;
}
--- main/libmpdemux/demux_mpg.c	2005-03-06 21:43:07.000000000 -0500
+++ updated/libmpdemux/demux_mpg.c	2005-03-19 02:29:43.000000000 -0500
@@ -13,6 +13,7 @@
#include "parse_es.h"
#include "stheader.h"
#include "mp3_hdr.h"
+#include "../macros.h"

//#define MAX_PS_PACKETSIZE 2048
#define MAX_PS_PACKETSIZE (224*1024)
@@ -54,7 +55,7 @@
prog_len = stream_read_word(demux->stream);		//length of program descriptors
stream_skip(demux->stream, prog_len);			//.. that we ignore
   es_map_len = stream_read_word(demux->stream);		//length of elementary stream
s map
-  es_map_len = min(es_map_len, len - prog_len - 8);	//sanity check
+  es_map_len = MIN(es_map_len, len - prog_len - 8);	//sanity check
while(es_map_len > 0) {
type = stream_read_char(demux->stream);
id = stream_read_char(demux->stream);
@@ -88,7 +89,7 @@
       mp_dbg(MSGT_DEMUX,MSGL_V, "PSM ES, id=0x%x, type=%x, stype: %x\n", id, t
ype, priv->es_map[idoffset]);
}
     plen = stream_read_word(demux->stream);		//length of elementary stream des
criptors
-    plen = min(plen, es_map_len);			//sanity check
+    plen = MIN(plen, es_map_len);			//sanity check
stream_skip(demux->stream, plen);			//skip descriptors for now
es_map_len -= 4 + plen;
}
--- main/libmpdemux/demux_vqf.c	2004-12-29 14:51:56.000000000 -0500
+++ updated/libmpdemux/demux_vqf.c	2005-03-19 02:31:14.000000000 -0500
@@ -8,6 +8,7 @@
#include "demuxer.h"
#include "stheader.h"
#include "../libmpcodecs/vqf.h"
+#include "../macros.h"

extern void resync_audio_stream(sh_audio_t *sh_audio);

@@ -98,31 +99,31 @@
memcpy(sdata,&buf[i],slen); sdata[slen]=0; i+=slen;
if(sid==mmioFOURCC('N','A','M','E'))
{
-        memcpy(hi->Name,sdata,min(BUFSIZ,slen));
+        memcpy(hi->Name,sdata,MIN(BUFSIZ,slen));
demux_info_add(demuxer,"Title",sdata);
}
else
if(sid==mmioFOURCC('A','U','T','H'))
{
-        memcpy(hi->Auth,sdata,min(BUFSIZ,slen));
+        memcpy(hi->Auth,sdata,MIN(BUFSIZ,slen));
demux_info_add(demuxer,"Author",sdata);
}
else
if(sid==mmioFOURCC('C','O','M','T'))
{
-        memcpy(hi->Comt,sdata,min(BUFSIZ,slen));
+        memcpy(hi->Comt,sdata,MIN(BUFSIZ,slen));
demux_info_add(demuxer,"Comment",sdata);
}
else
if(sid==mmioFOURCC('(','c',')',' '))
{
-        memcpy(hi->Cpyr,sdata,min(BUFSIZ,slen));
+        memcpy(hi->Cpyr,sdata,MIN(BUFSIZ,slen));
demux_info_add(demuxer,"Copyright",sdata);
}
else
if(sid==mmioFOURCC('F','I','L','E'))
{
-        memcpy(hi->File,sdata,min(BUFSIZ,slen));
+        memcpy(hi->File,sdata,MIN(BUFSIZ,slen));
}
else
         if(sid==mmioFOURCC('A','L','B','M')) demux_info_add(demuxer,"Album",sd
ata);
--- main/libmpdemux/demux_ogg.c	2005-03-04 12:27:50.000000000 -0500
+++ updated/libmpdemux/demux_ogg.c	2005-03-19 02:32:38.000000000 -0500
@@ -14,6 +14,7 @@
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
+#include "../macros.h"

#define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's')
#define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o')
@@ -584,7 +585,7 @@
stream_seek(s,demuxer->movi_start);
} else {
//the 270000 are just a wild guess
-    stream_seek(s,max(ogg_d->pos,demuxer->movi_end-270000));
+    stream_seek(s,MAX(ogg_d->pos,demuxer->movi_end-270000));
}
ogg_sync_reset(sync);

--- main/libmpdemux/realrtsp/real.c	2004-12-20 01:27:36.000000000 -0500
+++ updated/libmpdemux/realrtsp/real.c	2005-03-19 01:23:02.000000000 -0500
@@ -36,6 +36,7 @@
#include "asmrp.h"
#include "sdpplin.h"
#include "xbuffer.h"
+#include "../../macros.h"

/*
#define LOG
@@ -55,10 +56,6 @@

#define BE_32(x)  be2me_32(*(uint32_t*)(x))

-#ifndef MAX
-#define MAX(x,y) ((x>y) ? x : y)
-#endif
-
#ifdef LOG
static void hexdump (const char *buf, int length) {

--- main/libaf/af.h	2005-03-04 12:27:49.000000000 -0500
+++ updated/libaf/af.h	2005-03-19 01:34:27.000000000 -0500
@@ -7,6 +7,7 @@
#include "config.h"
#include "control.h"
#include "af_format.h"
+#include "../macros.h"

struct af_instance_s;

@@ -225,16 +226,8 @@
((a->data->len < af_lencalc(a->mul,d))?af_resize_local_buffer(a,d):AF_OK)

/* Some other useful macro definitions*/
-#ifndef min
-#define min(a,b)(((a)>(b))?(b):(a))
-#endif
-
-#ifndef max
-#define max(a,b)(((a)>(b))?(a):(b))
-#endif
-
#ifndef clamp
-#define clamp(a,min,max) (((a)>(max))?(max):(((a)<(min))?(min):(a)))
+#define clamp(a,MIN,MAX) (((a)>(MAX))?(MAX):(((a)<(MIN))?(MIN):(a)))
#endif

#ifndef sign
--- main/libaf/af_channels.c	2005-01-13 09:32:30.000000000 -0500
+++ updated/libaf/af_channels.c	2005-03-19 01:34:43.000000000 -0500
@@ -131,14 +131,14 @@

// If mono: fake stereo
if(((af_data_t*)arg)->nch == 1){
-	s->nr = min(af->data->nch,2);
+	s->nr = MIN(af->data->nch,2);
for(i=0;i<s->nr;i++){
s->route[i][FR] = 0;
s->route[i][TO] = i;
}
}
else{
-	s->nr = min(af->data->nch, ((af_data_t*)arg)->nch);
+	s->nr = MIN(af->data->nch, ((af_data_t*)arg)->nch);
for(i=0;i<s->nr;i++){
s->route[i][FR] = i;
s->route[i][TO] = i;
--- main/libaf/af_center.c	2005-02-21 12:08:45.000000000 -0500
+++ updated/libaf/af_center.c	2005-03-19 01:35:22.000000000 -0500
@@ -33,7 +33,7 @@
if(!arg) return AF_ERROR;

af->data->rate   = ((af_data_t*)arg)->rate;
-    af->data->nch    = max(s->ch+1,((af_data_t*)arg)->nch);
+    af->data->nch    = MAX(s->ch+1,((af_data_t*)arg)->nch);
af->data->format = AF_FORMAT_FLOAT_NE;
af->data->bps    = 4;

--- main/libaf/af_resample.c	2005-01-13 09:32:31.000000000 -0500
+++ updated/libaf/af_resample.c	2005-03-19 01:36:01.000000000 -0500
@@ -221,7 +221,7 @@
s->dn = n->rate/d;

// Calculate cuttof frequency for filter
-      fc = 1/(float)(max(s->up,s->dn));
+      fc = 1/(float)(MAX(s->up,s->dn));
// Allocate space for polyphase filter bank and protptype filter
w = malloc(sizeof(float) * s->up *L);
if(NULL != s->w)
--- main/libaf/af_sub.c	2005-01-13 09:32:31.000000000 -0500
+++ updated/libaf/af_sub.c	2005-03-19 01:36:19.000000000 -0500
@@ -60,7 +60,7 @@
if(!arg) return AF_ERROR;

af->data->rate   = ((af_data_t*)arg)->rate;
-    af->data->nch    = max(s->ch+1,((af_data_t*)arg)->nch);
+    af->data->nch    = MAX(s->ch+1,((af_data_t*)arg)->nch);
af->data->format = AF_FORMAT_FLOAT_NE;
af->data->bps    = 4;

--- main/libaf/af_volume.c	2005-02-04 10:28:02.000000000 -0500
+++ updated/libaf/af_volume.c	2005-03-19 01:36:32.000000000 -0500
@@ -111,7 +111,7 @@
int i;
if(!s->fast){
for(i=0;i<AF_NCH;i++)
-	m=max(m,s->max[i]);
+	m=MAX(m,s->max[i]);
af_to_dB(1, &m, &m, 10.0);
af_msg(AF_MSG_INFO,"[volume] The maximum volume was %0.2fdB \n", m);
}
--- main/postproc/swscale.c	2005-02-23 11:50:51.000000000 -0500
+++ updated/postproc/swscale.c	2005-03-19 01:47:34.000000000 -0500
@@ -75,6 +75,7 @@
#include "../libvo/img_format.h"
#include "rgb2rgb.h"
#include "../libvo/fastmemcpy.h"
+#include "../macros.h"

#undef MOVNTQ
#undef PAVGB
@@ -151,8 +152,6 @@
*/

#define ABS(a) ((a) > 0 ? (a) : (-(a)))
-#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=       0xF8F8F8
F8F8F8F8F8LL;
--- main/postproc/swscale_altivec_template.c	2004-07-07 13:09:18.000000000 -040
0
+++ updated/postproc/swscale_altivec_template.c	2005-03-19 01:52:07.000000000 -
0500
@@ -19,6 +19,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
+#include "../macros.h"

#ifdef CONFIG_DARWIN
#define AVV(x...) (x)
--- main/postproc/swscale_template.c	2005-02-19 13:04:10.000000000 -0500
+++ updated/postproc/swscale_template.c	2005-03-19 01:50:33.000000000 -0500
@@ -15,6 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
+#include "../macros.h"

#undef REAL_MOVNTQ
#undef MOVNTQ
--- main/libmpcodecs/ve_xvid4.c	2005-03-04 12:27:49.000000000 -0500
+++ updated/libmpcodecs/ve_xvid4.c	2005-03-19 01:58:31.000000000 -0500
@@ -56,6 +56,7 @@
#include <assert.h>

#include "m_option.h"
+#include "../macros.h"

#define XVID_FIRST_PASS_FILENAME "xvid-twopass.stats"
#define FINE (!0)
@@ -68,7 +69,6 @@
int den;
} XVIDRational;

-#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : (-(a)))


--- main/libmpcodecs/vf_bmovl.c	2003-12-10 07:28:20.000000000 -0500
+++ updated/libmpcodecs/vf_bmovl.c	2005-03-19 01:59:24.000000000 -0500
@@ -71,6 +71,7 @@
#ifndef HAVE_NO_POSIX_SELECT

#include "../mp_msg.h"
+#include "../macros.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  )
--- main/libmpcodecs/vf_delogo.c	2003-10-06 14:11:38.000000000 -0400
+++ updated/libmpcodecs/vf_delogo.c	2005-03-19 02:00:13.000000000 -0500
@@ -36,6 +36,7 @@
#include "mp_image.h"
#include "vf.h"
#include "../libvo/fastmemcpy.h"
+#include "../macros.h"

#include "m_option.h"
#include "m_struct.h"
@@ -50,8 +51,6 @@
0, 0, 0, 0, 0, 0
};

-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))

 static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, i
nt width, int height,
 		   int logo_x, int logo_y, int logo_w, int logo_h, int band, int show, int d
irect) {
--- main/libmpcodecs/vf_filmdint.c	2004-10-21 16:59:52.000000000 -0400
+++ updated/libmpcodecs/vf_filmdint.c	2005-03-19 02:02:35.000000000 -0500
@@ -7,6 +7,7 @@
#include "../config.h"
#include "../mp_msg.h"
#include "../cpudetect.h"
+#include "../macros.h"

#include "img_format.h"
#include "mp_image.h"
@@ -83,13 +84,6 @@
extern int opt_screen_size_x;
extern int opt_screen_size_y;

-#ifndef MIN
-#define        MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef MAX
-#define        MAX(a,b) (((a)>(b))?(a):(b))
-#endif
-
 static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, in
t height, int dstStride, int srcStride)
{
int i;
--- main/libmpcodecs/vf_spp.c	2005-02-19 13:04:10.000000000 -0500
+++ updated/libmpcodecs/vf_spp.c	2005-03-19 02:03:56.000000000 -0500
@@ -53,8 +53,7 @@
#include "mp_image.h"
#include "vf.h"
#include "../libvo/fastmemcpy.h"
-
-#define XMIN(a,b) ((a) < (b) ? (a) : (b))
+#include "../macros.h"

 //===========================================================================/
/
static const uint8_t  __attribute__((aligned(8))) dither[8][8]={
@@ -407,7 +406,7 @@
if(p->qp)
qp= p->qp;
else{
-				qp= qp_store[ (XMIN(x, width-1)>>qps) + (XMIN(y, height-1)>>qps) * qp_stri
de];
+				qp= qp_store[ (MIN(x, width-1)>>qps) + (MIN(y, height-1)>>qps) * qp_stride
];
if(p->mpeg2) qp>>=1;
}
for(i=0; i<count; i++){
@@ -422,7 +421,7 @@
}
}
if(y)
-			store_slice(dst + (y-8)*dst_stride, p->temp + 8 + y*stride, dst_stride, str
ide, width, XMIN(8, height+8-y), 6-p->log2_count);
+			store_slice(dst + (y-8)*dst_stride, p->temp + 8 + y*stride, dst_stride, str
ide, width, MIN(8, height+8-y), 6-p->log2_count);
}
#if 0
for(y=0; y<height; y++){
--- main/libmpcodecs/vd_ffmpeg.c	2005-01-27 21:19:52.000000000 -0500
+++ updated/libmpcodecs/vd_ffmpeg.c	2005-03-19 02:05:23.000000000 -0500
@@ -6,6 +6,7 @@
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "../macros.h"

#ifdef USE_LIBAVCODEC

@@ -350,11 +351,11 @@
if (sh->bih->biSize-sizeof(BITMAPINFOHEADER))
/* Palette size in biSize */
memcpy(avctx->palctrl->palette, sh->bih+1,
-                   min(sh->bih->biSize-sizeof(BITMAPINFOHEADER), AVPALETTE_SIZ
E));
+                   MIN(sh->bih->biSize-sizeof(BITMAPINFOHEADER), AVPALETTE_SIZ
E));
else
/* Palette size in biClrUsed */
memcpy(avctx->palctrl->palette, sh->bih+1,
-                   min(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
+                   MIN(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
}
#endif
if (sh->ImageDesc &&

enclosed is a test patch
thanks





More information about the MPlayer-dev-eng mailing list