From 159ef4b02a231259da95af3e7384c216f3252abd Mon Sep 17 00:00:00 2001 From: Vladimir Voroshilov Date: Sat, 19 Apr 2008 17:07:58 +0000 Subject: [PATCH] Implement FFMAX3(a,b,c) - maximum over three arguments. Originally committed as revision 12910 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/h263.c | 2 +- libavcodec/h264.c | 2 +- libavcodec/mjpegbdec.c | 2 +- libavcodec/mjpegdec.c | 2 +- libavcodec/mpegvideo_enc.c | 2 +- libavformat/matroskadec.c | 4 ++-- libavutil/common.h | 1 + 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 3446204c6f..ad54203930 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -3100,7 +3100,7 @@ int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s){ case FF_S_TYPE: return s->f_code+15; case FF_B_TYPE: - return FFMAX(FFMAX(s->f_code, s->b_code)+15, 17); + return FFMAX3(s->f_code, s->b_code, 2) + 15; default: return -1; } diff --git a/libavcodec/h264.c b/libavcodec/h264.c index a1d4b0dfe3..219c6875fe 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -6502,7 +6502,7 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8 //for sufficiently low qp, filtering wouldn't do anything //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp if(!FRAME_MBAFF){ - int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX(0, FFMAX(h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1])); + int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]); int qp = s->current_picture.qscale_table[mb_xy]; if(qp <= qp_thresh && (mb_x == 0 || ((qp + s->current_picture.qscale_table[mb_xy-1] + 1)>>1) <= qp_thresh) diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index 0f27379f30..a6c409a902 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -123,7 +123,7 @@ read_header: *data_size = sizeof(AVFrame); if(!s->lossless){ - picture->quality= FFMAX(FFMAX(s->qscale[0], s->qscale[1]), s->qscale[2]); + picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); picture->qstride= 0; picture->qscale_table= s->qscale_table; memset(picture->qscale_table, picture->quality, (s->width+15)/16); diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 8390412408..5f43cb5b4d 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1284,7 +1284,7 @@ eoi_parser: *data_size = sizeof(AVFrame); if(!s->lossless){ - picture->quality= FFMAX(FFMAX(s->qscale[0], s->qscale[1]), s->qscale[2]); + picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); picture->qstride= 0; picture->qscale_table= s->qscale_table; memset(picture->qscale_table, picture->quality, (s->width+15)/16); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a04e818327..b2e3a369b8 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2814,7 +2814,7 @@ static int encode_picture(MpegEncContext *s, int picture_number) int a,b; a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I); - s->f_code= FFMAX(s->f_code, FFMAX(a,b)); + s->f_code= FFMAX3(s->f_code, a, b); } ff_fix_long_p_mvs(s); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 321968a98d..25fbdd5967 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -98,8 +98,8 @@ typedef struct MatroskaSubtitleTrack { //.. } MatroskaSubtitleTrack; -#define MAX_TRACK_SIZE (FFMAX(FFMAX(sizeof(MatroskaVideoTrack), \ - sizeof(MatroskaAudioTrack)), \ +#define MAX_TRACK_SIZE (FFMAX3(sizeof(MatroskaVideoTrack), \ + sizeof(MatroskaAudioTrack), \ sizeof(MatroskaSubtitleTrack))) typedef struct MatroskaLevel { diff --git a/libavutil/common.h b/libavutil/common.h index e9d96db78a..6615ded044 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -111,6 +111,7 @@ #define FFSIGN(a) ((a) > 0 ? 1 : -1) #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)