[MPlayer-dev-eng] [PATCH] get rid of min/max macros in aviheader.h
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Dec 7 13:37:39 CET 2006
Hello,
use of these macros has spread like a cancer to completely unrelated
parts.
My suggestion (attached) replaces them by FFMIN/FFMAX. If the min/max
names are dear to somebody than can be discussed, just leaving the in
aviheader.h is unacceptable IMO.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/ae_pcm.c
===================================================================
--- libmpcodecs/ae_pcm.c (revision 21523)
+++ libmpcodecs/ae_pcm.c (working copy)
@@ -36,7 +36,7 @@
static int encode_pcm(audio_encoder_t *encoder, uint8_t *dest, void *src, int nsamples, int max_size)
{
- max_size = min(nsamples, max_size);
+ max_size = FFMIN(nsamples, max_size);
memcpy(dest, src, max_size);
return max_size;
}
Index: libmpcodecs/vd_ffmpeg.c
===================================================================
--- libmpcodecs/vd_ffmpeg.c (revision 21523)
+++ libmpcodecs/vd_ffmpeg.c (working copy)
@@ -392,11 +392,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_SIZE));
+ FFMIN(sh->bih->biSize-sizeof(BITMAPINFOHEADER), AVPALETTE_SIZE));
else
/* Palette size in biClrUsed */
memcpy(avctx->palctrl->palette, sh->bih+1,
- min(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
+ FFMIN(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
}
if(sh->bih)
Index: libmpcodecs/ve_x264.c
===================================================================
--- libmpcodecs/ve_x264.c (revision 21523)
+++ libmpcodecs/ve_x264.c (working copy)
@@ -124,7 +124,7 @@
if(turbo == 1)
{
param.i_frame_reference = ( param.i_frame_reference + 1 ) >> 1;
- param.analyse.i_subpel_refine = max( min( 3, param.analyse.i_subpel_refine - 1 ), 1 );
+ param.analyse.i_subpel_refine = FFMAX( FFMIN( 3, param.analyse.i_subpel_refine - 1 ), 1 );
param.analyse.inter &= ( ~X264_ANALYSE_PSUB8x8 );
param.analyse.inter &= ( ~X264_ANALYSE_BSUB16x16 );
param.analyse.i_trellis = 0;
Index: libmpcodecs/ad_hwmpa.c
===================================================================
--- libmpcodecs/ad_hwmpa.c (revision 21523)
+++ libmpcodecs/ad_hwmpa.c (working copy)
@@ -96,7 +96,7 @@
if(start + len > sh->a_in_buffer_len)
{
int l;
- l = min(sh->a_in_buffer_size - sh->a_in_buffer_len, start + len);
+ l = FFMIN(sh->a_in_buffer_size - sh->a_in_buffer_len, start + len);
l = demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], l);
if(! l)
break;
Index: libmpdemux/demux_ts.c
===================================================================
--- libmpdemux/demux_ts.c (revision 21524)
+++ libmpdemux/demux_ts.c (working copy)
@@ -1174,7 +1174,7 @@
while(i < sl->ts_len)
{
- m = min(8, sl->ts_len - i);
+ m = FFMIN(8, sl->ts_len - i);
v |= getbits(buf, n, m);
if(sl->ts_len - i > 8)
v <<= 8;
@@ -1193,7 +1193,7 @@
pl_size = 0;
while(i < sl->au_len)
{
- m = min(8, sl->au_len - i);
+ m = FFMIN(8, sl->au_len - i);
pl_size |= getbits(buf, n, m);
if(sl->au_len - i > 8)
pl_size <<= 8;
@@ -1662,7 +1662,7 @@
int i = 0, j, size = 0;
mp_msg(MSGT_DEMUX, MSGL_DBG2, "PARSE_MP4_DESC_LEN(%d), bytes: ", *len);
- j = min(*len, 4);
+ j = FFMIN(*len, 4);
while(i < j)
{
mp_msg(MSGT_DEMUX, MSGL_DBG2, " %x ", buf[i]);
@@ -2957,7 +2957,7 @@
if(tss->payload_size > 0)
{
- sz = min(tss->payload_size, buf_size);
+ sz = FFMIN(tss->payload_size, buf_size);
tss->payload_size -= sz;
es->size = sz;
}
Index: libmpdemux/demux_mpg.c
===================================================================
--- libmpdemux/demux_mpg.c (revision 21524)
+++ libmpdemux/demux_mpg.c (working copy)
@@ -57,7 +57,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 streams map
- es_map_len = min(es_map_len, len - prog_len - 8); //sanity check
+ es_map_len = FFMIN(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);
@@ -91,7 +91,7 @@
mp_dbg(MSGT_DEMUX,MSGL_V, "PSM ES, id=0x%x, type=%x, stype: %x\n", id, type, priv->es_map[idoffset]);
}
plen = stream_read_word(demux->stream); //length of elementary stream descriptors
- plen = min(plen, es_map_len); //sanity check
+ plen = FFMIN(plen, es_map_len); //sanity check
stream_skip(demux->stream, plen); //skip descriptors for now
es_map_len -= 4 + plen;
}
Index: libmpdemux/aviheader.h
===================================================================
--- libmpdemux/aviheader.h (revision 21524)
+++ libmpdemux/aviheader.h (working copy)
@@ -5,18 +5,6 @@
#include "libavutil/common.h"
#include "mpbswap.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 ) | \
Index: libmpdemux/demux_ogg.c
===================================================================
--- libmpdemux/demux_ogg.c (revision 21525)
+++ libmpdemux/demux_ogg.c (working copy)
@@ -593,7 +593,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,FFMAX(ogg_d->pos,demuxer->movi_end-270000));
}
ogg_sync_reset(sync);
Index: libmpdemux/demux_vqf.c
===================================================================
--- libmpdemux/demux_vqf.c (revision 21524)
+++ libmpdemux/demux_vqf.c (working copy)
@@ -98,31 +98,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,FFMIN(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,FFMIN(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,FFMIN(BUFSIZ,slen));
demux_info_add(demuxer,"Comment",sdata);
}
else
if(sid==mmioFOURCC('(','c',')',' '))
{
- memcpy(hi->Cpyr,sdata,min(BUFSIZ,slen));
+ memcpy(hi->Cpyr,sdata,FFMIN(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,FFMIN(BUFSIZ,slen));
}
else
if(sid==mmioFOURCC('A','L','B','M')) demux_info_add(demuxer,"Album",sdata);
Index: libmpdemux/muxer_mpeg.c
===================================================================
--- libmpdemux/muxer_mpeg.c (revision 21524)
+++ libmpdemux/muxer_mpeg.c (working copy)
@@ -936,7 +936,7 @@
{
if(!frpos && len>0 && s->type == MUXER_TYPE_VIDEO && spriv->framebuf[n].type==I_FRAME)
return len;
- m = min(spriv->framebuf[n].size - frpos, psize - len);
+ m = FFMIN(spriv->framebuf[n].size - frpos, psize - len);
len += m;
frpos += m;
if(frpos == spriv->framebuf[n].size)
@@ -997,8 +997,8 @@
if(i > -1)
{
- dpts = max(spriv->last_saved_pts, spriv->framebuf[i].pts) -
- min(spriv->last_saved_pts, spriv->framebuf[i].pts) +
+ dpts = FFMAX(spriv->last_saved_pts, spriv->framebuf[i].pts) -
+ FFMIN(spriv->last_saved_pts, spriv->framebuf[i].pts) +
spriv->framebuf[0].idur;
if(s->type != MUXER_TYPE_VIDEO)
@@ -1218,7 +1218,7 @@
update_demux_bufsize(spriv, frm->dts, frm->size, s->type);
}
- m = min(frm->size - frm->pos, priv->packet_size - spriv->pack_offset);
+ m = FFMIN(frm->size - frm->pos, priv->packet_size - spriv->pack_offset);
memcpy(&(spriv->pack[spriv->pack_offset]), &(frm->buffer[frm->pos]), m);
len += m;
@@ -2215,7 +2215,7 @@
{
stream->ckid = be2me_32 (0x1bd);
if(priv->is_genmpeg1 || priv->is_genmpeg2)
- fix_audio_sys_header(priv, spriv->id, 0xbd, max(conf_abuf_size, 58)*1024); //only one audio at the moment
+ fix_audio_sys_header(priv, spriv->id, 0xbd, FFMAX(conf_abuf_size, 58)*1024); //only one audio at the moment
spriv->id = 0xbd;
if(!conf_abuf_size)
spriv->max_buffer_size = 16*1024;
More information about the MPlayer-dev-eng
mailing list