[FFmpeg-devel] [PATCH 1/2] Replace FFMIN/FFMAX by type specific macros

Michael Niedermayer michael at niedermayer.cc
Sat May 31 16:32:13 EEST 2025


This allows adjusting them to exactly match whatever is fastest on
a given CPU for each type.

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 doc/examples/avio_read_callback.c     |   2 +-
 doc/examples/transcode_aac.c          |   2 +-
 fftools/cmdutils.c                    |   2 +-
 fftools/ffmpeg.c                      |   2 +-
 fftools/ffmpeg_dec.c                  |   2 +-
 fftools/ffmpeg_demux.c                |  14 +--
 fftools/ffmpeg_enc.c                  |   8 +-
 fftools/ffmpeg_mux.c                  |   2 +-
 fftools/ffmpeg_mux_init.c             |   8 +-
 fftools/ffmpeg_opt.c                  |   2 +-
 fftools/ffmpeg_sched.c                |   4 +-
 fftools/ffmpeg_utils.h                |   2 +-
 fftools/ffplay.c                      |  32 +++----
 fftools/ffprobe.c                     |   4 +-
 fftools/graph/graphprint.c            |   2 +-
 fftools/opt_common.c                  |   2 +-
 fftools/textformat/avtextformat.c     |   4 +-
 libavcodec/4xm.c                      |   4 +-
 libavcodec/8svx.c                     |   2 +-
 libavcodec/a64multienc.c              |  14 +--
 libavcodec/aac/aacdec.c               |   8 +-
 libavcodec/aac/aacdec_ac.c            |   2 +-
 libavcodec/aac_ac3_parser.c           |   2 +-
 libavcodec/aaccoder.c                 |  54 ++++++------
 libavcodec/aaccoder_twoloop.h         |  60 ++++++-------
 libavcodec/aacenc.c                   |  24 ++---
 libavcodec/aacenc_is.c                |   4 +-
 libavcodec/aacenc_tns.c               |  12 +--
 libavcodec/aacenc_utils.h             |   8 +-
 libavcodec/aacencdsp.h                |   2 +-
 libavcodec/aacps.c                    |   2 +-
 libavcodec/aacps_common.c             |   2 +-
 libavcodec/aacps_tablegen.h           |   2 +-
 libavcodec/aacpsy.c                   |  50 +++++------
 libavcodec/aacsbr.c                   |   8 +-
 libavcodec/aacsbr_template.c          |   4 +-
 libavcodec/aarch64/vvc/dsp_init.c     |   2 +-
 libavcodec/aasc.c                     |   2 +-
 libavcodec/ac3.c                      |  26 +++---
 libavcodec/ac3_parser.c               |   2 +-
 libavcodec/ac3dec.c                   |  30 +++----
 libavcodec/ac3dsp.c                   |   4 +-
 libavcodec/ac3enc.c                   |  12 +--
 libavcodec/ac3enc_fixed.c             |   4 +-
 libavcodec/ac3enc_float.c             |   2 +-
 libavcodec/ac3enc_template.c          |  14 +--
 libavcodec/acelp_pitch_delay.c        |   2 +-
 libavcodec/adpcm.c                    |  22 ++---
 libavcodec/adpcmenc.c                 |   8 +-
 libavcodec/agm.c                      |  24 ++---
 libavcodec/aic.c                      |   2 +-
 libavcodec/alac.c                     |   8 +-
 libavcodec/alacenc.c                  |   2 +-
 libavcodec/alsdec.c                   |  30 +++----
 libavcodec/amrnbdec.c                 |   6 +-
 libavcodec/amrwbdec.c                 |   8 +-
 libavcodec/anm.c                      |   2 +-
 libavcodec/ansi.c                     |  18 ++--
 libavcodec/apac.c                     |   2 +-
 libavcodec/apedec.c                   |  10 +--
 libavcodec/aptxenc.c                  |   2 +-
 libavcodec/apv_entropy.c              |  18 ++--
 libavcodec/arbc.c                     |   2 +-
 libavcodec/asvenc.c                   |   4 +-
 libavcodec/atrac3.c                   |   6 +-
 libavcodec/atrac3plusdec.c            |   2 +-
 libavcodec/atrac9dec.c                |  20 ++---
 libavcodec/audio_frame_queue.c        |   2 +-
 libavcodec/audiotoolboxenc.c          |   2 +-
 libavcodec/av1_parse.h                |   2 +-
 libavcodec/av1dec.c                   |   8 +-
 libavcodec/avs2_parser.c              |   2 +-
 libavcodec/avs3_parser.c              |   2 +-
 libavcodec/bink.c                     |   4 +-
 libavcodec/binkaudio.c                |  10 +--
 libavcodec/bmp.c                      |   2 +-
 libavcodec/bmp_parser.c               |   4 +-
 libavcodec/bonk.c                     |   4 +-
 libavcodec/bsf/dts2pts.c              |   2 +-
 libavcodec/bytestream.h               |  14 +--
 libavcodec/cavs.c                     |   2 +-
 libavcodec/cavsdec.c                  |   4 +-
 libavcodec/cbs.c                      |   2 +-
 libavcodec/cbs_av1_syntax_template.c  |   4 +-
 libavcodec/cbs_h2645.c                |   4 +-
 libavcodec/cbs_h265_syntax_template.c |   2 +-
 libavcodec/cbs_h266_syntax_template.c |   6 +-
 libavcodec/ccaption_dec.c             |   2 +-
 libavcodec/cdgraphics.c               |  10 +--
 libavcodec/cfhdenc.c                  |   4 +-
 libavcodec/cinepak.c                  |   2 +-
 libavcodec/cngdec.c                   |   2 +-
 libavcodec/cook.c                     |   4 +-
 libavcodec/cri.c                      |   6 +-
 libavcodec/d3d12va_encode_hevc.c      |   4 +-
 libavcodec/dca_core.c                 |   8 +-
 libavcodec/dca_lbr.c                  |  14 +--
 libavcodec/decode.c                   |  14 +--
 libavcodec/dfa.c                      |   4 +-
 libavcodec/dirac_arith.c              |   2 +-
 libavcodec/dirac_dwt.c                |   2 +-
 libavcodec/diracdec.c                 |  20 ++---
 libavcodec/dnxhddata.c                |   2 +-
 libavcodec/dnxhdenc.c                 |  22 ++---
 libavcodec/dnxuc_parser.c             |   2 +-
 libavcodec/dolby_e.c                  |  18 ++--
 libavcodec/dovi_rpuenc.c              |   2 +-
 libavcodec/dpcm.c                     |   2 +-
 libavcodec/dpx_parser.c               |   2 +-
 libavcodec/dpxenc.c                   |   2 +-
 libavcodec/dsicinvideo.c              |   4 +-
 libavcodec/dstdec.c                   |   4 +-
 libavcodec/dvbsubdec.c                |   2 +-
 libavcodec/dvbsubenc.c                |   4 +-
 libavcodec/dvdec.c                    |   2 +-
 libavcodec/dvdsubdec.c                |   2 +-
 libavcodec/dvdsubenc.c                |  10 +--
 libavcodec/dxva2_av1.c                |   2 +-
 libavcodec/dxva2_h264.c               |   2 +-
 libavcodec/dxva2_hevc.c               |   2 +-
 libavcodec/dxva2_vc1.c                |   2 +-
 libavcodec/eac3dec.c                  |   2 +-
 libavcodec/eatgq.c                    |   2 +-
 libavcodec/eatgv.c                    |   4 +-
 libavcodec/elbg.c                     |   6 +-
 libavcodec/elsdec.c                   |   4 +-
 libavcodec/encode.c                   |   4 +-
 libavcodec/error_resilience.c         |  26 +++---
 libavcodec/evrcdec.c                  |   8 +-
 libavcodec/executor.c                 |   4 +-
 libavcodec/exr.c                      |  42 ++++-----
 libavcodec/exrenc.c                   |   2 +-
 libavcodec/fastaudio.c                |   2 +-
 libavcodec/ffv1.c                     |   2 +-
 libavcodec/ffv1.h                     |  14 +--
 libavcodec/ffv1enc.c                  |  30 +++----
 libavcodec/ffv1enc_vulkan.c           |   4 +-
 libavcodec/fic.c                      |   4 +-
 libavcodec/flac_parser.c              |  22 ++---
 libavcodec/flacenc.c                  |   8 +-
 libavcodec/flashsv.c                  |   2 +-
 libavcodec/g2meet.c                   |  12 +--
 libavcodec/g723_1.c                   |   6 +-
 libavcodec/g723_1_parser.c            |   2 +-
 libavcodec/g723_1dec.c                |  10 +--
 libavcodec/g723_1enc.c                |  12 +--
 libavcodec/g729dec.c                  |   6 +-
 libavcodec/g729postfilter.c           |  18 ++--
 libavcodec/get_bits.h                 |   4 +-
 libavcodec/get_buffer.c               |   2 +-
 libavcodec/gif.c                      |   2 +-
 libavcodec/golomb.h                   |   2 +-
 libavcodec/h2645_parse.c              |   6 +-
 libavcodec/h264_direct.c              |   2 +-
 libavcodec/h264_levels.c              |   2 +-
 libavcodec/h264_mb.c                  |  16 ++--
 libavcodec/h264_mvpred.h              |   2 +-
 libavcodec/h264_parse.c               |   2 +-
 libavcodec/h264_parser.c              |   2 +-
 libavcodec/h264_ps.c                  |   4 +-
 libavcodec/h264_refs.c                |   6 +-
 libavcodec/h264_slice.c               |  12 +--
 libavcodec/h264dec.c                  |   4 +-
 libavcodec/h265_profile_level.c       |   6 +-
 libavcodec/hapdec.c                   |   2 +-
 libavcodec/hapenc.c                   |   2 +-
 libavcodec/hdrenc.c                   |   2 +-
 libavcodec/hevc/cabac.c               |  20 ++---
 libavcodec/hevc/filter.c              |   4 +-
 libavcodec/hevc/hevcdec.c             |   8 +-
 libavcodec/hevc/mvs.c                 |   2 +-
 libavcodec/hevc/ps.c                  |  16 ++--
 libavcodec/hevc/refs.c                |   2 +-
 libavcodec/hevc/sei.c                 |   8 +-
 libavcodec/huffyuvdec.c               |   4 +-
 libavcodec/huffyuvenc.c               |  12 +--
 libavcodec/hw_base_encode.c           |   6 +-
 libavcodec/iff.c                      |  34 +++----
 libavcodec/ilbcdec.c                  |  22 ++---
 libavcodec/imc.c                      |   2 +-
 libavcodec/indeo3.c                   |   4 +-
 libavcodec/interplayacm.c             |   8 +-
 libavcodec/intrax8.c                  |   4 +-
 libavcodec/intrax8dsp.c               |  42 ++++-----
 libavcodec/ituh263dec.c               |   2 +-
 libavcodec/ivi.c                      |   4 +-
 libavcodec/j2kenc.c                   |  38 ++++----
 libavcodec/jpeg2000.c                 |  24 ++---
 libavcodec/jpeg2000_parser.c          |   2 +-
 libavcodec/jpeg2000dec.c              |  38 ++++----
 libavcodec/jpeg2000dwt.c              |   2 +-
 libavcodec/jpegls.c                   |  14 +--
 libavcodec/jpegls.h                   |   4 +-
 libavcodec/jpeglsdec.c                |   6 +-
 libavcodec/jpegxl_parse.c             |   2 +-
 libavcodec/jpegxl_parser.c            |  12 +--
 libavcodec/lagarith.c                 |   4 +-
 libavcodec/lagarithrac.c              |   2 +-
 libavcodec/lcldec.c                   |  10 +--
 libavcodec/libfdk-aacdec.c            |   4 +-
 libavcodec/libfdk-aacenc.c            |   2 +-
 libavcodec/liblc3dec.c                |   2 +-
 libavcodec/liblc3enc.c                |   2 +-
 libavcodec/libopenh264enc.c           |   2 +-
 libavcodec/libopenjpegenc.c           |   4 +-
 libavcodec/libvpxdec.c                |   2 +-
 libavcodec/libvpxenc.c                |   2 +-
 libavcodec/libwebpenc_common.c        |  12 +--
 libavcodec/libx264.c                  |  10 +--
 libavcodec/libx265.c                  |   8 +-
 libavcodec/libzvbi-teletextdec.c      |   4 +-
 libavcodec/lpc.c                      |   2 +-
 libavcodec/lscrdec.c                  |   2 +-
 libavcodec/lsp.c                      |   6 +-
 libavcodec/lzwenc.c                   |   2 +-
 libavcodec/mace.c                     |   2 +-
 libavcodec/magicyuv.c                 |  14 +--
 libavcodec/magicyuvenc.c              |   8 +-
 libavcodec/mathops.h                  |   8 +-
 libavcodec/me_cmp.c                   |   2 +-
 libavcodec/mf_utils.c                 |   2 +-
 libavcodec/mips/vc1dsp_mmi.c          |   4 +-
 libavcodec/mips/vp8dsp_mmi.c          |   8 +-
 libavcodec/mjpeg_parser.c             |   4 +-
 libavcodec/mjpegbdec.c                |   2 +-
 libavcodec/mjpegdec.c                 |   8 +-
 libavcodec/mjpegenc_common.c          |   2 +-
 libavcodec/mlpdec.c                   |   4 +-
 libavcodec/mlpenc.c                   |  50 +++++------
 libavcodec/mobiclip.c                 |  12 +--
 libavcodec/motion_est.c               |  50 +++++------
 libavcodec/motion_est_template.c      |  40 ++++-----
 libavcodec/motionpixels.c             |   4 +-
 libavcodec/movtextdec.c               |   2 +-
 libavcodec/movtextenc.c               |   2 +-
 libavcodec/mpc8.c                     |   4 +-
 libavcodec/mpeg12dec.c                |   6 +-
 libavcodec/mpeg4videodec.c            |  20 ++---
 libavcodec/mpeg4videoenc.c            |   6 +-
 libavcodec/mpegaudio_parser.c         |   2 +-
 libavcodec/mpegaudiodec_template.c    |  10 +--
 libavcodec/mpegutils.c                |   2 +-
 libavcodec/mpegvideo.c                |   2 +-
 libavcodec/mpegvideo_dec.c            |  18 ++--
 libavcodec/mpegvideo_enc.c            |  26 +++---
 libavcodec/mpegvideo_motion.c         |  20 ++---
 libavcodec/msmpeg4enc.c               |   4 +-
 libavcodec/msp2dec.c                  |   6 +-
 libavcodec/msrle.c                    |   2 +-
 libavcodec/mss12.c                    |   8 +-
 libavcodec/mss2.c                     |   6 +-
 libavcodec/mss3.c                     |   2 +-
 libavcodec/mss4.c                     |   2 +-
 libavcodec/mv30.c                     |   2 +-
 libavcodec/mvcdec.c                   |   2 +-
 libavcodec/mvha.c                     |   4 +-
 libavcodec/mxpegdec.c                 |   4 +-
 libavcodec/nellymoser.c               |   2 +-
 libavcodec/nellymoserenc.c            |   8 +-
 libavcodec/nuv.c                      |   8 +-
 libavcodec/nvenc.c                    |  16 ++--
 libavcodec/opus/celt.c                |  44 +++++-----
 libavcodec/opus/dec.c                 |   6 +-
 libavcodec/opus/dec_celt.c            |  22 ++---
 libavcodec/opus/enc.c                 |  16 ++--
 libavcodec/opus/enc_psy.c             |  18 ++--
 libavcodec/opus/pvq.c                 |   4 +-
 libavcodec/opus/rc.c                  |  26 +++---
 libavcodec/opus/silk.c                |  12 +--
 libavcodec/osq.c                      |   4 +-
 libavcodec/pcx.c                      |   2 +-
 libavcodec/pictordec.c                |  14 +--
 libavcodec/pixlet.c                   |   6 +-
 libavcodec/png_parser.c               |   2 +-
 libavcodec/pngdec.c                   |   4 +-
 libavcodec/pngenc.c                   |   2 +-
 libavcodec/pnm_parser.c               |   4 +-
 libavcodec/proresdec.c                |   6 +-
 libavcodec/proresenc_anatoliy.c       |  12 +--
 libavcodec/proresenc_kostya.c         |  22 ++---
 libavcodec/psd.c                      |   2 +-
 libavcodec/pthread_frame.c            |   2 +-
 libavcodec/pthread_slice.c            |   4 +-
 libavcodec/qcelpdec.c                 |  12 +--
 libavcodec/qdmc.c                     |   2 +-
 libavcodec/qpeg.c                     |   6 +-
 libavcodec/qsvenc.c                   |  20 ++---
 libavcodec/qtrleenc.c                 |   6 +-
 libavcodec/ra144.c                    |   2 +-
 libavcodec/ra144enc.c                 |   2 +-
 libavcodec/ra288.c                    |   2 +-
 libavcodec/ralf.c                     |  12 +--
 libavcodec/rasc.c                     |   2 +-
 libavcodec/ratecontrol.c              |  10 +--
 libavcodec/rawdec.c                   |   2 +-
 libavcodec/rectangle.h                |   2 +-
 libavcodec/rka.c                      |   8 +-
 libavcodec/rl2.c                      |   2 +-
 libavcodec/rle.c                      |   4 +-
 libavcodec/roqaudioenc.c              |   2 +-
 libavcodec/roqvideoenc.c              |   2 +-
 libavcodec/rpza.c                     |   2 +-
 libavcodec/rpzaenc.c                  |  42 ++++-----
 libavcodec/rv10.c                     |   4 +-
 libavcodec/rv34.c                     |   6 +-
 libavcodec/rv60dec.c                  |   2 +-
 libavcodec/sanm.c                     |  10 +--
 libavcodec/sbc_parser.c               |   2 +-
 libavcodec/sgirledec.c                |   2 +-
 libavcodec/shorten.c                  |  14 +--
 libavcodec/sipr.c                     |   6 +-
 libavcodec/sipr16k.c                  |   2 +-
 libavcodec/sipr_parser.c              |   2 +-
 libavcodec/smacker.c                  |   2 +-
 libavcodec/smcenc.c                   |  32 +++----
 libavcodec/snow.c                     |   8 +-
 libavcodec/snow.h                     |   4 +-
 libavcodec/snow_dwt.c                 |   4 +-
 libavcodec/snowdec.c                  |  38 ++++----
 libavcodec/snowenc.c                  |  32 +++----
 libavcodec/sonic.c                    |  10 +--
 libavcodec/speexdec.c                 |   6 +-
 libavcodec/svq3.c                     |   2 +-
 libavcodec/tak_parser.c               |   4 +-
 libavcodec/takdec.c                   |   4 +-
 libavcodec/targa.c                    |   4 +-
 libavcodec/tdsc.c                     |   4 +-
 libavcodec/tests/apv.c                |   6 +-
 libavcodec/tests/bitstream_template.c |  20 ++---
 libavcodec/tests/dct.c                |   4 +-
 libavcodec/tests/jpeg2000dwt.c        |   2 +-
 libavcodec/texturedsp_template.c      |   2 +-
 libavcodec/tiertexseqv.c              |   4 +-
 libavcodec/tiff.c                     |  18 ++--
 libavcodec/tiffenc.c                  |   8 +-
 libavcodec/truemotion2.c              |   2 +-
 libavcodec/utils.c                    |  12 +--
 libavcodec/utvideodec.c               |  12 +--
 libavcodec/v210dec.c                  |   2 +-
 libavcodec/v4l2_buffers.c             |   6 +-
 libavcodec/vaapi_encode_av1.c         |  12 +--
 libavcodec/vaapi_encode_h265.c        |  18 ++--
 libavcodec/vc1_pred.c                 |   8 +-
 libavcodec/vc1dec.c                   |  10 +--
 libavcodec/vc1dsp.c                   |   4 +-
 libavcodec/vc2enc.c                   |  10 +--
 libavcodec/videodsp_template.c        |   8 +-
 libavcodec/vlc.c                      |  14 +--
 libavcodec/vmixdec.c                  |   2 +-
 libavcodec/vorbis.c                   |   2 +-
 libavcodec/vorbisdec.c                |   2 +-
 libavcodec/vorbisenc.c                |  14 +--
 libavcodec/vp3.c                      |  12 +--
 libavcodec/vp5.c                      |   2 +-
 libavcodec/vp6.c                      |   6 +-
 libavcodec/vp8.c                      |  12 +--
 libavcodec/vp8dsp.c                   |   4 +-
 libavcodec/vulkan_decode.c            |   6 +-
 libavcodec/vulkan_encode.c            |   2 +-
 libavcodec/vulkan_encode_h265.c       |  18 ++--
 libavcodec/vulkan_ffv1.c              |   4 +-
 libavcodec/vvc/cabac.c                |   4 +-
 libavcodec/vvc/ctu.c                  |  30 +++----
 libavcodec/vvc/dec.c                  |   2 +-
 libavcodec/vvc/filter.c               |  26 +++---
 libavcodec/vvc/inter.c                |  12 +--
 libavcodec/vvc/intra.c                |   2 +-
 libavcodec/vvc/intra_template.c       |  40 ++++-----
 libavcodec/vvc/intra_utils.c          |  18 ++--
 libavcodec/vvc/mvs.c                  |  20 ++---
 libavcodec/vvc/ps.c                   |   8 +-
 libavcodec/vvc/refs.c                 |   2 +-
 libavcodec/wavarc.c                   |   4 +-
 libavcodec/wavpackenc.c               |  16 ++--
 libavcodec/wbmpdec.c                  |   2 +-
 libavcodec/webp.c                     |   8 +-
 libavcodec/webp_parser.c              |   4 +-
 libavcodec/wmaenc.c                   |   4 +-
 libavcodec/wmaprodec.c                |  20 ++---
 libavcodec/wmavoice.c                 |  30 +++----
 libavcodec/wmv2dec.c                  |   4 +-
 libavcodec/wmv2enc.c                  |   2 +-
 libavcodec/x86/videodsp_init.c        |   8 +-
 libavcodec/xan.c                      |   4 +-
 libavcodec/xpmdec.c                   |   2 +-
 libavcodec/xsubenc.c                  |   2 +-
 libavcodec/xxan.c                     |   2 +-
 libavcodec/ylc.c                      |   6 +-
 libavcodec/zmbv.c                     |   2 +-
 libavcodec/zmbvenc.c                  |  12 +--
 libavdevice/alsa.c                    |   2 +-
 libavdevice/fbdev_enc.c               |   4 +-
 libavdevice/lavfi.c                   |   2 +-
 libavdevice/openal-dec.c              |   2 +-
 libavdevice/oss_enc.c                 |   2 +-
 libavdevice/pulse_audio_enc.c         |   2 +-
 libavdevice/sndio_enc.c               |   2 +-
 libavdevice/timefilter.c              |   2 +-
 libavdevice/v4l2.c                    |   2 +-
 libavdevice/xcbgrab.c                 |  16 ++--
 libavfilter/aeval.c                   |   4 +-
 libavfilter/af_aap.c                  |   4 +-
 libavfilter/af_acrossover.c           |   2 +-
 libavfilter/af_acrusher.c             |   6 +-
 libavfilter/af_adeclick.c             |  10 +--
 libavfilter/af_adecorrelate.c         |   2 +-
 libavfilter/af_adelay.c               |  14 +--
 libavfilter/af_adenorm.c              |   2 +-
 libavfilter/af_adrc.c                 |   2 +-
 libavfilter/af_adynamicequalizer.c    |   2 +-
 libavfilter/af_aecho.c                |   4 +-
 libavfilter/af_afftdn.c               |  10 +--
 libavfilter/af_afftfilt.c             |   4 +-
 libavfilter/af_afir.c                 |  18 ++--
 libavfilter/af_afreqshift.c           |   2 +-
 libavfilter/af_afwtdn.c               |  12 +--
 libavfilter/af_agate.c                |  10 +--
 libavfilter/af_aiir.c                 |  16 ++--
 libavfilter/af_alimiter.c             |  16 ++--
 libavfilter/af_amerge.c               |   2 +-
 libavfilter/af_amix.c                 |   4 +-
 libavfilter/af_amultiply.c            |   2 +-
 libavfilter/af_anequalizer.c          |   2 +-
 libavfilter/af_anlms.c                |   4 +-
 libavfilter/af_apad.c                 |   4 +-
 libavfilter/af_apsyclip.c             |  18 ++--
 libavfilter/af_apulsator.c            |   2 +-
 libavfilter/af_aresample.c            |   2 +-
 libavfilter/af_arls.c                 |   4 +-
 libavfilter/af_arnndn.c               |  32 +++----
 libavfilter/af_asdr.c                 |   4 +-
 libavfilter/af_asetrate.c             |   2 +-
 libavfilter/af_asoftclip.c            |   2 +-
 libavfilter/af_aspectralstats.c       |   2 +-
 libavfilter/af_astats.c               |  66 +++++++-------
 libavfilter/af_asubboost.c            |   2 +-
 libavfilter/af_atempo.c               |  38 ++++----
 libavfilter/af_atilt.c                |   2 +-
 libavfilter/af_axcorrelate.c          |   2 +-
 libavfilter/af_biquads.c              |   2 +-
 libavfilter/af_channelmap.c           |   2 +-
 libavfilter/af_chorus.c               |   4 +-
 libavfilter/af_compand.c              |  10 +--
 libavfilter/af_crystalizer.c          |   2 +-
 libavfilter/af_deesser.c              |   6 +-
 libavfilter/af_dynaudnorm.c           |  10 +--
 libavfilter/af_firequalizer.c         |  10 +--
 libavfilter/af_hdcd.c                 |  14 +--
 libavfilter/af_headphone.c            |   6 +-
 libavfilter/af_join.c                 |   8 +-
 libavfilter/af_ladspa.c               |   4 +-
 libavfilter/af_mcompand.c             |  10 +--
 libavfilter/af_replaygain.c           |   2 +-
 libavfilter/af_sidechaincompress.c    |   8 +-
 libavfilter/af_silenceremove.c        |   2 +-
 libavfilter/af_sofalizer.c            |   6 +-
 libavfilter/af_speechnorm.c           |  20 ++---
 libavfilter/af_stereotools.c          |  40 ++++-----
 libavfilter/af_surround.c             |   8 +-
 libavfilter/af_volume.c               |   2 +-
 libavfilter/afir_template.c           |   2 +-
 libavfilter/asrc_afdelaysrc.c         |   2 +-
 libavfilter/asrc_afirsrc.c            |   4 +-
 libavfilter/asrc_anullsrc.c           |   2 +-
 libavfilter/asrc_flite.c              |   2 +-
 libavfilter/asrc_hilbert.c            |   2 +-
 libavfilter/asrc_sinc.c               |   2 +-
 libavfilter/avf_a3dscope.c            |   2 +-
 libavfilter/avf_abitscope.c           |   2 +-
 libavfilter/avf_ahistogram.c          |   4 +-
 libavfilter/avf_aphasemeter.c         |   8 +-
 libavfilter/avf_avectorscope.c        |  28 +++---
 libavfilter/avf_concat.c              |   6 +-
 libavfilter/avf_showcqt.c             |  28 +++---
 libavfilter/avf_showcwt.c             |  16 ++--
 libavfilter/avf_showfreqs.c           |   4 +-
 libavfilter/avf_showspatial.c         |   4 +-
 libavfilter/avf_showvolume.c          |  18 ++--
 libavfilter/avf_showwaves.c           |   2 +-
 libavfilter/avfilter.c                |  10 +--
 libavfilter/blend_modes.c             |   6 +-
 libavfilter/boxblur.c                 |   4 +-
 libavfilter/bwdifdsp.c                |   4 +-
 libavfilter/drawutils.c               |   4 +-
 libavfilter/edge_template.c           |   4 +-
 libavfilter/f_bench.c                 |   4 +-
 libavfilter/f_drawgraph.c             |   4 +-
 libavfilter/f_latency.c               |   4 +-
 libavfilter/f_loop.c                  |   6 +-
 libavfilter/f_metadata.c              |   2 +-
 libavfilter/f_segment.c               |   2 +-
 libavfilter/f_select.c                |   4 +-
 libavfilter/f_sendcmd.c               |   4 +-
 libavfilter/framepool.c               |   2 +-
 libavfilter/framesync.c               |   2 +-
 libavfilter/graphdump.c               |  14 +--
 libavfilter/graphparser.c             |   2 +-
 libavfilter/median_template.c         |   8 +-
 libavfilter/motion_estimation.c       |  80 ++++++++---------
 libavfilter/pthread.c                 |   2 +-
 libavfilter/scale_eval.c              |   8 +-
 libavfilter/signature_lookup.c        |   2 +-
 libavfilter/src_movie.c               |   2 +-
 libavfilter/trim.c                    |  14 +--
 libavfilter/vaf_spectrumsynth.c       |   2 +-
 libavfilter/vf_alphamerge.c           |   2 +-
 libavfilter/vf_amplify.c              |   2 +-
 libavfilter/vf_avgblur.c              |  12 +--
 libavfilter/vf_avgblur_opencl.c       |   2 +-
 libavfilter/vf_backgroundkey.c        |   2 +-
 libavfilter/vf_bilateral_cuda.c       |   2 +-
 libavfilter/vf_blackdetect.c          |   2 +-
 libavfilter/vf_blend.c                |   2 +-
 libavfilter/vf_blockdetect.c          |  12 +--
 libavfilter/vf_bm3d.c                 |  10 +--
 libavfilter/vf_boxblur.c              |   4 +-
 libavfilter/vf_bwdif.c                |   2 +-
 libavfilter/vf_cas.c                  |  22 ++---
 libavfilter/vf_chromakey.c            |   2 +-
 libavfilter/vf_chromakey_cuda.c       |   2 +-
 libavfilter/vf_chromanr.c             |   8 +-
 libavfilter/vf_ciescope.c             |   8 +-
 libavfilter/vf_colorbalance.c         |   6 +-
 libavfilter/vf_colorchannelmixer.c    |   2 +-
 libavfilter/vf_colorconstancy.c       |   6 +-
 libavfilter/vf_colorcontrast.c        |   2 +-
 libavfilter/vf_colorcorrect.c         |  18 ++--
 libavfilter/vf_colorize.c             |   2 +-
 libavfilter/vf_colorkey.c             |   2 +-
 libavfilter/vf_colorlevels.c          |  10 +--
 libavfilter/vf_colormap.c             |   6 +-
 libavfilter/vf_colormatrix.c          |   8 +-
 libavfilter/vf_colorspace.c           |  14 +--
 libavfilter/vf_colortemperature.c     |   2 +-
 libavfilter/vf_convolution.c          |  30 +++----
 libavfilter/vf_convolve.c             |   4 +-
 libavfilter/vf_corr.c                 |   4 +-
 libavfilter/vf_cover_rect.c           |   4 +-
 libavfilter/vf_cropdetect.c           |   8 +-
 libavfilter/vf_datascope.c            |  24 ++---
 libavfilter/vf_deblock.c              |  10 +--
 libavfilter/vf_dedot.c                |   6 +-
 libavfilter/vf_delogo.c               |  18 ++--
 libavfilter/vf_deshake.c              |   4 +-
 libavfilter/vf_deshake_opencl.c       |   6 +-
 libavfilter/vf_despill.c              |  12 +--
 libavfilter/vf_detelecine.c           |   2 +-
 libavfilter/vf_displace.c             |   2 +-
 libavfilter/vf_dnn_detect.c           |   4 +-
 libavfilter/vf_drawbox.c              |   4 +-
 libavfilter/vf_drawtext.c             |  42 ++++-----
 libavfilter/vf_epx.c                  |  26 +++---
 libavfilter/vf_estdif.c               |   2 +-
 libavfilter/vf_exposure.c             |   2 +-
 libavfilter/vf_fade.c                 |  12 +--
 libavfilter/vf_fftdnoiz.c             |  12 +--
 libavfilter/vf_fftfilt.c              |  16 ++--
 libavfilter/vf_fieldhint.c            |   4 +-
 libavfilter/vf_find_rect.c            |  16 ++--
 libavfilter/vf_framerate.c            |   4 +-
 libavfilter/vf_gblur.c                |   6 +-
 libavfilter/vf_gradfun.c              |   4 +-
 libavfilter/vf_grayworld.c            |   4 +-
 libavfilter/vf_guided.c               |  12 +--
 libavfilter/vf_hflip.c                |   2 +-
 libavfilter/vf_histogram.c            |  14 +--
 libavfilter/vf_hqdn3d.c               |   4 +-
 libavfilter/vf_hsvkey.c               |   2 +-
 libavfilter/vf_huesaturation.c        |  16 ++--
 libavfilter/vf_identity.c             |   6 +-
 libavfilter/vf_lagfun.c               |   2 +-
 libavfilter/vf_lcevc.c                |   4 +-
 libavfilter/vf_lenscorrection.c       |   6 +-
 libavfilter/vf_lensfun.c              |   4 +-
 libavfilter/vf_libopencv.c            |   2 +-
 libavfilter/vf_libplacebo.c           |   2 +-
 libavfilter/vf_limitdiff.c            |   2 +-
 libavfilter/vf_limiter.c              |   6 +-
 libavfilter/vf_lumakey.c              |   2 +-
 libavfilter/vf_lut.c                  |   8 +-
 libavfilter/vf_lut2.c                 |   4 +-
 libavfilter/vf_maskedclamp.c          |  10 +--
 libavfilter/vf_maskedmerge.c          |   2 +-
 libavfilter/vf_maskedminmax.c         |   2 +-
 libavfilter/vf_maskedthreshold.c      |   6 +-
 libavfilter/vf_maskfun.c              |   4 +-
 libavfilter/vf_median.c               |   2 +-
 libavfilter/vf_mergeplanes.c          |   2 +-
 libavfilter/vf_minterpolate.c         |  24 ++---
 libavfilter/vf_mix.c                  |   8 +-
 libavfilter/vf_monochrome.c           |   4 +-
 libavfilter/vf_morpho.c               |  40 ++++-----
 libavfilter/vf_mpdecimate.c           |   4 +-
 libavfilter/vf_multiply.c             |   2 +-
 libavfilter/vf_negate.c               |   2 +-
 libavfilter/vf_neighbor.c             |  42 ++++-----
 libavfilter/vf_nlmeans_vulkan.c       |  12 +--
 libavfilter/vf_nnedi.c                |  18 ++--
 libavfilter/vf_noise.c                |   4 +-
 libavfilter/vf_normalize.c            |  32 +++----
 libavfilter/vf_overlay.c              |  32 +++----
 libavfilter/vf_overlay_opencl.c       |   4 +-
 libavfilter/vf_pad.c                  |   4 +-
 libavfilter/vf_perspective.c          |   2 +-
 libavfilter/vf_photosensitivity.c     |   4 +-
 libavfilter/vf_pixelize.c             |  14 +--
 libavfilter/vf_pp7.c                  |   6 +-
 libavfilter/vf_premultiply.c          |  14 +--
 libavfilter/vf_pseudocolor.c          |   2 +-
 libavfilter/vf_pullup.c               |   4 +-
 libavfilter/vf_readeia608.c           |  14 +--
 libavfilter/vf_readvitc.c             |   4 +-
 libavfilter/vf_remap.c                |   2 +-
 libavfilter/vf_remap_opencl.c         |   2 +-
 libavfilter/vf_removegrain.c          | 122 +++++++++++++-------------
 libavfilter/vf_removelogo.c           |  12 +--
 libavfilter/vf_rotate.c               |  18 ++--
 libavfilter/vf_scale_cuda.c           |   2 +-
 libavfilter/vf_scdet.c                |   2 +-
 libavfilter/vf_scdet_vulkan.c         |   2 +-
 libavfilter/vf_scroll.c               |   2 +-
 libavfilter/vf_shear.c                |   6 +-
 libavfilter/vf_shufflepixels.c        |  10 +--
 libavfilter/vf_signature.c            |   2 +-
 libavfilter/vf_ssim.c                 |   6 +-
 libavfilter/vf_ssim360.c              |  14 +--
 libavfilter/vf_stack.c                |   6 +-
 libavfilter/vf_stereo3d.c             |   2 +-
 libavfilter/vf_super2xsai.c           |   8 +-
 libavfilter/vf_swaprect.c             |   4 +-
 libavfilter/vf_telecine.c             |   2 +-
 libavfilter/vf_threshold.c            |   2 +-
 libavfilter/vf_tiltandshift.c         |   2 +-
 libavfilter/vf_tonemap.c              |   8 +-
 libavfilter/vf_tonemap_vaapi.c        |  14 +--
 libavfilter/vf_transpose.c            |   2 +-
 libavfilter/vf_unsharp.c              |   4 +-
 libavfilter/vf_unsharp_opencl.c       |   2 +-
 libavfilter/vf_v360.c                 |  26 +++---
 libavfilter/vf_vaguedenoiser.c        |  10 +--
 libavfilter/vf_varblur.c              |  20 ++---
 libavfilter/vf_vectorscope.c          |  36 ++++----
 libavfilter/vf_vfrdet.c               |   4 +-
 libavfilter/vf_vibrance.c             |   2 +-
 libavfilter/vf_vif.c                  |  16 ++--
 libavfilter/vf_vpp_qsv.c              |   4 +-
 libavfilter/vf_w3fdif.c               |   2 +-
 libavfilter/vf_waveform.c             |  42 ++++-----
 libavfilter/vf_weave.c                |   2 +-
 libavfilter/vf_xbr.c                  |   2 +-
 libavfilter/vf_xfade.c                |  14 +--
 libavfilter/vf_xfade_opencl.c         |   2 +-
 libavfilter/vf_xmedian.c              |   4 +-
 libavfilter/vf_xpsnr.c                |  12 +--
 libavfilter/vf_yadif.c                |  18 ++--
 libavfilter/vf_yaepblur.c             |   8 +-
 libavfilter/vf_zoompan.c              |   4 +-
 libavfilter/vf_zscale.c               |  10 +--
 libavfilter/vsrc_ddagrab.c            |   4 +-
 libavfilter/vsrc_gradients.c          |   2 +-
 libavfilter/vsrc_life.c               |   4 +-
 libavfilter/vsrc_mandelbrot.c         |   4 +-
 libavfilter/vsrc_mptestsrc.c          |   2 +-
 libavfilter/vsrc_sierpinski.c         |   2 +-
 libavfilter/vsrc_testsrc.c            |  20 ++---
 libavfilter/window_func.h             |   2 +-
 libavformat/aacdec.c                  |   4 +-
 libavformat/ac3dec.c                  |   2 +-
 libavformat/ac4dec.c                  |   2 +-
 libavformat/aeadec.c                  |   2 +-
 libavformat/afc.c                     |   2 +-
 libavformat/aiffdec.c                 |   2 +-
 libavformat/amvenc.c                  |   2 +-
 libavformat/anm.c                     |   2 +-
 libavformat/argo_asf.c                |   4 +-
 libavformat/argo_brp.c                |   2 +-
 libavformat/argo_cvg.c                |   2 +-
 libavformat/asfdec_f.c                |   6 +-
 libavformat/asfenc.c                  |   4 +-
 libavformat/async.c                   |   4 +-
 libavformat/au.c                      |   2 +-
 libavformat/av1dec.c                  |   8 +-
 libavformat/avc.c                     |   2 +-
 libavformat/avformat.c                |   2 +-
 libavformat/avidec.c                  |  46 +++++-----
 libavformat/avienc.c                  |  12 +--
 libavformat/avio.c                    |   4 +-
 libavformat/aviobuf.c                 |  20 ++---
 libavformat/cache.c                   |  10 +--
 libavformat/cafdec.c                  |   6 +-
 libavformat/cdg.c                     |   2 +-
 libavformat/concatdec.c               |   2 +-
 libavformat/crypto.c                  |   2 +-
 libavformat/dash.c                    |   4 +-
 libavformat/dashenc.c                 |  26 +++---
 libavformat/data_uri.c                |   2 +-
 libavformat/demux.c                   |  34 +++----
 libavformat/dhav.c                    |   2 +-
 libavformat/dsfdec.c                  |   2 +-
 libavformat/dtsdec.c                  |   4 +-
 libavformat/dtshddec.c                |   4 +-
 libavformat/dump.c                    |   2 +-
 libavformat/dvbsub.c                  |   2 +-
 libavformat/dxa.c                     |   2 +-
 libavformat/fifo.c                    |   4 +-
 libavformat/file.c                    |   4 +-
 libavformat/filmstripdec.c            |   2 +-
 libavformat/flvdec.c                  |   6 +-
 libavformat/flvenc.c                  |   2 +-
 libavformat/format.c                  |  12 +--
 libavformat/ftp.c                     |   4 +-
 libavformat/gxf.c                     |   2 +-
 libavformat/h261dec.c                 |   2 +-
 libavformat/hdsenc.c                  |   2 +-
 libavformat/hevc.c                    |  18 ++--
 libavformat/hls.c                     |  14 +--
 libavformat/hls_sample_encryption.c   |   4 +-
 libavformat/hlsenc.c                  |   2 +-
 libavformat/http.c                    |   6 +-
 libavformat/iamf_parse.c              |   8 +-
 libavformat/iamf_reader.c             |   6 +-
 libavformat/iamfdec.c                 |   2 +-
 libavformat/icodec.c                  |  12 +--
 libavformat/iff.c                     |   4 +-
 libavformat/jvdec.c                   |   2 +-
 libavformat/lc3.c                     |   4 +-
 libavformat/libzmq.c                  |   2 +-
 libavformat/loasdec.c                 |   4 +-
 libavformat/matroskadec.c             |   8 +-
 libavformat/matroskaenc.c             |  24 ++---
 libavformat/mlvdec.c                  |   2 +-
 libavformat/mmf.c                     |   2 +-
 libavformat/mmsh.c                    |   2 +-
 libavformat/moflex.c                  |   2 +-
 libavformat/mov.c                     |  98 ++++++++++-----------
 libavformat/movenc.c                  |  30 +++----
 libavformat/movenc_ttml.c             |   2 +-
 libavformat/movenccenc.c              |   4 +-
 libavformat/mp3dec.c                  |  14 +--
 libavformat/mp3enc.c                  |   8 +-
 libavformat/mpc.c                     |   2 +-
 libavformat/mpegenc.c                 |   2 +-
 libavformat/mpegts.c                  |  14 +--
 libavformat/mpegtsenc.c               |  18 ++--
 libavformat/mux.c                     |   2 +-
 libavformat/mxfenc.c                  |   8 +-
 libavformat/network.c                 |   4 +-
 libavformat/nsvdec.c                  |   2 +-
 libavformat/nutdec.c                  |   8 +-
 libavformat/nutenc.c                  |   6 +-
 libavformat/oggenc.c                  |   4 +-
 libavformat/oggparseopus.c            |   4 +-
 libavformat/omadec.c                  |   4 +-
 libavformat/pp_bnk.c                  |   4 +-
 libavformat/pva.c                     |   2 +-
 libavformat/qcp.c                     |   2 +-
 libavformat/rawdec.c                  |   2 +-
 libavformat/rawutils.c                |   4 +-
 libavformat/riffdec.c                 |   2 +-
 libavformat/rmdec.c                   |   4 +-
 libavformat/rtmppkt.c                 |   6 +-
 libavformat/rtmpproto.c               |  12 +--
 libavformat/rtpdec.c                  |   4 +-
 libavformat/rtpdec_asf.c              |   4 +-
 libavformat/rtpdec_mpeg4.c            |   4 +-
 libavformat/rtpdec_mpegts.c           |   2 +-
 libavformat/rtpdec_opus.c             |   2 +-
 libavformat/rtpdec_qdm2.c             |   4 +-
 libavformat/rtpenc.c                  |   6 +-
 libavformat/rtpenc_aac.c              |   2 +-
 libavformat/rtpenc_h261.c             |   2 +-
 libavformat/rtpenc_h263.c             |   2 +-
 libavformat/rtpenc_h263_rfc2190.c     |   2 +-
 libavformat/rtpenc_jpeg.c             |   2 +-
 libavformat/rtpenc_latm.c             |   2 +-
 libavformat/rtpenc_vc2hq.c            |   2 +-
 libavformat/rtpenc_vp8.c              |   2 +-
 libavformat/rtpenc_vp9.c              |   2 +-
 libavformat/rtsp.c                    |   2 +-
 libavformat/sbgdec.c                  |  16 ++--
 libavformat/scd.c                     |   2 +-
 libavformat/sdns.c                    |   2 +-
 libavformat/seek.c                    |  12 +--
 libavformat/segment.c                 |   4 +-
 libavformat/sga.c                     |   4 +-
 libavformat/smjpegenc.c               |   2 +-
 libavformat/smoothstreamingenc.c      |   8 +-
 libavformat/spdifdec.c                |   2 +-
 libavformat/spdifenc.c                |   6 +-
 libavformat/srtp.c                    |   2 +-
 libavformat/srtpproto.c               |   2 +-
 libavformat/subfile.c                 |   2 +-
 libavformat/swfdec.c                  |   2 +-
 libavformat/takdec.c                  |   2 +-
 libavformat/thp.c                     |   2 +-
 libavformat/tls_schannel.c            |   2 +-
 libavformat/tls_securetransport.c     |   2 +-
 libavformat/tty.c                     |   2 +-
 libavformat/usmdec.c                  |   4 +-
 libavformat/utils.c                   |  14 +--
 libavformat/vapoursynth.c             |   2 +-
 libavformat/voc_packet.c              |   2 +-
 libavformat/vqf.c                     |   4 +-
 libavformat/vvc.c                     |  18 ++--
 libavformat/wavarc.c                  |   2 +-
 libavformat/wavdec.c                  |   6 +-
 libavformat/wavenc.c                  |  16 ++--
 libavformat/wtvdec.c                  |  12 +--
 libavformat/xmv.c                     |   2 +-
 libavformat/xwma.c                    |   2 +-
 libavformat/yop.c                     |   2 +-
 libavformat/yuv4mpegdec.c             |   2 +-
 libavutil/adler32.c                   |   2 +-
 libavutil/audio_fifo.c                |   6 +-
 libavutil/avstring.c                  |   4 +-
 libavutil/bprint.c                    |  20 ++---
 libavutil/buffer.c                    |   2 +-
 libavutil/channel_layout.c            |   2 +-
 libavutil/common.h                    |   4 +-
 libavutil/executor.c                  |   4 +-
 libavutil/fifo.c                      |   8 +-
 libavutil/frame.c                     |   6 +-
 libavutil/hwcontext_amf.c             |   8 +-
 libavutil/hwcontext_d3d11va.c         |   4 +-
 libavutil/hwcontext_qsv.c             |   2 +-
 libavutil/hwcontext_vulkan.c          |   6 +-
 libavutil/imgutils.c                  |   6 +-
 libavutil/lzo.c                       |   6 +-
 libavutil/macros.h                    |   6 ++
 libavutil/mathematics.c               |   4 +-
 libavutil/md5.c                       |   2 +-
 libavutil/mem.c                       |   8 +-
 libavutil/parseutils.c                |   2 +-
 libavutil/pca.c                       |   2 +-
 libavutil/pixdesc.c                   |  10 +--
 libavutil/rational.c                  |   4 +-
 libavutil/refstruct.c                 |   2 +-
 libavutil/side_data.c                 |   2 +-
 libavutil/slicethread.c               |   4 +-
 libavutil/tests/audio_fifo.c          |   2 +-
 libavutil/tests/fifo.c                |   4 +-
 libavutil/tests/pca.c                 |   2 +-
 libavutil/tests/tree.c                |   2 +-
 libavutil/timestamp.c                 |   2 +-
 libavutil/tx.c                        |   4 +-
 libavutil/vulkan.c                    |  12 +--
 libswresample/rematrix.c              |   4 +-
 libswresample/resample.c              |  24 ++---
 libswresample/soxr_resample.c         |   2 +-
 libswresample/swresample.c            |  14 +--
 libswresample/tests/swresample.c      |   4 +-
 libswresample/x86/rematrix_init.c     |   4 +-
 libswscale/cms.c                      |   4 +-
 libswscale/graph.c                    |   4 +-
 libswscale/loongarch/swscale_lasx.c   |  64 +++++++-------
 libswscale/lut3d.c                    |  14 +--
 libswscale/slice.c                    |  18 ++--
 libswscale/swscale.c                  |  42 ++++-----
 libswscale/swscale_unscaled.c         |   4 +-
 libswscale/tests/floatimg_cmp.c       |   4 +-
 libswscale/tests/swscale.c            |  10 +--
 libswscale/utils.c                    |  12 +--
 libswscale/vscale.c                   |  12 +--
 libswscale/x86/swscale.c              |   4 +-
 libswscale/yuv2rgb.c                  |   8 +-
 tests/checkasm/audiodsp.c             |  16 ++--
 tests/checkasm/hevc_deblock.c         |  26 +++---
 tests/checkasm/lls.c                  |   4 +-
 tests/checkasm/vp9dsp.c               |   2 +-
 tools/ismindex.c                      |   6 +-
 tools/probetest.c                     |   2 +-
 tools/scale_slice_test.c              |   2 +-
 tools/sidxindex.c                     |   2 +-
 tools/target_dec_fuzzer.c             |   4 +-
 tools/target_dem_fuzzer.c             |   6 +-
 tools/target_enc_fuzzer.c             |   4 +-
 876 files changed, 3475 insertions(+), 3469 deletions(-)

diff --git a/doc/examples/avio_read_callback.c b/doc/examples/avio_read_callback.c
index dffc061d9f8..ddb54621f77 100644
--- a/doc/examples/avio_read_callback.c
+++ b/doc/examples/avio_read_callback.c
@@ -42,7 +42,7 @@ struct buffer_data {
 static int read_packet(void *opaque, uint8_t *buf, int buf_size)
 {
     struct buffer_data *bd = (struct buffer_data *)opaque;
-    buf_size = FFMIN(buf_size, bd->size);
+    buf_size = FFMINI(buf_size, bd->size);
 
     if (!buf_size)
         return AVERROR_EOF;
diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index 20de08d93bf..65c3f5586cc 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -733,7 +733,7 @@ static int load_encode_and_write(AVAudioFifo *fifo,
     /* Use the maximum number of possible samples per frame.
      * If there is less than the maximum possible frame size in the FIFO
      * buffer use this number. Otherwise, use the maximum possible frame size. */
-    const int frame_size = FFMIN(av_audio_fifo_size(fifo),
+    const int frame_size = FFMINI(av_audio_fifo_size(fifo),
                                  output_codec_context->frame_size);
     int data_written;
 
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index be21ed2c6c2..f2430199823 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -614,7 +614,7 @@ int opt_default(void *optctx, const char *opt, const char *arg)
 
     if (!(p = strchr(opt, ':')))
         p = opt + strlen(opt);
-    av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
+    av_strlcpy(opt_stripped, opt, FFMINI(sizeof(opt_stripped), p - opt + 1));
 
     if ((o = opt_find(&cc, opt_stripped, NULL, 0,
                          AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index de607cac931..9c8bd4c5f3b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -701,7 +701,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
         av_bprintf(&buf_script, "progress=%s\n",
                    is_last_report ? "end" : "continue");
         avio_write(progress_avio, buf_script.str,
-                   FFMIN(buf_script.len, buf_script.size - 1));
+                   FFMINI(buf_script.len, buf_script.size - 1));
         avio_flush(progress_avio);
         av_bprint_finalize(&buf_script, NULL);
         if (is_last_report) {
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index b06455c7b18..2317105aa77 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -337,7 +337,7 @@ static int64_t video_duration_estimate(const DecoderPriv *dp, const AVFrame *fra
     }
 
     // last resort is last frame's estimated duration, and 1
-    return FFMAX(dp->last_frame_duration_est, 1);
+    return FFMAXI(dp->last_frame_duration_est, 1);
 }
 
 static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index cb4318c75b8..fc22c55789b 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -513,12 +513,12 @@ static void readrate_sleep(Demuxer *d)
 
         if (ds->discard) continue;
 
-        stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start);
+        stream_ts_offset = FFMAXI(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start);
         pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE);
         now = av_gettime_relative();
         wc_elapsed = now - d->wallclock_start;
         max_pts = stream_ts_offset + initial_burst + wc_elapsed * d->readrate;
-        lag = FFMAX(max_pts - pts, 0);
+        lag = FFMAXI(max_pts - pts, 0);
         if ( (!ds->lag && lag > 0.3 * AV_TIME_BASE) || ( lag > ds->lag + 0.3 * AV_TIME_BASE) ) {
             ds->lag = lag;
             ds->resume_wc = now;
@@ -1056,15 +1056,15 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
             for (int j = 0; j < d->f.nb_streams; j++) {
                 AVCodecParameters *par1 = d->f.streams[j]->par;
                 if (par1->codec_type == AVMEDIA_TYPE_VIDEO) {
-                    opts->sub2video_width  = FFMAX(opts->sub2video_width,  par1->width);
-                    opts->sub2video_height = FFMAX(opts->sub2video_height, par1->height);
+                    opts->sub2video_width  = FFMAXI(opts->sub2video_width,  par1->width);
+                    opts->sub2video_height = FFMAXI(opts->sub2video_height, par1->height);
                 }
             }
         }
 
         if (!(opts->sub2video_width && opts->sub2video_height)) {
-            opts->sub2video_width  = FFMAX(opts->sub2video_width,  720);
-            opts->sub2video_height = FFMAX(opts->sub2video_height, 576);
+            opts->sub2video_width  = FFMAXI(opts->sub2video_width,  720);
+            opts->sub2video_height = FFMAXI(opts->sub2video_height, 576);
         }
 
         if (!d->pkt_heartbeat) {
@@ -1317,7 +1317,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
         uint32_t tag = strtol(codec_tag, &next, 0);
         if (*next) {
             uint8_t buf[4] = { 0 };
-            memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
+            memcpy(buf, codec_tag, FFMINI(sizeof(buf), strlen(codec_tag)));
             tag = AV_RL32(buf);
         }
 
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index a46af4dce19..6b166b2358f 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -243,7 +243,7 @@ int enc_open(void *opaque, const AVFrame *frame)
         if (ost->bits_per_raw_sample)
             enc_ctx->bits_per_raw_sample = ost->bits_per_raw_sample;
         else
-            enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample,
+            enc_ctx->bits_per_raw_sample = FFMINI(fd->bits_per_raw_sample,
                                                  av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3);
         break;
 
@@ -263,7 +263,7 @@ int enc_open(void *opaque, const AVFrame *frame)
         if (ost->bits_per_raw_sample)
             enc_ctx->bits_per_raw_sample = ost->bits_per_raw_sample;
         else
-            enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample,
+            enc_ctx->bits_per_raw_sample = FFMINI(fd->bits_per_raw_sample,
                                                  av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
 
         enc_ctx->color_range            = frame->color_range;
@@ -394,7 +394,7 @@ static int do_subtitle_out(OutputFile *of, OutputStream *ost, const AVSubtitle *
     if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
         nb = 2;
     else if (enc->codec_id == AV_CODEC_ID_ASS)
-        nb = FFMAX(sub->num_rects, 1);
+        nb = FFMAXI(sub->num_rects, 1);
     else
         nb = 1;
 
@@ -512,7 +512,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es,
             case ENC_STATS_KEYFRAME:    avio_write(io, (pkt->flags & AV_PKT_FLAG_KEY) ?
                                                        "K" : "N", 1);                               continue;
             case ENC_STATS_BITRATE: {
-                double duration = FFMAX(pkt->duration, 1) * av_q2d(tb);
+                double duration = FFMAXI(pkt->duration, 1) * av_q2d(tb);
                 avio_printf(io, "%g",  8.0 * pkt->size / duration);
                 continue;
             }
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 25f66dd1856..836afbf20ee 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -193,7 +193,7 @@ static int mux_fixup_ts(Muxer *mux, MuxStream *ms, AVPacket *pkt)
                        "in incorrect timestamps in the output file.\n",
                        max);
                 if (pkt->pts >= pkt->dts)
-                    pkt->pts = FFMAX(pkt->pts, max);
+                    pkt->pts = FFMAXI(pkt->pts, max);
                 pkt->dts = max;
             }
         }
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 4a973e52868..526b6b75e5e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1104,7 +1104,7 @@ static int streamcopy_init(const OptionsContext *o, const Muxer *mux,
         ms->ts_copy_start = (mux->of.start_time == AV_NOPTS_VALUE) ?
                             0 : mux->of.start_time;
         if (copy_ts && ifile->start_time != AV_NOPTS_VALUE) {
-            ms->ts_copy_start = FFMAX(ms->ts_copy_start,
+            ms->ts_copy_start = FFMAXI(ms->ts_copy_start,
                                       ifile->start_time + ifile->ts_offset);
         }
     }
@@ -1484,7 +1484,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
         uint32_t tag = strtol(codec_tag, &next, 0);
         if (*next) {
             uint8_t buf[4] = { 0 };
-            memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
+            memcpy(buf, codec_tag, FFMINI(sizeof(buf), strlen(codec_tag)));
             tag = AV_RL32(buf);
         }
         ost->st->codecpar->codec_tag = tag;
@@ -2851,8 +2851,8 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, AVFormatContext *o
 
         out_ch->id        = in_ch->id;
         out_ch->time_base = in_ch->time_base;
-        out_ch->start     = FFMAX(0,  in_ch->start - ts_off);
-        out_ch->end       = FFMIN(rt, in_ch->end   - ts_off);
+        out_ch->start     = FFMAXI(0,  in_ch->start - ts_off);
+        out_ch->end       = FFMINI(rt, in_ch->end   - ts_off);
 
         if (copy_metadata)
             av_dict_copy(&out_ch->metadata, in_ch->metadata, 0);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 3d1efe32f90..c3e4c5385ef 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -347,7 +347,7 @@ static void correct_input_start_times(void)
             AVStream *st = is->streams[j];
             if(st->discard == AVDISCARD_ALL || st->start_time == AV_NOPTS_VALUE)
                 continue;
-            new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
+            new_start_time = FFMINI(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
         }
 
         diff = new_start_time - is->start_time;
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index e6d22063d71..ff52d4350fc 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -449,7 +449,7 @@ static int64_t trailing_dts(const Scheduler *sch, int count_finished)
             if (ms->last_dts == AV_NOPTS_VALUE)
                 return AV_NOPTS_VALUE;
 
-            min_dts = FFMIN(min_dts, ms->last_dts);
+            min_dts = FFMINI(min_dts, ms->last_dts);
         }
     }
 
@@ -1831,7 +1831,7 @@ static int mux_queue_packet(SchMux *mux, SchMuxStream *ms, AVPacket *pkt)
         size_t    pkt_size = pkt ? pkt->size : 0;
         int thresh_reached = (q->data_size + pkt_size) > q->data_threshold;
         size_t max_packets = thresh_reached ? q->max_packets : SIZE_MAX;
-        size_t new_size = FFMIN(2 * packets, max_packets);
+        size_t new_size = FFMINI(2 * packets, max_packets);
 
         if (new_size <= packets) {
             av_log(mux, AV_LOG_ERROR,
diff --git a/fftools/ffmpeg_utils.h b/fftools/ffmpeg_utils.h
index 9ca3afffa01..69b47a73aa3 100644
--- a/fftools/ffmpeg_utils.h
+++ b/fftools/ffmpeg_utils.h
@@ -41,7 +41,7 @@ static inline int err_merge(int err0, int err1)
     // prefer "real" errors over EOF
     if ((err0 >= 0 || err0 == AVERROR_EOF) && err1 < 0)
         return err1;
-    return (err0 < 0) ? err0 : FFMIN(err1, 0);
+    return (err0 < 0) ? err0 : FFMINI(err1, 0);
 }
 
 /**
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aae..c3699421dad 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -124,7 +124,7 @@ typedef struct PacketQueue {
 #define VIDEO_PICTURE_QUEUE_SIZE 3
 #define SUBPICTURE_QUEUE_SIZE 16
 #define SAMPLE_QUEUE_SIZE 9
-#define FRAME_QUEUE_SIZE FFMAX(SAMPLE_QUEUE_SIZE, FFMAX(VIDEO_PICTURE_QUEUE_SIZE, SUBPICTURE_QUEUE_SIZE))
+#define FRAME_QUEUE_SIZE FFMAXI(SAMPLE_QUEUE_SIZE, FFMAXI(VIDEO_PICTURE_QUEUE_SIZE, SUBPICTURE_QUEUE_SIZE))
 
 typedef struct AudioParams {
     int freq;
@@ -698,7 +698,7 @@ static int frame_queue_init(FrameQueue *f, PacketQueue *pktq, int max_size, int
         return AVERROR(ENOMEM);
     }
     f->pktq = pktq;
-    f->max_size = FFMIN(max_size, FRAME_QUEUE_SIZE);
+    f->max_size = FFMINI(max_size, FRAME_QUEUE_SIZE);
     f->keep_last = !!keep_last;
     for (i = 0; i < f->max_size; i++)
         if (!(f->queue[i].frame = av_frame_alloc()))
@@ -880,8 +880,8 @@ static void calculate_display_rect(SDL_Rect *rect,
     y = (scr_height - height) / 2;
     rect->x = scr_xleft + x;
     rect->y = scr_ytop  + y;
-    rect->w = FFMAX((int)width,  1);
-    rect->h = FFMAX((int)height, 1);
+    rect->w = FFMAXI((int)width,  1);
+    rect->h = FFMAXI((int)height, 1);
 }
 
 static void get_sdl_pix_fmt_and_blendmode(int format, Uint32 *sdl_pix_fmt, SDL_BlendMode *sdl_blendmode)
@@ -1144,7 +1144,7 @@ static void video_audio_display(VideoState *s)
 
         if (s->xpos >= s->width)
             s->xpos = 0;
-        nb_display_channels= FFMIN(nb_display_channels, 2);
+        nb_display_channels= FFMINI(nb_display_channels, 2);
         if (rdft_bits != s->rdft_bits) {
             const float rdft_scale = 1.0;
             av_tx_uninit(&s->rdft);
@@ -1190,8 +1190,8 @@ static void video_audio_display(VideoState *s)
                     int a = sqrt(w * sqrt(data[0][y].re * data[0][y].re + data[0][y].im * data[0][y].im));
                     int b = (nb_display_channels == 2 ) ? sqrt(w * hypot(data[1][y].re, data[1][y].im))
                                                         : a;
-                    a = FFMIN(a, 255);
-                    b = FFMIN(b, 255);
+                    a = FFMINI(a, 255);
+                    b = FFMINI(b, 255);
                     pixels -= pitch;
                     *pixels = (a << 16) + (b << 8) + ((a+b) >> 1);
                 }
@@ -1466,10 +1466,10 @@ static double get_master_clock(VideoState *is)
 static void check_external_clock_speed(VideoState *is) {
    if (is->video_stream >= 0 && is->videoq.nb_packets <= EXTERNAL_CLOCK_MIN_FRAMES ||
        is->audio_stream >= 0 && is->audioq.nb_packets <= EXTERNAL_CLOCK_MIN_FRAMES) {
-       set_clock_speed(&is->extclk, FFMAX(EXTERNAL_CLOCK_SPEED_MIN, is->extclk.speed - EXTERNAL_CLOCK_SPEED_STEP));
+       set_clock_speed(&is->extclk, FFMAXD(EXTERNAL_CLOCK_SPEED_MIN, is->extclk.speed - EXTERNAL_CLOCK_SPEED_STEP));
    } else if ((is->video_stream < 0 || is->videoq.nb_packets > EXTERNAL_CLOCK_MAX_FRAMES) &&
               (is->audio_stream < 0 || is->audioq.nb_packets > EXTERNAL_CLOCK_MAX_FRAMES)) {
-       set_clock_speed(&is->extclk, FFMIN(EXTERNAL_CLOCK_SPEED_MAX, is->extclk.speed + EXTERNAL_CLOCK_SPEED_STEP));
+       set_clock_speed(&is->extclk, FFMIND(EXTERNAL_CLOCK_SPEED_MAX, is->extclk.speed + EXTERNAL_CLOCK_SPEED_STEP));
    } else {
        double speed = is->extclk.speed;
        if (speed != 1.0)
@@ -1544,10 +1544,10 @@ static double compute_target_delay(double delay, VideoState *is)
         /* skip or repeat frame. We take into account the
            delay to compute the threshold. I still don't know
            if it is the best guess */
-        sync_threshold = FFMAX(AV_SYNC_THRESHOLD_MIN, FFMIN(AV_SYNC_THRESHOLD_MAX, delay));
+        sync_threshold = FFMAXD(AV_SYNC_THRESHOLD_MIN, FFMIND(AV_SYNC_THRESHOLD_MAX, delay));
         if (!isnan(diff) && fabs(diff) < is->max_frame_duration) {
             if (diff <= -sync_threshold)
-                delay = FFMAX(0, delay + diff);
+                delay = FFMAXD(0, delay + diff);
             else if (diff >= sync_threshold && delay > AV_SYNC_FRAMEDUP_THRESHOLD)
                 delay = delay + diff;
             else if (diff >= sync_threshold)
@@ -1597,7 +1597,7 @@ static void video_refresh(void *opaque, double *remaining_time)
             video_display(is);
             is->last_vis_time = time;
         }
-        *remaining_time = FFMIN(*remaining_time, is->last_vis_time + rdftspeed - time);
+        *remaining_time = FFMIND(*remaining_time, is->last_vis_time + rdftspeed - time);
     }
 
     if (is->video_st) {
@@ -1629,7 +1629,7 @@ retry:
 
             time= av_gettime_relative()/1000000.0;
             if (time < is->frame_timer + delay) {
-                *remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
+                *remaining_time = FFMIND(is->frame_timer + delay - time, *remaining_time);
                 goto display;
             }
 
@@ -2551,13 +2551,13 @@ static int audio_open(void *opaque, AVChannelLayout *wanted_channel_layout, int
         next_sample_rate_idx--;
     wanted_spec.format = AUDIO_S16SYS;
     wanted_spec.silence = 0;
-    wanted_spec.samples = FFMAX(SDL_AUDIO_MIN_BUFFER_SIZE, 2 << av_log2(wanted_spec.freq / SDL_AUDIO_MAX_CALLBACKS_PER_SEC));
+    wanted_spec.samples = FFMAXI(SDL_AUDIO_MIN_BUFFER_SIZE, 2 << av_log2(wanted_spec.freq / SDL_AUDIO_MAX_CALLBACKS_PER_SEC));
     wanted_spec.callback = sdl_audio_callback;
     wanted_spec.userdata = opaque;
     while (!(audio_dev = SDL_OpenAudioDevice(NULL, 0, &wanted_spec, &spec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE))) {
         av_log(NULL, AV_LOG_WARNING, "SDL_OpenAudio (%d channels, %d Hz): %s\n",
                wanted_spec.channels, wanted_spec.freq, SDL_GetError());
-        wanted_spec.channels = next_nb_channels[FFMIN(7, wanted_spec.channels)];
+        wanted_spec.channels = next_nb_channels[FFMINI(7, wanted_spec.channels)];
         if (!wanted_spec.channels) {
             wanted_spec.freq = next_sample_rates[next_sample_rate_idx--];
             wanted_spec.channels = wanted_nb_channels;
@@ -3345,7 +3345,7 @@ static void seek_chapter(VideoState *is, int incr)
     }
 
     i += incr;
-    i = FFMAX(i, 0);
+    i = FFMAXI(i, 0);
     if (i >= is->ic->nb_chapters)
         return;
 
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 80ce38e73bd..71a3d13dcb3 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -1292,7 +1292,7 @@ static void print_frame_side_data(AVTextFormatContext *tfc,
             print_str("timecode", tcbuf);
         } else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
             uint32_t *tc = (uint32_t*)sd->data;
-            int m = FFMIN(tc[0],3);
+            int m = FFMINI(tc[0],3);
             avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST);
             for (int j = 1; j <= m ; j++) {
                 char tcbuf[AV_TIMECODE_STR_SIZE];
@@ -3213,7 +3213,7 @@ int main(int argc, char **argv)
         if (ret < 0)
             av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing formatter): %s\n", av_err2str(ret));
 
-        ret = FFMIN(ret, input_ret);
+        ret = FFMINI(ret, input_ret);
     }
 
 end:
diff --git a/fftools/graph/graphprint.c b/fftools/graph/graphprint.c
index 852a8f6c0c2..0eb9c6feac8 100644
--- a/fftools/graph/graphprint.c
+++ b/fftools/graph/graphprint.c
@@ -1084,7 +1084,7 @@ static int print_filtergraphs_priv(FilterGraph **graphs, int nb_graphs, InputFil
                 goto cleanup;
             }
 
-            avio_write(avio, (const unsigned char *)target_buf.str, FFMIN(target_buf.len, target_buf.size - 1));
+            avio_write(avio, (const unsigned char *)target_buf.str, FFMINI(target_buf.len, target_buf.size - 1));
             avio_flush(avio);
 
             if ((ret = avio_closep(&avio)) < 0)
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index c2f6b9de2a7..6129cb7e7d9 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1202,7 +1202,7 @@ int init_report(const char *env, FILE **file)
 
     prog_loglevel = av_log_get_level();
     if (!envlevel)
-        report_file_level = FFMAX(report_file_level, prog_loglevel);
+        report_file_level = FFMAXI(report_file_level, prog_loglevel);
 
     report_file = fopen(filename.str, "w");
     if (!report_file) {
diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index bb90e66918e..dc76bf33cee 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -531,7 +531,7 @@ void avtext_print_data(AVTextFormatContext *tctx, const char *key,
     av_bprintf(&bp, "\n");
     while (size) {
         av_bprintf(&bp, "%08x: ", offset);
-        l = FFMIN(size, 16);
+        l = FFMINI(size, 16);
         for (i = 0; i < l; i++) {
             av_bprintf(&bp, "%02x", data[i]);
             if (i & 1)
@@ -580,7 +580,7 @@ void avtext_print_integers(AVTextFormatContext *tctx, const char *key,
     av_bprintf(&bp, "\n");
     while (size) {
         av_bprintf(&bp, "%08x: ", offset);
-        l = FFMIN(size, columns);
+        l = FFMINI(size, columns);
         for (i = 0; i < l; i++) {
             if      (bytes == 1) av_bprintf(&bp, format, *data);
             else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index c6b2ce12304..c9f7d5f46f7 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -453,7 +453,7 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
         extra           = 0;
         bitstream_size  = AV_RL16(buf - 4);
         wordstream_size = AV_RL16(buf - 2);
-        bytestream_size = FFMAX(length - bitstream_size - wordstream_size, 0);
+        bytestream_size = FFMAXI(length - bitstream_size - wordstream_size, 0);
     }
 
     if (bitstream_size > length || bitstream_size >= INT_MAX/8 ||
@@ -637,7 +637,7 @@ static const uint8_t *read_huffman_tables(FourXContext *f,
     for (;;) {
         int i;
 
-        if (ptr_end - ptr < FFMAX(end - start + 1, 0) + 1) {
+        if (ptr_end - ptr < FFMAXI(end - start + 1, 0) + 1) {
             av_log(f->avctx, AV_LOG_ERROR, "invalid data in read_huffman_tables\n");
             return NULL;
         }
diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index 18203ee69e2..bb142f2dcb5 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -132,7 +132,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     }
 
     /* decode next piece of data from the buffer */
-    buf_size = FFMIN(MAX_FRAME_SIZE, esc->data_size - esc->data_idx);
+    buf_size = FFMINI(MAX_FRAME_SIZE, esc->data_size - esc->data_idx);
     if (buf_size <= 0) {
         *got_frame_ptr = 0;
         return avpkt->size;
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index d81718dff5f..c8bdfac7d00 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -74,8 +74,8 @@ static void to_meta_with_crop(AVCodecContext *avctx,
 {
     int blockx, blocky, x, y;
     int luma = 0;
-    int height = FFMIN(avctx->height, C64YRES);
-    int width  = FFMIN(avctx->width , C64XRES);
+    int height = FFMINI(avctx->height, C64YRES);
+    int width  = FFMINI(avctx->width , C64XRES);
     const uint8_t *src = p->data[0];
 
     for (blocky = 0; blocky < C64YRES; blocky += 8) {
@@ -131,7 +131,7 @@ static void render_charset(AVCodecContext *avctx, uint8_t *charset,
         }
         if(i >= c->mc_pal_size - 1) dither[a] = 0;
         index1[a] = i;
-        index2[a] = FFMIN(i + 1, c->mc_pal_size - 1);
+        index2[a] = FFMINI(i + 1, c->mc_pal_size - 1);
     }
 
     /* and render charset */
@@ -177,10 +177,10 @@ static void render_charset(AVCodecContext *avctx, uint8_t *charset,
         if (highdiff > 0 && lowdiff > 0 && c->mc_use_5col) {
             if (lowdiff > highdiff) {
                 for (x = 0; x < 32; x++)
-                    best_cb[x] = FFMIN(c->mc_luma_vals[3], best_cb[x]);
+                    best_cb[x] = FFMINI(c->mc_luma_vals[3], best_cb[x]);
             } else {
                 for (x = 0; x < 32; x++)
-                    best_cb[x] = FFMAX(c->mc_luma_vals[1], best_cb[x]);
+                    best_cb[x] = FFMAXI(c->mc_luma_vals[1], best_cb[x]);
             }
             charpos--;          /* redo now adjusted char */
         /* no adjustment needed, all fine */
@@ -296,8 +296,8 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     int screen_size;
 
     if(CROP_SCREENS) {
-        b_height = FFMIN(avctx->height,C64YRES) >> 3;
-        b_width  = FFMIN(avctx->width ,C64XRES) >> 3;
+        b_height = FFMINI(avctx->height,C64YRES) >> 3;
+        b_width  = FFMINI(avctx->width ,C64XRES) >> 3;
         screen_size = b_width * b_height;
     } else {
         b_height = C64YRES >> 3;
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 18e072c0c9f..43c718df3ea 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1269,7 +1269,7 @@ static int decode_prediction(AACDecContext *ac, IndividualChannelStream *ics,
             return AVERROR_INVALIDDATA;
         }
     }
-    for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) {
+    for (sfb = 0; sfb < FFMINI(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) {
         ics->prediction_used[sfb] = get_bits1(gb);
     }
     return 0;
@@ -1289,7 +1289,7 @@ static void decode_ltp(AACDecContext *ac, LongTermPrediction *ltp,
     else if (CONFIG_AAC_DECODER)
         ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
 
-    for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
+    for (sfb = 0; sfb < FFMINI(max_sfb, MAX_LTP_LONG_SFB); sfb++)
         ltp->used[sfb] = get_bits1(gb);
 }
 
@@ -1323,7 +1323,7 @@ static int decode_ics_info(AACDecContext *ac, IndividualChannelStream *ics,
         ics->use_kb_window[1]   = ics->use_kb_window[0];
         ics->use_kb_window[0]   = get_bits1(gb);
     }
-    ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
+    ics->prev_num_window_groups = FFMAXI(ics->num_window_groups, 1);
     ics->num_window_groups  = 1;
     ics->group_len[0]       = 1;
     if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
@@ -2096,7 +2096,7 @@ static int parse_adts_frame_header(AACDecContext *ac, GetBitContext *gb)
                                                          hdr_info.chan_config)) < 0)
                 return ret;
             if ((ret = ff_aac_output_configure(ac, layout_map, layout_map_tags,
-                                              FFMAX(ac->oc[1].status,
+                                              FFMAXI(ac->oc[1].status,
                                               OC_TRIAL_FRAME), 0)) < 0)
                 return ret;
         } else {
diff --git a/libavcodec/aac/aacdec_ac.c b/libavcodec/aac/aacdec_ac.c
index 5104604fa58..d300e902375 100644
--- a/libavcodec/aac/aacdec_ac.c
+++ b/libavcodec/aac/aacdec_ac.c
@@ -91,7 +91,7 @@ uint32_t ff_aac_ac_get_pk(uint32_t c)
 void ff_aac_ac_update_context(AACArithState *state, int idx,
                               uint16_t a, uint16_t b)
 {
-    state->cur[0] = FFMIN(a + b + 1, 0xF);
+    state->cur[0] = FFMINI(a + b + 1, 0xF);
     state->cur[3] = state->cur[2];
     state->cur[2] = state->cur[1];
     state->cur[1] = state->cur[0];
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index e10ce13a3b4..b40b147245a 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -78,7 +78,7 @@ get_next:
         }
 
         if(ff_combine_frame(pc, i, &buf, &buf_size)<0){
-            s->remaining_size -= FFMIN(s->remaining_size, buf_size);
+            s->remaining_size -= FFMINI(s->remaining_size, buf_size);
             *poutbuf = NULL;
             *poutbuf_size = 0;
             return buf_size;
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 96915c97319..09bfae78b2d 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -354,7 +354,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
 
     // for values above this the decoder might end up in an endless loop
     // due to always having more bits than what can be encoded.
-    destbits = FFMIN(destbits, 5800);
+    destbits = FFMINI(destbits, 5800);
     //some heuristic to determine initial quantizers will reduce search time
     //determine zero bands and upper limits
     for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
@@ -375,7 +375,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
             sce->band_type[w*16+g] = 0;
             sce->zeroes[w*16+g] = !nz;
             if (nz)
-                minthr = FFMIN(minthr, uplim);
+                minthr = FFMINF(minthr, uplim);
             allz |= nz;
             start += sce->ics.swb_sizes[g];
         }
@@ -386,7 +386,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
                 sce->sf_idx[w*16+g] = SCALE_ONE_POS;
                 continue;
             }
-            sce->sf_idx[w*16+g] = SCALE_ONE_POS + FFMIN(log2f(uplims[w*16+g]/minthr)*4,59);
+            sce->sf_idx[w*16+g] = SCALE_ONE_POS + FFMINF(log2f(uplims[w*16+g]/minthr)*4,59);
         }
     }
 
@@ -427,7 +427,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
                         start += sce->ics.swb_sizes[g];
                         continue;
                     }
-                    minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]);
+                    minscaler = FFMINI(minscaler, sce->sf_idx[w*16+g]);
                     cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
                     for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
                         int b;
@@ -476,7 +476,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
                         sce->sf_idx[w*16+g]-=2;
                 }
                 sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF);
-                sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219);
+                sce->sf_idx[w*16+g] = FFMINI(sce->sf_idx[w*16+g], 219);
                 if (sce->sf_idx[w*16+g] != prevsc)
                     fflag = 1;
                 sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
@@ -498,9 +498,9 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
     const float lambda = s->lambda;
     const float freq_mult = avctx->sample_rate*0.5f/wlen;
     const float thr_mult = NOISE_LAMBDA_REPLACE*(100.0f/lambda);
-    const float spread_threshold = FFMIN(0.75f, NOISE_SPREAD_THRESHOLD*FFMAX(0.5f, lambda/100.f));
+    const float spread_threshold = FFMINF(0.75f, NOISE_SPREAD_THRESHOLD*FFMAXF(0.5f, lambda/100.f));
     const float dist_bias = av_clipf(4.f * 120 / lambda, 0.25f, 4.0f);
-    const float pns_transient_energy_r = FFMIN(0.7f, lambda / 140.f);
+    const float pns_transient_energy_r = FFMINF(0.7f, lambda / 140.f);
 
     int refbits = avctx->bit_rate * 1024.0 / avctx->sample_rate
         / ((avctx->flags & AV_CODEC_FLAG_QSCALE) ? 2.0f : avctx->ch_layout.nb_channels)
@@ -518,7 +518,7 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
     if (avctx->cutoff > 0) {
         bandwidth = avctx->cutoff;
     } else {
-        bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
+        bandwidth = FFMAXI(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
     }
 
     cutoff = bandwidth * 2 * wlen / avctx->sample_rate;
@@ -535,7 +535,7 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
             float min_energy = -1.0f, max_energy = 0.0f;
             const int start = wstart+sce->ics.swb_offset[g];
             const float freq = (start-wstart)*freq_mult;
-            const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);
+            const float freq_boost = FFMAXF(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);
             if (freq < NOISE_LOW_LIMIT || (start-wstart) >= cutoff) {
                 if (!sce->zeroes[w*16+g])
                     prev_sf = sce->sf_idx[w*16+g];
@@ -544,13 +544,13 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
             for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
                 band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
                 sfb_energy += band->energy;
-                spread     = FFMIN(spread, band->spread);
+                spread     = FFMINF(spread, band->spread);
                 threshold  += band->threshold;
                 if (!w2) {
                     min_energy = max_energy = band->energy;
                 } else {
-                    min_energy = FFMIN(min_energy, band->energy);
-                    max_energy = FFMAX(max_energy, band->energy);
+                    min_energy = FFMINF(min_energy, band->energy);
+                    max_energy = FFMAXF(max_energy, band->energy);
                 }
             }
 
@@ -574,7 +574,7 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
                 continue;
             }
 
-            pns_tgt_energy = sfb_energy*FFMIN(1.0f, spread*spread);
+            pns_tgt_energy = sfb_energy*FFMINF(1.0f, spread*spread);
             noise_sfi = av_clip(roundf(log2f(pns_tgt_energy)*2), -100, 155); /* Quantize */
             noise_amp = -ff_aac_pow2sf_tab[noise_sfi + POW_SF2_ZERO];    /* Dequantize */
             if (prev != -1000) {
@@ -636,8 +636,8 @@ static void mark_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelEleme
     int bandwidth, cutoff;
     const float lambda = s->lambda;
     const float freq_mult = avctx->sample_rate*0.5f/wlen;
-    const float spread_threshold = FFMIN(0.75f, NOISE_SPREAD_THRESHOLD*FFMAX(0.5f, lambda/100.f));
-    const float pns_transient_energy_r = FFMIN(0.7f, lambda / 140.f);
+    const float spread_threshold = FFMINF(0.75f, NOISE_SPREAD_THRESHOLD*FFMAXF(0.5f, lambda/100.f));
+    const float pns_transient_energy_r = FFMINF(0.7f, lambda / 140.f);
 
     int refbits = avctx->bit_rate * 1024.0 / avctx->sample_rate
         / ((avctx->flags & AV_CODEC_FLAG_QSCALE) ? 2.0f : avctx->ch_layout.nb_channels)
@@ -654,7 +654,7 @@ static void mark_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelEleme
     if (avctx->cutoff > 0) {
         bandwidth = avctx->cutoff;
     } else {
-        bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
+        bandwidth = FFMAXI(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
     }
 
     cutoff = bandwidth * 2 * wlen / avctx->sample_rate;
@@ -666,7 +666,7 @@ static void mark_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelEleme
             float min_energy = -1.0f, max_energy = 0.0f;
             const int start = sce->ics.swb_offset[g];
             const float freq = start*freq_mult;
-            const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);
+            const float freq_boost = FFMAXF(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);
             if (freq < NOISE_LOW_LIMIT || start >= cutoff) {
                 sce->can_pns[w*16+g] = 0;
                 continue;
@@ -674,13 +674,13 @@ static void mark_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelEleme
             for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
                 band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
                 sfb_energy += band->energy;
-                spread     = FFMIN(spread, band->spread);
+                spread     = FFMINF(spread, band->spread);
                 threshold  += band->threshold;
                 if (!w2) {
                     min_energy = max_energy = band->energy;
                 } else {
-                    min_energy = FFMIN(min_energy, band->energy);
-                    max_energy = FFMAX(max_energy, band->energy);
+                    min_energy = FFMINF(min_energy, band->energy);
+                    max_energy = FFMAXF(max_energy, band->energy);
                 }
             }
 
@@ -707,7 +707,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
     float *L34 = s->scoefs + 128*2, *R34 = s->scoefs + 128*3;
     float *M34 = s->scoefs + 128*4, *S34 = s->scoefs + 128*5;
     const float lambda = s->lambda;
-    const float mslambda = FFMIN(1.0f, lambda / 120.f);
+    const float mslambda = FFMINF(1.0f, lambda / 120.f);
     SingleChannelElement *sce0 = &cpe->ch[0];
     SingleChannelElement *sce1 = &cpe->ch[1];
     if (!cpe->common_window)
@@ -739,8 +739,8 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
                     s->aacdsp.abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
                     s->aacdsp.abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
                     for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {
-                        Mmax = FFMAX(Mmax, M34[i]);
-                        Smax = FFMAX(Smax, S34[i]);
+                        Mmax = FFMAXF(Mmax, M34[i]);
+                        Smax = FFMAXF(Smax, S34[i]);
                     }
                 }
 
@@ -751,7 +751,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
                     int mididx, sididx;
                     int midcb, sidcb;
 
-                    minidx = FFMIN(sce0->sf_idx[w*16+g], sce1->sf_idx[w*16+g]);
+                    minidx = FFMINI(sce0->sf_idx[w*16+g], sce1->sf_idx[w*16+g]);
                     mididx = av_clip(minidx, 0, SCALE_MAX_POS - SCALE_DIV_512);
                     sididx = av_clip(minidx - sid_sf_boost * 3, 0, SCALE_MAX_POS - SCALE_DIV_512);
                     if (sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT
@@ -765,13 +765,13 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
                     sidcb = find_min_book(Smax, sididx);
 
                     /* No CB can be zero */
-                    midcb = FFMAX(1,midcb);
-                    sidcb = FFMAX(1,sidcb);
+                    midcb = FFMAXI(1,midcb);
+                    sidcb = FFMAXI(1,sidcb);
 
                     for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
                         FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
                         FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
-                        float minthr = FFMIN(band0->threshold, band1->threshold);
+                        float minthr = FFMINF(band0->threshold, band1->threshold);
                         int b1,b2,b3,b4;
                         for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
                             M[i] = (sce0->coeffs[start+(w+w2)*128+i]
diff --git a/libavcodec/aaccoder_twoloop.h b/libavcodec/aaccoder_twoloop.h
index c56abc68a70..fe0becaeebd 100644
--- a/libavcodec/aaccoder_twoloop.h
+++ b/libavcodec/aaccoder_twoloop.h
@@ -193,7 +193,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
         if (avctx->cutoff > 0) {
             bandwidth = avctx->cutoff;
         } else {
-            bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
+            bandwidth = FFMAXI(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
             s->psy.cutoff = bandwidth;
         }
 
@@ -205,9 +205,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
      * for values above this the decoder might end up in an endless loop
      * due to always having more bits than what can be encoded.
      */
-    destbits = FFMIN(destbits, 5800);
-    toomanybits = FFMIN(toomanybits, 5800);
-    toofewbits = FFMIN(toofewbits, 5800);
+    destbits = FFMINI(destbits, 5800);
+    toomanybits = FFMINI(toomanybits, 5800);
+    toofewbits = FFMINI(toofewbits, 5800);
     /**
      * XXX: some heuristic to determine initial quantizers will reduce search time
      * determine zero bands and upper distortion limits
@@ -250,8 +250,8 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                 if (min_spread_thr_r < 0) {
                     min_spread_thr_r = max_spread_thr_r = spread_thr_r[w*16+g];
                 } else {
-                    min_spread_thr_r = FFMIN(min_spread_thr_r, spread_thr_r[w*16+g]);
-                    max_spread_thr_r = FFMAX(max_spread_thr_r, spread_thr_r[w*16+g]);
+                    min_spread_thr_r = FFMINF(min_spread_thr_r, spread_thr_r[w*16+g]);
+                    max_spread_thr_r = FFMAXF(max_spread_thr_r, spread_thr_r[w*16+g]);
                 }
             }
         }
@@ -273,10 +273,10 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
              */
             sce->sf_idx[w*16+g] = av_clip(
                 SCALE_ONE_POS
-                    + 1.75*log2f(FFMAX(0.00125f,uplims[w*16+g]) / sce->ics.swb_sizes[g])
+                    + 1.75*log2f(FFMAXF(0.00125f,uplims[w*16+g]) / sce->ics.swb_sizes[g])
                     + sfoffs,
                 60, SCALE_MAX_POS);
-            minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]);
+            minscaler = FFMINI(minscaler, sce->sf_idx[w*16+g]);
         }
     }
 
@@ -334,7 +334,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                     /** In ABR, we need to priorize less and let rate control do its thing */
                     energy2uplim = sqrtf(energy2uplim);
                 }
-                energy2uplim = FFMAX(0.015625f, FFMIN(1.0f, energy2uplim));
+                energy2uplim = FFMAXF(0.015625f, FFMINF(1.0f, energy2uplim));
                 uplims[w*16+g] *= av_clipf(rdlambda * energy2uplim, rdmin, rdmax)
                                   * sce->ics.group_len[w];
 
@@ -348,7 +348,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                     /** In ABR, we need to priorize less and let rate control do its thing */
                     energy2uplim = sqrtf(energy2uplim);
                 }
-                energy2uplim = FFMAX(0.015625f, FFMIN(1.0f, energy2uplim));
+                energy2uplim = FFMAXF(0.015625f, FFMINF(1.0f, energy2uplim));
                 euplims[w*16+g] *= av_clipf(rdlambda * energy2uplim * sce->ics.group_len[w],
                     0.5f, 1.0f);
             }
@@ -420,7 +420,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                 for (i = 0; i < 128; i++) {
                     if (sce->sf_idx[i] < (SCALE_MAX_POS - SCALE_DIV_512)) {
                         int maxsf_i = (tbits > 5800) ? SCALE_MAX_POS : maxsf[i];
-                        int new_sf = FFMIN(maxsf_i, sce->sf_idx[i] + qstep);
+                        int new_sf = FFMINI(maxsf_i, sce->sf_idx[i] + qstep);
                         if (new_sf != sce->sf_idx[i]) {
                             sce->sf_idx[i] = new_sf;
                             changed = 1;
@@ -504,8 +504,8 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
                     for (g = start = 0;  g < sce->ics.num_swb; start += sce->ics.swb_sizes[g++]) {
                         if (!sce->zeroes[w*16+g] && sce->sf_idx[w*16+g] > SCALE_ONE_POS && dists[w*16+g] > uplims[w*16+g]*ovrfactor) {
-                            float ovrdist = dists[w*16+g] / FFMAX(uplims[w*16+g],euplims[w*16+g]);
-                            maxoverdist = FFMAX(maxoverdist, ovrdist);
+                            float ovrdist = dists[w*16+g] / FFMAXF(uplims[w*16+g],euplims[w*16+g]);
+                            maxoverdist = FFMAXF(maxoverdist, ovrdist);
                             overdist++;
                         }
                     }
@@ -523,8 +523,8 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                     for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
                         for (g = start = 0;  g < sce->ics.num_swb; start += sce->ics.swb_sizes[g++]) {
                             if (start >= pns_start_pos && !sce->zeroes[w*16+g] && sce->can_pns[w*16+g]) {
-                                minspread = FFMIN(minspread, spread_thr_r[w*16+g]);
-                                maxspread = FFMAX(maxspread, spread_thr_r[w*16+g]);
+                                minspread = FFMINF(minspread, spread_thr_r[w*16+g]);
+                                maxspread = FFMAXF(maxspread, spread_thr_r[w*16+g]);
                                 zeroable++;
                             }
                         }
@@ -537,7 +537,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                      */
                     zspread = FFMIN3(min_spread_thr_r * 8.f, zspread,
                         ((toomanybits - tbits) * min_spread_thr_r + (tbits - toofewbits) * max_spread_thr_r) / (toomanybits - toofewbits + 1));
-                    maxzeroed = FFMIN(zeroable, FFMAX(1, (zeroable * its + maxits - 1) / (2 * maxits)));
+                    maxzeroed = FFMINI(zeroable, FFMAXI(1, (zeroable * its + maxits - 1) / (2 * maxits)));
                     for (zloop = 0; zloop < 2; zloop++) {
                         /* Two passes: first distorted stuff - two birds in one shot and all that,
                          * then anything viable. Viable means not zero, but either CB=zero-able
@@ -555,7 +555,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                                 if (!sce->zeroes[w*16+g] && sce->can_pns[w*16+g] && spread_thr_r[w*16+g] <= zspread
                                     && sce->sf_idx[w*16+g] > loopminsf
                                     && (dists[w*16+g] > loopovrfactor*uplims[w*16+g] || !(mcb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]))
-                                        || (mcb <= 1 && dists[w*16+g] > FFMIN(uplims[w*16+g], euplims[w*16+g]))) ) {
+                                        || (mcb <= 1 && dists[w*16+g] > FFMINF(uplims[w*16+g], euplims[w*16+g]))) ) {
                                     sce->zeroes[w*16+g] = 1;
                                     sce->band_type[w*16+g] = 0;
                                     zeroed++;
@@ -575,7 +575,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
         for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
             for (g = 0;  g < sce->ics.num_swb; g++) {
                 if (!sce->zeroes[w*16+g]) {
-                    minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]);
+                    minscaler = FFMINI(minscaler, sce->sf_idx[w*16+g]);
                 }
             }
         }
@@ -587,7 +587,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
             int depth = (its > maxits/2) ? ((its > maxits*2/3) ? 1 : 3) : 10;
             int edepth = depth+2;
             float uplmax = its / (maxits*0.25f) + 1.0f;
-            uplmax *= (tbits > destbits) ? FFMIN(2.0f, tbits / (float)FFMAX(1,destbits)) : 1.0f;
+            uplmax *= (tbits > destbits) ? FFMINF(2.0f, tbits / (float)FFMAXI(1,destbits)) : 1.0f;
             start = w * 128;
             for (g = 0; g < sce->ics.num_swb; g++) {
                 int prevsc = sce->sf_idx[w*16+g];
@@ -597,9 +597,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                     const float *coefs = sce->coeffs + start;
                     const float *scaled = s->scoefs + start;
                     int cmb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
-                    int mindeltasf = FFMAX(0, prev - SCALE_MAX_DIFF);
-                    int maxdeltasf = FFMIN(SCALE_MAX_POS - SCALE_DIV_512, prev + SCALE_MAX_DIFF);
-                    if ((!cmb || dists[w*16+g] > uplims[w*16+g]) && sce->sf_idx[w*16+g] > FFMAX(mindeltasf, minsf[w*16+g])) {
+                    int mindeltasf = FFMAXI(0, prev - SCALE_MAX_DIFF);
+                    int maxdeltasf = FFMINI(SCALE_MAX_POS - SCALE_DIV_512, prev + SCALE_MAX_DIFF);
+                    if ((!cmb || dists[w*16+g] > uplims[w*16+g]) && sce->sf_idx[w*16+g] > FFMAXI(mindeltasf, minsf[w*16+g])) {
                         /* Try to make sure there is some energy in every nonzero band
                          * NOTE: This algorithm must be forcibly imbalanced, pushing harder
                          *  on holes or more distorted bands at first, otherwise there's
@@ -614,7 +614,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                             dist = qenergy = 0.f;
                             bits = 0;
                             if (!cb) {
-                                maxsf[w*16+g] = FFMIN(sce->sf_idx[w*16+g]-1, maxsf[w*16+g]);
+                                maxsf[w*16+g] = FFMINI(sce->sf_idx[w*16+g]-1, maxsf[w*16+g]);
                             } else if (i >= depth && dists[w*16+g] < euplims[w*16+g]) {
                                 break;
                             }
@@ -623,7 +623,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                              * distortion if it doesn't stick to what psy requests
                              */
                             if (!g && sce->ics.num_windows > 1 && dists[w*16+g] >= euplims[w*16+g])
-                                maxsf[w*16+g] = FFMIN(sce->sf_idx[w*16+g], maxsf[w*16+g]);
+                                maxsf[w*16+g] = FFMINI(sce->sf_idx[w*16+g], maxsf[w*16+g]);
                             for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
                                 int b;
                                 float sqenergy;
@@ -643,14 +643,14 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                             dists[w*16+g] = dist - bits;
                             qenergies[w*16+g] = qenergy;
                             if (mb && (sce->sf_idx[w*16+g] < mindeltasf || (
-                                    (dists[w*16+g] < FFMIN(uplmax*uplims[w*16+g], euplims[w*16+g]))
+                                    (dists[w*16+g] < FFMINF(uplmax*uplims[w*16+g], euplims[w*16+g]))
                                     && (fabsf(qenergies[w*16+g]-energies[w*16+g]) < euplims[w*16+g])
                                 ) )) {
                                 break;
                             }
                         }
-                    } else if (tbits > toofewbits && sce->sf_idx[w*16+g] < FFMIN(maxdeltasf, maxsf[w*16+g])
-                            && (dists[w*16+g] < FFMIN(euplims[w*16+g], uplims[w*16+g]))
+                    } else if (tbits > toofewbits && sce->sf_idx[w*16+g] < FFMINI(maxdeltasf, maxsf[w*16+g])
+                            && (dists[w*16+g] < FFMINF(euplims[w*16+g], uplims[w*16+g]))
                             && (fabsf(qenergies[w*16+g]-energies[w*16+g]) < euplims[w*16+g])
                         ) {
                         /** Um... over target. Save bits for more important stuff. */
@@ -677,7 +677,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                                     qenergy += sqenergy;
                                 }
                                 dist -= bits;
-                                if (dist < FFMIN(euplims[w*16+g], uplims[w*16+g])) {
+                                if (dist < FFMINF(euplims[w*16+g], uplims[w*16+g])) {
                                     sce->sf_idx[w*16+g]++;
                                     dists[w*16+g] = dist;
                                     qenergies[w*16+g] = qenergy;
@@ -685,7 +685,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                                     break;
                                 }
                             } else {
-                                maxsf[w*16+g] = FFMIN(sce->sf_idx[w*16+g], maxsf[w*16+g]);
+                                maxsf[w*16+g] = FFMINI(sce->sf_idx[w*16+g], maxsf[w*16+g]);
                                 break;
                             }
                         }
@@ -693,7 +693,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                     prev = sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], mindeltasf, maxdeltasf);
                     if (sce->sf_idx[w*16+g] != prevsc)
                         fflag = 1;
-                    nminscaler = FFMIN(nminscaler, sce->sf_idx[w*16+g]);
+                    nminscaler = FFMINI(nminscaler, sce->sf_idx[w*16+g]);
                     sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
                 }
                 start += sce->ics.swb_sizes[g];
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index afb4478bfe5..bec98d42be9 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -540,7 +540,7 @@ static void adjust_frame_information(ChannelElement *cpe, int chans)
         for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {
             for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
                 ;
-            maxsfb = FFMAX(maxsfb, cmaxsfb);
+            maxsfb = FFMAXI(maxsfb, cmaxsfb);
         }
         ics->max_sfb = maxsfb;
 
@@ -563,7 +563,7 @@ static void adjust_frame_information(ChannelElement *cpe, int chans)
         IndividualChannelStream *ics0 = &cpe->ch[0].ics;
         IndividualChannelStream *ics1 = &cpe->ch[1].ics;
         int msc = 0;
-        ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);
+        ics0->max_sfb = FFMAXI(ics0->max_sfb, ics1->max_sfb);
         ics1->max_sfb = ics0->max_sfb;
         for (w = 0; w < ics0->num_windows*16; w += 16)
             for (i = 0; i < ics0->max_sfb; i++)
@@ -784,7 +784,7 @@ static void put_bitstream_info(AACEncContext *s, const char *name)
 
     namelen = strlen(name) + 2;
     put_bits(&s->pb, 3, TYPE_FIL);
-    put_bits(&s->pb, 4, FFMIN(namelen, 15));
+    put_bits(&s->pb, 4, FFMINI(namelen, 15));
     if (namelen >= 15)
         put_bits(&s->pb, 8, namelen - 14);
     put_bits(&s->pb, 4, 0); //extension type - filler
@@ -891,7 +891,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
             ics->num_windows        = wi[ch].num_windows;
             ics->swb_sizes          = s->psy.bands    [ics->num_windows == 8];
             ics->num_swb            = tag == TYPE_LFE ? ics->num_swb : s->psy.num_bands[ics->num_windows == 8];
-            ics->max_sfb            = FFMIN(ics->max_sfb, ics->num_swb);
+            ics->max_sfb            = FFMINI(ics->max_sfb, ics->num_swb);
             ics->swb_offset         = wi[ch].window_type[0] == EIGHT_SHORT_SEQUENCE ?
                                         ff_swb_offset_128 [s->samplerate_index]:
                                         ff_swb_offset_1024[s->samplerate_index];
@@ -911,13 +911,13 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                 int j;
                 /* mdct input is 2 * output */
                 for (j = 0; j < wlen; j++)
-                    max = FFMAX(max, fabsf(wbuf[j]));
+                    max = FFMAXF(max, fabsf(wbuf[j]));
                 wi[ch].clipping[w] = max;
             }
             for (w = 0; w < ics->num_windows; w++) {
                 if (wi[ch].clipping[w] > CLIP_AVOIDANCE_FACTOR) {
                     ics->window_clipping[w] = 1;
-                    clip_avoidance_factor = FFMAX(clip_avoidance_factor, wi[ch].clipping[w]);
+                    clip_avoidance_factor = FFMAXF(clip_avoidance_factor, wi[ch].clipping[w]);
                 } else {
                     ics->window_clipping[w] = 0;
                 }
@@ -1051,16 +1051,16 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
          */
         frame_bits = put_bits_count(&s->pb);
         rate_bits = avctx->bit_rate * 1024 / avctx->sample_rate;
-        rate_bits = FFMIN(rate_bits, 6144 * s->channels - 3);
-        too_many_bits = FFMAX(target_bits, rate_bits);
-        too_many_bits = FFMIN(too_many_bits, 6144 * s->channels - 3);
-        too_few_bits = FFMIN(FFMAX(rate_bits - rate_bits/4, target_bits), too_many_bits);
+        rate_bits = FFMINI(rate_bits, 6144 * s->channels - 3);
+        too_many_bits = FFMAXI(target_bits, rate_bits);
+        too_many_bits = FFMINI(too_many_bits, 6144 * s->channels - 3);
+        too_few_bits = FFMINI(FFMAXI(rate_bits - rate_bits/4, target_bits), too_many_bits);
 
         /* When strict bit-rate control is demanded */
         if (avctx->bit_rate_tolerance == 0) {
             if (rate_bits < frame_bits) {
                 float ratio = ((float)rate_bits) / frame_bits;
-                s->lambda *= FFMIN(0.9f, ratio);
+                s->lambda *= FFMINF(0.9f, ratio);
                 continue;
             }
             /* reset lambda when solution is found */
@@ -1248,7 +1248,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
              "Too many bits %f > %d per frame requested, clamping to max\n",
              1024.0 * avctx->bit_rate / avctx->sample_rate,
              6144 * s->channels);
-    avctx->bit_rate = (int64_t)FFMIN(6144 * s->channels / 1024.0 * avctx->sample_rate,
+    avctx->bit_rate = (int64_t)FFMIND(6144 * s->channels / 1024.0 * avctx->sample_rate,
                                      avctx->bit_rate);
 
     /* Profile and option setting */
diff --git a/libavcodec/aacenc_is.c b/libavcodec/aacenc_is.c
index 4e711382dc1..da8dcff23f4 100644
--- a/libavcodec/aacenc_is.c
+++ b/libavcodec/aacenc_is.c
@@ -64,10 +64,10 @@ static struct AACISError aac_is_encoding_err(AACEncContext *s, ChannelElement *c
     for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
         FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
         FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
-        int is_band_type, is_sf_idx = FFMAX(1, sce0->sf_idx[w*16+g]-4);
+        int is_band_type, is_sf_idx = FFMAXI(1, sce0->sf_idx[w*16+g]-4);
         float e01_34 = phase*pos_pow34(ener1/ener0);
         float maxval, dist_spec_err = 0.0f;
-        float minthr = FFMIN(band0->threshold, band1->threshold);
+        float minthr = FFMINF(band0->threshold, band1->threshold);
         for (i = 0; i < sce0->ics.swb_sizes[g]; i++)
             IS[i] = (L[start+(w+w2)*128+i] + phase*R[start+(w+w2)*128+i])*sqrt(ener0/ener01);
         s->aacdsp.abs_pow34(L34, &L[start+(w+w2)*128], sce0->ics.swb_sizes[g]);
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c
index 7884c035cb8..8ab2f33e405 100644
--- a/libavcodec/aacenc_tns.c
+++ b/libavcodec/aacenc_tns.c
@@ -104,14 +104,14 @@ void ff_aac_apply_tns(AACEncContext *s, SingleChannelElement *sce)
     TemporalNoiseShaping *tns = &sce->tns;
     IndividualChannelStream *ics = &sce->ics;
     int w, filt, m, i, top, order, bottom, start, end, size, inc;
-    const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
+    const int mmm = FFMINI(ics->tns_max_bands, ics->max_sfb);
     float lpc[TNS_MAX_ORDER];
 
     for (w = 0; w < ics->num_windows; w++) {
         bottom = ics->num_swb;
         for (filt = 0; filt < tns->n_filt[w]; filt++) {
             top    = bottom;
-            bottom = FFMAX(0, top - tns->length[w][filt]);
+            bottom = FFMAXI(0, top - tns->length[w][filt]);
             order  = tns->order[w][filt];
             if (order == 0)
                 continue;
@@ -119,8 +119,8 @@ void ff_aac_apply_tns(AACEncContext *s, SingleChannelElement *sce)
             // tns_decode_coef
             compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
 
-            start = ics->swb_offset[FFMIN(bottom, mmm)];
-            end   = ics->swb_offset[FFMIN(   top, mmm)];
+            start = ics->swb_offset[FFMINI(bottom, mmm)];
+            end   = ics->swb_offset[FFMINI(   top, mmm)];
             if ((size = end - start) <= 0)
                 continue;
             if (tns->direction[w][filt]) {
@@ -133,7 +133,7 @@ void ff_aac_apply_tns(AACEncContext *s, SingleChannelElement *sce)
 
             /* AR filter */
             for (m = 0; m < size; m++, start += inc) {
-                for (i = 1; i <= FFMIN(m, order); i++) {
+                for (i = 1; i <= FFMINI(m, order); i++) {
                     sce->coeffs[start] += lpc[i-1]*sce->pcoeffs[start - i*inc];
                 }
             }
@@ -163,7 +163,7 @@ void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce)
     TemporalNoiseShaping *tns = &sce->tns;
     int w, g, count = 0;
     double gain, coefs[MAX_LPC_ORDER];
-    const int mmm = FFMIN(sce->ics.tns_max_bands, sce->ics.max_sfb);
+    const int mmm = FFMINI(sce->ics.tns_max_bands, sce->ics.max_sfb);
     const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE;
     const int c_bits = is8 ? TNS_Q_BITS_IS8 == 4 : TNS_Q_BITS == 4;
     const int sfb_start = av_clip(tns_min_sfb[is8][s->samplerate_index], 0, mmm);
diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
index cc747c3ea6e..dd5dc160c68 100644
--- a/libavcodec/aacenc_utils.h
+++ b/libavcodec/aacenc_utils.h
@@ -59,7 +59,7 @@ static inline float find_max_val(int group_len, int swb_size, const float *scale
     int w2, i;
     for (w2 = 0; w2 < group_len; w2++) {
         for (i = 0; i < swb_size; i++) {
-            maxval = FFMAX(maxval, scaled[w2*128+i]);
+            maxval = FFMAXF(maxval, scaled[w2*128+i]);
         }
     }
     return maxval;
@@ -89,7 +89,7 @@ static inline float find_form_factor(int group_len, int swb_size, float thresh,
         float nzl = 0;
         for (i = 0; i < swb_size; i++) {
             float s = fabsf(scaled[w2*128+i]);
-            maxval = FFMAX(maxval, s);
+            maxval = FFMAXF(maxval, s);
             e += s;
             e2 += s *= s;
             /* We really don't want a hard non-zero-line count, since
@@ -117,8 +117,8 @@ static inline float find_form_factor(int group_len, int swb_size, float thresh,
             var = sqrtf(var * iswb_sizem1);
 
             e2 *= iswb_size;
-            frm = e / FFMIN(e+4*var,maxval);
-            form += e2 * sqrtf(frm) / FFMAX(0.5f,nzl);
+            frm = e / FFMINF(e+4*var,maxval);
+            form += e2 * sqrtf(frm) / FFMAXF(0.5f,nzl);
             weight += e2;
         }
     }
diff --git a/libavcodec/aacencdsp.h b/libavcodec/aacencdsp.h
index d0d86c3d70e..1b1cc066f71 100644
--- a/libavcodec/aacencdsp.h
+++ b/libavcodec/aacencdsp.h
@@ -50,7 +50,7 @@ static inline void quantize_bands(int *out, const float *in, const float *scaled
 {
     for (int i = 0; i < size; i++) {
         float qc = scaled[i] * Q34;
-        int tmp = (int)FFMIN(qc + rounding, (float)maxval);
+        int tmp = (int)FFMINF(qc + rounding, (float)maxval);
         if (is_signed && in[i] < 0.0f) {
             tmp = -tmp;
         }
diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c
index 6008edd332f..e2af9f13b6b 100644
--- a/libavcodec/aacps.c
+++ b/libavcodec/aacps.c
@@ -452,7 +452,7 @@ static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT
         for (n = n0; n < nL; n++) {
             float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
             float denom;
-            peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
+            peak_decay_nrg[i] = FFMAXF(decayed_peak, power[i][n]);
             power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]);
             peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]);
             denom = transient_impact * peak_decay_diff_smooth[i];
diff --git a/libavcodec/aacps_common.c b/libavcodec/aacps_common.c
index 74fa005aaf0..a65c06ed835 100644
--- a/libavcodec/aacps_common.c
+++ b/libavcodec/aacps_common.c
@@ -80,7 +80,7 @@ static int read_ ## PAR ## _data(void *logctx, GetBitContext *gb, PSCommonContex
     const VLCElem *vlc_table = vlc_ps[table_idx]; \
     if (dt) { \
         int e_prev = e ? e - 1 : ps->num_env_old - 1; \
-        e_prev = FFMAX(e_prev, 0); \
+        e_prev = FFMAXI(e_prev, 0); \
         for (b = 0; b < num; b++) { \
             int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, NB_BITS, MAX_DEPTH); \
             if (MASK) val &= MASK; \
diff --git a/libavcodec/aacps_tablegen.h b/libavcodec/aacps_tablegen.h
index 5fdd7f0a9dd..58d860c7b70 100644
--- a/libavcodec/aacps_tablegen.h
+++ b/libavcodec/aacps_tablegen.h
@@ -158,7 +158,7 @@ static av_cold void ps_tableinit(void)
             } /* else */ {
                 float alpha, gamma, mu, rho;
                 float alpha_c, alpha_s, gamma_c, gamma_s;
-                rho = FFMAX(icc_invq[icc], 0.05f);
+                rho = FFMAXF(icc_invq[icc], 0.05f);
                 alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f);
                 mu = c + 1.0f / c;
                 mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu));
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 019be09fa30..a6d21d2b88c 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -238,7 +238,7 @@ static float lame_calc_attack_threshold(int bitrate)
      * If the loop ends without breaking our above assumption of 320kbps was correct.
      */
     for (i = 1; i < 13; i++) {
-        if (FFMAX(bitrate, psy_abr_map[i].quality) != bitrate) {
+        if (FFMAXI(bitrate, psy_abr_map[i].quality) != bitrate) {
             upper_range = i;
             upper_range_kbps = psy_abr_map[i    ].quality;
             lower_range = i - 1;
@@ -320,7 +320,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
     }
 
     pctx->chan_bitrate = chan_bitrate;
-    pctx->frame_bits   = FFMIN(2560, chan_bitrate * AAC_BLOCK_SIZE_LONG / ctx->avctx->sample_rate);
+    pctx->frame_bits   = FFMINI(2560, chan_bitrate * AAC_BLOCK_SIZE_LONG / ctx->avctx->sample_rate);
     pctx->pe.min       =  8.0f * AAC_BLOCK_SIZE_LONG * bandwidth / (ctx->avctx->sample_rate * 2.0f);
     pctx->pe.max       = 12.0f * AAC_BLOCK_SIZE_LONG * bandwidth / (ctx->avctx->sample_rate * 2.0f);
     ctx->bitres.size   = 6144 - pctx->frame_bits;
@@ -361,7 +361,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
         for (g = 0; g < ctx->num_bands[j]; g++) {
             minscale = ath(start * line_to_frequency, ATH_ADD);
             for (i = 1; i < band_sizes[g]; i++)
-                minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD));
+                minscale = FFMINF(minscale, ath((start + i) * line_to_frequency, ATH_ADD));
             coeffs[g].ath = minscale - minath;
             start += band_sizes[g];
         }
@@ -518,17 +518,17 @@ static int calc_bit_demand(AacPsyContext *ctx, float pe, int bits, int size,
      * Here we do that by slowly forgetting pe.min when pe stays in a range that makes
      * it unlikely (ie: above the mean)
      */
-    ctx->pe.max = FFMAX(pe, ctx->pe.max);
+    ctx->pe.max = FFMAXF(pe, ctx->pe.max);
     forgetful_min_pe = ((ctx->pe.min * PSY_PE_FORGET_SLOPE)
-        + FFMAX(ctx->pe.min, pe * (pe / ctx->pe.max))) / (PSY_PE_FORGET_SLOPE + 1);
-    ctx->pe.min = FFMIN(pe, forgetful_min_pe);
+        + FFMAXF(ctx->pe.min, pe * (pe / ctx->pe.max))) / (PSY_PE_FORGET_SLOPE + 1);
+    ctx->pe.min = FFMINF(pe, forgetful_min_pe);
 
     /* NOTE: allocate a minimum of 1/8th average frame bits, to avoid
      *   reservoir starvation from producing zero-bit frames
      */
-    return FFMIN(
+    return FFMINF(
         ctx->frame_bits * bit_factor,
-        FFMAX(ctx->frame_bits + size - bits, ctx->frame_bits / 8));
+        FFMAXI(ctx->frame_bits + size - bits, ctx->frame_bits / 8));
 }
 
 static float calc_pe_3gpp(AacPsyBand *band)
@@ -565,7 +565,7 @@ static float calc_reduction_3gpp(float a, float desired_pe, float pe,
     thr_avg   = exp2f((a - pe) / (4.0f * active_lines));
     reduction = exp2f((a - desired_pe) / (4.0f * active_lines)) - thr_avg;
 
-    return FFMAX(reduction, 0.0f);
+    return FFMAXF(reduction, 0.0f);
 }
 
 static float calc_reduced_thr_3gpp(AacPsyBand *band, float min_snr,
@@ -585,7 +585,7 @@ static float calc_reduced_thr_3gpp(AacPsyBand *band, float min_snr,
          * threshold of bands with hole avoidance off.
          */
         if (thr > band->energy * min_snr && band->avoid_holes != PSY_3GPP_AH_NONE) {
-            thr = FFMAX(band->thr, band->energy * min_snr);
+            thr = FFMAXF(band->thr, band->energy * min_snr);
             band->avoid_holes = PSY_3GPP_AH_ACTIVE;
         }
     }
@@ -654,7 +654,7 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
     int i, w, g;
     float desired_bits, desired_pe, delta_pe, reduction= NAN, spread_en[128] = {0};
     float a = 0.0f, active_lines = 0.0f, norm_fac = 0.0f;
-    float pe = pctx->chan_bitrate > 32000 ? 0.0f : FFMAX(50.0f, 100.0f - pctx->chan_bitrate * 100.0f / 32000.0f);
+    float pe = pctx->chan_bitrate > 32000 ? 0.0f : FFMAXF(50.0f, 100.0f - pctx->chan_bitrate * 100.0f / 32000.0f);
     const int      num_bands   = ctx->num_bands[wi->num_windows == 8];
     const uint8_t *band_sizes  = ctx->bands[wi->num_windows == 8];
     AacPsyCoeffs  *coeffs      = pctx->psy_coef[wi->num_windows == 8];
@@ -672,21 +672,21 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
         /* 5.4.2.3 "Spreading" & 5.4.3 "Spread Energy Calculation" */
         spread_en[0] = bands[0].energy;
         for (g = 1; g < num_bands; g++) {
-            bands[g].thr   = FFMAX(bands[g].thr,    bands[g-1].thr * coeffs[g].spread_hi[0]);
-            spread_en[w+g] = FFMAX(bands[g].energy, spread_en[w+g-1] * coeffs[g].spread_hi[1]);
+            bands[g].thr   = FFMAXF(bands[g].thr,    bands[g-1].thr * coeffs[g].spread_hi[0]);
+            spread_en[w+g] = FFMAXF(bands[g].energy, spread_en[w+g-1] * coeffs[g].spread_hi[1]);
         }
         for (g = num_bands - 2; g >= 0; g--) {
-            bands[g].thr   = FFMAX(bands[g].thr,   bands[g+1].thr * coeffs[g].spread_low[0]);
-            spread_en[w+g] = FFMAX(spread_en[w+g], spread_en[w+g+1] * coeffs[g].spread_low[1]);
+            bands[g].thr   = FFMAXF(bands[g].thr,   bands[g+1].thr * coeffs[g].spread_low[0]);
+            spread_en[w+g] = FFMAXF(spread_en[w+g], spread_en[w+g+1] * coeffs[g].spread_low[1]);
         }
         //5.4.2.4 "Threshold in quiet"
         for (g = 0; g < num_bands; g++) {
             AacPsyBand *band = &bands[g];
 
-            band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);
+            band->thr_quiet = band->thr = FFMAXF(band->thr, coeffs[g].ath);
             //5.4.2.5 "Pre-echo control"
             if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (!w && wi->window_type[1] == LONG_START_SEQUENCE)))
-                band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr,
+                band->thr = FFMAXF(PSY_3GPP_RPEMIN*band->thr, FFMINF(band->thr,
                                   PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
 
             /* 5.6.1.3.1 "Preparatory steps of the perceptual entropy calculation" */
@@ -709,17 +709,17 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
          * ample room downwards, so we make that equivalent to QSCALE=2.4
          */
         desired_pe = pe * (ctx->avctx->global_quality ? ctx->avctx->global_quality : 120) / (2 * 2.5f * 120.0f);
-        desired_bits = FFMIN(2560, PSY_3GPP_PE_TO_BITS(desired_pe));
+        desired_bits = FFMINF(2560, PSY_3GPP_PE_TO_BITS(desired_pe));
         desired_pe = PSY_3GPP_BITS_TO_PE(desired_bits); // reflect clipping
 
         /* PE slope smoothing */
         if (ctx->bitres.bits > 0) {
-            desired_bits = FFMIN(2560, PSY_3GPP_PE_TO_BITS(desired_pe));
+            desired_bits = FFMINF(2560, PSY_3GPP_PE_TO_BITS(desired_pe));
             desired_pe = PSY_3GPP_BITS_TO_PE(desired_bits); // reflect clipping
         }
 
-        pctx->pe.max = FFMAX(pe, pctx->pe.max);
-        pctx->pe.min = FFMIN(pe, pctx->pe.min);
+        pctx->pe.max = FFMAXF(pe, pctx->pe.max);
+        pctx->pe.min = FFMINF(pe, pctx->pe.min);
     } else {
         desired_bits = calc_bit_demand(pctx, pe, ctx->bitres.bits, ctx->bitres.size, wi->num_windows == 8);
         desired_pe = PSY_3GPP_BITS_TO_PE(desired_bits);
@@ -768,7 +768,7 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
                     }
                 }
             }
-            desired_pe_no_ah = FFMAX(desired_pe - (pe - pe_no_ah), 0.0f);
+            desired_pe_no_ah = FFMAXF(desired_pe - (pe - pe_no_ah), 0.0f);
             if (active_lines > 0.0f)
                 reduction = calc_reduction_3gpp(a, desired_pe_no_ah, pe_no_ah, active_lines);
 
@@ -805,7 +805,7 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
 
                         thr *= exp2f(delta_sfb_pe / band->active_lines);
                         if (thr > coeffs[g].min_snr * band->energy && band->avoid_holes == PSY_3GPP_AH_INACTIVE)
-                            thr = FFMAX(band->thr, coeffs[g].min_snr * band->energy);
+                            thr = FFMAXF(band->thr, coeffs[g].min_snr * band->energy);
                         band->thr = thr;
                     }
                 }
@@ -913,7 +913,7 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
             const float *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
             float p = 1.0f;
             for (; pf < pfe; pf++)
-                p = FFMAX(p, fabsf(*pf));
+                p = FFMAXF(p, fabsf(*pf));
             pch->prev_energy_subshort[i] = energy_subshort[i + PSY_LAME_NUM_SUBBLOCKS] = p;
             energy_short[1 + i / PSY_LAME_NUM_SUBBLOCKS] += p;
             /* NOTE: The indexes below are [i + 3 - 2] in the LAME source.
@@ -945,7 +945,7 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
         for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) {
             const float u = energy_short[i - 1];
             const float v = energy_short[i];
-            const float m = FFMAX(u, v);
+            const float m = FFMAXF(u, v);
             if (m < 40000) {                          /* (2) */
                 if (u < 1.7f * v && v < 1.7f * u) {   /* (1) */
                     if (i == 1 && attacks[0] < attacks[i])
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
index 78f0aead8e3..01fe91332cd 100644
--- a/libavcodec/aacsbr.c
+++ b/libavcodec/aacsbr.c
@@ -261,11 +261,11 @@ static void sbr_gain_calc(SpectralBandReplication *sbr,
                 sum[1] += sbr->e_curr[e][m];
             }
             gain_max = limgain[sbr->bs_limiter_gains] * sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1]));
-            gain_max = FFMIN(100000.f, gain_max);
+            gain_max = FFMINF(100000.f, gain_max);
             for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
                 float q_m_max   = sbr->q_m[e][m] * gain_max / sbr->gain[e][m];
-                sbr->q_m[e][m]  = FFMIN(sbr->q_m[e][m], q_m_max);
-                sbr->gain[e][m] = FFMIN(sbr->gain[e][m], gain_max);
+                sbr->q_m[e][m]  = FFMINF(sbr->q_m[e][m], q_m_max);
+                sbr->gain[e][m] = FFMINF(sbr->gain[e][m], gain_max);
             }
             sum[0] = sum[1] = 0.0f;
             for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
@@ -275,7 +275,7 @@ static void sbr_gain_calc(SpectralBandReplication *sbr,
                           + (delta && !sbr->s_m[e][m]) * sbr->q_m[e][m] * sbr->q_m[e][m];
             }
             gain_boost = sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1]));
-            gain_boost = FFMIN(1.584893192f, gain_boost);
+            gain_boost = FFMINF(1.584893192f, gain_boost);
             for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
                 sbr->gain[e][m] *= gain_boost;
                 sbr->q_m[e][m]  *= gain_boost;
diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c
index 9fae44d9a5c..2c3c723858c 100644
--- a/libavcodec/aacsbr_template.c
+++ b/libavcodec/aacsbr_template.c
@@ -250,7 +250,7 @@ static int array_min_int16(const int16_t *array, int nel)
 {
     int i, min = array[0];
     for (i = 1; i < nel; i++)
-        min = FFMIN(array[i], min);
+        min = FFMINI(array[i], min);
     return min;
 }
 
@@ -455,7 +455,7 @@ static int sbr_make_f_master(AACDecContext *ac, SpectralBandReplication *sbr,
             if (vdk1_min < vdk0_max) {
                 int change;
                 AV_QSORT(vk1 + 1, num_bands_1, int16_t, qsort_comparison_function_int16);
-                change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1);
+                change = FFMINI(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1);
                 vk1[1]           += change;
                 vk1[num_bands_1] -= change;
             }
diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c
index 9a171234f65..ecc3dfcd249 100644
--- a/libavcodec/aarch64/vvc/dsp_init.c
+++ b/libavcodec/aarch64/vvc/dsp_init.c
@@ -92,7 +92,7 @@ static void vvc_w_avg_ ## bit_depth(uint8_t *dst, ptrdiff_t dst_stride, \
     const int16_t *src0, const int16_t *src1, int width, int height, \
     int denom, int w0, int w1, int o0, int o1) \
 { \
-    int shift = denom + FFMAX(3, 15 - bit_depth); \
+    int shift = denom + FFMAXI(3, 15 - bit_depth); \
     int offset = ((o0 + o1) * (1 << (bit_depth - 8)) + 1) * (1 << (shift - 1)); \
     uintptr_t w0_w1 = ((uintptr_t)w0 << 32) | (uint32_t)w1; \
     uintptr_t offset_shift = ((uintptr_t)offset << 32) | (uint32_t)shift; \
diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c
index c8e15772b14..3b14863ee84 100644
--- a/libavcodec/aasc.c
+++ b/libavcodec/aasc.c
@@ -52,7 +52,7 @@ static av_cold int aasc_decode_init(AVCodecContext *avctx)
         avctx->pix_fmt = AV_PIX_FMT_PAL8;
 
         ptr = avctx->extradata;
-        s->palette_size = FFMIN(avctx->extradata_size, AVPALETTE_SIZE);
+        s->palette_size = FFMINI(avctx->extradata_size, AVPALETTE_SIZE);
         for (i = 0; i < s->palette_size / 4; i++) {
             s->palette[i] = 0xFFU << 24 | AV_RL32(ptr);
             ptr += 4;
diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c
index 60491d1a7ae..7a27085fae2 100644
--- a/libavcodec/ac3.c
+++ b/libavcodec/ac3.c
@@ -156,7 +156,7 @@ static inline int calc_lowcomp1(int a, int b0, int b1, int c)
     if ((b0 + 256) == b1) {
         a = c;
     } else if (b0 > b1) {
-        a = FFMAX(a - 64, 0);
+        a = FFMAXI(a - 64, 0);
     }
     return a;
 }
@@ -168,7 +168,7 @@ static inline int calc_lowcomp(int a, int b0, int b1, int bin)
     } else if (bin < 20) {
         return calc_lowcomp1(a, b0, b1, 320);
     } else {
-        return FFMAX(a - 128, 0);
+        return FFMAXI(a - 128, 0);
     }
 }
 
@@ -187,11 +187,11 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
     band = ff_ac3_bin_to_band_tab[start];
     do {
         int v = psd[bin++];
-        int band_end = FFMIN(ff_ac3_band_start_tab[band+1], end);
+        int band_end = FFMINI(ff_ac3_band_start_tab[band+1], end);
         for (; bin < band_end; bin++) {
-            int max = FFMAX(v, psd[bin]);
+            int max = FFMAXI(v, psd[bin]);
             /* logadd */
-            int adr = FFMIN(max - ((v + psd[bin] + 1) >> 1), 255);
+            int adr = FFMINI(max - ((v + psd[bin] + 1) >> 1), 255);
             v = max + ac3_log_add_tab[adr];
         }
         band_psd[band++] = v;
@@ -237,13 +237,13 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
             }
         }
 
-        end1 = FFMIN(band_end, 22);
+        end1 = FFMINI(band_end, 22);
         for (band = begin; band < end1; band++) {
             if (!(is_lfe && band == 6))
                 lowcomp = calc_lowcomp(lowcomp, band_psd[band], band_psd[band+1], band);
-            fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
-            slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
-            excite[band] = FFMAX(fastleak - lowcomp, slowleak);
+            fastleak = FFMAXI(fastleak - s->fast_decay, band_psd[band] - fast_gain);
+            slowleak = FFMAXI(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
+            excite[band] = FFMAXI(fastleak - lowcomp, slowleak);
         }
         begin = 22;
     } else {
@@ -254,9 +254,9 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
     }
 
     for (band = begin; band < band_end; band++) {
-        fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
-        slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
-        excite[band] = FFMAX(fastleak, slowleak);
+        fastleak = FFMAXI(fastleak - s->fast_decay, band_psd[band] - fast_gain);
+        slowleak = FFMAXI(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
+        excite[band] = FFMAXI(fastleak, slowleak);
     }
 
     /* compute masking curve */
@@ -266,7 +266,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
         if (tmp > 0) {
             excite[band] += tmp >> 2;
         }
-        mask[band] = FFMAX(ac3_hearing_threshold_tab[band >> s->sr_shift][s->sr_code], excite[band]);
+        mask[band] = FFMAXI(ac3_hearing_threshold_tab[band >> s->sr_shift][s->sr_code], excite[band]);
     }
 
     /* delta bit allocation */
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 69989690dd1..85a3a59fd4d 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -126,7 +126,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
         }
         hdr->lfe_on = get_bits1(gbc);
 
-        hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8;
+        hdr->sr_shift = FFMAXI(hdr->bitstream_id, 8) - 8;
         hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift;
         hdr->bit_rate = (ff_ac3_bitrate_tab[hdr->ac3_bit_rate_code] * 1000) >> hdr->sr_shift;
         hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 49b170c2350..0f63bf99b1c 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -703,11 +703,11 @@ static void do_rematrixing(AC3DecodeContext *s)
     int bnd, i;
     int end, bndend;
 
-    end = FFMIN(s->end_freq[1], s->end_freq[2]);
+    end = FFMINI(s->end_freq[1], s->end_freq[2]);
 
     for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++) {
         if (s->rematrixing_flags[bnd]) {
-            bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd + 1]);
+            bndend = FFMINI(end, ff_ac3_rematrix_band_tab[bnd + 1]);
             for (i = ff_ac3_rematrix_band_tab[bnd]; i < bndend; i++) {
                 int tmp0 = s->fixed_coeffs[1][i];
                 s->fixed_coeffs[1][i] += s->fixed_coeffs[2][i];
@@ -1268,7 +1268,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk, int offset)
             s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)];
             s->bit_alloc_params.floor  = ff_ac3_floor_tab[get_bits(gbc, 3)];
             for (ch = !cpl_in_use; ch <= s->channels; ch++)
-                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
+                bit_alloc_stages[ch] = FFMAXI(bit_alloc_stages[ch], 2);
         } else if (!blk) {
             av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "
                    "be present in block 0\n");
@@ -1288,7 +1288,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk, int offset)
                     snr = (csnr + get_bits(gbc, 4)) << 2;
                 /* run at least last bit allocation stage if snr offset changes */
                 if (blk && s->snr_offset[ch] != snr) {
-                    bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 1);
+                    bit_alloc_stages[ch] = FFMAXI(bit_alloc_stages[ch], 1);
                 }
                 s->snr_offset[ch] = snr;
 
@@ -1298,7 +1298,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk, int offset)
                     s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];
                     /* run last 2 bit allocation stages if fast gain changes */
                     if (blk && prev != s->fast_gain[ch])
-                        bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
+                        bit_alloc_stages[ch] = FFMAXI(bit_alloc_stages[ch], 2);
                 }
             }
         } else if (!s->eac3 && !blk) {
@@ -1314,7 +1314,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk, int offset)
             s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];
             /* run last 2 bit allocation stages if fast gain changes */
             if (blk && prev != s->fast_gain[ch])
-                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
+                bit_alloc_stages[ch] = FFMAXI(bit_alloc_stages[ch], 2);
         }
     } else if (s->eac3 && !blk) {
         for (ch = !cpl_in_use; ch <= s->channels; ch++)
@@ -1335,7 +1335,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk, int offset)
                coupling leak changes */
             if (blk && (fl != s->bit_alloc_params.cpl_fast_leak ||
                 sl != s->bit_alloc_params.cpl_slow_leak)) {
-                bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2);
+                bit_alloc_stages[CPL_CH] = FFMAXI(bit_alloc_stages[CPL_CH], 2);
             }
             s->bit_alloc_params.cpl_fast_leak = fl;
             s->bit_alloc_params.cpl_slow_leak = sl;
@@ -1356,7 +1356,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk, int offset)
                 av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
                 return AVERROR_INVALIDDATA;
             }
-            bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
+            bit_alloc_stages[ch] = FFMAXI(bit_alloc_stages[ch], 2);
         }
         /* channel delta offset, len and bit allocation */
         for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
@@ -1368,7 +1368,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk, int offset)
                     s->dba_values[ch][seg]  = get_bits(gbc, 3);
                 }
                 /* run last 2 bit allocation stages if new dba values */
-                bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
+                bit_alloc_stages[ch] = FFMAXI(bit_alloc_stages[ch], 2);
             }
         }
     } else if (blk == 0) {
@@ -1527,17 +1527,17 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame,
        of the buffer, which can be caused by a damaged input stream. */
     if (buf_size >= 2 && AV_RB16(buf) == 0x770B) {
         // seems to be byte-swapped AC-3
-        int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;
+        int cnt = FFMINI(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;
         s->bdsp.bswap16_buf((uint16_t *) s->input_buffer,
                             (const uint16_t *) buf, cnt);
     } else
-        memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
+        memcpy(s->input_buffer, buf, FFMINI(buf_size, AC3_FRAME_BUFFER_SIZE));
 
     /* if consistent noise generation is enabled, seed the linear feedback generator
      * with the contents of the AC-3 frame so that the noise is identical across
      * decodes given the same AC-3 frame data, for use with non-linear edititing software. */
     if (s->consistent_noise_generation)
-        av_lfg_init_from_data(&s->dith_state, s->input_buffer, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
+        av_lfg_init_from_data(&s->dith_state, s->input_buffer, FFMINI(buf_size, AC3_FRAME_BUFFER_SIZE));
 
     buf = s->input_buffer;
 dependent_frame:
@@ -1601,7 +1601,7 @@ dependent_frame:
     if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT && !got_independent_frame) {
         av_log(avctx, AV_LOG_WARNING, "Ignoring dependent frame without independent frame.\n");
         *got_frame_ptr = 0;
-        return FFMIN(full_buf_size, s->frame_size);
+        return FFMINI(full_buf_size, s->frame_size);
     }
 
     /* channel config */
@@ -1875,9 +1875,9 @@ skip:
     *got_frame_ptr = 1;
 
     if (!s->superframe_size)
-        return FFMIN(full_buf_size, s->frame_size + skip);
+        return FFMINI(full_buf_size, s->frame_size + skip);
 
-    return FFMIN(full_buf_size, s->superframe_size + skip);
+    return FFMINI(full_buf_size, s->superframe_size + skip);
 }
 
 /**
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 730fa70fff4..cb18bf5df3a 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -86,9 +86,9 @@ static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
     bin  = start;
     band = ff_ac3_bin_to_band_tab[start];
     do {
-        int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor;
+        int m = (FFMAXI(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor;
         band_end = ff_ac3_band_start_tab[++band];
-        band_end = FFMIN(band_end, end);
+        band_end = FFMINI(band_end, end);
 
         for (; bin < band_end; bin++) {
             int address = av_clip_uintp2((psd[bin] - m) >> 5, 6);
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index a1783577c5a..d3eebdcabb4 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -593,11 +593,11 @@ static void ac3_apply_rematrixing(AC3EncodeContext *s)
         AC3Block *block = &s->blocks[blk];
         if (block->new_rematrixing_strategy)
             flags = block->rematrixing_flags;
-        nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]);
+        nb_coefs = FFMINI(block->end_freq[1], block->end_freq[2]);
         for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) {
             if (flags[bnd]) {
                 start = ff_ac3_rematrix_band_tab[bnd];
-                end   = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
+                end   = FFMINI(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
                 for (i = start; i < end; i++) {
                     int32_t lt = block->fixed_coef[1][i];
                     int32_t rt = block->fixed_coef[2][i];
@@ -768,10 +768,10 @@ static void encode_exponents_blk_ch(uint8_t *exp, int nb_exps, int exp_strategy,
     /* decrease the delta between each groups to within 2 so that they can be
        differentially encoded */
     for (i = 1; i <= nb_groups; i++)
-        exp[i] = FFMIN(exp[i], exp[i-1] + 2);
+        exp[i] = FFMINI(exp[i], exp[i-1] + 2);
     i--;
     while (--i >= 0)
-        exp[i] = FFMIN(exp[i], exp[i+1] + 2);
+        exp[i] = FFMINI(exp[i], exp[i+1] + 2);
 
     if (cpl)
         exp[-1] = exp[0] & ~1;
@@ -1334,7 +1334,7 @@ static void count_mantissa_bits_update_ch(AC3EncodeContext *s, int ch,
             continue;
         s->ac3dsp.update_bap_counts(mant_cnt[blk],
                                     s->ref_bap[ch][blk] + start,
-                                    FFMIN(end, block->end_freq[ch]) - start);
+                                    FFMINI(end, block->end_freq[ch]) - start);
     }
 }
 
@@ -2387,7 +2387,7 @@ static av_cold void set_bandwidth(AC3EncodeContext *s)
         uint8_t *cpl_band_sizes = s->cpl_band_sizes;
 
         cpl_end_band   = s->bandwidth_code / 4 + 3;
-        cpl_start_band = av_clip(cpl_start, 0, FFMIN(cpl_end_band-1, 15));
+        cpl_start_band = av_clip(cpl_start, 0, FFMINI(cpl_end_band-1, 15));
 
         s->num_cpl_subbands = cpl_end_band - cpl_start_band;
 
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 42530b0ea10..a147181dec3 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -59,9 +59,9 @@ static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
         return 1048576;
     } else {
         uint64_t coord   = energy_ch / (energy_cpl >> 24);
-        uint32_t coord32 = FFMIN(coord, 1073741824);
+        uint32_t coord32 = FFMINI(coord, 1073741824);
         coord32          = ff_sqrt(coord32) << 9;
-        return FFMIN(coord32, COEF_MAX);
+        return FFMINI(coord32, COEF_MAX);
     }
 }
 
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index 0ae7ddd7eb1..babc287624a 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -65,7 +65,7 @@ static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
     float coord = 0.125;
     if (energy_cpl > 0)
         coord *= sqrtf(energy_ch / energy_cpl);
-    return FFMIN(coord, COEF_MAX);
+    return FFMIND(coord, COEF_MAX);
 }
 
 static void sum_square_butterfly(AC3EncodeContext *s, float sum[4],
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 049666fdca4..c73a0622cde 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -106,7 +106,7 @@ static void apply_channel_coupling(AC3EncodeContext *s)
         note: coupling start bin % 4 will always be 1 */
     cpl_start     = s->start_freq[CPL_CH] - 1;
     num_cpl_coefs = FFALIGN(s->num_cpl_subbands * 12 + 1, 32);
-    cpl_start     = FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
+    cpl_start     = FFMINI(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
 
     /* calculate coupling channel from fbw channels */
     for (blk = 0; blk < s->num_blocks; blk++) {
@@ -260,11 +260,11 @@ static void apply_channel_coupling(AC3EncodeContext *s)
             min_exp = max_exp = block->cpl_coord_exp[ch][0];
             for (bnd = 1; bnd < s->num_cpl_bands; bnd++) {
                 int exp = block->cpl_coord_exp[ch][bnd];
-                min_exp = FFMIN(exp, min_exp);
-                max_exp = FFMAX(exp, max_exp);
+                min_exp = FFMINI(exp, min_exp);
+                max_exp = FFMAXI(exp, max_exp);
             }
             master_exp = ((max_exp - 15) + 2) / 3;
-            master_exp = FFMAX(master_exp, 0);
+            master_exp = FFMAXI(master_exp, 0);
             while (min_exp < master_exp * 3)
                 master_exp--;
             for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
@@ -315,7 +315,7 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
             if (blk && block->num_rematrixing_bands != block0->num_rematrixing_bands)
                 block->new_rematrixing_strategy = 1;
         }
-        nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]);
+        nb_coefs = FFMINI(block->end_freq[1], block->end_freq[2]);
 
         if (!s->rematrixing_enabled) {
             block0 = block;
@@ -325,13 +325,13 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
         for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) {
             /* calculate sum of squared coeffs for one band in one block */
             int start = ff_ac3_rematrix_band_tab[bnd];
-            int end   = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
+            int end   = FFMINI(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
             CoefSumType sum[4];
             sum_square_butterfly(s, sum, block->mdct_coef[1] + start,
                                  block->mdct_coef[2] + start, end - start);
 
             /* compare sums to determine if rematrixing will be used for this band */
-            if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))
+            if (FFMINI(sum[2], sum[3]) < FFMINI(sum[0], sum[1]))
                 block->rematrixing_flags[bnd] = 1;
             else
                 block->rematrixing_flags[bnd] = 0;
diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c
index 65f659cb2ec..aa741f50a70 100644
--- a/libavcodec/acelp_pitch_delay.c
+++ b/libavcodec/acelp_pitch_delay.c
@@ -43,7 +43,7 @@ void ff_acelp_update_past_gain(
     }
 
     if(erasure)
-        quant_energy[0] = FFMAX(avg_gain >> log2_ma_pred_order, -10240) - 4096; // -10 and -4 in (5.10)
+        quant_energy[0] = FFMAXI(avg_gain >> log2_ma_pred_order, -10240) - 4096; // -10 and -4 in (5.10)
     else
         quant_energy[0] = (6165 * ((ff_log2_q15(gain_corr_factor) >> 2) - (13 << 13))) >> 13;
 }
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 622cf54b40e..6f016a1a848 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -914,7 +914,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
         bytestream2_skip(gb, 4);
         has_coded_samples  = 1;
         *coded_samples     = bytestream2_get_le32u(gb);
-        nb_samples         = FFMIN((buf_size - 8) * 2, *coded_samples);
+        nb_samples         = FFMINI((buf_size - 8) * 2, *coded_samples);
         bytestream2_seek(gb, -8, SEEK_CUR);
         break;
     case AV_CODEC_ID_ADPCM_EA:
@@ -960,26 +960,26 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
         break;
     case AV_CODEC_ID_ADPCM_IMA_DK3:
         if (avctx->block_align > 0)
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
         break;
     case AV_CODEC_ID_ADPCM_IMA_DK4:
         if (avctx->block_align > 0)
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         if (buf_size < 4 * ch)
             return AVERROR_INVALIDDATA;
         nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
         break;
     case AV_CODEC_ID_ADPCM_IMA_RAD:
         if (avctx->block_align > 0)
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         nb_samples = (buf_size - 4 * ch) * 2 / ch;
         break;
     CASE(ADPCM_IMA_WAV,
         int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
         int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
         if (avctx->block_align > 0)
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         if (buf_size < 4 * ch)
             return AVERROR_INVALIDDATA;
         nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
@@ -988,19 +988,19 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
         int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
         int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
         if (avctx->block_align > 0)
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         if (buf_size < 4 * ch)
             return AVERROR_INVALIDDATA;
         nb_samples = (buf_size - 4 * ch) / (bsize * ch) * bsamples + 1;
         ) /* End of CASE */
     case AV_CODEC_ID_ADPCM_MS:
         if (avctx->block_align > 0)
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         nb_samples = (buf_size - 6 * ch) * 2 / ch;
         break;
     case AV_CODEC_ID_ADPCM_MTAF:
         if (avctx->block_align > 0)
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         nb_samples = (buf_size - 16 * (ch / 2)) * 2 / ch;
         break;
     case AV_CODEC_ID_ADPCM_SBPRO_2:
@@ -1856,7 +1856,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
                 count = count1;
             } else if (count != count1) {
                 av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n");
-                count = FFMAX(count, count1);
+                count = FFMAXI(count, count1);
             }
 
             if (avctx->codec->id != AV_CODEC_ID_ADPCM_EA_R1) {
@@ -2225,8 +2225,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         }
         ) /* End of CASE */
     CASE(ADPCM_PSX,
-        for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * channels); block++) {
-            int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * channels) / (16 * channels);
+        for (int block = 0; block < avpkt->size / FFMAXI(avctx->block_align, 16 * channels); block++) {
+            int nb_samples_per_block = 28 * FFMAXI(avctx->block_align, 16 * channels) / (16 * channels);
             for (int channel = 0; channel < channels; channel++) {
                 samples = samples_p[channel] + block * nb_samples_per_block;
                 av_assert0((block + 1) * nb_samples_per_block <= nb_samples);
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 96a053351db..7886ddfa28a 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -232,7 +232,7 @@ static inline uint8_t adpcm_ima_compress_sample(ADPCMChannelStatus *c,
                                                 int16_t sample)
 {
     int delta  = sample - c->prev_sample;
-    int nibble = FFMIN(7, abs(delta) * 4 /
+    int nibble = FFMINI(7, abs(delta) * 4 /
                        ff_adpcm_step_table[c->step_index]) + (delta < 0) * 8;
     c->prev_sample += ((ff_adpcm_step_table[c->step_index] *
                         ff_adpcm_yamaha_difflookup[nibble]) / 8);
@@ -247,7 +247,7 @@ static inline uint8_t adpcm_ima_alp_compress_sample(ADPCMChannelStatus *c, int16
     const int step   = ff_adpcm_step_table[c->step_index];
     const int sign   = (delta < 0) * 8;
 
-    int nibble = FFMIN(abs(delta) * 4 / step, 7);
+    int nibble = FFMINI(abs(delta) * 4 / step, 7);
     int diff   = (step * nibble) >> 2;
     if (sign)
         diff = -diff;
@@ -338,7 +338,7 @@ static inline uint8_t adpcm_yamaha_compress_sample(ADPCMChannelStatus *c,
 
     delta = sample - c->predictor;
 
-    nibble = FFMIN(7, abs(delta) * 4 / c->step) + (delta < 0) * 8;
+    nibble = FFMINI(7, abs(delta) * 4 / c->step) + (delta < 0) * 8;
 
     c->predictor += ((c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8);
     c->predictor = av_clip_int16(c->predictor);
@@ -474,7 +474,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx,
                         pos = parent;\
                     }\
                     next_##NAME:;
-                    STORE_NODE(ms, FFMAX(16,
+                    STORE_NODE(ms, FFMAXI(16,
                                (ff_adpcm_AdaptationTable[nibble] * step) >> 8));
                 }
             } else if (version == AV_CODEC_ID_ADPCM_IMA_WAV ||
diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index fdf896d61a0..96c7735d392 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -191,7 +191,7 @@ static int decode_intra_blocks(AGMContext *s, GetBitContext *gb,
             if (*skip > 0) {
                 int rskip;
 
-                rskip = FFMIN(*skip, s->blocks_w - j);
+                rskip = FFMINI(*skip, s->blocks_w - j);
                 j += rskip;
                 if (i == 0) {
                     for (int k = 0; k < rskip; k++)
@@ -234,7 +234,7 @@ static int decode_inter_blocks(AGMContext *s, GetBitContext *gb,
             if (*skip > 0) {
                 int rskip;
 
-                rskip = FFMIN(*skip, s->blocks_w - j);
+                rskip = FFMINI(*skip, s->blocks_w - j);
                 j += rskip;
                 block += rskip * 64;
                 *skip -= rskip;
@@ -277,7 +277,7 @@ static int decode_intra_block(AGMContext *s, GetBitContext *gb,
         if (*skip > 0) {
             int rskip;
 
-            rskip = FFMIN(*skip, 64 - i);
+            rskip = FFMINI(*skip, 64 - i);
             i += rskip;
             *skip -= rskip;
         } else {
@@ -356,7 +356,7 @@ static int decode_inter_block(AGMContext *s, GetBitContext *gb,
         if (*skip > 0) {
             int rskip;
 
-            rskip = FFMIN(*skip, 64 - i);
+            rskip = FFMINI(*skip, 64 - i);
             i += rskip;
             *skip -= rskip;
         } else {
@@ -522,25 +522,25 @@ static void compute_quant_matrix(AGMContext *s, double qscale)
     if (!s->key_frame && (s->flags & 2)) {
         if (qscale >= 0.0) {
             for (int i = 0; i < 64; i++) {
-                luma[i]   = FFMAX(1, 16 * f);
-                chroma[i] = FFMAX(1, 16 * f);
+                luma[i]   = FFMAXD(1, 16 * f);
+                chroma[i] = FFMAXD(1, 16 * f);
             }
         } else {
             for (int i = 0; i < 64; i++) {
-                luma[i]   = FFMAX(1, 16 - qscale * 32);
-                chroma[i] = FFMAX(1, 16 - qscale * 32);
+                luma[i]   = FFMAXD(1, 16 - qscale * 32);
+                chroma[i] = FFMAXD(1, 16 - qscale * 32);
             }
         }
     } else {
         if (qscale >= 0.0) {
             for (int i = 0; i < 64; i++) {
-                luma[i]   = FFMAX(1, ff_mjpeg_std_luminance_quant_tbl  [(i & 7) * 8 + (i >> 3)] * f);
-                chroma[i] = FFMAX(1, ff_mjpeg_std_chrominance_quant_tbl[(i & 7) * 8 + (i >> 3)] * f);
+                luma[i]   = FFMAXD(1, ff_mjpeg_std_luminance_quant_tbl  [(i & 7) * 8 + (i >> 3)] * f);
+                chroma[i] = FFMAXD(1, ff_mjpeg_std_chrominance_quant_tbl[(i & 7) * 8 + (i >> 3)] * f);
             }
         } else {
             for (int i = 0; i < 64; i++) {
-                luma[i]   = FFMAX(1, 255.0 - (255 - ff_mjpeg_std_luminance_quant_tbl  [(i & 7) * 8 + (i >> 3)]) * f);
-                chroma[i] = FFMAX(1, 255.0 - (255 - ff_mjpeg_std_chrominance_quant_tbl[(i & 7) * 8 + (i >> 3)]) * f);
+                luma[i]   = FFMAXD(1, 255.0 - (255 - ff_mjpeg_std_luminance_quant_tbl  [(i & 7) * 8 + (i >> 3)]) * f);
+                chroma[i] = FFMAXD(1, 255.0 - (255 - ff_mjpeg_std_chrominance_quant_tbl[(i & 7) * 8 + (i >> 3)]) * f);
             }
         }
     }
diff --git a/libavcodec/aic.c b/libavcodec/aic.c
index e12d689c478..e3b516d3b74 100644
--- a/libavcodec/aic.c
+++ b/libavcodec/aic.c
@@ -312,7 +312,7 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y,
 {
     GetBitContext gb;
     int ret, i, mb, blk;
-    int slice_width = FFMIN(ctx->slice_width, ctx->mb_width - mb_x);
+    int slice_width = FFMINI(ctx->slice_width, ctx->mb_width - mb_x);
     int last_row = mb_y && mb_y == ctx->mb_height - 1;
     int y_pos, c_pos;
     uint8_t *Y, *C[2];
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index f91288e97c8..4c91f85b3ad 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -127,7 +127,7 @@ static int rice_decompress(ALACContext *alac, int32_t *output_buffer,
 
         /* calculate rice param and decode next value */
         k = av_log2((history >> 9) + 3);
-        k = FFMIN(k, alac->rice_limit);
+        k = FFMINI(k, alac->rice_limit);
         x = decode_scalar(gb, k, bps);
         x += sign_modifier;
         sign_modifier = 0;
@@ -146,7 +146,7 @@ static int rice_decompress(ALACContext *alac, int32_t *output_buffer,
 
             /* calculate rice param and decode block size */
             k = 7 - av_log2(history) + ((history + 16) >> 6);
-            k = FFMIN(k, alac->rice_limit);
+            k = FFMINI(k, alac->rice_limit);
             block_size = decode_scalar(gb, k, 16);
 
             if (block_size > 0) {
@@ -481,7 +481,7 @@ static av_cold int alac_decode_close(AVCodecContext *avctx)
     ALACContext *alac = avctx->priv_data;
 
     int ch;
-    for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
+    for (ch = 0; ch < FFMINI(alac->channels, 2); ch++) {
         av_freep(&alac->predict_error_buffer[ch]);
         if (!alac->direct_output)
             av_freep(&alac->output_samples_buffer[ch]);
@@ -503,7 +503,7 @@ static int allocate_buffers(ALACContext *alac)
         alac->extra_bits_buffer[ch]     = NULL;
     }
 
-    for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
+    for (ch = 0; ch < FFMINI(alac->channels, 2); ch++) {
         if (!(alac->predict_error_buffer[ch] = av_malloc(buf_size)))
             return AVERROR(ENOMEM);
 
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 474200fee58..8c7ca5527b4 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -110,7 +110,7 @@ static void encode_scalar(AlacEncodeContext *s, int x,
 {
     int divisor, q, r;
 
-    k = FFMIN(k, s->rc.k_modifier);
+    k = FFMINI(k, s->rc.k_modifier);
     divisor = (1<<k) - 1;
     q = x / divisor;
     r = x % divisor;
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 734eec8bf87..a6b6a2118d5 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -744,7 +744,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
                 add_base = 1;
 
                 // read coefficient 0 to 19
-                k_max = FFMIN(opt_order, 20);
+                k_max = FFMINI(opt_order, 20);
                 for (k = 0; k < k_max; k++) {
                     int rice_param = parcor_rice_table[sconf->coef_table][k][1];
                     int offset     = parcor_rice_table[sconf->coef_table][k][0];
@@ -758,7 +758,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
                 }
 
                 // read coefficients 20 to 126
-                k_max = FFMIN(opt_order, 127);
+                k_max = FFMINI(opt_order, 127);
                 for (; k < k_max; k++)
                     quant_cof[k] = decode_rice(gb, 2) + (k & 1);
 
@@ -800,13 +800,13 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
             bd->ltp_gain[4]   = decode_rice(gb, 1) * 8;
 
             *bd->ltp_lag      = get_bits(gb, ctx->ltp_lag_length);
-            *bd->ltp_lag     += FFMAX(4, opt_order + 1);
+            *bd->ltp_lag     += FFMAXI(4, opt_order + 1);
         }
     }
 
     // read first value and residuals in case of a random access block
     if (bd->ra_block) {
-        start = FFMIN(opt_order, 3);
+        start = FFMINI(opt_order, 3);
         av_assert0(sb_length <= sconf->frame_length);
         if (sb_length <= start) {
             // opt_order or sb_length may be corrupted, either way this is unsupported and not well defined in the specification
@@ -817,9 +817,9 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
         if (opt_order)
             bd->raw_samples[0] = decode_rice(gb, avctx->bits_per_raw_sample - 4);
         if (opt_order > 1)
-            bd->raw_samples[1] = decode_rice(gb, FFMIN(s[0] + 3, ctx->s_max));
+            bd->raw_samples[1] = decode_rice(gb, FFMINI(s[0] + 3, ctx->s_max));
         if (opt_order > 2)
-            bd->raw_samples[2] = decode_rice(gb, FFMIN(s[0] + 1, ctx->s_max));
+            bd->raw_samples[2] = decode_rice(gb, FFMINI(s[0] + 1, ctx->s_max));
     }
 
     // read all residuals
@@ -930,9 +930,9 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
     if (*bd->use_ltp) {
         int ltp_smp;
 
-        for (ltp_smp = FFMAX(*bd->ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
+        for (ltp_smp = FFMAXI(*bd->ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
             int center = ltp_smp - *bd->ltp_lag;
-            int begin  = FFMAX(0, center - 2);
+            int begin  = FFMAXI(0, center - 2);
             int end    = center + 3;
             int tab    = 5 - (end - begin);
             int base;
@@ -948,7 +948,7 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
 
     // reconstruct all samples from residuals
     if (bd->ra_block) {
-        for (smp = 0; smp < FFMIN(opt_order, block_length); smp++) {
+        for (smp = 0; smp < FFMINI(opt_order, block_length); smp++) {
             y = 1 << 19;
 
             for (sb = 0; sb < smp; sb++)
@@ -1347,11 +1347,11 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
                 end   -= t;
             }
 
-            if (FFMIN(begin - 1, begin - 1 + t) < ctx->raw_buffer - master ||
-                FFMAX(end   + 1,   end + 1 + t) > ctx->raw_buffer + channels * channel_size - master) {
+            if (FFMINI(begin - 1, begin - 1 + t) < ctx->raw_buffer - master ||
+                FFMAXI(end   + 1,   end + 1 + t) > ctx->raw_buffer + channels * channel_size - master) {
                 av_log(ctx->avctx, AV_LOG_ERROR,
                        "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
-                       master + FFMIN(begin - 1, begin - 1 + t), master + FFMAX(end + 1,   end + 1 + t),
+                       master + FFMINI(begin - 1, begin - 1 + t), master + FFMAXI(end + 1,   end + 1 + t),
                        ctx->raw_buffer, ctx->raw_buffer + channels * channel_size);
                 return AVERROR_INVALIDDATA;
             }
@@ -1556,7 +1556,7 @@ static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame) {
                     } else {
                         nbits[i] = 23;
                     }
-                    nbits[i] = FFMIN(nbits[i], highest_byte*8);
+                    nbits[i] = FFMINI(nbits[i], highest_byte*8);
                 }
             }
 
@@ -1766,7 +1766,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
                 if ((ret = decode_block(ctx, &bd)) < 0)
                     return ret;
 
-                ctx->highest_decoded_channel = FFMAX(ctx->highest_decoded_channel, c);
+                ctx->highest_decoded_channel = FFMAXI(ctx->highest_decoded_channel, c);
             }
 
             memset(reverted_channels, 0, channels * sizeof(*reverted_channels));
@@ -1818,7 +1818,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     // the last frame to decode might have a different length
     if (sconf->samples != 0xFFFFFFFF)
-        ctx->cur_frame_length = FFMIN(sconf->samples - ctx->frame_id * (uint64_t) sconf->frame_length,
+        ctx->cur_frame_length = FFMINI(sconf->samples - ctx->frame_id * (uint64_t) sconf->frame_length,
                                       sconf->frame_length);
     else
         ctx->cur_frame_length = sconf->frame_length;
diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
index 822dc1297b8..3cbce4be9ec 100644
--- a/libavcodec/amrnbdec.c
+++ b/libavcodec/amrnbdec.c
@@ -565,7 +565,7 @@ static void pitch_sharpening(AMRContext *p, int subframe, enum Mode mode,
     // modes the pitch and codebook gains are jointly quantized (sec 5.8.2)
     // so the codebook gain cannot depend on the quantized pitch gain.
     if (mode == MODE_12k2)
-        p->beta = FFMIN(p->pitch_gain[4], 1.0);
+        p->beta = FFMIND(p->pitch_gain[4], 1.0);
 
     fixed_sparse->pitch_lag  = p->pitch_lag_int;
     fixed_sparse->pitch_fac  = p->beta;
@@ -819,8 +819,8 @@ static int synthesis(AMRContext *p, float *lpc,
         float pitch_factor =
             p->pitch_gain[4] *
             (p->cur_frame_mode == MODE_12k2 ?
-                0.25 * FFMIN(p->pitch_gain[4], 1.0) :
-                0.5  * FFMIN(p->pitch_gain[4], SHARP_MAX));
+                0.25 * FFMIND(p->pitch_gain[4], 1.0) :
+                0.5  * FFMIND(p->pitch_gain[4], SHARP_MAX));
 
         for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
             excitation[i] += pitch_factor * p->pitch_vector[i];
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 91fb870a640..cf88835acf7 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -716,7 +716,7 @@ static float stability_factor(const float *isf, const float *isf_past)
 
     // XXX: This part is not so clear from the reference code
     // the result is more accurate changing the "/ 256" to "* 512"
-    return FFMAX(0.0, 1.25 - acc * 0.8 * 512);
+    return FFMAXD(0.0, 1.25 - acc * 0.8 * 512);
 }
 
 /**
@@ -740,10 +740,10 @@ static float noise_enhancer(float fixed_gain, float *prev_tr_gain,
     // gain by 1.5dB were taken from the reference code, maybe it could
     // be simpler
     if (fixed_gain < *prev_tr_gain) {
-        g0 = FFMIN(*prev_tr_gain, fixed_gain + fixed_gain *
+        g0 = FFMINF(*prev_tr_gain, fixed_gain + fixed_gain *
                      (6226 * (1.0f / (1 << 15)))); // +1.5 dB
     } else
-        g0 = FFMAX(*prev_tr_gain, fixed_gain *
+        g0 = FFMAXF(*prev_tr_gain, fixed_gain *
                     (27536 * (1.0f / (1 << 15)))); // -1.5 dB
 
     *prev_tr_gain = g0; // update next frame threshold
@@ -976,7 +976,7 @@ static void extrapolate_isf(float isf[LP_ORDER_16k])
 
     /* Calculate an estimate for ISF(18) and scale ISF based on the error */
     est   = 7965 + (isf[2] - isf[3] - isf[4]) / 6.0;
-    scale = 0.5 * (FFMIN(est, 7600) - isf[LP_ORDER - 2]) /
+    scale = 0.5 * (FFMINF(est, 7600) - isf[LP_ORDER - 2]) /
             (isf[LP_ORDER_16k - 2] - isf[LP_ORDER - 2]);
 
     for (i = LP_ORDER - 1, j = 0; i < LP_ORDER_16k - 1; i++, j++)
diff --git a/libavcodec/anm.c b/libavcodec/anm.c
index 4aabe853b43..7a850b3f253 100644
--- a/libavcodec/anm.c
+++ b/libavcodec/anm.c
@@ -80,7 +80,7 @@ static inline int op(uint8_t **dst, const uint8_t *dst_end,
 {
     int remaining = width - *x;
     while(count > 0) {
-        int striplen = FFMIN(count, remaining);
+        int striplen = FFMINI(count, remaining);
         if (gb) {
             if (bytestream2_get_bytes_left(gb) < striplen)
                 goto exhausted;
diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c
index b58b72ef49c..832cd800216 100644
--- a/libavcodec/ansi.c
+++ b/libavcodec/ansi.c
@@ -195,16 +195,16 @@ static int execute_code(AVCodecContext * avctx, int c)
 
     switch(c) {
     case 'A': //Cursor Up
-        s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
+        s->y = FFMAXI(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
         break;
     case 'B': //Cursor Down
-        s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
+        s->y = FFMINI(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
         break;
     case 'C': //Cursor Right
-        s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width  - FONT_WIDTH);
+        s->x = FFMINI(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width  - FONT_WIDTH);
         break;
     case 'D': //Cursor Left
-        s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
+        s->x = FFMAXI(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
         break;
     case 'H': //Cursor Position
     case 'f': //Horizontal and Vertical Position
@@ -302,7 +302,7 @@ static int execute_code(AVCodecContext * avctx, int c)
             s->nb_args = 1;
             s->args[0] = 0;
         }
-        for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) {
+        for (i = 0; i < FFMINI(s->nb_args, MAX_NB_ARGS); i++) {
             int m = s->args[i];
             if (m == 0) {
                 s->attributes = 0;
@@ -312,7 +312,7 @@ static int execute_code(AVCodecContext * avctx, int c)
                 s->attributes |= 1 << (m - 1);
             } else if (m >= 30 && m <= 37) {
                 s->fg = ansi_to_cga[m - 30];
-            } else if (m == 38 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
+            } else if (m == 38 && i + 2 < FFMINI(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
                 int index = s->args[i + 2];
                 s->fg = index < 16 ? ansi_to_cga[index] : index;
                 i += 2;
@@ -320,7 +320,7 @@ static int execute_code(AVCodecContext * avctx, int c)
                 s->fg = ansi_to_cga[DEFAULT_FG_COLOR];
             } else if (m >= 40 && m <= 47) {
                 s->bg = ansi_to_cga[m - 40];
-            } else if (m == 48 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
+            } else if (m == 48 && i + 2 < FFMINI(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
                 int index = s->args[i + 2];
                 s->bg = index < 16 ? ansi_to_cga[index] : index;
                 i += 2;
@@ -386,7 +386,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
                 /* ignore */
                 break;
             case 0x08: //BS
-                s->x = FFMAX(s->x - 1, 0);
+                s->x = FFMAXI(s->x - 1, 0);
                 break;
             case 0x09: //HT
                 i = s->x / FONT_WIDTH;
@@ -425,7 +425,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
             case '0': case '1': case '2': case '3': case '4':
             case '5': case '6': case '7': case '8': case '9':
                 if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] < 6553)
-                    s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
+                    s->args[s->nb_args] = FFMAXI(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
                 break;
             case ';':
                 if (s->nb_args < MAX_NB_ARGS)
diff --git a/libavcodec/apac.c b/libavcodec/apac.c
index a092b1e372b..7d4826dd225 100644
--- a/libavcodec/apac.c
+++ b/libavcodec/apac.c
@@ -237,7 +237,7 @@ static int apac_decode(AVCodecContext *avctx, AVFrame *frame,
 end:
     nb_samples = frame->nb_samples;
     for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++)
-        nb_samples = FFMIN(av_audio_fifo_size(s->ch[ch].samples), nb_samples);
+        nb_samples = FFMINI(av_audio_fifo_size(s->ch[ch].samples), nb_samples);
 
     frame->nb_samples = nb_samples;
     for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 66346503551..8db30dbff6b 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -574,7 +574,7 @@ static inline int ape_decode_value_3990(APEContext *ctx, APERice *rice)
     unsigned int x, overflow, pivot;
     int base;
 
-    pivot = FFMAX(rice->ksum >> 5, 1);
+    pivot = FFMAXI(rice->ksum >> 5, 1);
 
     overflow = range_get_symbol(ctx, counts_3980, counts_diff_3980);
 
@@ -622,7 +622,7 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
     unsigned ksummax, ksummin;
 
     rice->ksum = 0;
-    for (i = 0; i < FFMIN(blockstodecode, 5); i++) {
+    for (i = 0; i < FFMINI(blockstodecode, 5); i++) {
         out[i] = get_rice_ook(&ctx->gb, 10);
         rice->ksum += out[i];
     }
@@ -633,7 +633,7 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
     rice->k = get_k(rice->ksum / 10);
     if (rice->k >= 24)
         return;
-    for (; i < FFMIN(blockstodecode, 64); i++) {
+    for (; i < FFMINI(blockstodecode, 64); i++) {
         out[i] = get_rice_ook(&ctx->gb, rice->k);
         rice->ksum += out[i];
         rice->k = get_k(rice->ksum / ((i + 1) * 2));
@@ -1287,7 +1287,7 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count)
                 int32_t left  = a1 - (unsigned)(a0 / 2);
                 int32_t right = left + (unsigned)a0;
 
-                if (FFMIN(FFNABS(left), FFNABS(right)) < -(1<<23)) {
+                if (FFMINI(FFNABS(left), FFNABS(right)) < -(1<<23)) {
                     ctx->interim_mode = !interim_mode;
                     av_log(ctx->avctx, AV_LOG_VERBOSE, "Interim mode: %d\n", ctx->interim_mode);
                     break;
@@ -1616,7 +1616,7 @@ static int ape_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         return avpkt->size;
     }
 
-    blockstodecode = FFMIN(s->blocks_per_loop, s->samples);
+    blockstodecode = FFMINI(s->blocks_per_loop, s->samples);
     // for old files coefficients were not interleaved,
     // so we need to decode all of them at once
     if (s->fileversion < 3930)
diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c
index ab024597333..38a0ae626e0 100644
--- a/libavcodec/aptxenc.c
+++ b/libavcodec/aptxenc.c
@@ -116,7 +116,7 @@ static void aptx_quantize_difference(Quantize *quantize,
     int64_t error;
 
     sample_difference_abs = FFABS(sample_difference);
-    sample_difference_abs = FFMIN(sample_difference_abs, (1 << 23) - 1);
+    sample_difference_abs = FFMINI(sample_difference_abs, (1 << 23) - 1);
 
     quantized_sample = aptx_bin_search(sample_difference_abs >> 4,
                                        quantization_factor,
diff --git a/libavcodec/apv_entropy.c b/libavcodec/apv_entropy.c
index 1cab88d547e..448781afa26 100644
--- a/libavcodec/apv_entropy.c
+++ b/libavcodec/apv_entropy.c
@@ -143,7 +143,7 @@ void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
                     ent->run[i] = value;
                     ent->offset[ent->count] = pos;
                     ++ent->count;
-                    k_run = FFMIN(value >> 2, 2);
+                    k_run = FFMINI(value >> 2, 2);
 
                     value = apv_read_vlc(&gbc, k_level, decode_lut);
                     sign = get_bits1(&gbc);
@@ -154,7 +154,7 @@ void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
                     ent->level[i] = sign ? -value : value;
                     ent->offset[ent->count] = pos;
                     ++ent->count;
-                    k_level = FFMIN(value >> 2, 4);
+                    k_level = FFMINI(value >> 2, 4);
                     if (i == 0)
                         ent->k_level_0 = k_level;
                 }
@@ -183,7 +183,7 @@ void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
                     ent->level[i] = sign ? -value : value;
                     ent->offset[ent->count] = pos;
                     ++ent->count;
-                    k_level = FFMIN(value >> 2, 4);
+                    k_level = FFMINI(value >> 2, 4);
                     if (i == 0)
                         ent->k_level_0 = k_level;
 
@@ -194,7 +194,7 @@ void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
                     ent->run[i] = value;
                     ent->offset[ent->count] = pos;
                     ++ent->count;
-                    k_run = FFMIN(value >> 2, 2);
+                    k_run = FFMINI(value >> 2, 2);
                 }
                 if (ent->count > 0 && ent->count < 4)
                     ent->offset[3] = ent->offset[ent->count - 1];
@@ -245,7 +245,7 @@ int ff_apv_entropy_decode_block(int16_t *restrict coeff,
         coeff[0] = dc_coeff;
 
         state->prev_dc   = dc_coeff;
-        state->prev_k_dc = FFMIN(abs_diff >> 1, 5);
+        state->prev_k_dc = FFMINI(abs_diff >> 1, 5);
     }
 
     // Repeatedly read 18 bits, look up the first half of them in either
@@ -297,7 +297,7 @@ int ff_apv_entropy_decode_block(int16_t *restrict coeff,
             scan_pos = run + 1;
             if (scan_pos >= 64)
                 goto end_of_block;
-            k_run = FFMIN(run >> 2, 2);
+            k_run = FFMINI(run >> 2, 2);
             goto first_level;
         } else {
             // One or more short codes starting with a run; if there is
@@ -386,7 +386,7 @@ int ff_apv_entropy_decode_block(int16_t *restrict coeff,
             }
             coeff[ff_zigzag_direct[scan_pos]] = level;
             ++scan_pos;
-            k_level = FFMIN(abs_level >> 2, 4);
+            k_level = FFMINI(abs_level >> 2, 4);
             state->prev_k_level = k_level;
             if (scan_pos >= 64)
                 goto end_of_block;
@@ -471,7 +471,7 @@ int ff_apv_entropy_decode_block(int16_t *restrict coeff,
             scan_pos += run;
             if (scan_pos >= 64)
                 goto end_of_block;
-            k_run = FFMIN(run >> 2, 2);
+            k_run = FFMINI(run >> 2, 2);
             goto next_is_level;
 
         } else {
@@ -556,7 +556,7 @@ int ff_apv_entropy_decode_block(int16_t *restrict coeff,
             }
             coeff[ff_zigzag_direct[scan_pos]] = level;
             ++scan_pos;
-            k_level = FFMIN(abs_level >> 2, 4);
+            k_level = FFMINI(abs_level >> 2, 4);
             if (scan_pos >= 64)
                 goto end_of_block;
             goto next_is_run;
diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c
index 46b0275e9a8..1074261f20c 100644
--- a/libavcodec/arbc.c
+++ b/libavcodec/arbc.c
@@ -102,7 +102,7 @@ static int fill_tileX(AVCodecContext *avctx, int tile_width, int tile_height,
                             AV_WB24(&frame->data[0][frame->linesize[0] * (h - (j + m)) + 3 * (k + n)], color);
                         }
                     }
-                    pixels_overwritten += FFMIN(step_h, avctx->height - j) * FFMIN(step_w, avctx->width - k);
+                    pixels_overwritten += FFMINI(step_h, avctx->height - j) * FFMINI(step_w, avctx->width - k);
                 }
                 mask = mask << 1;
             }
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index 883edd04686..f8a61cfb00a 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -262,8 +262,8 @@ static void handle_partial_mb(ASVEncContext *a, const uint8_t *const data[3],
             memset(a->block[i], 0, sizeof(a->block[i]));
             continue;
         }
-        width_avail  = FFMIN(width_avail,  8);
-        height_avail = FFMIN(height_avail, 8);
+        width_avail  = FFMINI(width_avail,  8);
+        height_avail = FFMINI(height_avail, 8);
 
         ptrdiff_t linesize = linesizes[desc->component];
         const uint8_t *src = data[desc->component] + desc->y_offset * linesize + desc->x_offset;
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index fe156fa4821..c9ca38f5879 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -384,7 +384,7 @@ static int decode_tonal_components(GetBitContext *gb,
 
                 max_coded_values = SAMPLES_PER_FRAME - cmp->pos;
                 coded_values     = coded_values_per_component + 1;
-                coded_values     = FFMIN(max_coded_values, coded_values);
+                coded_values     = FFMINI(max_coded_values, coded_values);
 
                 scale_factor = ff_atrac_sf_table[sf_index] *
                                inv_max_quant[quant_step_index];
@@ -455,7 +455,7 @@ static int add_tonal_components(float *spectrum, int num_components,
     float *input, *output;
 
     for (i = 0; i < num_components; i++) {
-        last_pos = FFMAX(components[i].pos + components[i].num_coefs, last_pos);
+        last_pos = FFMAXI(components[i].pos + components[i].num_coefs, last_pos);
         input    = components[i].coef;
         output   = &spectrum[components[i].pos];
 
@@ -618,7 +618,7 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
        spectral lines */
     num_bands = (subband_tab[num_subbands] - 1) >> 8;
     if (last_tonal >= 0)
-        num_bands = FFMAX((last_tonal + 256) >> 8, num_bands);
+        num_bands = FFMAXI((last_tonal + 256) >> 8, num_bands);
 
 
     /* Reconstruct time domain samples. */
diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c
index 9696a523be6..d2fe6eb440f 100644
--- a/libavcodec/atrac3plusdec.c
+++ b/libavcodec/atrac3plusdec.c
@@ -414,7 +414,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     *got_frame_ptr = 1;
 
-    return avctx->codec_id == AV_CODEC_ID_ATRAC3P ? FFMIN(avctx->block_align, avpkt->size) : avpkt->size;
+    return avctx->codec_id == AV_CODEC_ID_ATRAC3P ? FFMINI(avctx->block_align, avpkt->size) : avpkt->size;
 }
 
 const FFCodec ff_atrac3p_decoder = {
diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index e37f88500bb..340f4873dfc 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -161,7 +161,7 @@ static inline void calc_precision(ATRAC9Context *s, ATRAC9BlockData *b,
         const int delta = FFABS(c->scalefactors[i] - c->scalefactors[i - 1]) - 1;
         if (delta > 0) {
             const int neg = c->scalefactors[i - 1] > c->scalefactors[i];
-            c->precision_mask[i - neg] += FFMIN(delta, 5);
+            c->precision_mask[i - neg] += FFMINI(delta, 5);
         }
     }
 
@@ -190,7 +190,7 @@ static inline void calc_precision(ATRAC9Context *s, ATRAC9BlockData *b,
 
 
     for (int i = 0; i < b->q_unit_cnt; i++)
-        c->precision_coarse[i] = FFMAX(c->precision_coarse[i], 1);
+        c->precision_coarse[i] = FFMAXI(c->precision_coarse[i], 1);
 
     for (int i = 0; i < b->grad_boundary; i++)
         c->precision_coarse[i]++;
@@ -198,7 +198,7 @@ static inline void calc_precision(ATRAC9Context *s, ATRAC9BlockData *b,
     for (int i = 0; i < b->q_unit_cnt; i++) {
         c->precision_fine[i] = 0;
         if (c->precision_coarse[i] > 15) {
-            c->precision_fine[i] = FFMIN(c->precision_coarse[i], 30) - 15;
+            c->precision_fine[i] = FFMINI(c->precision_coarse[i], 30) - 15;
             c->precision_coarse[i] = 15;
         }
     }
@@ -310,7 +310,7 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b,
                                  b->q_unit_cnt_prev;
 
         const int len = get_bits(gb, 2) + 2;
-        const int unit_cnt = FFMIN(b->band_ext_q_unit, baseline_len);
+        const int unit_cnt = FFMINI(b->band_ext_q_unit, baseline_len);
         const VLCElem *tab = sf_vlc[1][len];
 
         for (int i = 0; i < unit_cnt; i++) {
@@ -331,7 +331,7 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b,
 
         const int base = get_bits(gb, 5) - (1 << (5 - 1));
         const int len = get_bits(gb, 2) + 1;
-        const int unit_cnt = FFMIN(b->band_ext_q_unit, baseline_len);
+        const int unit_cnt = FFMINI(b->band_ext_q_unit, baseline_len);
         const VLCElem *tab = sf_vlc[0][len];
 
         c->scalefactors[0] = get_bits(gb, len);
@@ -385,7 +385,7 @@ static inline void calc_codebook_idx(ATRAC9Context *s, ATRAC9BlockData *b,
         const int prev = c->scalefactors[i - 1];
         const int cur  = c->scalefactors[i    ];
         const int next = c->scalefactors[i + 1];
-        const int min  = FFMIN(prev, next);
+        const int min  = FFMINI(prev, next);
         if ((cur - min >= 3 || 2*cur - prev - next >= 3))
             c->codebookset[i] = 1;
     }
@@ -394,7 +394,7 @@ static inline void calc_codebook_idx(ATRAC9Context *s, ATRAC9BlockData *b,
     for (int i = 12; i < c->q_unit_cnt; i++) {
         const int cur = c->scalefactors[i];
         const int cnd = at9_q_unit_to_coeff_cnt[i] == 16;
-        const int min = FFMIN(c->scalefactors[i + 1], c->scalefactors[i - 1]);
+        const int min = FFMINI(c->scalefactors[i + 1], c->scalefactors[i - 1]);
         if (c->codebookset[i])
             continue;
 
@@ -524,7 +524,7 @@ static inline void fill_with_noise(ATRAC9Context *s, ATRAC9ChannelData *c,
         av_bmg_get(&s->lfg, tmp);
         c->coeffs[start + i + 0] = tmp[0];
         c->coeffs[start + i + 1] = tmp[1];
-        maxval = FFMAX(FFMAX(FFABS(tmp[0]), FFABS(tmp[1])), maxval);
+        maxval = FFMAXF(FFMAXD(FFABS(tmp[0]), FFABS(tmp[1])), maxval);
     }
     /* Normalize */
     for (int i = 0; i < count; i++)
@@ -549,7 +549,7 @@ static inline void apply_band_extension(ATRAC9Context *s, ATRAC9BlockData *b,
         b->q_unit_cnt,
         at9_tab_band_ext_group[b->q_unit_cnt - 13][0],
         at9_tab_band_ext_group[b->q_unit_cnt - 13][1],
-        FFMAX(g_units[2], 22),
+        FFMAXI(g_units[2], 22),
     };
 
     const int g_bins[4] = { /* A, B, C, total bins */
@@ -795,7 +795,7 @@ static int atrac9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     int ret;
     GetBitContext gb;
     ATRAC9Context *s = avctx->priv_data;
-    const int frames = FFMIN(avpkt->size / s->avg_frame_size, s->frame_count);
+    const int frames = FFMINI(avpkt->size / s->avg_frame_size, s->frame_count);
 
     frame->nb_samples = (1 << s->frame_log2) * frames;
     ret = ff_get_buffer(avctx, frame, 0);
diff --git a/libavcodec/audio_frame_queue.c b/libavcodec/audio_frame_queue.c
index 10b5d213929..40fb681caa7 100644
--- a/libavcodec/audio_frame_queue.c
+++ b/libavcodec/audio_frame_queue.c
@@ -89,7 +89,7 @@ void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts,
         *pts = ff_samples_to_time_base(afq->avctx, out_pts);
 
     for(i=0; nb_samples && i<afq->frame_count; i++){
-        int n= FFMIN(afq->frames[i].duration, nb_samples);
+        int n= FFMINI(afq->frames[i].duration, nb_samples);
         afq->frames[i].duration -= n;
         nb_samples              -= n;
         removed_samples         += n;
diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index d999e5e8a2f..53f46b04418 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -427,7 +427,7 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
                     bytestream2_skip(&gb, 13);
                     len = read_descr(&gb, &tag);
                     if (tag == MP4DecSpecificDescrTag) {
-                        len = FFMIN(gb.buffer_end - gb.buffer, len);
+                        len = FFMINI(gb.buffer_end - gb.buffer, len);
                         memmove(extradata, gb.buffer, len);
                         avctx->extradata_size = len;
                         break;
diff --git a/libavcodec/av1_parse.h b/libavcodec/av1_parse.h
index 2b8cce4835a..46b58d5a6d9 100644
--- a/libavcodec/av1_parse.h
+++ b/libavcodec/av1_parse.h
@@ -97,7 +97,7 @@ static inline int parse_obu_header(const uint8_t *buf, int buf_size,
     int ret, extension_flag, has_size_flag;
     int64_t size;
 
-    ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE));
+    ret = init_get_bits8(&gb, buf, FFMINI(buf_size, MAX_OBU_HEADER_SIZE));
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 8ff1bf394c5..d2e5fab3f07 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -304,9 +304,9 @@ static void skip_mode_params(AV1DecContext *s)
         return;
     } else if (backward_idx >= 0) {
         s->cur_frame.skip_mode_frame_idx[0] =
-            AV1_REF_FRAME_LAST + FFMIN(forward_idx, backward_idx);
+            AV1_REF_FRAME_LAST + FFMINI(forward_idx, backward_idx);
         s->cur_frame.skip_mode_frame_idx[1] =
-            AV1_REF_FRAME_LAST + FFMAX(forward_idx, backward_idx);
+            AV1_REF_FRAME_LAST + FFMAXI(forward_idx, backward_idx);
         return;
     }
 
@@ -326,9 +326,9 @@ static void skip_mode_params(AV1DecContext *s)
         return;
 
     s->cur_frame.skip_mode_frame_idx[0] =
-        AV1_REF_FRAME_LAST + FFMIN(forward_idx, second_forward_idx);
+        AV1_REF_FRAME_LAST + FFMINI(forward_idx, second_forward_idx);
     s->cur_frame.skip_mode_frame_idx[1] =
-        AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
+        AV1_REF_FRAME_LAST + FFMAXI(forward_idx, second_forward_idx);
 }
 
 static void coded_lossless_param(AV1DecContext *s)
diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 0d68ab1d00e..bb3a1c55d0f 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -118,7 +118,7 @@ static void parse_avs2_seq_header(AVCodecParserContext *s, const uint8_t *buf,
         ff_avs2_frame_rate_tab[frame_rate_code].num;
     avctx->framerate.den =
         ff_avs2_frame_rate_tab[frame_rate_code].den;
-    avctx->has_b_frames = FFMAX(avctx->has_b_frames, !low_delay);
+    avctx->has_b_frames = FFMAXI(avctx->has_b_frames, !low_delay);
 
     av_log(avctx, AV_LOG_DEBUG,
            "AVS2 parse seq HDR: profile %x, level %x, "
diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c
index 71278c7e2de..18e23c0b73a 100644
--- a/libavcodec/avs3_parser.c
+++ b/libavcodec/avs3_parser.c
@@ -116,7 +116,7 @@ static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
             skip_bits(&gb, 32);
 
             low_delay = get_bits(&gb, 1);
-            avctx->has_b_frames = FFMAX(avctx->has_b_frames, !low_delay);
+            avctx->has_b_frames = FFMAXI(avctx->has_b_frames, !low_delay);
 
             avctx->framerate.num = ff_avs3_frame_rate_tab[ratecode].num;
             avctx->framerate.den = ff_avs3_frame_rate_tab[ratecode].den;
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index 04fd90aa118..956cc26e7c6 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -521,7 +521,7 @@ static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b,
     *dst++ = v;
     len--;
     for (i = 0; i < len; i += 8) {
-        len2 = FFMIN(len - i, 8);
+        len2 = FFMINI(len - i, 8);
         if (dst_end - dst < len2)
             return AVERROR_INVALIDDATA;
         bsize = get_bits(gb, 4);
@@ -1047,7 +1047,7 @@ static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
         goto end;
     }
 
-    init_lengths(c, FFMAX(width, 8), bw);
+    init_lengths(c, FFMAXI(width, 8), bw);
     for (i = 0; i < BINK_NB_SRC; i++) {
         ret = read_bundle(gb, c, i);
         if (ret < 0)
diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 265f93a8222..92a6910461d 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -111,7 +111,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     s->frame_len     = 1 << frame_len_bits;
     s->overlap_len   = s->frame_len / 16;
-    s->block_size    = (s->frame_len - s->overlap_len) * FFMIN(MAX_CHANNELS, s->channels);
+    s->block_size    = (s->frame_len - s->overlap_len) * FFMINI(MAX_CHANNELS, s->channels);
     sample_rate_half = (sample_rate + 1LL) / 2;
     if (avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT)
         s->root = 2.0 / (sqrt(s->frame_len) * 32768.0);
@@ -199,7 +199,7 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct,
             return AVERROR_INVALIDDATA;
         for (i = 0; i < s->num_bands; i++) {
             int value = get_bits(gb, 8);
-            quant[i]  = s->quant_table[FFMIN(value, 95)];
+            quant[i]  = s->quant_table[FFMINI(value, 95)];
         }
 
         k = 0;
@@ -220,7 +220,7 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct,
                 }
             }
 
-            j = FFMIN(j, s->frame_len);
+            j = FFMINI(j, s->frame_len);
 
             width = get_bits(gb, 4);
             if (width == 0) {
@@ -332,7 +332,7 @@ again:
 
     if (decode_block(s, (float **)frame->extended_data,
                      avctx->codec->id == AV_CODEC_ID_BINKAUDIO_DCT,
-                     FFMIN(MAX_CHANNELS, s->channels - s->ch_offset), s->ch_offset)) {
+                     FFMINI(MAX_CHANNELS, s->channels - s->ch_offset), s->ch_offset)) {
         av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n");
         ret = AVERROR_INVALIDDATA;
         goto fail;
@@ -349,7 +349,7 @@ again:
         goto again;
     }
 
-    frame->nb_samples = s->block_size / FFMIN(avctx->ch_layout.nb_channels, MAX_CHANNELS);
+    frame->nb_samples = s->block_size / FFMINI(avctx->ch_layout.nb_channels, MAX_CHANNELS);
 
     return 0;
 fail:
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 360c1032000..5f9bc3d1a4d 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -255,7 +255,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, AVFrame *p,
                 colors = t;
             }
         } else {
-            colors = FFMIN(256, (hsize-ihsize-14) / 3);
+            colors = FFMINI(256, (hsize-ihsize-14) / 3);
         }
         buf = buf0 + 14 + ihsize; //palette location
         // OS/2 bitmap, 3 bytes per palette entry
diff --git a/libavcodec/bmp_parser.c b/libavcodec/bmp_parser.c
index 3440794b2cf..349f3f90a6d 100644
--- a/libavcodec/bmp_parser.c
+++ b/libavcodec/bmp_parser.c
@@ -81,7 +81,7 @@ restart:
         bpc->pc.state64 = state;
     } else {
         if (bpc->remaining_size) {
-            i = FFMIN(bpc->remaining_size, buf_size);
+            i = FFMINI(bpc->remaining_size, buf_size);
             bpc->remaining_size -= i;
             if (bpc->remaining_size)
                 goto flush;
@@ -96,7 +96,7 @@ flush:
         return buf_size;
 
     if (next != END_NOT_FOUND && next < 0)
-        bpc->pc.frame_start_found = FFMAX(bpc->pc.frame_start_found - i - 1, 0);
+        bpc->pc.frame_start_found = FFMAXI(bpc->pc.frame_start_found - i - 1, 0);
     else
         bpc->pc.frame_start_found = 0;
 
diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c
index 99098ef2b0d..c6444a430a9 100644
--- a/libavcodec/bonk.c
+++ b/libavcodec/bonk.c
@@ -316,7 +316,7 @@ static int bonk_decode(AVCodecContext *avctx, AVFrame *frame,
         return pkt->size;
     }
 
-    buf_size = FFMIN(pkt->size, s->max_framesize - s->bitstream_size);
+    buf_size = FFMINI(pkt->size, s->max_framesize - s->bitstream_size);
     input_buf_size = buf_size;
     if (s->bitstream_index + s->bitstream_size + buf_size + AV_INPUT_BUFFER_PADDING_SIZE > s->max_framesize) {
         memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
@@ -332,7 +332,7 @@ static int bonk_decode(AVCodecContext *avctx, AVFrame *frame,
         return input_buf_size;
     }
 
-    frame->nb_samples = FFMIN(s->samples_per_packet * s->down_sampling, s->nb_samples);
+    frame->nb_samples = FFMINI(s->samples_per_packet * s->down_sampling, s->nb_samples);
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         goto fail;
 
diff --git a/libavcodec/bsf/dts2pts.c b/libavcodec/bsf/dts2pts.c
index 9d31d7dc08a..09ba6bb2954 100644
--- a/libavcodec/bsf/dts2pts.c
+++ b/libavcodec/bsf/dts2pts.c
@@ -191,7 +191,7 @@ static int h264_queue_frame(AVBSFContext *ctx, AVPacket *pkt, int poc, int *queu
 
     poc_diff = (h264->picture_structure == 3) + 1;
     if (h264->sps.frame_mbs_only_flag && h264->poc_diff)
-        poc_diff = FFMIN(poc_diff, h264->poc_diff);
+        poc_diff = FFMINI(poc_diff, h264->poc_diff);
     if (poc < 0) {
         av_tree_enumerate(s->root, &poc_diff, NULL, dec_poc);
         s->nb_frame -= poc_diff;
diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h
index 67080604b92..54702a6834d 100644
--- a/libavcodec/bytestream.h
+++ b/libavcodec/bytestream.h
@@ -168,7 +168,7 @@ static av_always_inline int bytestream2_get_bytes_left_p(PutByteContext *p)
 static av_always_inline void bytestream2_skip(GetByteContext *g,
                                               unsigned int size)
 {
-    g->buffer += FFMIN(g->buffer_end - g->buffer, size);
+    g->buffer += FFMINI(g->buffer_end - g->buffer, size);
 }
 
 static av_always_inline void bytestream2_skipu(GetByteContext *g,
@@ -183,7 +183,7 @@ static av_always_inline void bytestream2_skip_p(PutByteContext *p,
     unsigned int size2;
     if (p->eof)
         return;
-    size2 = FFMIN(p->buffer_end - p->buffer, size);
+    size2 = FFMINI(p->buffer_end - p->buffer, size);
     if (size2 != size)
         p->eof = 1;
     p->buffer += size2;
@@ -268,7 +268,7 @@ static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g,
                                                             uint8_t *dst,
                                                             unsigned int size)
 {
-    unsigned int size2 = FFMIN(g->buffer_end - g->buffer, size);
+    unsigned int size2 = FFMINI(g->buffer_end - g->buffer, size);
     memcpy(dst, g->buffer, size2);
     g->buffer += size2;
     return size2;
@@ -290,7 +290,7 @@ static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p,
     unsigned int size2;
     if (p->eof)
         return 0;
-    size2 = FFMIN(p->buffer_end - p->buffer, size);
+    size2 = FFMINI(p->buffer_end - p->buffer, size);
     if (size2 != size)
         p->eof = 1;
     memcpy(p->buffer, src, size2);
@@ -314,7 +314,7 @@ static av_always_inline void bytestream2_set_buffer(PutByteContext *p,
     unsigned int size2;
     if (p->eof)
         return;
-    size2 = FFMIN(p->buffer_end - p->buffer, size);
+    size2 = FFMINI(p->buffer_end - p->buffer, size);
     if (size2 != size)
         p->eof = 1;
     memset(p->buffer, c, size2);
@@ -352,8 +352,8 @@ static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p,
 
     if (p->eof)
         return 0;
-    size  = FFMIN(g->buffer_end - g->buffer, size);
-    size2 = FFMIN(p->buffer_end - p->buffer, size);
+    size  = FFMINI(g->buffer_end - g->buffer, size);
+    size2 = FFMINI(p->buffer_end - p->buffer, size);
     if (size2 != size)
         p->eof = 1;
 
diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index 172cc5cc7a9..ec194c3783d 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -536,7 +536,7 @@ void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type)
 static inline void scale_mv(AVSContext *h, int *d_x, int *d_y,
                             cavs_vector *src, int distp)
 {
-    int64_t den = h->scale_den[FFMAX(src->ref, 0)];
+    int64_t den = h->scale_den[FFMAXI(src->ref, 0)];
     *d_x = (src->x * distp * den + 256 + FF_SIGNBIT(src->x)) >> 9;
     *d_y = (src->y * distp * den + 256 + FF_SIGNBIT(src->y)) >> 9;
 }
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 3cf8c9fb3ae..60b10442608 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -672,7 +672,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
 
         nA = h->pred_mode_Y[pos - 1];
         nB = h->pred_mode_Y[pos - 3];
-        predpred = FFMIN(nA, nB);
+        predpred = FFMINI(nA, nB);
         if (predpred == NOT_AVAIL) // if either is not available
             predpred = INTRA_L_LP;
         if (!get_bits1(gb)) {
@@ -1265,7 +1265,7 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
         if ((stc & 0xFFFFFE00) || buf_ptr == buf_end) {
             if (!h->stc)
                 av_log(h->avctx, AV_LOG_WARNING, "no frame decoded\n");
-            return FFMAX(0, buf_ptr - buf);
+            return FFMAXI(0, buf_ptr - buf);
         }
         input_size = (buf_end - buf_ptr) * 8;
         switch (stc) {
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 6b2ebe597d3..b4838463d5e 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -388,7 +388,7 @@ static int cbs_write_unit_data(CodedBitstreamContext *ctx,
             // Overflow.
             if (ctx->write_buffer_size == INT_MAX / 8)
                 return AVERROR(ENOMEM);
-            ctx->write_buffer_size = FFMIN(2 * ctx->write_buffer_size, INT_MAX / 8);
+            ctx->write_buffer_size = FFMINI(2 * ctx->write_buffer_size, INT_MAX / 8);
             goto reallocate_and_try_again;
         }
         // Write failed for some other reason.
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 5518544a4d6..8ad54dcb479 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -614,7 +614,7 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw,
     min_log2_tile_cols = cbs_av1_tile_log2(max_tile_width_sb, sb_cols);
     max_log2_tile_cols = cbs_av1_tile_log2(1, FFMIN(sb_cols, AV1_MAX_TILE_COLS));
     max_log2_tile_rows = cbs_av1_tile_log2(1, FFMIN(sb_rows, AV1_MAX_TILE_ROWS));
-    min_log2_tiles = FFMAX(min_log2_tile_cols,
+    min_log2_tiles = FFMAXI(min_log2_tile_cols,
                            cbs_av1_tile_log2(max_tile_area_sb, sb_rows * sb_cols));
 
     flag(uniform_tile_spacing_flag);
@@ -674,7 +674,7 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw,
             max_tile_area_sb = (sb_rows * sb_cols) >> (min_log2_tiles + 1);
         else
             max_tile_area_sb = sb_rows * sb_cols;
-        max_tile_height_sb = FFMAX(max_tile_area_sb / widest_tile_sb, 1);
+        max_tile_height_sb = FFMAXI(max_tile_area_sb / widest_tile_sb, 1);
 
         start_sb = 0;
         for (i = 0; start_sb < sb_rows && i < AV1_MAX_TILE_ROWS; i++) {
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 369e3ac8769..4f576a16714 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -43,7 +43,7 @@ static int cbs_read_ue_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc,
 
     CBS_TRACE_READ_START();
 
-    max_length = FFMIN(get_bits_left(gbc), 32);
+    max_length = FFMINI(get_bits_left(gbc), 32);
 
     leading_bits = max_length ? show_bits_long(gbc, max_length) : 0;
     if (leading_bits == 0) {
@@ -93,7 +93,7 @@ static int cbs_read_se_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc,
 
     CBS_TRACE_READ_START();
 
-    max_length = FFMIN(get_bits_left(gbc), 32);
+    max_length = FFMINI(get_bits_left(gbc), 32);
 
     leading_bits = max_length ? show_bits_long(gbc, max_length) : 0;
     if (leading_bits == 0) {
diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c
index e976c38b8d4..ac52290bfd9 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -683,7 +683,7 @@ static int FUNC(scaling_list_data)(CodedBitstreamContext *ctx, RWContext *rw,
                     0, sizeId == 3 ? matrixId / 3 : matrixId,
                     2, sizeId, matrixId);
             } else {
-                n = FFMIN(64, 1 << (4 + (sizeId << 1)));
+                n = FFMINI(64, 1 << (4 + (sizeId << 1)));
                 if (sizeId > 1) {
                     ses(scaling_list_dc_coef_minus8[sizeId - 2][matrixId], -7, +247,
                         2, sizeId - 2, matrixId);
diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c
index 32703d44937..f44f7cd7005 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -1709,7 +1709,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
        1, sps->sps_pic_height_max_in_luma_samples);
 
     min_cb_size_y = 1 << (sps->sps_log2_min_luma_coding_block_size_minus2 + 2);
-    divisor = FFMAX(min_cb_size_y, 8);
+    divisor = FFMAXI(min_cb_size_y, 8);
     if (current->pps_pic_width_in_luma_samples % divisor ||
         current->pps_pic_height_in_luma_samples % divisor) {
         av_log(ctx->log_ctx, AV_LOG_ERROR,
@@ -1903,7 +1903,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
                        current->num_tile_columns, VVC_MAX_TILE_COLUMNS);
                 return AVERROR_INVALIDDATA;
             }
-            unified_size = FFMIN(remaining_size, unified_size);
+            unified_size = FFMINI(remaining_size, unified_size);
             current->col_width_val[i] = unified_size;
             remaining_size -= unified_size;
             i++;
@@ -1929,7 +1929,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
         unified_size = current->pps_tile_row_height_minus1[i - 1] + 1;
 
         while (remaining_size > 0) {
-            unified_size = FFMIN(remaining_size, unified_size);
+            unified_size = FFMINI(remaining_size, unified_size);
             current->row_height_val[i] = unified_size;
             remaining_size -= unified_size;
             i++;
diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 01bdc4d5373..2429a02de49 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -435,7 +435,7 @@ static void roll_up(CCaptionSubContext *ctx)
     /* +1 signify cursor_row starts from 0
      * Can't keep lines less then row cursor pos
      */
-    keep_lines = FFMIN(ctx->cursor_row + 1, ctx->rollup);
+    keep_lines = FFMINI(ctx->cursor_row + 1, ctx->rollup);
 
     for (i = 0; i < SCREEN_ROWS; i++) {
         if (i > ctx->cursor_row - keep_lines && i <= ctx->cursor_row)
diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c
index 518c75081b5..1d7379090f2 100644
--- a/libavcodec/cdgraphics.c
+++ b/libavcodec/cdgraphics.c
@@ -213,8 +213,8 @@ static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
     hscmd = (data[1] & 0x30) >> 4;
     vscmd = (data[2] & 0x30) >> 4;
 
-    h_off =  FFMIN(data[1] & 0x07, CDG_BORDER_WIDTH  - 1);
-    v_off =  FFMIN(data[2] & 0x0F, CDG_BORDER_HEIGHT - 1);
+    h_off =  FFMINI(data[1] & 0x07, CDG_BORDER_WIDTH  - 1);
+    v_off =  FFMINI(data[2] & 0x0F, CDG_BORDER_HEIGHT - 1);
 
     /// find the difference and save the offset for cdg_tile_block usage
     hinc = h_off - cc->hscroll;
@@ -236,9 +236,9 @@ static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
 
     memcpy(new_frame->data[1], cc->frame->data[1], CDG_PALETTE_SIZE * 4);
 
-    for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
-        memcpy(out + FFMAX(0, hinc) + stride * y,
-               in + FFMAX(0, hinc) - hinc + (y - vinc) * stride,
+    for (y = FFMAXI(0, vinc); y < FFMINI(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
+        memcpy(out + FFMAXI(0, hinc) + stride * y,
+               in + FFMAXI(0, hinc) - hinc + (y - vinc) * stride,
                FFABS(stride) - FFABS(hinc));
 
     if (vinc > 0)
diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 42e01bfd851..d9838e775d2 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -322,7 +322,7 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx)
 
     for (int i = 0; i < 512; i++) {
         int value = (i & sign_mask) ? twos_complement + (i & mag_mask): i;
-        int mag = FFMIN(FFABS(value), 255);
+        int mag = FFMINI(FFABS(value), 255);
 
         if (mag) {
             s->cb[i].bits = (codebook[mag][1] << 1) | (value > 0 ? 0 : 1);
@@ -392,7 +392,7 @@ static void quantize_band(int16_t *input, int width, int a_width,
 static int put_runcode(PutBitContext *pb, int count, const Runbook *const rb)
 {
     while (count > 0) {
-        const int index = FFMIN(320, count);
+        const int index = FFMINI(320, count);
 
         put_bits(pb, rb[index].size, rb[index].bits);
         count -= rb[index].run;
diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index 9ec7ac5a8fb..491f0d8340b 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -377,7 +377,7 @@ static int cinepak_decode (CinepakContext *s)
 
     s->data += 10 + s->sega_film_skip_bytes;
 
-    num_strips = FFMIN(num_strips, MAX_STRIPS);
+    num_strips = FFMINI(num_strips, MAX_STRIPS);
 
     s->frame->flags &= ~AV_FRAME_FLAG_KEY;
 
diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c
index dfcc685e7e8..8d600ff9b6b 100644
--- a/libavcodec/cngdec.c
+++ b/libavcodec/cngdec.c
@@ -117,7 +117,7 @@ static int cng_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         int dbov = -avpkt->data[0];
         p->target_energy = 1081109975 * ff_exp10(dbov / 10.0) * 0.75;
         memset(p->target_refl_coef, 0, p->order * sizeof(*p->target_refl_coef));
-        for (i = 0; i < FFMIN(avpkt->size - 1, p->order); i++) {
+        for (i = 0; i < FFMINI(avpkt->size - 1, p->order); i++) {
             p->target_refl_coef[i] = (avpkt->data[1 + i] - 127) / 128.0;
         }
     }
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index f627967ffbb..2d761fba20f 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -1109,8 +1109,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
     ff_audiodsp_init(&q->adsp);
 
     while (bytestream2_get_bytes_left(&gb)) {
-        if (s >= FFMIN(MAX_SUBPACKETS, avctx->block_align)) {
-            avpriv_request_sample(avctx, "subpackets > %d", FFMIN(MAX_SUBPACKETS, avctx->block_align));
+        if (s >= FFMINI(MAX_SUBPACKETS, avctx->block_align)) {
+            avpriv_request_sample(avctx, "subpackets > %d", FFMINI(MAX_SUBPACKETS, avctx->block_align));
             return AVERROR_PATCHWELCOME;
         }
         /* 8 for mono, 16 for stereo, ? for multichannel
diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index 56ec485f7ae..5e2f018d34a 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -219,9 +219,9 @@ static int cri_decode_frame(AVCodecContext *avctx, AVFrame *p,
                 return AVERROR_INVALIDDATA;
             break;
         case 102:
-            bytestream2_get_buffer(gb, codec_name, FFMIN(length, sizeof(codec_name) - 1));
-            length -= FFMIN(length, sizeof(codec_name) - 1);
-            if (strncmp(codec_name, "cintel_craw", FFMIN(length, sizeof(codec_name) - 1)))
+            bytestream2_get_buffer(gb, codec_name, FFMINI(length, sizeof(codec_name) - 1));
+            length -= FFMINI(length, sizeof(codec_name) - 1);
+            if (strncmp(codec_name, "cintel_craw", FFMINI(length, sizeof(codec_name) - 1)))
                 return AVERROR_INVALIDDATA;
             compressed = 1;
             goto skip;
diff --git a/libavcodec/d3d12va_encode_hevc.c b/libavcodec/d3d12va_encode_hevc.c
index 938ba01f540..d34acbb31ef 100644
--- a/libavcodec/d3d12va_encode_hevc.c
+++ b/libavcodec/d3d12va_encode_hevc.c
@@ -488,10 +488,10 @@ static int d3d12va_encode_hevc_configure(AVCodecContext *avctx)
     // Power of 2
     if (base_ctx->gop_size & base_ctx->gop_size - 1 == 0)
         ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4 =
-            FFMAX(av_log2(base_ctx->gop_size) - 4, 0);
+            FFMAXI(av_log2(base_ctx->gop_size) - 4, 0);
     else
         ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4 =
-            FFMAX(av_log2(base_ctx->gop_size) - 3, 0);
+            FFMAXI(av_log2(base_ctx->gop_size) - 3, 0);
 
     return 0;
 }
diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index cb1f7b7bbfa..8ea2112640f 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -818,7 +818,7 @@ static int parse_frame_data(DCACoreDecoder *s, enum HeaderType header, int xch_b
         // Determine number of active subbands for this channel
         int nsubbands = s->nsubbands[ch];
         if (s->joint_intensity_index[ch])
-            nsubbands = FFMAX(nsubbands, s->nsubbands[s->joint_intensity_index[ch] - 1]);
+            nsubbands = FFMAXI(nsubbands, s->nsubbands[s->joint_intensity_index[ch] - 1]);
 
         // Update history for ADPCM
         for (band = 0; band < nsubbands; band++) {
@@ -1194,7 +1194,7 @@ static int parse_x96_subframe_audio(DCACoreDecoder *s, int sf, int xch_base, int
                     // the VQ code book for up to 16 subband samples
                     const int8_t *vq_samples = ff_dca_high_freq_vq[get_bits(&s->gb, 10)];
                     // Scale and take the samples
-                    for (n = 0; n < FFMIN(nsamples - ssf * 16, 16); n++)
+                    for (n = 0; n < FFMINI(nsamples - ssf * 16, 16); n++)
                         *samples++ = clip23(vq_samples[n] * scale + (1 << 3) >> 4);
                 }
                 break;
@@ -1492,7 +1492,7 @@ static int parse_x96_frame_data(DCACoreDecoder *s, int exss, int xch_base)
         // Determine number of active subbands for this channel
         int nsubbands = s->nsubbands[ch];
         if (s->joint_intensity_index[ch])
-            nsubbands = FFMAX(nsubbands, s->nsubbands[s->joint_intensity_index[ch] - 1]);
+            nsubbands = FFMAXI(nsubbands, s->nsubbands[s->joint_intensity_index[ch] - 1]);
 
         // Update history for ADPCM and clear inactive subbands
         for (band = 0; band < DCA_SUBBANDS_X96; band++) {
@@ -1699,7 +1699,7 @@ static int parse_optional_info(DCACoreDecoder *s)
 
     // Core extensions
     if (s->ext_audio_present && !dca->core_only) {
-        int sync_pos = FFMIN(s->frame_size / 4, s->gb.size_in_bits / 32) - 1;
+        int sync_pos = FFMINI(s->frame_size / 4, s->gb.size_in_bits / 32) - 1;
         int last_pos = get_bits_count(&s->gb) / 32;
         int size, dist;
         uint32_t w1, w2 = 0;
diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index 4996c204e60..17f4c2de552 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -644,7 +644,7 @@ static void parse_ch(DCALbrDecoder *s, int ch, int sb, int quant_level, int flag
 
     switch (quant_level) {
     case 1:
-        nblocks = FFMIN(get_bits_left(&s->gb) / 8, DCA_LBR_TIME_SAMPLES / 8);
+        nblocks = FFMINI(get_bits_left(&s->gb) / 8, DCA_LBR_TIME_SAMPLES / 8);
         for (i = 0; i < nblocks; i++, samples += 8) {
             code = get_bits(&s->gb, 8);
             for (j = 0; j < 8; j++)
@@ -662,7 +662,7 @@ static void parse_ch(DCALbrDecoder *s, int ch, int sb, int quant_level, int flag
                     samples[i] = 0;
             }
         } else {
-            nblocks = FFMIN(get_bits_left(&s->gb) / 8, (DCA_LBR_TIME_SAMPLES + 4) / 5);
+            nblocks = FFMINI(get_bits_left(&s->gb) / 8, (DCA_LBR_TIME_SAMPLES + 4) / 5);
             for (i = 0; i < nblocks; i++, samples += 5) {
                 code = ff_dca_rsd_pack_5_in_8[get_bits(&s->gb, 8)];
                 for (j = 0; j < 5; j++)
@@ -673,7 +673,7 @@ static void parse_ch(DCALbrDecoder *s, int ch, int sb, int quant_level, int flag
         break;
 
     case 3:
-        nblocks = FFMIN(get_bits_left(&s->gb) / 7, (DCA_LBR_TIME_SAMPLES + 2) / 3);
+        nblocks = FFMINI(get_bits_left(&s->gb) / 7, (DCA_LBR_TIME_SAMPLES + 2) / 3);
         for (i = 0; i < nblocks; i++, samples += 3) {
             code = get_bits(&s->gb, 7);
             for (j = 0; j < 3; j++)
@@ -688,7 +688,7 @@ static void parse_ch(DCALbrDecoder *s, int ch, int sb, int quant_level, int flag
         break;
 
     case 5:
-        nblocks = FFMIN(get_bits_left(&s->gb) / 4, DCA_LBR_TIME_SAMPLES);
+        nblocks = FFMINI(get_bits_left(&s->gb) / 4, DCA_LBR_TIME_SAMPLES);
         for (i = 0; i < nblocks; i++)
             samples[i] = ff_dca_rsd_level_16[get_bits(&s->gb, 4)];
         break;
@@ -1078,7 +1078,7 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb)
 
     // Setup number of fullband channels
     s->nchannels_total = ff_dca_count_chs_for_mask(s->ch_mask & ~DCA_SPEAKER_PAIR_LFE1);
-    s->nchannels = FFMIN(s->nchannels_total, DCA_LBR_CHANNELS);
+    s->nchannels = FFMINI(s->nchannels_total, DCA_LBR_CHANNELS);
 
     // Setup band limit
     switch (s->flags & LBR_FLAG_BAND_LIMIT_MASK) {
@@ -1376,7 +1376,7 @@ int ff_dca_lbr_parse(DCALbrDecoder *s, const uint8_t *data, DCAExssAsset *asset)
 
     for (i = 0; i < (s->nchannels + 1) / 2; i++) {
         int ch1 = i * 2;
-        int ch2 = FFMIN(ch1 + 1, s->nchannels - 1);
+        int ch2 = FFMINI(ch1 + 1, s->nchannels - 1);
 
         if (parse_grid_1_chunk (s, &chunk.grid1  [i], ch1, ch2) < 0 ||
             parse_high_res_grid(s, &chunk.hr_grid[i], ch1, ch2) < 0) {
@@ -1765,7 +1765,7 @@ int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame)
     // Filter fullband channels
     for (i = 0; i < (s->nchannels + 1) / 2; i++) {
         int ch1 = i * 2;
-        int ch2 = FFMIN(ch1 + 1, s->nchannels - 1);
+        int ch2 = FFMINI(ch1 + 1, s->nchannels - 1);
 
         decode_grid(s, ch1, ch2);
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index ef095683813..ce5ee438b97 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -323,7 +323,7 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca
     side = av_frame_get_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES);
     if (side && side->size >= 10) {
         avci->skip_samples = AV_RL32(side->data);
-        avci->skip_samples = FFMAX(0, avci->skip_samples);
+        avci->skip_samples = FFMAXI(0, avci->skip_samples);
         discard_padding = AV_RL32(side->data + 4);
         av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n",
                avci->skip_samples, (int)discard_padding);
@@ -346,7 +346,7 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca
     av_frame_remove_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES);
 
     if ((frame->flags & AV_FRAME_FLAG_DISCARD)) {
-        avci->skip_samples = FFMAX(0, avci->skip_samples - frame->nb_samples);
+        avci->skip_samples = FFMAXI(0, avci->skip_samples - frame->nb_samples);
         *discarded_samples += frame->nb_samples;
         return AVERROR(EAGAIN);
     }
@@ -865,7 +865,7 @@ static int recode_subtitle(AVCodecContext *avctx, const AVPacket **outpkt,
     if (iconv(cd, &inb, &inl, &outb, &outl) == (size_t)-1 ||
         iconv(cd, NULL, NULL, &outb, &outl) == (size_t)-1 ||
         outl >= buf_pkt->size || inl != 0) {
-        ret = FFMIN(AVERROR(errno), -1);
+        ret = FFMINI(AVERROR(errno), -1);
         av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" "
                "from %s to UTF-8\n", inpkt->data, avctx->sub_charenc);
         goto end;
@@ -1585,8 +1585,8 @@ static void update_frame_props(AVCodecContext *avctx, AVFrame *frame)
     if (dc->lcevc_frame) {
         dc->width     = frame->width;
         dc->height    = frame->height;
-        frame->width  = frame->width  * 2 / FFMAX(frame->sample_aspect_ratio.den, 1);
-        frame->height = frame->height * 2 / FFMAX(frame->sample_aspect_ratio.num, 1);
+        frame->width  = frame->width  * 2 / FFMAXI(frame->sample_aspect_ratio.den, 1);
+        frame->height = frame->height * 2 / FFMAXI(frame->sample_aspect_ratio.num, 1);
     }
 }
 
@@ -1652,8 +1652,8 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
         }
 
         if (frame->width <= 0 || frame->height <= 0) {
-            frame->width  = FFMAX(avctx->width,  AV_CEIL_RSHIFT(avctx->coded_width,  avctx->lowres));
-            frame->height = FFMAX(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
+            frame->width  = FFMAXI(avctx->width,  AV_CEIL_RSHIFT(avctx->coded_width,  avctx->lowres));
+            frame->height = FFMAXI(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
             override_dimensions = 0;
         }
 
diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c
index 1efaefcb699..fdf562a6c0f 100644
--- a/libavcodec/dfa.c
+++ b/libavcodec/dfa.c
@@ -42,7 +42,7 @@ static av_cold int dfa_decode_init(AVCodecContext *avctx)
 
     avctx->pix_fmt = AV_PIX_FMT_PAL8;
 
-    if (!avctx->width || !avctx->height || FFMAX(avctx->width, avctx->height) >= (1<<16))
+    if (!avctx->width || !avctx->height || FFMAXI(avctx->width, avctx->height) >= (1<<16))
         return AVERROR_INVALIDDATA;
 
     av_assert0(av_image_check_size(avctx->width, avctx->height, 0, avctx) >= 0);
@@ -362,7 +362,7 @@ static int dfa_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         if (!chunk_type)
             break;
         if (chunk_type == 1) {
-            pal_elems = FFMIN(chunk_size / 3, 256);
+            pal_elems = FFMINI(chunk_size / 3, 256);
             for (i = 0; i < pal_elems; i++) {
                 s->pal[i] = bytestream2_get_be24(&gb) << 2;
                 s->pal[i] |= 0xFFU << 24 | (s->pal[i] >> 6) & 0x30303;
diff --git a/libavcodec/dirac_arith.c b/libavcodec/dirac_arith.c
index 69b62802302..9a49fefdc09 100644
--- a/libavcodec/dirac_arith.c
+++ b/libavcodec/dirac_arith.c
@@ -98,7 +98,7 @@ void ff_dirac_init_arith_decoder(DiracArith *c, GetBitContext *gb, int length)
     int i;
     align_get_bits(gb);
 
-    length = FFMIN(length, get_bits_left(gb)/8);
+    length = FFMINI(length, get_bits_left(gb)/8);
 
     c->bytestream     = gb->buffer + get_bits_count(gb)/8;
     c->bytestream_end = c->bytestream + length;
diff --git a/libavcodec/dirac_dwt.c b/libavcodec/dirac_dwt.c
index d473f64daa5..a0bf0e08c52 100644
--- a/libavcodec/dirac_dwt.c
+++ b/libavcodec/dirac_dwt.c
@@ -75,7 +75,7 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y)
         int hl = d->height >> level;
         int stride_l = d->stride << level;
 
-        while (d->cs[level].y <= FFMIN((y>>level)+support, hl))
+        while (d->cs[level].y <= FFMINI((y>>level)+support, hl))
             d->spatial_compose(d, level, wl, hl, stride_l);
     }
 }
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 76209aebba9..133954484bf 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -302,7 +302,7 @@ static int alloc_sequence_buffers(DiracContext *s)
          * 1<<MAX_DWT_LEVELS top padding to avoid if(y>0) in arith decoding
          * MAX_BLOCKSIZE padding for MC: blocks can spill up to half of that
          * on each side */
-        top_padding = FFMAX(1<<MAX_DWT_LEVELS, max_yblen/2);
+        top_padding = FFMAXI(1<<MAX_DWT_LEVELS, max_yblen/2);
         w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */
         h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2;
 
@@ -684,8 +684,8 @@ static int decode_component(DiracContext *s, int comp)
                 }
                 align_get_bits(&s->gb);
                 b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;
-                if (b->length > FFMAX(get_bits_left(&s->gb)/8, 0)) {
-                    b->length = FFMAX(get_bits_left(&s->gb)/8, 0);
+                if (b->length > FFMAXI(get_bits_left(&s->gb)/8, 0)) {
+                    b->length = FFMAXI(get_bits_left(&s->gb)/8, 0);
                     damaged_count ++;
                 }
                 skip_bits_long(&s->gb, b->length*8);
@@ -785,12 +785,12 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
     int quant_base  = get_bits(gb, 7); /*[DIRAC_STD] qindex */
     int length_bits = av_log2(8 * slice->bytes)+1;
     int luma_bits   = get_bits_long(gb, length_bits);
-    int luma_end    = get_bits_count(gb) + FFMIN(luma_bits, get_bits_left(gb));
+    int luma_end    = get_bits_count(gb) + FFMINI(luma_bits, get_bits_left(gb));
 
     /* [DIRAC_STD] 13.5.5.2 luma_slice_band */
     for (level = 0; level < s->wavelet_depth; level++)
         for (orientation = !!level; orientation < 4; orientation++) {
-            quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
+            quant = FFMAXI(quant_base - s->lowdelay.quant[level][orientation], 0);
             decode_subband(s, gb, quant, slice->slice_x, slice->slice_y, luma_end,
                            &s->plane[0].band[level][orientation], NULL);
         }
@@ -799,11 +799,11 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
     skip_bits_long(gb, get_bits_count(gb) - luma_end);
 
     chroma_bits = 8*slice->bytes - 7 - length_bits - luma_bits;
-    chroma_end  = get_bits_count(gb) + FFMIN(chroma_bits, get_bits_left(gb));
+    chroma_end  = get_bits_count(gb) + FFMINI(chroma_bits, get_bits_left(gb));
     /* [DIRAC_STD] 13.5.5.3 chroma_slice_band */
     for (level = 0; level < s->wavelet_depth; level++)
         for (orientation = !!level; orientation < 4; orientation++) {
-            quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
+            quant = FFMAXI(quant_base - s->lowdelay.quant[level][orientation], 0);
             decode_subband(s, gb, quant, slice->slice_x, slice->slice_y, chroma_end,
                            &s->plane[1].band[level][orientation],
                            &s->plane[2].band[level][orientation]);
@@ -859,7 +859,7 @@ static int decode_hq_slice(const DiracContext *s, DiracSlice *slice, uint8_t *tm
     /* Slice quantization (slice_quantizers() in the specs) */
     for (level = 0; level < s->wavelet_depth; level++) {
         for (orientation = !!level; orientation < 4; orientation++) {
-            const int quant = FFMAX(quant_idx - s->lowdelay.quant[level][orientation], 0);
+            const int quant = FFMAXI(quant_idx - s->lowdelay.quant[level][orientation], 0);
             qfactor[level][orientation] = ff_dirac_qscale_tab[quant];
             qoffset[level][orientation] = ff_dirac_qoffset_intra_tab[quant] + 2;
         }
@@ -1150,7 +1150,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
         av_log(s->avctx, AV_LOG_ERROR, "Block separation greater than size\n");
         return AVERROR_INVALIDDATA;
     }
-    if (FFMAX(s->plane[0].xblen, s->plane[0].yblen) > MAX_BLOCKSIZE) {
+    if (FFMAXI(s->plane[0].xblen, s->plane[0].yblen) > MAX_BLOCKSIZE) {
         av_log(s->avctx, AV_LOG_ERROR, "Unsupported large block size\n");
         return AVERROR_PATCHWELCOME;
     }
@@ -1934,7 +1934,7 @@ static int dirac_decode_frame_internal(DiracContext *s)
             dsty = -p->yoffset;
             for (y = 0; y < s->blheight; y++) {
                 int h     = 0,
-                    start = FFMAX(dsty, 0);
+                    start = FFMAXI(dsty, 0);
                 uint16_t *mctmp    = s->mctmp + y*rowheight;
                 DiracBlock *blocks = s->blmotion + y*s->blwidth;
 
diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index ce06d77f18e..8475c50d38c 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -1104,7 +1104,7 @@ int ff_dnxhd_get_hr_frame_size(int cid, int w, int h)
     result = ((h + 15) / 16) * ((w + 15) / 16) * (int64_t)entry->packet_scale.num / entry->packet_scale.den;
     result = (result + 2048) / 4096 * 4096;
 
-    return FFMAX(result, 8192);
+    return FFMAXI(result, 8192);
 }
 
 static int dnxhd_find_hr_cid(AVCodecContext *avctx)
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 7a5978c137d..81c50c4f117 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -946,8 +946,8 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
                 sum  = ctx->m.mpvencdsp.pix_sum(pix, ctx->m.c.linesize);
                 varc = ctx->m.mpvencdsp.pix_norm1(pix, ctx->m.c.linesize);
             } else {
-                int bw = FFMIN(avctx->width - 16 * mb_x, 16);
-                int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16);
+                int bw = FFMINI(avctx->width - 16 * mb_x, 16);
+                int bh = FFMINI((avctx->height >> ctx->interlaced) - 16 * mb_y, 16);
                 sum = varc = 0;
                 for (y = 0; y < bh; y++) {
                     for (x = 0; x < bw; x++) {
@@ -970,8 +970,8 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
             unsigned mb  = mb_y * ctx->m.c.mb_width + mb_x;
             int sum = 0;
             int sqsum = 0;
-            int bw = FFMIN(avctx->width - 16 * mb_x, 16);
-            int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16);
+            int bw = FFMINI(avctx->width - 16 * mb_x, 16);
+            int bh = FFMINI((avctx->height >> ctx->interlaced) - 16 * mb_y, 16);
             int mean, sqmean;
             int i, j;
             // Macroblocks are 16x16 pixels, unlike DCT blocks which are 8x8.
@@ -1044,25 +1044,25 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
             break;
         }
         if (bits < ctx->frame_bits) {
-            last_lower = FFMIN(lambda, last_lower);
+            last_lower = FFMINI(lambda, last_lower);
             if (last_higher != 0)
                 lambda = (lambda+last_higher)>>1;
             else
                 lambda -= down_step;
-            down_step = FFMIN((int64_t)down_step*5, INT_MAX);
+            down_step = FFMINI((int64_t)down_step*5, INT_MAX);
             up_step = 1<<LAMBDA_FRAC_BITS;
-            lambda = FFMAX(1, lambda);
+            lambda = FFMAXI(1, lambda);
             if (lambda == last_lower)
                 break;
         } else {
-            last_higher = FFMAX(lambda, last_higher);
+            last_higher = FFMAXI(lambda, last_higher);
             if (last_lower != INT_MAX)
                 lambda = (lambda+last_lower)>>1;
             else if ((int64_t)lambda + up_step > INT_MAX)
                 return AVERROR(EINVAL);
             else
                 lambda += up_step;
-            up_step = FFMIN((int64_t)up_step*5, INT_MAX);
+            up_step = FFMINI((int64_t)up_step*5, INT_MAX);
             down_step = 1<<LAMBDA_FRAC_BITS;
         }
     }
@@ -1100,7 +1100,7 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
                 qscale = last_higher;
                 break;
             }
-            last_lower = FFMIN(qscale, last_lower);
+            last_lower = FFMINI(qscale, last_lower);
             if (last_higher != 0)
                 qscale = (qscale + last_higher) >> 1;
             else
@@ -1111,7 +1111,7 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
         } else {
             if (last_lower == qscale + 1)
                 break;
-            last_higher = FFMAX(qscale, last_higher);
+            last_higher = FFMAXI(qscale, last_higher);
             if (last_lower != INT_MAX)
                 qscale = (qscale + last_lower) >> 1;
             else
diff --git a/libavcodec/dnxuc_parser.c b/libavcodec/dnxuc_parser.c
index 34088ac3b1c..a792b082eee 100644
--- a/libavcodec/dnxuc_parser.c
+++ b/libavcodec/dnxuc_parser.c
@@ -56,7 +56,7 @@ static int dnxuc_parse(AVCodecParserContext *s,
                     uint32_t size = av_bswap32(state >> 32);
                     if (size >= 8) {
                          next = i - 7;
-                         ipc->remaining = size + FFMIN(next, 0);
+                         ipc->remaining = size + FFMINI(next, 0);
                          break;
                     }
                 }
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index bbcb747c06a..402d6ac42cf 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -682,7 +682,7 @@ static int parse_exponents(DBEContext *s, DBEChannel *c)
 static inline int log_add(int a, int b)
 {
     int c = FFABS(a - b) >> 1;
-    return FFMAX(a, b) + log_add_tab[FFMIN(c, 211)];
+    return FFMAXI(a, b) + log_add_tab[FFMINI(c, 211)];
 }
 
 static void calc_lowcomp(int *msk_val)
@@ -695,7 +695,7 @@ static void calc_lowcomp(int *msk_val)
         int max_v = INT_MIN;
         int thr   = 0;
 
-        for (j = FFMAX(i - 3, 0), k = 0; j <= i + 3; j++, k++) {
+        for (j = FFMAXI(i - 3, 0), k = 0; j <= i + 3; j++, k++) {
             int v = msk_val[j] + lwc_gain_tab[i][k];
             if (v > max_v) {
                 max_j = j;
@@ -705,16 +705,16 @@ static void calc_lowcomp(int *msk_val)
         }
 
         if (msk_val[i] < thr) {
-            for (j = FFMAX(max_j - 3, 0),
-                 k = FFMAX(3 - max_j, 0);
+            for (j = FFMAXI(max_j - 3, 0),
+                 k = FFMAXI(3 - max_j, 0);
                  j <= max_j + 3; j++, k++)
                 lwc_val[j] += lwc_adj_tab[k];
         }
     }
 
     for (i = 0; i < 16; i++) {
-        int v = FFMAX(lwc_val[i], -512);
-        msk_val[i] = FFMAX(msk_val[i] + v, 0);
+        int v = FFMAXI(lwc_val[i], -512);
+        msk_val[i] = FFMAXI(msk_val[i] + v, 0);
     }
 }
 
@@ -746,17 +746,17 @@ static void bit_allocate(int nb_exponent, int nb_code, int fr_code,
                             psd_val[i] - fast_gain + fast_gain_adj[i]);
         slow_leak = log_add(slow_leak  - slow_decay,
                             psd_val[i] - slow_gain[i]);
-        msk_val[i] = FFMAX(fast_leak, slow_leak);
+        msk_val[i] = FFMAXI(fast_leak, slow_leak);
     }
 
     fast_leak = 0;
     for (i = nb_exponent - 1; i > band_low_tab[nb_code]; i--) {
         fast_leak = log_add(fast_leak - misc_decay, psd_val[i] - fast_gain);
-        msk_val[i] = FFMAX(msk_val[i], fast_leak);
+        msk_val[i] = FFMAXI(msk_val[i], fast_leak);
     }
 
     for (i = 0; i < nb_exponent; i++)
-        msk_val[i] = FFMAX(msk_val[i], hearing_thresh[i]);
+        msk_val[i] = FFMAXI(msk_val[i], hearing_thresh[i]);
 
     if (!nb_code)
         calc_lowcomp(msk_val);
diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
index b05ad0a3588..1fdbcc12ea0 100644
--- a/libavcodec/dovi_rpuenc.c
+++ b/libavcodec/dovi_rpuenc.c
@@ -855,7 +855,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata,
         }
 
         if (ext) {
-            size_t ext_sz = FFMIN(sizeof(AVDOVIDmData), metadata->ext_block_size);
+            size_t ext_sz = FFMINI(sizeof(AVDOVIDmData), metadata->ext_block_size);
             ext->num_dynamic = 0;
             if (!dm_compression)
                 ext->num_static = 0;
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index eff6587404d..3e6023c5bd4 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -425,7 +425,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
         while (output_samples < samples_end) {
             uint8_t n = bytestream2_get_byteu(&gb);
-            int index = FFMIN(n & 0x7f, 95);
+            int index = FFMINI(n & 0x7f, 95);
 
             s->sample[idx] += (n & 0x80 ? -1: 1) * derf_steps[index];
             s->sample[idx]  = av_clip_int16(s->sample[idx]);
diff --git a/libavcodec/dpx_parser.c b/libavcodec/dpx_parser.c
index b74e6c5c68b..434b6846d00 100644
--- a/libavcodec/dpx_parser.c
+++ b/libavcodec/dpx_parser.c
@@ -66,7 +66,7 @@ static int dpx_parse(AVCodecParserContext *s, AVCodecContext *avctx,
         d->pc.state = state;
     } else {
         if (d->remaining_size) {
-            i = FFMIN(d->remaining_size, buf_size);
+            i = FFMINI(d->remaining_size, buf_size);
             d->remaining_size -= i;
             if (d->remaining_size)
                 goto flush;
diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c
index 400ff983950..036bad8ee6b 100644
--- a/libavcodec/dpxenc.c
+++ b/libavcodec/dpxenc.c
@@ -208,7 +208,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     write32(buf +  20, 1); /* new image */
     write32(buf +  24, HEADER_SIZE);
     if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT))
-        memcpy (buf + 160, LIBAVCODEC_IDENT, FFMIN(sizeof(LIBAVCODEC_IDENT), 100));
+        memcpy (buf + 160, LIBAVCODEC_IDENT, FFMINI(sizeof(LIBAVCODEC_IDENT), 100));
     write32(buf + 660, 0xFFFFFFFF); /* unencrypted */
 
     /* Image information header */
diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c
index 7001a195e2e..82449ee63b1 100644
--- a/libavcodec/dsicinvideo.c
+++ b/libavcodec/dsicinvideo.c
@@ -150,7 +150,7 @@ static int cin_decode_lzss(const unsigned char *src, int src_size,
                 /* don't use memcpy/memmove here as the decoding routine
                  * (ab)uses buffer overlappings to repeat bytes in the
                  * destination */
-                sz = FFMIN(sz, dst_end - dst);
+                sz = FFMINI(sz, dst_end - dst);
                 while (sz--) {
                     *dst = *(dst - offset - 1);
                     ++dst;
@@ -176,7 +176,7 @@ static int cin_decode_rle(const unsigned char *src, int src_size,
         code = *src++;
         if (code & 0x80) {
             len = code - 0x7F;
-            memset(dst, *src++, FFMIN(len, dst_end - dst));
+            memset(dst, *src++, FFMINI(len, dst_end - dst));
         } else {
             len = code + 1;
             if (len > src_end-src) {
diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
index cfb34b7b3c5..c18e6f23c11 100644
--- a/libavcodec/dstdec.c
+++ b/libavcodec/dstdec.c
@@ -271,7 +271,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
         skip_bits1(gb);
         if (get_bits(gb, 6))
             return AVERROR_INVALIDDATA;
-        memcpy(frame->data[0], avpkt->data + 1, FFMIN(avpkt->size - 1, frame->nb_samples * channels));
+        memcpy(frame->data[0], avpkt->data + 1, FFMINI(avpkt->size - 1, frame->nb_samples * channels));
         goto dsd;
     }
 
@@ -357,7 +357,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
             if (!half_prob[ch] || i >= s->fsets.length[felem]) {
                 unsigned pelem = map_ch_to_pelem[ch];
                 unsigned index = FFABS(predict) >> 3;
-                prob = s->probs.coeff[pelem][FFMIN(index, s->probs.length[pelem] - 1)];
+                prob = s->probs.coeff[pelem][FFMINI(index, s->probs.length[pelem] - 1)];
             } else {
                 prob = 128;
             }
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index cbb16e501ac..8dede0d9841 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -719,7 +719,7 @@ static void compute_default_clut(DVBSubContext *ctx, uint8_t *clut, AVSubtitleRe
         list_inv[     i ] = bestv;
     }
 
-    count = FFMAX(i - 1, 1);
+    count = FFMAXI(i - 1, 1);
     for (i--; i >= 0; i--) {
         int v = i * 255 / count;
         AV_WN32(clut + 4*list_inv[i], RGBA(v/2,v,v/2,v));
diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
index 113bb320a9a..7fe8f11f817 100644
--- a/libavcodec/dvbsubenc.c
+++ b/libavcodec/dvbsubenc.c
@@ -237,12 +237,12 @@ static int dvb_encode_rle8(uint8_t **pq, int buf_size,
             } else {
                 if (color == 0x00) {
                     // 00000000 0LLLLLLL          L pixels (1-127) in colour 0 (L > 0)
-                    len = FFMIN(len, 127);
+                    len = FFMINI(len, 127);
                     *q++ = 0x00;
                     *q++ = len;
                 } else if (len > 2) {
                     // 00000000 1LLLLLLL CCCCCCCC L pixels (3-127) in colour C (L > 2)
-                    len = FFMIN(len, 127);
+                    len = FFMINI(len, 127);
                     *q++ = 0x00;
                     *q++ = 0x80+len;
                     *q++ = color;
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 242708c70a8..009453997e1 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -589,7 +589,7 @@ retry:
                 for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->frame->linesize[j], pixels += 8) {
                     ptr1   = pixels + ((1 << (log2_blocksize))>>1);
                     c_ptr1 = c_ptr + (s->frame->linesize[j] << log2_blocksize);
-                    for (x = 0; x < (1 << FFMAX(log2_blocksize - 1, 0)); x++) {
+                    for (x = 0; x < (1 << FFMAXI(log2_blocksize - 1, 0)); x++) {
                         c_ptr[x]  = pixels[x];
                         c_ptr1[x] = ptr1[x];
                     }
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 78658f7d2f7..039081cfc8a 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -126,7 +126,7 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, uint8_t used_
             len = decode_run_2bit(&gb, &color);
         if (len != INT_MAX && len > w - x)
             return AVERROR_INVALIDDATA;
-        len = FFMIN(len, w - x);
+        len = FFMINI(len, w - x);
         memset(d + x, color, len);
         used_color[color] = 1;
         x += len;
diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
index 00bab359885..c8ab75d359e 100644
--- a/libavcodec/dvdsubenc.c
+++ b/libavcodec/dvdsubenc.c
@@ -174,7 +174,7 @@ static void select_palette(AVCodecContext *avctx, int out_palette[4],
         bright = 0;
         for (j = 0; j < 3; j++, color >>= 8)
             bright += (color & 0xFF) < 0x40 || (color & 0xFF) >= 0xC0;
-        mult = 2 + FFMIN(bright, 2);
+        mult = 2 + FFMINI(bright, 2);
         hits[ 1 + i] *= mult;
         hits[17 + i] *= mult;
     }
@@ -291,10 +291,10 @@ static int dvdsub_encode(AVCodecContext *avctx,
         int xmin = h->rects[0]->x, xmax = xmin + h->rects[0]->w;
         int ymin = h->rects[0]->y, ymax = ymin + h->rects[0]->h;
         for (i = 1; i < rects; i++) {
-            xmin = FFMIN(xmin, h->rects[i]->x);
-            ymin = FFMIN(ymin, h->rects[i]->y);
-            xmax = FFMAX(xmax, h->rects[i]->x + h->rects[i]->w);
-            ymax = FFMAX(ymax, h->rects[i]->y + h->rects[i]->h);
+            xmin = FFMINI(xmin, h->rects[i]->x);
+            ymin = FFMINI(ymin, h->rects[i]->y);
+            xmax = FFMAXI(xmax, h->rects[i]->x + h->rects[i]->w);
+            ymax = FFMAXI(ymax, h->rects[i]->y + h->rects[i]->h);
         }
         vrect.x = xmin;
         vrect.y = ymin;
diff --git a/libavcodec/dxva2_av1.c b/libavcodec/dxva2_av1.c
index 47866ff4c3a..02f56774aac 100644
--- a/libavcodec/dxva2_av1.c
+++ b/libavcodec/dxva2_av1.c
@@ -390,7 +390,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
 
     memcpy(dxva_data, ctx_pic->bitstream, ctx_pic->bitstream_size);
 
-    padding = FFMIN(128 - ((ctx_pic->bitstream_size) & 127), dxva_size - ctx_pic->bitstream_size);
+    padding = FFMINI(128 - ((ctx_pic->bitstream_size) & 127), dxva_size - ctx_pic->bitstream_size);
     if (padding > 0) {
         memset(dxva_data + ctx_pic->bitstream_size, 0, padding);
         ctx_pic->bitstream_size += padding;
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index dd9dccbf8c0..fbb0f1a2cc9 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -383,7 +383,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
         memcpy(current, &ctx_pic->bitstream[position], size);
         current += size;
     }
-    padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
+    padding = FFMINI(128 - ((current - dxva_data) & 127), end - current);
     if (slice && padding > 0) {
         memset(current, 0, padding);
         current += padding;
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 85698dfcce2..ca2e11fb788 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -309,7 +309,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
         memcpy(current, &ctx_pic->bitstream[position], size);
         current += size;
     }
-    padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
+    padding = FFMINI(128 - ((current - dxva_data) & 127), end - current);
     if (slice && padding > 0) {
         memset(current, 0, padding);
         current += padding;
diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index 1f5db8156ae..5567467d8da 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -264,7 +264,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
         memcpy(current, &ctx_pic->bitstream[position], size);
         current += size;
     }
-    padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
+    padding = FFMINI(128 - ((current - dxva_data) & 127), end - current);
     if (slice && padding > 0) {
         memset(current, 0, padding);
         current += padding;
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index 2b3bffda6e6..a2aa3437e23 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -78,7 +78,7 @@ static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
                 copy_sizes[num_copy_sections++] = bin - s->spx_dst_start_freq;
                 bin = s->spx_dst_start_freq;
             }
-            copysize = FFMIN(bandsize - i, s->spx_src_start_freq - bin);
+            copysize = FFMINI(bandsize - i, s->spx_src_start_freq - bin);
             bin += copysize;
         }
     }
diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index efcad62df1d..22b7b541915 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -165,7 +165,7 @@ static int tgq_decode_mb(TgqContext *s, GetByteContext *gbyte,
     mode = bytestream2_get_byte(gbyte);
     if (mode > 12) {
         GetBitContext gb;
-        int ret = init_get_bits8(&gb, gbyte->buffer, FFMIN(bytestream2_get_bytes_left(gbyte), mode));
+        int ret = init_get_bits8(&gb, gbyte->buffer, FFMINI(bytestream2_get_bytes_left(gbyte), mode));
         if (ret < 0)
             return ret;
 
diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
index 35bd88b7403..5e5899cb6a2 100644
--- a/libavcodec/eatgv.c
+++ b/libavcodec/eatgv.c
@@ -122,7 +122,7 @@ static int unpack(const uint8_t *src, const uint8_t *src_end,
 
         if (size1 > 0) {
             size -= size1;
-            run   = FFMIN(size1, dst_end - dst);
+            run   = FFMINI(size1, dst_end - dst);
             memcpy(dst, src, run);
             dst += run;
             src += run;
@@ -132,7 +132,7 @@ static int unpack(const uint8_t *src, const uint8_t *src_end,
             if (dst - dst_start < offset)
                 return 0;
             size -= size2;
-            run   = FFMIN(size2, dst_end - dst);
+            run   = FFMINI(size2, dst_end - dst);
             av_memcpy_backptr(dst, offset, run);
             dst += run;
         }
diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
index 84043af4fd3..cfdb4f0a0c2 100644
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -210,8 +210,8 @@ static void get_new_centroids(ELBGContext *elbg, int huc, int *newcentroid_i,
 
     for (tempcell = elbg->cells[huc]; tempcell; tempcell = tempcell->next)
         for(i=0; i<elbg->dim; i++) {
-            min[i]=FFMIN(min[i], elbg->points[tempcell->index*elbg->dim + i]);
-            max[i]=FFMAX(max[i], elbg->points[tempcell->index*elbg->dim + i]);
+            min[i]=FFMINI(min[i], elbg->points[tempcell->index*elbg->dim + i]);
+            max[i]=FFMAXI(max[i], elbg->points[tempcell->index*elbg->dim + i]);
         }
 
     for (i=0; i<elbg->dim; i++) {
@@ -266,7 +266,7 @@ static void evaluate_utility_inc(ELBGContext *elbg)
     for (int i = 0; i < elbg->num_cb; i++) {
         if (elbg->num_cb * (int64_t)elbg->utility[i] > elbg->error)
             inc += elbg->utility[i];
-        elbg->utility_inc[i] = FFMIN(inc, INT_MAX);
+        elbg->utility_inc[i] = FFMINI(inc, INT_MAX);
     }
 }
 
diff --git a/libavcodec/elsdec.c b/libavcodec/elsdec.c
index 9ae932cdf7e..a1aa7fd40fc 100644
--- a/libavcodec/elsdec.c
+++ b/libavcodec/elsdec.c
@@ -267,7 +267,7 @@ void ff_els_decoder_init(ElsDecCtx *ctx, const uint8_t *in, size_t data_size)
     ctx->err       = 0;
     ctx->j         = ELS_JOTS_PER_BYTE;
     ctx->t         = ELS_MAX;
-    ctx->diff      = FFMIN(ELS_MAX - ctx->x,
+    ctx->diff      = FFMINI(ELS_MAX - ctx->x,
                            ELS_MAX - els_exp_tab[ELS_JOTS_PER_BYTE * 4 - 1]);
 }
 
@@ -344,7 +344,7 @@ int ff_els_decode_bit(ElsDecCtx *ctx, uint8_t *rung)
         *rung = Ladder[*rung].next1;
     }
 
-    ctx->diff = FFMIN(z - ctx->x, z - pAllowable[ctx->j - 1]);
+    ctx->diff = FFMINI(z - ctx->x, z - pAllowable[ctx->j - 1]);
 
     return bit;
 }
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 72dfa8867ab..a9fe177c38b 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -823,8 +823,8 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
     case AVMEDIA_TYPE_VIDEO:
         frame->format = avctx->pix_fmt;
         if (frame->width <= 0 || frame->height <= 0) {
-            frame->width  = FFMAX(avctx->width,  avctx->coded_width);
-            frame->height = FFMAX(avctx->height, avctx->coded_height);
+            frame->width  = FFMAXI(avctx->width,  avctx->coded_width);
+            frame->height = FFMAXI(avctx->height, avctx->coded_height);
         }
 
         break;
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 6edc2dc15f9..3771cf6a39a 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -218,7 +218,7 @@ static void guess_dc(ERContext *s, int16_t *dc, int w,
             weight_sum = 0;
             guess      = 0;
             for (j = 0; j < 4; j++) {
-                int64_t weight  = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
+                int64_t weight  = 256 * 256 * 256 * 16 / FFMAXI(dist[b_x + b_y*stride][j], 1);
                 guess          += weight*(int64_t)col[b_x + b_y*stride][j];
                 weight_sum     += weight;
             }
@@ -274,7 +274,7 @@ static void h_block_filter(ERContext *s, uint8_t *dst, int w,
                 c = dst[offset + 9 + y * stride] - dst[offset + 8 + y * stride];
 
                 d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);
-                d = FFMAX(d, 0);
+                d = FFMAXI(d, 0);
                 if (b < 0)
                     d = -d;
 
@@ -346,7 +346,7 @@ static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
                 c = dst[offset + x + 9 * stride] - dst[offset + x + 8 * stride];
 
                 d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);
-                d = FFMAX(d, 0);
+                d = FFMAXI(d, 0);
                 if (b < 0)
                     d = -d;
 
@@ -399,9 +399,9 @@ static void guess_mv(ERContext *s)
     int blocklist_length, next_blocklist_length;
 
     if (s->last_pic.f && s->last_pic.f->data[0])
-        mb_height = FFMIN(mb_height, (s->last_pic.f->height+15)>>4);
+        mb_height = FFMINI(mb_height, (s->last_pic.f->height+15)>>4);
     if (s->next_pic.f && s->next_pic.f->data[0])
-        mb_height = FFMIN(mb_height, (s->next_pic.f->height+15)>>4);
+        mb_height = FFMINI(mb_height, (s->next_pic.f->height+15)>>4);
 
     blocklist      = (int (*)[2])s->er_temp_buffer;
     next_blocklist = blocklist + s->mb_stride * s->mb_height;
@@ -440,7 +440,7 @@ static void guess_mv(ERContext *s)
     }
 
     if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
-        num_avail <= FFMAX(mb_width, mb_height) / 2) {
+        num_avail <= FFMAXI(mb_width, mb_height) / 2) {
         for (mb_y = 0; mb_y < mb_height; mb_y++) {
             for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
                 const int mb_xy = mb_x + mb_y * s->mb_stride;
@@ -585,12 +585,12 @@ static void guess_mv(ERContext *s)
                         min_x = min_y = max_x = max_y = min_r = max_r = 0;
                     }
                     for (j = 0; j < pred_count; j++) {
-                        max_x = FFMAX(max_x, mv_predictor[j][0]);
-                        max_y = FFMAX(max_y, mv_predictor[j][1]);
-                        max_r = FFMAX(max_r, ref[j]);
-                        min_x = FFMIN(min_x, mv_predictor[j][0]);
-                        min_y = FFMIN(min_y, mv_predictor[j][1]);
-                        min_r = FFMIN(min_r, ref[j]);
+                        max_x = FFMAXI(max_x, mv_predictor[j][0]);
+                        max_y = FFMAXI(max_y, mv_predictor[j][1]);
+                        max_r = FFMAXI(max_r, ref[j]);
+                        min_x = FFMINI(min_x, mv_predictor[j][0]);
+                        min_y = FFMINI(min_y, mv_predictor[j][1]);
+                        min_r = FFMINI(min_r, ref[j]);
                     }
                     mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
                     mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
@@ -740,7 +740,7 @@ static int is_intra_more_likely(ERContext *s)
     if (undamaged_count < 5)
         return 0; // almost all MBs damaged -> use temporal prediction
 
-    skip_amount     = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
+    skip_amount     = FFMAXI(undamaged_count / 50, 1); // check only up to 50 MBs
     is_intra_likely = 0;
 
     j = 0;
diff --git a/libavcodec/evrcdec.c b/libavcodec/evrcdec.c
index 44d5bee7229..82a15654892 100644
--- a/libavcodec/evrcdec.c
+++ b/libavcodec/evrcdec.c
@@ -600,7 +600,7 @@ static void postfilter(EVRCContext *e, float *in, const float *coeff,
 
     /* Long term postfilter */
     best = idx;
-    for (i = FFMIN(MIN_DELAY, idx - 3); i <= FFMAX(MAX_DELAY, idx + 3); i++) {
+    for (i = FFMINI(MIN_DELAY, idx - 3); i <= FFMAXI(MAX_DELAY, idx + 3); i++) {
         for (n = ACB_SIZE, sum2 = 0; n < ACB_SIZE + length; n++)
             sum2 += e->postfilter_residual[n] * e->postfilter_residual[n - i];
         if (sum2 > sum1) {
@@ -621,7 +621,7 @@ static void postfilter(EVRCContext *e, float *in, const float *coeff,
         if (gamma < 0.5)
             memcpy(temp, e->postfilter_residual + ACB_SIZE, length * sizeof(float));
         else {
-            gamma = FFMIN(gamma, 1.0);
+            gamma = FFMIND(gamma, 1.0);
 
             for (i = 0; i < length; i++) {
                 temp[i] = e->postfilter_residual[ACB_SIZE + i] + gamma *
@@ -715,7 +715,7 @@ static void frame_erasure(EVRCContext *e, float *samples)
                            e->avg_acb_gain, idelay, subframe_size);
             for (j = 0; j < subframe_size; j++)
                 e->pitch[ACB_SIZE + j] *= e->fade_scale;
-            e->fade_scale = FFMAX(e->fade_scale - 0.05, 0.0);
+            e->fade_scale = FFMAXD(e->fade_scale - 0.05, 0.0);
         } else {
             for (j = 0; j < subframe_size; j++)
                 e->pitch[ACB_SIZE + j] = e->energy_vector[i];
@@ -873,7 +873,7 @@ static int evrc_decode_frame(AVCodecContext *avctx, AVFrame *frame,
             /* Total excitation generation as per TIA/IS-127 5.2.3.9 */
             for (j = 0; j < subframe_size; j++)
                 e->pitch[ACB_SIZE + j] += f * tmp[j];
-            e->fade_scale = FFMIN(e->fade_scale + 0.2, 1.0);
+            e->fade_scale = FFMIND(e->fade_scale + 0.2, 1.0);
         } else {
             for (j = 0; j < subframe_size; j++)
                 e->pitch[ACB_SIZE + j] = e->energy_vector[i];
diff --git a/libavcodec/executor.c b/libavcodec/executor.c
index 7a86e894f8b..0d227751d3a 100644
--- a/libavcodec/executor.c
+++ b/libavcodec/executor.c
@@ -165,7 +165,7 @@ FFExecutor* ff_executor_alloc(const FFTaskCallbacks *cb, int thread_count)
         return NULL;
     e->cb = *cb;
 
-    e->local_contexts = av_calloc(FFMAX(thread_count, 1), e->cb.local_context_size);
+    e->local_contexts = av_calloc(FFMAXI(thread_count, 1), e->cb.local_context_size);
     if (!e->local_contexts)
         goto free_executor;
 
@@ -173,7 +173,7 @@ FFExecutor* ff_executor_alloc(const FFTaskCallbacks *cb, int thread_count)
     if (!e->q)
         goto free_executor;
 
-    e->threads = av_calloc(FFMAX(thread_count, 1), sizeof(*e->threads));
+    e->threads = av_calloc(FFMAXI(thread_count, 1), sizeof(*e->threads));
     if (!e->threads)
         goto free_executor;
 
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 0a6aab662e4..63ceaa1346b 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -628,7 +628,7 @@ static int piz_uncompress(const EXRContext *s, const uint8_t *src, int ssize,
     if (max_non_zero >= BITMAP_SIZE)
         return AVERROR_INVALIDDATA;
 
-    memset(td->bitmap, 0, FFMIN(min_non_zero, BITMAP_SIZE));
+    memset(td->bitmap, 0, FFMINI(min_non_zero, BITMAP_SIZE));
     if (min_non_zero <= max_non_zero)
         bytestream2_get_buffer(&gb, td->bitmap + min_non_zero,
                                max_non_zero - min_non_zero + 1);
@@ -860,8 +860,8 @@ static int b44_uncompress(const EXRContext *s, const uint8_t *src, int compresse
                     index_tl_x = iX * 4;
                     index_tl_y = iY * 4;
 
-                    for (y = index_tl_y; y < FFMIN(index_tl_y + 4, td->ysize); y++) {
-                        for (x = index_tl_x; x < FFMIN(index_tl_x + 4, td->xsize); x++) {
+                    for (y = index_tl_y; y < FFMINI(index_tl_y + 4, td->ysize); y++) {
+                        for (x = index_tl_x; x < FFMINI(index_tl_x + 4, td->xsize); x++) {
                             index_out = target_channel_offset * td->xsize + y * td->channel_line_size + 2 * x;
                             index_tmp = (y-index_tl_y) * 4 + (x-index_tl_x);
                             td->uncompressed_data[index_out] = tmp_buffer[index_tmp] & 0xff;
@@ -1262,9 +1262,9 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
             return AVERROR_PATCHWELCOME;
         }
 
-        if (tile_x && s->tile_attr.xSize + (int64_t)FFMAX(s->xmin, 0) >= INT_MAX / tile_x )
+        if (tile_x && s->tile_attr.xSize + (int64_t)FFMAXI(s->xmin, 0) >= INT_MAX / tile_x )
             return AVERROR_INVALIDDATA;
-        if (tile_y && s->tile_attr.ySize + (int64_t)FFMAX(s->ymin, 0) >= INT_MAX / tile_y )
+        if (tile_y && s->tile_attr.ySize + (int64_t)FFMAXI(s->ymin, 0) >= INT_MAX / tile_y )
             return AVERROR_INVALIDDATA;
 
         line = s->ymin + s->tile_attr.ySize * tile_y;
@@ -1274,8 +1274,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
             s->xmin + col  < s->xmin ||  s->xmin + col  > s->xmax)
             return AVERROR_INVALIDDATA;
 
-        td->ysize = FFMIN(s->tile_attr.ySize, s->ydelta - tile_y * s->tile_attr.ySize);
-        td->xsize = FFMIN(s->tile_attr.xSize, s->xdelta - tile_x * s->tile_attr.xSize);
+        td->ysize = FFMINI(s->tile_attr.ySize, s->ydelta - tile_y * s->tile_attr.ySize);
+        td->xsize = FFMINI(s->tile_attr.xSize, s->xdelta - tile_x * s->tile_attr.xSize);
 
         if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
             av_image_check_size2(td->xsize, td->ysize, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx) < 0)
@@ -1299,7 +1299,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
         if (data_size <= 0 || data_size > buf_size - line_offset - 8)
             return AVERROR_INVALIDDATA;
 
-        td->ysize          = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */
+        td->ysize          = FFMINI(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */
         td->xsize          = s->xdelta;
 
         if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
@@ -1317,10 +1317,10 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
         }
     }
 
-    window_xmin = FFMIN(avctx->width, FFMAX(0, s->xmin + col));
-    window_xmax = FFMIN(avctx->width, FFMAX(0, s->xmin + col + td->xsize));
-    window_ymin = FFMIN(avctx->height, FFMAX(0, line ));
-    window_ymax = FFMIN(avctx->height, FFMAX(0, line + td->ysize));
+    window_xmin = FFMINI(avctx->width, FFMAXI(0, s->xmin + col));
+    window_xmax = FFMINI(avctx->width, FFMAXI(0, s->xmin + col + td->xsize));
+    window_ymin = FFMINI(avctx->height, FFMAXI(0, line ));
+    window_ymax = FFMINI(avctx->height, FFMAXI(0, line + td->ysize));
     xsize = window_xmax - window_xmin;
     ysize = window_ymax - window_ymin;
 
@@ -1332,7 +1332,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
     if(col == 0) {
         window_xmin = 0;
         /* pixels to add at the left of the display window */
-        window_xoffset = FFMAX(0, s->xmin);
+        window_xoffset = FFMAXI(0, s->xmin);
         /* bytes to add at the left of the display window */
         bxmin = window_xoffset * step;
     }
@@ -1341,7 +1341,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
     if(col + td->xsize == s->xdelta) {
         window_xmax = avctx->width;
          /* bytes to add at the right of the display window */
-        axmax = FFMAX(0, (avctx->width - (s->xmax + 1))) * step;
+        axmax = FFMAXI(0, (avctx->width - (s->xmax + 1))) * step;
     }
 
     if (avctx->max_pixels && uncompressed_size > avctx->max_pixels * 16LL)
@@ -1392,8 +1392,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
     }
 
     /* offsets to crop data outside display window */
-    data_xoffset = FFABS(FFMIN(0, s->xmin + col)) * (s->pixel_type == EXR_HALF ? 2 : 4);
-    data_yoffset = FFABS(FFMIN(0, line));
+    data_xoffset = FFABS(FFMINI(0, s->xmin + col)) * (s->pixel_type == EXR_HALF ? 2 : 4);
+    data_yoffset = FFABS(FFMINI(0, line));
     data_window_offset = (data_yoffset * td->channel_line_size) + data_xoffset;
 
     if (s->channel_offsets[3] >= 0)
@@ -1934,7 +1934,7 @@ static int decode_header(EXRContext *s, AVFrame *frame)
                                                      "string", 1)) >= 0) {
             uint8_t key[256] = { 0 };
 
-            bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
+            bytestream2_get_buffer(gb, key, FFMINI(sizeof(key) - 1, var_size));
             av_dict_set(&metadata, "writer", key, 0);
 
             continue;
@@ -1959,7 +1959,7 @@ static int decode_header(EXRContext *s, AVFrame *frame)
                                                      "string", 16)) >= 0) {
             uint8_t key[256] = { 0 };
 
-            bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
+            bytestream2_get_buffer(gb, key, FFMINI(sizeof(key) - 1, var_size));
             if (strncmp("scanlineimage", key, var_size) &&
                 strncmp("tiledimage", key, var_size)) {
                 ret = AVERROR_PATCHWELCOME;
@@ -2016,7 +2016,7 @@ static int decode_header(EXRContext *s, AVFrame *frame)
             bytestream2_skip(gb, 1);
             size = bytestream2_get_le32(gb);
 
-            bytestream2_get_buffer(gb, value, FFMIN(sizeof(value) - 1, size));
+            bytestream2_get_buffer(gb, value, FFMINI(sizeof(value) - 1, size));
             if (size > sizeof(value) - 1)
                 bytestream2_skip(gb, size - (sizeof(value) - 1));
             if (!strcmp(type, "string"))
@@ -2224,7 +2224,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
     // Zero out the start if ymin is not 0
     for (i = 0; i < planes; i++) {
         ptr = picture->data[i];
-        for (y = 0; y < FFMIN(s->ymin, s->h); y++) {
+        for (y = 0; y < FFMINI(s->ymin, s->h); y++) {
             memset(ptr, 0, out_line_size);
             ptr += picture->linesize[i];
         }
@@ -2234,7 +2234,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
 
     avctx->execute2(avctx, decode_block, s->thread_data, NULL, nb_blocks);
 
-    ymax = FFMAX(0, s->ymax + 1);
+    ymax = FFMAXI(0, s->ymax + 1);
     // Zero out the end if ymax+1 is not h
     if (ymax < avctx->height)
         for (i = 0; i < planes; i++) {
diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c
index c9685890ea8..72a54016139 100644
--- a/libavcodec/exrenc.c
+++ b/libavcodec/exrenc.c
@@ -282,7 +282,7 @@ static int encode_scanline_zip(EXRContext *s, const AVFrame *frame)
 
     for (int y = 0; y < s->nb_scanlines; y++) {
         EXRScanlineData *scanline = &s->scanline[y];
-        const int scanline_height = FFMIN(s->scanline_height, frame->height - y * s->scanline_height);
+        const int scanline_height = FFMINI(s->scanline_height, frame->height - y * s->scanline_height);
         int64_t tmp_size = element_size * s->planes * frame->width * scanline_height;
         int64_t max_compressed_size = tmp_size * 3 / 2;
         unsigned long actual_size, source_size;
diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c
index ee31a06f18f..59c2f8ca0cf 100644
--- a/libavcodec/fastaudio.c
+++ b/libavcodec/fastaudio.c
@@ -148,7 +148,7 @@ static int fastaudio_decode(AVCodecContext *avctx, AVFrame *frame,
                     if (j % 10 == 9)
                         tmp = 4 * tmp + read_bits(2, &pos, src);
                     if (j == 20)
-                        index5 = FFMIN(2 * index5 + tmp % 2, 63);
+                        index5 = FFMINI(2 * index5 + tmp % 2, 63);
                 }
 
                 m[2] = s->table[5][index5];
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 885cef265f7..eacc745bbb1 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -211,7 +211,7 @@ void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1SliceContext *sc)
         } else {
             for (j = 0; j < p->context_count; j++) {
                 p->vlc_state[j].drift     = 0;
-                p->vlc_state[j].error_sum = 4;    //FFMAX((RANGE + 32)/64, 2);
+                p->vlc_state[j].error_sum = 4;    //FFMAXI((RANGE + 32)/64, 2);
                 p->vlc_state[j].bias      = 0;
                 p->vlc_state[j].count     = 1;
             }
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index ee0a1a78584..107b4fb5c59 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -235,13 +235,13 @@ static inline void update_vlc_state(VlcState *const state, const int v)
     count++;
 
     if (drift <= -count) {
-        state->bias = FFMAX(state->bias - 1, -128);
+        state->bias = FFMAXI(state->bias - 1, -128);
 
-        drift = FFMAX(drift + count, -count + 1);
+        drift = FFMAXI(drift + count, -count + 1);
     } else if (drift > 0) {
-        state->bias = FFMIN(state->bias + 1, 127);
+        state->bias = FFMINI(state->bias + 1, 127);
 
-        drift = FFMIN(drift - count, 0);
+        drift = FFMINI(drift - count, 0);
     }
 
     state->drift = drift;
@@ -258,7 +258,7 @@ static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state,
         int e;
         unsigned a;
         e = 0;
-        while (get_rac(c, state + 1 + FFMIN(e, 9))) { // 1..10
+        while (get_rac(c, state + 1 + FFMINI(e, 9))) { // 1..10
             e++;
             if (e > 31)
                 return AVERROR_INVALIDDATA;
@@ -266,9 +266,9 @@ static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state,
 
         a = 1;
         for (int i = e - 1; i >= 0; i--)
-            a += a + get_rac(c, state + 22 + FFMIN(i, 9));  // 22..31
+            a += a + get_rac(c, state + 22 + FFMINI(i, 9));  // 22..31
 
-        e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); // 11..21
+        e = -(is_signed && get_rac(c, state + 11 + FFMINI(e, 10))); // 11..21
         return (a ^ e) - e;
     }
 }
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 463f46e091e..259ed3c102b 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -152,7 +152,7 @@ static void find_best_state(uint8_t best_state[256][256],
         for (j = 0; j < 256; j++)
             best_len[j] = UINT64_MAX;
 
-        for (j = FFMAX(i - 10, 1); j < FFMIN(i + 11, 256); j++) {
+        for (j = FFMAXI(i - 10, 1); j < FFMINI(i + 11, 256); j++) {
             uint32_t occ[256] = { 0 };
             uint64_t len      = 0;
             occ[j] = UINT32_MAX;
@@ -215,11 +215,11 @@ static av_always_inline av_flatten void put_symbol_inline(RangeCoder *c,
                 put_rac(c, state + 11 + e, v < 0);  // 11..21
         } else {
             for (i = 0; i < e; i++)
-                put_rac(c, state + 1 + FFMIN(i, 9), 1);  // 1..10
+                put_rac(c, state + 1 + FFMINI(i, 9), 1);  // 1..10
             put_rac(c, state + 1 + 9, 0);
 
             for (i = e - 1; i >= 0; i--)
-                put_rac(c, state + 22 + FFMIN(i, 9), (a >> i) & 1);  // 22..31
+                put_rac(c, state + 22 + FFMINI(i, 9), (a >> i) & 1);  // 22..31
 
             if (is_signed)
                 put_rac(c, state + 11 + 10, v < 0);  // 11..21
@@ -568,7 +568,7 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
     int max_h_slices = AV_CEIL_RSHIFT(avctx->width , s->chroma_h_shift);
     int max_v_slices = AV_CEIL_RSHIFT(avctx->height, s->chroma_v_shift);
     s->num_v_slices = (avctx->width > 352 || avctx->height > 288 || !avctx->slices) ? 2 : 1;
-    s->num_v_slices = FFMIN(s->num_v_slices, max_v_slices);
+    s->num_v_slices = FFMINI(s->num_v_slices, max_v_slices);
     for (; s->num_v_slices <= 32; s->num_v_slices++) {
         for (s->num_h_slices = s->num_v_slices; s->num_h_slices <= 2*s->num_v_slices; s->num_h_slices++) {
             int maxw = (avctx->width  + s->num_h_slices - 1) / s->num_h_slices;
@@ -603,7 +603,7 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx)
 
     if ((avctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) ||
         avctx->slices > 1)
-        s->version = FFMAX(s->version, 2);
+        s->version = FFMAXI(s->version, 2);
 
     if ((avctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) && s->ac == AC_GOLOMB_RICE) {
         av_log(avctx, AV_LOG_ERROR, "2 Pass mode is not possible with golomb coding\n");
@@ -612,7 +612,7 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx)
 
     // Unspecified level & slices, we choose version 1.2+ to ensure multithreaded decodability
     if (avctx->slices == 0 && avctx->level < 0 && avctx->width * avctx->height > 720*576)
-        s->version = FFMAX(s->version, 2);
+        s->version = FFMAXI(s->version, 2);
 
     if (avctx->level <= 0 && s->version == 2) {
         s->version = 3;
@@ -637,9 +637,9 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx)
 
     // CRC requires version 3+
     if (s->ec == 1)
-        s->version = FFMAX(s->version, 3);
+        s->version = FFMAXI(s->version, 3);
     if (s->ec == 2) {
-        s->version = FFMAX(s->version, 4);
+        s->version = FFMAXI(s->version, 4);
         s->crcref = 0x7a8c4079;
     }
 
@@ -860,7 +860,7 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
             av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample invalid\n");
             return AVERROR_INVALIDDATA;
         }
-        s->version = FFMAX(s->version, 1);
+        s->version = FFMAXI(s->version, 1);
     case AV_PIX_FMT_GRAY8:
     case AV_PIX_FMT_YA8:
     case AV_PIX_FMT_NV12:
@@ -895,14 +895,14 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
         s->chroma_planes = 1;
         s->bits_per_raw_sample = 16;
         s->use32bit = 1;
-        s->version = FFMAX(s->version, 1);
+        s->version = FFMAXI(s->version, 1);
         break;
     case AV_PIX_FMT_RGB48:
         s->colorspace = 1;
         s->chroma_planes = 1;
         s->bits_per_raw_sample = 16;
         s->use32bit = 1;
-        s->version = FFMAX(s->version, 1);
+        s->version = FFMAXI(s->version, 1);
         break;
     case AV_PIX_FMT_0RGB32:
         s->colorspace = 1;
@@ -942,7 +942,7 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
         if (s->bits_per_raw_sample >= 16) {
             s->use32bit = 1;
         }
-        s->version = FFMAX(s->version, 1);
+        s->version = FFMAXI(s->version, 1);
         break;
     default:
         av_log(avctx, AV_LOG_ERROR, "format %s not supported\n",
@@ -951,7 +951,7 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
     }
     s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
     if (s->flt || s->remap_mode > 0)
-        s->version = FFMAX(s->version, 4);
+        s->version = FFMAXI(s->version, 4);
     av_assert0(s->bits_per_raw_sample >= 8);
 
     if (s->remap_mode < 0)
@@ -1320,7 +1320,7 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc,
 
         if (last_val != val) {
             int64_t delta = val - last_val;
-            int64_t step  = FFMAX(1, (delta + current_mul/2) / current_mul);
+            int64_t step  = FFMAXI(1, (delta + current_mul/2) / current_mul);
             av_assert2(last_val < val);
             av_assert2(current_mul > 0);
 
@@ -1445,7 +1445,7 @@ static void encode_float32_remap(FFV1Context *f, FFV1SliceContext *sc,
                             mul = (0x10001LL)<<si >> 16;
                         }
 
-                        cost = FFMAX((delta + mul/2)  / mul, 1);
+                        cost = FFMAXI((delta + mul/2)  / mul, 1);
                         float score = 1;
                         if (mul > 1) {
                             score *= (FFABS(delta - cost*mul)+1);
diff --git a/libavcodec/ffv1enc_vulkan.c b/libavcodec/ffv1enc_vulkan.c
index 259bc75d4c8..2956aea5d78 100644
--- a/libavcodec/ffv1enc_vulkan.c
+++ b/libavcodec/ffv1enc_vulkan.c
@@ -1496,8 +1496,8 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx)
             f->num_h_slices = MAX_SLICES / f->num_v_slices;
         }
 
-        f->num_h_slices = FFMIN(f->num_h_slices, avctx->width);
-        f->num_v_slices = FFMIN(f->num_v_slices, avctx->height);
+        f->num_h_slices = FFMINI(f->num_h_slices, avctx->width);
+        f->num_v_slices = FFMINI(f->num_v_slices, avctx->height);
 
         if (f->num_h_slices * f->num_v_slices > MAX_SLICES) {
             av_log(avctx, AV_LOG_ERROR, "Too many slices (%i), maximum supported "
diff --git a/libavcodec/fic.c b/libavcodec/fic.c
index ec26e3154d3..a970b69d38b 100644
--- a/libavcodec/fic.c
+++ b/libavcodec/fic.c
@@ -249,8 +249,8 @@ static void fic_draw_cursor(AVCodecContext *avctx, int cur_x, int cur_y)
                     (cur_x >> !!i) + !!i;
 
     /* Copy. */
-    for (i = 0; i < FFMIN(32, avctx->height - cur_y) - 1; i += 2) {
-        int lsize = FFMIN(32, avctx->width - cur_x);
+    for (i = 0; i < FFMINI(32, avctx->height - cur_y) - 1; i += 2) {
+        int lsize = FFMINI(32, avctx->width - cur_x);
         int csize = lsize / 2;
 
         fic_alpha_blend(dstptr[0],
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index d9c47801f83..dadd29789f8 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -179,7 +179,7 @@ static uint8_t *flac_fifo_read_wrap(FLACParseContext *fpc, int offset, int len,
     }
     *wrap_buf = tmp_buf;
     do {
-        int seg_len = FFMIN(f->end - start, len);
+        int seg_len = FFMINI(f->end - start, len);
         memcpy(tmp_buf, start, seg_len);
         tmp_buf = (uint8_t*)tmp_buf + seg_len;
 // memory barrier needed for SMP here in theory
@@ -204,7 +204,7 @@ static uint8_t *flac_fifo_read(FifoBuffer *f, int offset, int *len)
 
     if (start >= f->end)
         start -= f->end - f->buffer;
-    *len = FFMIN(*len, f->end - start);
+    *len = FFMINI(*len, f->end - start);
     return start;
 }
 
@@ -228,7 +228,7 @@ static int flac_fifo_grow(FifoBuffer *f, size_t inc)
     // move the data from the beginning of the ring buffer
     // to the newly allocated space
     if (offset_w <= offset_r && !f->empty) {
-        const size_t copy = FFMIN(inc, offset_w);
+        const size_t copy = FFMINI(inc, offset_w);
         memcpy(tmp + size_old, tmp, copy);
         if (copy < offset_w) {
             memmove(tmp, tmp + copy, offset_w - copy);
@@ -250,7 +250,7 @@ static int flac_fifo_write(FifoBuffer *f, const uint8_t *src, size_t size)
     uint8_t *wptr;
 
     if (flac_fifo_space(f) < size) {
-        int ret = flac_fifo_grow(f, FFMAX(flac_fifo_size(f), size));
+        int ret = flac_fifo_grow(f, FFMAXI(flac_fifo_size(f), size));
         if (ret < 0)
             return ret;
     }
@@ -260,7 +260,7 @@ static int flac_fifo_write(FifoBuffer *f, const uint8_t *src, size_t size)
 
     wptr = f->wptr;
     do {
-        size_t len = FFMIN(f->end - wptr, size);
+        size_t len = FFMINI(f->end - wptr, size);
         memcpy(wptr, src, len);
         src  += len;
         wptr += len;
@@ -356,7 +356,7 @@ static int find_headers_search(FLACParseContext *fpc, uint8_t *buf,
     for (i = 0; i < mod_offset; i++) {
         if ((AV_RB16(buf + i) & 0xFFFE) == 0xFFF8) {
             int ret = find_headers_search_validate(fpc, search_start + i);
-            size = FFMAX(size, ret);
+            size = FFMAXI(size, ret);
         }
     }
 
@@ -366,7 +366,7 @@ static int find_headers_search(FLACParseContext *fpc, uint8_t *buf,
             for (j = 0; j < 4; j++) {
                 if ((AV_RB16(buf + i + j) & 0xFFFE) == 0xFFF8) {
                     int ret = find_headers_search_validate(fpc, search_start + i + j);
-                    size = FFMAX(size, ret);
+                    size = FFMAXI(size, ret);
                 }
             }
         }
@@ -401,13 +401,13 @@ static int find_new_headers(FLACParseContext *fpc, int search_start)
 
         if ((AV_RB16(wrap) & 0xFFFE) == 0xFFF8) {
             temp = find_headers_search_validate(fpc, search_start);
-            size = FFMAX(size, temp);
+            size = FFMAXI(size, temp);
         }
         search_start++;
 
         /* Continue to do the last half of the wrap. */
         temp     = find_headers_search(fpc, buf, read_len, search_start);
-        size     = FFMAX(size, temp);
+        size     = FFMAXI(size, temp);
         search_start += read_len - 1;
     }
 
@@ -764,7 +764,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
             /* The maximum read size is the upper-bound of what the parser
                needs to have the required number of frames buffered */
             int nb_desired = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1;
-            read_end       = read_end + FFMIN(buf + buf_size - read_end,
+            read_end       = read_end + FFMINI(buf + buf_size - read_end,
                                               nb_desired * FLAC_AVG_FRAME_SIZE);
         }
 
@@ -793,7 +793,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
         /* Tag headers and update sequences. */
         start_offset = flac_fifo_size(&fpc->fifo_buf) -
                        ((read_end - read_start) + (MAX_FRAME_HEADER_SIZE - 1));
-        start_offset = FFMAX(0, start_offset);
+        start_offset = FFMAXI(0, start_offset);
         nb_headers   = find_new_headers(fpc, start_offset);
 
         if (nb_headers < 0) {
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index c6b9eb437a5..228711f3eef 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -597,7 +597,7 @@ static uint64_t subframe_count_exact(FlacEncodeContext *s, FlacSubframe *sub,
             count += sub->rc.coding_mode;
             count += rice_count_exact(&sub->residual[i], part_end - i, k);
             i = part_end;
-            part_end = FFMIN(s->frame.blocksize, part_end + psize);
+            part_end = FFMINI(s->frame.blocksize, part_end + psize);
         }
     }
 
@@ -619,7 +619,7 @@ static int find_optimal_param(uint64_t sum, int n, int max_param)
         return 0;
     sum2 = sum - (n >> 1);
     k    = av_log2(av_clipl_int32(sum2 / n));
-    return FFMIN(k, max_param);
+    return FFMINI(k, max_param);
 }
 
 static int find_optimal_param_exact(uint64_t sums[32][MAX_PARTITIONS], int i, int max_param)
@@ -751,9 +751,9 @@ static uint64_t calc_rice_params(RiceContext *rc,
 
 static int get_max_p_order(int max_porder, int n, int order)
 {
-    int porder = FFMIN(max_porder, av_log2(n^(n-1)));
+    int porder = FFMINI(max_porder, av_log2(n^(n-1)));
     if (order > 0)
-        porder = FFMIN(porder, av_log2(n/order));
+        porder = FFMINI(porder, av_log2(n/order));
     return porder;
 }
 
diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index d27918c9237..f03b71db03f 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -171,7 +171,7 @@ static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size)
     if (zret != Z_OK)
         return AVERROR_UNKNOWN;
     while (remaining > 0) {
-        unsigned block_size = FFMIN(UINT16_MAX, remaining);
+        unsigned block_size = FFMINI(UINT16_MAX, remaining);
         uint8_t header[5];
         /* Bit 0: Non-last-block, bits 1-2: BTYPE for uncompressed block */
         header[0] = 0;
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index f952a06f122..1059ac860c1 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -895,8 +895,8 @@ static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y,
         return AVERROR_INVALIDDATA;
     }
 
-    tile_width  = FFMIN(c->width  - tile_x * c->tile_width,  c->tile_width);
-    tile_height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
+    tile_width  = FFMINI(c->width  - tile_x * c->tile_width,  c->tile_width);
+    tile_height = FFMINI(c->height - tile_y * c->tile_height, c->tile_height);
     awidth      = FFALIGN(tile_width,  16);
     aheight     = FFALIGN(tile_height, 16);
 
@@ -1064,8 +1064,8 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
     if (src_size < 2)
         return AVERROR_INVALIDDATA;
 
-    width  = FFMIN(c->width  - tile_x * c->tile_width,  c->tile_width);
-    height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
+    width  = FFMINI(c->width  - tile_x * c->tile_width,  c->tile_width);
+    height = FFMINI(c->height - tile_y * c->tile_height, c->tile_height);
 
     hdr      = *src++;
     sub_type = hdr >> 5;
@@ -1227,8 +1227,8 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
     if (cursor_hot_x > cursor_w || cursor_hot_y > cursor_h) {
         av_log(avctx, AV_LOG_WARNING, "Invalid hotspot position %"PRIu32",%"PRIu32"\n",
                cursor_hot_x, cursor_hot_y);
-        cursor_hot_x = FFMIN(cursor_hot_x, cursor_w - 1);
-        cursor_hot_y = FFMIN(cursor_hot_y, cursor_h - 1);
+        cursor_hot_x = FFMINI(cursor_hot_x, cursor_w - 1);
+        cursor_hot_y = FFMINI(cursor_hot_y, cursor_h - 1);
     }
     if (cur_size - 9 > bytestream2_get_bytes_left(gb) ||
         c->cursor_w * c->cursor_h / 4 > cur_size) {
diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index d19d09dd899..a02120abb7c 100644
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -1110,7 +1110,7 @@ int ff_g723_1_scale_vector(int16_t *dst, const int16_t *vector, int length)
         max |= FFABS(vector[i]);
 
     bits= 14 - av_log2_16bit(max);
-    bits= FFMAX(bits, 0);
+    bits= FFMAXI(bits, 0);
 
     for (i = 0; i < length; i++)
         dst[i] = (vector[i] * (1 << bits)) >> 3;
@@ -1305,8 +1305,8 @@ void ff_g723_1_inverse_quant(int16_t *cur_lsp, int16_t *prev_lsp,
     }
 
     for (i = 0; i < LPC_ORDER; i++) {
-        cur_lsp[0]             = FFMAX(cur_lsp[0],  0x180);
-        cur_lsp[LPC_ORDER - 1] = FFMIN(cur_lsp[LPC_ORDER - 1], 0x7e00);
+        cur_lsp[0]             = FFMAXI(cur_lsp[0],  0x180);
+        cur_lsp[LPC_ORDER - 1] = FFMINI(cur_lsp[LPC_ORDER - 1], 0x7e00);
 
         /* Stability check */
         for (j = 1; j < LPC_ORDER; j++) {
diff --git a/libavcodec/g723_1_parser.c b/libavcodec/g723_1_parser.c
index 2ed1a8ab192..f76f96809c3 100644
--- a/libavcodec/g723_1_parser.c
+++ b/libavcodec/g723_1_parser.c
@@ -37,7 +37,7 @@ static int g723_1_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
     int next = END_NOT_FOUND;
 
     if (buf_size > 0)
-        next = frame_size[buf[0] & 3] * FFMAX(1, avctx->ch_layout.nb_channels);
+        next = frame_size[buf[0] & 3] * FFMAXI(1, avctx->ch_layout.nb_channels);
 
     if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {
         *poutbuf      = NULL;
diff --git a/libavcodec/g723_1dec.c b/libavcodec/g723_1dec.c
index 67a5df55ff0..cdf612b0be9 100644
--- a/libavcodec/g723_1dec.c
+++ b/libavcodec/g723_1dec.c
@@ -351,9 +351,9 @@ static int autocorr_max(const int16_t *buf, int offset, int *ccr_max,
     int limit, ccr, lag = 0;
     int i;
 
-    pitch_lag = FFMIN(PITCH_MAX - 3, pitch_lag);
+    pitch_lag = FFMINI(PITCH_MAX - 3, pitch_lag);
     if (dir > 0)
-        limit = FFMIN(FRAME_LEN + PITCH_MAX - offset - length, pitch_lag + 3);
+        limit = FFMINI(FRAME_LEN + PITCH_MAX - offset - length, pitch_lag + 3);
     else
         limit = pitch_lag + 3;
 
@@ -472,7 +472,7 @@ static void comp_ppf_coeff(G723_1_ChannelContext *p, int offset, int pitch_lag,
     /* Normalize and shorten */
     temp1 = 0;
     for (i = 0; i < 5; i++)
-        temp1 = FFMAX(energy[i], temp1);
+        temp1 = FFMAXI(energy[i], temp1);
 
     scale = ff_g723_1_normalize_bits(temp1, 31);
     for (i = 0; i < 5; i++)
@@ -766,7 +766,7 @@ static int estimate_sid_gain(G723_1_ChannelContext *p)
         shift = 3;
         seg   = (x >= cng_bseg[0]);
     }
-    seg2 = FFMIN(seg, 3);
+    seg2 = FFMINI(seg, 3);
 
     val     = 1 << shift;
     val_add = val >> 1;
@@ -856,7 +856,7 @@ static void generate_noise(G723_1_ChannelContext *p)
         t = 0;
         for (j = 0; j < SUBFRAME_LEN * 2; j++)
             t |= FFABS(vector_ptr[j]);
-        t = FFMIN(t, 0x7FFF);
+        t = FFMINI(t, 0x7FFF);
         if (!t) {
             shift = 0;
         } else {
diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c
index ee5b0fe2514..2384918fa43 100644
--- a/libavcodec/g723_1enc.c
+++ b/libavcodec/g723_1enc.c
@@ -271,7 +271,7 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
     /* Normalize and shorten */
     max = FFABS(f[0]);
     for (i = 1; i < LPC_ORDER + 2; i++)
-        max = FFMAX(max, FFABS(f[i]));
+        max = FFMAXI(max, FFABS(f[i]));
 
     shift = ff_g723_1_normalize_bits(max, 31);
 
@@ -371,7 +371,7 @@ static void lsp_quantize(uint8_t *lsp_index, int16_t *lsp, int16_t *prev_lsp)
                             (lsp[LPC_ORDER - 1] - lsp[LPC_ORDER - 2]);
 
     for (i = 1; i < LPC_ORDER - 1; i++) {
-        min = FFMIN(lsp[i] - lsp[i - 1], lsp[i + 1] - lsp[i]);
+        min = FFMINI(lsp[i] - lsp[i - 1], lsp[i + 1] - lsp[i]);
         if (min > 0x20)
             weight[i] = (1 << 20) / min;
         else
@@ -381,7 +381,7 @@ static void lsp_quantize(uint8_t *lsp_index, int16_t *lsp, int16_t *prev_lsp)
     /* Normalize */
     max = 0;
     for (i = 0; i < LPC_ORDER; i++)
-        max = FFMAX(weight[i], max);
+        max = FFMAXI(weight[i], max);
 
     shift = ff_g723_1_normalize_bits(max, 15);
     for (i = 0; i < LPC_ORDER; i++) {
@@ -555,7 +555,7 @@ static void comp_harmonic_coeff(int16_t *buf, int16_t pitch_lag, HFParam *hf)
     /* Normalize */
     max = 0;
     for (i = 0; i < 15; i++)
-        max = FFMAX(max, FFABS(energy[i]));
+        max = FFMAXI(max, FFABS(energy[i]));
 
     exp = ff_g723_1_normalize_bits(max, 31);
     for (i = 0; i < 15; i++) {
@@ -704,7 +704,7 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual,
         if (pitch_lag == PITCH_MIN)
             pitch_lag++;
         else
-            pitch_lag = FFMIN(pitch_lag, PITCH_MAX - 5);
+            pitch_lag = FFMINI(pitch_lag, PITCH_MAX - 5);
     }
 
     for (i = 0; i < iter; i++) {
@@ -749,7 +749,7 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual,
     /* Normalize and shorten */
     max = 0;
     for (i = 0; i < 20 * iter; i++)
-        max = FFMAX(max, FFABS(ccr_buf[i]));
+        max = FFMAXI(max, FFABS(ccr_buf[i]));
 
     temp = ff_g723_1_normalize_bits(max, 31);
 
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 7499ed74442..646a3041b79 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -295,7 +295,7 @@ static int g729d_onset_decision(int past_onset, const int16_t* past_gain_code)
     if ((past_gain_code[0] >> 1) > past_gain_code[1])
         return 2;
 
-    return FFMAX(past_onset-1, 0);
+    return FFMAXI(past_onset-1, 0);
 }
 
 /**
@@ -591,7 +591,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                     /* Without check below overflow can occur in ff_acelp_update_past_gain.
                        It is not issue for G.729, because gain_corr_factor in it's case is always
                        greater than 1024, while in G.729D it can be even zero. */
-                    gain_corr_factor = FFMAX(gain_corr_factor, 1024);
+                    gain_corr_factor = FFMAXI(gain_corr_factor, 1024);
     #ifndef G729_BITEXACT
                     gain_corr_factor >>= 1;
     #endif
@@ -717,7 +717,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                     ctx->gain_coeff);
 
             if (frame_erasure) {
-                ctx->pitch_delay_int_prev = FFMIN(ctx->pitch_delay_int_prev + 1, PITCH_DELAY_MAX);
+                ctx->pitch_delay_int_prev = FFMINI(ctx->pitch_delay_int_prev + 1, PITCH_DELAY_MAX);
             } else {
                 ctx->pitch_delay_int_prev = pitch_delay_int[i];
             }
diff --git a/libavcodec/g729postfilter.c b/libavcodec/g729postfilter.c
index b1880b2fe13..0a59ae592ac 100644
--- a/libavcodec/g729postfilter.c
+++ b/libavcodec/g729postfilter.c
@@ -169,7 +169,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
                                     subframe_size);
     if (ener) {
         sh_ener = av_log2(ener) - 14;
-        sh_ener = FFMAX(sh_ener, 0);
+        sh_ener = FFMAXI(sh_ener, 0);
         ener >>= sh_ener;
         /* Search for best pitch delay.
 
@@ -243,7 +243,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
             sh_gain_den = av_log2(tmp) - 14;
             if (sh_gain_den >= 0) {
 
-                sh_gain_num =  FFMAX(sh_gain_den, sh_ener);
+                sh_gain_num =  FFMAXI(sh_gain_den, sh_ener);
                 /* Loop through all k and find delay that maximizes
                    R'(k) correlation.
                    Search is done in [int(T0)-1; intT(0)+1] range
@@ -262,7 +262,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
                         sum = adsp->scalarproduct_int16(&delayed_signal[k][i],
                                                        sig_scaled + RES_PREV_DATA_SIZE,
                                                        subframe_size);
-                        gain_num_short = FFMAX(sum >> sh_gain_num, 0);
+                        gain_num_short = FFMAXI(sum >> sh_gain_num, 0);
 
                         /*
                                       gain_num_short_square                gain_num_square
@@ -325,7 +325,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
             sh_gain_long_num = 0;
         } else {
             tmp = av_log2(sum) - 14;
-            tmp = FFMAX(tmp, 0);
+            tmp = FFMAXI(tmp, 0);
             sum >>= tmp;
             gain_long_num = sum;
             sh_gain_long_num = tmp;
@@ -335,7 +335,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
         sum = adsp->scalarproduct_int16(residual_filt, residual_filt, subframe_size);
 
         tmp = av_log2(sum) - 14;
-        tmp = FFMAX(tmp, 0);
+        tmp = FFMAXI(tmp, 0);
         sum >>= tmp;
         gain_long_den = sum;
         sh_gain_long_den = tmp;
@@ -353,7 +353,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
         if (tmp > 0)
             L_temp0 >>= tmp;
         else
-            L_temp1 >>= FFMIN(-tmp, 31);
+            L_temp1 >>= FFMINI(-tmp, 31);
 
         /* Check if longer filter increases the values of R'(k). */
         if (L_temp1 > L_temp0) {
@@ -397,7 +397,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
 #else
     L64_temp0 = (((int64_t)gain_num) << sh_gain_num) >> 1;
     L64_temp1 = ((int64_t)gain_den) << sh_gain_den;
-    lt_filt_factor_a = FFMAX((L64_temp1 << 15) / (L64_temp1 + L64_temp0), MIN_LT_FILT_FACTOR_A);
+    lt_filt_factor_a = FFMAXI((L64_temp1 << 15) / (L64_temp1 + L64_temp0), MIN_LT_FILT_FACTOR_A);
 #endif
 
     /* Filter through selected filter. */
@@ -550,7 +550,7 @@ void ff_g729_postfilter(AudioDSPContext *adsp, int16_t* ht_prev_data, int* voici
     i = long_term_filter(adsp, pitch_delay_int,
                                                 residual, residual_filt_buf + 10,
                                                 subframe_size);
-    *voicing = FFMAX(*voicing, i);
+    *voicing = FFMAXI(*voicing, i);
 
     /* shift residual for using in next subframe */
     memmove(residual, residual + subframe_size, RES_PREV_DATA_SIZE * sizeof(int16_t));
@@ -603,7 +603,7 @@ int16_t ff_g729_adaptive_gain_control(int gain_before, int gain_after, int16_t *
             gain = ((gain_before - gain_after) << 14) / gain_after + 0x4000;
             gain = bidir_sal(gain, exp_after - exp_before);
         }
-        gain = FFMIN(gain, 32767);
+        gain = FFMINI(gain, 32767);
         gain = (gain * G729_AGC_FAC1 + 0x4000) >> 15; // gain * (1-0.9875)
     } else
         gain = 0;
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 19542965697..b0691042409 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -216,7 +216,7 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
 #   define SKIP_COUNTER(name, gb, num) name ## _index += (num)
 #else
 #   define SKIP_COUNTER(name, gb, num) \
-    name ## _index = FFMIN(name ## _size_plus8, name ## _index + (num))
+    name ## _index = FFMINI(name ## _size_plus8, name ## _index + (num))
 #endif
 
 #define BITS_LEFT(name, gb) ((int)((gb)->size_in_bits - name ## _index))
@@ -500,7 +500,7 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
     int buffer_size;
     int ret = 0;
 
-    if (bit_size >= INT_MAX - FFMAX(7, AV_INPUT_BUFFER_PADDING_SIZE*8) || bit_size < 0 || !buffer) {
+    if (bit_size >= INT_MAX - FFMAXI(7, AV_INPUT_BUFFER_PADDING_SIZE*8) || bit_size < 0 || !buffer) {
         bit_size    = 0;
         buffer      = NULL;
         ret         = AVERROR_INVALIDDATA;
diff --git a/libavcodec/get_buffer.c b/libavcodec/get_buffer.c
index b391adf24f4..1e04dde4f6a 100644
--- a/libavcodec/get_buffer.c
+++ b/libavcodec/get_buffer.c
@@ -192,7 +192,7 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
         av_assert0(frame->nb_extended_buf == 0);
     }
 
-    for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) {
+    for (i = 0; i < FFMINI(planes, AV_NUM_DATA_POINTERS); i++) {
         frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
         if (!frame->buf[i])
             goto fail;
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index 04f5341ea79..ae5f5afdd8c 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -435,7 +435,7 @@ static int gif_image_write_image(AVCodecContext *avctx,
 
     ptr = s->buf;
     while (len > 0) {
-        int size = FFMIN(255, len);
+        int size = FFMINI(255, len);
         bytestream_put_byte(bytestream, size);
         if (end - *bytestream < size)
             return -1;
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 742334978d5..d9a964d72a3 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -187,7 +187,7 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb)
         do {
             buf >>= 32 - 8;
             LAST_SKIP_BITS(re, gb,
-                           FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
+                           FFMINI(ff_interleaved_golomb_vlc_len[buf], 8));
 
             if (ff_interleaved_golomb_vlc_len[buf] != 9) {
                 ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index fa57911c08b..e6eb6d689eb 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -431,7 +431,7 @@ static void alloc_rbsp_buffer(H2645RBSP *rbsp, unsigned int size, int use_ref)
         return;
     }
 
-    size = FFMIN(size + size / 16 + 32, INT_MAX);
+    size = FFMINI(size + size / 16 + 32, INT_MAX);
 
     if (rbsp->rbsp_buffer_ref)
         av_buffer_unref(&rbsp->rbsp_buffer_ref);
@@ -517,7 +517,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
                 }
             }
 
-            extract_length = FFMIN(bytestream2_get_bytes_left(&bc), next_avc - bytestream2_tell(&bc));
+            extract_length = FFMINI(bytestream2_get_bytes_left(&bc), next_avc - bytestream2_tell(&bc));
 
             if (bytestream2_tell(&bc) >= next_avc) {
                 /* skip to the start of the next NAL */
@@ -541,7 +541,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
             memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
 
             nal = &pkt->nals[pkt->nb_nals];
-            nal->skipped_bytes_pos_size = FFMIN(1024, extract_length/3+1); // initial buffer size
+            nal->skipped_bytes_pos_size = FFMINI(1024, extract_length/3+1); // initial buffer size
             nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
             if (!nal->skipped_bytes_pos)
                 return AVERROR(ENOMEM);
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index 587274aa6de..88cba22a070 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -191,7 +191,7 @@ static void await_reference_mb_row(const H264Context *const h, H264Ref *ref,
      * even if pixels aren't deblocked yet. */
 
     ff_thread_await_progress(&ref->parent->tf,
-                             FFMIN(16 * mb_y >> ref_field_picture,
+                             FFMINI(16 * mb_y >> ref_field_picture,
                                    ref_height - 1),
                              ref_field_picture && ref_field);
 }
diff --git a/libavcodec/h264_levels.c b/libavcodec/h264_levels.c
index f7ed9a6e375..bdad5bec192 100644
--- a/libavcodec/h264_levels.c
+++ b/libavcodec/h264_levels.c
@@ -107,7 +107,7 @@ const H264LevelDescriptor *ff_h264_guess_level(int profile_idc,
 
         if (width_mbs && height_mbs) {
             int max_dpb_frames =
-                FFMIN(level->max_dpb_mbs / (width_mbs * height_mbs), 16);
+                FFMINI(level->max_dpb_mbs / (width_mbs * height_mbs), 16);
             if (max_dec_frame_buffering > max_dpb_frames)
                 continue;
 
diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
index 0d6562b5830..8980c2fecd0 100644
--- a/libavcodec/h264_mb.c
+++ b/libavcodec/h264_mb.c
@@ -47,7 +47,7 @@ static inline int get_lowest_part_list_y(H264SliceContext *sl,
 
     av_assert2(height >= 0);
 
-    return FFMAX(0, bottom);
+    return FFMAXI(0, bottom);
 }
 
 static inline void get_lowest_part_y(const H264Context *h, H264SliceContext *sl,
@@ -71,7 +71,7 @@ static inline void get_lowest_part_y(const H264Context *h, H264SliceContext *sl,
             my = get_lowest_part_list_y(sl, n, height, y_offset, 0);
             if (refs[0][ref_n] < 0)
                 nrefs[0] += 1;
-            refs[0][ref_n] = FFMAX(refs[0][ref_n], my);
+            refs[0][ref_n] = FFMAXI(refs[0][ref_n], my);
         }
     }
 
@@ -84,7 +84,7 @@ static inline void get_lowest_part_y(const H264Context *h, H264SliceContext *sl,
             my = get_lowest_part_list_y(sl, n, height, y_offset, 1);
             if (refs[1][ref_n] < 0)
                 nrefs[1] += 1;
-            refs[1][ref_n] = FFMAX(refs[1][ref_n], my);
+            refs[1][ref_n] = FFMAXI(refs[1][ref_n], my);
         }
     }
 }
@@ -179,24 +179,24 @@ static void await_references(const H264Context *h, H264SliceContext *sl)
                 if (!FIELD_PICTURE(h) && ref_field_picture) { // frame referencing two fields
                     av_assert2((ref_pic->parent->reference & 3) == 3);
                     ff_thread_await_progress(&ref_pic->parent->tf,
-                                             FFMIN((row >> 1) - !(row & 1),
+                                             FFMINI((row >> 1) - !(row & 1),
                                                    pic_height - 1),
                                              1);
                     ff_thread_await_progress(&ref_pic->parent->tf,
-                                             FFMIN((row >> 1), pic_height - 1),
+                                             FFMINI((row >> 1), pic_height - 1),
                                              0);
                 } else if (FIELD_PICTURE(h) && !ref_field_picture) { // field referencing one field of a frame
                     ff_thread_await_progress(&ref_pic->parent->tf,
-                                             FFMIN(row * 2 + ref_field,
+                                             FFMINI(row * 2 + ref_field,
                                                    pic_height - 1),
                                              0);
                 } else if (FIELD_PICTURE(h)) {
                     ff_thread_await_progress(&ref_pic->parent->tf,
-                                             FFMIN(row, pic_height - 1),
+                                             FFMINI(row, pic_height - 1),
                                              ref_field);
                 } else {
                     ff_thread_await_progress(&ref_pic->parent->tf,
-                                             FFMIN(row, pic_height - 1),
+                                             FFMINI(row, pic_height - 1),
                                              0);
                 }
             }
diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h
index bc9fef50e4e..7ef7d7383e1 100644
--- a/libavcodec/h264_mvpred.h
+++ b/libavcodec/h264_mvpred.h
@@ -45,7 +45,7 @@ static av_always_inline int pred_intra_mode(const H264Context *h,
     const int index8 = scan8[n];
     const int left   = sl->intra4x4_pred_mode_cache[index8 - 1];
     const int top    = sl->intra4x4_pred_mode_cache[index8 - 8];
-    const int min    = FFMIN(left, top);
+    const int min    = FFMINI(left, top);
 
     ff_tlog(h->avctx, "mode:%d %d min:%d\n", left, top, min);
 
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index c6f9b3cea75..cfe99603c7a 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -359,7 +359,7 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
         pic_field_poc[0] = field_poc[0];
     if (picture_structure != PICT_TOP_FIELD)
         pic_field_poc[1] = field_poc[1];
-    *pic_poc = FFMIN(pic_field_poc[0], pic_field_poc[1]);
+    *pic_poc = FFMINI(pic_field_poc[0], pic_field_poc[1]);
 
     return 0;
 }
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 006f4059e8a..74652f6a5a3 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -74,7 +74,7 @@ static int find_start_code(const uint8_t *buf, int buf_size,
 
     buf_index = avpriv_find_start_code(buf + buf_index, buf + next_avc + 1, &state) - buf - 1;
 
-    return FFMIN(buf_index, buf_size);
+    return FFMINI(buf_index, buf_size);
 }
 
 static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index c698f1b80d3..92ec2fc71be 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -438,7 +438,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
 
     sps->ref_frame_count = get_ue_golomb_31(gb);
     if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
-        sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
+        sps->ref_frame_count = FFMAXI(2, sps->ref_frame_count);
     if (sps->ref_frame_count > H264_MAX_DPB_FRAMES) {
         av_log(avctx, AV_LOG_ERROR,
                "too many reference frames %d\n", sps->ref_frame_count);
@@ -542,7 +542,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
         sps->num_reorder_frames = H264_MAX_DPB_FRAMES - 1;
         for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) {
             if (level_max_dpb_mbs[i][0] == sps->level_idc) {
-                sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height),
+                sps->num_reorder_frames = FFMINI(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height),
                                                 sps->num_reorder_frames);
                 break;
             }
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 74840e59092..2623bfe70ab 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -761,7 +761,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
         }
     }
 
-    if (h->long_ref_count + h->short_ref_count > FFMAX(h->ps.sps->ref_frame_count, 1)) {
+    if (h->long_ref_count + h->short_ref_count > FFMAXI(h->ps.sps->ref_frame_count, 1)) {
 
         /* We have too many reference frames, probably due to corrupted
          * stream. Need to discard one frame. Prevents overrun of the
@@ -802,8 +802,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
     for (int i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) {
         if (h->ps.pps_list[i]) {
             const PPS *pps = h->ps.pps_list[i];
-            pps_ref_count[0] = FFMAX(pps_ref_count[0], pps->ref_count[0]);
-            pps_ref_count[1] = FFMAX(pps_ref_count[1], pps->ref_count[1]);
+            pps_ref_count[0] = FFMAXI(pps_ref_count[0], pps->ref_count[0]);
+            pps_ref_count[1] = FFMAXI(pps_ref_count[1], pps->ref_count[1]);
         }
     }
 
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 7e53e38cca2..b75e24d526c 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1303,7 +1303,7 @@ static int h264_select_output_frame(H264Context *h)
 
     if (sps->bitstream_restriction_flag ||
         h->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
-        h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, sps->num_reorder_frames);
+        h->avctx->has_b_frames = FFMAXI(h->avctx->has_b_frames, sps->num_reorder_frames);
     }
 
     for (i = 0; 1; i++) {
@@ -1318,7 +1318,7 @@ static int h264_select_output_frame(H264Context *h)
     out_of_order = H264_MAX_DPB_FRAMES - i;
     if(   cur->f->pict_type == AV_PICTURE_TYPE_B
        || (h->last_pocs[H264_MAX_DPB_FRAMES-2] > INT_MIN && h->last_pocs[H264_MAX_DPB_FRAMES-1] - (int64_t)h->last_pocs[H264_MAX_DPB_FRAMES-2] > 2))
-        out_of_order = FFMAX(out_of_order, 1);
+        out_of_order = FFMAXI(out_of_order, 1);
     if (out_of_order == H264_MAX_DPB_FRAMES) {
         av_log(h->avctx, AV_LOG_VERBOSE, "Invalid POC %d<%d\n", cur->poc, h->last_pocs[0]);
         for (i = 1; i < H264_MAX_DPB_FRAMES; i++)
@@ -1973,7 +1973,7 @@ static int h264_slice_init(H264Context *h, H264SliceContext *sl,
         }
     }
     sl->qp_thresh = 15 -
-                   FFMIN(sl->slice_alpha_c0_offset, sl->slice_beta_offset) -
+                   FFMINI(sl->slice_alpha_c0_offset, sl->slice_beta_offset) -
                    FFMAX3(0,
                           h->ps.pps->chroma_qp_index_offset[0],
                           h->ps.pps->chroma_qp_index_offset[1]) +
@@ -2528,7 +2528,7 @@ static void decode_finish_row(const H264Context *h, H264SliceContext *sl)
     if (top >= pic_height || (top + height) < 0)
         return;
 
-    height = FFMIN(height, pic_height - top);
+    height = FFMINI(height, pic_height - top);
     if (top < 0) {
         height = top + height;
         top    = 0;
@@ -2807,7 +2807,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
 
                 if (i == j || slice_idx2 < slice_idx)
                     continue;
-                next_slice_idx = FFMIN(next_slice_idx, slice_idx2);
+                next_slice_idx = FFMINI(next_slice_idx, slice_idx2);
             }
             sl->next_slice_idx = next_slice_idx;
         }
@@ -2826,7 +2826,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
                 int y_end, x_end;
 
                 sl = &h->slice_ctx[i];
-                y_end = FFMIN(sl->mb_y + 1, h->mb_height);
+                y_end = FFMINI(sl->mb_y + 1, h->mb_height);
                 x_end = (sl->mb_y >= h->mb_height) ? h->mb_width : sl->mb_x;
 
                 for (j = sl->resync_mb_y; j < y_end; j += 1 + FIELD_OR_MBAFF_PICTURE(h)) {
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 82b85b33879..42e04f55dd6 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -121,7 +121,7 @@ void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl,
         y      <<= 1;
     }
 
-    height = FFMIN(height, avctx->height - y);
+    height = FFMINI(height, avctx->height - y);
 
     desc   = av_pix_fmt_desc_get(avctx->pix_fmt);
     vshift = desc->log2_chroma_h;
@@ -187,7 +187,7 @@ int ff_h264_alloc_tables(H264Context *h)
 {
     ERContext *const er = &h->er;
     const int big_mb_num = h->mb_stride * (h->mb_height + 1);
-    const int row_mb_num = 2*h->mb_stride*FFMAX(h->nb_slice_ctx, 1);
+    const int row_mb_num = 2*h->mb_stride*FFMAXI(h->nb_slice_ctx, 1);
     const int st_size = big_mb_num + h->mb_stride;
     int x, y;
 
diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c
index 7ff9681f65e..4287470de06 100644
--- a/libavcodec/h265_profile_level.c
+++ b/libavcodec/h265_profile_level.c
@@ -230,11 +230,11 @@ const H265LevelDescriptor *ff_h265_guess_level(const H265RawProfileTierLevel *pt
             continue;
 
         if (pic_size <= (level->max_luma_ps >> 2))
-            max_dpb_size = FFMIN(4 * profile->max_dpb_pic_buf, 16);
+            max_dpb_size = FFMINI(4 * profile->max_dpb_pic_buf, 16);
         else if (pic_size <= (level->max_luma_ps >> 1))
-            max_dpb_size = FFMIN(2 * profile->max_dpb_pic_buf, 16);
+            max_dpb_size = FFMINI(2 * profile->max_dpb_pic_buf, 16);
         else if (pic_size <= (3 * level->max_luma_ps >> 2))
-            max_dpb_size = FFMIN(4 * profile->max_dpb_pic_buf / 3, 16);
+            max_dpb_size = FFMINI(4 * profile->max_dpb_pic_buf / 3, 16);
         else
             max_dpb_size = profile->max_dpb_pic_buf;
         if (max_dec_pic_buffering > max_dpb_size)
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index 70bf592f2aa..119ba7fc757 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -298,7 +298,7 @@ static int hap_decode(AVCodecContext *avctx, AVFrame *frame,
             int tex_size;
             /* Only DXTC texture compression in a contiguous block */
             ctx->dec[t].tex_data.in = ctx->gbc.buffer;
-            tex_size = FFMIN(ctx->texture_section_size, bytestream2_get_bytes_left(&ctx->gbc));
+            tex_size = FFMINI(ctx->texture_section_size, bytestream2_get_bytes_left(&ctx->gbc));
             if (tex_size < (avctx->coded_width  / TEXTURE_BLOCK_W)
                 *(avctx->coded_height / TEXTURE_BLOCK_H)
                 *ctx->dec[t].tex_ratio) {
diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c
index c4b790035fa..0649efddb47 100644
--- a/libavcodec/hapenc.c
+++ b/libavcodec/hapenc.c
@@ -196,7 +196,7 @@ static int hap_encode(AVCodecContext *avctx, AVPacket *pkt,
     HapContext *ctx = avctx->priv_data;
     int header_length = hap_header_length(ctx);
     int final_data_size, ret;
-    int pktsize = FFMAX(ctx->tex_size, ctx->max_snappy * ctx->chunk_count) + header_length;
+    int pktsize = FFMAXI(ctx->tex_size, ctx->max_snappy * ctx->chunk_count) + header_length;
 
     /* Allocate maximum size packet, shrink later. */
     ret = ff_alloc_packet(avctx, pkt, pktsize);
diff --git a/libavcodec/hdrenc.c b/libavcodec/hdrenc.c
index 71478475e05..54c58abef32 100644
--- a/libavcodec/hdrenc.c
+++ b/libavcodec/hdrenc.c
@@ -99,7 +99,7 @@ static void rle(uint8_t **buffer, const uint8_t *data, int width)
         }
 
         while (cur < beg_run) {
-            int nonrun_count = FFMIN(128, beg_run - cur);
+            int nonrun_count = FFMINI(128, beg_run - cur);
             buf[0] = nonrun_count;
             bytestream_put_byte(buffer, buf[0]);
             for (int n = 0; n < nonrun_count; n++)
diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c
index 892dd1c215a..69627fdcb0b 100644
--- a/libavcodec/hevc/cabac.c
+++ b/libavcodec/hevc/cabac.c
@@ -541,7 +541,7 @@ int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc)
 int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc, int bit_depth)
 {
     int i = 0;
-    int length = (1 << (FFMIN(bit_depth, 10) - 5)) - 1;
+    int length = (1 << (FFMINI(bit_depth, 10) - 5)) - 1;
 
     while (i < length && get_cabac_bypass(&lc->cc))
         i++;
@@ -622,7 +622,7 @@ int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc)
 
 int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1)
 {
-    int c_max= FFMAX(5, chroma_qp_offset_list_len_minus1);
+    int c_max= FFMAXI(5, chroma_qp_offset_list_len_minus1);
     int i = 0;
 
     while (i < c_max && GET_CABAC(CU_CHROMA_QP_OFFSET_IDX_OFFSET))
@@ -763,7 +763,7 @@ int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx)
 {
     int i = 0;
     int max = num_ref_idx_lx - 1;
-    int max_ctx = FFMIN(max, 2);
+    int max_ctx = FFMINI(max, 2);
 
     while (i < max_ctx && GET_CABAC(REF_IDX_L0_OFFSET + i))
         i++;
@@ -905,7 +905,7 @@ static av_always_inline int significant_coeff_group_flag_decode(HEVCLocalContext
 {
     int inc;
 
-    inc = FFMIN(ctx_cg, 1) + (c_idx>0 ? 2 : 0);
+    inc = FFMINI(ctx_cg, 1) + (c_idx>0 ? 2 : 0);
 
     return GET_CABAC(SIGNIFICANT_COEFF_GROUP_FLAG_OFFSET + inc);
 }
@@ -1373,7 +1373,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps,
 
                         trans_coeff_level += last_coeff_abs_level_remaining;
                         if (trans_coeff_level > (3 << c_rice_param))
-                            c_rice_param = sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
+                            c_rice_param = sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMINI(c_rice_param + 1, 4);
                         if (sps->persistent_rice_adaptation_enabled && !rice_init) {
                             int c_rice_p_init = lc->stat_coeff[sb_type] / 4;
                             if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init))
@@ -1389,7 +1389,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps,
 
                     trans_coeff_level = 1 + last_coeff_abs_level_remaining;
                     if (trans_coeff_level > (3 << c_rice_param))
-                        c_rice_param = sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
+                        c_rice_param = sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMINI(c_rice_param + 1, 4);
                     if (sps->persistent_rice_adaptation_enabled && !rice_init) {
                         int c_rice_p_init = lc->stat_coeff[sb_type] / 4;
                         if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init))
@@ -1465,17 +1465,17 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps,
         } else if (lc->cu.pred_mode == MODE_INTRA && c_idx == 0 && log2_trafo_size == 2) {
             s->hevcdsp.transform_4x4_luma(coeffs);
         } else {
-            int max_xy = FFMAX(last_significant_coeff_x, last_significant_coeff_y);
+            int max_xy = FFMAXI(last_significant_coeff_x, last_significant_coeff_y);
             if (max_xy == 0)
                 s->hevcdsp.idct_dc[log2_trafo_size - 2](coeffs);
             else {
                 int col_limit = last_significant_coeff_x + last_significant_coeff_y + 4;
                 if (max_xy < 4)
-                    col_limit = FFMIN(4, col_limit);
+                    col_limit = FFMINI(4, col_limit);
                 else if (max_xy < 8)
-                    col_limit = FFMIN(8, col_limit);
+                    col_limit = FFMINI(8, col_limit);
                 else if (max_xy < 12)
-                    col_limit = FFMIN(24, col_limit);
+                    col_limit = FFMINI(24, col_limit);
                 s->hevcdsp.idct[log2_trafo_size - 2](coeffs, col_limit);
             }
         }
diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c
index 68ae0e9ef69..7f82792c398 100644
--- a/libavcodec/hevc/filter.c
+++ b/libavcodec/hevc/filter.c
@@ -334,8 +334,8 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCLayerContext *l,
         ptrdiff_t stride_src = s->cur_frame->f->linesize[c_idx];
         int ctb_size_h = (1 << (sps->log2_ctb_size)) >> sps->hshift[c_idx];
         int ctb_size_v = (1 << (sps->log2_ctb_size)) >> sps->vshift[c_idx];
-        int width    = FFMIN(ctb_size_h, (sps->width  >> sps->hshift[c_idx]) - x0);
-        int height   = FFMIN(ctb_size_v, (sps->height >> sps->vshift[c_idx]) - y0);
+        int width    = FFMINI(ctb_size_h, (sps->width  >> sps->hshift[c_idx]) - x0);
+        int height   = FFMINI(ctb_size_v, (sps->height >> sps->vshift[c_idx]) - y0);
         int tab      = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
         uint8_t *src = &s->cur_frame->f->data[c_idx][y0 * stride_src + (x0 << sps->pixel_shift)];
         ptrdiff_t stride_dst;
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 636df5a4e9e..f2d2cc109df 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1514,8 +1514,8 @@ static void set_deblocking_bypass(uint8_t *is_pcm, const HEVCSPS *sps,
     int log2_min_pu_size = sps->log2_min_pu_size;
 
     int min_pu_width     = sps->min_pu_width;
-    int x_end = FFMIN(x0 + cb_size, sps->width);
-    int y_end = FFMIN(y0 + cb_size, sps->height);
+    int x_end = FFMINI(x0 + cb_size, sps->width);
+    int y_end = FFMINI(y0 + cb_size, sps->height);
     int i, j;
 
     for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
@@ -2035,7 +2035,7 @@ static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref,
                                 const Mv *mv, int y0, int height)
 {
     if (s->avctx->active_thread_type == FF_THREAD_FRAME ) {
-        int y = FFMAX(0, (mv->y >> 2) + y0 + height + 9);
+        int y = FFMAXI(0, (mv->y >> 2) + y0 + height + 9);
 
         ff_progress_frame_await(&ref->tf, y);
     }
@@ -2719,7 +2719,7 @@ static void hls_decode_neighbour(HEVCLocalContext *lc,
         lc->end_of_tiles_x = sps->width;
     }
 
-    lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, sps->height);
+    lc->end_of_tiles_y = FFMINI(y_ctb + ctb_size, sps->height);
 
     lc->boundary_flags = 0;
     if (pps->tiles_enabled_flag) {
diff --git a/libavcodec/hevc/mvs.c b/libavcodec/hevc/mvs.c
index 55f115ad0c2..e167e34913c 100644
--- a/libavcodec/hevc/mvs.c
+++ b/libavcodec/hevc/mvs.c
@@ -320,7 +320,7 @@ static void derive_spatial_merge_candidates(HEVCLocalContext *lc, const HEVCCont
     const int yB2    = y0 - 1;
 
     const int nb_refs = (s->sh.slice_type == HEVC_SLICE_P) ?
-                        s->sh.nb_refs[0] : FFMIN(s->sh.nb_refs[0], s->sh.nb_refs[1]);
+                        s->sh.nb_refs[0] : FFMINI(s->sh.nb_refs[0], s->sh.nb_refs[1]);
 
     int zero_idx = 0;
 
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 4b021ea9c1f..e6d45c57ddf 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -715,7 +715,7 @@ static int decode_vps_ext(GetBitContext *gb, AVCodecContext *avctx, HEVCVPS *vps
         vps->poc_lsb_not_present = get_bits1(gb) << 1;
 
     sub_layer_flag_info_present_flag = get_bits1(gb);
-    for (int j = 0; j < FFMAX(max_sub_layers[0], max_sub_layers[1]); j++) {
+    for (int j = 0; j < FFMAXI(max_sub_layers[0], max_sub_layers[1]); j++) {
         int sub_layer_dpb_info_present_flag = 1;
         if (j > 0 && sub_layer_flag_info_present_flag)
             sub_layer_dpb_info_present_flag = get_bits1(gb);
@@ -1110,7 +1110,7 @@ static int scaling_list_data(GetBitContext *gb, AVCodecContext *avctx,
                 int32_t scaling_list_delta_coef;
 
                 next_coef = 8;
-                coef_num  = FFMIN(64, 1 << (4 + (size_id << 1)));
+                coef_num  = FFMINI(64, 1 << (4 + (size_id << 1)));
                 if (size_id > 1) {
                     int scaling_list_coeff_minus8 = get_se_golomb(gb);
                     if (scaling_list_coeff_minus8 < -7 ||
@@ -1234,7 +1234,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
         sps->max_sub_layers = sps->vps->vps_max_sub_layers;
     }
     vps_max_sub_layers = sps->vps ? sps->vps->vps_max_sub_layers
-                                  : FFMIN(sps->max_sub_layers, HEVC_MAX_SUB_LAYERS);
+                                  : FFMINI(sps->max_sub_layers, HEVC_MAX_SUB_LAYERS);
 
     if (sps->max_sub_layers > vps_max_sub_layers) {
         av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
@@ -1461,7 +1461,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
         sps->pcm.log2_min_pcm_cb_size = get_ue_golomb_long(gb) + 3;
         sps->pcm.log2_max_pcm_cb_size = sps->pcm.log2_min_pcm_cb_size +
                                         get_ue_golomb_long(gb);
-        if (FFMAX(sps->pcm.bit_depth, sps->pcm.bit_depth_chroma) > sps->bit_depth) {
+        if (FFMAXI(sps->pcm.bit_depth, sps->pcm.bit_depth_chroma) > sps->bit_depth) {
             av_log(avctx, AV_LOG_ERROR,
                    "PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n",
                    sps->pcm.bit_depth, sps->pcm.bit_depth_chroma, sps->bit_depth);
@@ -1666,7 +1666,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
                sps->max_transform_hierarchy_depth_intra);
         return AVERROR_INVALIDDATA;
     }
-    if (sps->log2_max_trafo_size > FFMIN(sps->log2_ctb_size, 5)) {
+    if (sps->log2_max_trafo_size > FFMINI(sps->log2_ctb_size, 5)) {
         av_log(avctx, AV_LOG_ERROR,
                "max transform block size out of range: %d\n",
                sps->log2_max_trafo_size);
@@ -1795,7 +1795,7 @@ static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int inp_dept
                 if (coded_res_flag)
                     for (int c = 0; c < 3; c++) {
                         res_coeff_q = get_ue_golomb_long(gb);
-                        cm_res_bits = FFMAX(0, 10 + pps->luma_bit_depth_cm_input -
+                        cm_res_bits = FFMAXI(0, 10 + pps->luma_bit_depth_cm_input -
                                             pps->luma_bit_depth_cm_output -
                                             pps->cm_res_quant_bits - pps->cm_delta_flc_bits);
                         res_coeff_r = cm_res_bits ? get_bits(gb, cm_res_bits) : 0;
@@ -1965,8 +1965,8 @@ static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx,
     pps->log2_sao_offset_scale_luma = get_ue_golomb_31(gb);
     pps->log2_sao_offset_scale_chroma = get_ue_golomb_31(gb);
 
-    if (   pps->log2_sao_offset_scale_luma   > FFMAX(sps->bit_depth        - 10, 0)
-        || pps->log2_sao_offset_scale_chroma > FFMAX(sps->bit_depth_chroma - 10, 0)
+    if (   pps->log2_sao_offset_scale_luma   > FFMAXI(sps->bit_depth        - 10, 0)
+        || pps->log2_sao_offset_scale_chroma > FFMAXI(sps->bit_depth_chroma - 10, 0)
     )
         return AVERROR_INVALIDDATA;
 
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index ab2e075af02..7d927486f8d 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -414,7 +414,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
             }
         } else {
             memcpy(rpl, &rpl_tmp, sizeof(*rpl));
-            rpl->nb_refs = FFMIN(rpl->nb_refs, sh->nb_refs[list_idx]);
+            rpl->nb_refs = FFMINI(rpl->nb_refs, sh->nb_refs[list_idx]);
         }
 
         // 8-9
diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index b8e98cde898..c745724d6f7 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -189,9 +189,9 @@ static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitCont
         if (s->exponent_ref_display_width[i] > 62)
             return AVERROR_INVALIDDATA;
         else if (!s->exponent_ref_display_width[i])
-            length = FFMAX(0, (int)s->prec_ref_display_width - 30);
+            length = FFMAXI(0, (int)s->prec_ref_display_width - 30);
         else
-            length = FFMAX(0, (int)s->exponent_ref_display_width[i] +
+            length = FFMAXI(0, (int)s->exponent_ref_display_width[i] +
                               (int)s->prec_ref_display_width - 31);
         s->mantissa_ref_display_width[i] = get_bits_long(gb, length);
         if (s->ref_viewing_distance_flag) {
@@ -199,9 +199,9 @@ static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitCont
             if (s->exponent_ref_viewing_distance[i] > 62)
                 return AVERROR_INVALIDDATA;
             else if (!s->exponent_ref_viewing_distance[i])
-                length = FFMAX(0, (int)s->prec_ref_viewing_dist - 30);
+                length = FFMAXI(0, (int)s->prec_ref_viewing_dist - 30);
             else
-                length = FFMAX(0, (int)s->exponent_ref_viewing_distance[i] +
+                length = FFMAXI(0, (int)s->exponent_ref_viewing_distance[i] +
                                   (int)s->prec_ref_viewing_dist - 31);
             s->mantissa_ref_viewing_distance[i] = get_bits_long(gb, length);
         }
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index c98904d4972..8bf3d27a578 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -370,7 +370,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     s->bps = 8;
     s->n = 1<<s->bps;
-    s->vlc_n = FFMIN(s->n, MAX_VLC_N);
+    s->vlc_n = FFMINI(s->n, MAX_VLC_N);
     s->chroma = 1;
     if (s->version >= 2) {
         int method, interlace;
@@ -388,7 +388,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         } else {
             s->bps = (avctx->extradata[1] >> 4) + 1;
             s->n = 1<<s->bps;
-            s->vlc_n = FFMIN(s->n, MAX_VLC_N);
+            s->vlc_n = FFMINI(s->n, MAX_VLC_N);
             s->chroma_h_shift = avctx->extradata[1] & 3;
             s->chroma_v_shift = (avctx->extradata[1] >> 2) & 3;
             s->yuv   = !!(avctx->extradata[2] & 1);
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index b213d4dc952..5dfddd3d35d 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -92,7 +92,7 @@ static inline int sub_left_prediction(HYuvEncContext *s, uint8_t *dst,
                                       const uint8_t *src, int w, int left)
 {
     int i;
-    int min_width = FFMIN(w, 32);
+    int min_width = FFMINI(w, 32);
 
     if (s->bps <= 8) {
         for (i = 0; i < min_width; i++) { /* scalar loop before dsp call */
@@ -126,7 +126,7 @@ static inline void sub_left_prediction_bgr32(HYuvEncContext *s, uint8_t *dst,
 {
     int i;
     int r, g, b, a;
-    int min_width = FFMIN(w, 8);
+    int min_width = FFMINI(w, 8);
     r = *red;
     g = *green;
     b = *blue;
@@ -164,7 +164,7 @@ static inline void sub_left_prediction_rgb24(HYuvEncContext *s, uint8_t *dst,
     r = *red;
     g = *green;
     b = *blue;
-    for (i = 0; i < FFMIN(w, 16); i++) {
+    for (i = 0; i < FFMINI(w, 16); i++) {
         const int rt = src[i * 3 + 0];
         const int gt = src[i * 3 + 1];
         const int bt = src[i * 3 + 2];
@@ -336,7 +336,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
     s->n = 1<<s->bps;
-    s->vlc_n = FFMIN(s->n, MAX_VLC_N);
+    s->vlc_n = FFMINI(s->n, MAX_VLC_N);
 
     avctx->bits_per_coded_sample = s->bitstream_bpp;
     s->decorrelate = s->bitstream_bpp >= 24 && !s->yuv && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR);
@@ -407,7 +407,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
     } else {
         for (i = 0; i < 4; i++)
             for (j = 0; j < s->vlc_n; j++) {
-                int d = FFMIN(j, s->vlc_n - j);
+                int d = FFMINI(j, s->vlc_n - j);
 
                 s->stats[i][j] = 100000000 / (d*d + 1);
             }
@@ -422,7 +422,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
         for (i = 0; i < 4; i++) {
             int pels = avctx->width * avctx->height / (i ? 40 : 10);
             for (j = 0; j < s->vlc_n; j++) {
-                int d = FFMIN(j, s->vlc_n - j);
+                int d = FFMINI(j, s->vlc_n - j);
                 s->stats[i][j] = pels/(d*d + 1);
             }
         }
diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c
index 33a30c8d105..6d355983837 100644
--- a/libavcodec/hw_base_encode.c
+++ b/libavcodec/hw_base_encode.c
@@ -663,8 +663,8 @@ int ff_hw_base_init_gop_structure(FFHWBaseEncodeContext *ctx, AVCodecContext *av
                                   uint32_t ref_l0, uint32_t ref_l1,
                                   int flags, int prediction_pre_only)
 {
-    ctx->ref_l0 = FFMIN(ref_l0, MAX_PICTURE_REFERENCES);
-    ctx->ref_l1 = FFMIN(ref_l1, MAX_PICTURE_REFERENCES);
+    ctx->ref_l0 = FFMINI(ref_l0, MAX_PICTURE_REFERENCES);
+    ctx->ref_l1 = FFMINI(ref_l1, MAX_PICTURE_REFERENCES);
 
     if (flags & FF_HW_FLAG_INTRA_ONLY || avctx->gop_size <= 1) {
         av_log(avctx, AV_LOG_VERBOSE, "Using intra frames only.\n");
@@ -697,7 +697,7 @@ int ff_hw_base_init_gop_structure(FFHWBaseEncodeContext *ctx, AVCodecContext *av
         ctx->p_per_i  = INT_MAX;
         ctx->b_per_p  = avctx->max_b_frames;
         if (flags & FF_HW_FLAG_B_PICTURE_REFERENCES) {
-            ctx->max_b_depth = FFMIN(ctx->desired_b_depth,
+            ctx->max_b_depth = FFMINI(ctx->desired_b_depth,
                                      av_log2(ctx->b_per_p) + 1);
         } else {
             ctx->max_b_depth = 1;
diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 13010b451ef..78010e95bf0 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -164,14 +164,14 @@ static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
 
     count = 1 << avctx->bits_per_coded_sample;
     // If extradata is smaller than actually needed, fill the remaining with black.
-    count = FFMIN(palette_size / 3, count);
+    count = FFMINI(palette_size / 3, count);
     if (count) {
         for (i = 0; i < count; i++)
             pal[i] = 0xFF000000 | AV_RB24(palette + i*3);
         if (s->flags && count >= 32) { // EHB
             for (i = 0; i < 32; i++)
                 pal[i + 32] = 0xFF000000 | (AV_RB24(palette + i*3) & 0xFEFEFE) >> 1;
-            count = FFMAX(count, 64);
+            count = FFMAXI(count, 64);
         }
     } else { // Create gray-scale color palette for bps < 8
         count = 1 << avctx->bits_per_coded_sample;
@@ -271,7 +271,7 @@ static int extract_header(AVCodecContext *const avctx,
         return AVERROR_INVALIDDATA;
 
     if (s->ham) {
-        int count = FFMIN(palette_size / 3, 1 << s->ham);
+        int count = FFMINI(palette_size / 3, 1 << s->ham);
         int ham_count;
         const uint8_t *const palette = extradata + AV_RB16(extradata);
         int extra_space = 1;
@@ -505,7 +505,7 @@ static int decode_byterun(uint8_t *dst, int dst_size,
             if (length < value + 1)
                 bytestream2_skip(gb, value + 1 - length);
         } else if (value > -128) {
-            length = FFMIN(-value + 1, dst_size - x);
+            length = FFMINI(-value + 1, dst_size - x);
             memset(dst + x, bytestream2_get_byte(gb), length);
         } else { // noop
             continue;
@@ -663,7 +663,7 @@ static void decode_deep_rle32(uint8_t *dst, const uint8_t *src, int src_size, in
         if (opcode >= 0) {
             int size = opcode + 1;
             for (i = 0; i < size; i++) {
-                int length = FFMIN(size - i, width - x);
+                int length = FFMINI(size - i, width - x);
                 if (src_end - src < length * 4)
                     return;
                 memcpy(dst + y*linesize + x * 4, src, length * 4);
@@ -724,7 +724,7 @@ static void decode_deep_tvdc32(uint8_t *dst, const uint8_t *src, int src_size, i
                 return;
             d = GETNIBBLE + 1;
             i++;
-            d = FFMIN(d, width - x);
+            d = FFMINI(d, width - x);
             for (j = 0; j < d; j++) {
                 dst[y * linesize + x*4 + plane] = pixel;
                 x++;
@@ -1567,7 +1567,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                 for (plane = 0; plane < s->bpp; plane++) {
                     for (y = 0; y < avctx->height && buf < buf_end; y++) {
                         uint8_t *row = &frame->data[0][y * frame->linesize[0]];
-                        decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
+                        decodeplane8(row, buf, FFMINI(s->planesize, buf_end - buf), plane);
                         buf += s->planesize;
                     }
                 }
@@ -1580,7 +1580,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                         const uint8_t * start = buf + (plane * avctx->height + y) * s->planesize;
                         if (start >= buf_end)
                             break;
-                        decodeplane8(s->ham_buf, start, FFMIN(s->planesize, buf_end - start), plane);
+                        decodeplane8(s->ham_buf, start, FFMINI(s->planesize, buf_end - start), plane);
                     }
                     decode_ham_plane32((uint32_t *)row, s->ham_buf, s->ham_palbuf, s->planesize);
                 }
@@ -1591,7 +1591,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
             int x;
             for (y = 0; y < avctx->height && buf < buf_end; y++) {
                 uint8_t *row = &frame->data[0][y * frame->linesize[0]];
-                memcpy(row, buf, FFMIN(raw_width, buf_end - buf));
+                memcpy(row, buf, FFMINI(raw_width, buf_end - buf));
                 buf += raw_width;
                 if (avctx->pix_fmt == AV_PIX_FMT_BGR32) {
                     for (x = 0; x < avctx->width; x++)
@@ -1601,13 +1601,13 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
         } else if (avctx->codec_tag == MKTAG('I', 'L', 'B', 'M') || // interleaved
                    avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) {
             if (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M'))
-                memcpy(s->video[0], buf, FFMIN(buf_end - buf, s->video_size));
+                memcpy(s->video[0], buf, FFMINI(buf_end - buf, s->video_size));
             if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
                 for (y = 0; y < avctx->height; y++) {
                     uint8_t *row = &frame->data[0][y * frame->linesize[0]];
                     memset(row, 0, avctx->width);
                     for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
-                        decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
+                        decodeplane8(row, buf, FFMINI(s->planesize, buf_end - buf), plane);
                         buf += s->planesize;
                     }
                 }
@@ -1616,7 +1616,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                     uint8_t *row = &frame->data[0][y * frame->linesize[0]];
                     memset(s->ham_buf, 0, s->planesize * 8);
                     for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
-                        decodeplane8(s->ham_buf, buf, FFMIN(s->planesize, buf_end - buf), plane);
+                        decodeplane8(s->ham_buf, buf, FFMINI(s->planesize, buf_end - buf), plane);
                         buf += s->planesize;
                     }
                     decode_ham_plane32((uint32_t *)row, s->ham_buf, s->ham_palbuf, s->planesize);
@@ -1627,7 +1627,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                     memset(row, 0, avctx->width << 2);
                     for (plane = 0; plane < s->bpp && buf < buf_end; plane++) {
                         decodeplane32((uint32_t *)row, buf,
-                                      FFMIN(s->planesize, buf_end - buf), plane);
+                                      FFMINI(s->planesize, buf_end - buf), plane);
                         buf += s->planesize;
                     }
                 }
@@ -1636,13 +1636,13 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
             if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
                 for (y = 0; y < avctx->height && buf_end > buf; y++) {
                     uint8_t *row = &frame->data[0][y * frame->linesize[0]];
-                    memcpy(row, buf, FFMIN(avctx->width, buf_end - buf));
+                    memcpy(row, buf, FFMINI(avctx->width, buf_end - buf));
                     buf += avctx->width + (avctx->width % 2); // padding if odd
                 }
             } else if (s->ham) { // IFF-PBM: HAM to AV_PIX_FMT_BGR32
                 for (y = 0; y < avctx->height && buf_end > buf; y++) {
                     uint8_t *row = &frame->data[0][y * frame->linesize[0]];
-                    memcpy(s->ham_buf, buf, FFMIN(avctx->width, buf_end - buf));
+                    memcpy(s->ham_buf, buf, FFMINI(avctx->width, buf_end - buf));
                     buf += avctx->width + (avctx->width & 1); // padding if odd
                     decode_ham_plane32((uint32_t *)row, s->ham_buf, s->ham_palbuf, s->planesize);
                 }
@@ -1730,7 +1730,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                 for (plane = 0; plane < s->bpp; plane++) {
                     for (y = 0; y < avctx->height && buf < buf_end; y++) {
                         uint8_t *row = &frame->data[0][y * frame->linesize[0]];
-                        decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane);
+                        decodeplane8(row, buf, FFMINI(s->planesize, buf_end - buf), plane);
                         buf += s->planesize;
                     }
                 }
@@ -1743,7 +1743,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                         const uint8_t * start = buf + (plane * avctx->height + y) * s->planesize;
                         if (start >= buf_end)
                             break;
-                        decodeplane8(s->ham_buf, start, FFMIN(s->planesize, buf_end - start), plane);
+                        decodeplane8(s->ham_buf, start, FFMINI(s->planesize, buf_end - start), plane);
                     }
                     decode_ham_plane32((uint32_t *)row, s->ham_buf, s->ham_palbuf, s->planesize);
                 }
diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c
index 7fea39b43ca..06f00d2a0fe 100644
--- a/libavcodec/ilbcdec.c
+++ b/libavcodec/ilbcdec.c
@@ -357,7 +357,7 @@ static void lsf2lsp(const int16_t *lsf, int16_t *lsp, int order)
            Lower 8 bits give the difference, which needs
            to be approximated linearly
          */
-        k = FFMIN(freq >> 8, 63);
+        k = FFMINI(freq >> 8, 63);
         diff = freq & 0xFF;
 
         /* Calculate linear approximation */
@@ -604,7 +604,7 @@ static void state_construct(int16_t ifm, const int16_t *idx,
 
 static int16_t gain_dequantization(int index, int max_in, int stage)
 {
-    int16_t scale = FFMAX(1638, FFABS(max_in));
+    int16_t scale = FFMAXI(1638, FFABS(max_in));
 
     return ((scale * ilbc_gain[stage][index]) + 8192) >> 14;
 }
@@ -636,7 +636,7 @@ static void add_vector_and_shift(int16_t *out, const int16_t *in1,
 static void create_augmented_vector(int index, const int16_t *buffer, int16_t *cbVec)
 {
     int16_t cbVecTmp[4];
-    int interpolation_length = FFMIN(4, index);
+    int interpolation_length = FFMINI(4, index);
     int16_t ilow = index - interpolation_length;
 
     memcpy(cbVec, buffer - index, index * 2);
@@ -645,7 +645,7 @@ static void create_augmented_vector(int index, const int16_t *buffer, int16_t *c
     vector_rmultiplication(cbVecTmp, buffer - interpolation_length, &alpha[interpolation_length - 1], interpolation_length, 15);
     add_vector_and_shift(&cbVec[ilow], &cbVec[ilow], cbVecTmp, interpolation_length, 0);
 
-    memcpy(cbVec + index, buffer - index, FFMIN(SUBL - index, index) * sizeof(*cbVec));
+    memcpy(cbVec + index, buffer - index, FFMINI(SUBL - index, index) * sizeof(*cbVec));
 }
 
 static void get_codebook(int16_t * cbvec,   /* (o) Constructed codebook vector */
@@ -882,7 +882,7 @@ static int16_t max_abs_value_w16(const int16_t* vector, int length)
     }
 
     // Guard the case for abs(-32768).
-    return FFMIN(maximum, INT16_MAX);
+    return FFMINI(maximum, INT16_MAX);
 }
 
 static int16_t get_size_in_bits(uint32_t n)
@@ -1006,7 +1006,7 @@ static void do_plc(int16_t *plc_residual,      /* (o) concealed residual */
             lag = inlag - 3;
 
             /* Guard against getting outside the frame */
-            corrLen = FFMIN(60, s->block_samples - (inlag + 3));
+            corrLen = FFMINI(60, s->block_samples - (inlag + 3));
 
             correlation(&cross, &ener, s->prevResidual, lag, s->block_samples, corrLen, scale3);
 
@@ -1032,11 +1032,11 @@ static void do_plc(int16_t *plc_residual,      /* (o) concealed residual */
                 /* Calculate shift value, so that the two measures can
                    be put in the same Q domain */
                 if (((shift_max << 1) + shift3) > ((shift1 << 1) + shift2)) {
-                    tmp1 = FFMIN(31, (shift_max << 1) + shift3 - (shift1 << 1) - shift2);
+                    tmp1 = FFMINI(31, (shift_max << 1) + shift3 - (shift1 << 1) - shift2);
                     tmp2 = 0;
                 } else {
                     tmp1 = 0;
-                    tmp2 = FFMIN(31, (shift1 << 1) + shift2 - (shift_max << 1) - shift3);
+                    tmp2 = FFMINI(31, (shift1 << 1) + shift2 - (shift_max << 1) - shift3);
                 }
 
                 if ((measure >> tmp1) > (max_measure >> tmp2)) {
@@ -1114,7 +1114,7 @@ static void do_plc(int16_t *plc_residual,      /* (o) concealed residual */
             /* pitch fact is approximated by first order */
             tmpW32 = kPlcPitchFact[ind] + SPL_MUL_16_16_RSFT(kPlcPfSlope[ind], (max_perSquare - kPlcPerSqr[ind]), 11);
 
-            pitchfact = FFMIN(tmpW32, 32767); /* guard against overflow */
+            pitchfact = FFMINI(tmpW32, 32767); /* guard against overflow */
 
         } else {                /* periodicity < 0.4 */
             pitchfact = 0;
@@ -1271,8 +1271,8 @@ static int xcorr_coeff(const int16_t *target, const int16_t *regressor,
                (cross_corr*cross_corr)/energy in the same domain
              */
             scalediff = totscale - totscale_max;
-            scalediff = FFMIN(scalediff, 31);
-            scalediff = FFMAX(scalediff, -31);
+            scalediff = FFMINI(scalediff, 31);
+            scalediff = FFMAXI(scalediff, -31);
 
             /* Compute the cross multiplication between the old best criteria
                and the new one to be able to compare them without using a
diff --git a/libavcodec/imc.c b/libavcodec/imc.c
index 76df971aaad..442783557d9 100644
--- a/libavcodec/imc.c
+++ b/libavcodec/imc.c
@@ -440,7 +440,7 @@ static int bit_allocation(IMCContext *q, IMCChannel *chctx,
     int found_indx = 0;
 
     for (i = 0; i < BANDS; i++)
-        highest = FFMAX(highest, chctx->flcoeffs1[i]);
+        highest = FFMAXF(highest, chctx->flcoeffs1[i]);
 
     for (i = 0; i < BANDS - 1; i++) {
         if (chctx->flcoeffs5[i] <= 0) {
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index fbabd4b6ad0..cf32dc89865 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -936,7 +936,7 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
 
     if (ctx->data_size == 16)
         return 4;
-    ctx->data_size = FFMIN(ctx->data_size, buf_size - 16);
+    ctx->data_size = FFMINI(ctx->data_size, buf_size - 16);
 
     bytestream2_skip(&gb, 3); // skip reserved byte and checksum
 
@@ -1035,7 +1035,7 @@ static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst,
     const uint8_t   *src  = plane->pixels[buf_sel];
     ptrdiff_t       pitch = plane->pitch;
 
-    dst_height = FFMIN(dst_height, plane->height);
+    dst_height = FFMINI(dst_height, plane->height);
     for (y = 0; y < dst_height; y++) {
         /* convert four pixels at once using SWAR */
         for (x = 0; x < plane->width >> 2; x++) {
diff --git a/libavcodec/interplayacm.c b/libavcodec/interplayacm.c
index 2ae992a71d4..946244c7710 100644
--- a/libavcodec/interplayacm.c
+++ b/libavcodec/interplayacm.c
@@ -569,7 +569,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
         return 0;
     }
 
-    buf_size = FFMIN(pkt->size, s->max_framesize - s->bitstream_size);
+    buf_size = FFMINI(pkt->size, s->max_framesize - s->bitstream_size);
     input_buf_size = buf_size;
     if (s->bitstream_index + s->bitstream_size + buf_size > s->max_framesize) {
         memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
@@ -588,8 +588,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
     if ((ret = init_get_bits8(gb, buf, buf_size)) < 0)
         return ret;
 
-    frame->nb_samples = FFMIN(s->block_len / avctx->ch_layout.nb_channels, s->max_samples);
-    s->max_samples -= FFMIN(frame->nb_samples, s->max_samples);
+    frame->nb_samples = FFMINI(s->block_len / avctx->ch_layout.nb_channels, s->max_samples);
+    s->max_samples -= FFMINI(frame->nb_samples, s->max_samples);
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
@@ -616,7 +616,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     if (s->bitstream_size > 0) {
         s->bitstream_index += n;
-        s->bitstream_size  -= FFMIN(s->bitstream_size, n);
+        s->bitstream_size  -= FFMINI(s->bitstream_size, n);
         return input_buf_size;
     }
     return n;
diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 684f15d9047..eeecec2f560 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -395,12 +395,12 @@ static void x8_get_prediction(IntraX8Context *const w)
     a = w->prediction_table[2 * w->mb_x - 2 +  (w->mb_y & 1)]; // block[x - 1][y    ]
     c = w->prediction_table[2 * w->mb_x - 2 + !(w->mb_y & 1)]; // block[x - 1][y - 1]
 
-    w->est_run = FFMIN(b, a);
+    w->est_run = FFMINI(b, a);
     /* This condition has nothing to do with w->edges, even if it looks
      * similar it would trigger if e.g. x = 3; y = 2;
      * I guess somebody wrote something wrong and it became standard. */
     if ((w->mb_x & w->mb_y) != 0)
-        w->est_run = FFMIN(c, w->est_run);
+        w->est_run = FFMINI(c, w->est_run);
     w->est_run >>= 2;
 
     a &= 3;
diff --git a/libavcodec/intrax8dsp.c b/libavcodec/intrax8dsp.c
index 2673316369b..3b5e5d42596 100644
--- a/libavcodec/intrax8dsp.c
+++ b/libavcodec/intrax8dsp.c
@@ -96,8 +96,8 @@ static void x8_setup_spatial_compensation(const uint8_t *restrict src,
             c              = *ptr;
 
             sum           += c;
-            min_pix        = FFMIN(min_pix, c);
-            max_pix        = FFMAX(max_pix, c);
+            min_pix        = FFMINI(min_pix, c);
+            max_pix        = FFMAXI(max_pix, c);
             dst[area2 + i] = c;
 
             ptr += stride;
@@ -109,8 +109,8 @@ static void x8_setup_spatial_compensation(const uint8_t *restrict src,
         for (i = 0; i < 8; i++) {
             c       = *(ptr + i);
             sum    += c;
-            min_pix = FFMIN(min_pix, c);
-            max_pix = FFMAX(max_pix, c);
+            min_pix = FFMINI(min_pix, c);
+            max_pix = FFMAXI(max_pix, c);
         }
         if (edges & 4) { // last block on the row?
             memset(dst + area5, c, 8); // set with last pixel fr
@@ -220,7 +220,7 @@ static void spatial_compensation_1(const uint8_t *restrict src, uint8_t *restric
 
     for (y = 0; y < 8; y++) {
         for (x = 0; x < 8; x++)
-            dst[x] = src[area4 + FFMIN(2 * y + x + 2, 15)];
+            dst[x] = src[area4 + FFMINI(2 * y + x + 2, 15)];
         dst += stride;
     }
 }
@@ -307,7 +307,7 @@ static void spatial_compensation_9(const uint8_t *restrict src, uint8_t *restric
 
     for (y = 0; y < 8; y++) {
         for (x = 0; x < 8; x++)
-            dst[x] = src[area2 + 6 - FFMIN(x + y, 6)];
+            dst[x] = src[area2 + 6 - FFMINI(x + y, 6)];
         dst += stride;
     }
 }
@@ -369,21 +369,21 @@ static void x8_loop_filter(uint8_t *ptr, const ptrdiff_t a_stride,
                 int min, max;
 
                 min = max = p1;
-                min = FFMIN(min, p3);
-                max = FFMAX(max, p3);
-                min = FFMIN(min, p5);
-                max = FFMAX(max, p5);
-                min = FFMIN(min, p8);
-                max = FFMAX(max, p8);
+                min = FFMINI(min, p3);
+                max = FFMAXI(max, p3);
+                min = FFMINI(min, p5);
+                max = FFMAXI(max, p5);
+                min = FFMINI(min, p8);
+                max = FFMAXI(max, p8);
                 if (max - min < 2 * quant) { // early stop
-                    min = FFMIN(min, p2);
-                    max = FFMAX(max, p2);
-                    min = FFMIN(min, p4);
-                    max = FFMAX(max, p4);
-                    min = FFMIN(min, p6);
-                    max = FFMAX(max, p6);
-                    min = FFMIN(min, p7);
-                    max = FFMAX(max, p7);
+                    min = FFMINI(min, p2);
+                    max = FFMAXI(max, p2);
+                    min = FFMINI(min, p4);
+                    max = FFMAXI(max, p4);
+                    min = FFMINI(min, p6);
+                    max = FFMAXI(max, p6);
+                    min = FFMINI(min, p7);
+                    max = FFMAXI(max, p7);
                     if (max - min < 2 * quant) {
                         ptr[-2 * a_stride] = (4 * p2 + 3 * p3 + 1 * p7 + 4) >> 3;
                         ptr[-1 * a_stride] = (3 * p2 + 3 * p4 + 2 * p7 + 4) >> 3;
@@ -403,7 +403,7 @@ static void x8_loop_filter(uint8_t *ptr, const ptrdiff_t a_stride,
                 x1 = (2 * p1 - 5 * p2 + 5 * p3 - 2 * p4 + 4) >> 3;
                 x2 = (2 * p5 - 5 * p6 + 5 * p7 - 2 * p8 + 4) >> 3;
 
-                x = FFABS(x0) - FFMIN(FFABS(x1), FFABS(x2));
+                x = FFABS(x0) - FFMINI(FFABS(x1), FFABS(x2));
                 m = p4 - p5;
 
                 if (x > 0 && (m ^ x0) < 0) {
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 21c78f3cb5b..f534f38834e 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -172,7 +172,7 @@ static int h263_decode_gob_header(MpegEncContext *s)
         /* We have a GBSC probably with GSTUFF */
     skip_bits(&s->gb, 16); /* Drop the zeros */
     left= get_bits_left(&s->gb);
-    left = FFMIN(left, 32);
+    left = FFMINI(left, 32);
     //MN: we must check the bits left or we might end in an infinite loop (or segfault)
     for(;left>13; left--){
         if(get_bits1(&s->gb)) break; /* Seek the '1' bit */
diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
index e7d8d10c3e0..a83fe0078be 100644
--- a/libavcodec/ivi.c
+++ b/libavcodec/ivi.c
@@ -365,8 +365,8 @@ static int ivi_init_tiles(const IVIBandDesc *band, IVITile *ref_tile,
             tile->xpos     = x;
             tile->ypos     = y;
             tile->mb_size  = band->mb_size;
-            tile->width    = FFMIN(band->width - x,  t_width);
-            tile->height   = FFMIN(band->height - y, t_height);
+            tile->width    = FFMINI(band->width - x,  t_width);
+            tile->height   = FFMINI(band->height - y, t_height);
             tile->is_empty = tile->data_size = 0;
             /* calculate number of macroblocks */
             tile->num_MBs  = IVI_MBs_PER_TILE(tile->width, tile->height,
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 449e8dead2a..40efa4a2684 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -482,9 +482,9 @@ static int init_tiles(Jpeg2000EncoderContext *s)
                 int ret, i, j;
 
                 comp->coord[0][0] = comp->coord_o[0][0] = tilex * s->tile_width;
-                comp->coord[0][1] = comp->coord_o[0][1] = FFMIN((tilex+1)*s->tile_width, s->width);
+                comp->coord[0][1] = comp->coord_o[0][1] = FFMINI((tilex+1)*s->tile_width, s->width);
                 comp->coord[1][0] = comp->coord_o[1][0] = tiley * s->tile_height;
-                comp->coord[1][1] = comp->coord_o[1][1] = FFMIN((tiley+1)*s->tile_height, s->height);
+                comp->coord[1][1] = comp->coord_o[1][1] = FFMINI((tiley+1)*s->tile_height, s->height);
                 if (compno + 1 & 2)
                     for (i = 0; i < 2; i++)
                         for (j = 0; j < 2; j++)
@@ -586,13 +586,13 @@ static void init_luts(void)
         mask = ~((1<<NMSEDEC_FRACBITS)-1);
 
     for (i = 0; i < (1 << NMSEDEC_BITS); i++){
-        lut_nmsedec_sig[i]  = FFMAX((3 * i << (13 - NMSEDEC_FRACBITS)) - (9 << 11), 0);
-        lut_nmsedec_sig0[i] = FFMAX((i*i + (1<<NMSEDEC_FRACBITS-1) & mask) << 1, 0);
+        lut_nmsedec_sig[i]  = FFMAXI((3 * i << (13 - NMSEDEC_FRACBITS)) - (9 << 11), 0);
+        lut_nmsedec_sig0[i] = FFMAXI((i*i + (1<<NMSEDEC_FRACBITS-1) & mask) << 1, 0);
 
         a = (i >> (NMSEDEC_BITS-2)&2) + 1;
-        lut_nmsedec_ref[i]  = FFMAX((a - 2) * (i << (13 - NMSEDEC_FRACBITS)) +
+        lut_nmsedec_ref[i]  = FFMAXI((a - 2) * (i << (13 - NMSEDEC_FRACBITS)) +
                                     (1 << 13) - (a * a << 11), 0);
-        lut_nmsedec_ref0[i] = FFMAX(((i * i - (i << NMSEDEC_BITS) + (1 << 2 * NMSEDEC_FRACBITS) + (1 << (NMSEDEC_FRACBITS - 1))) & mask)
+        lut_nmsedec_ref0[i] = FFMAXI(((i * i - (i << NMSEDEC_BITS) + (1 << 2 * NMSEDEC_FRACBITS) + (1 << (NMSEDEC_FRACBITS - 1))) & mask)
                                     << 1, 0);
     }
     ff_jpeg2000_init_tier1_luts();
@@ -718,7 +718,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
                 t1->flags[(y+1) * t1->stride + x+1] |= JPEG2000_T1_SGN;
                 t1->data[(y) * t1->stride + x] = -t1->data[(y) * t1->stride + x];
             }
-            max = FFMAX(max, t1->data[(y) * t1->stride + x]);
+            max = FFMAXI(max, t1->data[(y) * t1->stride + x]);
         }
     }
 
@@ -950,9 +950,9 @@ static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int til
     int row = tileno / s->numXtiles;
 
     tile_coord[0][0] = col * s->tile_width;
-    tile_coord[0][1] = FFMIN(tile_coord[0][0] + s->tile_width, s->width);
+    tile_coord[0][1] = FFMINI(tile_coord[0][0] + s->tile_width, s->width);
     tile_coord[1][0] = row * s->tile_height;
-    tile_coord[1][1] = FFMIN(tile_coord[1][0] + s->tile_height, s->height);
+    tile_coord[1][1] = FFMINI(tile_coord[1][0] + s->tile_height, s->height);
 
     av_log(s->avctx, AV_LOG_DEBUG, "tier2\n");
     // lay-rlevel-comp-pos progression
@@ -997,8 +997,8 @@ static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int til
             if (reslevelno < codsty->nreslevels) {
                 uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                 Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
-                step_x = FFMIN(step_x, rlevel->log2_prec_width  + reducedresno);
-                step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno);
+                step_x = FFMINI(step_x, rlevel->log2_prec_width  + reducedresno);
+                step_y = FFMINI(step_y, rlevel->log2_prec_height + reducedresno);
             }
         }
 
@@ -1056,8 +1056,8 @@ static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int til
             for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
                 uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                 Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
-                step_x = FFMIN(step_x, rlevel->log2_prec_width  + reducedresno);
-                step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno);
+                step_x = FFMINI(step_x, rlevel->log2_prec_width  + reducedresno);
+                step_y = FFMINI(step_y, rlevel->log2_prec_height + reducedresno);
             }
         }
         if (step_x >= 31 || step_y >= 31){
@@ -1124,8 +1124,8 @@ static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int til
             for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
                 uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                 Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
-                step_x = FFMIN(step_x, rlevel->log2_prec_width  + reducedresno);
-                step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno);
+                step_x = FFMINI(step_x, rlevel->log2_prec_width  + reducedresno);
+                step_y = FFMINI(step_y, rlevel->log2_prec_height + reducedresno);
             }
             if (step_x >= 31 || step_y >= 31){
                 avpriv_request_sample(s->avctx, "CPRL with large step");
@@ -1426,7 +1426,7 @@ static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno
                 int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;
                 yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
                 y0 = yy0;
-                yy1 = FFMIN(ff_jpeg2000_ceildivpow2(band->coord[1][0] + 1, band->log2_cblk_height) << band->log2_cblk_height,
+                yy1 = FFMINI(ff_jpeg2000_ceildivpow2(band->coord[1][0] + 1, band->log2_cblk_height) << band->log2_cblk_height,
                             band->coord[1][1]) - band->coord[1][0] + yy0;
 
                 if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
@@ -1440,7 +1440,7 @@ static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno
                     else
                         xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
                     x0 = xx0;
-                    xx1 = FFMIN(ff_jpeg2000_ceildivpow2(band->coord[0][0] + 1, band->log2_cblk_width) << band->log2_cblk_width,
+                    xx1 = FFMINI(ff_jpeg2000_ceildivpow2(band->coord[0][0] + 1, band->log2_cblk_width) << band->log2_cblk_width,
                                 band->coord[0][1]) - band->coord[0][0] + xx0;
 
                     for (cblkx = 0; cblkx < prec->nb_codeblocks_width; cblkx++, cblkno++){
@@ -1471,10 +1471,10 @@ static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno
                         encode_cblk(s, &t1, prec->cblk + cblkno, tile, xx1 - xx0, yy1 - yy0,
                                     bandpos, codsty->nreslevels - reslevelno - 1);
                         xx0 = xx1;
-                        xx1 = FFMIN(xx1 + (1 << band->log2_cblk_width), band->coord[0][1] - band->coord[0][0] + x0);
+                        xx1 = FFMINI(xx1 + (1 << band->log2_cblk_width), band->coord[0][1] - band->coord[0][0] + x0);
                     }
                     yy0 = yy1;
-                    yy1 = FFMIN(yy1 + (1 << band->log2_cblk_height), band->coord[1][1] - band->coord[1][0] + y0);
+                    yy1 = FFMINI(yy1 + (1 << band->log2_cblk_height), band->coord[1][1] - band->coord[1][0] + y0);
                 }
             }
         }
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 6433e13892e..8ff463341ad 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -300,14 +300,14 @@ static int init_prec(AVCodecContext *avctx,
     /* Compute P_x1 */
     prec->coord[0][1] = prec->coord[0][0] +
                         (1 << log2_band_prec_width);
-    prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
-    prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
+    prec->coord[0][0] = FFMAXI(prec->coord[0][0], band->coord[0][0]);
+    prec->coord[0][1] = FFMINI(prec->coord[0][1], band->coord[0][1]);
 
     /* Compute P_y1 */
     prec->coord[1][1] = prec->coord[1][0] +
                         (1 << log2_band_prec_height);
-    prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
-    prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
+    prec->coord[1][0] = FFMAXI(prec->coord[1][0], band->coord[1][0]);
+    prec->coord[1][1] = FFMINI(prec->coord[1][1], band->coord[1][1]);
 
     prec->nb_codeblocks_width =
         ff_jpeg2000_ceildivpow2(prec->coord[0][1],
@@ -348,19 +348,19 @@ static int init_prec(AVCodecContext *avctx,
         /* Compute Cx0*/
         Cx0 = ((prec->coord[0][0]) >> band->log2_cblk_width) << band->log2_cblk_width;
         Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width)  << band->log2_cblk_width);
-        cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
+        cblk->coord[0][0] = FFMAXI(Cx0, prec->coord[0][0]);
 
         /* Compute Cy0*/
         Cy0 = ((prec->coord[1][0]) >> band->log2_cblk_height) << band->log2_cblk_height;
         Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width)   << band->log2_cblk_height);
-        cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
+        cblk->coord[1][0] = FFMAXI(Cy0, prec->coord[1][0]);
 
         /* Compute Cx1 */
-        cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
+        cblk->coord[0][1] = FFMINI(Cx0 + (1 << band->log2_cblk_width),
                                   prec->coord[0][1]);
 
         /* Compute Cy1 */
-        cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
+        cblk->coord[1][1] = FFMINI(Cy0 + (1 << band->log2_cblk_height),
                                   prec->coord[1][1]);
         /* Update code-blocks coordinates according sub-band position */
         if ((bandno + !!reslevelno) & 1) {
@@ -420,9 +420,9 @@ static int init_band(AVCodecContext *avctx,
         log2_band_prec_width  = reslevel->log2_prec_width;
         log2_band_prec_height = reslevel->log2_prec_height;
         /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
-        band->log2_cblk_width  = FFMIN(codsty->log2_cblk_width,
+        band->log2_cblk_width  = FFMINI(codsty->log2_cblk_width,
                                        reslevel->log2_prec_width);
-        band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
+        band->log2_cblk_height = FFMINI(codsty->log2_cblk_height,
                                        reslevel->log2_prec_height);
     } else {
         /* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
@@ -438,9 +438,9 @@ static int init_band(AVCodecContext *avctx,
          * in coding/decoding function? */
 
         /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
-        band->log2_cblk_width  = FFMIN(codsty->log2_cblk_width,
+        band->log2_cblk_width  = FFMINI(codsty->log2_cblk_width,
                                        reslevel->log2_prec_width - 1);
-        band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
+        band->log2_cblk_height = FFMINI(codsty->log2_cblk_height,
                                        reslevel->log2_prec_height - 1);
 
         log2_band_prec_width  = reslevel->log2_prec_width  - 1;
diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c
index e96efc28ed9..bb2264f8d01 100644
--- a/libavcodec/jpeg2000_parser.c
+++ b/libavcodec/jpeg2000_parser.c
@@ -109,7 +109,7 @@ static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_
             if (m->skip_bytes > 8) {
                 // need -9 else buf_size - i == 8 ==> i == buf_size after this,
                 // and thus i == buf_size + 1 after the loop
-                int skip = FFMIN(FFMIN((int64_t)m->skip_bytes - 8, buf_size - i - 9), INT_MAX);
+                int skip = FFMINI(FFMINI((int64_t)m->skip_bytes - 8, buf_size - i - 9), INT_MAX);
                 if (skip > 0) {
                     m->skip_bytes -= skip;
                     i += skip;
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index b82d85d5ee5..a953c34d726 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -274,7 +274,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
     for (i = 0; i < s->ncomponents; i++) { // Ssiz_i XRsiz_i, YRsiz_i
         uint8_t x    = bytestream2_get_byteu(&s->g);
         s->cbps[i]   = (x & 0x7f) + 1;
-        s->precision = FFMAX(s->cbps[i], s->precision);
+        s->precision = FFMAXI(s->cbps[i], s->precision);
         s->sgnd[i]   = !!(x & 0x80);
         s->cdx[i]    = bytestream2_get_byteu(&s->g);
         s->cdy[i]    = bytestream2_get_byteu(&s->g);
@@ -319,8 +319,8 @@ static int get_siz(Jpeg2000DecoderContext *s)
     dimx = ff_jpeg2000_ceildiv(o_dimx, s->cdx[0]);
     dimy = ff_jpeg2000_ceildiv(o_dimy, s->cdy[0]);
     for (i = 1; i < s->ncomponents; i++) {
-        dimx = FFMAX(dimx, ff_jpeg2000_ceildiv(o_dimx, s->cdx[i]));
-        dimy = FFMAX(dimy, ff_jpeg2000_ceildiv(o_dimy, s->cdy[i]));
+        dimx = FFMAXI(dimx, ff_jpeg2000_ceildiv(o_dimx, s->cdx[i]));
+        dimy = FFMAXI(dimy, ff_jpeg2000_ceildiv(o_dimy, s->cdy[i]));
     }
 
     ret = ff_set_dimensions(s->avctx, dimx << s->avctx->lowres, dimy << s->avctx->lowres);
@@ -703,7 +703,7 @@ static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
         q->expn[0] = x >> 11;
         q->mant[0] = x & 0x7ff;
         for (i = 1; i < JPEG2000_MAX_DECLEVELS * 3; i++) {
-            int curexpn = FFMAX(0, q->expn[0] - (i - 1) / 3);
+            int curexpn = FFMAXI(0, q->expn[0] - (i - 1) / 3);
             q->expn[i] = curexpn;
             q->mant[i] = q->mant[0];
         }
@@ -1446,7 +1446,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
                     tmp_length = (tmp_length < cblk->lengthinc[i]) ? cblk->lengthinc[i] : tmp_length;
 
                 if (tmp_length > cblk->data_allocated) {
-                    size_t new_size = FFMAX(2 * cblk->data_allocated, tmp_length);
+                    size_t new_size = FFMAXI(2 * cblk->data_allocated, tmp_length);
                     void *new = av_realloc(cblk->data, new_size);
                     if (new) {
                         cblk->data = new;
@@ -1493,7 +1493,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
                 continue;
             for (cwsno = 0; cwsno < cblk->nb_lengthinc; cwsno ++) {
                 if (cblk->data_allocated < cblk->length + cblk->lengthinc[cwsno] + 4) {
-                    size_t new_size = FFMAX(2*cblk->data_allocated, cblk->length + cblk->lengthinc[cwsno] + 4);
+                    size_t new_size = FFMAXI(2*cblk->data_allocated, cblk->length + cblk->lengthinc[cwsno] + 4);
                     void *new = av_realloc(cblk->data, new_size);
                     if (new) {
                         cblk->data = new;
@@ -1618,14 +1618,14 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
             step_x = 32;
             step_y = 32;
 
-            if (RSpoc >= FFMIN(codsty->nreslevels, REpoc))
+            if (RSpoc >= FFMINI(codsty->nreslevels, REpoc))
                 continue;
 
-            for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) {
+            for (reslevelno = RSpoc; reslevelno < FFMINI(codsty->nreslevels, REpoc); reslevelno++) {
                 uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                 Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
-                step_x = FFMIN(step_x, rlevel->log2_prec_width  + reducedresno);
-                step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno);
+                step_x = FFMINI(step_x, rlevel->log2_prec_width  + reducedresno);
+                step_y = FFMINI(step_y, rlevel->log2_prec_height + reducedresno);
             }
             if (step_x >= 31 || step_y >= 31){
                 avpriv_request_sample(s->avctx, "CPRL with large step");
@@ -1636,7 +1636,7 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
 
             for (y = tile->coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
                 for (x = tile->coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
-                    for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) {
+                    for (reslevelno = RSpoc; reslevelno < FFMINI(codsty->nreslevels, REpoc); reslevelno++) {
                         unsigned prcx, prcy;
                         uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                         Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
@@ -1690,8 +1690,8 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
                 if (reslevelno < codsty->nreslevels) {
                     uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                     Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
-                    step_x = FFMIN(step_x, rlevel->log2_prec_width  + reducedresno);
-                    step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno);
+                    step_x = FFMINI(step_x, rlevel->log2_prec_width  + reducedresno);
+                    step_y = FFMINI(step_y, rlevel->log2_prec_height + reducedresno);
                 }
             }
             step_x = 1<<step_x;
@@ -1762,11 +1762,11 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
             Jpeg2000Component *comp     = tile->comp + compno;
             Jpeg2000CodingStyle *codsty = tile->codsty + compno;
 
-            for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) {
+            for (reslevelno = RSpoc; reslevelno < FFMINI(codsty->nreslevels, REpoc); reslevelno++) {
                 uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                 Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
-                step_x = FFMIN(step_x, rlevel->log2_prec_width  + reducedresno);
-                step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno);
+                step_x = FFMINI(step_x, rlevel->log2_prec_width  + reducedresno);
+                step_y = FFMINI(step_y, rlevel->log2_prec_height + reducedresno);
             }
         }
         if (step_x >= 31 || step_y >= 31){
@@ -1786,7 +1786,7 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
                     if (!s->cdx[compno] || !s->cdy[compno])
                         return AVERROR_INVALIDDATA;
 
-                    for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) {
+                    for (reslevelno = RSpoc; reslevelno < FFMINI(codsty->nreslevels, REpoc); reslevelno++) {
                         unsigned prcx, prcy;
                         uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; //  ==> N_L - r
                         Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
@@ -1849,9 +1849,9 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
             Jpeg2000POCEntry *e = &tile->poc.poc[i];
             ret = jpeg2000_decode_packets_po_iteration(s, tile,
                 e->RSpoc, e->CSpoc,
-                FFMIN(e->LYEpoc, tile->codsty[0].nlayers),
+                FFMINI(e->LYEpoc, tile->codsty[0].nlayers),
                 e->REpoc,
-                FFMIN(e->CEpoc, s->ncomponents),
+                FFMINI(e->CEpoc, s->ncomponents),
                 e->Ppoc, &tp_index
                 );
             if (ret < 0)
diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index 9ee8122658d..fea5d76d3b0 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -549,7 +549,7 @@ int ff_jpeg2000_dwt_init(DWTContext *s, int border[2][2],
         for (j = 0; j < 2; j++)
             b[i][j] = border[i][j];
 
-    maxlen = FFMAX(b[0][1] - b[0][0],
+    maxlen = FFMAXI(b[0][1] - b[0][0],
                    b[1][1] - b[1][0]);
     while (--lev >= 0)
         for (i = 0; i < 2; i++) {
diff --git a/libavcodec/jpegls.c b/libavcodec/jpegls.c
index 7b4bc30e466..500592cb3fc 100644
--- a/libavcodec/jpegls.c
+++ b/libavcodec/jpegls.c
@@ -42,11 +42,11 @@ void ff_jpegls_init_state(JLSState *state)
     for (state->qbpp = 0; (1 << state->qbpp) < state->range; state->qbpp++)
         ;
 
-    state->bpp   = FFMAX(av_log2(state->maxval) + 1, 2);
-    state->limit = 2*(state->bpp + FFMAX(state->bpp, 8)) - state->qbpp;
+    state->bpp   = FFMAXI(av_log2(state->maxval) + 1, 2);
+    state->limit = 2*(state->bpp + FFMAXI(state->bpp, 8)) - state->qbpp;
 
     for (i = 0; i < 367; i++) {
-        state->A[i] = FFMAX(state->range + 32 >> 6, 2);
+        state->A[i] = FFMAXI(state->range + 32 >> 6, 2);
         state->N[i] = 1;
     }
 }
@@ -73,7 +73,7 @@ void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
         s->maxval = (1 << s->bpp) - 1;
 
     if (s->maxval >= 128) {
-        factor = FFMIN(s->maxval, 4095) + 128 >> 8;
+        factor = FFMINI(s->maxval, 4095) + 128 >> 8;
 
         if (s->T1 == 0 || reset_all)
             s->T1 = iso_clip(factor * (basic_t1 - 2) + 2 + 3 * s->near,
@@ -88,13 +88,13 @@ void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
         factor = 256 / (s->maxval + 1);
 
         if (s->T1 == 0 || reset_all)
-            s->T1 = iso_clip(FFMAX(2, basic_t1 / factor + 3 * s->near),
+            s->T1 = iso_clip(FFMAXI(2, basic_t1 / factor + 3 * s->near),
                              s->near + 1, s->maxval);
         if (s->T2 == 0 || reset_all)
-            s->T2 = iso_clip(FFMAX(3, basic_t2 / factor + 5 * s->near),
+            s->T2 = iso_clip(FFMAXI(3, basic_t2 / factor + 5 * s->near),
                              s->T1, s->maxval);
         if (s->T3 == 0 || reset_all)
-            s->T3 = iso_clip(FFMAX(4, basic_t3 / factor + 7 * s->near),
+            s->T3 = iso_clip(FFMAXI(4, basic_t3 / factor + 7 * s->near),
                              s->T2, s->maxval);
     }
 
diff --git a/libavcodec/jpegls.h b/libavcodec/jpegls.h
index ebf9159371d..07579a3a37a 100644
--- a/libavcodec/jpegls.h
+++ b/libavcodec/jpegls.h
@@ -103,11 +103,11 @@ static inline int ff_jpegls_update_state_regular(JLSState *state,
     ff_jpegls_downscale_state(state, Q);
 
     if (state->B[Q] <= -state->N[Q]) {
-        state->B[Q] = FFMAX(state->B[Q] + state->N[Q], 1 - state->N[Q]);
+        state->B[Q] = FFMAXI(state->B[Q] + state->N[Q], 1 - state->N[Q]);
         if (state->C[Q] > -128)
             state->C[Q]--;
     } else if (state->B[Q] > 0) {
-        state->B[Q] = FFMIN(state->B[Q] - state->N[Q], 0);
+        state->B[Q] = FFMINI(state->B[Q] - state->N[Q], 0);
         if (state->C[Q] < 127)
             state->C[Q]++;
     }
diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index 5f463c96607..1f171b914df 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -103,7 +103,7 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s)
             avpriv_request_sample(s->avctx, ">8bit palette");
             return AVERROR_PATCHWELCOME;
         }
-        maxtab = FFMIN(maxtab, (len - 5) / wt + s->palette_index);
+        maxtab = FFMINI(maxtab, (len - 5) / wt + s->palette_index);
 
         if (s->palette_index > maxtab)
             return AVERROR_INVALIDDATA;
@@ -114,7 +114,7 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s)
             int shift = 0;
 
             if (s->avctx->bits_per_raw_sample > 0 && s->avctx->bits_per_raw_sample < 8) {
-                maxtab = FFMIN(maxtab, (1<<s->avctx->bits_per_raw_sample)-1);
+                maxtab = FFMINI(maxtab, (1<<s->avctx->bits_per_raw_sample)-1);
                 shift = 8 - s->avctx->bits_per_raw_sample;
             }
 
@@ -391,7 +391,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
         state->T1 > state->T2 ||
         state->T2 > state->T3 ||
         state->T3 > state->maxval ||
-        state->reset > FFMAX(255, state->maxval)) {
+        state->reset > FFMAXI(255, state->maxval)) {
         ret = AVERROR_INVALIDDATA;
         goto end;
     }
diff --git a/libavcodec/jpegxl_parse.c b/libavcodec/jpegxl_parse.c
index 022eed322de..a2d95223ae0 100644
--- a/libavcodec/jpegxl_parse.c
+++ b/libavcodec/jpegxl_parse.c
@@ -517,5 +517,5 @@ int ff_jpegxl_collect_codestream_header(const uint8_t *input_buffer, int input_l
             break;
     }
 
-    return FFMIN(pos, INT_MAX);
+    return FFMINI(pos, INT_MAX);
 }
diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c
index 68404229a5e..df379ad3cb9 100644
--- a/libavcodec/jpegxl_parser.c
+++ b/libavcodec/jpegxl_parser.c
@@ -400,7 +400,7 @@ static int populate_distribution(GetBitContext *gb, JXLSymbolDistribution *dist,
             dist->freq[v2] = (1 << 12) - dist->freq[v1];
             if (!dist->freq[v1])
                 dist->uniq_pos = v2;
-            dist->alphabet_size = 1 + FFMAX(v1, v2);
+            dist->alphabet_size = 1 + FFMAXI(v1, v2);
         } else {
             uint8_t x = jxl_u8(gb);
             dist->freq[x] = 1 << 12;
@@ -468,7 +468,7 @@ static int populate_distribution(GetBitContext *gb, JXLSymbolDistribution *dist,
             if (logcounts[i] == 1) {
                 dist->freq[i] = 1;
             } else {
-                int bitcount = FFMIN(FFMAX(0, shift - ((12 - logcounts[i] + 1) >> 1)), logcounts[i] - 1);
+                int bitcount = FFMINI(FFMAXI(0, shift - ((12 - logcounts[i] + 1) >> 1)), logcounts[i] - 1);
                 dist->freq[i] = (1 << (logcounts[i] - 1)) + (get_bitsz(gb, bitcount) << (logcounts[i] - 1 - bitcount));
             }
         }
@@ -772,7 +772,7 @@ static int read_vlc_prefix(GetBitContext *gb, JXLEntropyDecoder *dec, JXLSymbolD
             int extra = 3 + get_bits(gb, 2);
             if (repeat_count_prev)
                 extra += 4 * (repeat_count_prev - 2) - repeat_count_prev;
-            extra = FFMIN(extra, dist->alphabet_size - i);
+            extra = FFMINI(extra, dist->alphabet_size - i);
             for (int j = 0; j < extra; j++)
                 level2_lens[i + j] = prev;
             total_code += (32768 >> prev) * extra;
@@ -784,7 +784,7 @@ static int read_vlc_prefix(GetBitContext *gb, JXLEntropyDecoder *dec, JXLSymbolD
             int extra = 3 + get_bits(gb, 3);
             if (repeat_count_zero > 0)
                 extra += 8 * (repeat_count_zero - 2) - repeat_count_zero;
-            extra = FFMIN(extra, dist->alphabet_size - i);
+            extra = FFMINI(extra, dist->alphabet_size - i);
             i += extra - 1;
             repeat_count_prev = 0;
             repeat_count_zero += extra;
@@ -987,7 +987,7 @@ static inline uint32_t icc_context(uint64_t i, uint32_t b1, uint32_t b2)
 
 static inline uint32_t toc_context(uint32_t x)
 {
-    return FFMIN(7, clog1p(x));
+    return FFMINI(7, clog1p(x));
 }
 
 static void populate_fields(AVCodecParserContext *s, AVCodecContext *avctx, const FFJXLMetadata *meta)
@@ -1421,7 +1421,7 @@ static int64_t try_parse(AVCodecParserContext *s, AVCodecContext *avctx, JXLPars
             return AVERROR_BUFFER_TOO_SMALL;
         }
         cs_buffer = ctx->cs_buffer;
-        cs_buflen = FFMIN(sizeof(ctx->cs_buffer) - AV_INPUT_BUFFER_PADDING_SIZE, ctx->copied);
+        cs_buflen = FFMINI(sizeof(ctx->cs_buffer) - AV_INPUT_BUFFER_PADDING_SIZE, ctx->copied);
     } else {
         cs_buffer = buf;
         cs_buflen = buf_size;
diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
index 0969448eda4..8494f4a454e 100644
--- a/libavcodec/lagarith.c
+++ b/libavcodec/lagarith.c
@@ -359,7 +359,7 @@ static int lag_decode_line(LagarithContext *l, lag_rac *rac,
     /* Output any zeros remaining from the previous run */
 handle_zeros:
     if (l->zeros_rem) {
-        int count = FFMIN(l->zeros_rem, width - i);
+        int count = FFMINI(l->zeros_rem, width - i);
         memset(dst + i, 0, count);
         i += count;
         l->zeros_rem -= count;
@@ -406,7 +406,7 @@ static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,
 
 output_zeros:
     if (l->zeros_rem) {
-        count = FFMIN(l->zeros_rem, width - i);
+        count = FFMINI(l->zeros_rem, width - i);
         if (end - dst < count) {
             av_log(l->avctx, AV_LOG_ERROR, "Too many zeros remaining.\n");
             return AVERROR_INVALIDDATA;
diff --git a/libavcodec/lagarithrac.c b/libavcodec/lagarithrac.c
index cdda67fb815..37380eae9b3 100644
--- a/libavcodec/lagarithrac.c
+++ b/libavcodec/lagarithrac.c
@@ -45,7 +45,7 @@ void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length)
 
     l->range        = 0x80;
     l->low          = *l->bytestream >> 1;
-    l->hash_shift   = FFMAX(l->scale, 10) - 10;
+    l->hash_shift   = FFMAXI(l->scale, 10) - 10;
     l->overread     = 0;
 
     for (i = j = 0; i < 1024; i++) {
diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c
index b439dbe25e4..ac4ef930ced 100644
--- a/libavcodec/lcldec.c
+++ b/libavcodec/lcldec.c
@@ -93,9 +93,9 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign
             unsigned ofs = bytestream_get_le16(&srcptr);
             unsigned cnt = (ofs >> 11) + 1;
             ofs &= 0x7ff;
-            ofs = FFMIN(ofs, destptr - destptr_bak);
+            ofs = FFMINI(ofs, destptr - destptr_bak);
             cnt *= 4;
-            cnt = FFMIN(cnt, destptr_end - destptr);
+            cnt = FFMINI(cnt, destptr_end - destptr);
             if (ofs) {
                 av_memcpy_backptr(destptr, ofs, cnt);
             } else {
@@ -200,7 +200,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                     return AVERROR_INVALIDDATA;
                 }
                 mthread_outlen = AV_RL32(buf + 4);
-                mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
+                mthread_outlen = FFMINI(mthread_outlen, c->decomp_size);
                 mszh_dlen = mszh_decomp(buf + 8, mthread_inlen, c->decomp_buf, c->decomp_size);
                 if (mthread_outlen != mszh_dlen) {
                     av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
@@ -275,9 +275,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
             }
         } else if (c->flags & FLAG_MULTITHREAD) {
             mthread_inlen = AV_RL32(buf);
-            mthread_inlen = FFMIN(mthread_inlen, len - 8);
+            mthread_inlen = FFMINI(mthread_inlen, len - 8);
             mthread_outlen = AV_RL32(buf + 4);
-            mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
+            mthread_outlen = FFMINI(mthread_outlen, c->decomp_size);
             ret = zlib_decomp(avctx, buf + 8, mthread_inlen, 0, mthread_outlen);
             if (ret < 0) return ret;
             ret = zlib_decomp(avctx, buf + 8 + mthread_inlen, len - 8 - mthread_inlen,
diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index ac221645f06..f7fe3d9eeef 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -424,7 +424,7 @@ static int fdk_aac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     if (flags & AACDEC_FLUSH) {
         // Only return the right amount of samples at the end; if calling the
         // decoder with AACDEC_FLUSH, it will keep returning frames indefinitely.
-        frame->nb_samples = FFMIN(s->flush_samples, frame->nb_samples);
+        frame->nb_samples = FFMINI(s->flush_samples, frame->nb_samples);
         av_log(s, AV_LOG_DEBUG, "Returning %d/%d delayed samples.\n",
                                 frame->nb_samples, s->flush_samples);
         s->flush_samples -= frame->nb_samples;
@@ -433,7 +433,7 @@ static int fdk_aac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         // delay. We could also just adjust the pts, but this avoids
         // including the extra samples in the output altogether.
         if (s->delay_samples) {
-            int drop_samples = FFMIN(s->delay_samples, frame->nb_samples);
+            int drop_samples = FFMINI(s->delay_samples, frame->nb_samples);
             av_log(s, AV_LOG_DEBUG, "Dropping %d/%d delayed samples.\n",
                                     drop_samples, s->delay_samples);
             s->delay_samples  -= drop_samples;
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index 1a3f127d370..b478457e95e 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -501,7 +501,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     in_buf.bufElSizes        = in_buffer_element_sizes;
 
     /* The maximum packet size is 6144 bits aka 768 bytes per channel. */
-    ret = ff_alloc_packet(avctx, avpkt, FFMAX(8192, 768 * avctx->ch_layout.nb_channels));
+    ret = ff_alloc_packet(avctx, avpkt, FFMAXI(8192, 768 * avctx->ch_layout.nb_channels));
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/liblc3dec.c b/libavcodec/liblc3dec.c
index d250ace38a5..de25a8db468 100644
--- a/libavcodec/liblc3dec.c
+++ b/libavcodec/liblc3dec.c
@@ -124,7 +124,7 @@ static int liblc3_decode(AVCodecContext *avctx, AVFrame *frame,
         in += nbytes;
     }
 
-    frame->nb_samples = FFMIN(frame->nb_samples, avpkt->duration);
+    frame->nb_samples = FFMINI(frame->nb_samples, avpkt->duration);
 
     *got_frame_ptr = 1;
 
diff --git a/libavcodec/liblc3enc.c b/libavcodec/liblc3enc.c
index 66007a90f3e..453698c378b 100644
--- a/libavcodec/liblc3enc.c
+++ b/libavcodec/liblc3enc.c
@@ -146,7 +146,7 @@ static int liblc3_encode(AVCodecContext *avctx, AVPacket *pkt,
 
     if (frame) {
         int padding = frame->nb_samples - frame->duration;
-        liblc3->remaining_samples = FFMAX(liblc3->delay_samples - padding, 0);
+        liblc3->remaining_samples = FFMAXI(liblc3->delay_samples - padding, 0);
     } else {
         if (!liblc3->remaining_samples)
             return 0;
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 6f6f2646364..db45b5f5bb5 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -140,7 +140,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
     param.iPicWidth                  = avctx->width;
     param.iPicHeight                 = avctx->height;
     param.iTargetBitrate             = avctx->bit_rate > 0 ? avctx->bit_rate : TARGET_BITRATE_DEFAULT;
-    param.iMaxBitrate                = FFMAX(avctx->rc_max_rate, avctx->bit_rate);
+    param.iMaxBitrate                = FFMAXI(avctx->rc_max_rate, avctx->bit_rate);
     param.iRCMode                    = s->rc_mode;
     if (avctx->qmax >= 0)
         param.iMaxQp                 = av_clip(avctx->qmax, 1, 51);
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index b797d34e1cb..6d8b602e228 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -326,7 +326,7 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
 
     if (!ctx->numresolution) {
         ctx->numresolution = 6;
-        while (FFMIN(avctx->width, avctx->height) >> ctx->numresolution < 1)
+        while (FFMINI(avctx->width, avctx->height) >> ctx->numresolution < 1)
             ctx->numresolution --;
     }
 
@@ -336,7 +336,7 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
     ctx->enc_params.cp_disto_alloc = ctx->disto_alloc;
     ctx->enc_params.cp_fixed_quality = ctx->fixed_quality;
     ctx->enc_params.tcp_numlayers = 1;
-    ctx->enc_params.tcp_rates[0] = FFMAX(avctx->compression_level, 0) * 2;
+    ctx->enc_params.tcp_rates[0] = FFMAXI(avctx->compression_level, 0) * 2;
 
     if (ctx->cinema_mode > 0) {
         cinema_parameters(&ctx->enc_params);
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index c6187fd5a14..4cf5336e3cf 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -88,7 +88,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
                             const struct vpx_codec_iface *iface)
 {
     struct vpx_codec_dec_cfg deccfg = {
-        .threads = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), MAX_VPX_THREADS)
+        .threads = FFMINI(avctx->thread_count ? avctx->thread_count : av_cpu_count(), MAX_VPX_THREADS)
     };
 
     av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 406333d45f5..0f2956e62bc 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1012,7 +1012,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
     enccfg.g_timebase.num = avctx->time_base.num;
     enccfg.g_timebase.den = avctx->time_base.den;
     enccfg.g_threads      =
-        FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), MAX_VPX_THREADS);
+        FFMINI(avctx->thread_count ? avctx->thread_count : av_cpu_count(), MAX_VPX_THREADS);
     enccfg.g_lag_in_frames= ctx->lag_in_frames;
 
     if (avctx->flags & AV_CODEC_FLAG_PASS1)
diff --git a/libavcodec/libwebpenc_common.c b/libavcodec/libwebpenc_common.c
index 80040ea9e3e..d8f57647409 100644
--- a/libavcodec/libwebpenc_common.c
+++ b/libavcodec/libwebpenc_common.c
@@ -210,8 +210,8 @@ int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s,
                             int h = AV_CEIL_RSHIFT(frame->height, !!p);
                             int xs = x >> !!p;
                             int ys = y >> !!p;
-                            for (y2 = ys; y2 < FFMIN(ys + bs2, h); y2++) {
-                                for (x2 = xs; x2 < FFMIN(xs + bs2, w); x2++) {
+                            for (y2 = ys; y2 < FFMINI(ys + bs2, h); y2++) {
+                                for (x2 = xs; x2 < FFMINI(xs + bs2, w); x2++) {
                                     int diff =  frame->data[p][frame->linesize[p] * y2 + x2]
                                               -s->ref->data[p][frame->linesize[p] * y2 + x2];
                                     sse += diff*diff;
@@ -226,15 +226,15 @@ int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s,
                                 int h = AV_CEIL_RSHIFT(frame->height, !!p);
                                 int xs = x >> !!p;
                                 int ys = y >> !!p;
-                                for (y2 = ys; y2 < FFMIN(ys + bs2, h); y2++) {
+                                for (y2 = ys; y2 < FFMINI(ys + bs2, h); y2++) {
                                     memcpy(&s->ref->data[p][frame->linesize[p] * y2 + xs],
-                                            & frame->data[p][frame->linesize[p] * y2 + xs], FFMIN(bs2, w-xs));
+                                            & frame->data[p][frame->linesize[p] * y2 + xs], FFMINI(bs2, w-xs));
                                 }
                             }
-                        for (y2 = y; y2 < FFMIN(y+bs, frame->height); y2++) {
+                        for (y2 = y; y2 < FFMINI(y+bs, frame->height); y2++) {
                             memset(&frame->data[3][frame->linesize[3] * y2 + x],
                                     skip ? 0 : 255,
-                                    FFMIN(bs, frame->width-x));
+                                    FFMINI(bs, frame->width-x));
                         }
                     }
                 }
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index d7f8683b09f..4557cf51110 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -156,7 +156,7 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
 {
     X264Context *x4 = ctx->priv_data;
     uint8_t *p;
-    uint64_t size = FFMAX(x4->sei_size, 0);
+    uint64_t size = FFMAXI(x4->sei_size, 0);
     int ret;
 
     if (!nnal)
@@ -439,10 +439,10 @@ static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic,
 
         roi = (const AVRegionOfInterest*)(data + roi_size * i);
 
-        starty = FFMIN(mby, roi->top / MB_SIZE);
-        endy   = FFMIN(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE);
-        startx = FFMIN(mbx, roi->left / MB_SIZE);
-        endx   = FFMIN(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE);
+        starty = FFMINI(mby, roi->top / MB_SIZE);
+        endy   = FFMINI(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE);
+        startx = FFMINI(mbx, roi->left / MB_SIZE);
+        endx   = FFMINI(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE);
 
         if (roi->qoffset.den == 0) {
             av_free(qoffsets);
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index d897707dd79..69c80f4d614 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -638,10 +638,10 @@ static av_cold int libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
 
                 roi = (const AVRegionOfInterest*)(sd->data + roi_size * i);
 
-                starty = FFMIN(mby, roi->top / mb_size);
-                endy   = FFMIN(mby, (roi->bottom + mb_size - 1)/ mb_size);
-                startx = FFMIN(mbx, roi->left / mb_size);
-                endx   = FFMIN(mbx, (roi->right + mb_size - 1)/ mb_size);
+                starty = FFMINI(mby, roi->top / mb_size);
+                endy   = FFMINI(mby, (roi->bottom + mb_size - 1)/ mb_size);
+                startx = FFMINI(mbx, roi->left / mb_size);
+                endx   = FFMINI(mbx, (roi->right + mb_size - 1)/ mb_size);
 
                 if (roi->qoffset.den == 0) {
                     av_free(qoffsets);
diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c
index e02ecb8b3a3..dd0d5fccecb 100644
--- a/libavcodec/libzvbi-teletextdec.c
+++ b/libavcodec/libzvbi-teletextdec.c
@@ -323,8 +323,8 @@ static int gen_sub_ass(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page
                 can_align_center = 0;
             last_leading = leading;
             last_trailing = trailing;
-            min_leading = FFMIN(leading, min_leading);
-            min_trailing = FFMIN(trailing, min_trailing);
+            min_leading = FFMINI(leading, min_leading);
+            min_trailing = FFMINI(trailing, min_trailing);
         }
     }
 
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index e793e540387..60d049be7a7 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -145,7 +145,7 @@ static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
     /* find maximum coefficient value */
     cmax = 0.0;
     for(i=0; i<order; i++) {
-        cmax= FFMAX(cmax, fabs(lpc_in[i]));
+        cmax= FFMAXD(cmax, fabs(lpc_in[i]));
     }
 
     /* if maximum value quantizes to zero, return all zeros */
diff --git a/libavcodec/lscrdec.c b/libavcodec/lscrdec.c
index fb8cdfa9f84..e304d73702d 100644
--- a/libavcodec/lscrdec.c
+++ b/libavcodec/lscrdec.c
@@ -77,7 +77,7 @@ static void handle_row(LSCRContext *s)
 static int decode_idat(LSCRContext *s, z_stream *zstream, int length)
 {
     int ret;
-    zstream->avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb));
+    zstream->avail_in = FFMINI(length, bytestream2_get_bytes_left(&s->gb));
     zstream->next_in  = s->gb.buffer;
 
     if (length <= 0)
diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 4eaeb2bfc2c..dc5286e8985 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -46,10 +46,10 @@ void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, in
 
     for(i=0; i<lp_order; i++)
     {
-        lsfq[i] = FFMAX(lsfq[i], lsfq_min);
+        lsfq[i] = FFMAXI(lsfq[i], lsfq_min);
         lsfq_min = lsfq[i] + lsfq_min_distance;
     }
-    lsfq[lp_order-1] = FFMIN(lsfq[lp_order-1], lsfq_max);//Is warning required ?
+    lsfq[lp_order-1] = FFMINI(lsfq[lp_order-1], lsfq_max);//Is warning required ?
 }
 
 void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size)
@@ -57,7 +57,7 @@ void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size)
     int i;
     float prev = 0.0;
     for (i = 0; i < size; i++)
-        prev = lsf[i] = FFMAX(lsf[i], prev + min_spacing);
+        prev = lsf[i] = FFMAXD(lsf[i], prev + min_spacing);
 }
 
 
diff --git a/libavcodec/lzwenc.c b/libavcodec/lzwenc.c
index ae1816a03e9..6dcd817bed8 100644
--- a/libavcodec/lzwenc.c
+++ b/libavcodec/lzwenc.c
@@ -130,7 +130,7 @@ static inline void writeCode(LZWEncodeState * s, int c)
  */
 static inline int findCode(LZWEncodeState * s, uint8_t c, int hash_prefix)
 {
-    int h = hash(FFMAX(hash_prefix, 0), c);
+    int h = hash(FFMAXI(hash_prefix, 0), c);
     int hash_offset = hashOffset(h);
 
     while (s->tab[h].hash_prefix != LZW_PREFIX_FREE) {
diff --git a/libavcodec/mace.c b/libavcodec/mace.c
index 2aa54fb548d..808985b226d 100644
--- a/libavcodec/mace.c
+++ b/libavcodec/mace.c
@@ -203,7 +203,7 @@ static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, int tab_idx)
     int16_t current = read_table(chd, val, tab_idx);
 
     if ((chd->previous ^ current) >= 0) {
-        chd->factor = FFMIN(chd->factor + 506, 32767);
+        chd->factor = FFMINI(chd->factor + 506, 32767);
     } else {
         if (chd->factor - 314 < -32768)
             chd->factor = -32767;
diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index e106228757a..0b4ab061638 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -93,7 +93,7 @@ static int huff_build(AVCodecContext *avctx,
 
     ff_vlc_free(vlc);
     ff_vlc_free_multi(multi);
-    return ff_vlc_init_multi_from_lengths(vlc, multi, FFMIN(he[0].len, VLC_BITS), nb_elems, nb_elems,
+    return ff_vlc_init_multi_from_lengths(vlc, multi, FFMINI(he[0].len, VLC_BITS), nb_elems, nb_elems,
                                     &he[0].len, sizeof(he[0]),
                                     &he[0].sym, sizeof(he[0]), sizeof(he[0].sym),
                                     0, 0, logctx);
@@ -149,7 +149,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata,
 
     for (i = 0; i < s->planes; i++) {
         int left, lefttop, top;
-        int height = AV_CEIL_RSHIFT(FFMIN(s->slice_height, avctx->coded_height - j * s->slice_height), s->vshift[i]);
+        int height = AV_CEIL_RSHIFT(FFMINI(s->slice_height, avctx->coded_height - j * s->slice_height), s->vshift[i]);
         int width = AV_CEIL_RSHIFT(avctx->coded_width, s->hshift[i]);
         int sheight = AV_CEIL_RSHIFT(s->slice_height, s->vshift[i]);
         ptrdiff_t fake_stride = (p->linesize[i] / 2) * (1 + interlaced);
@@ -238,7 +238,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata,
     }
 
     if (s->decorrelate) {
-        int height = FFMIN(s->slice_height, avctx->coded_height - j * s->slice_height);
+        int height = FFMINI(s->slice_height, avctx->coded_height - j * s->slice_height);
         int width = avctx->coded_width;
         uint16_t *r = (uint16_t *)p->data[0] + j * s->slice_height * p->linesize[0] / 2;
         uint16_t *g = (uint16_t *)p->data[1] + j * s->slice_height * p->linesize[1] / 2;
@@ -270,7 +270,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata,
 
     for (i = 0; i < s->planes; i++) {
         int left, lefttop, top;
-        int height = AV_CEIL_RSHIFT(FFMIN(s->slice_height, avctx->coded_height - j * s->slice_height), s->vshift[i]);
+        int height = AV_CEIL_RSHIFT(FFMINI(s->slice_height, avctx->coded_height - j * s->slice_height), s->vshift[i]);
         int width = AV_CEIL_RSHIFT(avctx->coded_width, s->hshift[i]);
         int sheight = AV_CEIL_RSHIFT(s->slice_height, s->vshift[i]);
         ptrdiff_t fake_stride = p->linesize[i] * (1 + interlaced);
@@ -324,7 +324,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata,
                 s->llviddsp.add_left_pred(dst, dst, width, 0);
                 dst += stride;
             }
-            min_width = FFMIN(width, 32);
+            min_width = FFMINI(width, 32);
             for (k = 1 + interlaced; k < height; k++) {
                 top = dst[-fake_stride];
                 left = top + dst[0];
@@ -362,7 +362,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata,
     }
 
     if (s->decorrelate) {
-        int height = FFMIN(s->slice_height, avctx->coded_height - j * s->slice_height);
+        int height = FFMINI(s->slice_height, avctx->coded_height - j * s->slice_height);
         int width = avctx->coded_width;
         uint8_t *b = p->data[0] + j * s->slice_height * p->linesize[0];
         uint8_t *g = p->data[1] + j * s->slice_height * p->linesize[1];
@@ -556,7 +556,7 @@ static int magy_decode_frame(AVCodecContext *avctx, AVFrame *p,
     bytestream2_skipu(&gb, 4);
 
     s->nb_slices = (avctx->coded_height + s->slice_height - 1) / s->slice_height;
-    if (s->nb_slices > INT_MAX / FFMAX(sizeof(Slice), 4 * 5)) {
+    if (s->nb_slices > INT_MAX / FFMAXI(sizeof(Slice), 4 * 5)) {
         av_log(avctx, AV_LOG_ERROR,
                "invalid number of slices: %d\n", s->nb_slices);
         return AVERROR_INVALIDDATA;
diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 02b570d618f..6928dd80e71 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -204,11 +204,11 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
     s->planes = av_pix_fmt_count_planes(avctx->pix_fmt);
 
     s->nb_slices = avctx->slices > 0 ? avctx->slices : avctx->thread_count;
-    s->nb_slices = FFMIN(s->nb_slices, avctx->height >> s->vshift[1]);
-    s->nb_slices = FFMAX(1, s->nb_slices);
+    s->nb_slices = FFMINI(s->nb_slices, avctx->height >> s->vshift[1]);
+    s->nb_slices = FFMAXI(1, s->nb_slices);
     s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / s->nb_slices, 1 << s->vshift[1]);
     s->nb_slices = (avctx->height + s->slice_height - 1) / s->slice_height;
-    s->nb_slices = FFMIN(256U / s->planes, s->nb_slices);
+    s->nb_slices = FFMINI(256U / s->planes, s->nb_slices);
     s->slices = av_calloc(s->nb_slices * s->planes, sizeof(*s->slices));
     if (!s->slices)
         return AVERROR(ENOMEM);
@@ -487,7 +487,7 @@ static int predict_slice(AVCodecContext *avctx, void *tdata,
     const int aligned_width = FFALIGN(avctx->width, max_align);
     MagicYUVContext *s = avctx->priv_data;
     const int slice_height = s->slice_height;
-    const int last_height = FFMIN(slice_height, avctx->height - n * slice_height);
+    const int last_height = FFMINI(slice_height, avctx->height - n * slice_height);
     const int height = (n < (s->nb_slices - 1)) ? slice_height : last_height;
     const int width = avctx->width;
     AVFrame *frame = tdata;
diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 3e074ddf476..8f25f21cc40 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -116,11 +116,11 @@ static inline av_const int mid_pred(int a, int b, int c)
 static inline av_const int median4(int a, int b, int c, int d)
 {
     if (a < b) {
-        if (c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2;
-        else       return (FFMIN(b, c) + FFMAX(a, d)) / 2;
+        if (c < d) return (FFMINI(b, d) + FFMAXI(a, c)) / 2;
+        else       return (FFMINI(b, c) + FFMAXI(a, d)) / 2;
     } else {
-        if (c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2;
-        else       return (FFMIN(a, c) + FFMAX(b, d)) / 2;
+        if (c < d) return (FFMINI(a, d) + FFMAXI(b, c)) / 2;
+        else       return (FFMINI(a, c) + FFMAXI(b, d)) / 2;
     }
 }
 #endif
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index 2a8ede59557..7f4b9912b76 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -720,7 +720,7 @@ static int dct_max8x8_c(MPVEncContext *const s, const uint8_t *src1,
     s->fdsp.fdct(temp);
 
     for (i = 0; i < 64; i++)
-        sum = FFMAX(sum, FFABS(temp[i]));
+        sum = FFMAXI(sum, FFABS(temp[i]));
 
     return sum;
 }
diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
index ff44130ca95..ddaa28b6773 100644
--- a/libavcodec/mf_utils.c
+++ b/libavcodec/mf_utils.c
@@ -84,7 +84,7 @@ IMFSample *ff_create_memory_sample(MFFunctions *f,void *fill_data, size_t size,
     if (FAILED(hr))
         return NULL;
 
-    align = FFMAX(align, 16); // 16 is "recommended", even if not required
+    align = FFMAXI(align, 16); // 16 is "recommended", even if not required
 
     hr = f->MFCreateAlignedMemoryBuffer(size, align - 1, &buffer);
     if (FAILED(hr))
diff --git a/libavcodec/mips/vc1dsp_mmi.c b/libavcodec/mips/vc1dsp_mmi.c
index 290b47d697e..76bd0bb1839 100644
--- a/libavcodec/mips/vc1dsp_mmi.c
+++ b/libavcodec/mips/vc1dsp_mmi.c
@@ -1503,7 +1503,7 @@ static av_always_inline int vc1_filter_line(uint8_t *src, int stride, int pq)
 
             clip = ((clip ^ clip_sign) - clip_sign) >> 1;
             if (clip) {
-                int a3     = FFMIN(a1, a2);
+                int a3     = FFMINI(a1, a2);
                 int d      = 5 * (a3 - a0);
                 int d_sign = (d >> 31);
 
@@ -1513,7 +1513,7 @@ static av_always_inline int vc1_filter_line(uint8_t *src, int stride, int pq)
                 if (d_sign ^ clip_sign)
                     d = 0;
                 else {
-                    d = FFMIN(d, clip);
+                    d = FFMINI(d, clip);
                     d = (d ^ d_sign) - d_sign; /* Restore sign */
                     src[-1 * stride] = av_clip_uint8(src[-1 * stride] - d);
                     src[ 0 * stride] = av_clip_uint8(src[ 0 * stride] + d);
diff --git a/libavcodec/mips/vp8dsp_mmi.c b/libavcodec/mips/vp8dsp_mmi.c
index 8b518e9c498..47cdae7231e 100644
--- a/libavcodec/mips/vp8dsp_mmi.c
+++ b/libavcodec/mips/vp8dsp_mmi.c
@@ -682,8 +682,8 @@ static av_always_inline void vp8_filter_common_is4tap(uint8_t *p,
 
     // We deviate from the spec here with c(a+3) >> 3
     // since that's what libvpx does.
-    f1 = FFMIN(a + 4, 127) >> 3;
-    f2 = FFMIN(a + 3, 127) >> 3;
+    f1 = FFMINI(a + 4, 127) >> 3;
+    f2 = FFMINI(a + 3, 127) >> 3;
 
     // Despite what the spec says, we do need to clamp here to
     // be bitexact with libvpx.
@@ -706,8 +706,8 @@ static av_always_inline void vp8_filter_common_isnot4tap(uint8_t *p,
 
     // We deviate from the spec here with c(a+3) >> 3
     // since that's what libvpx does.
-    f1 = FFMIN(a + 4, 127) >> 3;
-    f2 = FFMIN(a + 3, 127) >> 3;
+    f1 = FFMINI(a + 4, 127) >> 3;
+    f2 = FFMINI(a + 3, 127) >> 3;
 
     // Despite what the spec says, we do need to clamp here to
     // be bitexact with libvpx.
diff --git a/libavcodec/mjpeg_parser.c b/libavcodec/mjpeg_parser.c
index 62b923b625d..f7e48726c66 100644
--- a/libavcodec/mjpeg_parser.c
+++ b/libavcodec/mjpeg_parser.c
@@ -59,7 +59,7 @@ static int find_frame_end(MJPEGParserContext *m, const uint8_t *buf, int buf_siz
                 }
             }
             if(m->size>0){
-                int size= FFMIN(buf_size-i, m->size);
+                int size= FFMINI(buf_size-i, m->size);
                 i+=size;
                 m->size-=size;
                 state=0;
@@ -87,7 +87,7 @@ static int find_frame_end(MJPEGParserContext *m, const uint8_t *buf, int buf_siz
                 }
             }
             if(m->size>0){
-                int size= FFMIN(buf_size-i, m->size);
+                int size= FFMINI(buf_size-i, m->size);
                 i+=size;
                 m->size-=size;
                 state=0;
diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c
index 4db1d9a89d7..efb6d751727 100644
--- a/libavcodec/mjpegbdec.c
+++ b/libavcodec/mjpegbdec.c
@@ -114,7 +114,7 @@ read_header:
     av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%"PRIx32"\n", sod_offs);
     if (sos_offs) {
         init_get_bits(&s->gb, buf_ptr + sos_offs,
-                      8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
+                      8 * FFMINI(field_size, buf_end - buf_ptr - sos_offs));
         s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
         s->start_code = SOS;
         if (avctx->skip_frame == AVDISCARD_ALL) {
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a2dca7a88a5..81032d46bef 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -228,7 +228,7 @@ int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
         }
 
         // XXX FIXME fine-tune, and perhaps add dc too
-        s->qscale[index] = FFMAX(s->quant_matrixes[index][1],
+        s->qscale[index] = FFMAXI(s->quant_matrixes[index][1],
                                  s->quant_matrixes[index][8]) >> 1;
         av_log(s->avctx, AV_LOG_DEBUG, "qscale[%d]: %d\n",
                index, s->qscale[index]);
@@ -1006,7 +1006,7 @@ static int decode_block_refinement(MJpegDecodeContext *s, int16_t *block,
                                    int ss, int se, int Al, int *EOBRUN)
 {
     int code, i = ss, j, sign, val, run;
-    int last    = FFMIN(se, *last_nnz);
+    int last    = FFMINI(se, *last_nnz);
 
     OPEN_READER(re, &s->gb);
     if (*EOBRUN) {
@@ -2321,7 +2321,7 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
                 while ((src + t < buf_end) && x == 0xff)
                     x = src[t++];
                 if (x & 0x80) {
-                    t -= FFMIN(2, t);
+                    t -= FFMINI(2, t);
                     break;
                 }
             }
@@ -3063,7 +3063,7 @@ static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame)
 
     frame->width       = avctx->coded_width;
     frame->height      = avctx->coded_height;
-    frame->crop_top    = FFMIN(s->smv_next_frame * avctx->height, frame->height);
+    frame->crop_top    = FFMINI(s->smv_next_frame * avctx->height, frame->height);
     frame->crop_bottom = frame->height - (s->smv_next_frame + 1) * avctx->height;
 
     if (s->smv_frame->pts != AV_NOPTS_VALUE)
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 21b3b19b936..74ed2426111 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -202,7 +202,7 @@ static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p,
         av_assert0(remaining <= ICC_MAX_CHUNKS * ICC_CHUNK_SIZE);
         flush_put_bits(p);
         for (int i = 0; i < nb_chunks; i++) {
-            size = FFMIN(remaining, ICC_CHUNK_SIZE);
+            size = FFMINI(remaining, ICC_CHUNK_SIZE);
             av_assert1(size > 0);
             ptr = put_bits_ptr(p);
             ptr[0] = 0xff; /* chunk marker, not part of ICC_HDR_SIZE */
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index e85dac36a71..7967ef87da0 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -411,7 +411,7 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
     }
 
     /* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
-    m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
+    m->max_decoded_substream = FFMINI(m->num_substreams - 1, 2);
 
     m->avctx->sample_rate    = mh.group1_samplerate;
     m->avctx->frame_size     = mh.access_unit_size;
@@ -1355,7 +1355,7 @@ static int read_access_unit(AVCodecContext *avctx, AVFrame *frame,
 
             shorten_by = get_bits(&gb, 16);
             if      (m->avctx->codec_id == AV_CODEC_ID_TRUEHD && shorten_by  & 0x2000)
-                s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos);
+                s->blockpos -= FFMINI(shorten_by & 0x1FFF, s->blockpos);
             else if (m->avctx->codec_id == AV_CODEC_ID_MLP    && shorten_by != 0xD234)
                 return AVERROR_INVALIDDATA;
 
diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 475a70c2259..44600757b26 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -641,7 +641,7 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx)
 
         rh->noisegen_seed      = 0;
         rh->min_channel        = 0;
-        rh->max_channel        = FFMIN(avctx->ch_layout.nb_channels, 2) - 1;
+        rh->max_channel        = FFMINI(avctx->ch_layout.nb_channels, 2) - 1;
         rh->max_matrix_channel = rh->max_channel;
 
         if (avctx->ch_layout.nb_channels > 2) {
@@ -1200,7 +1200,7 @@ static void input_data_internal(MLPEncodeContext *ctx, MLPSubstream *s,
 
             sample = is24 ? samples_32[i] >> 8 : samples_16[i] * 256;
 
-            bits = FFMAX(number_sbits(sample), bits);
+            bits = FFMAXI(number_sbits(sample), bits);
 
             temp_lossless_check_data ^= (sample & 0x00ffffff) << ch;
             sample_buffer[i] = sample;
@@ -1260,7 +1260,7 @@ static void input_to_sample_buffer(MLPEncodeContext *ctx, MLPSubstream *s)
 /** Counts the number of trailing zeroes in a value */
 static int number_trailing_zeroes(int32_t sample, unsigned int max, unsigned int def)
 {
-    return sample ? FFMIN(max, ff_ctz(sample)) : def;
+    return sample ? FFMINI(max, ff_ctz(sample)) : def;
 }
 
 static void determine_output_shift(MLPEncodeContext *ctx, MLPSubstream *s)
@@ -1336,15 +1336,15 @@ static void code_filter_coeffs(MLPEncodeContext *ctx, FilterParams *fp, const in
     for (int order = 0; order < fp->order; order++) {
         int32_t coeff = fcoeff[order];
 
-        bits = FFMAX(number_sbits(coeff), bits);
+        bits = FFMAXI(number_sbits(coeff), bits);
 
         coeff_mask |= coeff;
     }
 
-    shift = FFMIN(7, coeff_mask ? ff_ctz(coeff_mask) : 0);
+    shift = FFMINI(7, coeff_mask ? ff_ctz(coeff_mask) : 0);
 
-    fp->coeff_bits  = FFMAX(1, bits - shift);
-    fp->coeff_shift = FFMIN(shift, 16 - fp->coeff_bits);
+    fp->coeff_bits  = FFMAXI(1, bits - shift);
+    fp->coeff_shift = FFMINI(shift, 16 - fp->coeff_bits);
 }
 
 /** Determines the best filter parameters for the given data and writes the
@@ -1437,11 +1437,11 @@ static int estimate_coeff(MLPEncodeContext *ctx, MLPSubstream *s,
             suml += lm;
             sumr += rm;
 
-            maxl = FFMAX(maxl, lm);
-            maxr = FFMAX(maxr, rm);
+            maxl = FFMAXI(maxl, lm);
+            maxr = FFMAXI(maxr, rm);
 
-            minl = FFMIN(minl, lm);
-            minr = FFMIN(minr, rm);
+            minl = FFMINI(minl, lm);
+            minr = FFMINI(minr, rm);
         }
     }
 
@@ -1460,7 +1460,7 @@ static int estimate_coeff(MLPEncodeContext *ctx, MLPSubstream *s,
     if ((FFABS(ml) + FFABS(mr)) >= (1 << 24))
         return 0;
 
-    cf0 = (FFMIN(FFABS(mr), FFABS(ml)) * (1LL << 14)) / FFMAX(FFABS(ml), FFABS(mr));
+    cf0 = (FFMINI(FFABS(mr), FFABS(ml)) * (1LL << 14)) / FFMAXI(FFABS(ml), FFABS(mr));
     cf0 = (cf0 >> shift) << shift;
     cf1 = -cf0;
 
@@ -1544,7 +1544,7 @@ static void no_codebook_bits_offset(MLPEncodeContext *ctx,
     min -= offset;
     max -= offset;
 
-    lsb_bits = FFMAX(number_sbits(min), number_sbits(max)) - 1;
+    lsb_bits = FFMAXI(number_sbits(min), number_sbits(max)) - 1;
 
     lsb_bits += !!lsb_bits;
 
@@ -1573,11 +1573,11 @@ static void no_codebook_bits(MLPEncodeContext *ctx,
     /* Set offset inside huffoffset's boundaries by adjusting extremes
      * so that more bits are used, thus shifting the offset. */
     if (min < HUFF_OFFSET_MIN)
-        max = FFMAX(max, 2 * HUFF_OFFSET_MIN - min + 1);
+        max = FFMAXI(max, 2 * HUFF_OFFSET_MIN - min + 1);
     if (max > HUFF_OFFSET_MAX)
-        min = FFMIN(min, 2 * HUFF_OFFSET_MAX - max - 1);
+        min = FFMINI(min, 2 * HUFF_OFFSET_MAX - max - 1);
 
-    lsb_bits = FFMAX(number_sbits(min), number_sbits(max));
+    lsb_bits = FFMAXI(number_sbits(min), number_sbits(max));
 
     if (lsb_bits > 0)
         unsign = 1 << (lsb_bits - 1);
@@ -1591,8 +1591,8 @@ static void no_codebook_bits(MLPEncodeContext *ctx,
     bo->bitcount = lsb_bits * dp->blocksize;
     bo->min      = max - unsign + 1;
     bo->max      = min + unsign;
-    bo->min      = FFMAX(bo->min, HUFF_OFFSET_MIN);
-    bo->max      = FFMIN(bo->max, HUFF_OFFSET_MAX);
+    bo->min      = FFMAXI(bo->min, HUFF_OFFSET_MIN);
+    bo->max      = FFMINI(bo->max, HUFF_OFFSET_MAX);
 }
 
 /** Determines the least amount of bits needed to encode the samples using a
@@ -1653,8 +1653,8 @@ static inline void codebook_bits_offset(MLPEncodeContext *ctx,
     bo->offset   = offset;
     bo->lsb_bits = lsb_bits;
     bo->bitcount = lsb_bits * dp->blocksize + bitcount;
-    bo->min      = FFMAX(offset - offset_min, HUFF_OFFSET_MIN);
-    bo->max      = FFMIN(offset + offset_max, HUFF_OFFSET_MAX);
+    bo->min      = FFMAXI(offset - offset_min, HUFF_OFFSET_MIN);
+    bo->max      = FFMINI(offset + offset_max, HUFF_OFFSET_MAX);
 }
 
 /** Determines the least amount of bits needed to encode the samples using a
@@ -1670,8 +1670,8 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
     int offset_min, offset_max;
     int is_greater = 0;
 
-    offset_min = FFMAX(min, HUFF_OFFSET_MIN);
-    offset_max = FFMIN(max, HUFF_OFFSET_MAX);
+    offset_min = FFMAXI(min, HUFF_OFFSET_MIN);
+    offset_max = FFMINI(max, HUFF_OFFSET_MAX);
 
     while (offset <= offset_max && offset >= offset_min) {
         BestOffset temp_bo;
@@ -2070,12 +2070,12 @@ static void set_major_params(MLPEncodeContext *ctx, MLPSubstream *s)
         for (int ch = 0; ch <= rh->max_matrix_channel; ch++) {
             int8_t shift = s->b[index].decoding_params.output_shift[ch];
 
-            max_shift = FFMAX(max_shift, shift);
+            max_shift = FFMAXI(max_shift, shift);
         }
         for (int ch = rh->min_channel; ch <= rh->max_channel; ch++) {
             uint8_t huff_lsbs = s->b[index].channel_params[ch].huff_lsbs;
 
-            max_huff_lsbs = FFMAX(max_huff_lsbs, huff_lsbs);
+            max_huff_lsbs = FFMAXI(max_huff_lsbs, huff_lsbs);
 
             memcpy(&s->b[index].major_channel_params[ch],
                    &s->b[index].channel_params[ch],
@@ -2247,7 +2247,7 @@ input_and_return:
 
     if (bytes_written > 0) {
         ff_af_queue_remove(&ctx->afq,
-                           FFMIN(avctx->frame_size, ctx->afq.remaining_samples),
+                           FFMINI(avctx->frame_size, ctx->afq.remaining_samples),
                            &avpkt->pts,
                            &avpkt->duration);
 
diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
index 133a835ad1f..812c68d28e3 100644
--- a/libavcodec/mobiclip.c
+++ b/libavcodec/mobiclip.c
@@ -843,10 +843,10 @@ static int predict_intra(AVCodecContext *avctx, AVFrame *frame, int ax, int ay,
         {
             int arr1[16];
             int arr2[16];
-            uint8_t *top = frame->data[plane] + FFMAX(ay - 1, 0) * frame->linesize[plane] + ax;
-            uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] + FFMAX(ax - 1, 0);
-            int bottommost = frame->data[plane][(ay + size - 1) * frame->linesize[plane] + FFMAX(ax - 1, 0)];
-            int rightmost = frame->data[plane][FFMAX(ay - 1, 0) * frame->linesize[plane] + ax + size - 1];
+            uint8_t *top = frame->data[plane] + FFMAXI(ay - 1, 0) * frame->linesize[plane] + ax;
+            uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] + FFMAXI(ax - 1, 0);
+            int bottommost = frame->data[plane][(ay + size - 1) * frame->linesize[plane] + FFMAXI(ax - 1, 0)];
+            int rightmost = frame->data[plane][FFMAXI(ay - 1, 0) * frame->linesize[plane] + ax + size - 1];
             int avg = (bottommost + rightmost + 1) / 2 + 2 * av_clip(get_se_golomb(gb), -(1<<16), 1<<16);
             int r6 = adjust(avg - bottommost, size);
             int r9 = adjust(avg - rightmost, size);
@@ -930,7 +930,7 @@ static int get_prediction(AVCodecContext *avctx, int x, int y, int size)
     GetBitContext *gb = &s->gb;
     int index = (y & 0xC) | (x / 4 % 4);
 
-    uint8_t val = FFMIN(s->pre[index], index % 4 == 0 ? 9 : s->pre[index + 3]);
+    uint8_t val = FFMINI(s->pre[index], index % 4 == 0 ? 9 : s->pre[index + 3]);
     if (val == 9)
         val = 3;
 
@@ -1083,7 +1083,7 @@ static int predict_motion(AVCodecContext *avctx,
     int fwidth = avctx->width;
 
     if (index <= 5) {
-        int sidx = -FFMAX(1, index) + s->current_pic;
+        int sidx = -FFMAXI(1, index) + s->current_pic;
         MotionXY mv = s->motion[0];
 
         if (sidx < 0)
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 93aa909fb59..1ab2c622912 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -309,11 +309,11 @@ static void zero_hpel(uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h){
 av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx,
                        const MECmpContext *mecc, int mpvenc)
 {
-    int cache_size = FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);
-    int dia_size   = FFMAX(FFABS(avctx->dia_size) & 255, FFABS(avctx->pre_dia_size) & 255);
+    int cache_size = FFMINI(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);
+    int dia_size   = FFMAXI(FFABS(avctx->dia_size) & 255, FFABS(avctx->pre_dia_size) & 255);
     int ret;
 
-    if (FFMIN(avctx->dia_size, avctx->pre_dia_size) < -FFMIN(ME_MAP_SIZE, MAX_SAB_SIZE)) {
+    if (FFMINI(avctx->dia_size, avctx->pre_dia_size) < -FFMINI(ME_MAP_SIZE, MAX_SAB_SIZE)) {
         av_log(avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n");
         return AVERROR(EINVAL);
     }
@@ -571,10 +571,10 @@ static inline void get_limits(MPVEncContext *const s, int x, int y, int bframe)
     if(!range || range > max_range)
         range = max_range;
     if(range){
-        c->xmin = FFMAX(c->xmin,-range);
-        c->xmax = FFMIN(c->xmax, range);
-        c->ymin = FFMAX(c->ymin,-range);
-        c->ymax = FFMIN(c->ymax, range);
+        c->xmin = FFMAXI(c->xmin,-range);
+        c->xmax = FFMINI(c->xmax, range);
+        c->ymin = FFMAXI(c->ymin,-range);
+        c->ymax = FFMINI(c->ymax, range);
     }
 }
 
@@ -973,7 +973,7 @@ void ff_estimate_p_frame_motion(MPVEncContext *const s,
     c->mc_mb_var_sum_temp += (vard+128)>>8;
 
     if (c->avctx->mb_decision > FF_MB_DECISION_SIMPLE) {
-        int p_score = FFMIN(vard, varc - 500 + (s->lambda2 >> FF_LAMBDA_SHIFT)*100);
+        int p_score = FFMINI(vard, varc - 500 + (s->lambda2 >> FF_LAMBDA_SHIFT)*100);
         int i_score = varc - 500 + (s->lambda2 >> FF_LAMBDA_SHIFT)*20;
         c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
 
@@ -1055,7 +1055,7 @@ void ff_estimate_p_frame_motion(MPVEncContext *const s,
             s->c.cur_pic.mb_type[mb_y*s->c.mb_stride + mb_x] = 0;
 
         {
-            int p_score = FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
+            int p_score = FFMINI(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
             int i_score = varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
             c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
         }
@@ -1351,8 +1351,8 @@ CHECK_BIDIR(-(a),-(b),-(c),-(d))
                 int bx= motion_bx+vect[i][2];
                 int by= motion_by+vect[i][3];
                 if(borderdist<=0){
-                    int a= (xmax - FFMAX(fx,bx))|(FFMIN(fx,bx) - xmin);
-                    int b= (ymax - FFMAX(fy,by))|(FFMIN(fy,by) - ymin);
+                    int a= (xmax - FFMAXI(fx,bx))|(FFMINI(fx,bx) - xmin);
+                    int b= (ymax - FFMAXI(fy,by))|(FFMINI(fy,by) - ymin);
                     if((a|b) < 0)
                         map[(hashidx+hash[i])&255] = 1;
                 }
@@ -1370,9 +1370,9 @@ CHECK_BIDIR(-(a),-(b),-(c),-(d))
                         end=0;
                         borderdist--;
                         if(borderdist<=0){
-                            int a= FFMIN(xmax - FFMAX(fx,bx), FFMIN(fx,bx) - xmin);
-                            int b= FFMIN(ymax - FFMAX(fy,by), FFMIN(fy,by) - ymin);
-                            borderdist= FFMIN(a,b);
+                            int a= FFMINI(xmax - FFMAXI(fx,bx), FFMINI(fx,bx) - xmin);
+                            int b= FFMINI(ymax - FFMAXI(fy,by), FFMINI(fy,by) - ymin);
+                            borderdist= FFMINI(a,b);
                         }
                     }
                 }
@@ -1422,19 +1422,19 @@ static inline int direct_search(MPVEncContext *const s, int mb_x, int mb_y)
 //        c->direct_basis_mv[1][i][0]= c->co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(shift+3);
 //        c->direct_basis_mv[1][i][1]= c->co_located_mv[i][1]*(time_pb - time_pp)/time_pp + ((i>>1)<<(shift+3);
 
-        max= FFMAX(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
-        min= FFMIN(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
+        max= FFMAXI(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
+        min= FFMINI(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
         max+= 16*mb_x + 1; // +-1 is for the simpler rounding
         min+= 16*mb_x - 1;
-        xmax= FFMIN(xmax, s->c.width - max);
-        xmin= FFMAX(xmin, - 16     - min);
+        xmax= FFMINI(xmax, s->c.width - max);
+        xmin= FFMAXI(xmin, - 16     - min);
 
-        max= FFMAX(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
-        min= FFMIN(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
+        max= FFMAXI(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
+        min= FFMINI(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
         max+= 16*mb_y + 1; // +-1 is for the simpler rounding
         min+= 16*mb_y - 1;
-        ymax= FFMIN(ymax, s->c.height - max);
-        ymin= FFMAX(ymin, - 16      - min);
+        ymax= FFMINI(ymax, s->c.height - max);
+        ymin= FFMAXI(ymin, - 16      - min);
 
         if(s->c.mv_type == MV_TYPE_16X16) break;
     }
@@ -1615,10 +1615,10 @@ int ff_get_best_fcode(MPVMainEncContext *const m, const int16_t (*mv_table)[2],
         int best_score=-10000000;
 
         if (s->c.msmpeg4_version != MSMP4_UNUSED)
-            range= FFMIN(range, 16);
+            range= FFMINI(range, 16);
         else if (s->c.codec_id == AV_CODEC_ID_MPEG2VIDEO &&
                  c->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL)
-            range= FFMIN(range, 256);
+            range= FFMINI(range, 256);
 
         for(i=0; i<8; i++) score[i]= s->c.mb_num*(8-i);
 
@@ -1629,7 +1629,7 @@ int ff_get_best_fcode(MPVMainEncContext *const m, const int16_t (*mv_table)[2],
                 if(s->mb_type[xy] & type){
                     int mx= mv_table[xy][0];
                     int my= mv_table[xy][1];
-                    int fcode = FFMAX(fcode_tab[mx], fcode_tab[my]);
+                    int fcode = FFMAXI(fcode_tab[mx], fcode_tab[my]);
                     int j;
 
                     if (mx >= range || mx < -range ||
diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c
index aa669e0ee7d..ef2e02805af 100644
--- a/libavcodec/motion_est_template.c
+++ b/libavcodec/motion_est_template.c
@@ -379,8 +379,8 @@ static int qpel_motion_search(MPVEncContext *const s,
 {\
     const int Lx= ax;\
     const int Ly= ay;\
-    const int Lx2= FFMAX(xmin, FFMIN(Lx, xmax));\
-    const int Ly2= FFMAX(ymin, FFMIN(Ly, ymax));\
+    const int Lx2= FFMAXI(xmin, FFMINI(Lx, xmax));\
+    const int Ly2= FFMAXI(ymin, FFMINI(Ly, ymax));\
     CHECK_MV(Lx2, Ly2)\
 }
 
@@ -589,17 +589,17 @@ static int umh_search(MPVEncContext *const s, int *best, int dmin,
 
     x= best[0];
     y= best[1];
-    for(x2=FFMAX(x-dia_size+1, xmin); x2<=FFMIN(x+dia_size-1,xmax); x2+=2){
+    for(x2=FFMAXI(x-dia_size+1, xmin); x2<=FFMINI(x+dia_size-1,xmax); x2+=2){
         CHECK_MV(x2, y);
     }
-    for(y2=FFMAX(y-dia_size/2+1, ymin); y2<=FFMIN(y+dia_size/2-1,ymax); y2+=2){
+    for(y2=FFMAXI(y-dia_size/2+1, ymin); y2<=FFMINI(y+dia_size/2-1,ymax); y2+=2){
         CHECK_MV(x, y2);
     }
 
     x= best[0];
     y= best[1];
-    for(y2=FFMAX(y-2, ymin); y2<=FFMIN(y+2,ymax); y2++){
-        for(x2=FFMAX(x-2, xmin); x2<=FFMIN(x+2,xmax); x2++){
+    for(y2=FFMAXI(y-2, ymin); y2<=FFMINI(y+2,ymax); y2++){
+        for(x2=FFMAXI(x-2, xmin); x2<=FFMINI(x+2,xmax); x2++){
             CHECK_MV(x2, y2);
         }
     }
@@ -630,8 +630,8 @@ static int full_search(MPVEncContext *const s, int *best, int dmin,
     cmpf        = c->me_cmp[size];
     chroma_cmpf = c->me_cmp[size + 1];
 
-    for(y=FFMAX(-dia_size, ymin); y<=FFMIN(dia_size,ymax); y++){
-        for(x=FFMAX(-dia_size, xmin); x<=FFMIN(dia_size,xmax); x++){
+    for(y=FFMAXI(-dia_size, ymin); y<=FFMINI(dia_size,ymax); y++){
+        for(x=FFMAXI(-dia_size, xmin); x<=FFMINI(dia_size,xmax); x++){
             CHECK_MV(x, y);
         }
     }
@@ -787,8 +787,8 @@ static int var_diamond_search(MPVEncContext *const s, int *best, int dmin,
         const int x= best[0];
         const int y= best[1];
 
-        start= FFMAX(0, y + dia_size - ymax);
-        end  = FFMIN(dia_size, xmax - x + 1);
+        start= FFMAXI(0, y + dia_size - ymax);
+        end  = FFMINI(dia_size, xmax - x + 1);
         for(dir= start; dir<end; dir++){
             int d;
 
@@ -796,8 +796,8 @@ static int var_diamond_search(MPVEncContext *const s, int *best, int dmin,
             CHECK_MV(x + dir           , y + dia_size - dir);
         }
 
-        start= FFMAX(0, x + dia_size - xmax);
-        end  = FFMIN(dia_size, y - ymin + 1);
+        start= FFMAXI(0, x + dia_size - xmax);
+        end  = FFMINI(dia_size, y - ymin + 1);
         for(dir= start; dir<end; dir++){
             int d;
 
@@ -805,8 +805,8 @@ static int var_diamond_search(MPVEncContext *const s, int *best, int dmin,
             CHECK_MV(x + dia_size - dir, y - dir           );
         }
 
-        start= FFMAX(0, -y + dia_size + ymin );
-        end  = FFMIN(dia_size, x - xmin + 1);
+        start= FFMAXI(0, -y + dia_size + ymin );
+        end  = FFMINI(dia_size, x - xmin + 1);
         for(dir= start; dir<end; dir++){
             int d;
 
@@ -814,8 +814,8 @@ static int var_diamond_search(MPVEncContext *const s, int *best, int dmin,
             CHECK_MV(x - dir           , y - dia_size + dir);
         }
 
-        start= FFMAX(0, -x + dia_size + xmin );
-        end  = FFMIN(dia_size, ymax - y + 1);
+        start= FFMAXI(0, -x + dia_size + xmin );
+        end  = FFMINI(dia_size, ymax - y + 1);
         for(dir= start; dir<end; dir++){
             int d;
 
@@ -944,10 +944,10 @@ static av_always_inline int epzs_motion_search_internal(MPVEncContext *const s,
 
     if(c->avctx->last_predictor_count){
         const int count= c->avctx->last_predictor_count;
-        const int xstart= FFMAX(0, s->c.mb_x - count);
-        const int ystart= FFMAX(0, s->c.mb_y - count);
-        const int xend= FFMIN(s->c.mb_width , s->c.mb_x + count + 1);
-        const int yend= FFMIN(s->c.mb_height, s->c.mb_y + count + 1);
+        const int xstart= FFMAXI(0, s->c.mb_x - count);
+        const int ystart= FFMAXI(0, s->c.mb_y - count);
+        const int xend= FFMINI(s->c.mb_width , s->c.mb_x + count + 1);
+        const int yend= FFMINI(s->c.mb_height, s->c.mb_y + count + 1);
         int mb_y;
 
         for(mb_y=ystart; mb_y<yend; mb_y++){
diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index e5c3daece6a..2e00f13e4ae 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -116,8 +116,8 @@ static void mp_read_changes_map(MotionPixelsContext *mp, GetBitContext *gb, int
         y = offset / mp->avctx->width;
         if (y >= mp->avctx->height)
             continue;
-        w = FFMIN(w, mp->avctx->width  - x);
-        h = FFMIN(h, mp->avctx->height - y);
+        w = FFMINI(w, mp->avctx->width  - x);
+        h = FFMINI(h, mp->avctx->height - y);
         pixels = (uint16_t *)&mp->frame->data[0][y * mp->frame->linesize[0] + x * 2];
         while (h--) {
             mp->changes_map[offset] = w;
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index fe04514e162..5c4d0dfbde3 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -501,7 +501,7 @@ static int mov_text_decode_frame(AVCodecContext *avctx, AVSubtitle *sub,
      * so we can't just assume the packet size is the string size.
      */
     text_length = AV_RB16(ptr);
-    end = ptr + FFMIN(2 + text_length, avpkt->size);
+    end = ptr + FFMINI(2 + text_length, avpkt->size);
     ptr += 2;
 
     mov_text_cleanup(m);
diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index fd8c7dc9f79..98f79af4dee 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -356,7 +356,7 @@ static int mov_text_style_start(MovTextContext *s)
         StyleBox *tmp;
 
         // last style != defaults, end the style entry and start a new one
-        if (s->count + 1 > FFMIN(SIZE_MAX / sizeof(*s->style_attributes), UINT16_MAX) ||
+        if (s->count + 1 > FFMINI(SIZE_MAX / sizeof(*s->style_attributes), UINT16_MAX) ||
             !(tmp = av_fast_realloc(s->style_attributes,
                                     &s->style_attributes_bytes_allocated,
                                     (s->count + 1) * sizeof(*s->style_attributes)))) {
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
index c72b2e3686a..963adb0accc 100644
--- a/libavcodec/mpc8.c
+++ b/libavcodec/mpc8.c
@@ -82,7 +82,7 @@ static int mpc8_get_mask(GetBitContext *gb, int size, int t)
     int mask = 0;
 
     if(t && t != size)
-         mask = mpc8_dec_enum(gb, FFMIN(t, size - t), size);
+         mask = mpc8_dec_enum(gb, FFMINI(t, size - t), size);
     if((t << 1) > size) mask = ~mask;
 
     return mask;
@@ -103,7 +103,7 @@ static av_cold void build_vlc(VLC *vlc, unsigned *buf_offset,
         for (unsigned tmp = num + codes_counts[i - 1]; num < tmp; num++)
             len[num] = i;
 
-    ff_vlc_init_from_lengths(vlc, FFMIN(len[0], 9), num, len, 1,
+    ff_vlc_init_from_lengths(vlc, FFMINI(len[0], 9), num, len, 1,
                              *syms, 1, 1, offset, VLC_INIT_STATIC_OVERLONG, NULL);
     *buf_offset += vlc->table_size;
     *syms       += num;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 9cf1bb9b28e..305aec2f9e2 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1522,10 +1522,10 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
                 }
 
                 if (left < 0 ||
-                    (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) ||
+                    (left && show_bits(&s->gb, FFMINI(left, 23)) && !is_d10) ||
                     ((avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_AGGRESSIVE)) && left > 8)) {
                     av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X at %d %d\n",
-                           left, left>0 ? show_bits(&s->gb, FFMIN(left, 23)) : 0, s->mb_x, s->mb_y);
+                           left, left>0 ? show_bits(&s->gb, FFMINI(left, 23)) : 0, s->mb_x, s->mb_y);
                     return AVERROR_INVALIDDATA;
                 } else
                     goto eos;
@@ -2244,7 +2244,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
             if (avctx->err_recognition & AV_EF_EXPLODE && s2->er.error_count)
                 return AVERROR_INVALIDDATA;
 
-            return FFMAX(0, buf_ptr - buf);
+            return FFMAXI(0, buf_ptr - buf);
         }
 
         input_size = buf_end - buf_ptr;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 313d73157f7..245c55ba83c 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -108,8 +108,8 @@ static void gmc1_motion(MpegEncContext *s, const Mpeg4DecContext *ctx,
 
     ptr = ref_picture[0] + src_y * linesize + src_x;
 
-    if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||
-        (unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {
+    if ((unsigned)src_x >= FFMAXI(s->h_edge_pos - 17, 0) ||
+        (unsigned)src_y >= FFMAXI(s->v_edge_pos - 17, 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
                                  linesize, linesize,
                                  17, 17,
@@ -152,8 +152,8 @@ static void gmc1_motion(MpegEncContext *s, const Mpeg4DecContext *ctx,
 
     offset = (src_y * uvlinesize) + src_x;
     ptr    = ref_picture[1] + offset;
-    if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||
-        (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {
+    if ((unsigned)src_x >= FFMAXI((s->h_edge_pos >> 1) - 9, 0) ||
+        (unsigned)src_y >= FFMAXI((s->v_edge_pos >> 1) - 9, 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
                                  uvlinesize, uvlinesize,
                                  9, 9,
@@ -577,7 +577,7 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
         ctx->sprite_shift[1]  = alpha + rho + 2;
         break;
     case 3:
-        min_ab = FFMIN(alpha, beta);
+        min_ab = FFMINI(alpha, beta);
         w3     = w2 >> min_ab;
         h3     = h2 >> min_ab;
         sprite_offset[0][0]    = ((int64_t)sprite_ref[0][0] * (1 << (alpha + beta + rho - min_ab))) +
@@ -686,7 +686,7 @@ overflow:
 
 static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) {
     MpegEncContext *s = &ctx->m;
-    int len = FFMIN(ctx->time_increment_bits + 3, 15);
+    int len = FFMINI(ctx->time_increment_bits + 3, 15);
 
     get_bits(gb, len);
     if (get_bits1(gb))
@@ -2061,7 +2061,7 @@ end:
             const int delta = s->mb_x + 1 == s->mb_width ? 2 : 1;
             ff_thread_progress_await(&s->next_pic.ptr->progress,
                                         (s->mb_x + delta >= s->mb_width)
-                                        ? FFMIN(s->mb_y + 1, s->mb_height - 1)
+                                        ? FFMINI(s->mb_y + 1, s->mb_height - 1)
                                         : s->mb_y);
             if (s->next_pic.mbskip_table[xy + delta])
                 return SLICE_OK;
@@ -2286,15 +2286,15 @@ static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[25
                 top = macroblock[idx-w];
 
             p = left + top - topleft;
-            min_left_top = FFMIN(left, top);
+            min_left_top = FFMINI(left, top);
             if (p < min_left_top)
                 p = min_left_top;
 
-            max_left_top = FFMAX(left, top);
+            max_left_top = FFMAXI(left, top);
             if (p > max_left_top)
                 p = max_left_top;
 
-            p2 = (FFMIN(min_left_top, topleft) + FFMAX(max_left_top, topleft)) >> 1;
+            p2 = (FFMINI(min_left_top, topleft) + FFMAXI(max_left_top, topleft)) >> 1;
             if (p2 == p)
                 p2 = block_mean;
 
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 0fa8159f181..553b18959d4 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -598,8 +598,8 @@ static void mpeg4_encode_mb(MPVEncContext *const s, int16_t block[][64],
 
                         if (x + 16 > s->c.width || y + 16 > s->c.height) {
                             int x1, y1;
-                            int xe = FFMIN(16, s->c.width - x);
-                            int ye = FFMIN(16, s->c.height - y);
+                            int xe = FFMINI(16, s->c.width - x);
+                            int ye = FFMINI(16, s->c.height - y);
                             diff = 0;
                             for (y1 = 0; y1 < ye; y1++) {
                                 for (x1 = 0; x1 < xe; x1++) {
@@ -829,7 +829,7 @@ static void mpeg4_encode_gop_header(MPVMainEncContext *const m)
 
     time = s->c.cur_pic.ptr->f->pts;
     if (m->reordered_input_picture[1])
-        time = FFMIN(time, m->reordered_input_picture[1]->f->pts);
+        time = FFMINI(time, m->reordered_input_picture[1]->f->pts);
     time = time * s->c.avctx->time_base.num;
     s->c.last_time_base = FFUDIV(time, s->c.avctx->time_base.den);
 
diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c
index d54366f10af..0de6f75c018 100644
--- a/libavcodec/mpegaudio_parser.c
+++ b/libavcodec/mpegaudio_parser.c
@@ -54,7 +54,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
 
     for(i=0; i<buf_size; ){
         if(s->frame_size){
-            int inc= FFMIN(buf_size - i, s->frame_size);
+            int inc= FFMINI(buf_size - i, s->frame_size);
             i += inc;
             s->frame_size -= inc;
             state = 0;
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index c73b1e0054d..6f9b7ae19a5 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -128,7 +128,7 @@ static void region_offset2size(GranuleDef *g)
     int i, k, j = 0;
     g->region_size[2] = 576 / 2;
     for (i = 0; i < 3; i++) {
-        k = FFMIN(g->region_size[i], g->big_values);
+        k = FFMINI(g->region_size[i], g->big_values);
         g->region_size[i] = k - j;
         j = k;
     }
@@ -158,7 +158,7 @@ static void init_long_region(MPADecodeContext *s, GranuleDef *g,
     int l;
     g->region_size[0] = ff_band_index_long[s->sample_rate_index][ra1 + 1];
     /* should not overflow */
-    l = FFMIN(ra1 + ra2 + 2, 22);
+    l = FFMINI(ra1 + ra2 + 2, 22);
     g->region_size[1] = ff_band_index_long[s->sample_rate_index][      l];
 }
 
@@ -756,7 +756,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
     int i;
     int last_pos, bits_left;
     VLC *vlc;
-    int end_pos = FFMIN(end_pos2, s->gb.size_in_bits - s->extrasize * 8);
+    int end_pos = FFMINI(end_pos2, s->gb.size_in_bits - s->extrasize * 8);
 
     /* low frequencies (called big values) */
     s_index = 0;
@@ -1299,7 +1299,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
         int skip;
         const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb) >> 3);
         s->extrasize = av_clip((get_bits_left(&s->gb) >> 3) - s->extrasize, 0,
-                               FFMAX(0, LAST_BUF_SIZE - s->last_buf_size));
+                               FFMAXI(0, LAST_BUF_SIZE - s->last_buf_size));
         av_assert1((get_bits_count(&s->gb) & 7) == 0);
         /* now we get bits from the main_data_begin offset */
         ff_dlog(s->avctx, "seekback:%d, lastbuf:%d\n",
@@ -1508,7 +1508,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples,
         if (i < 0 || i > BACKSTEP_SIZE || nb_frames < 0) {
             if (i < 0)
                 av_log(s->avctx, AV_LOG_ERROR, "invalid new backstep %d\n", i);
-            i = FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE);
+            i = FFMINI(BACKSTEP_SIZE, buf_size - HEADER_SIZE);
         }
         av_assert1(i <= buf_size - HEADER_SIZE && i >= 0);
         memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 73b6650b70d..bf65695438c 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -69,7 +69,7 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
         y <<= 1;
     }
 
-    h = FFMIN(h, avctx->height - y);
+    h = FFMINI(h, avctx->height - y);
 
     if (field_pic && first_field &&
         !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index f3e4d4c386a..75e78c86a8c 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -418,7 +418,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
     if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) {
         int max_slices;
         if (s->mb_height)
-            max_slices = FFMIN(MAX_THREADS, s->mb_height);
+            max_slices = FFMINI(MAX_THREADS, s->mb_height);
         else
             max_slices = MAX_THREADS;
         av_log(s->avctx, AV_LOG_WARNING, "too many threads/slices (%d),"
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index f8551b93c88..a90be87b86a 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -453,8 +453,8 @@ static inline int hpel_motion_lowres(MpegEncContext *s,
 
     src   += src_y * stride + src_x;
 
-    if ((unsigned)src_x > FFMAX( h_edge_pos - (!!sx) - w,                 0) ||
-        (unsigned)src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
+    if ((unsigned)src_x > FFMAXI( h_edge_pos - (!!sx) - w,                 0) ||
+        (unsigned)src_y > FFMAXI((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src,
                                  s->linesize, s->linesize,
                                  w + 1, (h + 1) << field_based,
@@ -559,8 +559,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
     ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
     ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
 
-    if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s,       0) || uvsrc_y<0 ||
-        (unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - FFMAX(h, hc<<s->chroma_y_shift), 0)) {
+    if ((unsigned) src_x > FFMAXI( h_edge_pos - (!!sx) - 2 * block_s,       0) || uvsrc_y<0 ||
+        (unsigned) src_y > FFMAXI((v_edge_pos >> field_based) - (!!sy) - FFMAXI(h, hc<<s->chroma_y_shift), 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
                                  linesize >> field_based, linesize >> field_based,
                                  17, 17 + field_based,
@@ -650,8 +650,8 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
 
     offset = src_y * s->uvlinesize + src_x;
     ptr = ref_picture[1] + offset;
-    if ((unsigned) src_x > FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
-        (unsigned) src_y > FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
+    if ((unsigned) src_x > FFMAXI(h_edge_pos - (!!sx) - block_s, 0) ||
+        (unsigned) src_y > FFMAXI(v_edge_pos - (!!sy) - block_s, 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
                                  s->uvlinesize, s->uvlinesize,
                                  9, 9,
@@ -841,11 +841,11 @@ static int lowest_referenced_row(MpegEncContext *s, int dir)
 
     for (int i = 0; i < mvs; i++) {
         int my = s->mv[dir][i][1];
-        my_max = FFMAX(my_max, my);
-        my_min = FFMIN(my_min, my);
+        my_max = FFMAXI(my_max, my);
+        my_min = FFMINI(my_min, my);
     }
 
-    off = ((FFMAX(-my_min, my_max) << qpel_shift) + 63) >> 6;
+    off = ((FFMAXI(-my_min, my_max) << qpel_shift) + 63) >> 6;
 
     return av_clip(s->mb_y + off, 0, s->mb_height - 1);
 unhandled:
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 46901fc5062..605ea3129e5 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -646,7 +646,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
         switch(avctx->codec_id) {
         case AV_CODEC_ID_MPEG1VIDEO:
         case AV_CODEC_ID_MPEG2VIDEO:
-            avctx->rc_buffer_size = FFMAX(avctx->rc_max_rate, 15000000) * 112LL / 15000000 * 16384;
+            avctx->rc_buffer_size = FFMAXI(avctx->rc_max_rate, 15000000) * 112LL / 15000000 * 16384;
             break;
         case AV_CODEC_ID_MPEG4:
         case AV_CODEC_ID_MSMPEG4V1:
@@ -1460,7 +1460,7 @@ static int skip_check(MPVMainEncContext *const m,
                 int v = m->frame_skip_cmp_fn(s, dptr, rptr, stride, 8);
 
                 switch (FFABS(m->frame_skip_exp)) {
-                case 0: score    =  FFMAX(score, v);          break;
+                case 0: score    =  FFMAXI(score, v);          break;
                 case 1: score   += FFABS(v);                  break;
                 case 2: score64 += v * (int64_t)v;                       break;
                 case 3: score64 += FFABS(v * (int64_t)v * v);            break;
@@ -1726,7 +1726,7 @@ static int set_bframe_chain_length(MPVMainEncContext *const m)
                     !m->input_picture[i] ||
                     m->input_picture[i]->b_frame_score - 1 >
                         s->c.mb_num / m->b_sensitivity) {
-                    b_frames = FFMAX(0, i - 1);
+                    b_frames = FFMAXI(0, i - 1);
                     break;
                 }
             }
@@ -1990,18 +1990,18 @@ vbv_retry:
 
         if (avctx->rc_buffer_size) {
             RateControlContext *rcc = &m->rc_context;
-            int max_size = FFMAX(rcc->buffer_index * avctx->rc_max_available_vbv_use, rcc->buffer_index - 500);
+            int max_size = FFMAXD(rcc->buffer_index * avctx->rc_max_available_vbv_use, rcc->buffer_index - 500);
             int hq = (avctx->mb_decision == FF_MB_DECISION_RD || avctx->trellis);
             int min_step = hq ? 1 : (1<<(FF_LAMBDA_SHIFT + 7))/139;
 
             if (put_bits_count(&s->pb) > max_size &&
                 s->lambda < m->lmax) {
-                m->next_lambda = FFMAX(s->lambda + min_step, s->lambda *
+                m->next_lambda = FFMAXI(s->lambda + min_step, s->lambda *
                                        (s->c.qscale + 1) / s->c.qscale);
                 if (s->adaptive_quant) {
                     for (int i = 0; i < s->c.mb_height * s->c.mb_stride; i++)
                         s->lambda_table[i] =
-                            FFMAX(s->lambda_table[i] + min_step,
+                            FFMAXI(s->lambda_table[i] + min_step,
                                   s->lambda_table[i] * (s->c.qscale + 1) /
                                   s->c.qscale);
                 }
@@ -2097,7 +2097,7 @@ vbv_retry:
             min_delay = (minbits * 90000LL + avctx->rc_max_rate - 1) /
                         avctx->rc_max_rate;
 
-            vbv_delay = FFMAX(vbv_delay, min_delay);
+            vbv_delay = FFMAXI(vbv_delay, min_delay);
 
             av_assert0(vbv_delay < 0xFFFF);
 
@@ -2257,8 +2257,8 @@ static void get_visual_weight(int16_t *weight, const uint8_t *ptr, int stride)
             int sqr = 0;
             int count = 0;
 
-            for (y2 = FFMAX(y - 1, 0); y2 < FFMIN(8, y + 2); y2++) {
-                for (x2= FFMAX(x - 1, 0); x2 < FFMIN(8, x + 2); x2++) {
+            for (y2 = FFMAXI(y - 1, 0); y2 < FFMINI(8, y + 2); y2++) {
+                for (x2= FFMAXI(x - 1, 0); x2 < FFMINI(8, x + 2); x2++) {
                     int v = ptr[x2 + y2 * stride];
                     sum += v;
                     sqr += v * v;
@@ -3817,11 +3817,11 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt)
 
             a = ff_get_best_fcode(m, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
             b = ff_get_best_fcode(m, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
-            s->f_code = FFMAX(a, b);
+            s->f_code = FFMAXI(a, b);
 
             a = ff_get_best_fcode(m, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
             b = ff_get_best_fcode(m, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
-            s->b_code = FFMAX(a, b);
+            s->b_code = FFMAXI(a, b);
 
             ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
             ff_fix_long_mvs(s, NULL, 0, s->b_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1);
@@ -3926,7 +3926,7 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt)
                         NULL, context_count, sizeof(void*));
     for(i=1; i<context_count; i++){
         if (s->pb.buf_end == s->c.enc_contexts[i]->pb.buf)
-            set_put_bits_buffer_size(&s->pb, FFMIN(s->c.enc_contexts[i]->pb.buf_end - s->pb.buf, INT_MAX/8-BUF_BITS));
+            set_put_bits_buffer_size(&s->pb, FFMINI(s->c.enc_contexts[i]->pb.buf_end - s->pb.buf, INT_MAX/8-BUF_BITS));
         merge_context_after_encode(s, s->c.enc_contexts[i]);
     }
     emms_c();
@@ -4070,7 +4070,7 @@ static int dct_quantize_trellis_c(MPVEncContext *const s,
                 coeff[1][i]= -level+1;
 //                coeff[2][k]= -level+2;
             }
-            coeff_count[i]= FFMIN(level, 2);
+            coeff_count[i]= FFMINI(level, 2);
             av_assert2(coeff_count[i]);
             max |=level;
         }else{
diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index a48b898dac1..fc14a6165ac 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -57,8 +57,8 @@ static inline int hpel_motion(MpegEncContext *s,
         dxy |= (motion_y & 1) << 1;
     src += src_y * s->linesize + src_x;
 
-    if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) ||
-        (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) {
+    if ((unsigned)src_x >= FFMAXI(s->h_edge_pos - (motion_x & 1) - 7, 0) ||
+        (unsigned)src_y >= FFMAXI(s->v_edge_pos - (motion_y & 1) - 7, 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src,
                                  s->linesize, s->linesize,
                                  9, 9,
@@ -151,8 +151,8 @@ void mpeg_motion_internal(MpegEncContext *s,
     ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
     ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
 
-    if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 15   , 0) ||
-        (unsigned)src_y >= FFMAX(   v_edge_pos - (motion_y & 1) - h + 1, 0)) {
+    if ((unsigned)src_x >= FFMAXI(s->h_edge_pos - (motion_x & 1) - 15   , 0) ||
+        (unsigned)src_y >= FFMAXI(   v_edge_pos - (motion_y & 1) - h + 1, 0)) {
         if (is_mpeg12 || (CONFIG_SMALL &&
                           (s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
                            s->codec_id == AV_CODEC_ID_MPEG1VIDEO))) {
@@ -385,8 +385,8 @@ static inline void qpel_motion(MpegEncContext *s,
     ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
     ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
 
-    if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 3) - 15   , 0) ||
-        (unsigned)src_y >= FFMAX(   v_edge_pos - (motion_y & 3) - h + 1, 0)) {
+    if ((unsigned)src_x >= FFMAXI(s->h_edge_pos - (motion_x & 3) - 15   , 0) ||
+        (unsigned)src_y >= FFMAXI(   v_edge_pos - (motion_y & 3) - h + 1, 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
                                  s->linesize, s->linesize,
                                  17, 17 + field_based,
@@ -471,8 +471,8 @@ static void chroma_4mv_motion(MpegEncContext *s,
 
     offset = src_y * s->uvlinesize + src_x;
     ptr    = ref_picture[1] + offset;
-    if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - (dxy  & 1) - 7, 0) ||
-        (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 7, 0)) {
+    if ((unsigned)src_x >= FFMAXI((s->h_edge_pos >> 1) - (dxy  & 1) - 7, 0) ||
+        (unsigned)src_y >= FFMAXI((s->v_edge_pos >> 1) - (dxy >> 1) - 7, 0)) {
         s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
                                  s->uvlinesize, s->uvlinesize,
                                  9, 9, src_x, src_y,
@@ -630,8 +630,8 @@ static inline void apply_8x8(MpegEncContext *s,
                 dxy &= ~12;
 
             ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
-            if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 3) - 7, 0) ||
-                (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 3) - 7, 0)) {
+            if ((unsigned)src_x >= FFMAXI(s->h_edge_pos - (motion_x & 3) - 7, 0) ||
+                (unsigned)src_y >= FFMAXI(s->v_edge_pos - (motion_y & 3) - 7, 0)) {
                 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
                                          s->linesize, s->linesize,
                                          9, 9,
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index 3449328b3c7..739073f868d 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -293,9 +293,9 @@ void ff_msmpeg4_encode_ext_header(MPVEncContext *const s)
         fps = s->c.avctx->time_base.den / s->c.avctx->time_base.num;
     }
 
-    put_bits(&s->pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29
+    put_bits(&s->pb, 5, FFMINI(fps, 31)); //yes 29.97 -> 29
 
-    put_bits(&s->pb, 11, FFMIN(m->bit_rate / 1024, 2047));
+    put_bits(&s->pb, 11, FFMINI(m->bit_rate / 1024, 2047));
 
     if (s->c.msmpeg4_version >= MSMP4_V3)
         put_bits(&s->pb, 1, s->c.flipflop_rounding);
diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
index e1daeeb1449..6df09a50603 100644
--- a/libavcodec/msp2dec.c
+++ b/libavcodec/msp2dec.c
@@ -67,8 +67,8 @@ static int msp2_decode_frame(AVCodecContext *avctx, AVFrame *p,
         while (bytestream2_get_bytes_left(&gb) && x < width) {
             int size = bytestream2_get_byte(&gb);
             if (size) {
-                size = FFMIN(size, bytestream2_get_bytes_left(&gb));
-                memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, FFMIN(size, width - x));
+                size = FFMINI(size, bytestream2_get_bytes_left(&gb));
+                memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, FFMINI(size, width - x));
                 bytestream2_skip(&gb, size);
             } else {
                 int value;
@@ -76,7 +76,7 @@ static int msp2_decode_frame(AVCodecContext *avctx, AVFrame *p,
                 if (!size)
                     avpriv_request_sample(avctx, "escape value");
                 value = bytestream2_get_byte(&gb);
-                memset(p->data[0] + y * p->linesize[0] + x, value, FFMIN(size, width - x));
+                memset(p->data[0] + y * p->linesize[0] + x, value, FFMINI(size, width - x));
             }
             x += size;
         }
diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
index 288f0d768a7..d0977636e5c 100644
--- a/libavcodec/msrle.c
+++ b/libavcodec/msrle.c
@@ -73,7 +73,7 @@ static av_cold int msrle_decode_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
 
     if (avctx->extradata_size >= 4)
-        for (i = 0; i < FFMIN(avctx->extradata_size, AVPALETTE_SIZE)/4; i++)
+        for (i = 0; i < FFMINI(avctx->extradata_size, AVPALETTE_SIZE)/4; i++)
             s->pal[i] = 0xFFU<<24 | AV_RL32(avctx->extradata+4*i);
 
     return 0;
diff --git a/libavcodec/mss12.c b/libavcodec/mss12.c
index 8dd3b4fc8ab..157d28a8091 100644
--- a/libavcodec/mss12.c
+++ b/libavcodec/mss12.c
@@ -53,7 +53,7 @@ static int model_calc_threshold(Model *m)
     thr = 2 * m->weights[m->num_syms] - 1;
     thr = ((thr >> 1) + 4 * m->cum_prob[0]) / thr;
 
-    return FFMIN(thr, 0x3FFF);
+    return FFMINI(thr, 0x3FFF);
 }
 
 static void model_reset(Model *m)
@@ -180,7 +180,7 @@ static av_always_inline int decode_pixel(ArithCoder *acoder, PixContext *pctx,
                     idx++;
                 }
             }
-            val = FFMIN(i, pctx->cache_size - 1);
+            val = FFMINI(i, pctx->cache_size - 1);
         }
         pix = pctx->cache[val];
     } else {
@@ -598,8 +598,8 @@ av_cold int ff_mss12_decode_init(MSS12Context *c, int version,
         return AVERROR_INVALIDDATA;
     }
 
-    avctx->coded_width  = FFMAX(AV_RB32(avctx->extradata + 20), avctx->width);
-    avctx->coded_height = FFMAX(AV_RB32(avctx->extradata + 24), avctx->height);
+    avctx->coded_width  = FFMAXI(AV_RB32(avctx->extradata + 20), avctx->width);
+    avctx->coded_height = FFMAXI(AV_RB32(avctx->extradata + 24), avctx->height);
     if (avctx->coded_width > 4096 || avctx->coded_height > 4096) {
         av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too large",
                avctx->coded_width, avctx->coded_height);
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 74a25b3e55a..b509c833b61 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -219,7 +219,7 @@ static int decode_555(AVCodecContext *avctx, GetByteContext *gB, uint16_t *dst,
                         repeat = (repeat << 8) + bytestream2_get_byte(gB) + 1;
                     }
                     if (last_symbol == -2) {
-                        int skip = FFMIN((unsigned)repeat, dst + w - p);
+                        int skip = FFMINI((unsigned)repeat, dst + w - p);
                         repeat -= skip;
                         p      += skip;
                     }
@@ -349,7 +349,7 @@ static int decode_rle(GetBitContext *gb, uint8_t *pal_dst, ptrdiff_t pal_stride,
                     repeat += (1 << b) - 1;
 
                     if (last_symbol == -2) {
-                        int skip = FFMIN(repeat, pal_dst + w - pp);
+                        int skip = FFMINI(repeat, pal_dst + w - pp);
                         repeat -= skip;
                         pp     += skip;
                         rp     += skip * 3;
@@ -476,7 +476,7 @@ static void calc_draw_region(struct Rectangle2 * draw, const struct Rectangle2 *
 #define COMPARE(top, bottom, left, right)  \
     if (rect->top <= draw->top && rect->bottom >= draw->bottom) { \
         if (rect->left <= draw->left && rect->right >= draw->left) \
-            draw->left = FFMIN(rect->right, draw->right); \
+            draw->left = FFMINI(rect->right, draw->right); \
         \
         if (rect->right >= draw->right) { \
             if (rect->left >= draw->left) { \
diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
index 257943f648b..82d2ebd875a 100644
--- a/libavcodec/mss3.c
+++ b/libavcodec/mss3.c
@@ -283,7 +283,7 @@ static void rac_init(RangeCoder *c, const uint8_t *src, int size)
     c->src       = src;
     c->src_end   = src + size;
     c->low       = 0;
-    for (i = 0; i < FFMIN(size, 4); i++)
+    for (i = 0; i < FFMINI(size, 4); i++)
         c->low = (c->low << 8) | *c->src++;
     c->range     = 0xFFFFFFFF;
     c->got_error = 0;
diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c
index c931aa4e4a0..040531dacc8 100644
--- a/libavcodec/mss4.c
+++ b/libavcodec/mss4.c
@@ -116,7 +116,7 @@ static av_cold void mss4_init_vlc(VLC *vlc, unsigned *offset,
 
     vlc->table           = &vlc_buf[*offset];
     vlc->table_allocated = FF_ARRAY_ELEMS(vlc_buf) - *offset;
-    ff_vlc_init_from_lengths(vlc, FFMIN(bits[idx - 1], 9), idx,
+    ff_vlc_init_from_lengths(vlc, FFMINI(bits[idx - 1], 9), idx,
                              bits, 1, syms, 1, 1,
                              0, VLC_INIT_STATIC_OVERLONG, NULL);
     *offset += vlc->table_size;
diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index 124a37e23fe..ea4ea093b0d 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -97,7 +97,7 @@ static const uint8_t zigzag[] = {
 
 static void get_qtable(int16_t *table, int quant, const uint8_t *quant_tab)
 {
-    int factor = quant < 50 ? 5000 / FFMAX(quant, 1) : 200 - FFMIN(quant, 100) * 2;
+    int factor = quant < 50 ? 5000 / FFMAXI(quant, 1) : 200 - FFMINI(quant, 100) * 2;
 
     for (int i = 0; i < 64; i++) {
         table[i] = av_clip((quant_tab[i] * factor + 0x32) / 100, 1, 0x7fff);
diff --git a/libavcodec/mvcdec.c b/libavcodec/mvcdec.c
index 44cab1889b2..b8dd03e3cb7 100644
--- a/libavcodec/mvcdec.c
+++ b/libavcodec/mvcdec.c
@@ -157,7 +157,7 @@ static int decode_mvc2(AVCodecContext *avctx, GetByteContext *gb,
     nb_colors = bytestream2_get_byteu(gb);
     if (bytestream2_get_bytes_left(gb) < nb_colors * 3)
         return AVERROR_INVALIDDATA;
-    for (i = 0; i < FFMIN(nb_colors, 128); i++)
+    for (i = 0; i < FFMINI(nb_colors, 128); i++)
         color[i] = 0xFF000000 | bytestream2_get_be24u(gb);
     if (nb_colors > 128)
         bytestream2_skip(gb, (nb_colors - 128) * 3);
diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c
index 4aad56640ee..22c88bb9a9c 100644
--- a/libavcodec/mvha.c
+++ b/libavcodec/mvha.c
@@ -59,8 +59,8 @@ static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat,
 
     s = nodes[node].sym;
     if (s != -1) {
-        bits[*pos] = (~pfx) & ((1ULL << FFMAX(pl, 1)) - 1);
-        lens[*pos] = FFMAX(pl, 1);
+        bits[*pos] = (~pfx) & ((1ULL << FFMAXI(pl, 1)) - 1);
+        lens[*pos] = FFMAXI(pl, 1);
         xlat[*pos] = s + (pl == 0);
         (*pos)++;
     } else {
diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c
index 8661bba566a..a629cf6a4c4 100644
--- a/libavcodec/mxpegdec.c
+++ b/libavcodec/mxpegdec.c
@@ -81,7 +81,7 @@ static int mxpeg_decode_app(MXpegDecodeContext *s,
     if (buf_size < 2)
         return 0;
     len = AV_RB16(buf_ptr);
-    skip_bits(&s->jpg.gb, 8*FFMIN(len,buf_size));
+    skip_bits(&s->jpg.gb, 8*FFMINI(len,buf_size));
 
     return 0;
 }
@@ -149,7 +149,7 @@ static int mxpeg_decode_com(MXpegDecodeContext *s,
     if (len > 14 && len <= buf_size && !strncmp(buf_ptr + 2, "MXM", 3)) {
         ret = mxpeg_decode_mxm(s, buf_ptr + 2, len - 2);
     }
-    skip_bits(&s->jpg.gb, 8*FFMIN(len,buf_size));
+    skip_bits(&s->jpg.gb, 8*FFMINI(len,buf_size));
 
     return ret;
 }
diff --git a/libavcodec/nellymoser.c b/libavcodec/nellymoser.c
index 66c5f83a56d..cfd57f04dca 100644
--- a/libavcodec/nellymoser.c
+++ b/libavcodec/nellymoser.c
@@ -127,7 +127,7 @@ void ff_nelly_get_sample_bits(const float *buf, int *bits)
 
     max = 0;
     for (i = 0; i < NELLY_FILL_LEN; i++) {
-        max = FFMAX(max, buf[i]);
+        max = FFMAXF(max, buf[i]);
     }
     shift = -16;
     shift += headroom(&max);
diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c
index 6f002eb891d..c1135013fed 100644
--- a/libavcodec/nellymoserenc.c
+++ b/libavcodec/nellymoserenc.c
@@ -258,9 +258,9 @@ static void get_exponent_dynamic(NellyMoserEncodeContext *s, float *cand, int *i
         int idx_min, idx_max, idx;
         power_candidate = cand[band];
         for (q = 1000; !c && q < OPT_SIZE; q <<= 2) {
-            idx_min = FFMAX(0, cand[band] - q);
-            idx_max = FFMIN(OPT_SIZE, cand[band - 1] + q);
-            for (i = FFMAX(0, cand[band - 1] - q); i < FFMIN(OPT_SIZE, cand[band - 1] + q); i++) {
+            idx_min = FFMAXF(0, cand[band] - q);
+            idx_max = FFMINF(OPT_SIZE, cand[band - 1] + q);
+            for (i = FFMAXF(0, cand[band - 1] - q); i < FFMINF(OPT_SIZE, cand[band - 1] + q); i++) {
                 if ( isinf(opt[band - 1][i]) )
                     continue;
                 for (j = 0; j < 32; j++) {
@@ -325,7 +325,7 @@ static void encode_block(NellyMoserEncodeContext *s, unsigned char *output, int
                        + s->mdct_out[i + NELLY_BUF_LEN] * s->mdct_out[i + NELLY_BUF_LEN];
         }
         cand[band] =
-            log2(FFMAX(1.0, coeff_sum / (ff_nelly_band_sizes_table[band] << 7))) * 1024.0;
+            log2(FFMAXD(1.0, coeff_sum / (ff_nelly_band_sizes_table[band] << 7))) * 1024.0;
     }
 
     if (s->avctx->trellis) {
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index c2301be77b8..9a1356f2644 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -85,7 +85,7 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c, const uint8_t *buf,
 static void get_quant_quality(NuvContext *c, int quality)
 {
     int i;
-    quality = FFMAX(quality, 1);
+    quality = FFMAXI(quality, 1);
     for (i = 0; i < 64; i++) {
         c->lq[i] = (ff_mjpeg_std_luminance_quant_tbl[i] << 7) / quality;
         c->cq[i] = (ff_mjpeg_std_chrominance_quant_tbl[i] << 7) / quality;
@@ -105,7 +105,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
     if (width != c->width || height != c->height) {
         // also reserve space for a possible additional header
         int64_t buf_size = height * (int64_t)width * 3 / 2
-                     + FFMAX(AV_LZO_OUTPUT_PADDING, AV_INPUT_BUFFER_PADDING_SIZE)
+                     + FFMAXI(AV_LZO_OUTPUT_PADDING, AV_INPUT_BUFFER_PADDING_SIZE)
                      + RTJPEG_HEADER_SIZE;
         if (buf_size > INT_MAX/8)
             return -1;
@@ -212,14 +212,14 @@ retry:
     buf       = &buf[12];
     buf_size -= 12;
     if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) {
-        int outlen = c->decomp_size - FFMAX(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING);
+        int outlen = c->decomp_size - FFMAXI(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING);
         int inlen  = buf_size;
         if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) {
             av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
             return AVERROR_INVALIDDATA;
         }
         buf      = c->decomp_buf;
-        buf_size = c->decomp_size - FFMAX(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING) - outlen;
+        buf_size = c->decomp_size - FFMAXI(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING) - outlen;
         memset(c->decomp_buf + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
     }
     if (c->codec_frameheader) {
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 41a4dc55f4a..89faa42e90a 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1030,29 +1030,29 @@ static av_cold int nvenc_recalc_surfaces(AVCodecContext *avctx)
     if (ctx->rc_lookahead > 0) {
         // +1 is to account for lkd_bound calculation later
         // +4 is to allow sufficient pipelining with lookahead
-        nb_surfaces = FFMAX(1, FFMAX(nb_surfaces, ctx->rc_lookahead + ctx->encode_config.frameIntervalP + 1 + 4));
+        nb_surfaces = FFMAXI(1, FFMAX(nb_surfaces, ctx->rc_lookahead + ctx->encode_config.frameIntervalP + 1 + 4));
         if (nb_surfaces > ctx->nb_surfaces && ctx->nb_surfaces > 0)
         {
             av_log(avctx, AV_LOG_WARNING,
                    "Defined rc_lookahead requires more surfaces, "
                    "increasing used surfaces %d -> %d\n", ctx->nb_surfaces, nb_surfaces);
         }
-        ctx->nb_surfaces = FFMAX(nb_surfaces, ctx->nb_surfaces);
+        ctx->nb_surfaces = FFMAXI(nb_surfaces, ctx->nb_surfaces);
     } else {
         if (ctx->encode_config.frameIntervalP > 1 && ctx->nb_surfaces < nb_surfaces && ctx->nb_surfaces > 0)
         {
             av_log(avctx, AV_LOG_WARNING,
                    "Defined b-frame requires more surfaces, "
                    "increasing used surfaces %d -> %d\n", ctx->nb_surfaces, nb_surfaces);
-            ctx->nb_surfaces = FFMAX(ctx->nb_surfaces, nb_surfaces);
+            ctx->nb_surfaces = FFMAXI(ctx->nb_surfaces, nb_surfaces);
         }
         else if (ctx->nb_surfaces <= 0)
             ctx->nb_surfaces = nb_surfaces;
         // otherwise use user specified value
     }
 
-    ctx->nb_surfaces = FFMAX(1, FFMIN(MAX_REGISTERED_FRAMES, ctx->nb_surfaces));
-    ctx->async_depth = FFMIN(ctx->async_depth, ctx->nb_surfaces - 1);
+    ctx->nb_surfaces = FFMAXI(1, FFMINI(MAX_REGISTERED_FRAMES, ctx->nb_surfaces));
+    ctx->async_depth = FFMINI(ctx->async_depth, ctx->nb_surfaces - 1);
 
     // Output in the worst case will only start when the surface buffer is completely full.
     // Hence we need to keep at least the max amount of surfaces plus the max reorder delay around.
@@ -1171,7 +1171,7 @@ static av_cold int nvenc_setup_rate_control(AVCodecContext *avctx)
     }
 
     if (ctx->rc_lookahead > 0) {
-        int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) -
+        int lkd_bound = FFMINI(ctx->nb_surfaces, ctx->async_depth) -
                         ctx->encode_config.frameIntervalP - 4;
 
         if (lkd_bound < 0) {
@@ -1842,8 +1842,8 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
 
     if (ctx->bluray_compat) {
         ctx->aud = 1;
-        ctx->dpb_size = FFMIN(FFMAX(avctx->refs, 0), 6);
-        avctx->max_b_frames = FFMIN(avctx->max_b_frames, 3);
+        ctx->dpb_size = FFMINI(FFMAXI(avctx->refs, 0), 6);
+        avctx->max_b_frames = FFMINI(avctx->max_b_frames, 3);
         switch (avctx->codec->id) {
         case AV_CODEC_ID_H264:
             /* maximum level depends on used resolution */
diff --git a/libavcodec/opus/celt.c b/libavcodec/opus/celt.c
index 3b9c633702e..6b538136a3b 100644
--- a/libavcodec/opus/celt.c
+++ b/libavcodec/opus/celt.c
@@ -55,8 +55,8 @@ void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)
             f->remaining -= consumed;
         f->remaining2 = totalbits - consumed - 1;
         if (i <= f->coded_bands - 1) {
-            int curr_balance = f->remaining / FFMIN(3, f->coded_bands-i);
-            b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[i] + curr_balance), 14);
+            int curr_balance = f->remaining / FFMINI(3, f->coded_bands-i);
+            b = av_clip_uintp2(FFMINI(f->remaining2 + 1, f->pulses[i] + curr_balance), 14);
         }
 
         if ((ff_celt_freq_bands[i] - ff_celt_freq_range[i] >= ff_celt_freq_bands[f->start_band] ||
@@ -81,7 +81,7 @@ void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)
             int foldstart, foldend;
 
             /* This ensures we never repeat spectral content within one band */
-            effective_lowband = FFMAX(ff_celt_freq_bands[f->start_band],
+            effective_lowband = FFMAXI(ff_celt_freq_bands[f->start_band],
                                       ff_celt_freq_bands[lowband_offset] - ff_celt_freq_range[i]);
             foldstart = lowband_offset;
             while (ff_celt_freq_bands[--foldstart] > effective_lowband);
@@ -170,7 +170,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
         int quanta = ff_celt_freq_range[i] << (f->channels - 1) << f->size;
         int b_dynalloc = dynalloc;
         int boost_amount = f->alloc_boost[i];
-        quanta = FFMIN(quanta << 3, FFMAX(6 << 3, quanta));
+        quanta = FFMINI(quanta << 3, FFMAXI(6 << 3, quanta));
 
         while (opus_rc_tell_frac(rc) + (b_dynalloc << 3) < tbits_8ths && boost[i] < f->caps[i]) {
             int is_boost;
@@ -191,7 +191,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
         }
 
         if (boost[i])
-            dynalloc = FFMAX(dynalloc - 1, 2);
+            dynalloc = FFMAXI(dynalloc - 1, 2);
     }
 
     /* Allocation trim */
@@ -238,7 +238,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
 
         /* PVQ minimum allocation threshold, below this value the band is
          * skipped */
-        threshold[i] = FFMAX(3 * ff_celt_freq_range[i] << duration >> 4,
+        threshold[i] = FFMAXI(3 * ff_celt_freq_range[i] << duration >> 4,
                              f->channels << 3);
 
         trim_offset[i] = trim * (band << scale) >> 6;
@@ -258,12 +258,12 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
             bandbits = NORMC(ff_celt_freq_range[i] * ff_celt_static_alloc[center][i]);
 
             if (bandbits)
-                bandbits = FFMAX(bandbits + trim_offset[i], 0);
+                bandbits = FFMAXI(bandbits + trim_offset[i], 0);
             bandbits += boost[i];
 
             if (bandbits >= threshold[i] || done) {
                 done = 1;
-                total += FFMIN(bandbits, f->caps[i]);
+                total += FFMINI(bandbits, f->caps[i]);
             } else if (bandbits >= f->channels << 3) {
                 total += f->channels << 3;
             }
@@ -283,9 +283,9 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
                    NORMC(ff_celt_freq_range[i] * ff_celt_static_alloc[high][i]);
 
         if (bits1[i])
-            bits1[i] = FFMAX(bits1[i] + trim_offset[i], 0);
+            bits1[i] = FFMAXI(bits1[i] + trim_offset[i], 0);
         if (bits2[i])
-            bits2[i] = FFMAX(bits2[i] + trim_offset[i], 0);
+            bits2[i] = FFMAXI(bits2[i] + trim_offset[i], 0);
 
         if (low)
             bits1[i] += boost[i];
@@ -293,7 +293,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
 
         if (boost[i])
             skip_startband = i;
-        bits2[i] = FFMAX(bits2[i] - bits1[i], 0);
+        bits2[i] = FFMAXI(bits2[i] - bits1[i], 0);
     }
 
     /* Bisection */
@@ -308,7 +308,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
 
             if (bandbits >= threshold[j] || done) {
                 done = 1;
-                total += FFMIN(bandbits, f->caps[j]);
+                total += FFMINI(bandbits, f->caps[j]);
             } else if (bandbits >= f->channels << 3)
                 total += f->channels << 3;
         }
@@ -329,7 +329,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
             bandbits = (bandbits >= f->channels << 3) ?
             f->channels << 3 : 0;
 
-        bandbits     = FFMIN(bandbits, f->caps[i]);
+        bandbits     = FFMINI(bandbits, f->caps[i]);
         f->pulses[i] = bandbits;
         total      += bandbits;
     }
@@ -350,11 +350,11 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
         bandbits    = remaining / (ff_celt_freq_bands[j+1] - ff_celt_freq_bands[f->start_band]);
         remaining  -= bandbits  * (ff_celt_freq_bands[j+1] - ff_celt_freq_bands[f->start_band]);
         allocation  = f->pulses[j] + bandbits * ff_celt_freq_range[j];
-        allocation += FFMAX(remaining - (ff_celt_freq_bands[j] - ff_celt_freq_bands[f->start_band]), 0);
+        allocation += FFMAXI(remaining - (ff_celt_freq_bands[j] - ff_celt_freq_bands[f->start_band]), 0);
 
         /* a "do not skip" marker is only coded if the allocation is
          * above the chosen threshold */
-        if (allocation >= FFMAX(threshold[j], (f->channels + 1) << 3)) {
+        if (allocation >= FFMAXI(threshold[j], (f->channels + 1) << 3)) {
             int do_not_skip;
             if (encode) {
                 do_not_skip = f->coded_bands <= f->skip_band_floor;
@@ -384,7 +384,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
     /* IS start band */
     if (encode) {
         if (intensitystereo_bit) {
-            f->intensity_stereo = FFMIN(f->intensity_stereo, f->coded_bands);
+            f->intensity_stereo = FFMINI(f->intensity_stereo, f->coded_bands);
             ff_opus_rc_enc_uint(rc, f->intensity_stereo, f->coded_bands + 1 - f->start_band);
         }
     } else {
@@ -407,7 +407,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
     bandbits  = remaining / (ff_celt_freq_bands[f->coded_bands] - ff_celt_freq_bands[f->start_band]);
     remaining -= bandbits * (ff_celt_freq_bands[f->coded_bands] - ff_celt_freq_bands[f->start_band]);
     for (i = f->start_band; i < f->coded_bands; i++) {
-        const int bits = FFMIN(remaining, ff_celt_freq_range[i]);
+        const int bits = FFMINI(remaining, ff_celt_freq_range[i]);
         f->pulses[i] += bits + bandbits * ff_celt_freq_range[i];
         remaining    -= bits;
     }
@@ -427,7 +427,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
                              * extra bits assigned over the standard
                              * totalbits/dof */
 
-            extrabits = FFMAX(f->pulses[i] - f->caps[i], 0);
+            extrabits = FFMAXI(f->pulses[i] - f->caps[i], 0);
             f->pulses[i] -= extrabits;
 
             /* intensity stereo makes use of an extra degree of freedom */
@@ -444,8 +444,8 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
                 offset += temp >> 3;
 
             fine_bits = (f->pulses[i] + offset + (dof << 2)) / (dof << 3);
-            max_bits  = FFMIN((f->pulses[i] >> 3) >> (f->channels - 1), CELT_MAX_FINE_BITS);
-            max_bits  = FFMAX(max_bits, 0);
+            max_bits  = FFMINI((f->pulses[i] >> 3) >> (f->channels - 1), CELT_MAX_FINE_BITS);
+            max_bits  = FFMAXI(max_bits, 0);
             f->fine_bits[i] = av_clip(fine_bits, 0, max_bits);
 
             /* If fine_bits was rounded down or capped,
@@ -456,7 +456,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
             f->pulses[i] -= f->fine_bits[i] << (f->channels - 1) << 3;
         } else {
             /* all bits go to fine energy except for the sign bit */
-            extrabits = FFMAX(f->pulses[i] - (f->channels << 3), 0);
+            extrabits = FFMAXI(f->pulses[i] - (f->channels << 3), 0);
             f->pulses[i] -= extrabits;
             f->fine_bits[i] = 0;
             f->fine_priority[i] = 1;
@@ -464,7 +464,7 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
 
         /* hand back a limited number of extra fine energy bits to this band */
         if (extrabits > 0) {
-            int fineextra = FFMIN(extrabits >> (f->channels + 2),
+            int fineextra = FFMINI(extrabits >> (f->channels + 2),
                                   CELT_MAX_FINE_BITS - f->fine_bits[i]);
             f->fine_bits[i] += fineextra;
 
diff --git a/libavcodec/opus/dec.c b/libavcodec/opus/dec.c
index 6c59dc1f46e..62b8ecc98b1 100644
--- a/libavcodec/opus/dec.c
+++ b/libavcodec/opus/dec.c
@@ -255,7 +255,7 @@ static int opus_decode_frame(OpusStreamContext *s, const uint8_t *data, int size
         }
 
         samples = ff_silk_decode_superframe(s->silk, &s->rc, s->silk_output,
-                                            FFMIN(s->packet.bandwidth, OPUS_BANDWIDTH_WIDEBAND),
+                                            FFMINI(s->packet.bandwidth, OPUS_BANDWIDTH_WIDEBAND),
                                             s->packet.stereo + 1,
                                             silk_frame_duration_ms[s->packet.config]);
         if (samples < 0) {
@@ -491,7 +491,7 @@ static int opus_decode_packet(AVCodecContext *avctx, AVFrame *frame,
         OpusStreamContext *s = &c->streams[i];
         s->out[0] =
         s->out[1] = NULL;
-        delayed_samples = FFMAX(delayed_samples,
+        delayed_samples = FFMAXI(delayed_samples,
                                 s->delayed_samples + av_audio_fifo_size(s->sync_buffer));
     }
 
@@ -583,7 +583,7 @@ static int opus_decode_packet(AVCodecContext *avctx, AVFrame *frame,
         if (ret < 0)
             return ret;
         s->decoded_samples = ret;
-        decoded_samples       = FFMIN(decoded_samples, ret);
+        decoded_samples       = FFMINI(decoded_samples, ret);
 
         buf      += s->packet.packet_size;
         buf_size -= s->packet.packet_size;
diff --git a/libavcodec/opus/dec_celt.c b/libavcodec/opus/dec_celt.c
index 3feb4a4e475..4324b387b49 100644
--- a/libavcodec/opus/dec_celt.c
+++ b/libavcodec/opus/dec_celt.c
@@ -63,7 +63,7 @@ static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc)
             available = f->framebits - opus_rc_tell(rc);
             if (available >= 15) {
                 /* decode using a Laplace distribution */
-                int k = FFMIN(i, 20) << 1;
+                int k = FFMINI(i, 20) << 1;
                 value = ff_opus_rc_dec_laplace(rc, model[k] << 7, model[k+1] << 6);
             } else if (available >= 2) {
                 int x = ff_opus_rc_dec_cdf(rc, ff_celt_model_energy_small);
@@ -72,7 +72,7 @@ static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc)
                 value = -(float)ff_opus_rc_dec_log(rc, 1);
             } else value = -1;
 
-            block->energy[i] = FFMAX(-9.0f, block->energy[i]) * alpha + prev[j] + value;
+            block->energy[i] = FFMAXF(-9.0f, block->energy[i]) * alpha + prev[j] + value;
             prev[j] += beta * value;
         }
     }
@@ -153,7 +153,7 @@ static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
     for (i = f->start_band; i < f->end_band; i++) {
         float *dst = data + (ff_celt_freq_bands[i] << f->size);
         float log_norm = block->energy[i] + ff_celt_mean_energy[i];
-        float norm = exp2f(FFMIN(log_norm, 32.0f));
+        float norm = exp2f(FFMINF(log_norm, 32.0f));
 
         for (j = 0; j < ff_celt_freq_range[i] << f->size; j++)
             dst[j] *= norm;
@@ -255,7 +255,7 @@ static int parse_postfilter(CeltFrame *f, OpusRangeCoder *rc, int consumed)
             for (i = 0; i < 2; i++) {
                 CeltBlock *block = &f->block[i];
 
-                block->pf_period_new = FFMAX(period, CELT_POSTFILTER_MINPERIOD);
+                block->pf_period_new = FFMAXI(period, CELT_POSTFILTER_MINPERIOD);
                 block->pf_gains_new[0] = gain * ff_celt_postfilter_taps[tapset][0];
                 block->pf_gains_new[1] = gain * ff_celt_postfilter_taps[tapset][1];
                 block->pf_gains_new[2] = gain * ff_celt_postfilter_taps[tapset][2];
@@ -292,18 +292,18 @@ static void process_anticollapse(CeltFrame *f, CeltBlock *block, float *X)
         if (f->channels == 1) {
             CeltBlock *block1 = &f->block[1];
 
-            prev[0] = FFMAX(prev[0], block1->prev_energy[0][i]);
-            prev[1] = FFMAX(prev[1], block1->prev_energy[1][i]);
+            prev[0] = FFMAXF(prev[0], block1->prev_energy[0][i]);
+            prev[1] = FFMAXF(prev[1], block1->prev_energy[1][i]);
         }
-        Ediff = block->energy[i] - FFMIN(prev[0], prev[1]);
-        Ediff = FFMAX(0, Ediff);
+        Ediff = block->energy[i] - FFMINF(prev[0], prev[1]);
+        Ediff = FFMAXF(0, Ediff);
 
         /* r needs to be multiplied by 2 or 2*sqrt(2) depending on LM because
         short blocks don't have the same energy as long */
         r = exp2f(1 - Ediff);
         if (f->size == 3)
             r *= M_SQRT2;
-        r = FFMIN(thresh, r) * sqrt_1;
+        r = FFMINF(thresh, r) * sqrt_1;
         for (k = 0; k < 1 << f->size; k++) {
             /* Detect collapse */
             if (!(block->collapse_masks[i] & 1 << k)) {
@@ -394,7 +394,7 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc,
 
     if (channels == 1) {
         for (i = 0; i < CELT_MAX_BANDS; i++)
-            f->block[0].energy[i] = FFMAX(f->block[0].energy[i], f->block[1].energy[i]);
+            f->block[0].energy[i] = FFMAXF(f->block[0].energy[i], f->block[1].energy[i]);
     }
 
     celt_decode_coarse_energy(f, rc);
@@ -476,7 +476,7 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc,
             memcpy(block->prev_energy[0], block->energy,         sizeof(block->prev_energy[0]));
         } else {
             for (j = 0; j < CELT_MAX_BANDS; j++)
-                block->prev_energy[0][j] = FFMIN(block->prev_energy[0][j], block->energy[j]);
+                block->prev_energy[0][j] = FFMINF(block->prev_energy[0][j], block->energy[j]);
         }
 
         for (j = 0; j < f->start_band; j++) {
diff --git a/libavcodec/opus/enc.c b/libavcodec/opus/enc.c
index f603b422a05..70dd5ad474f 100644
--- a/libavcodec/opus/enc.c
+++ b/libavcodec/opus/enc.c
@@ -148,7 +148,7 @@ static void celt_frame_setup_input(OpusEncContext *s, CeltFrame *f)
             const void *input = cur->extended_data[ch];
             const size_t bps  = av_get_bytes_per_sample(cur->format);
             const size_t left = (subframesize - cur->nb_samples)*bps;
-            const size_t len  = FFMIN(subframesize, cur->nb_samples)*bps;
+            const size_t len  = FFMINI(subframesize, cur->nb_samples)*bps;
             memcpy(&b->samples[sf*subframesize], input, len);
             memset(&b->samples[cur->nb_samples], 0, left);
         }
@@ -255,7 +255,7 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f)
             block->energy[i] = log2f(block->lin_energy[i]) - ff_celt_mean_energy[i];
 
             /* CELT_ENERGY_SILENCE is what the decoder uses and its not -infinity */
-            block->energy[i] = FFMAX(block->energy[i], CELT_ENERGY_SILENCE);
+            block->energy[i] = FFMAXF(block->energy[i], CELT_ENERGY_SILENCE);
         }
     }
 }
@@ -297,7 +297,7 @@ static void celt_enc_quant_pfilter(OpusRangeCoder *rc, CeltFrame *f)
         return;
 
     /* Octave */
-    txval = FFMIN(octave, 6);
+    txval = FFMINI(octave, 6);
     ff_opus_rc_enc_uint(rc, txval, 6);
     octave = txval;
     /* Period */
@@ -305,7 +305,7 @@ static void celt_enc_quant_pfilter(OpusRangeCoder *rc, CeltFrame *f)
     ff_opus_rc_put_raw(rc, period, 4 + octave);
     period = txval + (16 << octave) - 1;
     /* Gain */
-    txval = FFMIN(((int)(gain / 0.09375f)) - 1, 7);
+    txval = FFMINI(((int)(gain / 0.09375f)) - 1, 7);
     ff_opus_rc_put_raw(rc, txval, 3);
     gain   = 0.09375f * (txval + 1);
     /* Tapset */
@@ -317,7 +317,7 @@ static void celt_enc_quant_pfilter(OpusRangeCoder *rc, CeltFrame *f)
     for (int i = 0; i < 2; i++) {
         CeltBlock *block = &f->block[i];
 
-        block->pf_period_new = FFMAX(period, CELT_POSTFILTER_MINPERIOD);
+        block->pf_period_new = FFMAXI(period, CELT_POSTFILTER_MINPERIOD);
         block->pf_gains_new[0] = gain * ff_celt_postfilter_taps[tapset][0];
         block->pf_gains_new[1] = gain * ff_celt_postfilter_taps[tapset][1];
         block->pf_gains_new[2] = gain * ff_celt_postfilter_taps[tapset][2];
@@ -348,7 +348,7 @@ static void exp_quant_coarse(OpusRangeCoder *rc, CeltFrame *f,
         for (int ch = 0; ch < f->channels; ch++) {
             CeltBlock *block = &f->block[ch];
             const int left = f->framebits - opus_rc_tell(rc);
-            const float last = FFMAX(-9.0f, last_energy[ch][i]);
+            const float last = FFMAXF(-9.0f, last_energy[ch][i]);
             float diff = block->energy[i] - prev[ch] - last*alpha;
             int q_en = lrintf(diff);
             if (left >= 15) {
@@ -489,7 +489,7 @@ static void celt_encode_frame(OpusEncContext *s, OpusRangeCoder *rc,
 
 static inline int write_opuslacing(uint8_t *dst, int v)
 {
-    dst[0] = FFMIN(v - FFALIGN(v - 255, 4), v);
+    dst[0] = FFMINI(v - FFALIGN(v - 255, 4), v);
     dst[1] = v - dst[0] >> 2;
     return 1 + (v >= 252);
 }
@@ -692,7 +692,7 @@ static av_cold int opus_encode_init(AVCodecContext *avctx)
         return ret;
 
     /* Frame structs and range coder buffers */
-    max_frames = ceilf(FFMIN(s->options.max_delay_ms, 120.0f)/2.5f);
+    max_frames = ceilf(FFMINF(s->options.max_delay_ms, 120.0f)/2.5f);
     s->frame = av_malloc(max_frames*sizeof(CeltFrame));
     if (!s->frame)
         return AVERROR(ENOMEM);
diff --git a/libavcodec/opus/enc_psy.c b/libavcodec/opus/enc_psy.c
index 250cfb567ae..d5b5c7ad4e8 100644
--- a/libavcodec/opus/enc_psy.c
+++ b/libavcodec/opus/enc_psy.c
@@ -48,8 +48,8 @@ static float pvq_band_cost(CeltPVQ *pvq, CeltFrame *f, OpusRangeCoder *rc, int b
 
     f->remaining2 = ((f->framebits << 3) - f->anticollapse_needed) - opus_rc_tell_frac(rc) - 1;
     if (band <= f->coded_bands - 1) {
-        int curr_balance = f->remaining / FFMIN(3, f->coded_bands - band);
-        b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[band] + curr_balance), 14);
+        int curr_balance = f->remaining / FFMINI(3, f->coded_bands - band);
+        b = av_clip_uintp2(FFMINI(f->remaining2 + 1, f->pulses[band] + curr_balance), 14);
     }
 
     if (f->dual_stereo) {
@@ -88,7 +88,7 @@ static void step_collect_psy_metrics(OpusPsyContext *s, int index)
 
     for (ch = 0; ch < s->avctx->ch_layout.nb_channels; ch++) {
         const int lap_size = (1 << s->bsize_analysis);
-        for (i = 1; i <= FFMIN(lap_size, index); i++) {
+        for (i = 1; i <= FFMINI(lap_size, index); i++) {
             const int offset = i*120;
             AVFrame *cur = ff_bufqueue_peek(s->bufqueue, index - i);
             memcpy(&s->scratch[offset], cur->extended_data[ch], cur->nb_samples*sizeof(float));
@@ -158,7 +158,7 @@ static void step_collect_psy_metrics(OpusPsyContext *s, int index)
             }
             if (ex->excitation > 0.0f) {
                 ex->excitation -= av_clipf((1/expf(ex->excitation_dist)), ex->excitation_init/20, ex->excitation_init/1.09);
-                ex->excitation = FFMAX(ex->excitation, 0.0f);
+                ex->excitation = FFMAXF(ex->excitation, 0.0f);
                 ex->excitation_dist += 1.0f;
             }
         }
@@ -198,7 +198,7 @@ static int flush_silent_frames(OpusPsyContext *s)
     for (fsize = CELT_BLOCK_960; fsize > CELT_BLOCK_120; fsize--) {
         if ((1 << fsize) > silent_frames)
             continue;
-        s->p.frames = FFMIN(silent_frames / (1 << fsize), 48 >> fsize);
+        s->p.frames = FFMINI(silent_frames / (1 << fsize), 48 >> fsize);
         s->p.framesize = fsize;
         return 1;
     }
@@ -210,7 +210,7 @@ static int flush_silent_frames(OpusPsyContext *s)
 static void psy_output_groups(OpusPsyContext *s)
 {
     int max_delay_samples = (s->options->max_delay_ms*s->avctx->sample_rate)/1000;
-    int max_bsize = FFMIN(OPUS_SAMPLES_TO_BLOCK_SIZE(max_delay_samples), CELT_BLOCK_960);
+    int max_bsize = FFMINI(OPUS_SAMPLES_TO_BLOCK_SIZE(max_delay_samples), CELT_BLOCK_960);
 
     /* These don't change for now */
     s->p.mode      = OPUS_MODE_CELT;
@@ -220,7 +220,7 @@ static void psy_output_groups(OpusPsyContext *s)
     if (s->steps[0]->silence && flush_silent_frames(s))
         return;
 
-    s->p.framesize = FFMIN(max_bsize, CELT_BLOCK_960);
+    s->p.framesize = FFMINI(max_bsize, CELT_BLOCK_960);
     s->p.frames    = 1;
 }
 
@@ -282,7 +282,7 @@ void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index)
         }
     }
 
-    for (i = start_offset; i < FFMIN(radius, s->inflection_points_count - start_offset); i++) {
+    for (i = start_offset; i < FFMINI(radius, s->inflection_points_count - start_offset); i++) {
         if (s->inflection_points[i] < (step_offset + radius)) {
             neighbouring_points++;
         }
@@ -360,7 +360,7 @@ static void celt_gauge_psy_weight(OpusPsyContext *s, OpusPsyStep **start,
     rate /= s->avctx->sample_rate/frame_size;
 
     f_out->framebits = lrintf(rate);
-    f_out->framebits = FFMIN(f_out->framebits, OPUS_MAX_FRAME_SIZE * 8);
+    f_out->framebits = FFMINI(f_out->framebits, OPUS_MAX_FRAME_SIZE * 8);
     f_out->framebits = FFALIGN(f_out->framebits, 8);
 }
 
diff --git a/libavcodec/opus/pvq.c b/libavcodec/opus/pvq.c
index fe57ab02cee..bccf82b9eae 100644
--- a/libavcodec/opus/pvq.c
+++ b/libavcodec/opus/pvq.c
@@ -34,7 +34,7 @@
 
 #define ROUND_MUL16(a,b)  ((MUL16(a, b) + 16384) >> 15)
 
-#define CELT_PVQ_U(n, k) (ff_celt_pvq_u_row[FFMIN(n, k)][FFMAX(n, k)])
+#define CELT_PVQ_U(n, k) (ff_celt_pvq_u_row[FFMINI(n, k)][FFMAXI(n, k)])
 #define CELT_PVQ_V(n, k) (CELT_PVQ_U(n, k) + CELT_PVQ_U(n, (k) + 1))
 
 static inline int16_t celt_cos(int16_t x)
@@ -742,7 +742,7 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
                 else
                     /* Corresponds to a forward-masking slope of
                      * 1.5 dB per 10 ms */
-                    delta = FFMIN(0, delta + (N << 3 >> (5 - duration)));
+                    delta = FFMINI(0, delta + (N << 3 >> (5 - duration)));
             }
             mbits = av_clip((b - delta) / 2, 0, b);
             sbits = b - mbits;
diff --git a/libavcodec/opus/rc.c b/libavcodec/opus/rc.c
index 8e58a52b853..2645ed6cc9f 100644
--- a/libavcodec/opus/rc.c
+++ b/libavcodec/opus/rc.c
@@ -95,7 +95,7 @@ uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
 
     scale   = rc->range / total;
     symbol = rc->value / scale + 1;
-    symbol = total - FFMIN(symbol, total);
+    symbol = total - FFMINI(symbol, total);
 
     for (k = 0; cdf[k] <= symbol; k++);
     high = cdf[k];
@@ -160,7 +160,7 @@ uint32_t ff_opus_rc_get_raw(OpusRangeCoder *rc, uint32_t count)
  */
 void ff_opus_rc_put_raw(OpusRangeCoder *rc, uint32_t val, uint32_t count)
 {
-    const int to_write = FFMIN(32 - rc->rb.cachelen, count);
+    const int to_write = FFMINI(32 - rc->rb.cachelen, count);
 
     rc->total_bits += count;
     rc->rb.cacheval |= av_zero_extend(val, to_write) << rc->rb.cachelen;
@@ -188,12 +188,12 @@ uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size)
 
     scale  = rc->range / total;
     k      = rc->value / scale + 1;
-    k      = total - FFMIN(k, total);
+    k      = total - FFMINI(k, total);
     opus_rc_dec_update(rc, scale, k, k + 1, total);
 
     if (bits > 8) {
         k = k << (bits - 8) | ff_opus_rc_get_raw(rc, bits - 8);
-        return FFMIN(k, size - 1);
+        return FFMINI(k, size - 1);
     } else
         return k;
 }
@@ -203,7 +203,7 @@ uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size)
  */
 void ff_opus_rc_enc_uint(OpusRangeCoder *rc, uint32_t val, uint32_t size)
 {
-    const int ps = FFMAX(opus_ilog(size - 1) - 8, 0);
+    const int ps = FFMAXI(opus_ilog(size - 1) - 8, 0);
     opus_rc_enc_update(rc, val >> ps, (val >> ps) + 1, ((size - 1) >> ps) + 1, 0);
     ff_opus_rc_put_raw(rc, val, ps);
 }
@@ -214,7 +214,7 @@ uint32_t ff_opus_rc_dec_uint_step(OpusRangeCoder *rc, int k0)
     uint32_t k, scale, symbol, total = (k0+1)*3 + k0;
     scale  = rc->range / total;
     symbol = rc->value / scale + 1;
-    symbol = total - FFMIN(symbol, total);
+    symbol = total - FFMINI(symbol, total);
 
     k = (symbol < (k0+1)*3) ? symbol/3 : symbol - (k0+1)*2;
 
@@ -238,7 +238,7 @@ uint32_t ff_opus_rc_dec_uint_tri(OpusRangeCoder *rc, int qn)
     total = ((qn>>1) + 1) * ((qn>>1) + 1);
     scale   = rc->range / total;
     center = rc->value / scale + 1;
-    center = total - FFMIN(center, total);
+    center = total - FFMINI(center, total);
 
     if (center < total >> 1) {
         k      = (ff_sqrt(8 * center + 1) - 1) >> 1;
@@ -280,7 +280,7 @@ int ff_opus_rc_dec_laplace(OpusRangeCoder *rc, uint32_t symbol, int decay)
 
     scale  = rc->range >> 15;
     center = rc->value / scale + 1;
-    center = (1 << 15) - FFMIN(center, 1 << 15);
+    center = (1 << 15) - FFMINI(center, 1 << 15);
 
     if (center >= symbol) {
         value++;
@@ -306,7 +306,7 @@ int ff_opus_rc_dec_laplace(OpusRangeCoder *rc, uint32_t symbol, int decay)
             low += symbol;
     }
 
-    opus_rc_dec_update(rc, scale, low, FFMIN(low + symbol, 32768), 32768);
+    opus_rc_dec_update(rc, scale, low, FFMINI(low + symbol, 32768), 32768);
 
     return value;
 }
@@ -327,9 +327,9 @@ void ff_opus_rc_enc_laplace(OpusRangeCoder *rc, int *value, uint32_t symbol, int
     if (symbol) {
         low += (++symbol)*pos;
     } else {
-        const int distance = FFMIN(val - i, (((32768 - low) - !pos) >> 1) - 1);
+        const int distance = FFMINI(val - i, (((32768 - low) - !pos) >> 1) - 1);
         low   += pos + (distance << 1);
-        symbol = FFMIN(1, 32768 - low);
+        symbol = FFMINI(1, 32768 - low);
         *value = FFSIGN(*value)*(distance + i);
     }
     opus_rc_enc_update(rc, low, low + symbol, 1 << 15, 1);
@@ -391,11 +391,11 @@ void ff_opus_rc_enc_end(OpusRangeCoder *rc, uint8_t *dst, int size)
         uint8_t *rb_src, *rb_dst;
         ff_opus_rc_put_raw(rc, 0, 32 - rc->rb.cachelen);
         rb_src = rc->buf + OPUS_MAX_FRAME_SIZE + 12 - rc->rb.bytes;
-        rb_dst = dst + FFMAX(size - rc->rb.bytes, 0);
+        rb_dst = dst + FFMAXI(size - rc->rb.bytes, 0);
         lap = &dst[rng_bytes] - rb_dst;
         for (i = 0; i < lap; i++)
             rb_dst[i] |= rb_src[i];
-        memcpy(&rb_dst[lap], &rb_src[lap], FFMAX(rc->rb.bytes - lap, 0));
+        memcpy(&rb_dst[lap], &rb_src[lap], FFMAXI(rc->rb.bytes - lap, 0));
     }
 }
 
diff --git a/libavcodec/opus/silk.c b/libavcodec/opus/silk.c
index 97bb95037ce..1a492d09ef1 100644
--- a/libavcodec/opus/silk.c
+++ b/libavcodec/opus/silk.c
@@ -113,7 +113,7 @@ static inline void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_
             /* move apart */
             center_val = nlsf[k - 1] + nlsf[k];
             center_val = (center_val >> 1) + (center_val & 1); // rounded divide by 2
-            center_val = FFMIN(max_center, FFMAX(min_center, center_val));
+            center_val = FFMINI(max_center, FFMAXI(min_center, center_val));
 
             nlsf[k - 1] = center_val - (min_delta[k] >> 1);
             nlsf[k]     = nlsf[k - 1] + min_delta[k];
@@ -134,7 +134,7 @@ static inline void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_
     if (nlsf[0] < min_delta[0])
         nlsf[0] = min_delta[0];
     for (i = 1; i < order; i++)
-        nlsf[i] = FFMAX(nlsf[i], FFMIN(nlsf[i - 1] + min_delta[i], 32767));
+        nlsf[i] = FFMAXI(nlsf[i], FFMINI(nlsf[i - 1] + min_delta[i], 32767));
 
     /* push backwards to increase distance */
     if (nlsf[order-1] > 32768 - min_delta[order])
@@ -269,7 +269,7 @@ static void silk_lsf2lpc(const int16_t nlsf[16], float lpcf[16], int order)
         if (maxabs > 32767) {
             /* perform bandwidth expansion */
             unsigned int chirp, chirp_base; // Q16
-            maxabs = FFMIN(maxabs, 163838); // anything above this overflows chirp's numerator
+            maxabs = FFMINI(maxabs, 163838); // anything above this overflows chirp's numerator
             chirp_base = chirp = 65470 - ((maxabs - 32767) << 14) / ((maxabs * (k+1)) >> 2);
 
             for (k = 0; k < order; k++) {
@@ -483,7 +483,7 @@ static inline void silk_decode_excitation(SilkContext *s, OpusRangeCoder *rc,
     for (i = 0; i < shellblocks << 4; i++) {
         if (excitation[i] != 0) {
             int sign = ff_opus_rc_dec_cdf(rc, ff_silk_model_excitation_sign[active +
-                                         voiced][qoffset_high][FFMIN(pulsecount[i >> 4], 6)]);
+                                         voiced][qoffset_high][FFMINI(pulsecount[i >> 4], 6)]);
             if (sign == 0)
                 excitation[i] *= -1;
         }
@@ -577,11 +577,11 @@ static void silk_decode_frame(SilkContext *s, OpusRangeCoder *rc,
             log_gain = (x<<3) | ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_lowbits);
 
             if (frame->coded)
-                log_gain = FFMAX(log_gain, frame->log_gain - 16);
+                log_gain = FFMAXI(log_gain, frame->log_gain - 16);
         } else {
             /* gain is coded relative */
             int delta_gain = ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_delta);
-            log_gain = av_clip_uintp2(FFMAX((delta_gain<<1) - 16,
+            log_gain = av_clip_uintp2(FFMAXI((delta_gain<<1) - 16,
                                      frame->log_gain + delta_gain - 4), 6);
         }
 
diff --git a/libavcodec/osq.c b/libavcodec/osq.c
index 1e94a486e9e..6612ce13e99 100644
--- a/libavcodec/osq.c
+++ b/libavcodec/osq.c
@@ -432,7 +432,7 @@ static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
                 goto fail;
         }
 
-        size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize - s->bitstream_size);
+        size = FFMINI(s->pkt->size - s->pkt_offset, s->max_framesize - s->bitstream_size);
         memcpy(s->bitstream + s->bitstream_size, s->pkt->data + s->pkt_offset, size);
         s->bitstream_size += size;
         s->pkt_offset += size;
@@ -443,7 +443,7 @@ static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
         }
     }
 
-    frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
+    frame->nb_samples = FFMINI(s->frame_samples, s->nb_samples);
     if (frame->nb_samples <= 0)
         return AVERROR_EOF;
 
diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index 15f2e3c2cf1..1e474b200ec 100644
--- a/libavcodec/pcx.c
+++ b/libavcodec/pcx.c
@@ -63,7 +63,7 @@ static void pcx_palette(GetByteContext *gb, uint32_t *dst, int pallen)
 {
     int i;
 
-    pallen = FFMIN(pallen, bytestream2_get_bytes_left(gb) / 3);
+    pallen = FFMINI(pallen, bytestream2_get_bytes_left(gb) / 3);
     for (i = 0; i < pallen; i++)
         *dst++ = 0xFF000000 | bytestream2_get_be24u(gb);
     if (pallen < 256)
diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index a6f2a1a3425..dcbf2c2c01c 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -201,19 +201,19 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
         for (i = 0; i < npal; i++)
             palette[i] = ff_cga_palette[ cga_mode45_index[idx][i] ];
     } else if (etype == 2) {
-        npal = FFMIN(esize, 16);
+        npal = FFMINI(esize, 16);
         for (i = 0; i < npal; i++) {
             int pal_idx = bytestream2_get_byte(&s->g);
-            palette[i]  = ff_cga_palette[FFMIN(pal_idx, 15)];
+            palette[i]  = ff_cga_palette[FFMINI(pal_idx, 15)];
         }
     } else if (etype == 3) {
-        npal = FFMIN(esize, 16);
+        npal = FFMINI(esize, 16);
         for (i = 0; i < npal; i++) {
             int pal_idx = bytestream2_get_byte(&s->g);
-            palette[i]  = ff_ega_palette[FFMIN(pal_idx, 63)];
+            palette[i]  = ff_ega_palette[FFMINI(pal_idx, 63)];
         }
     } else if (etype == 4 || etype == 5) {
-        npal = FFMIN(esize / 3, 256);
+        npal = FFMINI(esize / 3, 256);
         for (i = 0; i < npal; i++) {
             palette[i] = bytestream2_get_be24(&s->g) << 2;
             palette[i] |= 0xFFU << 24 | palette[i] >> 6 & 0x30303;
@@ -247,7 +247,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
             t1        = bytestream2_get_bytes_left(&s->g);
             t2        = bytestream2_get_le16(&s->g);
-            stop_size = t1 - FFMIN(t1, t2);
+            stop_size = t1 - FFMINI(t1, t2);
             // ignore uncompressed block size
             bytestream2_skip(&s->g, 2);
             marker    = bytestream2_get_byte(&s->g);
@@ -285,7 +285,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
         }
     } else {
         while (y >= 0 && bytestream2_get_bytes_left(&s->g) > 0) {
-            memcpy(frame->data[0] + y * frame->linesize[0], s->g.buffer, FFMIN(avctx->width, bytestream2_get_bytes_left(&s->g)));
+            memcpy(frame->data[0] + y * frame->linesize[0], s->g.buffer, FFMINI(avctx->width, bytestream2_get_bytes_left(&s->g)));
             bytestream2_skip(&s->g, avctx->width);
             y--;
         }
diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
index e9c561d70d9..0c138e63a24 100644
--- a/libavcodec/pixlet.c
+++ b/libavcodec/pixlet.c
@@ -93,7 +93,7 @@ static int init_decoder(AVCodecContext *avctx)
     int i, plane;
 
     ctx->filter[0]  = av_malloc_array(ctx->h, sizeof(int16_t));
-    ctx->filter[1]  = av_malloc_array(FFMAX(ctx->h, ctx->w) + 16, sizeof(int16_t));
+    ctx->filter[1]  = av_malloc_array(FFMAXI(ctx->h, ctx->w) + 16, sizeof(int16_t));
     ctx->prediction = av_malloc_array((ctx->w >> NB_LEVELS), sizeof(int16_t));
     if (!ctx->filter[0] || !ctx->filter[1] || !ctx->prediction)
         return AVERROR(ENOMEM);
@@ -132,7 +132,7 @@ static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size,
     int rlen, escape, flag = 0;
 
     while (i < size) {
-        nbits = FFMIN(ff_clz((state >> 8) + 3) ^ 0x1F, 14);
+        nbits = FFMINI(ff_clz((state >> 8) + 3) ^ 0x1F, 14);
 
         cnt1 = get_unary(bc, 0, 8);
         if (cnt1 < 8) {
@@ -231,7 +231,7 @@ static int read_high_coeffs(AVCodecContext *avctx, const uint8_t *src, int16_t *
         if (cnt1 >= length) {
             cnt1 = get_bits(bc, nbits);
         } else {
-            pfx = FFMIN(value, 14);
+            pfx = FFMINI(value, 14);
             if (pfx < 1)
                 return AVERROR_INVALIDDATA;
             cnt1 *= (1 << pfx) - 1;
diff --git a/libavcodec/png_parser.c b/libavcodec/png_parser.c
index 314de1b4366..781ef1e54ea 100644
--- a/libavcodec/png_parser.c
+++ b/libavcodec/png_parser.c
@@ -59,7 +59,7 @@ static int png_parse(AVCodecParserContext *s, AVCodecContext *avctx,
         }
         ppc->pc.state64 = state64;
     } else if (ppc->remaining_size) {
-        i = FFMIN(ppc->remaining_size, buf_size);
+        i = FFMINI(ppc->remaining_size, buf_size);
         ppc->remaining_size -= i;
         if (ppc->remaining_size)
             goto flush;
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index b9c997ab0e4..8bd66fb5e6c 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1096,7 +1096,7 @@ static int decode_sbit_chunk(AVCodecContext *avctx, PNGDecContext *s,
 
     for (int i = 0; i < channels; i++) {
         int b = bytestream2_get_byteu(gb);
-        bits = FFMAX(b, bits);
+        bits = FFMAXI(b, bits);
     }
 
     if (bits <= 0 || bits > (s->color_type & PNG_COLOR_MASK_PALETTE ? 8 : s->bit_depth)) {
@@ -1259,7 +1259,7 @@ static void handle_p_frame_png(PNGDecContext *s, AVFrame *p)
     uint8_t *pd_last = s->last_picture.f->data[0];
     int ls = av_image_get_linesize(p->format, s->width, 0);
 
-    ls = FFMIN(ls, s->width * s->bpp);
+    ls = FFMINI(ls, s->width * s->bpp);
 
     ff_progress_frame_await(&s->last_picture, INT_MAX);
     for (j = 0; j < s->height; j++) {
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 9bbb8267cf5..f539a24b5b9 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -160,7 +160,7 @@ static void sub_left_prediction(PNGEncContext *c, uint8_t *dst, const uint8_t *s
     memcpy(dst, src, bpp);
     dst += bpp;
     size -= bpp;
-    unaligned_w = FFMIN(32 - bpp, size);
+    unaligned_w = FFMINI(32 - bpp, size);
     for (x = 0; x < unaligned_w; x++)
         *dst++ = *src1++ - *src2++;
     size -= unaligned_w;
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 74f918a94bc..c66bfc58f84 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -49,7 +49,7 @@ static int pnm_parse(AVCodecParserContext *s, AVCodecContext *avctx,
     }
 
     if (pnmpc->remaining_bytes) {
-        int inc = FFMIN(pnmpc->remaining_bytes, buf_size);
+        int inc = FFMINI(pnmpc->remaining_bytes, buf_size);
         skip += inc;
         pnmpc->remaining_bytes -= inc;
 
@@ -74,7 +74,7 @@ retry:
                 pc->index = 0;
                 pnmpc->ascii_scan = 0;
             } else {
-                unsigned step = FFMAX(1, pnmctx.bytestream - pnmctx.bytestream_start);
+                unsigned step = FFMAXI(1, pnmctx.bytestream - pnmctx.bytestream_start);
 
                 skip += step;
             }
diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index 5f917daca19..f138563b69d 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -466,7 +466,7 @@ static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out,
     code = 5;
     sign = 0;
     for (i = 1; i < blocks_per_slice; i++, out += 64) {
-        DECODE_CODEWORD(code, dc_codebook[FFMIN(code, 6U)], LAST_SKIP_BITS);
+        DECODE_CODEWORD(code, dc_codebook[FFMINI(code, 6U)], LAST_SKIP_BITS);
         if(code) sign ^= -(code & 1);
         else     sign  = 0;
         prev_dc += (((code + 1) >> 1) ^ sign) - sign;
@@ -502,14 +502,14 @@ static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContex
         if (bits_left <= 0 || (bits_left < 32 && !SHOW_UBITS(re, gb, bits_left)))
             break;
 
-        DECODE_CODEWORD(run, run_to_cb[FFMIN(run,  15)], LAST_SKIP_BITS);
+        DECODE_CODEWORD(run, run_to_cb[FFMINI(run,  15)], LAST_SKIP_BITS);
         pos += run + 1;
         if (pos >= max_coeffs) {
             av_log(avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", pos, max_coeffs);
             return AVERROR_INVALIDDATA;
         }
 
-        DECODE_CODEWORD(level, lev_to_cb[FFMIN(level, 9)], SKIP_BITS);
+        DECODE_CODEWORD(level, lev_to_cb[FFMINI(level, 9)], SKIP_BITS);
         level += 1;
 
         i = pos >> log2_block_count;
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 4fc40abaac8..439160fe10b 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -278,7 +278,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
         delta    = (delta ^ sign) - sign;
         code     = MAKE_CODE(delta);
         encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
-        codebook = FFMIN(code, 6);
+        codebook = FFMINI(code, 6);
         sign     = new_sign;
         prev_dc  = dc;
     }
@@ -305,8 +305,8 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
                 encode_vlc_codeword(pb, ff_prores_level_to_cb[prev_level], abs_level - 1);
                 put_sbits(pb, 1, GET_SIGN(level));
 
-                prev_run   = FFMIN(run, 15);
-                prev_level = FFMIN(abs_level, 9);
+                prev_run   = FFMINI(run, 15);
+                prev_level = FFMINI(abs_level, 9);
                 run        = 0;
             } else {
                 run++;
@@ -487,18 +487,18 @@ static inline void subimage_with_fill_template(const uint16_t *src, unsigned x,
                                                unsigned dst_width, unsigned dst_height, int is_alpha_plane,
                                                int is_interlaced, int is_top_field)
 {
-    int box_width = FFMIN(width - x, dst_width);
+    int box_width = FFMINI(width - x, dst_width);
     int i, j, src_stride, box_height;
     uint16_t last_pix, *last_line;
 
     if (!is_interlaced) {
         src_stride = stride >> 1;
         src += y * src_stride + x;
-        box_height = FFMIN(height - y, dst_height);
+        box_height = FFMINI(height - y, dst_height);
     } else {
         src_stride = stride; /* 2 lines stride */
         src += y * src_stride + x;
-        box_height = FFMIN(height/2 - y, dst_height);
+        box_height = FFMINI(height/2 - y, dst_height);
         if (!is_top_field)
             src += stride >> 1;
     }
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index b98bc5c1954..02970ff6eb1 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -295,8 +295,8 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src,
             esrc      = emu_buf;
             elinesize = 16 * sizeof(*emu_buf);
 
-            bw = FFMIN(w - x, mb_width);
-            bh = FFMIN(h - y, 16);
+            bw = FFMINI(w - x, mb_width);
+            bh = FFMINI(h - y, 16);
 
             for (j = 0; j < bh; j++) {
                 memcpy(emu_buf + j * 16,
@@ -348,8 +348,8 @@ static void get_alpha_data(ProresContext *ctx, const uint16_t *src,
     const int slice_width = 16 * mbs_per_slice;
     int i, j, copy_w, copy_h;
 
-    copy_w = FFMIN(w - x, slice_width);
-    copy_h = FFMIN(h - y, 16);
+    copy_w = FFMINI(w - x, slice_width);
+    copy_h = FFMINI(h - y, 16);
     for (i = 0; i < copy_h; i++) {
         memcpy(blocks, src, copy_w * sizeof(*src));
         if (abits == 8)
@@ -422,7 +422,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks,
         delta    = (delta ^ sign) - sign;
         code     = MAKE_CODE(delta);
         encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code);
-        codebook = FFMIN(code, 6);
+        codebook = FFMINI(code, 6);
         sign     = new_sign;
         prev_dc  = dc;
     }
@@ -449,8 +449,8 @@ static void encode_acs(PutBitContext *pb, int16_t *blocks,
                 encode_vlc_codeword(pb, ff_prores_level_to_cb[prev_level], abs_level - 1);
                 put_sbits(pb, 1, GET_SIGN(level));
 
-                prev_run   = FFMIN(run, 15);
-                prev_level = FFMIN(abs_level, 9);
+                prev_run   = FFMINI(run, 15);
+                prev_level = FFMINI(abs_level, 9);
                 run        = 0;
             } else {
                 run++;
@@ -655,7 +655,7 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
         delta    = (delta ^ sign) - sign;
         code     = MAKE_CODE(delta);
         bits    += estimate_vlc(ff_prores_dc_codebook[codebook], code);
-        codebook = FFMIN(code, 6);
+        codebook = FFMINI(code, 6);
         sign     = new_sign;
         prev_dc  = dc;
     }
@@ -686,8 +686,8 @@ static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
                 bits += estimate_vlc(ff_prores_level_to_cb[prev_level],
                                      abs_level - 1) + 1;
 
-                prev_run   = FFMIN(run, 15);
-                prev_level = FFMIN(abs_level, 9);
+                prev_run   = FFMINI(run, 15);
+                prev_level = FFMINI(abs_level, 9);
                 run    = 0;
             } else {
                 run++;
@@ -1059,7 +1059,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                                 ctx->slices_per_picture + 1) *
                                 max_slice_size - pkt_size;
 
-                    delta = FFMAX(delta, 2 * max_slice_size);
+                    delta = FFMAXI(delta, 2 * max_slice_size);
                     ctx->frame_size_upper_bound += delta;
 
                     if (!ctx->warn) {
diff --git a/libavcodec/psd.c b/libavcodec/psd.c
index 9c3e4f69052..da1516cb8fa 100644
--- a/libavcodec/psd.c
+++ b/libavcodec/psd.c
@@ -167,7 +167,7 @@ static int decode_header(PSDContext * s)
         int i,j;
         memset(s->palette, 0xff, AVPALETTE_SIZE);
         for (j = HAVE_BIGENDIAN; j < 3 + HAVE_BIGENDIAN; j++)
-            for (i = 0; i < FFMIN(256, len_section / 3); i++)
+            for (i = 0; i < FFMINI(256, len_section / 3); i++)
                 s->palette[i * 4 + (HAVE_BIGENDIAN ? j : 2 - j)] = bytestream2_get_byteu(&s->gb);
         len_section -= i * 3;
     }
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 4ea5dd3698a..ace2fefb390 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -928,7 +928,7 @@ av_cold int ff_frame_thread_init(AVCodecContext *avctx)
         int nb_cpus = av_cpu_count();
         // use number of cores + 1 as thread count if there is more than one
         if (nb_cpus > 1)
-            thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
+            thread_count = avctx->thread_count = FFMINI(nb_cpus + 1, MAX_AUTO_THREADS);
         else
             thread_count = avctx->thread_count = 1;
     }
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index f9da670735c..aad3960532a 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -118,10 +118,10 @@ av_cold int ff_slice_thread_init(AVCodecContext *avctx)
     if (!thread_count) {
         int nb_cpus = av_cpu_count();
         if  (avctx->height)
-            nb_cpus = FFMIN(nb_cpus, (avctx->height+15)/16);
+            nb_cpus = FFMINI(nb_cpus, (avctx->height+15)/16);
         // use number of cores + 1 as thread count if there is more than one
         if (nb_cpus > 1)
-            thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
+            thread_count = avctx->thread_count = FFMINI(nb_cpus + 1, MAX_AUTO_THREADS);
         else
             thread_count = avctx->thread_count = 1;
     }
diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c
index 7d23a11102b..759ff1ce33e 100644
--- a/libavcodec/qcelpdec.c
+++ b/libavcodec/qcelpdec.c
@@ -146,13 +146,13 @@ static int decode_lspf(QCELPContext *q, float *lspf)
         }
 
         // Check the stability of the LSP frequencies.
-        lspf[0] = FFMAX(lspf[0], QCELP_LSP_SPREAD_FACTOR);
+        lspf[0] = FFMAXD(lspf[0], QCELP_LSP_SPREAD_FACTOR);
         for (i = 1; i < 10; i++)
-            lspf[i] = FFMAX(lspf[i], lspf[i - 1] + QCELP_LSP_SPREAD_FACTOR);
+            lspf[i] = FFMAXD(lspf[i], lspf[i - 1] + QCELP_LSP_SPREAD_FACTOR);
 
-        lspf[9] = FFMIN(lspf[9], 1.0 - QCELP_LSP_SPREAD_FACTOR);
+        lspf[9] = FFMIND(lspf[9], 1.0 - QCELP_LSP_SPREAD_FACTOR);
         for (i = 9; i > 0; i--)
-            lspf[i - 1] = FFMIN(lspf[i - 1], lspf[i] - QCELP_LSP_SPREAD_FACTOR);
+            lspf[i - 1] = FFMIND(lspf[i - 1], lspf[i] - QCELP_LSP_SPREAD_FACTOR);
 
         // Low-pass filter the LSP frequencies.
         ff_weighted_vector_sumf(lspf, lspf, q->prev_lspf, smooth, 1.0 - smooth, 10);
@@ -491,7 +491,7 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
                 max_pitch_gain = 1.0;
             }
             for (i = 0; i < 4; i++)
-                q->pitch_gain[i] = FFMIN(q->pitch_gain[i], max_pitch_gain);
+                q->pitch_gain[i] = FFMINF(q->pitch_gain[i], max_pitch_gain);
 
             memset(q->frame.pfrac, 0, sizeof(q->frame.pfrac));
         }
@@ -503,7 +503,7 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
 
         // pitch prefilter update
         for (i = 0; i < 4; i++)
-            q->pitch_gain[i] = 0.5 * FFMIN(q->pitch_gain[i], 1.0);
+            q->pitch_gain[i] = 0.5 * FFMIND(q->pitch_gain[i], 1.0);
 
         v_pre_filtered       = do_pitchfilter(q->pitch_pre_filter_mem,
                                               v_synthesis_filtered,
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
index 474e5ef8faa..bc07715e1e0 100644
--- a/libavcodec/qdmc.c
+++ b/libavcodec/qdmc.c
@@ -284,7 +284,7 @@ static av_cold int qdmc_decode_init(AVCodecContext *avctx)
 
     if (avctx->ch_layout.nb_channels == 2)
         x = 3 * x / 2;
-    s->band_index = noise_bands_selector[FFMIN(6, llrint(floor(avctx->bit_rate * 3.0 / (double)x + 0.5)))];
+    s->band_index = noise_bands_selector[FFMINI(6, llrint(floor(avctx->bit_rate * 3.0 / (double)x + 0.5)))];
 
     if ((fft_order < 7) || (fft_order > 9)) {
         avpriv_request_sample(avctx, "Unknown FFT order %d", fft_order);
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index 08bff5c81bf..f718d3a5b25 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -81,7 +81,7 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst,
 
             p = bytestream2_get_byte(&qctx->buffer);
             for(i = 0; i < run; i++) {
-                int step = FFMIN(run - i, width - filled);
+                int step = FFMINI(run - i, width - filled);
                 memset(dst+filled, p, step);
                 filled += step;
                 i      += step - 1;
@@ -103,7 +103,7 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst,
             if (bytestream2_get_bytes_left(&qctx->buffer) < copy)
                 copy = bytestream2_get_bytes_left(&qctx->buffer);
             while (copy > 0) {
-                int step = FFMIN(copy, width - filled);
+                int step = FFMINI(copy, width - filled);
                 bytestream2_get_bufferu(&qctx->buffer, dst + filled, step);
                 filled += step;
                 copy -= step;
@@ -321,7 +321,7 @@ static void decode_flush(AVCodecContext *avctx){
 
     av_frame_unref(a->ref);
 
-    pal_size = FFMIN(1024U, avctx->extradata_size);
+    pal_size = FFMINI(1024U, avctx->extradata_size);
     pal_src = avctx->extradata + avctx->extradata_size - pal_size;
 
     for (i=0; i<pal_size/4; i++)
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f0b572ec299..8f5019bdc21 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -812,15 +812,15 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
 
     q->param.mfx.CodecProfile       = q->profile;
     q->param.mfx.TargetUsage        = avctx->compression_level;
-    q->param.mfx.GopPicSize         = FFMAX(0, avctx->gop_size);
+    q->param.mfx.GopPicSize         = FFMAXI(0, avctx->gop_size);
     q->old_gop_size                 = avctx->gop_size;
-    q->param.mfx.GopRefDist         = FFMAX(-1, avctx->max_b_frames) + 1;
+    q->param.mfx.GopRefDist         = FFMAXI(-1, avctx->max_b_frames) + 1;
     q->param.mfx.GopOptFlag         = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ?
                                       MFX_GOP_CLOSED : is_strict_gop(q) ?
                                       MFX_GOP_STRICT : 0;
     q->param.mfx.IdrInterval        = q->idr_interval;
     q->param.mfx.NumSlice           = avctx->slices;
-    q->param.mfx.NumRefFrame        = FFMAX(0, avctx->refs);
+    q->param.mfx.NumRefFrame        = FFMAXI(0, avctx->refs);
     q->param.mfx.EncodedOrder       = 0;
     q->param.mfx.BufferSizeInKB     = 0;
 
@@ -893,7 +893,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     initial_delay_in_kilobytes = avctx->rc_initial_buffer_occupancy / 8000;
     target_bitrate_kbps        = avctx->bit_rate / 1000;
     max_bitrate_kbps           = avctx->rc_max_rate / 1000;
-    brc_param_multiplier       = (FFMAX(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
+    brc_param_multiplier       = (FFMAXI(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
                                   initial_delay_in_kilobytes) + 0x10000) / 0x10000;
     q->old_rc_buffer_size = avctx->rc_buffer_size;
     q->old_rc_initial_buffer_occupancy = avctx->rc_initial_buffer_occupancy;
@@ -2245,7 +2245,7 @@ static int update_max_frame_size(AVCodecContext *avctx, QSVEncContext *q)
     if (!updated)
         return 0;
 
-    q->extco2.MaxFrameSize  = FFMAX(0, q->max_frame_size);
+    q->extco2.MaxFrameSize  = FFMAXI(0, q->max_frame_size);
     av_log(avctx, AV_LOG_DEBUG,
            "Reset MaxFrameSize: %d;\n", q->extco2.MaxFrameSize);
 
@@ -2259,7 +2259,7 @@ static int update_gop_size(AVCodecContext *avctx, QSVEncContext *q)
     if (!updated)
         return 0;
 
-    q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size);
+    q->param.mfx.GopPicSize = FFMAXI(0, avctx->gop_size);
     av_log(avctx, AV_LOG_DEBUG, "reset GopPicSize to %d\n",
            q->param.mfx.GopPicSize);
 
@@ -2280,11 +2280,11 @@ static int update_rir(AVCodecContext *avctx, QSVEncContext *q)
     if (!updated)
         return 0;
 
-    q->extco2.IntRefType      = FFMAX(0, q->int_ref_type);
-    q->extco2.IntRefCycleSize = FFMAX(0, q->int_ref_cycle_size);
+    q->extco2.IntRefType      = FFMAXI(0, q->int_ref_type);
+    q->extco2.IntRefCycleSize = FFMAXI(0, q->int_ref_cycle_size);
     q->extco2.IntRefQPDelta   =
         q->int_ref_qp_delta != INT16_MIN ? q->int_ref_qp_delta : 0;
-    q->extco3.IntRefCycleDist = FFMAX(0, q->int_ref_cycle_dist);
+    q->extco3.IntRefCycleDist = FFMAXI(0, q->int_ref_cycle_dist);
     av_log(avctx, AV_LOG_DEBUG,
            "Reset IntRefType: %d; IntRefCycleSize: %d; "
            "IntRefQPDelta: %d; IntRefCycleDist: %d\n",
@@ -2422,7 +2422,7 @@ static int update_bitrate(AVCodecContext *avctx, QSVEncContext *q)
     initial_delay_in_kilobytes = avctx->rc_initial_buffer_occupancy / 8000;
     target_bitrate_kbps        = avctx->bit_rate / 1000;
     max_bitrate_kbps           = avctx->rc_max_rate / 1000;
-    brc_param_multiplier       = (FFMAX(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
+    brc_param_multiplier       = (FFMAXI(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes),
                                     initial_delay_in_kilobytes) + 0x10000) / 0x10000;
 
     q->param.mfx.BufferSizeInKB = buffer_size_in_kilobytes / brc_param_multiplier;
diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index ae341c60b6d..8ab599a1a79 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -186,7 +186,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, ui
 
         /* If our lowest bulk cost index is too far away, replace it
          * with the next lowest bulk cost */
-        if (FFMIN(width, i + MAX_RLE_BULK) < lowest_bulk_cost_index) {
+        if (FFMINI(width, i + MAX_RLE_BULK) < lowest_bulk_cost_index) {
             lowest_bulk_cost = sec_lowest_bulk_cost;
             lowest_bulk_cost_index = sec_lowest_bulk_cost_index;
 
@@ -224,7 +224,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, ui
         }
 
         if (!s->key_frame && !memcmp(this_line, prev_line, s->pixel_size))
-            skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP);
+            skipcount = FFMINI(skipcount + 1, MAX_RLE_SKIP);
         else
             skipcount = 0;
 
@@ -233,7 +233,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, ui
 
 
         if (i < width - 1 && !memcmp(this_line, this_line + s->pixel_size, s->pixel_size))
-            repeatcount = FFMIN(repeatcount + 1, MAX_RLE_REPEAT);
+            repeatcount = FFMINI(repeatcount + 1, MAX_RLE_REPEAT);
         else
             repeatcount = 1;
 
diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c
index 65a744876cf..89c151a7e9f 100644
--- a/libavcodec/ra144.c
+++ b/libavcodec/ra144.c
@@ -1531,7 +1531,7 @@ void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
 {
     source += BUFFERSIZE - offset;
 
-    memcpy(target, source, FFMIN(BLOCKSIZE, offset)*sizeof(*target));
+    memcpy(target, source, FFMINI(BLOCKSIZE, offset)*sizeof(*target));
     if (offset < BLOCKSIZE)
         memcpy(target + offset, source, (BLOCKSIZE - offset)*sizeof(*target));
 }
diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c
index d38c39ce14e..5743aee4fd1 100644
--- a/libavcodec/ra144enc.c
+++ b/libavcodec/ra144enc.c
@@ -171,7 +171,7 @@ static void create_adapt_vect(float *vect, const int16_t *cb, int lag)
     int i;
 
     cb += BUFFERSIZE - lag;
-    for (i = 0; i < FFMIN(BLOCKSIZE, lag); i++)
+    for (i = 0; i < FFMINI(BLOCKSIZE, lag); i++)
         vect[i] = cb[i];
     if (lag < BLOCKSIZE)
         for (i = 0; i < BLOCKSIZE - lag; i++)
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index aa499506b7d..1a89564a418 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -121,7 +121,7 @@ static void decode(RA288Context *ractx, float gain, int cb_coef)
 
     sum = ff_scalarproduct_float_c(buffer, buffer, 5);
 
-    sum = FFMAX(sum, 5.0 / (1<<24));
+    sum = FFMAXD(sum, 5.0 / (1<<24));
 
     /* shift and store */
     memmove(gain_block, gain_block + 1, 9 * sizeof(*gain_block));
diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index 036c3a931cb..9484c8e86c7 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -87,7 +87,7 @@ static av_cold int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
     for (i = 0; i < elems; i++) {
         cur_len  = (nb ? *data & 0xF : *data >> 4) + 1;
         counts[cur_len]++;
-        max_bits = FFMAX(max_bits, cur_len);
+        max_bits = FFMAXI(max_bits, cur_len);
         lens[i]  = cur_len;
         data    += nb;
         nb      ^= 1;
@@ -99,7 +99,7 @@ static av_cold int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
     for (i = 0; i < elems; i++)
         codes[i] = prefixes[lens[i]]++;
 
-    return ff_vlc_init_sparse(vlc, FFMIN(max_bits, 9), elems,
+    return ff_vlc_init_sparse(vlc, FFMINI(max_bits, 9), elems,
                               lens, 1, 1, codes, 2, 2, NULL, 0, 0, 0);
 }
 
@@ -158,7 +158,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_ERROR, "invalid frame size %d\n",
                ctx->max_frame_size);
     }
-    ctx->max_frame_size = FFMAX(ctx->max_frame_size, avctx->sample_rate);
+    ctx->max_frame_size = FFMAXI(ctx->max_frame_size, avctx->sample_rate);
 
     for (i = 0; i < 3; i++) {
         ret = init_ralf_vlc(&ctx->sets[i].filter_params, filter_param_def[i],
@@ -309,17 +309,17 @@ static void apply_lpc(RALFContext *ctx, int ch, int length, int bits)
     int max_clip = (1 << bits) - 1, min_clip = -max_clip - 1;
 
     for (i = 1; i < length; i++) {
-        int flen = FFMIN(ctx->filter_length, i);
+        int flen = FFMINI(ctx->filter_length, i);
 
         acc = 0;
         for (j = 0; j < flen; j++)
             acc += (unsigned)ctx->filter[j] * audio[i - j - 1];
         if (acc < 0) {
             acc = (acc + bias - 1) >> ctx->filter_bits;
-            acc = FFMAX(acc, min_clip);
+            acc = FFMAXI(acc, min_clip);
         } else {
             acc = ((unsigned)acc + bias) >> ctx->filter_bits;
-            acc = FFMIN(acc, max_clip);
+            acc = FFMINI(acc, max_clip);
         }
         audio[i] += acc;
     }
diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
index a8e00a41a6f..79146ac831a 100644
--- a/libavcodec/rasc.c
+++ b/libavcodec/rasc.c
@@ -190,7 +190,7 @@ static int decode_zlib(AVCodecContext *avctx, const AVPacket *avpkt,
         return AVERROR(ENOMEM);
 
     zstream->next_in  = avpkt->data + bytestream2_tell(gb);
-    zstream->avail_in = FFMIN(size, bytestream2_get_bytes_left(gb));
+    zstream->avail_in = FFMINI(size, bytestream2_get_bytes_left(gb));
 
     zstream->next_out  = s->delta;
     zstream->avail_out = s->delta_size;
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 3dc44683d01..acf369248d2 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -199,7 +199,7 @@ static double modify_qscale(MPVMainEncContext *const m, const RateControlEntry *
             q *= pow(d, 1.0 / rcc->buffer_aggressivity);
 
             q_limit = bits2qp(rce,
-                              FFMAX((min_rate - buffer_size + rcc->buffer_index) *
+                              FFMAXD((min_rate - buffer_size + rcc->buffer_index) *
                                     s->c.avctx->rc_min_vbv_overflow_use, 1));
 
             if (q > q_limit) {
@@ -219,7 +219,7 @@ static double modify_qscale(MPVMainEncContext *const m, const RateControlEntry *
             q /= pow(d, 1.0 / rcc->buffer_aggressivity);
 
             q_limit = bits2qp(rce,
-                              FFMAX(rcc->buffer_index *
+                              FFMAXD(rcc->buffer_index *
                                     s->c.avctx->rc_max_available_vbv_use,
                                     1));
             if (q < q_limit) {
@@ -399,7 +399,7 @@ static int init_pass2(MPVMainEncContext *const m)
         av_assert0(filter_size % 2 == 1);
 
         /* fixed I/B QP relative to P mode */
-        for (i = FFMAX(0, rcc->num_entries - 300); i < rcc->num_entries; i++) {
+        for (i = FFMAXI(0, rcc->num_entries - 300); i < rcc->num_entries; i++) {
             const RateControlEntry *rce = &rcc->entry[i];
 
             qscale[i] = get_diff_limited_q(m, rce, qscale[i]);
@@ -837,11 +837,11 @@ static void adaptive_quantization(RateControlContext *const rcc,
         }
         if (mb_y < mb_height / 5) {
             mb_distance = mb_height / 5 - mb_y;
-            mb_factor   = FFMAX(mb_factor,
+            mb_factor   = FFMAXF(mb_factor,
                                 (float)mb_distance / (float)(mb_height / 5));
         } else if (mb_y > 4 * mb_height / 5) {
             mb_distance = mb_y - 4 * mb_height / 5;
-            mb_factor   = FFMAX(mb_factor,
+            mb_factor   = FFMAXF(mb_factor,
                                 (float)mb_distance / (float)(mb_height / 5));
         }
 
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 53d1fba5839..f2865473ff3 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -239,7 +239,7 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
         return res;
 
     if (need_copy)
-        frame->buf[0] = av_buffer_alloc(FFMAX(context->frame_size, buf_size));
+        frame->buf[0] = av_buffer_alloc(FFMAXI(context->frame_size, buf_size));
     else
         frame->buf[0] = av_buffer_ref(avpkt->buf);
     if (!frame->buf[0])
diff --git a/libavcodec/rectangle.h b/libavcodec/rectangle.h
index df7c18a4e2f..9c56d49e407 100644
--- a/libavcodec/rectangle.h
+++ b/libavcodec/rectangle.h
@@ -46,7 +46,7 @@ static av_always_inline void fill_rectangle(void *vp, int w, int h, int stride,
     w      *= size;
     stride *= size;
 
-    av_assert2((((long)vp)&(FFMIN(w, 8<<(HAVE_NEON|ARCH_PPC|HAVE_MMX))-1)) == 0);
+    av_assert2((((long)vp)&(FFMINI(w, 8<<(HAVE_NEON|ARCH_PPC|HAVE_MMX))-1)) == 0);
     av_assert2((stride&(w-1))==0);
     if(w==2){
         const uint16_t v= size==4 ? val : val*0x0101;
diff --git a/libavcodec/rka.c b/libavcodec/rka.c
index 600c1600287..86f071d85d2 100644
--- a/libavcodec/rka.c
+++ b/libavcodec/rka.c
@@ -186,7 +186,7 @@ static void model64_init(Model64 *m, unsigned bits)
     m->zero[0] = 1;
 
     x = (1 << (bits >> 1)) + 3;
-    x = FFMIN(x, 20);
+    x = FFMINI(x, 20);
 
     m->zero[1] = x;
     m->sign[0] = 1;
@@ -412,7 +412,7 @@ static int amdl_decode_int(AdaptiveModel *am, ACoder *ac, unsigned *dst, unsigne
     unsigned freq, size2, val, mul;
     int j;
 
-    size = FFMIN(size, am->buf_size - 1);
+    size = FFMINI(size, am->buf_size - 1);
 
     if (am->aprob0 >= am->sum)
         update_ch_subobj(am);
@@ -705,7 +705,7 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns
         idx = (ctx->pos_idx + idx) % 11;
         ctx->pos_idx = idx;
 
-        rsize = FFMIN(split, size - x);
+        rsize = FFMINI(split, size - x);
         for (int y = 0; y < rsize; y++, off++) {
             int midx, shift = idx, *src, sum = 16;
 
@@ -758,7 +758,7 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns
             for (unsigned i = (m << 6) / rsize; i > 0; i = i >> 1)
                 sum++;
             sum -= (ctx->vrq + 7);
-            ctx->qfactor = FFMAX(sum, vrq_qfactors[ctx->vrq - 1]);
+            ctx->qfactor = FFMAXI(sum, vrq_qfactors[ctx->vrq - 1]);
         }
 
         x += split;
diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c
index e427a27dce3..7c9a1bfea0b 100644
--- a/libavcodec/rl2.c
+++ b/libavcodec/rl2.c
@@ -97,7 +97,7 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size,
         if (back_frame) {
             if (!val) {
                 do {
-                    size_t copy = FFMIN(line_end - out, len);
+                    size_t copy = FFMINI(line_end - out, len);
                     memcpy(out, back_frame, copy);
                     out        += copy;
                     back_frame += copy;
diff --git a/libavcodec/rle.c b/libavcodec/rle.c
index cebd2382640..6224c5ea2ba 100644
--- a/libavcodec/rle.c
+++ b/libavcodec/rle.c
@@ -30,13 +30,13 @@ int ff_rle_count_pixels(const uint8_t *start, int len, int bpp, int same)
     const uint8_t *pos;
     int count = 1;
 
-    for (pos = start + bpp; count < FFMIN(127, len); pos += bpp, count++) {
+    for (pos = start + bpp; count < FFMINI(127, len); pos += bpp, count++) {
         if (same != !memcmp(pos - bpp, pos, bpp)) {
             if (!same) {
                 /* if bpp == 1, then 0 1 1 0 is more efficiently encoded as a
                  * single raw block of pixels. For larger bpp, RLE is as good
                  * or better */
-                if (bpp == 1 && count + 1 < FFMIN(127, len) && *pos != *(pos + 1))
+                if (bpp == 1 && count + 1 < FFMINI(127, len) && *pos != *(pos + 1))
                     continue;
 
                 /* if RLE can encode the next block better than as a raw block,
diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c
index 8a626c0d29f..f6ab07c48fd 100644
--- a/libavcodec/roqaudioenc.c
+++ b/libavcodec/roqaudioenc.c
@@ -182,7 +182,7 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 
     context->input_frames++;
     if (!in)
-        context->input_frames = FFMAX(context->input_frames, 8);
+        context->input_frames = FFMAXI(context->input_frames, 8);
 
     *got_packet_ptr = 1;
     return 0;
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 03a1651c7f5..70b19a02ca9 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -150,7 +150,7 @@ typedef struct RoqEncContext {
     uint8_t *out_buf;
     RoqTempData tmp_data;
     roq_cell results4[4 * MAX_CBS_4x4];
-    int tmp_codebook_buf[FFMAX(24 * MAX_CBS_4x4, 6 * MAX_CBS_2x2)];
+    int tmp_codebook_buf[FFMAXI(24 * MAX_CBS_4x4, 6 * MAX_CBS_2x2)];
 
     CelEvaluation *cel_evals;
     int *closest_cb;
diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
index cad2eaad731..a4919dd0c6d 100644
--- a/libavcodec/rpza.c
+++ b/libavcodec/rpza.c
@@ -131,7 +131,7 @@ static int rpza_decode_stream(RpzaContext *s)
             }
         }
 
-        n_blocks = FFMIN(n_blocks, total_blocks);
+        n_blocks = FFMINI(n_blocks, total_blocks);
 
         switch (opcode & 0xe0) {
 
diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c
index b43c213ec8a..0260d2d68b7 100644
--- a/libavcodec/rpzaenc.c
+++ b/libavcodec/rpzaenc.c
@@ -209,13 +209,13 @@ static void get_max_component_diff(const BlockInfo *bi, const uint16_t *block_pt
     for (y = 0; y < bi->block_height; y++) {
         for (x = 0; x < bi->block_width; x++) {
             // TODO:  optimize
-            min_r = FFMIN(R(block_ptr[x]), min_r);
-            min_g = FFMIN(G(block_ptr[x]), min_g);
-            min_b = FFMIN(B(block_ptr[x]), min_b);
+            min_r = FFMINI(R(block_ptr[x]), min_r);
+            min_g = FFMINI(G(block_ptr[x]), min_g);
+            min_b = FFMINI(B(block_ptr[x]), min_b);
 
-            max_r = FFMAX(R(block_ptr[x]), max_r);
-            max_g = FFMAX(G(block_ptr[x]), max_g);
-            max_b = FFMAX(B(block_ptr[x]), max_b);
+            max_r = FFMAXI(R(block_ptr[x]), max_r);
+            max_g = FFMAXI(G(block_ptr[x]), max_g);
+            max_b = FFMAXI(B(block_ptr[x]), max_b);
         }
         block_ptr += bi->rowstride;
     }
@@ -334,7 +334,7 @@ static int calc_lsq_max_fit_error(const uint16_t *block_ptr, const BlockInfo *bi
 
             /* calculate x_inc as the 4-color index (0..3) */
             x_inc = (x - min) * 3 / (max - min) + 1;
-            x_inc = FFMAX(FFMIN(3, x_inc), 0);
+            x_inc = FFMAXI(FFMINI(3, x_inc), 0);
 
             /* calculate lin_y corresponding to x_inc */
             lin_y = tmp_min + (tmp_max - tmp_min) * x_inc / 3 + 1;
@@ -389,8 +389,8 @@ static int match_color(const uint16_t *color, uint8_t colors[4][3])
 static int encode_four_color_block(const uint8_t *min_color, const uint8_t *max_color,
                                    PutBitContext *pb, const uint16_t *block_ptr, const BlockInfo *bi)
 {
-    const int y_size = FFMIN(4, bi->image_height - bi->row * 4);
-    const int x_size = FFMIN(4, bi->image_width  - bi->col * 4);
+    const int y_size = FFMINI(4, bi->image_height - bi->row * 4);
+    const int x_size = FFMINI(4, bi->image_width  - bi->col * 4);
     uint8_t color4[4][3];
     uint16_t rounded_max, rounded_min;
     int idx;
@@ -432,8 +432,8 @@ static void update_block_in_prev_frame(const uint16_t *src_pixels,
                                        uint16_t *dest_pixels,
                                        const BlockInfo *bi, int block_counter)
 {
-    const int y_size = FFMIN(4, bi->image_height - bi->row * 4);
-    const int x_size = FFMIN(4, bi->image_width  - bi->col * 4) * 2;
+    const int y_size = FFMINI(4, bi->image_height - bi->row * 4);
+    const int x_size = FFMINI(4, bi->image_width  - bi->col * 4) * 2;
 
     for (int y = 0; y < y_size; y++) {
         memcpy(dest_pixels, src_pixels, x_size);
@@ -511,13 +511,13 @@ static int update_block_stats(RpzaContext *s, const BlockInfo *bi, const uint16_
             total_rgb_blk[1] += G(block[x]);
             total_rgb_blk[2] += B(block[x]);
 
-            min_color_blk[0] = FFMIN(R(block[x]), min_color_blk[0]);
-            min_color_blk[1] = FFMIN(G(block[x]), min_color_blk[1]);
-            min_color_blk[2] = FFMIN(B(block[x]), min_color_blk[2]);
+            min_color_blk[0] = FFMINI(R(block[x]), min_color_blk[0]);
+            min_color_blk[1] = FFMINI(G(block[x]), min_color_blk[1]);
+            min_color_blk[2] = FFMINI(B(block[x]), min_color_blk[2]);
 
-            max_color_blk[0] = FFMAX(R(block[x]), max_color_blk[0]);
-            max_color_blk[1] = FFMAX(G(block[x]), max_color_blk[1]);
-            max_color_blk[2] = FFMAX(B(block[x]), max_color_blk[2]);
+            max_color_blk[0] = FFMAXI(R(block[x]), max_color_blk[0]);
+            max_color_blk[1] = FFMAXI(G(block[x]), max_color_blk[1]);
+            max_color_blk[2] = FFMAXI(B(block[x]), max_color_blk[2]);
         }
         block += bi->rowstride;
     }
@@ -739,7 +739,7 @@ post_skip :
                     tmp_min = av_clip_uint8(tmp_min);
                     tmp_max = av_clip_uint8(tmp_max);
 
-                    err = FFMAX(calc_lsq_max_fit_error(&src_pixels[block_offset], &bi,
+                    err = FFMAXI(calc_lsq_max_fit_error(&src_pixels[block_offset], &bi,
                                                        min, max, tmp_min, tmp_max, chan, i), err);
 
                     min_color[i] = tmp_min;
@@ -755,8 +755,8 @@ post_skip :
                 pblock_offset = get_block_info(&bi, block_counter, 1);
 
                 row_ptr = &src_pixels[block_offset];
-                y_size = FFMIN(4, bi.image_height - bi.row * 4);
-                x_size = FFMIN(4, bi.image_width  - bi.col * 4);
+                y_size = FFMINI(4, bi.image_height - bi.row * 4);
+                x_size = FFMINI(4, bi.image_width  - bi.col * 4);
 
                 for (int y = 0; y < y_size; y++) {
                     for (int x = 0; x < x_size; x++) {
@@ -807,7 +807,7 @@ static int rpza_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 {
     RpzaContext *s = avctx->priv_data;
     uint8_t *buf;
-    int ret = ff_alloc_packet(avctx, pkt, 4LL + 6LL * FFMAX(avctx->height, 4) * FFMAX(avctx->width, 4));
+    int ret = ff_alloc_packet(avctx, pkt, 4LL + 6LL * FFMAXI(avctx->height, 4) * FFMAXI(avctx->width, 4));
 
     if (ret < 0)
         return ret;
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 482af8e52aa..a7cc0569c5d 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -411,7 +411,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
     int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret;
 
     active_bits_size = buf_size * 8;
-    init_get_bits(&s->gb, buf, FFMAX(buf_size, buf_size2) * 8);
+    init_get_bits(&s->gb, buf, FFMAXI(buf_size, buf_size2) * 8);
     if (s->codec_id == AV_CODEC_ID_RV10)
         mb_count = rv10_decode_picture_header(s);
     else
@@ -595,7 +595,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, AVFrame *pict,
             size2 = get_slice_offset(avctx, slices_hdr, i + 2) - offset;
 
         if (size <= 0 || size2 <= 0 ||
-            offset + FFMAX(size, size2) > buf_size)
+            offset + FFMAXI(size, size2) > buf_size)
             return AVERROR_INVALIDDATA;
 
         if ((ret = rv10_decode_packet(avctx, buf + offset, size, size2, buf_size)) < 0)
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 5dcbe9a222f..4af39ed3b2d 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -116,7 +116,7 @@ static av_cold void rv34_gen_vlc_ext(const uint8_t *bits, int size, VLC *vlc,
 
     vlc->table           = &table_data[*offset];
     vlc->table_allocated = FF_ARRAY_ELEMS(table_data) - *offset;
-    ff_vlc_init_sparse(vlc, FFMIN(maxbits, 9), size,
+    ff_vlc_init_sparse(vlc, FFMINI(maxbits, 9), size,
                        bits, 1, 1,
                        cw,    2, 2,
                        syms, !!syms, !!syms, VLC_INIT_STATIC_OVERLONG);
@@ -901,7 +901,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type)
         //surprisingly, it uses motion scheme from next reference frame
         /* wait for the current mb row to be finished */
         if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
-            ff_thread_progress_await(&s->next_pic.ptr->progress, FFMAX(0, s->mb_y-1));
+            ff_thread_progress_await(&s->next_pic.ptr->progress, FFMAXI(0, s->mb_y-1));
 
         next_bt = s->next_pic.mb_type[s->mb_x + s->mb_y * s->mb_stride];
         if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){
@@ -1732,7 +1732,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict,
                 r->mv_weight1 = r->mv_weight2 = r->weight1 = r->weight2 = 8192;
                 r->scaled_weight = 0;
             }else{
-                if (FFMAX(dist0, dist1) > refdist)
+                if (FFMAXI(dist0, dist1) > refdist)
                     av_log(avctx, AV_LOG_TRACE, "distance overflow\n");
 
                 r->mv_weight1 = (dist0 << 14) / refdist;
diff --git a/libavcodec/rv60dec.c b/libavcodec/rv60dec.c
index 2bbcb1d6209..fbb1c6f0d83 100644
--- a/libavcodec/rv60dec.c
+++ b/libavcodec/rv60dec.c
@@ -2351,7 +2351,7 @@ static int rv60_decode_frame(AVCodecContext *avctx, AVFrame * frame,
         if (header_size + ofs >= avpkt->size)
             return AVERROR_INVALIDDATA;
         s->slice[i].data = avpkt->data + header_size + ofs;
-        s->slice[i].data_size = FFMIN(s->slice[i].size, avpkt->size - header_size - ofs);
+        s->slice[i].data_size = FFMINI(s->slice[i].size, avpkt->size - header_size - ofs);
         ofs += s->slice[i].size;
     }
 
diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 00bfef00fe8..c61b247d71b 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -403,7 +403,7 @@ static void make_glyphs(int8_t *pglyphs, const int8_t *xvec, const int8_t *yvec,
             int y1 = yvec[j];
             enum GlyphEdge edge1 = which_edge(x1, y1, side_length);
             enum GlyphDir dir = which_direction(edge0, edge1);
-            int npoints = FFMAX(FFABS(x1 - x0), FFABS(y1 - y0));
+            int npoints = FFMAXI(FFABS(x1 - x0), FFABS(y1 - y0));
             int ipoint;
 
             for (ipoint = 0; ipoint <= npoints; ipoint++) {
@@ -1659,8 +1659,8 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb)
                 ctx->have_dimensions = 1;
             }
 
-            xres = FFMAX(xres, ctx->width);
-            yres = FFMAX(yres, ctx->height);
+            xres = FFMAXI(xres, ctx->width);
+            yres = FFMAXI(yres, ctx->height);
         }
 
         if (ctx->width < xres || ctx->height < yres) {
@@ -1733,8 +1733,8 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb)
     } else {
         uint8_t *dst = (uint8_t *)ctx->fbuf + left + top * ctx->pitch;
         const uint8_t *src = (uint8_t *)ctx->frm0;
-        const int cw = FFMIN(w, ctx->width - left);
-        const int ch = FFMIN(h, ctx->height - top);
+        const int cw = FFMINI(w, ctx->width - left);
+        const int ch = FFMINI(h, ctx->height - top);
         if ((cw > 0) && (ch > 0) && (left >= 0) && (top >= 0)) {
             for (int i = 0; i < ch; i++) {
                 memcpy(dst, src, cw);
diff --git a/libavcodec/sbc_parser.c b/libavcodec/sbc_parser.c
index 2d427cc7cb8..37ee1097f81 100644
--- a/libavcodec/sbc_parser.c
+++ b/libavcodec/sbc_parser.c
@@ -98,7 +98,7 @@ static int sbc_parse(AVCodecParserContext *s, AVCodecContext *avctx,
         }
 
         if (next < 0) {
-            pc->header_size = FFMIN(sizeof(pc->header), buf_size);
+            pc->header_size = FFMINI(sizeof(pc->header), buf_size);
             memcpy(pc->header, buf, pc->header_size);
             pc->buffered_size = buf_size;
             next = END_NOT_FOUND;
diff --git a/libavcodec/sgirledec.c b/libavcodec/sgirledec.c
index 3bd31b73470..95c913696b2 100644
--- a/libavcodec/sgirledec.c
+++ b/libavcodec/sgirledec.c
@@ -83,7 +83,7 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst,
         uint8_t v = *src++;
         if (v > 0 && v < 0xC0) {
             do {
-                int length = FFMIN(v, width - x);
+                int length = FFMINI(v, width - x);
                 if (length <= 0)
                     break;
                 memset(dst + y * linesize + x, RBG323_TO_BGR8(*src), length);
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index ad2e7588d69..844bf7e0915 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -131,7 +131,7 @@ static int allocate_buffers(ShortenContext *s)
     int i, chan, err;
 
     for (chan = 0; chan < s->channels; chan++) {
-        if (FFMAX(1, s->nmean) >= UINT_MAX / sizeof(int32_t)) {
+        if (FFMAXI(1, s->nmean) >= UINT_MAX / sizeof(int32_t)) {
             av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n");
             return AVERROR_INVALIDDATA;
         }
@@ -143,7 +143,7 @@ static int allocate_buffers(ShortenContext *s)
 
         if ((err = av_reallocp_array(&s->offset[chan],
                                sizeof(int32_t),
-                               FFMAX(1, s->nmean))) < 0)
+                               FFMAXI(1, s->nmean))) < 0)
             return err;
 
         if ((err = av_reallocp_array(&s->decoded_base[chan], (s->blocksize + s->nwrap),
@@ -187,7 +187,7 @@ static int init_offset(ShortenContext *s)
 {
     int32_t mean = 0;
     int chan, i;
-    int nblock = FFMAX(1, s->nmean);
+    int nblock = FFMAXI(1, s->nmean);
     /* initialise offset */
     switch (s->internal_ftype) {
     case TYPE_U8:
@@ -462,7 +462,7 @@ static int read_header(ShortenContext *s)
         }
 
         skip_bytes = get_uint(s, NSKIPSIZE);
-        if ((unsigned)skip_bytes > FFMAX(get_bits_left(&s->gb), 0)/8) {
+        if ((unsigned)skip_bytes > FFMAXI(get_bits_left(&s->gb), 0)/8) {
             av_log(s->avctx, AV_LOG_ERROR, "invalid skip_bytes: %d\n", skip_bytes);
             return AVERROR_INVALIDDATA;
         }
@@ -470,7 +470,7 @@ static int read_header(ShortenContext *s)
         for (i = 0; i < skip_bytes; i++)
             skip_bits(&s->gb, 8);
     }
-    s->nwrap = FFMAX(NWRAP, maxnlpc);
+    s->nwrap = FFMAXI(NWRAP, maxnlpc);
 
     if (s->version > 1)
         s->lpcqoffset = V2LPCQOFFSET;
@@ -548,7 +548,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     }
 
     /* append current packet data to bitstream buffer */
-    buf_size       = FFMIN(buf_size, s->max_framesize - s->bitstream_size);
+    buf_size       = FFMINI(buf_size, s->max_framesize - s->bitstream_size);
     input_buf_size = buf_size;
 
     if (s->bitstream_index + s->bitstream_size + buf_size + AV_INPUT_BUFFER_PADDING_SIZE >
@@ -595,7 +595,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame,
             if (max_framesize > s->max_framesize)
                 memset(s->bitstream + s->max_framesize, 0, (max_framesize - s->max_framesize) +
                                                             AV_INPUT_BUFFER_PADDING_SIZE);
-            s->max_framesize = FFMAX(s->max_framesize, max_framesize);
+            s->max_framesize = FFMAXI(s->max_framesize, max_framesize);
             *got_frame_ptr = 0;
             goto finish_frame;
         }
diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c
index ebd7dab03c7..4dc9df49ea5 100644
--- a/libavcodec/sipr.c
+++ b/libavcodec/sipr.c
@@ -167,7 +167,7 @@ static void lsf_decode_fp(float *lsfnew, float *lsf_history,
     /* Note that a minimum distance is not enforced between the last value and
        the previous one, contrary to what is done in ff_acelp_reorder_lsf() */
     ff_set_min_dist_lsf(lsfnew, LSFQ_DIFF_MIN, LP_FILTER_ORDER - 1);
-    lsfnew[9] = FFMIN(lsfnew[LP_FILTER_ORDER - 1], 1.3 * M_PI);
+    lsfnew[9] = FFMIND(lsfnew[LP_FILTER_ORDER - 1], 1.3 * M_PI);
 
     memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER * sizeof(*lsf_history));
 
@@ -428,10 +428,10 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params,
                                 pitch_gain, gain_code, SUBFR_SIZE);
 
         pitch_gain *= 0.5 * pitch_gain;
-        pitch_gain = FFMIN(pitch_gain, 0.4);
+        pitch_gain = FFMIND(pitch_gain, 0.4);
 
         ctx->gain_mem = 0.7 * ctx->gain_mem + 0.3 * pitch_gain;
-        ctx->gain_mem = FFMIN(ctx->gain_mem, pitch_gain);
+        ctx->gain_mem = FFMINF(ctx->gain_mem, pitch_gain);
         gain_code *= ctx->gain_mem;
 
         for (j = 0; j < SUBFR_SIZE; j++)
diff --git a/libavcodec/sipr16k.c b/libavcodec/sipr16k.c
index ab892d0547e..68ee0360c31 100644
--- a/libavcodec/sipr16k.c
+++ b/libavcodec/sipr16k.c
@@ -218,7 +218,7 @@ void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params,
                                             ctx->pitch_lag_prev);
 
         pitch_fac = gain_pitch_cb_16k[params->gp_index[i]];
-        f.pitch_fac = FFMIN(pitch_fac, 1.0);
+        f.pitch_fac = FFMIND(pitch_fac, 1.0);
         f.pitch_lag = DIVIDE_BY_3(pitch_delay_3x+1);
         ctx->pitch_lag_prev = f.pitch_lag;
 
diff --git a/libavcodec/sipr_parser.c b/libavcodec/sipr_parser.c
index e01da3c8a86..cebffbab4b1 100644
--- a/libavcodec/sipr_parser.c
+++ b/libavcodec/sipr_parser.c
@@ -43,7 +43,7 @@ static int sipr_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
         else                              next = 37;
     }
 
-    return FFMIN(next, buf_size);
+    return FFMINI(next, buf_size);
 }
 
 static int sipr_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index db464dfcf7d..fdfe4ec81d8 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -38,7 +38,7 @@
 #define SMKTREE_BITS 9
 #define SMK_NODE 0x80000000
 
-#define SMKTREE_DECODE_MAX_RECURSION FFMIN(32, 3 * SMKTREE_BITS)
+#define SMKTREE_DECODE_MAX_RECURSION FFMINI(32, 3 * SMKTREE_BITS)
 #define SMKTREE_DECODE_BIG_MAX_RECURSION 500
 
 /* The maximum possible unchecked overread happens in decode_header_trees:
diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c
index dfa1c17d2d3..fd2c707579f 100644
--- a/libavcodec/smcenc.c
+++ b/libavcodec/smcenc.c
@@ -151,8 +151,8 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
         int frame_x = cur_x;
 
         while (prev_pixels && s->key_frame == 0 && block_counter + inter_skip_blocks < total_blocks) {
-            const int y_size = FFMIN(4, height - cur_y);
-            const int x_size = FFMIN(4, width  - cur_x);
+            const int y_size = FFMINI(4, height - cur_y);
+            const int x_size = FFMINI(4, width  - cur_x);
             int compare = 0;
 
             for (int y = 0; y < y_size; y++) {
@@ -179,13 +179,13 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
         cur_x = frame_x;
 
         while (block_counter > 0 && block_counter + intra_skip_blocks < total_blocks) {
-            const int y_size = FFMIN(4, height - cur_y);
-            const int x_size = FFMIN(4, width  - cur_x);
+            const int y_size = FFMINI(4, height - cur_y);
+            const int x_size = FFMINI(4, width  - cur_x);
             const ptrdiff_t offset = xpixel_ptr - src_pixels;
             const int sy = offset / stride;
             const int sx = offset % stride;
-            const int ny = sx < 4 ? FFMAX(sy - 4, 0) : sy;
-            const int nx = sx < 4 ? FFMAX(width - 4 + (width & 3), 0) : sx - 4;
+            const int ny = sx < 4 ? FFMAXI(sy - 4, 0) : sy;
+            const int nx = sx < 4 ? FFMAXI(width - 4 + (width & 3), 0) : sx - 4;
             const uint8_t *old_pixel_ptr = src_pixels + nx + ny * stride;
             int compare = 0;
 
@@ -211,8 +211,8 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
         cur_x = frame_x;
 
         while (block_counter + coded_blocks < total_blocks && coded_blocks < 256) {
-            const int y_size = FFMIN(4, height - cur_y);
-            const int x_size = FFMIN(4, width  - cur_x);
+            const int y_size = FFMINI(4, height - cur_y);
+            const int x_size = FFMINI(4, width  - cur_x);
             const int nb_elements = x_size * y_size;
             uint8_t block_values[16] = { 0 };
             for (int y = 0; y < y_size; y++)
@@ -314,8 +314,8 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
             }
 
             for (int i = 0; i < blocks; i++) {
-                const int y_size = FFMIN(4, height - cur_y);
-                const int x_size = FFMIN(4, width  - cur_x);
+                const int y_size = FFMINI(4, height - cur_y);
+                const int x_size = FFMINI(4, width  - cur_x);
                 uint8_t value = s->color_pairs[color_table_index][1];
                 uint16_t flags = 0;
                 int shift = 15;
@@ -365,8 +365,8 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
             }
 
             for (int i = 0; i < blocks; i++) {
-                const int y_size = FFMIN(4, height - cur_y);
-                const int x_size = FFMIN(4, width  - cur_x);
+                const int y_size = FFMINI(4, height - cur_y);
+                const int x_size = FFMINI(4, width  - cur_x);
                 uint32_t flags = 0;
                 uint8_t quad[4];
                 int shift = 30;
@@ -436,8 +436,8 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
             }
 
             for (int i = 0; i < blocks; i++) {
-                const int y_size = FFMIN(4, height - cur_y);
-                const int x_size = FFMIN(4, width  - cur_x);
+                const int y_size = FFMINI(4, height - cur_y);
+                const int x_size = FFMINI(4, width  - cur_x);
                 uint64_t flags = 0;
                 uint8_t octet[8];
                 int shift = 45;
@@ -474,8 +474,8 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
         default:
             bytestream2_put_byte(pb, 0xE0 | (blocks - 1));
             for (int i = 0; i < blocks; i++) {
-                const int y_size = FFMIN(4, height - cur_y);
-                const int x_size = FFMIN(4, width  - cur_x);
+                const int y_size = FFMINI(4, height - cur_y);
+                const int x_size = FFMINI(4, width  - cur_x);
                 for (int y = 0; y < y_size; y++) {
                     for (int x = 0; x < x_size; x++)
                         bytestream2_put_byte(pb, pixel_ptr[x + y * stride]);
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index e0ce83eb9c7..52194afbed7 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -332,8 +332,8 @@ void ff_snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, ptrdiff_t st
         sx += (mx>>4) - (HTAPS_MAX/2-1);
         sy += (my>>4) - (HTAPS_MAX/2-1);
         src += sx + sy*stride;
-        if(   (unsigned)sx >= FFMAX(w - b_w - (HTAPS_MAX-2), 0)
-           || (unsigned)sy >= FFMAX(h - b_h - (HTAPS_MAX-2), 0)){
+        if(   (unsigned)sx >= FFMAXI(w - b_w - (HTAPS_MAX-2), 0)
+           || (unsigned)sy >= FFMAXI(h - b_h - (HTAPS_MAX-2), 0)){
             s->vdsp.emulated_edge_mc(tmp + MB_SIZE, src,
                                      stride, stride,
                                      b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1,
@@ -453,8 +453,8 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
 
     if(!s->scratchbuf) {
         int emu_buf_size;
-        emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
-        if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf,      FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) ||
+        emu_buf_size = FFMAXI(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
+        if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf,      FFMAXI(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) ||
             !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size))
             return AVERROR(ENOMEM);
     }
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index 9b19e70bd5f..02987c11737 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -361,7 +361,7 @@ static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int pl
             return;
 
         if(add){
-            for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
+            for(y=block_h*mb_y; y<FFMINI(h,block_h*(mb_y+1)); y++){
                 for(x=0; x<w; x++){
                     int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
                     v >>= FRAC_BITS;
@@ -370,7 +370,7 @@ static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int pl
                 }
             }
         }else{
-            for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
+            for(y=block_h*mb_y; y<FFMINI(h,block_h*(mb_y+1)); y++){
                 for(x=0; x<w; x++){
                     buf[x + y*w]-= 128<<FRAC_BITS;
                 }
diff --git a/libavcodec/snow_dwt.c b/libavcodec/snow_dwt.c
index 0f2b86e2ccb..0dd993f78ac 100644
--- a/libavcodec/snow_dwt.c
+++ b/libavcodec/snow_dwt.c
@@ -667,7 +667,7 @@ void ff_spatial_idwt_buffered_slice(SnowDWTContext *dsp, DWTCompose *cs,
         return;
 
     for (level = decomposition_count - 1; level >= 0; level--)
-        while (cs[level].y <= FFMIN((y >> level) + support, height >> level)) {
+        while (cs[level].y <= FFMINI((y >> level) + support, height >> level)) {
             switch (type) {
             case DWT_97:
                 spatial_compose97i_dy_buffered(dsp, cs + level, slice_buf, temp,
@@ -715,7 +715,7 @@ static void spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer,
         return;
 
     for (level = decomposition_count - 1; level >= 0; level--)
-        while (cs[level].y <= FFMIN((y >> level) + support, height >> level)) {
+        while (cs[level].y <= FFMINI((y >> level) + support, height >> level)) {
             switch (type) {
             case DWT_97:
                 spatial_compose97i_dy(cs + level, buffer, temp, width >> level,
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index c16e824c73f..980b430717d 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -39,7 +39,7 @@ static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
         int e;
         unsigned a;
         e = 0;
-        while (get_rac(c, state + 1 + FFMIN(e, 9))) { //1..10
+        while (get_rac(c, state + 1 + FFMINI(e, 9))) { //1..10
             e++;
             if (e > 31)
                 return AVERROR_INVALIDDATA;
@@ -47,9 +47,9 @@ static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
 
         a = 1;
         for (int i = e - 1; i >= 0; i--)
-            a += a + get_rac(c, state + 22 + FFMIN(i, 9)); //22..31
+            a += a + get_rac(c, state + 22 + FFMINI(i, 9)); //22..31
 
-        e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); //11..21
+        e = -(is_signed && get_rac(c, state + 11 + FFMINI(e, 10))); //11..21
         return (a ^ e) - e;
     }
 }
@@ -148,10 +148,10 @@ static void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orie
                     run--;
                     v = 0;
                     av_assert2(run >= 0);
-                    if (y) max_run = FFMIN(run, prev_xc->x - x - 2);
-                    else   max_run = FFMIN(run, w-x-1);
+                    if (y) max_run = FFMINI(run, prev_xc->x - x - 2);
+                    else   max_run = FFMINI(run, w-x-1);
                     if (parent_xc)
-                        max_run = FFMIN(max_run, 2*parent_xc->x - x - 1);
+                        max_run = FFMINI(max_run, 2*parent_xc->x - x - 1);
                     av_assert2(max_run >= 0 && max_run <= run);
 
                     x   += max_run;
@@ -198,7 +198,7 @@ static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer
             return;
 
         if(add){
-            for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
+            for(y=block_h*mb_y; y<FFMINI(h,block_h*(mb_y+1)); y++){
 //                DWTELEM * line = slice_buffer_get_line(sb, y);
                 IDWTELEM * line = sb->line[y];
                 for(x=0; x<w; x++){
@@ -210,7 +210,7 @@ static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer
                 }
             }
         }else{
-            for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
+            for(y=block_h*mb_y; y<FFMINI(h,block_h*(mb_y+1)); y++){
 //                DWTELEM * line = slice_buffer_get_line(sb, y);
                 IDWTELEM * line = sb->line[y];
                 for(x=0; x<w; x++){
@@ -507,7 +507,7 @@ static int decode_header(SnowContext *s){
 
     if(!s->keyframe){
         if(get_rac(&s->c, s->header_state)){
-            for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){
+            for(plane_index=0; plane_index<FFMINI(s->nb_planes, 2); plane_index++){
                 int htaps, i, sum=0;
                 Plane *p= &s->plane[plane_index];
                 p->diag_mc= get_rac(&s->c, s->header_state);
@@ -540,7 +540,7 @@ static int decode_header(SnowContext *s){
         av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported\n", s->spatial_decomposition_type);
         return AVERROR_INVALIDDATA;
     }
-    if(FFMIN(s->avctx-> width>>s->chroma_h_shift,
+    if(FFMINI(s->avctx-> width>>s->chroma_h_shift,
              s->avctx->height>>s->chroma_v_shift) >> (s->spatial_decomposition_count-1) <= 1){
         av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_count %d too large for size\n", s->spatial_decomposition_count);
         return AVERROR_INVALIDDATA;
@@ -717,7 +717,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
             int slice_h = block_h*(mb_y+1);
 
             if (!(s->keyframe || s->avctx->debug&512)){
-                slice_starty = FFMAX(0, slice_starty - (block_h >> 1));
+                slice_starty = FFMAXI(0, slice_starty - (block_h >> 1));
                 slice_h -= (block_h >> 1);
             }
 
@@ -732,17 +732,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
                     start_y = (mb_y ? ((block_h * our_mb_start) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra: 0);
                     end_y = (((block_h * our_mb_end) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra);
                     if (!(s->keyframe || s->avctx->debug&512)){
-                        start_y = FFMAX(0, start_y - (block_h >> (1+s->spatial_decomposition_count - level)));
-                        end_y = FFMAX(0, end_y - (block_h >> (1+s->spatial_decomposition_count - level)));
+                        start_y = FFMAXI(0, start_y - (block_h >> (1+s->spatial_decomposition_count - level)));
+                        end_y = FFMAXI(0, end_y - (block_h >> (1+s->spatial_decomposition_count - level)));
                     }
-                    start_y = FFMIN(b->height, start_y);
-                    end_y = FFMIN(b->height, end_y);
+                    start_y = FFMINI(b->height, start_y);
+                    end_y = FFMINI(b->height, end_y);
 
                     if (start_y != end_y){
                         if (orientation == 0){
                             SubBand * correlate_band = &p->band[0][0];
-                            int correlate_end_y = FFMIN(b->height, end_y + 1);
-                            int correlate_start_y = FFMIN(b->height, (start_y ? start_y + 1 : 0));
+                            int correlate_end_y = FFMINI(b->height, end_y + 1);
+                            int correlate_start_y = FFMINI(b->height, (start_y ? start_y + 1 : 0));
                             decode_subband_slice_buffered(s, correlate_band, &s->sb, correlate_start_y, correlate_end_y, decode_state[0][0]);
                             correlate_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, 1, 0, correlate_start_y, correlate_end_y);
                             dequantize_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, start_y, end_y);
@@ -768,8 +768,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
 
             predict_slice_buffered(s, &s->sb, s->spatial_idwt_buffer, plane_index, 1, mb_y);
 
-            y = FFMIN(p->height, slice_starty);
-            end_y = FFMIN(p->height, slice_h);
+            y = FFMINI(p->height, slice_starty);
+            end_y = FFMINI(p->height, slice_h);
             while(y < end_y)
                 ff_slice_buffer_release(&s->sb, y++);
         }
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 661c6b3c07a..9ab92013862 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -94,7 +94,7 @@ static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signe
     if (v) {
         const int a = FFABS(v);
         const int e = av_log2(a);
-        const int el = FFMIN(e, 10);
+        const int el = FFMINI(e, 10);
         int i;
 
         put_rac(c, state + 0, 0);
@@ -103,7 +103,7 @@ static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signe
             put_rac(c, state + 1 + i, 1);  //1..10
         for(; i < e; i++)
             put_rac(c, state + 1 + 9, 1);  //1..10
-        put_rac(c, state + 1 + FFMIN(i, 9), 0);
+        put_rac(c, state + 1 + FFMINI(i, 9), 0);
 
         for (i = e - 1; i >= el; i--)
             put_rac(c, state + 22 + 9, (a >> i) & 1); //22..31
@@ -452,10 +452,10 @@ static int encode_q_branch(SnowEncContext *enc, int level, int x, int y)
     c->xmax = - (x+1)*block_w + (w<<(LOG2_MB_SIZE - s->block_max_depth)) + 16-3;
     c->ymax = - (y+1)*block_w + (h<<(LOG2_MB_SIZE - s->block_max_depth)) + 16-3;
 
-    c->xmin = FFMAX(c->xmin,-range);
-    c->xmax = FFMIN(c->xmax, range);
-    c->ymin = FFMAX(c->ymin,-range);
-    c->ymax = FFMIN(c->ymax, range);
+    c->xmin = FFMAXI(c->xmin,-range);
+    c->xmax = FFMINI(c->xmax, range);
+    c->ymin = FFMAXI(c->ymin,-range);
+    c->ymax = FFMINI(c->ymax, range);
 
     if(P_LEFT[0]     > (c->xmax<<shift)) P_LEFT[0]    = (c->xmax<<shift);
     if(P_LEFT[1]     > (c->ymax<<shift)) P_LEFT[1]    = (c->ymax<<shift);
@@ -696,8 +696,8 @@ static int get_dc(SnowEncContext *enc, int mb_x, int mb_y, int plane_index)
         add_yblock(s, 0, NULL, dst + (i&1)*block_w + (i>>1)*obmc_stride*block_h, NULL, obmc,
                     x, y, block_w, block_h, w, h, obmc_stride, ref_stride, obmc_stride, mb_x2, mb_y2, 0, 0, plane_index);
 
-        for(y2= FFMAX(y, 0); y2<FFMIN(h, y+block_h); y2++){
-            for(x2= FFMAX(x, 0); x2<FFMIN(w, x+block_w); x2++){
+        for(y2= FFMAXI(y, 0); y2<FFMINI(h, y+block_h); y2++){
+            for(x2= FFMAXI(x, 0); x2<FFMINI(w, x+block_w); x2++){
                 int index= x2-(block_w*mb_x - block_w/2) + (y2-(block_h*mb_y - block_h/2))*obmc_stride;
                 int obmc_v= obmc[index];
                 int d;
@@ -781,10 +781,10 @@ static int get_block_rd(SnowEncContext *enc, int mb_x, int mb_y,
     const int penalty_factor = get_penalty_factor(enc->lambda, enc->lambda2, s->avctx->me_cmp);
     int sx= block_w*mb_x - block_w/2;
     int sy= block_h*mb_y - block_h/2;
-    int x0= FFMAX(0,-sx);
-    int y0= FFMAX(0,-sy);
-    int x1= FFMIN(block_w*2, w-sx);
-    int y1= FFMIN(block_h*2, h-sy);
+    int x0= FFMAXI(0,-sx);
+    int y0= FFMAXI(0,-sy);
+    int x1= FFMINI(block_w*2, w-sx);
+    int y1= FFMINI(block_h*2, h-sy);
     int i,x,y;
 
     av_assert2(s->chroma_h_shift == s->chroma_v_shift); //obmc and square assumtions below chckinhg only block_w
@@ -1314,7 +1314,7 @@ static void iterative_me(SnowEncContext *enc)
                     do{
                         int newx = block->mx;
                         int newy = block->my;
-                        int dia_size = enc->iterative_dia_size ? enc->iterative_dia_size : FFMAX(s->avctx->dia_size, 1);
+                        int dia_size = enc->iterative_dia_size ? enc->iterative_dia_size : FFMAXI(s->avctx->dia_size, 1);
                         dia_change=0;
                         for(i=0; i < dia_size; i++){
                             for(j=0; j<i; j++){
@@ -1562,7 +1562,7 @@ static void correlate(SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int
 static void encode_qlogs(SnowContext *s){
     int plane_index, level, orientation;
 
-    for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){
+    for(plane_index=0; plane_index<FFMINI(s->nb_planes, 2); plane_index++){
         for(level=0; level<s->spatial_decomposition_count; level++){
             for(orientation=level ? 1:0; orientation<4; orientation++){
                 if(orientation==2) continue;
@@ -1613,7 +1613,7 @@ static void encode_header(SnowContext *s){
 
     if(!s->keyframe){
         int update_mc=0;
-        for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){
+        for(plane_index=0; plane_index<FFMINI(s->nb_planes, 2); plane_index++){
             Plane *p= &s->plane[plane_index];
             update_mc |= p->last_htaps   != p->htaps;
             update_mc |= p->last_diag_mc != p->diag_mc;
@@ -1621,7 +1621,7 @@ static void encode_header(SnowContext *s){
         }
         put_rac(&s->c, s->header_state, update_mc);
         if(update_mc){
-            for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){
+            for(plane_index=0; plane_index<FFMINI(s->nb_planes, 2); plane_index++){
                 Plane *p= &s->plane[plane_index];
                 put_rac(&s->c, s->header_state, p->diag_mc);
                 put_symbol(&s->c, s->header_state, p->htaps/2-1, 0);
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index 8b1d092ec91..a04e8870ace 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -126,12 +126,12 @@ do{\
                 put_rac(c, state+11 + e, v < 0); //11..21
         }else{
             for(i=0; i<e; i++){
-                put_rac(c, state+1+FFMIN(i,9), 1);  //1..10
+                put_rac(c, state+1+FFMINI(i,9), 1);  //1..10
             }
             put_rac(c, state+1+9, 0);
 
             for(i=e-1; i>=0; i--){
-                put_rac(c, state+22+FFMIN(i,9), (a>>i)&1); //22..31
+                put_rac(c, state+22+FFMINI(i,9), (a>>i)&1); //22..31
             }
 
             if(is_signed)
@@ -150,7 +150,7 @@ static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_si
         int i, e;
         unsigned a;
         e= 0;
-        while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
+        while(get_rac(c, state+1 + FFMINI(e,9))){ //1..10
             e++;
             if (e > 31)
                 return AVERROR_INVALIDDATA;
@@ -158,10 +158,10 @@ static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_si
 
         a= 1;
         for(i=e-1; i>=0; i--){
-            a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
+            a += a + get_rac(c, state+22 + FFMINI(i,9)); //22..31
         }
 
-        e= -(is_signed && get_rac(c, state+11 + FFMIN(e, 10))); //11..21
+        e= -(is_signed && get_rac(c, state+11 + FFMINI(e, 10))); //11..21
         return (a^e)-e;
     }
 }
diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index 94dce5420cc..3afc8f52d54 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -1008,9 +1008,9 @@ static int nb_decode(AVCodecContext *avctx, void *ptr_st,
 
             if (margin) {
                 pit_min = ol_pitch - margin + 1;
-                pit_min = FFMAX(pit_min, NB_PITCH_START);
+                pit_min = FFMAXI(pit_min, NB_PITCH_START);
                 pit_max = ol_pitch + margin;
-                pit_max = FFMIN(pit_max, NB_PITCH_START);
+                pit_max = FFMINI(pit_max, NB_PITCH_START);
             } else {
                 pit_min = pit_max = ol_pitch;
             }
@@ -1428,7 +1428,7 @@ static int parse_speex_extradata(AVCodecContext *avctx,
     if (s->frame_size < NB_FRAME_SIZE << (s->mode > 1) ||
         s->frame_size >     INT32_MAX >> (s->mode > 1))
         return AVERROR_INVALIDDATA;
-    s->frame_size = FFMIN(s->frame_size << (s->mode > 1), NB_FRAME_SIZE << s->mode);
+    s->frame_size = FFMINI(s->frame_size << (s->mode > 1), NB_FRAME_SIZE << s->mode);
     s->vbr = bytestream_get_le32(&buf);
     s->frames_per_packet = bytestream_get_le32(&buf);
     if (s->frames_per_packet <= 0 ||
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 4c4f3018c51..d443a8d751a 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -734,7 +734,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
 
             mb_type = MB_TYPE_SKIP;
         } else {
-            mb_type = FFMIN(s->next_pic->mb_type[mb_xy], 6);
+            mb_type = FFMINI(s->next_pic->mb_type[mb_xy], 6);
             if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 0, 0) < 0)
                 return -1;
             if (svq3_mc_dir(s, mb_type, PREDICT_MODE, 1, 1) < 0)
diff --git a/libavcodec/tak_parser.c b/libavcodec/tak_parser.c
index 7f5f5314af8..c5c9b331d6d 100644
--- a/libavcodec/tak_parser.c
+++ b/libavcodec/tak_parser.c
@@ -62,7 +62,7 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx,
 
     while (buf_size || t->index + needed <= pc->index) {
         if (buf_size && t->index + TAK_MAX_FRAME_HEADER_BYTES > pc->index) {
-            int tmp_buf_size       = FFMIN(TAK_MAX_FRAME_HEADER_BYTES,
+            int tmp_buf_size       = FFMINI(TAK_MAX_FRAME_HEADER_BYTES,
                                            buf_size);
             const uint8_t *tmp_buf = buf;
 
@@ -110,7 +110,7 @@ found:
 
     if (next != END_NOT_FOUND) {
         next        += consumed;
-        pc->overread = FFMAX(0, -next);
+        pc->overread = FFMAXI(0, -next);
     }
 
     *poutbuf      = buf;
diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index 1e6e6caebda..25aafa155d2 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -483,7 +483,7 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded,
     y    = FF_ARRAY_ELEMS(s->residues) - filter_order;
     x    = subframe_size - filter_order;
     while (x > 0) {
-        int tmp = FFMIN(y, x);
+        int tmp = FFMINI(y, x);
 
         for (i = 0; i < tmp; i++) {
             int v = 1 << (filter_quant - 1);
@@ -635,7 +635,7 @@ static int decorrelate(TAKDecContext *s, int c1, int c2, int length)
         p1 += order_half;
         x = FF_ARRAY_ELEMS(s->residues) - filter_order;
         for (; length2 > 0; length2 -= tmp) {
-            tmp = FFMIN(length2, x);
+            tmp = FFMINI(length2, x);
 
             for (i = 0; i < tmp - (tmp == length2); i++)
                 s->residues[filter_order + i] = *p2++ >> dshift;
diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 7e016ea4afc..6468a86451c 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -68,7 +68,7 @@ static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s,
         type &= 0x80;
         if (!type) {
             do {
-                int n  = FFMIN(count, w - x);
+                int n  = FFMINI(count, w - x);
                 bytestream2_get_buffer(&s->gb, dst, n * depth);
                 count -= n;
                 dst   += n * depth;
@@ -82,7 +82,7 @@ static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s,
             uint8_t tmp[4];
             bytestream2_get_buffer(&s->gb, tmp, depth);
             do {
-                int n  = FFMIN(count, w - x);
+                int n  = FFMINI(count, w - x);
                 count -= n;
                 x     += n;
                 do {
diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index 225ddf3701f..f158f02fda8 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -217,8 +217,8 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
         ctx->cursor_hot_y > ctx->cursor_h) {
         av_log(avctx, AV_LOG_WARNING, "Invalid hotspot position %d.%d.\n",
                ctx->cursor_hot_x, ctx->cursor_hot_y);
-        ctx->cursor_hot_x = FFMIN(ctx->cursor_hot_x, ctx->cursor_w - 1);
-        ctx->cursor_hot_y = FFMIN(ctx->cursor_hot_y, ctx->cursor_h - 1);
+        ctx->cursor_hot_x = FFMINI(ctx->cursor_hot_x, ctx->cursor_w - 1);
+        ctx->cursor_hot_y = FFMINI(ctx->cursor_hot_y, ctx->cursor_h - 1);
     }
 
     ret = av_reallocp(&ctx->cursor, ctx->cursor_stride * ctx->cursor_h);
diff --git a/libavcodec/tests/apv.c b/libavcodec/tests/apv.c
index 018674afe7d..3e8257a7f30 100644
--- a/libavcodec/tests/apv.c
+++ b/libavcodec/tests/apv.c
@@ -140,7 +140,7 @@ static int apv_entropy_decode_block(int16_t *restrict coeff,
         coeff[0] = dc_coeff;
 
         state->prev_dc   = dc_coeff;
-        state->prev_k_dc = FFMIN(abs_dc_coeff_diff >> 1, 5);
+        state->prev_k_dc = FFMINI(abs_dc_coeff_diff >> 1, 5);
     }
 
     // AC coefficients.
@@ -166,7 +166,7 @@ static int apv_entropy_decode_block(int16_t *restrict coeff,
                 coeff[ff_zigzag_direct[scan_pos]] = 0;
                 ++scan_pos;
             }
-            k_run = FFMIN(coeff_zero_run >> 2, 2);
+            k_run = FFMINI(coeff_zero_run >> 2, 2);
 
             if (scan_pos < APV_BLK_COEFFS) {
                 int abs_ac_coeff_minus1;
@@ -192,7 +192,7 @@ static int apv_entropy_decode_block(int16_t *restrict coeff,
 
                 coeff[ff_zigzag_direct[scan_pos]] = level;
 
-                k_level = FFMIN(abs_level >> 2, 4);
+                k_level = FFMINI(abs_level >> 2, 4);
                 if (first_ac) {
                     state->prev_k_level = k_level;
                     first_ac = 0;
diff --git a/libavcodec/tests/bitstream_template.c b/libavcodec/tests/bitstream_template.c
index b4c8821a907..6d8b735abf9 100644
--- a/libavcodec/tests/bitstream_template.c
+++ b/libavcodec/tests/bitstream_template.c
@@ -86,7 +86,7 @@ int main(int argc, char **argv)
 
         switch (op) {
         case OP_READ:
-            count = av_lfg_get(&lfg) % FFMIN(33, bits_left(&bc) + 1);
+            count = av_lfg_get(&lfg) % FFMINI(33, bits_left(&bc) + 1);
             val1  = bits_peek(&bc, count);
             val   = bits_read(&bc, count);
 
@@ -97,8 +97,8 @@ int main(int argc, char **argv)
             put_bits64(&pb, count, val);
             break;
         case OP_READ_NZ:
-            count = av_lfg_get(&lfg) % FFMIN(33, bits_left(&bc) + 1);
-            count = FFMAX(count, 1);
+            count = av_lfg_get(&lfg) % FFMINI(33, bits_left(&bc) + 1);
+            count = FFMAXI(count, 1);
             val1  = bits_peek_nz(&bc, count);
             val   = bits_read_nz(&bc, count);
 
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
             put_bits(&pb, 1, val);
             break;
         case OP_READ_63:
-            count = av_lfg_get(&lfg) % FFMIN(64, bits_left(&bc) + 1);
+            count = av_lfg_get(&lfg) % FFMINI(64, bits_left(&bc) + 1);
             val   = bits_read_63(&bc, count);
 
             fprintf(stderr, "%d read_63 %u: %"PRIu64"\n", bits_tell(&bc) - count, count, val);
@@ -124,7 +124,7 @@ int main(int argc, char **argv)
             put_bits64(&pb, count, val);
             break;
         case OP_READ_64:
-            count = av_lfg_get(&lfg) % FFMIN(65, bits_left(&bc) + 1);
+            count = av_lfg_get(&lfg) % FFMINI(65, bits_left(&bc) + 1);
             val   = bits_read_64(&bc, count);
 
             fprintf(stderr, "%d read_64 %u: %"PRIu64"\n", bits_tell(&bc) - count, count, val);
@@ -132,7 +132,7 @@ int main(int argc, char **argv)
             put_bits64(&pb, count, val);
             break;
         case OP_READ_SIGNED:
-            count = av_lfg_get(&lfg) % FFMIN(33, bits_left(&bc) + 1);
+            count = av_lfg_get(&lfg) % FFMINI(33, bits_left(&bc) + 1);
             sval1 = bits_peek_signed(&bc, count);
             sval  = bits_read_signed(&bc, count);
 
@@ -144,8 +144,8 @@ int main(int argc, char **argv)
             else             put_sbits(&pb, count, sval);
             break;
         case OP_READ_SIGNED_NZ:
-            count = av_lfg_get(&lfg) % FFMIN(33, bits_left(&bc) + 1);
-            count = FFMAX(count, 1);
+            count = av_lfg_get(&lfg) % FFMINI(33, bits_left(&bc) + 1);
+            count = FFMAXI(count, 1);
             sval1 = bits_peek_signed_nz(&bc, count);
             sval  = bits_read_signed_nz(&bc, count);
 
@@ -168,8 +168,8 @@ int main(int argc, char **argv)
             if (bits_left(&bc) < 2)
                 continue;
 
-            count = av_lfg_get(&lfg) % FFMIN(32, bits_left(&bc));
-            count = FFMAX(count, 1);
+            count = av_lfg_get(&lfg) % FFMINI(32, bits_left(&bc));
+            count = FFMAXI(count, 1);
 
             if (!bits_peek(&bc, count))
                 continue;
diff --git a/libavcodec/tests/dct.c b/libavcodec/tests/dct.c
index 76ad42bdfa9..6e79373c0f7 100644
--- a/libavcodec/tests/dct.c
+++ b/libavcodec/tests/dct.c
@@ -238,8 +238,8 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
             blockSumErrMax = blockSumErr;
     }
     for (i = 0; i < 64; i++) {
-        sysErrMax = FFMAX(sysErrMax, FFABS(sysErr[i]));
-        err2_max  = FFMAX(err2_max , FFABS(err2_matrix[i]));
+        sysErrMax = FFMAXI(sysErrMax, FFABS(sysErr[i]));
+        err2_max  = FFMAXI(err2_max , FFABS(err2_matrix[i]));
     }
 
     for (i = 0; i < 64; i++) {
diff --git a/libavcodec/tests/jpeg2000dwt.c b/libavcodec/tests/jpeg2000dwt.c
index f9adb605649..42c12c3cb16 100644
--- a/libavcodec/tests/jpeg2000dwt.c
+++ b/libavcodec/tests/jpeg2000dwt.c
@@ -139,7 +139,7 @@ int main(void) {
         ret = test_dwt(array, ref, border, decomp_levels, FF_DWT53, 0);
         if (ret)
             return ret;
-        ret = test_dwt(array, ref, border, decomp_levels, FF_DWT97_INT, FFMIN(7+5*decomp_levels, 15+3*decomp_levels));
+        ret = test_dwt(array, ref, border, decomp_levels, FF_DWT97_INT, FFMINI(7+5*decomp_levels, 15+3*decomp_levels));
         if (ret)
             return ret;
         ret = test_dwtf(arrayf, reff, border, decomp_levels, 0.05);
diff --git a/libavcodec/texturedsp_template.c b/libavcodec/texturedsp_template.c
index b9caf494cc0..2dd67300da0 100644
--- a/libavcodec/texturedsp_template.c
+++ b/libavcodec/texturedsp_template.c
@@ -39,7 +39,7 @@ static int exec_func(AVCodecContext *avctx, void *arg,
      * operations */
     start_slice = slice * base_blocks_per_slice;
     /* Add any extra blocks (one per slice) that have been added before this slice */
-    start_slice += FFMIN(slice, remainder_blocks);
+    start_slice += FFMINI(slice, remainder_blocks);
 
     end_slice = start_slice + base_blocks_per_slice;
     /* Add an extra block if there are still remainder blocks to be accounted for */
diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c
index 31acc9b438d..3379d747f01 100644
--- a/libavcodec/tiertexseqv.c
+++ b/libavcodec/tiertexseqv.c
@@ -62,11 +62,11 @@ static const unsigned char *seq_unpack_rle_block(const unsigned char *src,
             len = -len;
             if (src_end - src < 1)
                 return NULL;
-            memset(dst, *src++, FFMIN(len, dst_size));
+            memset(dst, *src++, FFMINI(len, dst_size));
         } else {
             if (src_end - src < len)
                 return NULL;
-            memcpy(dst, src, FFMIN(len, dst_size));
+            memcpy(dst, src, FFMINI(len, dst_size));
             src += len;
         }
         dst += len;
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index e515845a839..c7b58b6763d 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -477,8 +477,8 @@ static void unpack_yuv(TiffContext *s, AVFrame *p,
         for (i = 0; i < w; i++) {
             for (j = 0; j < s->subsampling[1]; j++)
                 for (k = 0; k < s->subsampling[0]; k++)
-                    p->data[0][FFMIN(lnum + j, s->height-1) * p->linesize[0] +
-                               FFMIN(i * s->subsampling[0] + k, s->width-1)] = *src++;
+                    p->data[0][FFMINI(lnum + j, s->height-1) * p->linesize[0] +
+                               FFMINI(i * s->subsampling[0] + k, s->width-1)] = *src++;
             *pu++ = *src++;
             *pv++ = *src++;
         }
@@ -1391,7 +1391,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
     case TIFF_ROWSPERSTRIP:
         if (!value || (type == TIFF_LONG && value == UINT_MAX))
             value = s->height;
-        s->rps = FFMIN(value, s->height);
+        s->rps = FFMINI(value, s->height);
         break;
     case TIFF_STRIP_OFFS:
         if (count == 1) {
@@ -2216,7 +2216,7 @@ again:
             }
             remaining -= ssize;
             if ((ret = tiff_unpack_strip(s, p, dst, stride, avpkt->data + soff, ssize, i,
-                                         FFMIN(s->rps, s->height - i))) < 0) {
+                                         FFMINI(s->rps, s->height - i))) < 0) {
                 if (avctx->err_recognition & AV_EF_EXPLODE) {
                     av_freep(&five_planes);
                     return ret;
@@ -2224,7 +2224,7 @@ again:
                 break;
             }
         }
-        decoded_height = FFMIN(i, s->height);
+        decoded_height = FFMINI(i, s->height);
 
         if (s->predictor == 2) {
             if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
@@ -2234,7 +2234,7 @@ again:
             dst   = five_planes ? five_planes : p->data[plane];
             soff  = s->bpp >> 3;
             if (s->planar)
-                soff  = FFMAX(soff / s->bppcount, 1);
+                soff  = FFMAXI(soff / s->bppcount, 1);
             ssize = s->width * soff;
             if (s->avctx->pix_fmt == AV_PIX_FMT_RGB48LE ||
                 s->avctx->pix_fmt == AV_PIX_FMT_RGBA64LE ||
@@ -2278,11 +2278,11 @@ again:
             dst   = five_planes ? five_planes : p->data[plane];
             soff  = s->bpp >> 3;
             if (s->planar) {
-                soff  = FFMAX(soff / s->bppcount, 1);
+                soff  = FFMAXI(soff / s->bppcount, 1);
                 channels = 1;
             }
             ssize = s->width * soff;
-            bpc = FFMAX(soff / s->bppcount, 1); /* Bytes per component */
+            bpc = FFMAXI(soff / s->bppcount, 1); /* Bytes per component */
             group_size = s->width * channels;
 
             tmpbuf = av_malloc(ssize);
@@ -2397,7 +2397,7 @@ again:
         uint16_t *dst = (uint16_t *)p->data[0];
         for (i = 0; i < s->height; i++) {
             for (j = 0; j < s->width; j++)
-                dst[j] = FFMIN((dst[j] / (float)s->white_level) * 65535, 65535);
+                dst[j] = FFMINF((dst[j] / (float)s->white_level) * 65535, 65535);
             dst += stride / 2;
         }
     }
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 66facb41747..cc6076049f5 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -213,8 +213,8 @@ static void pack_yuv(TiffEncoderContext *s, const AVFrame *p,
         for (i = 0; i < w; i++) {
             for (j = 0; j < s->subsampling[1]; j++)
                 for (k = 0; k < s->subsampling[0]; k++)
-                    *dst++ = p->data[0][FFMIN(lnum + j, s->height-1) * p->linesize[0] +
-                                        FFMIN(i * s->subsampling[0] + k, s->width-1)];
+                    *dst++ = p->data[0][FFMINI(lnum + j, s->height-1) * p->linesize[0] +
+                                        FFMINI(i * s->subsampling[0] + k, s->width-1)];
             *dst++ = *pu++;
             *dst++ = *pv++;
         }
@@ -325,7 +325,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         s->rps = s->height;
     else
         // suggest size of strip
-        s->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);
+        s->rps = FFMAXI(8192 / (((s->width * s->bpp) >> 3) + 1), 1);
     // round rps up
     s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1];
 
@@ -355,7 +355,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     offset = ptr;
     bytestream_put_le32(&ptr, 0);
 
-    if (strips > INT_MAX / FFMAX(sizeof(s->strip_sizes[0]), sizeof(s->strip_offsets[0]))) {
+    if (strips > INT_MAX / FFMAXI(sizeof(s->strip_sizes[0]), sizeof(s->strip_offsets[0]))) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 7ae9a67ec41..a56dbd2655b 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -144,7 +144,7 @@ static int tm2_read_tree(TM2Context *ctx, int length, TM2Huff *huff)
         if ((ret = tm2_read_tree(ctx, length + 1, huff)) < 0)
             return ret;
     }
-    return FFMAX(ret, ret2);
+    return FFMAXI(ret, ret2);
 }
 
 static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 90867ed6b10..d2c63cff095 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -320,7 +320,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
     }
 
     if (s->codec_id == AV_CODEC_ID_IFF_ILBM) {
-        w_align = FFMAX(w_align, 16);
+        w_align = FFMAXI(w_align, 16);
     }
 
     *width  = FFALIGN(*width, w_align);
@@ -338,10 +338,10 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
         // it requires a temporary area large enough to hold a 21x21 block,
         // increasing witdth ensure that the temporary area is large enough,
         // the next rounded up width is 32
-        *width = FFMAX(*width, 32);
+        *width = FFMAXI(*width, 32);
     }
     if (s->codec_id == AV_CODEC_ID_SVQ3) {
-        *width = FFMAX(*width, 32);
+        *width = FFMAXI(*width, 32);
     }
 
     for (i = 0; i < 4; i++)
@@ -356,7 +356,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
     int align;
 
     avcodec_align_dimensions2(s, width, height, linesize_align);
-    align               = FFMAX(linesize_align[0], linesize_align[3]);
+    align               = FFMAXI(linesize_align[0], linesize_align[3]);
     linesize_align[1] <<= chroma_shift;
     linesize_align[2] <<= chroma_shift;
     align               = FFMAX3(align, linesize_align[1], linesize_align[2]);
@@ -796,7 +796,7 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
                                     avctx->codec_tag, avctx->bits_per_coded_sample,
                                     avctx->bit_rate, avctx->extradata, avctx->frame_size,
                                     frame_bytes);
-    return FFMAX(0, duration);
+    return FFMAXI(0, duration);
 }
 
 int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
@@ -809,7 +809,7 @@ int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
                                     par->codec_tag, par->bits_per_coded_sample,
                                     par->bit_rate, par->extradata, par->frame_size,
                                     frame_bytes);
-    return FFMAX(0, duration);
+    return FFMAXI(0, duration);
 }
 
 unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 4c0fa2ca67d..dcbb7bf3c03 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -403,7 +403,7 @@ static void restore_median_planar(UtvideoContext *c, uint8_t *src, ptrdiff_t str
         C        = bsrc[-stride];
         bsrc[0] += C;
         A        = bsrc[0];
-        for (i = 1; i < FFMIN(width, 16); i++) { /* scalar loop (DSP need align 16) */
+        for (i = 1; i < FFMINI(width, 16); i++) { /* scalar loop (DSP need align 16) */
             B        = bsrc[i - stride];
             bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
             C        = B;
@@ -458,7 +458,7 @@ static void restore_median_planar_il(UtvideoContext *c, uint8_t *src, ptrdiff_t
         C        = bsrc[-stride2];
         bsrc[0] += C;
         A        = bsrc[0];
-        for (i = 1; i < FFMIN(width, 16); i++) { /* scalar loop (DSP need align 16) */
+        for (i = 1; i < FFMINI(width, 16); i++) { /* scalar loop (DSP need align 16) */
             B        = bsrc[i - stride2];
             bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
             C        = B;
@@ -490,7 +490,7 @@ static void restore_gradient_planar(UtvideoContext *c, uint8_t *src, ptrdiff_t s
     uint8_t *bsrc;
     int slice_start, slice_height;
     const int cmask = ~rmode;
-    int min_width = FFMIN(width, 32);
+    int min_width = FFMINI(width, 32);
 
     for (slice = 0; slice < slices; slice++) {
         slice_start  = ((slice * height) / slices) & cmask;
@@ -532,7 +532,7 @@ static void restore_gradient_planar_il(UtvideoContext *c, uint8_t *src, ptrdiff_
     int slice_start, slice_height;
     const int cmask   = ~(rmode ? 3 : 1);
     const ptrdiff_t stride2 = stride << 1;
-    int min_width = FFMIN(width, 32);
+    int min_width = FFMINI(width, 32);
 
     for (slice = 0; slice < slices; slice++) {
         slice_start    = ((slice * height) / slices) & cmask;
@@ -670,7 +670,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                 }
                 slice_size  = slice_end - slice_start;
                 slice_start = slice_end;
-                max_slice_size = FFMAX(max_slice_size, slice_size);
+                max_slice_size = FFMAXI(max_slice_size, slice_size);
             }
             plane_size = slice_end;
             bytestream2_skipu(&gb, plane_size);
@@ -696,7 +696,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
                 }
                 slice_size  = slice_end - slice_start;
                 slice_start = slice_end;
-                max_slice_size = FFMAX(max_slice_size, slice_size);
+                max_slice_size = FFMAXI(max_slice_size, slice_size);
             }
             plane_size = slice_end;
             bytestream2_skipu(&gb, plane_size);
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 8b370e56594..4fbf7b0078c 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -56,7 +56,7 @@ static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *
                        void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width))
 {
     uint32_t val;
-    int w = (FFMAX(0, width - 12) / 12) * 12;
+    int w = (FFMAXI(0, width - 12) / 12) * 12;
 
     unpack_frame(src, y, u, v, w);
 
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index 7f597a424aa..d4d881a35b2 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -297,9 +297,9 @@ static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, i
         return AVERROR(EINVAL);
 
     length = out->plane_info[plane].length;
-    bytesused = FFMIN(size+offset, length);
+    bytesused = FFMINI(size+offset, length);
 
-    memcpy((uint8_t*)out->plane_info[plane].mm_addr+offset, data, FFMIN(size, length-offset));
+    memcpy((uint8_t*)out->plane_info[plane].mm_addr+offset, data, FFMINI(size, length-offset));
 
     if (V4L2_TYPE_IS_MULTIPLANAR(out->buf.type)) {
         out->planes[plane].bytesused = bytesused;
@@ -393,7 +393,7 @@ static int v4l2_buffer_swframe_to_buf(const AVFrame *frame, V4L2Buffer *out)
         int offset = 0;
 
         for (i = 0; i < desc->nb_components; i++)
-            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
+            planes_nb = FFMAXI(planes_nb, desc->comp[i].plane + 1);
 
         for (i = 0; i < planes_nb; i++) {
             int size, h = height;
diff --git a/libavcodec/vaapi_encode_av1.c b/libavcodec/vaapi_encode_av1.c
index f3df5baddc3..7f566ee0d26 100644
--- a/libavcodec/vaapi_encode_av1.c
+++ b/libavcodec/vaapi_encode_av1.c
@@ -242,9 +242,9 @@ static int vaapi_encode_av1_set_tile(AVCodecContext *avctx)
     max_tile_area_sb = AV1_MAX_TILE_AREA  >> (2 * sb_size);
 
     priv->min_log2_tile_cols = tile_log2(priv->max_tile_width_sb, priv->sb_cols);
-    priv->max_log2_tile_cols = tile_log2(1, FFMIN(priv->sb_cols, AV1_MAX_TILE_COLS));
-    priv->max_log2_tile_rows = tile_log2(1, FFMIN(priv->sb_rows, AV1_MAX_TILE_ROWS));
-    min_log2_tiles = FFMAX(priv->min_log2_tile_cols,
+    priv->max_log2_tile_cols = tile_log2(1, FFMINI(priv->sb_cols, AV1_MAX_TILE_COLS));
+    priv->max_log2_tile_rows = tile_log2(1, FFMINI(priv->sb_rows, AV1_MAX_TILE_ROWS));
+    min_log2_tiles = FFMAXI(priv->min_log2_tile_cols,
                            tile_log2(max_tile_area_sb, priv->sb_rows * priv->sb_cols));
 
     tile_cols = av_clip(priv->tile_cols, (priv->sb_cols + priv->max_tile_width_sb - 1) / priv->max_tile_width_sb, priv->sb_cols);
@@ -289,7 +289,7 @@ static int vaapi_encode_av1_set_tile(AVCodecContext *avctx)
                 priv->height_in_sbs_minus_1[i] = priv->sb_rows - (tile_rows - 1) * tile_height_sb - 1;
 
                 priv->uniform_tile = 1;
-                priv->min_log2_tile_rows = FFMAX(min_log2_tiles - priv->tile_cols_log2, 0);
+                priv->min_log2_tile_rows = FFMAXI(min_log2_tiles - priv->tile_cols_log2, 0);
 
                 break;
             }
@@ -299,14 +299,14 @@ static int vaapi_encode_av1_set_tile(AVCodecContext *avctx)
         widest_tile_sb = 0;
         for (i = 0; i < priv->tile_cols; i++) {
             priv->width_in_sbs_minus_1[i] = (i + 1) * priv->sb_cols / priv->tile_cols - i * priv->sb_cols / priv->tile_cols - 1;
-            widest_tile_sb = FFMAX(widest_tile_sb, priv->width_in_sbs_minus_1[i] + 1);
+            widest_tile_sb = FFMAXI(widest_tile_sb, priv->width_in_sbs_minus_1[i] + 1);
         }
 
         if (min_log2_tiles)
             max_tile_area_sb_varied = (priv->sb_rows * priv->sb_cols) >> (min_log2_tiles + 1);
         else
             max_tile_area_sb_varied = priv->sb_rows * priv->sb_cols;
-        priv->max_tile_height_sb = FFMAX(1, max_tile_area_sb_varied / widest_tile_sb);
+        priv->max_tile_height_sb = FFMAXI(1, max_tile_area_sb_varied / widest_tile_sb);
 
         if (tile_rows == av_clip(tile_rows, (priv->sb_rows + priv->max_tile_height_sb - 1) / priv->max_tile_height_sb, priv->sb_rows)) {
             for (i = 0; i < tile_rows; i++)
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 2acde2296bc..a7f04244bed 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -549,26 +549,26 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
                 for (i = 0; i < 3; i++) {
                     const int j = mapping[i];
                     mdcv->display_primaries_x[i] =
-                        FFMIN(lrint(chroma_den *
+                        FFMINI(lrint(chroma_den *
                                     av_q2d(mdm->display_primaries[j][0])),
                               chroma_den);
                     mdcv->display_primaries_y[i] =
-                        FFMIN(lrint(chroma_den *
+                        FFMINI(lrint(chroma_den *
                                     av_q2d(mdm->display_primaries[j][1])),
                               chroma_den);
                 }
 
                 mdcv->white_point_x =
-                    FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[0])),
+                    FFMINI(lrint(chroma_den * av_q2d(mdm->white_point[0])),
                           chroma_den);
                 mdcv->white_point_y =
-                    FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[1])),
+                    FFMINI(lrint(chroma_den * av_q2d(mdm->white_point[1])),
                           chroma_den);
 
                 mdcv->max_display_mastering_luminance =
                     lrint(luma_den * av_q2d(mdm->max_luminance));
                 mdcv->min_display_mastering_luminance =
-                    FFMIN(lrint(luma_den * av_q2d(mdm->min_luminance)),
+                    FFMINI(lrint(luma_den * av_q2d(mdm->min_luminance)),
                           mdcv->max_display_mastering_luminance);
 
                 priv->sei_needed |= SEI_MASTERING_DISPLAY;
@@ -588,8 +588,8 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
             SEIRawContentLightLevelInfo *clli =
                 &priv->sei_content_light_level;
 
-            clli->max_content_light_level     = FFMIN(clm->MaxCLL,  65535);
-            clli->max_pic_average_light_level = FFMIN(clm->MaxFALL, 65535);
+            clli->max_content_light_level     = FFMINI(clm->MaxCLL,  65535);
+            clli->max_pic_average_light_level = FFMINI(clm->MaxFALL, 65535);
 
             priv->sei_needed |= SEI_CONTENT_LIGHT_LEVEL;
         }
@@ -952,9 +952,9 @@ static av_cold int vaapi_encode_h265_get_encoder_caps(AVCodecContext *avctx)
            priv->min_cb_size, priv->min_cb_size);
 
     base_ctx->surface_width  = FFALIGN(avctx->width,
-        FFMAX(priv->min_cb_size, priv->common.surface_alignment_width));
+        FFMAXI(priv->min_cb_size, priv->common.surface_alignment_width));
     base_ctx->surface_height = FFALIGN(avctx->height,
-        FFMAX(priv->min_cb_size, priv->common.surface_alignment_height));
+        FFMAXI(priv->min_cb_size, priv->common.surface_alignment_height));
 
     base_ctx->slice_block_width = base_ctx->slice_block_height = priv->ctu_size;
 
diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c
index 87d9b6d6dc4..50e3f4c2b25 100644
--- a/libavcodec/vc1_pred.c
+++ b/libavcodec/vc1_pred.c
@@ -109,7 +109,7 @@ static av_always_inline int scaleforopp_x(const VC1Context *v, int n /* MV */)
     int scaleopp1, scaleopp2, brfd;
     int scaledvalue;
 
-    brfd = FFMIN(v->brfd, 3);
+    brfd = FFMINI(v->brfd, 3);
     scalezone1_x  = ff_vc1_b_field_mvpred_scales[3][brfd];
     zone1offset_x = ff_vc1_b_field_mvpred_scales[5][brfd];
     scaleopp1     = ff_vc1_b_field_mvpred_scales[1][brfd];
@@ -136,7 +136,7 @@ static av_always_inline int scaleforopp_y(const VC1Context *v, int n /* MV */, i
     int scaleopp1, scaleopp2, brfd;
     int scaledvalue;
 
-    brfd = FFMIN(v->brfd, 3);
+    brfd = FFMINI(v->brfd, 3);
     scalezone1_y  = ff_vc1_b_field_mvpred_scales[4][brfd];
     zone1offset_y = ff_vc1_b_field_mvpred_scales[6][brfd];
     scaleopp1     = ff_vc1_b_field_mvpred_scales[1][brfd];
@@ -175,7 +175,7 @@ static av_always_inline int scaleforsame(const VC1Context *v, int n /* MV */,
             n = scaleforsame_x(v, n, dir) * (1 << hpel);
         return n;
     }
-    brfd      = FFMIN(v->brfd, 3);
+    brfd      = FFMINI(v->brfd, 3);
     scalesame = ff_vc1_b_field_mvpred_scales[0][brfd];
 
     n = (n * scalesame >> 8) * (1 << hpel);
@@ -200,7 +200,7 @@ static av_always_inline int scaleforopp(const VC1Context *v, int n /* MV */,
         refdist = v->refdist;
     else
         refdist = dir ? v->brfd : v->frfd;
-    refdist = FFMIN(refdist, 3);
+    refdist = FFMINI(refdist, 3);
     scaleopp = ff_vc1_field_mvpred_scales[dir ^ v->second_field][0][refdist];
 
     n = (n * scaleopp >> 8) * (1 << hpel);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 7ee014d4b6d..77c2bfb26b3 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -245,7 +245,7 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
                     iplane = s->last_pic.data[plane];
                     iline  = s->last_pic.linesize[plane];
                 }
-                next_line = FFMIN(yline + 1, (v->sprite_height >> !!plane) - 1) * iline;
+                next_line = FFMINI(yline + 1, (v->sprite_height >> !!plane) - 1) * iline;
                 if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) {
                         src_h[sprite][0] = iplane + (xoff[sprite] >> 16) +  yline      * iline;
                     if (ysub[sprite])
@@ -659,7 +659,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
         count = avctx->extradata_size*8 - get_bits_count(&gb);
         if (count > 0) {
             av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n",
-                   count, get_bits_long(&gb, FFMIN(count, 32)));
+                   count, get_bits_long(&gb, FFMINI(count, 32)));
         } else if (count < 0) {
             av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
         }
@@ -1285,15 +1285,15 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
             }
             if (header_ret < 0)
                 continue;
-            s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start % mb_height);
+            s->start_mb_y = (i == 0) ? 0 : FFMAXI(0, slices[i-1].mby_start % mb_height);
             if (!v->field_mode || v->second_field)
-                s->end_mb_y = (i == n_slices     ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
+                s->end_mb_y = (i == n_slices     ) ? mb_height : FFMINI(mb_height, slices[i].mby_start % mb_height);
             else {
                 if (i >= n_slices) {
                     av_log(v->s.avctx, AV_LOG_ERROR, "first field slice count too large\n");
                     continue;
                 }
-                s->end_mb_y = (i == n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
+                s->end_mb_y = (i == n_slices1 + 1) ? mb_height : FFMINI(mb_height, slices[i].mby_start % mb_height);
             }
             if (s->end_mb_y <= s->start_mb_y) {
                 av_log(v->s.avctx, AV_LOG_ERROR, "end mb y %d %d invalid\n", s->end_mb_y, s->start_mb_y);
diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c
index 2caa3c68636..01ee3381a2e 100644
--- a/libavcodec/vc1dsp.c
+++ b/libavcodec/vc1dsp.c
@@ -165,7 +165,7 @@ static av_always_inline int vc1_filter_line(uint8_t *src, ptrdiff_t stride, int
 
             clip = ((clip ^ clip_sign) - clip_sign) >> 1;
             if (clip) {
-                int a3     = FFMIN(a1, a2);
+                int a3     = FFMINI(a1, a2);
                 int d      = 5 * (a3 - a0);
                 int d_sign = (d >> 31);
 
@@ -175,7 +175,7 @@ static av_always_inline int vc1_filter_line(uint8_t *src, ptrdiff_t stride, int
                 if (d_sign ^ clip_sign)
                     d = 0;
                 else {
-                    d = FFMIN(d, clip);
+                    d = FFMINI(d, clip);
                     d = (d ^ d_sign) - d_sign; /* Restore sign */
                     src[-1 * stride] = av_clip_uint8(src[-1 * stride] - d);
                     src[ 0 * stride] = av_clip_uint8(src[ 0 * stride] + d);
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index b0588f6b584..51aeeb78db5 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -577,7 +577,7 @@ static int count_hq_slice(SliceArgs *slice, int quant_idx)
 
     for (level = 0; level < s->wavelet_depth; level++)
         for (orientation = !!level; orientation < 4; orientation++)
-            quants[level][orientation] = FFMAX(quant_idx - s->quant[level][orientation], 0);
+            quants[level][orientation] = FFMAXI(quant_idx - s->quant[level][orientation], 0);
 
     for (p = 0; p < 3; p++) {
         int bytes_start, bytes_len, pad_s, pad_c;
@@ -638,7 +638,7 @@ static int rate_control(AVCodecContext *avctx, void *arg)
         quant  = av_clip(quant + signed_step, 0, s->q_ceil-1);
         bits   = count_hq_slice(slice_dat, quant);
         if (quant_buf[1] == quant) {
-            quant = FFMAX(quant_buf[0], quant);
+            quant = FFMAXI(quant_buf[0], quant);
             bits  = quant == quant_buf[0] ? bits_last : bits;
             break;
         }
@@ -657,7 +657,7 @@ static int calc_slice_sizes(VC2EncContext *s)
     int i, j, slice_x, slice_y, bytes_left = 0;
     int bytes_top[SLICE_REDIST_TOTAL] = {0};
     int64_t total_bytes_needed = 0;
-    int slice_redist_range = FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y);
+    int slice_redist_range = FFMINI(SLICE_REDIST_TOTAL, s->num_x*s->num_y);
     SliceArgs *enc_args = s->slice_args;
     SliceArgs *top_loc[SLICE_REDIST_TOTAL] = {NULL};
 
@@ -705,7 +705,7 @@ static int calc_slice_sizes(VC2EncContext *s)
                 break;
             args = top_loc[i];
             prev_bytes = args->bytes;
-            new_idx = FFMAX(args->quant_idx - 1, 0);
+            new_idx = FFMAXI(args->quant_idx - 1, 0);
             bits  = count_hq_slice(args, new_idx);
             bytes = SSIZE_ROUND(bits >> 3);
             diff  = bytes - prev_bytes;
@@ -752,7 +752,7 @@ static int encode_hq_slice(AVCodecContext *avctx, void *arg)
     /* Slice quantization (slice_quantizers() in the specs) */
     for (level = 0; level < s->wavelet_depth; level++)
         for (orientation = !!level; orientation < 4; orientation++)
-            quants[level][orientation] = FFMAX(quant_idx - s->quant[level][orientation], 0);
+            quants[level][orientation] = FFMAXI(quant_idx - s->quant[level][orientation], 0);
 
     /* Luma + 2 Chroma planes */
     for (p = 0; p < 3; p++) {
diff --git a/libavcodec/videodsp_template.c b/libavcodec/videodsp_template.c
index d653f4d524d..30412559d3e 100644
--- a/libavcodec/videodsp_template.c
+++ b/libavcodec/videodsp_template.c
@@ -56,10 +56,10 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
         src_x = 1 - block_w;
     }
 
-    start_y = FFMAX(0, -src_y);
-    start_x = FFMAX(0, -src_x);
-    end_y = FFMIN(block_h, h-src_y);
-    end_x = FFMIN(block_w, w-src_x);
+    start_y = FFMAXI(0, -src_y);
+    start_x = FFMAXI(0, -src_x);
+    end_y = FFMINI(block_h, h-src_y);
+    end_x = FFMINI(block_w, w-src_x);
     av_assert2(start_y < end_y && block_h);
     av_assert2(start_x < end_x && block_w);
 
diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c
index 3aa198a2778..fd4f4d965f5 100644
--- a/libavcodec/vlc.c
+++ b/libavcodec/vlc.c
@@ -197,9 +197,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
                     break;
                 codes[k].bits = n;
                 codes[k].code = code << table_nb_bits;
-                subtable_bits = FFMAX(subtable_bits, n);
+                subtable_bits = FFMAXI(subtable_bits, n);
             }
-            subtable_bits = FFMIN(subtable_bits, table_nb_bits);
+            subtable_bits = FFMINI(subtable_bits, table_nb_bits);
             j = (flags & VLC_INIT_OUTPUT_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
             table[j].len = -subtable_bits;
             ff_dlog(NULL, "%4x: n=%d (subtable)\n",
@@ -310,7 +310,7 @@ int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes,
 {
     VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf;
     uint64_t code;
-    int ret, j, len_max = FFMIN(32, 3 * nb_bits);
+    int ret, j, len_max = FFMINI(32, 3 * nb_bits);
 
     ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags);
     if (ret < 0)
@@ -482,8 +482,8 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
     maxbits = 0;
 
     for (int n = nb_codes - count0; n < nb_codes; n++) {
-        minbits = FFMIN(minbits, buf[n].bits);
-        maxbits = FFMAX(maxbits, buf[n].bits);
+        minbits = FFMINI(minbits, buf[n].bits);
+        maxbits = FFMAXI(maxbits, buf[n].bits);
     }
     av_assert0(maxbits <= numbits);
 
@@ -506,7 +506,7 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
     }
 
     add_level(table, is16bit, nb_codes, numbits, buf,
-              0, 0, FFMIN(maxbits, numbits), 0, minbits, max, count, info);
+              0, 0, FFMINI(maxbits, numbits), 0, minbits, max, count, info);
 
     av_log(logctx, AV_LOG_DEBUG, "Joint: %d/%d/%d/%d/%d codes min=%ubits max=%u\n",
            count[0], count[1], count[2], count[3], count[4], minbits, max);
@@ -521,7 +521,7 @@ int ff_vlc_init_multi_from_lengths(VLC *vlc, VLC_MULTI *multi, int nb_bits, int
 {
     VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf;
     uint64_t code;
-    int ret, j, len_max = FFMIN(32, 3 * nb_bits);
+    int ret, j, len_max = FFMINI(32, 3 * nb_bits);
 
     ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags);
     if (ret < 0)
diff --git a/libavcodec/vmixdec.c b/libavcodec/vmixdec.c
index 46d817c7f3a..bcfd0b79f18 100644
--- a/libavcodec/vmixdec.c
+++ b/libavcodec/vmixdec.c
@@ -238,7 +238,7 @@ static int decode_frame(AVCodecContext *avctx,
     if (s->lshift > 31)
         return AVERROR_INVALIDDATA;
 
-    q = quality[FFMIN(avpkt->data[offset - 2], FF_ARRAY_ELEMS(quality)-1)];
+    q = quality[FFMINI(avpkt->data[offset - 2], FF_ARRAY_ELEMS(quality)-1)];
     for (int n = 0; n < 64; n++)
         s->factors[n] = quant[n] * q;
 
diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index 3d859975763..f07174455df 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -209,7 +209,7 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
             int x1 = list[pos].x;
             int y1 = y_list[pos] * multiplier;
             if (lx < samples)
-                render_line(lx, ly, FFMIN(x1,samples), y1, out);
+                render_line(lx, ly, FFMINI(x1,samples), y1, out);
             lx = x1;
             ly = y1;
         }
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index adbd7261832..f3a87495dcd 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -722,7 +722,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
         res_setup->partition_size = get_bits(gb, 24) + 1;
         /* Validations to prevent a buffer overflow later. */
         if (res_setup->begin>res_setup->end ||
-            (res_setup->end-res_setup->begin) / res_setup->partition_size > FFMIN(V_MAX_PARTITIONS, 65535)) {
+            (res_setup->end-res_setup->begin) / res_setup->partition_size > FFMINI(V_MAX_PARTITIONS, 65535)) {
             av_log(vc->avctx, AV_LOG_ERROR,
                    "partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n",
                    res_setup->type, res_setup->begin, res_setup->end,
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 99ac72c9100..f47b4f7796e 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -343,7 +343,7 @@ static int create_vorbis_context(vorbis_enc_context *venc,
     for (i = 0; i < fc->partitions; i++) {
         static const int a[] = {0, 1, 2, 2, 3, 3, 4, 4};
         fc->partition_to_class[i] = a[i];
-        fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[i]);
+        fc->nclasses = FFMAXI(fc->nclasses, fc->partition_to_class[i]);
     }
     fc->nclasses++;
     fc->classes = av_calloc(fc->nclasses, sizeof(vorbis_enc_floor_class));
@@ -544,7 +544,7 @@ static void put_codebook_header(PutBitContext *pb, vorbis_enc_codebook *cb)
         int bits = ilog(cb->quantlist[0]);
 
         for (i = 1; i < tmp; i++)
-            bits = FFMAX(bits, ilog(cb->quantlist[i]));
+            bits = FFMAXI(bits, ilog(cb->quantlist[i]));
 
         put_float(pb, cb->min);
         put_float(pb, cb->delta);
@@ -759,8 +759,8 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out)
 
 static float get_floor_average(vorbis_enc_floor * fc, float *coeffs, int i)
 {
-    int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
-    int end   = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
+    int begin = fc->list[fc->list[FFMAXI(i-1, 0)].sort].x;
+    int end   = fc->list[fc->list[FFMINI(i+1, fc->values - 1)].sort].x;
     int j;
     float average = 0;
 
@@ -824,7 +824,7 @@ static int floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc,
                                      fc->list[i].x);
         int highroom = range - predicted;
         int lowroom = predicted;
-        int room = FFMIN(highroom, lowroom);
+        int room = FFMINI(highroom, lowroom);
         if (predicted == posts[i]) {
             coded[i] = 0; // must be used later as flag!
             continue;
@@ -930,8 +930,8 @@ static int residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc,
         float max1 = 0.0, max2 = 0.0;
         int s = rc->begin + p * psize;
         for (k = s; k < s + psize; k += 2) {
-            max1 = FFMAX(max1, fabs(coeffs[          k / real_ch]));
-            max2 = FFMAX(max2, fabs(coeffs[samples + k / real_ch]));
+            max1 = FFMAXD(max1, fabs(coeffs[          k / real_ch]));
+            max2 = FFMAXD(max2, fabs(coeffs[samples + k / real_ch]));
         }
 
         for (i = 0; i < rc->classifications - 1; i++)
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 3089499a0f4..fb6a9144223 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -1946,7 +1946,7 @@ static void await_reference_row(Vp3DecodeContext *s, const Vp3Fragment *fragment
         ref_frame = &s->last_frame;
 
     ref_row = y + (motion_y >> 1);
-    ref_row = FFMAX(FFABS(ref_row), ref_row + 8 + border);
+    ref_row = FFMAXI(FFABS(ref_row), ref_row + 8 + border);
 
     ff_progress_frame_await(ref_frame, ref_row);
 }
@@ -1987,10 +1987,10 @@ static int vp4_mc_loop_filter(Vp3DecodeContext *s, int plane, int motion_x, int
         y--;
 
         if (x_subpel)
-            x = FFMIN(x, x + FFSIGN(motion_x));
+            x = FFMINI(x, x + FFSIGN(motion_x));
 
         if (y_subpel)
-            y = FFMIN(y, y + FFSIGN(motion_y));
+            y = FFMINI(y, y + FFSIGN(motion_y));
 
         x2 = x + block_width;
         y2 = y + block_width;
@@ -2243,7 +2243,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
             // Filter up to the last row in the superblock row
             if (s->version < 2 && !s->skip_loop_filter)
                 apply_loop_filter(s, plane, 4 * sb_y - !!sb_y,
-                                  FFMIN(4 * sb_y + 3, fragment_height - 1));
+                                  FFMINI(4 * sb_y + 3, fragment_height - 1));
         }
     }
 
@@ -2255,7 +2255,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
      *     dispatch (slice - 1);
      */
 
-    vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) - 16,
+    vp3_draw_horiz_band(s, FFMINI((32 << s->chroma_y_shift) * (slice + 1) - 16,
                                  s->height - 16));
 }
 
@@ -2313,7 +2313,7 @@ static av_cold int allocate_tables(AVCodecContext *avctx)
     c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
 
     /* superblock_coding is used by unpack_superblocks (VP3/Theora) and vp4_unpack_macroblocks (VP4) */
-    s->superblock_coding = av_mallocz(FFMAX(s->superblock_count, s->yuv_macroblock_count));
+    s->superblock_coding = av_mallocz(FFMAXI(s->superblock_count, s->yuv_macroblock_count));
     s->all_fragments     = av_calloc(s->fragment_count, sizeof(*s->all_fragments));
 
     s-> kf_coded_fragment_list = av_calloc(s->fragment_count, sizeof(int));
diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c
index 77b479471be..aaa0e5066a1 100644
--- a/libavcodec/vp5.c
+++ b/libavcodec/vp5.c
@@ -252,7 +252,7 @@ static int vp5_parse_coeff(VP56Context *s)
             model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx];
         }
 
-        ctx_last = FFMIN(s->coeff_ctx_last[ff_vp56_b6to4[b]], 24);
+        ctx_last = FFMINI(s->coeff_ctx_last[ff_vp56_b6to4[b]], 24);
         s->coeff_ctx_last[ff_vp56_b6to4[b]] = coeff_idx;
         if (coeff_idx < ctx_last)
             for (i=coeff_idx; i<=ctx_last; i++)
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 48ff9da8189..88129a81e89 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -474,10 +474,10 @@ static int vp6_parse_coeff_huffman(VP56Context *s)
             coeff_idx+=run;
             if (coeff_idx >= 64)
                 break;
-            cg = FFMIN(vp6_coeff_groups[coeff_idx], 3);
+            cg = FFMINI(vp6_coeff_groups[coeff_idx], 3);
             vlc_coeff = &s->ract_vlc[pt][ct][cg];
         }
-        s->idct_selector[b] = model->coeff_index_to_idct_selector[FFMIN(coeff_idx, 63)];
+        s->idct_selector[b] = model->coeff_index_to_idct_selector[FFMINI(coeff_idx, 63)];
     }
     return 0;
 }
@@ -559,7 +559,7 @@ static int vp6_parse_coeff(VP56Context *s)
 
         s->left_block[ff_vp56_b6to4[b]].not_null_dc =
         s->above_blocks[s->above_block_idx[b]].not_null_dc = !!s->block_coeff[b][0];
-        s->idct_selector[b] = model->coeff_index_to_idct_selector[FFMIN(coeff_idx, 63)];
+        s->idct_selector[b] = model->coeff_index_to_idct_selector[FFMINI(coeff_idx, 63)];
     }
     return 0;
 }
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index ed346ab2edb..e9bd15cee5a 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -368,7 +368,7 @@ static void vp7_get_quants(VP8Context *s)
     s->qmat[0].luma_qmul[1]    =       vp7_yac_qlookup[yac_qi];
     s->qmat[0].luma_dc_qmul[0] =       vp7_y2dc_qlookup[y2dc_qi];
     s->qmat[0].luma_dc_qmul[1] =       vp7_y2ac_qlookup[y2ac_qi];
-    s->qmat[0].chroma_qmul[0]  = FFMIN(vp7_ydc_qlookup[uvdc_qi], 132);
+    s->qmat[0].chroma_qmul[0]  = FFMINI(vp7_ydc_qlookup[uvdc_qi], 132);
     s->qmat[0].chroma_qmul[1]  =       vp7_yac_qlookup[uvac_qi];
 }
 
@@ -400,8 +400,8 @@ static void vp8_get_quants(VP8Context *s)
         s->qmat[i].chroma_qmul[0]  = vp8_dc_qlookup[av_clip_uintp2(base_qi + s->quant.uvdc_delta, 7)];
         s->qmat[i].chroma_qmul[1]  = vp8_ac_qlookup[av_clip_uintp2(base_qi + s->quant.uvac_delta, 7)];
 
-        s->qmat[i].luma_dc_qmul[1] = FFMAX(s->qmat[i].luma_dc_qmul[1], 8);
-        s->qmat[i].chroma_qmul[0]  = FFMIN(s->qmat[i].chroma_qmul[0], 132);
+        s->qmat[i].luma_dc_qmul[1] = FFMAXI(s->qmat[i].luma_dc_qmul[1], 8);
+        s->qmat[i].chroma_qmul[0]  = FFMINI(s->qmat[i].chroma_qmul[0], 132);
     }
 }
 
@@ -2163,9 +2163,9 @@ void filter_level_for_mb(const VP8Context *s, const VP8Macroblock *mb,
     interior_limit = filter_level;
     if (s->filter.sharpness) {
         interior_limit >>= (s->filter.sharpness + 3) >> 2;
-        interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness);
+        interior_limit = FFMINI(interior_limit, 9 - s->filter.sharpness);
     }
-    interior_limit = FFMAX(interior_limit, 1);
+    interior_limit = FFMAXI(interior_limit, 1);
 
     f->filter_level = filter_level;
     f->inner_limit = interior_limit;
@@ -2776,7 +2776,7 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame,
         if (avctx->active_thread_type == FF_THREAD_FRAME)
             num_jobs = 1;
         else
-            num_jobs = FFMIN(s->num_coeff_partitions, avctx->thread_count);
+            num_jobs = FFMINI(s->num_coeff_partitions, avctx->thread_count);
         s->num_jobs   = num_jobs;
         s->curframe   = curframe;
         s->prev_frame = prev_frame;
diff --git a/libavcodec/vp8dsp.c b/libavcodec/vp8dsp.c
index 88bb67f78d5..b46485cd76d 100644
--- a/libavcodec/vp8dsp.c
+++ b/libavcodec/vp8dsp.c
@@ -276,12 +276,12 @@ static av_always_inline void filter_common(uint8_t *p, ptrdiff_t stride,
 
     // We deviate from the spec here with c(a+3) >> 3
     // since that's what libvpx does.
-    f1 = FFMIN(a + 4, 127) >> 3;
+    f1 = FFMINI(a + 4, 127) >> 3;
 
     if (is_vp7)
         f2 = f1 - ((a & 7) == 4);
     else
-        f2 = FFMIN(a + 3, 127) >> 3;
+        f2 = FFMINI(a + 3, 127) >> 3;
 
     // Despite what the spec says, we do need to clamp here to
     // be bitexact with libvpx.
diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 7310ba15479..a93a02467c7 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -285,7 +285,7 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
         FFVkBuffer *new_buf;
 
         /* No point in requesting anything smaller. */
-        size_t buf_size = FFMAX(new_size, 1024*1024);
+        size_t buf_size = FFMAXI(new_size, 1024*1024);
 
         /* Align buffer to nearest power of two. Makes fragmentation management
          * easier, and gives us ample headroom. */
@@ -1241,9 +1241,9 @@ int ff_vk_decode_init(AVCodecContext *avctx)
      * for a majority of streams. */
     async_depth = 2*ctx->qf->num;
     /* We don't need more than 2 per thread context */
-    async_depth = FFMIN(async_depth, 2*avctx->thread_count);
+    async_depth = FFMINI(async_depth, 2*avctx->thread_count);
     /* Make sure there are enough async contexts for each thread */
-    async_depth = FFMAX(async_depth, avctx->thread_count);
+    async_depth = FFMAXI(async_depth, avctx->thread_count);
 
     err = ff_vk_exec_pool_init(s, ctx->qf, &ctx->exec_pool,
                                async_depth, 0, 0, 0, profile);
diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c
index 122dd34f4c9..7384b5b11e6 100644
--- a/libavcodec/vulkan_encode.c
+++ b/libavcodec/vulkan_encode.c
@@ -500,7 +500,7 @@ static int vulkan_encode_output(AVCodecContext *avctx,
             ctx->caps.minBitstreamBufferOffsetAlignment && offs &&
             (FFALIGN(offs, ctx->s.props.properties.limits.nonCoherentAtomSize) != offs)) {
             offs -= ctx->s.props.properties.limits.nonCoherentAtomSize;
-            offs = FFALIGN(FFMAX(offs, 0), ctx->s.props.properties.limits.nonCoherentAtomSize);
+            offs = FFALIGN(FFMAXI(offs, 0), ctx->s.props.properties.limits.nonCoherentAtomSize);
         }
 
         invalidate_buf = (VkMappedMemoryRange) {
diff --git a/libavcodec/vulkan_encode_h265.c b/libavcodec/vulkan_encode_h265.c
index d81d2de95a5..96392aef9ff 100644
--- a/libavcodec/vulkan_encode_h265.c
+++ b/libavcodec/vulkan_encode_h265.c
@@ -229,26 +229,26 @@ static int vk_enc_h265_update_pic_info(AVCodecContext *avctx,
                 for (int i = 0; i < 3; i++) {
                     const int j = mapping[i];
                     mdcv->display_primaries_x[i] =
-                        FFMIN(lrint(chroma_den *
+                        FFMINI(lrint(chroma_den *
                                     av_q2d(mdm->display_primaries[j][0])),
                               chroma_den);
                     mdcv->display_primaries_y[i] =
-                        FFMIN(lrint(chroma_den *
+                        FFMINI(lrint(chroma_den *
                                     av_q2d(mdm->display_primaries[j][1])),
                               chroma_den);
                 }
 
                 mdcv->white_point_x =
-                    FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[0])),
+                    FFMINI(lrint(chroma_den * av_q2d(mdm->white_point[0])),
                           chroma_den);
                 mdcv->white_point_y =
-                    FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[1])),
+                    FFMINI(lrint(chroma_den * av_q2d(mdm->white_point[1])),
                           chroma_den);
 
                 mdcv->max_display_mastering_luminance =
                     lrint(luma_den * av_q2d(mdm->max_luminance));
                 mdcv->min_display_mastering_luminance =
-                    FFMIN(lrint(luma_den * av_q2d(mdm->min_luminance)),
+                    FFMINI(lrint(luma_den * av_q2d(mdm->min_luminance)),
                           mdcv->max_display_mastering_luminance);
 
                 hp->units_needed |= UNIT_SEI_MASTERING_DISPLAY;
@@ -265,8 +265,8 @@ static int vk_enc_h265_update_pic_info(AVCodecContext *avctx,
             AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data;
             SEIRawContentLightLevelInfo *clli = &enc->sei_content_light_level;
 
-            clli->max_content_light_level     = FFMIN(clm->MaxCLL,  65535);
-            clli->max_pic_average_light_level = FFMIN(clm->MaxFALL, 65535);
+            clli->max_content_light_level     = FFMINI(clm->MaxCLL,  65535);
+            clli->max_pic_average_light_level = FFMINI(clm->MaxFALL, 65535);
 
             hp->units_needed |= UNIT_SEI_CONTENT_LIGHT_LEVEL;
         }
@@ -809,9 +809,9 @@ static av_cold int init_sequence_headers(AVCodecContext *avctx)
     units->raw_sps.sps_temporal_mvp_enabled_flag = 0;
 
     if (base_ctx->gop_size & base_ctx->gop_size - 1 == 0)
-        units->raw_sps.log2_max_pic_order_cnt_lsb_minus4 = FFMAX(av_log2(base_ctx->gop_size) - 4, 0);
+        units->raw_sps.log2_max_pic_order_cnt_lsb_minus4 = FFMAXI(av_log2(base_ctx->gop_size) - 4, 0);
     else
-        units->raw_sps.log2_max_pic_order_cnt_lsb_minus4 = FFMAX(av_log2(base_ctx->gop_size) - 3, 0);
+        units->raw_sps.log2_max_pic_order_cnt_lsb_minus4 = FFMAXI(av_log2(base_ctx->gop_size) - 3, 0);
 
     return 0;
 }
diff --git a/libavcodec/vulkan_ffv1.c b/libavcodec/vulkan_ffv1.c
index c839f4c3879..7808600ec73 100644
--- a/libavcodec/vulkan_ffv1.c
+++ b/libavcodec/vulkan_ffv1.c
@@ -164,7 +164,7 @@ static int vk_ffv1_start_frame(AVCodecContext          *avctx,
 
     max_contexts = 0;
     for (int i = 0; i < f->quant_table_count; i++)
-        max_contexts = FFMAX(f->context_count[i], max_contexts);
+        max_contexts = FFMAXI(f->context_count[i], max_contexts);
 
     /* Allocate slice buffer data */
     if (f->ac == AC_GOLOMB_RICE)
@@ -736,7 +736,7 @@ static int init_reset_shader(FFV1Context *f, FFVulkanContext *s,
     uint8_t *spv_data;
     size_t spv_len;
     void *spv_opaque = NULL;
-    int wg_dim = FFMIN(s->props.properties.limits.maxComputeWorkGroupSize[0], 1024);
+    int wg_dim = FFMINI(s->props.properties.limits.maxComputeWorkGroupSize[0], 1024);
 
     RET(ff_vk_shader_init(s, shd, "ffv1_dec_reset",
                           VK_SHADER_STAGE_COMPUTE_BIT,
diff --git a/libavcodec/vvc/cabac.c b/libavcodec/vvc/cabac.c
index 6847ce59aff..5e566c9c48c 100644
--- a/libavcodec/vvc/cabac.c
+++ b/libavcodec/vvc/cabac.c
@@ -1028,7 +1028,7 @@ int ff_vvc_sao_band_position_decode(VVCLocalContext *lc)
 int ff_vvc_sao_offset_abs_decode(VVCLocalContext *lc)
 {
     int i = 0;
-    const int length = (1 << (FFMIN(lc->fc->ps.sps->bit_depth, 10) - 5)) - 1;
+    const int length = (1 << (FFMINI(lc->fc->ps.sps->bit_depth, 10) - 5)) - 1;
 
     while (i < length && get_cabac_bypass(&lc->ep->cc))
         i++;
@@ -1592,7 +1592,7 @@ int ff_vvc_sym_mvd_flag(VVCLocalContext *lc)
 int ff_vvc_ref_idx_lx(VVCLocalContext *lc, const uint8_t nb_refs)
 {
     const int c_max = nb_refs - 1;
-    const int max_ctx = FFMIN(c_max, 2);
+    const int max_ctx = FFMINI(c_max, 2);
     int i = 0;
 
     while (i < max_ctx && GET_CABAC(REF_IDX_LX + i))
diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index ba4c89b1d1b..f99d34fe75c 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -46,8 +46,8 @@ static void set_tb_size(const VVCFrameContext *fc, const TransformBlock *tb)
     const int hs        = fc->ps.sps->hshift[tb->c_idx];
     const int vs        = fc->ps.sps->vshift[tb->c_idx];
     const int is_chroma = tb->c_idx != 0;
-    const int width     = FFMAX(1, tb->tb_width >> (MIN_TU_LOG2 - hs));
-    const int end       = y_tb + FFMAX(1, tb->tb_height >> (MIN_TU_LOG2 - vs));
+    const int width     = FFMAXI(1, tb->tb_width >> (MIN_TU_LOG2 - hs));
+    const int end       = y_tb + FFMAXI(1, tb->tb_height >> (MIN_TU_LOG2 - vs));
 
     for (int y = y_tb; y < end; y++) {
         const int off = y * fc->ps.pps->min_tu_width + x_tb;
@@ -65,7 +65,7 @@ static void set_tb_tab(uint8_t *tab, uint8_t v, const VVCFrameContext *fc,
     for (int h = 0; h < height; h += MIN_TU_SIZE) {
         const int y = (tb->y0 + h) >> MIN_TU_LOG2;
         const int off = y * fc->ps.pps->min_tu_width + (tb->x0 >> MIN_TU_LOG2);
-        const int w = FFMAX(1, width >> MIN_TU_LOG2);
+        const int w = FFMAXI(1, width >> MIN_TU_LOG2);
         memset(tab + off, v, w);
     }
 }
@@ -590,7 +590,7 @@ static void can_split(const VVCLocalContext *lc, int x0, int y0,int cb_width, in
     }
     if (cb_width > max_bt_size || cb_height > max_bt_size)
         *btv = *bth = 0;
-    max_tt_size = FFMIN(64, max_tt_size);
+    max_tt_size = FFMINI(64, max_tt_size);
     if (cb_width > max_tt_size || cb_height > max_tt_size)
         *ttv = *tth = 0;
     if (mtt_depth >= max_mtt_depth)
@@ -741,8 +741,8 @@ static enum IntraPredMode luma_intra_pred_mode(VVCLocalContext* lc, const int in
             cand[3] = 2 + ((a + 60) % 64);
             cand[4] = 2 + (a % 64);
         } else {
-            const int minab = FFMIN(a, b);
-            const int maxab = FFMAX(a, b);
+            const int minab = FFMINI(a, b);
+            const int maxab = FFMAXI(a, b);
             if (a > INTRA_DC && b > INTRA_DC) {
                 const int diff = maxab - minab;
                 cand[0] = a;
@@ -805,7 +805,7 @@ static int lfnst_idx_decode(VVCLocalContext *lc)
 
     memset(cu->apply_lfnst_flag, 0, sizeof(cu->apply_lfnst_flag));
 
-    if (!sps->r->sps_lfnst_enabled_flag || cu->pred_mode != MODE_INTRA || FFMAX(cb_width, cb_height) > sps->max_tb_size_y)
+    if (!sps->r->sps_lfnst_enabled_flag || cu->pred_mode != MODE_INTRA || FFMAXI(cb_width, cb_height) > sps->max_tb_size_y)
         return 0;
 
     while (tu) {
@@ -826,7 +826,7 @@ static int lfnst_idx_decode(VVCLocalContext *lc)
         lfnst_width = vs ? cb_width / cu->num_intra_subpartitions : cb_width;
         lfnst_height = hs ? cb_height / cu->num_intra_subpartitions : cb_height;
     }
-    min_lfnst = FFMIN(lfnst_width, lfnst_height);
+    min_lfnst = FFMINI(lfnst_width, lfnst_height);
     if (tree_type != DUAL_TREE_CHROMA && cu->intra_mip_flag && min_lfnst < 16)
         return 0;
 
@@ -852,7 +852,7 @@ static MtsIdx mts_idx_decode(VVCLocalContext *lc)
     const uint8_t transform_skip_flag = cu->tus.head->tbs[0].ts; //fix me
     int mts_idx = MTS_DCT2_DCT2;
     if (cu->tree_type != DUAL_TREE_CHROMA && !cu->lfnst_idx &&
-        !transform_skip_flag && FFMAX(cb_width, cb_height) <= 32 &&
+        !transform_skip_flag && FFMAXI(cb_width, cb_height) <= 32 &&
         cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag &&
         lc->parse.mts_zero_out_sig_coeff_flag && !lc->parse.mts_dc_only) {
         if ((cu->pred_mode == MODE_INTER && sps->r->sps_explicit_mts_inter_enabled_flag) ||
@@ -1984,7 +1984,7 @@ static int palette_subblock_data(VVCLocalContext *lc,
     TransformUnit *tu    = cu->tus.head;
     const VVCSPS *sps    = lc->fc->ps.sps;
     const int min_pos    = subset_id << 4;
-    const int max_pos    = FFMIN(min_pos + 16, cu->cb_width * cu->cb_height);
+    const int max_pos    = FFMINI(min_pos + 16, cu->cb_width * cu->cb_height);
     const int wmask      = cu->cb_width  - 1;
     const int hmask      = cu->cb_height - 1;
     const int wlog2      = av_log2(cu->cb_width);
@@ -2598,7 +2598,7 @@ static void hls_sao(VVCLocalContext *lc, const int rx, const int ry)
             } else if (sao->offset_sign[c_idx][i]) {
                 sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1];
             }
-            sao->offset_val[c_idx][i + 1] *= 1 << (fc->ps.sps->bit_depth - FFMIN(10, fc->ps.sps->bit_depth));
+            sao->offset_val[c_idx][i + 1] *= 1 << (fc->ps.sps->bit_depth - FFMINI(10, fc->ps.sps->bit_depth));
         }
     }
 }
@@ -2731,7 +2731,7 @@ static void cu_get_max_y(const CodingUnit *cu, int max_y[2][VVC_MAX_REF_ENTRIES]
             const int idx       = mvf->ref_idx[lx];
             const int y         = pred_get_y(lc, cu->y0, mvf->mv + lx, cu->cb_height);
 
-            max_y[lx][idx]      = FFMAX(max_y[lx][idx], y);
+            max_y[lx][idx]      = FFMAXI(max_y[lx][idx], y);
         }
     } else {
         const MotionInfo *mi    = &pu->mi;
@@ -2749,7 +2749,7 @@ static void cu_get_max_y(const CodingUnit *cu, int max_y[2][VVC_MAX_REF_ENTRIES]
                         const int idx   = mvf->ref_idx[lx];
                         const int y     = pred_get_y(lc, y0, mvf->mv + lx, sbh);
 
-                        max_y[lx][idx]  = FFMAX(max_y[lx][idx], y + max_dmvr_off);
+                        max_y[lx][idx]  = FFMAXI(max_y[lx][idx], y + max_dmvr_off);
                     }
                 }
             }
@@ -2822,9 +2822,9 @@ void ff_vvc_decode_neighbour(VVCLocalContext *lc, const int x_ctb, const int y_c
     lc->end_of_tiles_x = fc->ps.pps->width;
     lc->end_of_tiles_y = fc->ps.pps->height;
     if (fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx + 1])
-        lc->end_of_tiles_x = FFMIN(x_ctb + ctb_size, lc->end_of_tiles_x);
+        lc->end_of_tiles_x = FFMINI(x_ctb + ctb_size, lc->end_of_tiles_x);
     if (fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry + 1])
-        lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, lc->end_of_tiles_y);
+        lc->end_of_tiles_y = FFMINI(y_ctb + ctb_size, lc->end_of_tiles_y);
 
     lc->boundary_flags = 0;
     if (rx > 0 && fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx - 1])
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 49ba47d5d42..18af5786a3e 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -1114,7 +1114,7 @@ static av_cold int vvc_decode_init(AVCodecContext *avctx)
     VVCContext *s                  = avctx->priv_data;
     static AVOnce init_static_once = AV_ONCE_INIT;
     const int cpu_count            = av_cpu_count();
-    const int delayed              = FFMIN(cpu_count, VVC_MAX_DELAYED_FRAMES);
+    const int delayed              = FFMINI(cpu_count, VVC_MAX_DELAYED_FRAMES);
     int thread_count               = avctx->thread_count ? avctx->thread_count : delayed;
     int ret;
 
diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 3815668bcf5..93f397a7656 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -164,8 +164,8 @@ static void sao_copy_ctb_to_hv(VVCLocalContext *lc, const int rx, const int ry,
         const ptrdiff_t src_stride = fc->frame->linesize[c_idx];
         const int ctb_size_h       = ctb_size_y >> fc->ps.sps->hshift[c_idx];
         const int ctb_size_v       = ctb_size_y >> fc->ps.sps->vshift[c_idx];
-        const int width            = FFMIN(ctb_size_h, (fc->ps.pps->width  >> fc->ps.sps->hshift[c_idx]) - x);
-        const int height           = FFMIN(ctb_size_v, (fc->ps.pps->height >> fc->ps.sps->vshift[c_idx]) - y);
+        const int width            = FFMINI(ctb_size_h, (fc->ps.pps->width  >> fc->ps.sps->hshift[c_idx]) - x);
+        const int height           = FFMINI(ctb_size_v, (fc->ps.pps->height >> fc->ps.sps->vshift[c_idx]) - y);
         const uint8_t *src         = POS(c_idx, x0, y0);
         copy_ctb_to_hv(fc, src, src_stride, x, y, width, height, c_idx, rx, ry, top);
     }
@@ -339,8 +339,8 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x0, int y0)
         const int hs                     = sps->hshift[c_idx];
         const int vs                     = sps->vshift[c_idx];
         const int ps                     = sps->pixel_shift;
-        const int width                  = FFMIN(sps->ctb_size_y, fc->ps.pps->width  - x0) >> hs;
-        const int height                 = FFMIN(sps->ctb_size_y, fc->ps.pps->height - y0) >> vs;
+        const int width                  = FFMINI(sps->ctb_size_y, fc->ps.pps->width  - x0) >> hs;
+        const int height                 = FFMINI(sps->ctb_size_y, fc->ps.pps->height - y0) >> vs;
         const int tab                    = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
         const int sao_eo_class           = sao->eo_class[c_idx];
 
@@ -473,9 +473,9 @@ static void derive_max_filter_length_luma(const VVCFrameContext *fc, const int q
             *max_len_q = 7;
     }
     if (has_subblock)
-        *max_len_q = FFMIN(5, *max_len_q);
+        *max_len_q = FFMINI(5, *max_len_q);
     if (fc->tab.msf[off_p] || fc->tab.iaf[off_p])
-        *max_len_p = FFMIN(5, *max_len_p);
+        *max_len_p = FFMINI(5, *max_len_p);
 }
 
 static void vvc_deblock_subblock_bs(const VVCLocalContext *lc,
@@ -780,8 +780,8 @@ static void vvc_deblock(const VVCLocalContext *lc, int x0, int y0, const int rs,
     const int c_end            = sps->r->sps_chroma_format_idc ? VVC_MAX_SAMPLE_ARRAYS : 1;
     const int ctb_size         = fc->ps.sps->ctb_size_y;
     const DBParams *params     = fc->tab.deblock + rs;
-    int x_end                  = FFMIN(x0 + ctb_size, fc->ps.pps->width);
-    int y_end                  = FFMIN(y0 + ctb_size, fc->ps.pps->height);
+    int x_end                  = FFMINI(x0 + ctb_size, fc->ps.pps->width);
+    int y_end                  = FFMINI(y0 + ctb_size, fc->ps.pps->height);
     const int log2_min_cb_size = fc->ps.sps->min_cb_log2_size_y;
     const int min_cb_width     = fc->ps.pps->min_cb_width;
 
@@ -1091,8 +1091,8 @@ void ff_vvc_alf_copy_ctu_to_hv(VVCLocalContext* lc, const int x0, const int y0)
         const int vs     = fc->ps.sps->vshift[c_idx];
         const int x      = x0 >> hs;
         const int y      = y0 >> vs;
-        const int width  = FFMIN(fc->ps.pps->width - x0, ctb_size_y) >> hs;
-        const int height = FFMIN(fc->ps.pps->height - y0, ctb_size_y) >> vs;
+        const int width  = FFMINI(fc->ps.pps->width - x0, ctb_size_y) >> hs;
+        const int height = FFMINI(fc->ps.pps->height - y0, ctb_size_y) >> vs;
 
         const int src_stride = fc->frame->linesize[c_idx];
         uint8_t *src = POS(c_idx, x0, y0);
@@ -1167,7 +1167,7 @@ static void alf_get_subblocks(const VVCLocalContext *lc, VVCRect sbs[MAX_VBBS],
     const int ctu_size_y = sps->ctb_size_y;
     const int vb_pos[]   = { get_virtual_boundary(fc, ry, 0),  get_virtual_boundary(fc, rx, 1) };
     const int has_vb[]   = { vb_pos[0] > y0, vb_pos[1] > x0 };
-    const VVCRect b      = { x0, y0, FFMIN(x0 + ctu_size_y, pps->width), FFMIN(y0 + ctu_size_y, pps->height) };
+    const VVCRect b      = { x0, y0, FFMINI(x0 + ctu_size_y, pps->width), FFMINI(y0 + ctu_size_y, pps->height) };
     int edges[MAX_EDGES] = { !rx, !ry, rx == pps->ctb_width - 1, ry == pps->ctb_height - 1 };
     int i                = 0;
 
@@ -1242,8 +1242,8 @@ void ff_vvc_lmcs_filter(const VVCLocalContext *lc, const int x, const int y)
     const SliceContext *sc = lc->sc;
     const VVCFrameContext *fc = lc->fc;
     const int ctb_size = fc->ps.sps->ctb_size_y;
-    const int width    = FFMIN(fc->ps.pps->width  - x, ctb_size);
-    const int height   = FFMIN(fc->ps.pps->height - y, ctb_size);
+    const int width    = FFMINI(fc->ps.pps->width  - x, ctb_size);
+    const int height   = FFMINI(fc->ps.pps->height - y, ctb_size);
     uint8_t *data      = POS(LUMA, x, y);
     if (sc->sh.r->sh_lmcs_used_flag)
         fc->vvcdsp.lmcs.filter(data, fc->frame->linesize[LUMA], width, height, &fc->ps.lmcs.inv_lut);
diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 64a9dd1e46d..f9b7f6393b6 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -46,10 +46,10 @@ static void subpic_get_rect(VVCRect *r, const VVCFrame *src_frame, const int sub
 // clip to subblock and subpicture process in 8.5.6.3.2 Luma sample interpolation filtering process
 static void clip_to_subpic(int *x_off, int *y_off, int *pic_width, int *pic_height, const VVCRect *subpic, const VVCRect *sb, const int dmvr_clip)
 {
-    const int l = dmvr_clip ? FFMIN(FFMAX(subpic->l, sb->l), subpic->r - 1) : subpic->l;
-    const int t = dmvr_clip ? FFMIN(FFMAX(subpic->t, sb->t), subpic->b - 1) : subpic->t;
-    const int r = dmvr_clip ? FFMAX(FFMIN(subpic->r, sb->r), subpic->l + 1) : subpic->r;
-    const int b = dmvr_clip ? FFMAX(FFMIN(subpic->b, sb->b), subpic->t + 1) : subpic->b;
+    const int l = dmvr_clip ? FFMINI(FFMAXI(subpic->l, sb->l), subpic->r - 1) : subpic->l;
+    const int t = dmvr_clip ? FFMINI(FFMAXI(subpic->t, sb->t), subpic->b - 1) : subpic->t;
+    const int r = dmvr_clip ? FFMAXI(FFMINI(subpic->r, sb->r), subpic->l + 1) : subpic->r;
+    const int b = dmvr_clip ? FFMAXI(FFMINI(subpic->b, sb->b), subpic->t + 1) : subpic->b;
 
     *x_off -= l;
     *y_off -= t;
@@ -126,8 +126,8 @@ static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
     const int subpic_idx       = lc->sc->sh.r->curr_subpic_idx;
     const int extra            = extra_before + extra_after;
     const int dmvr_clip        = x_sb != x_off || y_sb != y_off;
-    const int dmvr_left        = FFMAX(x_off, x_sb) - extra_before;
-    const int dmvr_right       = FFMIN(x_off, x_sb) + block_w + extra_after;
+    const int dmvr_left        = FFMAXI(x_off, x_sb) - extra_before;
+    const int dmvr_right       = FFMINI(x_off, x_sb) + block_w + extra_after;
     const int left             = x_off - extra_before;
     const int top              = y_off - extra_before;
     const int pic_width        = pps->width >> sps->hshift[is_chroma];
diff --git a/libavcodec/vvc/intra.c b/libavcodec/vvc/intra.c
index f56b43be66e..f58d09a03c4 100644
--- a/libavcodec/vvc/intra.c
+++ b/libavcodec/vvc/intra.c
@@ -146,7 +146,7 @@ static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalConte
 
     if (sps->r->sps_mts_enabled_flag) {
         if (cu->isp_split_type != ISP_NO_SPLIT ||
-            (cu->sbt_flag && FFMAX(tb->tb_width, tb->tb_height) <= 32) ||
+            (cu->sbt_flag && FFMAXI(tb->tb_width, tb->tb_height) <= 32) ||
             (!sps->r->sps_explicit_mts_intra_enabled_flag && cu->pred_mode == MODE_INTRA &&
             !cu->lfnst_idx && !cu->intra_mip_flag)) {
             implicit_mts_enabled = 1;
diff --git a/libavcodec/vvc/intra_template.c b/libavcodec/vvc/intra_template.c
index 3ec6c72213e..f616d2262af 100644
--- a/libavcodec/vvc/intra_template.c
+++ b/libavcodec/vvc/intra_template.c
@@ -70,16 +70,16 @@ static av_always_inline int FUNC(cclm_get_select_pos)(const VVCLocalContext *lc,
         num_samp[TOP]  = avail_t ? w : 0;
         num_samp[LEFT] = avail_l ? h : 0;
     } else {
-        num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc,  x, y, w + FFMIN(w, h), 1) : 0;
-        num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMIN(w, h), 1) : 0;
+        num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc,  x, y, w + FFMINI(w, h), 1) : 0;
+        num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMINI(w, h), 1) : 0;
     }
     if (!num_samp[TOP] && !num_samp[LEFT]) {
         return 0;
     }
     for (int i = TOP; i <= LEFT; i++) {
         const int start = num_samp[i] >> (2 + num_is4);
-        const int step  = FFMAX(1, num_samp[i] >> (1 + num_is4)) ;
-        cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1);
+        const int step  = FFMAXI(1, num_samp[i] >> (1 + num_is4)) ;
+        cnt[i] = FFMINI(num_samp[i], (1 + num_is4) << 1);
         for (int c = 0; c < cnt[i]; c++)
             pos[i][c] = start + c * step;
     }
@@ -268,7 +268,7 @@ static av_always_inline void FUNC(cclm_get_params)(const VVCLocalContext *lc,
         v = div_sig_table[norm_diff] | 8;
         add = (1 << y >> 1);
         a[i] = (diffc * v + add) >> y;
-        k[i] = FFMAX(1, 3 + x -y);
+        k[i] = FFMAXI(1, 3 + x -y);
         sign = a[i] < 0 ? -1 : (a[i] > 0);
         a[i] = ((3 + x - y) < 1) ?  sign * 15 : a[i];
         b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]);
@@ -376,7 +376,7 @@ static void FUNC(intra_cclm_pred)(const VVCLocalContext *lc, const int x0, const
 
 static int FUNC(lmcs_sum_samples)(const pixel *start, ptrdiff_t stride, const int avail, const int target_size)
 {
-    const int size = FFMIN(avail, target_size);
+    const int size = FFMINI(avail, target_size);
     int sum = 0;
     for (int i = 0; i < size; i++) {
         sum += *start;
@@ -391,7 +391,7 @@ static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, con
 {
     VVCFrameContext *fc = lc->fc;
     const VVCLMCS *lmcs = &fc->ps.lmcs;
-    const int size_y    = FFMIN(fc->ps.sps->ctb_size_y, 64);
+    const int size_y    = FFMINI(fc->ps.sps->ctb_size_y, 64);
 
     const int x = x0 & ~(size_y - 1);
     const int y = y0 & ~(size_y - 1);
@@ -418,7 +418,7 @@ static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, con
             if (luma < lmcs->pivot[i + 1])
                 break;
         }
-        i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1);
+        i = FFMINI(i, LMCS_MAX_BIN_SIZE - 1);
 
         lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i];
         lc->lmcs.x_vpdu = x;
@@ -554,7 +554,7 @@ do {                                  \
         if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) {
             edge->filter_flag = 0;
         } else {
-            const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18));
+            const int min_dist_ver_hor = FFMINI(abs(mode - 50), abs(mode - 18));
             const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0};
             const int ntbs = (av_log2(w) + av_log2(h)) >> 1;
             edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2];
@@ -565,22 +565,22 @@ do {                                  \
                 if (intra_pred_angle < 0) {
                     pixel *p = top - (ref_idx + 1);
                     for (int x = -h; x < 0; x++) {
-                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h);
+                        const int idx = -1 - ref_idx + FFMINI((x*inv_angle + 256) >> 9, h);
                         p[x] = left[idx];
                     }
                 } else {
-                    for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++)
+                    for (int i = refw; i <= refw + FFMAXI(1, w/h) * ref_idx + 1; i++)
                         top[i] = top[refw - 1];
                 }
             } else {
                 if (intra_pred_angle < 0) {
                     pixel *p = left - (ref_idx + 1);
                     for (int x = -w; x < 0; x++) {
-                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w);
+                        const int idx = -1 - ref_idx + FFMINI((x*inv_angle + 256) >> 9, w);
                         p[x] = top[idx];
                     }
                 } else {
-                    for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++)
+                    for (int i = refh; i <= refh + FFMAXI(1, h/w) * ref_idx + 1; i++)
                         left[i] = left[refh - 1];
                 }
             }
@@ -665,13 +665,13 @@ static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0,
                     if (mode == INTRA_PLANAR || mode == INTRA_DC) {
                         l  = left[y];
                         t = top[x];
-                        wl = 32 >> FFMIN((x << 1) >> scale, 31);
-                        wt = 32 >> FFMIN((y << 1) >> scale, 31);
+                        wl = 32 >> FFMINI((x << 1) >> scale, 31);
+                        wt = 32 >> FFMINI((y << 1) >> scale, 31);
                     } else {
                         l  = left[y] - left[-1] + POS(x,y);
                         t = top[x] - top[-1] + POS(x,y);
-                        wl = (mode == INTRA_VERT) ?  (32 >> FFMIN((x << 1) >> scale, 31)) : 0;
-                        wt = (mode == INTRA_HORZ) ?  (32 >> FFMIN((y << 1) >> scale, 31)) : 0;
+                        wl = (mode == INTRA_VERT) ?  (32 >> FFMINI((x << 1) >> scale, 31)) : 0;
+                        wt = (mode == INTRA_HORZ) ?  (32 >> FFMINI((y << 1) >> scale, 31)) : 0;
                     }
                     val = POS(x, y);
                     pred  = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6);
@@ -828,7 +828,7 @@ static av_always_inline pixel FUNC(pred_dc_val)(const pixel *top, const pixel *l
 {
     pixel dc_val;
     int sum = 0;
-    unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h);
+    unsigned int offset = (w == h) ? (w << 1) : FFMAXI(w, h);
     const int shift = av_log2(offset);
     offset >>= 1;
     if (w >= h) {
@@ -933,7 +933,7 @@ static void FUNC(pred_angular_v)(uint8_t *_src, const uint8_t *_top, const uint8
         }
         if (need_pdpc) {
             int inv_angle_sum = 256 + inv_angle;
-            for (int x = 0; x < FFMIN(w, 3 << nscale); x++) {
+            for (int x = 0; x < FFMINI(w, 3 << nscale); x++) {
                 const pixel l   = left[y + (inv_angle_sum >> 9)];
                 const pixel val = POS(x, y);
                 const int wl    = 32 >> ((x << 1) >> nscale);
@@ -969,7 +969,7 @@ static void FUNC(pred_angular_h)(uint8_t *_src, const uint8_t *_top, const uint8
         int pos = (1 + ref_idx) * intra_pred_angle;
         int wt;
         if (need_pdpc)
-            wt = (32 >> FFMIN(31, (y * 2) >> nscale));
+            wt = (32 >> FFMINI(31, (y * 2) >> nscale));
 
         for (int x = 0; x < w; x++) {
             const int idx  = (pos >> 5) + ref_idx;
diff --git a/libavcodec/vvc/intra_utils.c b/libavcodec/vvc/intra_utils.c
index 7229222b959..bd18d695aee 100644
--- a/libavcodec/vvc/intra_utils.c
+++ b/libavcodec/vvc/intra_utils.c
@@ -53,7 +53,7 @@ int ff_vvc_nscale_derive(const int w, const int h, const int mode)
             side_size = h;
         if (mode <= INTRA_HORZ)
             side_size = w;
-        nscale = FFMIN(2, av_log2(side_size) - av_log2(3 * inv_angle - 2) + 8);
+        nscale = FFMINI(2, av_log2(side_size) - av_log2(3 * inv_angle - 2) + 8);
     }
     return nscale;
 }
@@ -101,22 +101,22 @@ int ff_vvc_get_top_available(const VVCLocalContext *lc, const int x, const int y
     const int log2_ctb_size_v   = sps->ctb_log2_size_y - vs;
     const int end_of_ctb_x      = ((lc->cu->x0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y;
     const int y0b               = av_zero_extend(y, log2_ctb_size_v);
-    const int max_x             = FFMIN(fc->ps.pps->width, end_of_ctb_x) >> hs;
+    const int max_x             = FFMINI(fc->ps.pps->width, end_of_ctb_x) >> hs;
     const ReconstructedArea *a;
     int px = x;
 
     if (!y0b) {
         if (!lc->ctb_up_flag)
             return 0;
-        target_size = FFMIN(target_size, (lc->end_of_tiles_x >> hs) - x);
+        target_size = FFMINI(target_size, (lc->end_of_tiles_x >> hs) - x);
         if (sps->r->sps_entropy_coding_sync_enabled_flag)
-            target_size = FFMIN(target_size, (end_of_ctb_x >> hs) - x);
+            target_size = FFMINI(target_size, (end_of_ctb_x >> hs) - x);
         return target_size;
     }
 
-    target_size = FFMAX(0, FFMIN(target_size, max_x - x));
+    target_size = FFMAXI(0, FFMINI(target_size, max_x - x));
     while (target_size > 0 && (a = get_reconstructed_area(lc, px, y - 1, c_idx))) {
-        const int sz = FFMIN(target_size, a->x + a->w - px);
+        const int sz = FFMINI(target_size, a->x + a->w - px);
         px += sz;
         target_size -= sz;
     }
@@ -132,19 +132,19 @@ int ff_vvc_get_left_available(const VVCLocalContext *lc, const int x, const int
     const int log2_ctb_size_h   =  sps->ctb_log2_size_y - hs;
     const int x0b               = av_zero_extend(x, log2_ctb_size_h);
     const int end_of_ctb_y      = ((lc->cu->y0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y;
-    const int max_y             = FFMIN(fc->ps.pps->height, end_of_ctb_y) >> vs;
+    const int max_y             = FFMINI(fc->ps.pps->height, end_of_ctb_y) >> vs;
     const ReconstructedArea *a;
     int  py = y;
 
     if (!x0b && !lc->ctb_left_flag)
         return 0;
 
-    target_size = FFMAX(0, FFMIN(target_size, max_y - y));
+    target_size = FFMAXI(0, FFMINI(target_size, max_y - y));
     if (!x0b)
         return target_size;
 
     while (target_size > 0 && (a = get_reconstructed_area(lc, x - 1, py, c_idx))) {
-        const int sz = FFMIN(target_size, a->y + a->h - py);
+        const int sz = FFMINI(target_size, a->y + a->h - py);
         py += sz;
         target_size -= sz;
     }
diff --git a/libavcodec/vvc/mvs.c b/libavcodec/vvc/mvs.c
index 2cf67def7be..da9be1d9489 100644
--- a/libavcodec/vvc/mvs.c
+++ b/libavcodec/vvc/mvs.c
@@ -327,10 +327,10 @@ static int is_fallback_mode(const SubblockParams *sp, const PredFlag pred_flag)
     const int c = 4 * (2048 + sp->d_ver_y);
     const int d = 4 * sp->d_ver_x;
     if (pred_flag == PF_BI) {
-        const int max_w4 = FFMAX(0, FFMAX(a, FFMAX(b, a + b)));
-        const int min_w4 = FFMIN(0, FFMIN(a, FFMIN(b, a + b)));
-        const int max_h4 = FFMAX(0, FFMAX(c, FFMAX(d, c + d)));
-        const int min_h4 = FFMIN(0, FFMIN(c, FFMIN(d, c + d)));
+        const int max_w4 = FFMAXI(0, FFMAXI(a, FFMAXI(b, a + b)));
+        const int min_w4 = FFMINI(0, FFMINI(a, FFMINI(b, a + b)));
+        const int max_h4 = FFMAXI(0, FFMAXI(c, FFMAXI(d, c + d)));
+        const int min_h4 = FFMINI(0, FFMINI(c, FFMINI(d, c + d)));
         const int bx_wx4 = ((max_w4 - min_w4) >> 11) + 9;
         const int bx_hx4 = ((max_h4 - min_h4) >> 11) + 9;
         return bx_wx4 * bx_hx4 > 225;
@@ -569,7 +569,7 @@ static int is_a0_available(const VVCLocalContext *lc, const CodingUnit *cu)
     if (!x0b && !lc->ctb_left_flag) {
         cand_bottom_left = 0;
     } else {
-        const int max_y = FFMIN(fc->ps.pps->height, ((cu->y0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y);
+        const int max_y = FFMINI(fc->ps.pps->height, ((cu->y0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y);
         if (cu->y0 + cu->cb_height >= max_y)
             cand_bottom_left = 0;
         else
@@ -779,7 +779,7 @@ static void mv_merge_zero_motion_candidate(const VVCLocalContext *lc, const int
     const VVCSPS *sps             = lc->fc->ps.sps;
     const H266RawSliceHeader *rsh = lc->sc->sh.r;
     const int num_ref_idx         = IS_P(rsh) ?
-        rsh->num_ref_idx_active[L0] : FFMIN(rsh->num_ref_idx_active[L0], rsh->num_ref_idx_active[L1]);
+        rsh->num_ref_idx_active[L0] : FFMINI(rsh->num_ref_idx_active[L0], rsh->num_ref_idx_active[L1]);
     int zero_idx                  = 0;
 
     while (num_cands < sps->max_num_merge_cand) {
@@ -847,7 +847,7 @@ void ff_vvc_luma_mv_merge_gpm(VVCLocalContext *lc, const int merge_gpm_idx[2], M
     const int idx[] = { merge_gpm_idx[0], merge_gpm_idx[1] + (merge_gpm_idx[1] >= merge_gpm_idx[0]) };
 
     ff_vvc_set_neighbour_available(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height);
-    mv_merge_mode(lc, FFMAX(idx[0], idx[1]), cand_list);
+    mv_merge_mode(lc, FFMAXI(idx[0], idx[1]), cand_list);
     memset(mv, 0, 2 * sizeof(*mv));
     for (int i = 0; i < 2; i++) {
         int lx   = idx[i] & 1;
@@ -1026,8 +1026,8 @@ static av_always_inline void sb_clip_location(const VVCLocalContext *lc,
     const int x_end           = pps->subpic_x[subpic_idx] + pps->subpic_width[subpic_idx];
     const int y_end           = pps->subpic_y[subpic_idx] + pps->subpic_height[subpic_idx];
 
-    *x = av_clip(*x + temp_mv->x, x_ctb, FFMIN(x_end - 1, x_ctb + (1 << ctb_log2_size) + 3)) & ~7;
-    *y = av_clip(*y + temp_mv->y, y_ctb, FFMIN(y_end - 1, y_ctb + (1 << ctb_log2_size) - 1)) & ~7;
+    *x = av_clip(*x + temp_mv->x, x_ctb, FFMINI(x_end - 1, x_ctb + (1 << ctb_log2_size) + 3)) & ~7;
+    *y = av_clip(*y + temp_mv->y, y_ctb, FFMINI(y_end - 1, y_ctb + (1 << ctb_log2_size) - 1)) & ~7;
 }
 
 static void sb_temproal_luma_motion(const VVCLocalContext *lc,
@@ -1575,7 +1575,7 @@ static int mvp_history_candidates(const VVCLocalContext *lc,
 
     if (ep->num_hmvp == 0)
         return 0;
-    for (int i = 1; i <= FFMIN(4, ep->num_hmvp); i++) {
+    for (int i = 1; i <= FFMINI(4, ep->num_hmvp); i++) {
         const MvField* h = &ep->hmvp[i - 1];
         for (int j = 0; j < 2; j++) {
             const int ly = (j ? !lx : lx);
diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index d9f46b219af..9fb66acbece 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -84,7 +84,7 @@ static int sps_bit_depth(VVCSPS *sps, void *log_ctx)
     sps->bit_depth = r->sps_bitdepth_minus8 + 8;
     sps->qp_bd_offset = 6 * (sps->bit_depth - 8);
     sps->log2_transform_range =
-        r->sps_extended_precision_flag ? FFMAX(15, FFMIN(20, sps->bit_depth + 6)) : 15;
+        r->sps_extended_precision_flag ? FFMAXI(15, FFMINI(20, sps->bit_depth + 6)) : 15;
     return sps_map_pixel_format(sps, log_ctx);
 }
 
@@ -655,8 +655,8 @@ static void pps_subpic(VVCPPS *pps, const VVCSPS *sps)
         if (rsps->sps_subpic_treated_as_pic_flag[i]) {
             pps->subpic_x[i]      = rsps->sps_subpic_ctu_top_left_x[i] << sps->ctb_log2_size_y;
             pps->subpic_y[i]      = rsps->sps_subpic_ctu_top_left_y[i] << sps->ctb_log2_size_y;
-            pps->subpic_width[i]  = FFMIN(pps->width  - pps->subpic_x[i], (rsps->sps_subpic_width_minus1[i]  + 1) << sps->ctb_log2_size_y);
-            pps->subpic_height[i] = FFMIN(pps->height - pps->subpic_y[i], (rsps->sps_subpic_height_minus1[i] + 1) << sps->ctb_log2_size_y);
+            pps->subpic_width[i]  = FFMINI(pps->width  - pps->subpic_x[i], (rsps->sps_subpic_width_minus1[i]  + 1) << sps->ctb_log2_size_y);
+            pps->subpic_height[i] = FFMINI(pps->height - pps->subpic_y[i], (rsps->sps_subpic_height_minus1[i] + 1) << sps->ctb_log2_size_y);
         } else {
             pps->subpic_x[i]      = 0;
             pps->subpic_y[i]      = 0;
@@ -908,7 +908,7 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266Raw
         uint16_t inv_sample;
         while (i <= lmcs->max_bin_idx && sample >= lmcs->pivot[i + 1])
             i++;
-        i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1);
+        i = FFMINI(i, LMCS_MAX_BIN_SIZE - 1);
 
         inv_sample = lmcs_derive_lut_sample(sample, input_pivot, lmcs->pivot,
             inv_scale_coeff, i, max);
diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 1cfca482047..ebb43423501 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -408,7 +408,7 @@ static int check_candidate_ref(const VVCFrame *frame, const VVCRefPic *refp)
     const VVCFrame *ref = refp->ref;
 
     if (refp->is_scaled) {
-        const int max = FFMAX(8, frame->sps->min_cb_size_y);
+        const int max = FFMAXI(8, frame->sps->min_cb_size_y);
         return frame->ref_width * 2 >= ref->ref_width &&
             frame->ref_height * 2 >= ref->ref_height &&
             frame->ref_width <= ref->ref_width * 8 &&
diff --git a/libavcodec/wavarc.c b/libavcodec/wavarc.c
index 3169a5f0d65..e5d6ffcaa28 100644
--- a/libavcodec/wavarc.c
+++ b/libavcodec/wavarc.c
@@ -167,7 +167,7 @@ static int decode_0cpy(AVCodecContext *avctx,
 {
     const int bits = s->align * 8;
 
-    s->nb_samples = FFMIN(640, get_bits_left(gb) / bits);
+    s->nb_samples = FFMINI(640, get_bits_left(gb) / bits);
 
     switch (avctx->sample_fmt) {
     case AV_SAMPLE_FMT_U8P:
@@ -771,7 +771,7 @@ static int wavarc_decode(AVCodecContext *avctx, AVFrame *frame,
         return pkt->size;
     }
 
-    buf_size = FFMIN(pkt->size, s->max_framesize - s->bitstream_size);
+    buf_size = FFMINI(pkt->size, s->max_framesize - s->bitstream_size);
     input_buf_size = buf_size;
     if (s->bitstream_index + s->bitstream_size + buf_size + AV_INPUT_BUFFER_PADDING_SIZE > s->max_framesize) {
         memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index a89f3d16708..2c29391230d 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -697,7 +697,7 @@ static void decorr_mono_buffer(int32_t *samples, int32_t *outsamples,
     CLEAR(dp);
     dp.value = term;
     dp.delta = pre_delta;
-    decorr_mono(samples, outsamples, FFMIN(2048, nb_samples), &dp, -1);
+    decorr_mono(samples, outsamples, FFMINI(2048, nb_samples), &dp, -1);
     dp.delta = delta;
 
     if (tindex == 0)
@@ -938,7 +938,7 @@ static void analyze_mono(WavPackEncodeContext *s, int32_t *samples, int do_sampl
     int i;
 
     info.log_limit = (((s->flags & MAG_MASK) >> MAG_LSB) + 4) * 256;
-    info.log_limit = FFMIN(6912, info.log_limit);
+    info.log_limit = FFMINI(6912, info.log_limit);
 
     info.nterms = s->num_terms;
 
@@ -1037,7 +1037,7 @@ static int wv_mono(WavPackEncodeContext *s, int32_t *samples,
     }
 
     log_limit = (((s->flags & MAG_MASK) >> MAG_LSB) + 4) * 256;
-    log_limit = FFMIN(6912, log_limit);
+    log_limit = FFMINI(6912, log_limit);
 
     if ((ret = allocate_buffers(s)) < 0)
         return ret;
@@ -1079,7 +1079,7 @@ static int wv_mono(WavPackEncodeContext *s, int32_t *samples,
                 temp_decorr_pass.value = 1;
 
             decorr_mono(s->temp_buffer[j&1][0], s->temp_buffer[~j&1][0],
-                        FFMIN(nb_samples, 2048), &temp_decorr_pass, -1);
+                        FFMINI(nb_samples, 2048), &temp_decorr_pass, -1);
 
             if (j) {
                 CLEAR(temp_decorr_pass.samplesA);
@@ -1514,7 +1514,7 @@ static void decorr_stereo_buffer(WavPackExtraInfo *info,
     dp.value = term;
     dp.delta = pre_delta;
     decorr_stereo(in_left, in_right, out_left, out_right,
-                  FFMIN(2048, nb_samples), &dp, -1);
+                  FFMINI(2048, nb_samples), &dp, -1);
     dp.delta = delta;
 
     if (tindex == 0) {
@@ -1747,7 +1747,7 @@ static void analyze_stereo(WavPackEncodeContext *s,
     info.gt16bit = ((s->flags & MAG_MASK) >> MAG_LSB) >= 16;
 
     info.log_limit = (((s->flags & MAG_MASK) >> MAG_LSB) + 4) * 256;
-    info.log_limit = FFMIN(6912, info.log_limit);
+    info.log_limit = FFMINI(6912, info.log_limit);
 
     info.nterms = s->num_terms;
 
@@ -1829,7 +1829,7 @@ static int wv_stereo(WavPackEncodeContext *s,
     }
 
     log_limit = (((s->flags & MAG_MASK) >> MAG_LSB) + 4) * 256;
-    log_limit = FFMIN(6912, log_limit);
+    log_limit = FFMINI(6912, log_limit);
 
     if (s->joint != -1) {
         force_js =  s->joint;
@@ -1895,7 +1895,7 @@ static int wv_stereo(WavPackEncodeContext *s,
 
                 decorr_stereo(s->temp_buffer[ j&1][0], s->temp_buffer[ j&1][1],
                               s->temp_buffer[~j&1][0], s->temp_buffer[~j&1][1],
-                              FFMIN(2048, nb_samples), &temp_decorr_pass, -1);
+                              FFMINI(2048, nb_samples), &temp_decorr_pass, -1);
 
                 if (j) {
                     CLEAR(temp_decorr_pass.samplesA);
diff --git a/libavcodec/wbmpdec.c b/libavcodec/wbmpdec.c
index 50c729047d4..698865efeed 100644
--- a/libavcodec/wbmpdec.c
+++ b/libavcodec/wbmpdec.c
@@ -40,7 +40,7 @@ static void readbits(uint8_t * dst, int width, int height, int linesize, const u
 {
     int wpad = (width + 7) / 8;
     for (int j = 0; j < height && size > 0; j++) {
-        memcpy(dst, src, FFMIN(wpad, size));
+        memcpy(dst, src, FFMINI(wpad, size));
         src += wpad;
         size -= wpad;
         dst += linesize;
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 7d77d645241..ca4b4f3ee50 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -448,7 +448,7 @@ static int decode_entropy_image(WebPContext *s)
             int p0 = GET_PIXEL_COMP(img->frame, x, y, 1);
             int p1 = GET_PIXEL_COMP(img->frame, x, y, 2);
             int p  = p0 << 8 | p1;
-            max = FFMAX(max, p);
+            max = FFMAXI(max, p);
         }
     }
     s->nb_huffman_groups = max + 1;
@@ -676,7 +676,7 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
             if (distance <= NUM_SHORT_DISTANCES) {
                 int xi = lz77_distance_offsets[distance - 1][0];
                 int yi = lz77_distance_offsets[distance - 1][1];
-                distance = FFMAX(1, xi + yi * width);
+                distance = FFMAXI(1, xi + yi * width);
             } else {
                 distance -= NUM_SHORT_DISTANCES;
             }
@@ -697,8 +697,8 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
                 ref_x = width - distance;
                 ref_y--;
             }
-            ref_x = FFMAX(0, ref_x);
-            ref_y = FFMAX(0, ref_y);
+            ref_x = FFMAXI(0, ref_x);
+            ref_y = FFMAXI(0, ref_y);
 
             if (ref_y == y && ref_x >= x)
                 return AVERROR_INVALIDDATA;
diff --git a/libavcodec/webp_parser.c b/libavcodec/webp_parser.c
index bd5f94dac5c..e43241a1ca7 100644
--- a/libavcodec/webp_parser.c
+++ b/libavcodec/webp_parser.c
@@ -79,7 +79,7 @@ restart:
         ctx->pc.state64 = state;
     } else {
         if (ctx->remaining_size) {
-            i = FFMIN(ctx->remaining_size, buf_size);
+            i = FFMINI(ctx->remaining_size, buf_size);
             ctx->remaining_size -= i;
             if (ctx->remaining_size)
                 goto flush;
@@ -94,7 +94,7 @@ flush:
         return buf_size;
 
     if (next != END_NOT_FOUND && next < 0)
-        ctx->pc.frame_start_found = FFMAX(ctx->pc.frame_start_found - i - 1, 0);
+        ctx->pc.frame_start_found = FFMAXI(ctx->pc.frame_start_found - i - 1, 0);
     else
         ctx->pc.frame_start_found = 0;
 
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 51487b72b5a..337dd62e068 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -102,7 +102,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
     block_align        = avctx->bit_rate * (int64_t) s->frame_len /
                          (avctx->sample_rate * 8);
-    block_align        = FFMIN(block_align, MAX_CODED_SUPERFRAME_SIZE);
+    block_align        = FFMINI(block_align, MAX_CODED_SUPERFRAME_SIZE);
     avctx->block_align = block_align;
     avctx->frame_size = avctx->initial_padding = s->frame_len;
 
@@ -152,7 +152,7 @@ static void init_exp(WMACodecContext *s, int ch, const int *exp_param)
     while (q < q_end) {
         /* XXX: use a table */
         v         = ff_exp10(*exp_param++ *(1.0 / 16.0));
-        max_scale = FFMAX(max_scale, v);
+        max_scale = FFMAXF(max_scale, v);
         n         = *ptr++;
         do {
             *q++ = v;
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 44e5da08abd..2221e8990ad 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1111,7 +1111,7 @@ static int decode_scale_factors(WMAProDecodeCtx* s)
         s->channel[c].max_scale_factor = s->channel[c].scale_factors[0];
         for (sf = s->channel[c].scale_factors + 1; sf < sf_end; sf++) {
             s->channel[c].max_scale_factor =
-                FFMAX(s->channel[c].max_scale_factor, *sf);
+                FFMAXI(s->channel[c].max_scale_factor, *sf);
         }
 
     }
@@ -1141,7 +1141,7 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
                 int y;
                 if (*tb++ == 1) {
                     /** multiply values with the decorrelation_matrix */
-                    for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) {
+                    for (y = sfb[0]; y < FFMINI(sfb[1], s->subframe_len); y++) {
                         const float* mat = s->chgroup[i].decorrelation_matrix;
                         const float* data_end = data + num_channels;
                         float* data_ptr = data;
@@ -1160,7 +1160,7 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
                         }
                     }
                 } else if (s->nb_channels == 2) {
-                    int len = FFMIN(sfb[1], s->subframe_len) - sfb[0];
+                    int len = FFMINI(sfb[1], s->subframe_len) - sfb[0];
                     s->fdsp->vector_fmul_scalar(ch_data[0] + sfb[0],
                                                ch_data[0] + sfb[0],
                                                181.0 / 128, len);
@@ -1410,7 +1410,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
 
             /** inverse quantization and rescaling */
             for (b = 0; b < s->num_bands; b++) {
-                const int end = FFMIN(s->cur_sfb_offsets[b+1], s->subframe_len);
+                const int end = FFMINI(s->cur_sfb_offsets[b+1], s->subframe_len);
                 const int exp = s->channel[c].quant_step -
                             (s->channel[c].max_scale_factor - *sf++) *
                             s->channel[c].scale_factor_step;
@@ -1604,7 +1604,7 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len,
                      s->num_saved_bits);
     } else {
         int align = 8 - (get_bits_count(gb) & 7);
-        align = FFMIN(align, len);
+        align = FFMINI(align, len);
         put_bits(&s->pb, align, get_bits(gb, align));
         len -= align;
         ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len);
@@ -1670,8 +1670,8 @@ static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s,
             s->next_packet_start = buf_size - avctx->block_align;
             buf_size = avctx->block_align;
         } else {
-            s->next_packet_start = buf_size - FFMIN(buf_size, avctx->block_align);
-            buf_size = FFMIN(buf_size, avctx->block_align);
+            s->next_packet_start = buf_size - FFMINI(buf_size, avctx->block_align);
+            buf_size = FFMINI(buf_size, avctx->block_align);
         }
         s->buf_bit_size = buf_size << 3;
 
@@ -1919,12 +1919,12 @@ static int xma_decode_packet(AVCodecContext *avctx, AVFrame *frame,
 
         /* all other streams skip next packet */
         for (i = 0; i < s->num_streams; i++) {
-            s->xma[i].skip_packets = FFMAX(0, s->xma[i].skip_packets - 1);
-            nb_samples = FFMIN(nb_samples, av_audio_fifo_size(s->samples[0][i]));
+            s->xma[i].skip_packets = FFMAXI(0, s->xma[i].skip_packets - 1);
+            nb_samples = FFMINI(nb_samples, av_audio_fifo_size(s->samples[0][i]));
         }
 
         if (!eof && avpkt->size)
-            nb_samples -= FFMIN(nb_samples, 4096);
+            nb_samples -= FFMINI(nb_samples, 4096);
 
         /* copy samples from buffer to output if possible */
         if ((nb_samples > 0 || eof || !avpkt->size) && !s->flushed) {
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 7fc735ad1d9..89090d12f58 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -553,8 +553,8 @@ static int kalman_smoothen(WMAVoiceContext *s, int pitch,
 {
     int n;
     float optimal_gain = 0, dot;
-    const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)],
-                *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)],
+    const float *ptr = &in[-FFMAXI(s->min_pitch_val, pitch - 3)],
+                *end = &in[-FFMINI(s->max_pitch_val, pitch + 3)],
                 *best_hist_ptr = NULL;
 
     /* find best fitting point in history */
@@ -623,7 +623,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src,
     s->rdft_fn(s->rdft, lpcs, lpcs_src, sizeof(float));
 #define log_range(var, assign) do { \
         float tmp = log10f(assign);  var = tmp; \
-        max       = FFMAX(max, tmp); min = FFMIN(min, tmp); \
+        max       = FFMAXF(max, tmp); min = FFMINF(min, tmp); \
     } while (0)
     log_range(last_coeff,  lpcs[64]         * lpcs[64]);
     for (n = 1; n < 64; n++)
@@ -647,7 +647,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src,
         float pwr;
 
         idx = lrint((max - lpcs[n]) * irange - 1);
-        idx = FFMAX(0, idx);
+        idx = FFMAXI(0, idx);
         pwr = wmavoice_denoise_power_table[s->denoise_strength][idx];
         lpcs[n] = angle_mul * pwr;
 
@@ -658,7 +658,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src,
             coeffs[n] = wmavoice_energy_table[127] *
                         powf(1.0331663, idx - 127);
         } else
-            coeffs[n] = wmavoice_energy_table[FFMAX(0, idx)];
+            coeffs[n] = wmavoice_energy_table[FFMAXI(0, idx)];
     }
 
     /* calculate the Hilbert transform of the gains, which we do (since this
@@ -754,7 +754,7 @@ static void wiener_denoise(WMAVoiceContext *s, int fcb_type,
          * size is applied to the next frame. All input beyond this is zero,
          * and thus all output beyond this will go towards zero, hence we can
          * limit to min(size-1, 127-size) as a performance consideration. */
-        remainder = FFMIN(127 - size, size - 1);
+        remainder = FFMINI(127 - size, size - 1);
         calc_input_response(s, tilted_lpcs, fcb_type, coeffs, remainder);
 
         /* apply coefficients (in frequency spectrum domain), i.e. complex
@@ -774,7 +774,7 @@ static void wiener_denoise(WMAVoiceContext *s, int fcb_type,
 
     /* merge filter output with the history of previous runs */
     if (s->denoise_filter_cache_size) {
-        lim = FFMIN(s->denoise_filter_cache_size, size);
+        lim = FFMINI(s->denoise_filter_cache_size, size);
         for (n = 0; n < lim; n++)
             synth_pf[n] += s->denoise_filter_cache[n];
         s->denoise_filter_cache_size -= lim;
@@ -784,7 +784,7 @@ static void wiener_denoise(WMAVoiceContext *s, int fcb_type,
 
     /* move remainder of filter output into a cache for future runs */
     if (fcb_type != FCB_TYPE_SILENCE) {
-        lim = FFMIN(remainder, s->denoise_filter_cache_size);
+        lim = FFMINI(remainder, s->denoise_filter_cache_size);
         for (n = 0; n < lim; n++)
             s->denoise_filter_cache[n] += synth_pf[size + n];
         if (lim < remainder) {
@@ -1069,7 +1069,7 @@ static void aw_parse_coords(WMAVoiceContext *s, GetBitContext *gb,
 
     /* for a repeated pulse at pulse_off with a pitch_lag of pitch[], count
      * the distribution of the pulses in each block contained in this frame. */
-    s->aw_pulse_range        = FFMIN(pitch[0], pitch[1]) > 32 ? 24 : 16;
+    s->aw_pulse_range        = FFMINI(pitch[0], pitch[1]) > 32 ? 24 : 16;
     for (offset = start_offset[bits]; offset < 0; offset += pitch[0]) ;
     s->aw_n_pulses[0]        = (pitch[0] - 1 + MAX_FRAMESIZE / 2 - offset) / pitch[0];
     s->aw_first_pulse_off[0] = offset - s->aw_pulse_range / 2;
@@ -1522,7 +1522,7 @@ static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx,
         n_blocks_x2      = frame_descs[bd_idx].n_blocks << 1;
         log_n_blocks_x2  = frame_descs[bd_idx].log_n_blocks + 1;
         cur_pitch_val    = s->min_pitch_val + get_bits(gb, s->pitch_nbits);
-        cur_pitch_val    = FFMIN(cur_pitch_val, s->max_pitch_val - 1);
+        cur_pitch_val    = FFMINI(cur_pitch_val, s->max_pitch_val - 1);
         if (s->last_acb_type == ACB_TYPE_NONE ||
             20 * abs(cur_pitch_val - s->last_pitch_val) >
                 (cur_pitch_val + s->last_pitch_val))
@@ -1679,10 +1679,10 @@ static void stabilize_lsps(double *lsps, int num)
     /* set minimum value for first, maximum value for last and minimum
      * spacing between LSF values.
      * Very similar to ff_set_min_dist_lsf(), but in double. */
-    lsps[0]       = FFMAX(lsps[0],       0.0015 * M_PI);
+    lsps[0]       = FFMAXD(lsps[0],       0.0015 * M_PI);
     for (n = 1; n < num; n++)
-        lsps[n]   = FFMAX(lsps[n],       lsps[n - 1] + 0.0125 * M_PI);
-    lsps[num - 1] = FFMIN(lsps[num - 1], 0.9985 * M_PI);
+        lsps[n]   = FFMAXD(lsps[n],       lsps[n - 1] + 0.0125 * M_PI);
+    lsps[num - 1] = FFMIND(lsps[num - 1], 0.9985 * M_PI);
 
     /* reorder (looks like one-time / non-recursed bubblesort).
      * Very similar to ff_sort_nearly_sorted_floats(), but in double. */
@@ -1901,10 +1901,10 @@ static void copy_bits(PutBitContext *pb,
     if (nbits > put_bits_left(pb))
         return;
     rmn_bits &= 7; rmn_bytes >>= 3;
-    if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0)
+    if ((rmn_bits = FFMINI(rmn_bits, nbits)) > 0)
         put_bits(pb, rmn_bits, get_bits(gb, rmn_bits));
     ff_copy_bits(pb, data + size - rmn_bytes,
-                 FFMIN(nbits - rmn_bits, rmn_bytes << 3));
+                 FFMINI(nbits - rmn_bits, rmn_bytes << 3));
 }
 
 /**
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 964d6a4c060..27aff8c6119 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -221,7 +221,7 @@ int ff_wmv2_decode_picture_header(MpegEncContext *s)
         int run = skip_type == SKIP_TYPE_COL ? s->mb_width : s->mb_height;
 
         while (run > 0) {
-            int block = FFMIN(run, 25);
+            int block = FFMINI(run, 25);
             if (get_bits(&gb, block) + 1 != 1<<block)
                 break;
             run -= block;
@@ -373,7 +373,7 @@ static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)
     C       = s->cur_pic.motion_val[0][xy + 2 - wrap];
 
     if (s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag)
-        diff = FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
+        diff = FFMAXI(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
     else
         diff = 0;
 
diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c
index 592d1060d39..43a38fb77ba 100644
--- a/libavcodec/wmv2enc.c
+++ b/libavcodec/wmv2enc.c
@@ -56,7 +56,7 @@ static int encode_ext_header(WMV2EncContext *w)
     init_put_bits(&pb, s->c.avctx->extradata, WMV2_EXTRADATA_SIZE);
 
     put_bits(&pb, 5, s->c.avctx->time_base.den / s->c.avctx->time_base.num); // yes 29.97 -> 29
-    put_bits(&pb, 11, FFMIN(w->msmpeg4.m.bit_rate / 1024, 2047));
+    put_bits(&pb, 11, FFMINI(w->msmpeg4.m.bit_rate / 1024, 2047));
 
     put_bits(&pb, 1, w->mspel_bit        = 1);
     put_bits(&pb, 1, s->c.loop_filter);
diff --git a/libavcodec/x86/videodsp_init.c b/libavcodec/x86/videodsp_init.c
index 602856de1e6..43584cba69c 100644
--- a/libavcodec/x86/videodsp_init.c
+++ b/libavcodec/x86/videodsp_init.c
@@ -147,10 +147,10 @@ static av_always_inline void emulated_edge_mc(uint8_t *dst, const uint8_t *src,
         src_x  = 1 - block_w;
     }
 
-    start_y = FFMAX(0, -src_y);
-    start_x = FFMAX(0, -src_x);
-    end_y   = FFMIN(block_h, h-src_y);
-    end_x   = FFMIN(block_w, w-src_x);
+    start_y = FFMAXI(0, -src_y);
+    start_x = FFMAXI(0, -src_x);
+    end_y   = FFMINI(block_h, h-src_y);
+    end_x   = FFMINI(block_w, w-src_x);
     av_assert2(start_x < end_x && block_w > 0);
     av_assert2(start_y < end_y && block_h > 0);
 
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index 56675dbbb18..11bee0bbaac 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -220,7 +220,7 @@ static inline void xan_wc3_output_pixel_run(XanContext *s, AVFrame *frame,
     index = y * stride + x;
     current_x = x;
     while (pixel_count && index < s->frame_size) {
-        int count = FFMIN(pixel_count, width - current_x);
+        int count = FFMINI(pixel_count, width - current_x);
         memcpy(palette_plane + index, pixel_buffer, count);
         pixel_count  -= count;
         index        += count;
@@ -557,7 +557,7 @@ static int xan_decode_frame(AVCodecContext *avctx, AVFrame *frame,
             av_log(avctx, AV_LOG_ERROR, "Invalid tag size %d\n", size);
             return AVERROR_INVALIDDATA;
         }
-        size = FFMIN(size, bytestream2_get_bytes_left(&ctx));
+        size = FFMINI(size, bytestream2_get_bytes_left(&ctx));
         switch (tag) {
         case PALT_TAG:
             if (size < PALETTE_SIZE)
diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c
index 2eb5daf545c..4f4999bf27b 100644
--- a/libavcodec/xpmdec.c
+++ b/libavcodec/xpmdec.c
@@ -277,7 +277,7 @@ static uint32_t color_string_to_rgba(const char *p, size_t len)
                    (hex_char_to_number(p[0]) << 28);
         }
     } else {
-        len = FFMIN(len, sizeof(color_name) - 1);
+        len = FFMINI(len, sizeof(color_name) - 1);
         strncpy(color_name, p, len);
         color_name[len] = '\0';
 
diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c
index 6f417c59580..71acf9fbbda 100644
--- a/libavcodec/xsubenc.c
+++ b/libavcodec/xsubenc.c
@@ -83,7 +83,7 @@ static int xsub_encode_rle(PutBitContext *pb, const uint8_t *bitmap,
             if (x1 == w && color == PADDING_COLOR) {
                 len += PADDING + (w&1);
             } else
-                len = FFMIN(len, 255);
+                len = FFMINI(len, 255);
             put_xsub_rle(pb, len, color);
 
             x0 += len;
diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c
index cb6a97c668c..971dc6c0b01 100644
--- a/libavcodec/xxan.c
+++ b/libavcodec/xxan.c
@@ -336,7 +336,7 @@ static int xan_decode_frame_type0(AVCodecContext *avctx)
         if (dec_size < 0)
             dec_size = 0;
         else
-            dec_size = FFMIN(dec_size, s->buffer_size/2 - 1);
+            dec_size = FFMINI(dec_size, s->buffer_size/2 - 1);
 
         for (i = 0; i < dec_size; i++)
             s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F;
diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c
index 44cbfa712a8..b70db1e08d5 100644
--- a/libavcodec/ylc.c
+++ b/libavcodec/ylc.c
@@ -64,8 +64,8 @@ static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat,
 
     s = nodes[node].sym;
     if (s != -1) {
-        bits[*pos] = (~pfx) & ((1ULL << FFMAX(pl, 1)) - 1);
-        lens[*pos] = FFMAX(pl, 1);
+        bits[*pos] = (~pfx) & ((1ULL << FFMAXI(pl, 1)) - 1);
+        lens[*pos] = FFMAXI(pl, 1);
         xlat[*pos] = s + (pl == 0);
         (*pos)++;
     } else {
@@ -304,7 +304,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
         return ret;
 
     av_fast_malloc(&s->buffer, &s->buffer_size,
-                   FFMAX(boffset - toffset, avpkt->size - boffset)
+                   FFMAXI(boffset - toffset, avpkt->size - boffset)
                        + AV_INPUT_BUFFER_PADDING_SIZE);
     if (!s->buffer)
         return AVERROR(ENOMEM);
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 2c09ccbd732..fe5e8af2925 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -614,7 +614,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     c->bpp = avctx->bits_per_coded_sample;
 
-    if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > FFMIN(avctx->max_pixels, INT_MAX / 4) ) {
+    if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > FFMINI(avctx->max_pixels, INT_MAX / 4) ) {
         av_log(avctx, AV_LOG_ERROR, "Internal buffer (decomp_size) larger than max_pixels or too large\n");
         return AVERROR_INVALIDDATA;
     }
diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index 17eb3caa2b2..bce5313abbe 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -126,8 +126,8 @@ static int zmbv_me(ZmbvEncContext *c, const uint8_t *src, int sstride, const uin
 
     mx0 = *mx;
     my0 = *my;
-    bw = FFMIN(ZMBV_BLOCK, c->avctx->width - x);
-    bh = FFMIN(ZMBV_BLOCK, c->avctx->height - y);
+    bw = FFMINI(ZMBV_BLOCK, c->avctx->width - x);
+    bh = FFMINI(ZMBV_BLOCK, c->avctx->height - y);
 
     /* Try (0,0) */
     bv = block_cmp(c, src, sstride, prev, pstride, bw, bh, xored);
@@ -229,9 +229,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         work_size += (bw * bh * 2 + 3) & ~3;
         /* for now just XOR'ing */
         for(y = 0; y < avctx->height; y += ZMBV_BLOCK) {
-            bh2 = FFMIN(avctx->height - y, ZMBV_BLOCK);
+            bh2 = FFMINI(avctx->height - y, ZMBV_BLOCK);
             for(x = 0; x < avctx->width; x += ZMBV_BLOCK, mv += 2) {
-                bw2 = FFMIN(avctx->width - x, ZMBV_BLOCK);
+                bw2 = FFMINI(avctx->width - x, ZMBV_BLOCK);
 
                 tsrc = src + x * c->bypp;
                 tprev = prev + x * c->bypp;
@@ -363,8 +363,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
     /* Motion estimation range: maximum distance is -64..63 */
     c->lrange = c->urange = 8;
     if(avctx->me_range > 0){
-        c->lrange = FFMIN(avctx->me_range, 64);
-        c->urange = FFMIN(avctx->me_range, 63);
+        c->lrange = FFMINI(avctx->me_range, 64);
+        c->urange = FFMINI(avctx->me_range, 63);
     }
 
     if(avctx->compression_level >= 0)
diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index cfdb28ff499..aade61ea3fc 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -248,7 +248,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
     }
 
     snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size);
-    buffer_size = FFMIN(buffer_size, ALSA_BUFFER_SIZE_MAX);
+    buffer_size = FFMINI(buffer_size, ALSA_BUFFER_SIZE_MAX);
     /* TODO: maybe use ctx->max_picture_buffer somehow */
     res = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size);
     if (res < 0) {
diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c
index 7f3e8e5935f..bfa28c19b5e 100644
--- a/libavdevice/fbdev_enc.c
+++ b/libavdevice/fbdev_enc.c
@@ -127,8 +127,8 @@ static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
         return AVERROR(EINVAL);
     }
 
-    disp_height = FFMIN(fbdev->varinfo.yres, video_height);
-    bytes_to_copy = FFMIN(fbdev->varinfo.xres, video_width) * bytes_per_pixel;
+    disp_height = FFMINI(fbdev->varinfo.yres, video_height);
+    bytes_to_copy = FFMINI(fbdev->varinfo.xres, video_width) * bytes_per_pixel;
 
     pin  = pkt->data;
     pout = fbdev->data +
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 548183d6335..2be133d49f6 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -307,7 +307,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
             par->format     = av_buffersink_get_format(sink);
             par->width      = av_buffersink_get_w(sink);
             par->height     = av_buffersink_get_h(sink);
-            avctx->probesize = FFMAX(avctx->probesize, sizeof(AVFrame) * 30);
+            avctx->probesize = FFMAXI(avctx->probesize, sizeof(AVFrame) * 30);
             st ->sample_aspect_ratio =
             par->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink);
             if (frame_rate.num > 0 && frame_rate.den > 0) {
diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c
index 7aa165ee74e..1bf420bdb76 100644
--- a/libavdevice/openal-dec.c
+++ b/libavdevice/openal-dec.c
@@ -54,7 +54,7 @@ typedef struct {
     int channels;
 } al_format_info;
 
-#define LOWEST_AL_FORMAT FFMIN(FFMIN(AL_FORMAT_MONO8,AL_FORMAT_MONO16),FFMIN(AL_FORMAT_STEREO8,AL_FORMAT_STEREO16))
+#define LOWEST_AL_FORMAT FFMINI(FFMINI(AL_FORMAT_MONO8,AL_FORMAT_MONO16),FFMINI(AL_FORMAT_STEREO8,AL_FORMAT_STEREO16))
 
 /**
  * Get information about an AL_FORMAT value.
diff --git a/libavdevice/oss_enc.c b/libavdevice/oss_enc.c
index c125e6c0e9f..67337609166 100644
--- a/libavdevice/oss_enc.c
+++ b/libavdevice/oss_enc.c
@@ -61,7 +61,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
     int size= pkt->size;
 
     while (size > 0) {
-        len = FFMIN(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size);
+        len = FFMINI(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size);
         memcpy(s->buffer + s->buffer_ptr, buf, len);
         s->buffer_ptr += len;
         if (s->buffer_ptr >= OSS_AUDIO_BLOCK_SIZE) {
diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c
index d1652bf8d73..f3eab8d1539 100644
--- a/libavdevice/pulse_audio_enc.c
+++ b/libavdevice/pulse_audio_enc.c
@@ -476,7 +476,7 @@ static av_cold int pulse_write_header(AVFormatContext *h)
                                     (int64_t)st->codecpar->sample_rate *
                                     av_get_bytes_per_sample(st->codecpar->format),
                                    1000);
-        buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1));
+        buffer_attributes.tlength = FFMAXI(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1));
         av_log(s, AV_LOG_DEBUG,
                "Buffer duration: %ums recalculated into %"PRId64" bytes buffer.\n",
                s->buffer_duration, bytes);
diff --git a/libavdevice/sndio_enc.c b/libavdevice/sndio_enc.c
index 578e287a41f..6384c98544f 100644
--- a/libavdevice/sndio_enc.c
+++ b/libavdevice/sndio_enc.c
@@ -52,7 +52,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
     int len, ret;
 
     while (size > 0) {
-        len = FFMIN(s->buffer_size - s->buffer_offset, size);
+        len = FFMINI(s->buffer_size - s->buffer_offset, size);
         memcpy(s->buffer + s->buffer_offset, buf, len);
         buf  += len;
         size -= len;
diff --git a/libavdevice/timefilter.c b/libavdevice/timefilter.c
index a97afc5fdca..a338a2632e6 100644
--- a/libavdevice/timefilter.c
+++ b/libavdevice/timefilter.c
@@ -83,7 +83,7 @@ double ff_timefilter_update(TimeFilter *self, double system_time, double period)
         self->cycle_time += self->clock_period * period;
         loop_error = system_time - self->cycle_time;
 
-        self->cycle_time   += FFMAX(self->feedback2_factor, 1.0 / self->count) * loop_error;
+        self->cycle_time   += FFMAXD(self->feedback2_factor, 1.0 / self->count) * loop_error;
         self->clock_period += self->feedback3_factor * loop_error;
     }
     return self->cycle_time;
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 0ae68723382..24b4e984a8c 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -593,7 +593,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
     }
 
     /* Image is at s->buff_start[buf.index] */
-    if (atomic_load(&s->buffers_queued) == FFMAX(s->buffers / 8, 1)) {
+    if (atomic_load(&s->buffers_queued) == FFMAXI(s->buffers / 8, 1)) {
         /* when we start getting low on queued buffers, fall back on copying data */
         res = av_new_packet(pkt, bytesused);
         if (res < 0) {
diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index c736ec0cbcb..632093b1fff 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -145,8 +145,8 @@ static int xcbgrab_reposition(AVFormatContext *s,
         }
     }
 
-    c->x = FFMIN(FFMAX(0, x), geo->width  - w);
-    c->y = FFMIN(FFMAX(0, y), geo->height - h);
+    c->x = FFMINI(FFMAXI(0, x), geo->width  - w);
+    c->y = FFMINI(FFMAXI(0, y), geo->height - h);
 
     return 0;
 }
@@ -356,11 +356,11 @@ static void xcbgrab_draw_mouse(AVFormatContext *s, AVPacket *pkt,
     cx = ci->x - ci->xhot;
     cy = ci->y - ci->yhot;
 
-    x = FFMAX(cx, win_x + gr->x);
-    y = FFMAX(cy, win_y + gr->y);
+    x = FFMAXI(cx, win_x + gr->x);
+    y = FFMAXI(cy, win_y + gr->y);
 
-    w = FFMIN(cx + ci->width,  win_x + gr->x + gr->width)  - x;
-    h = FFMIN(cy + ci->height, win_y + gr->y + gr->height) - y;
+    w = FFMINI(cx + ci->width,  win_x + gr->x + gr->width)  - x;
+    h = FFMINI(cy + ci->height, win_y + gr->y + gr->height) - y;
 
     c_off = x - cx;
     i_off = x - gr->x - win_x;
@@ -711,8 +711,8 @@ static xcb_rectangle_t rectangle_from_corners(xcb_point_t *corner_a,
                                               xcb_point_t *corner_b)
 {
     xcb_rectangle_t rectangle;
-    rectangle.x = FFMIN(corner_a->x, corner_b->x);
-    rectangle.y = FFMIN(corner_a->y, corner_b->y);
+    rectangle.x = FFMINI(corner_a->x, corner_b->x);
+    rectangle.y = FFMINI(corner_a->y, corner_b->y);
     rectangle.width = FFABS(corner_a->x - corner_b->x);
     rectangle.height = FFABS(corner_a->y - corner_b->y);
     return rectangle;
diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c
index 03ecb4e5bb0..20a10b22cce 100644
--- a/libavfilter/aeval.c
+++ b/libavfilter/aeval.c
@@ -77,7 +77,7 @@ typedef struct EvalContext {
 static double val(void *priv, double ch)
 {
     EvalContext *eval = priv;
-    return eval->channel_values[FFMIN((int)ch, eval->nb_in_channels-1)];
+    return eval->channel_values[FFMINI((int)ch, eval->nb_in_channels-1)];
 }
 
 static double (* const aeval_func1[])(void *, double) = { val, NULL };
@@ -282,7 +282,7 @@ static int activate(AVFilterContext *ctx)
     }
 
     if (eval->duration >= 0) {
-        nb_samples = FFMIN(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts);
+        nb_samples = FFMINI(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts);
         if (!nb_samples) {
             ff_outlink_set_status(outlink, AVERROR_EOF, eval->pts);
             return 0;
diff --git a/libavfilter/af_aap.c b/libavfilter/af_aap.c
index 8d3209a1efc..1a5ac7e41a4 100644
--- a/libavfilter/af_aap.c
+++ b/libavfilter/af_aap.c
@@ -123,7 +123,7 @@ static int activate(AVFilterContext *ctx)
 
     FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
 
-    nb_samples = FFMIN(ff_inlink_queued_samples(ctx->inputs[0]),
+    nb_samples = FFMINI(ff_inlink_queued_samples(ctx->inputs[0]),
                        ff_inlink_queued_samples(ctx->inputs[1]));
     for (i = 0; i < ctx->nb_inputs && nb_samples > 0; i++) {
         if (s->frame[i])
@@ -147,7 +147,7 @@ static int activate(AVFilterContext *ctx)
         }
 
         ff_filter_execute(ctx, s->filter_channels, out, NULL,
-                          FFMIN(ctx->outputs[0]->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(ctx->outputs[0]->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
         out->pts = s->frame[0]->pts;
         out->duration = s->frame[0]->duration;
diff --git a/libavfilter/af_acrossover.c b/libavfilter/af_acrossover.c
index 2c9a1e00bcd..f3d0beca2ce 100644
--- a/libavfilter/af_acrossover.c
+++ b/libavfilter/af_acrossover.c
@@ -537,7 +537,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         goto fail;
 
     ff_filter_execute(ctx, s->filter_channels, in, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     for (int i = 0; i < ctx->nb_outputs; i++) {
         if (ff_outlink_get_status(ctx->outputs[i])) {
diff --git a/libavfilter/af_acrusher.c b/libavfilter/af_acrusher.c
index 3ec38269d0c..4b228fdf7ce 100644
--- a/libavfilter/af_acrusher.c
+++ b/libavfilter/af_acrusher.c
@@ -196,7 +196,7 @@ static double bitreduction(ACrusherContext *s, double in)
 
 static double lfo_get(LFOContext *lfo)
 {
-    double phs = FFMIN(100., lfo->phase / FFMIN(1.99, FFMAX(0.01, lfo->pwidth)) + lfo->offset);
+    double phs = FFMIND(100., lfo->phase / FFMIND(1.99, FFMAXD(0.01, lfo->pwidth)) + lfo->offset);
     double val;
 
     if (phs > 1)
@@ -283,9 +283,9 @@ static int config_input(AVFilterLink *inlink)
     s->aa1 = (1. - s->aa) / 2.;
     s->round = round(s->samples);
     rad = s->lforange / 2.;
-    s->smin = FFMAX(s->samples - rad, 1.);
+    s->smin = FFMAXD(s->samples - rad, 1.);
     sunder   = s->samples - rad - s->smin;
-    smax = FFMIN(s->samples + rad, 250.);
+    smax = FFMIND(s->samples + rad, 250.);
     sover    = s->samples + rad - smax;
     smax    -= sunder;
     s->smin -= sover;
diff --git a/libavfilter/af_adeclick.c b/libavfilter/af_adeclick.c
index 043435b1869..8e611f539a6 100644
--- a/libavfilter/af_adeclick.c
+++ b/libavfilter/af_adeclick.c
@@ -120,10 +120,10 @@ static int config_input(AVFilterLink *inlink)
     int i;
 
     s->pts = AV_NOPTS_VALUE;
-    s->window_size = FFMAX(100, inlink->sample_rate * s->w / 1000.);
-    s->ar_order = FFMAX(s->window_size * s->ar / 100., 1);
+    s->window_size = FFMAXD(100, inlink->sample_rate * s->w / 1000.);
+    s->ar_order = FFMAXD(s->window_size * s->ar / 100., 1);
     s->nb_burst_samples = s->window_size * s->burst / 1000.;
-    s->hop_size = FFMAX(1, s->window_size * (1. - (s->overlap / 100.)));
+    s->hop_size = FFMAXD(1, s->window_size * (1. - (s->overlap / 100.)));
 
     s->window_func_lut = av_calloc(s->window_size, sizeof(*s->window_func_lut));
     if (!s->window_func_lut)
@@ -457,7 +457,7 @@ static int detect_clips(AudioDeclickContext *s, DeclickChannel *c,
 
     for (i = s->nb_hbins - 1; i > 1; i--) {
         if (histogram[i]) {
-            if (histogram[i] / (double)FFMAX(histogram[i - 1], 1) > threshold) {
+            if (histogram[i] / (double)FFMAXI(histogram[i - 1], 1) > threshold) {
                 max_amplitude = i / (double)s->nb_hbins;
             }
             break;
@@ -627,7 +627,7 @@ static int filter_frame(AVFilterLink *inlink)
     av_audio_fifo_drain(s->efifo, s->hop_size);
 
     if (s->samples_left > 0)
-        out->nb_samples = FFMIN(s->hop_size, s->samples_left);
+        out->nb_samples = FFMINI(s->hop_size, s->samples_left);
 
     out->pts = s->pts;
     s->pts += av_rescale_q(s->hop_size, (AVRational){1, outlink->sample_rate}, outlink->time_base);
diff --git a/libavfilter/af_adecorrelate.c b/libavfilter/af_adecorrelate.c
index 8991bf2077a..a3a62562f42 100644
--- a/libavfilter/af_adecorrelate.c
+++ b/libavfilter/af_adecorrelate.c
@@ -190,7 +190,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in; td.out = out;
     ff_filter_execute(ctx, filter_channels, &td, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
index c0d076fe642..a6f400db1a7 100644
--- a/libavfilter/af_adelay.c
+++ b/libavfilter/af_adelay.c
@@ -75,7 +75,7 @@ static void delay_channel_## name ##p(ChanDelay *d, int nb_samples,       \
                                                                           \
     while (nb_samples) {                                                  \
         if (d->delay_index < d->delay) {                                  \
-            const int len = FFMIN(nb_samples, d->delay - d->delay_index); \
+            const int len = FFMINI(nb_samples, d->delay - d->delay_index); \
                                                                           \
             memcpy(&samples[d->delay_index], src, len * sizeof(type));    \
             memset(dst, fill, len * sizeof(type));                        \
@@ -218,7 +218,7 @@ static int config_input(AVFilterLink *inlink)
     for (i = 1; i < s->nb_delays; i++) {
         ChanDelay *d = &s->chandelay[i];
 
-        s->padding = FFMIN(s->padding, d->delay);
+        s->padding = FFMINI(s->padding, d->delay);
     }
 
     if (s->padding) {
@@ -249,7 +249,7 @@ static int config_input(AVFilterLink *inlink)
             return AVERROR(ENOMEM);
         d->samples_size = d->delay * s->block_align;
 
-        s->max_delay = FFMAX(s->max_delay, d->delay);
+        s->max_delay = FFMAXI(s->max_delay, d->delay);
     }
 
     switch (inlink->format) {
@@ -313,9 +313,9 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar
                 ret = s->resize_channel_samples(d, delay);
                 if (ret)
                     break;
-                max_delay = FFMAX(max_delay, d->delay);
+                max_delay = FFMAXI(max_delay, d->delay);
             }
-            s->max_delay = FFMAX(s->max_delay, max_delay);
+            s->max_delay = FFMAXI(s->max_delay, max_delay);
         }
         av_freep(&args_cpy);
     }
@@ -390,7 +390,7 @@ static int activate(AVFilterContext *ctx)
         s->next_pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
 
     if (s->padding) {
-        int nb_samples = FFMIN(s->padding, 2048);
+        int nb_samples = FFMINI(s->padding, 2048);
 
         frame = ff_get_audio_buffer(outlink, nb_samples);
         if (!frame)
@@ -415,7 +415,7 @@ static int activate(AVFilterContext *ctx)
         return filter_frame(inlink, s->input);
 
     if (s->eof && s->max_delay) {
-        int nb_samples = FFMIN(s->max_delay, 2048);
+        int nb_samples = FFMINI(s->max_delay, 2048);
 
         frame = ff_get_audio_buffer(outlink, nb_samples);
         if (!frame)
diff --git a/libavfilter/af_adenorm.c b/libavfilter/af_adenorm.c
index 0d61eed1dd0..ddc1bed3eae 100644
--- a/libavfilter/af_adenorm.c
+++ b/libavfilter/af_adenorm.c
@@ -222,7 +222,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     s->level = exp(s->level_db / 20. * M_LN10);
     td.in = in; td.out = out;
     ff_filter_execute(ctx, filter_channels, &td, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     s->in_samples += in->nb_samples;
 
diff --git a/libavfilter/af_adrc.c b/libavfilter/af_adrc.c
index 9e3becdf2e8..331b772a452 100644
--- a/libavfilter/af_adrc.c
+++ b/libavfilter/af_adrc.c
@@ -379,7 +379,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     s->in = in;
     av_frame_copy_props(out, in);
     ff_filter_execute(ctx, drc_channels, out, NULL,
-                      FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     out->pts = in->pts;
     out->nb_samples = in->nb_samples;
diff --git a/libavfilter/af_adynamicequalizer.c b/libavfilter/af_adynamicequalizer.c
index 6043623f466..f62e8c4965d 100644
--- a/libavfilter/af_adynamicequalizer.c
+++ b/libavfilter/af_adynamicequalizer.c
@@ -201,7 +201,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     s->filter_prepare(ctx);
     ff_filter_execute(ctx, s->filter_channels, &td, NULL,
-                     FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                     FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
diff --git a/libavfilter/af_aecho.c b/libavfilter/af_aecho.c
index ff316eaa675..7311e8137b7 100644
--- a/libavfilter/af_aecho.c
+++ b/libavfilter/af_aecho.c
@@ -209,7 +209,7 @@ static int config_output(AVFilterLink *outlink)
 
     for (i = 0; i < s->nb_echoes; i++) {
         s->samples[i] = s->delay[i] * outlink->sample_rate / 1000.0;
-        s->max_samples = FFMAX(s->max_samples, s->samples[i]);
+        s->max_samples = FFMAXI(s->max_samples, s->samples[i]);
         volume += s->decay[i];
     }
 
@@ -273,7 +273,7 @@ static int request_frame(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     AudioEchoContext *s = ctx->priv;
-    int nb_samples = FFMIN(s->fade_out, 2048);
+    int nb_samples = FFMINI(s->fade_out, 2048);
     AVFrame *frame = ff_get_audio_buffer(outlink, nb_samples);
 
     if (!frame)
diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index ce71d1f511a..b43a65a8afe 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -324,7 +324,7 @@ static void spectral_flatness(AudioFFTDeNoiseContext *s, const double *const spe
         }
     }
 
-    size = FFMAX(size, 1);
+    size = FFMAXI(size, 1);
 
     num /= size;
     den /= size;
@@ -508,7 +508,7 @@ static int get_band_edge(AudioFFTDeNoiseContext *s, int band)
         i = lrint(s->band_centre[band] / 1.224745);
     }
 
-    return FFMIN(i, s->sample_rate / 2);
+    return FFMINF(i, s->sample_rate / 2);
 }
 
 static void set_band_parameters(AudioFFTDeNoiseContext *s,
@@ -882,10 +882,10 @@ static int config_input(AVFilterLink *inlink)
         set_parameters(s, dnch, 1, 1);
     }
 
-    s->noise_band_edge[0] = FFMIN(s->fft_length2, s->fft_length * get_band_edge(s, 0) / s->sample_rate);
+    s->noise_band_edge[0] = FFMINF(s->fft_length2, s->fft_length * get_band_edge(s, 0) / s->sample_rate);
     i = 0;
     for (int j = 1; j < NB_PROFILE_BANDS + 1; j++) {
-        s->noise_band_edge[j] = FFMIN(s->fft_length2, s->fft_length * get_band_edge(s, j) / s->sample_rate);
+        s->noise_band_edge[j] = FFMINF(s->fft_length2, s->fft_length * get_band_edge(s, j) / s->sample_rate);
         if (s->noise_band_edge[j] > lrint(1.1 * s->noise_band_edge[j - 1]))
             i++;
         s->noise_band_edge[NB_PROFILE_BANDS + 1] = i;
@@ -1191,7 +1191,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     ff_filter_execute(ctx, filter_channel, s->winframe, NULL,
-                      FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     if (av_frame_is_writable(in)) {
         out = in;
diff --git a/libavfilter/af_afftfilt.c b/libavfilter/af_afftfilt.c
index 08cdcae2f76..49017d4d672 100644
--- a/libavfilter/af_afftfilt.c
+++ b/libavfilter/af_afftfilt.c
@@ -334,10 +334,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     values[VAR_CHANNELS]    = inlink->ch_layout.nb_channels;
 
     ff_filter_execute(ctx, tx_channel, NULL, NULL,
-                      FFMIN(s->channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->channels, ff_filter_get_nb_threads(ctx)));
 
     ff_filter_execute(ctx, filter_channel, values, NULL,
-                      FFMIN(s->channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->channels, ff_filter_get_nb_threads(ctx)));
 
     out = ff_get_audio_buffer(outlink, s->hop_size);
     if (!out) {
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index aff837d9bf3..d579858798d 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -180,7 +180,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
 
     s->in = in;
     ff_filter_execute(ctx, fir_channels, out, NULL,
-                      FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
     s->prev_is_disabled = ctx->is_disabled;
 
     av_frame_free(&in);
@@ -207,7 +207,7 @@ static int init_segment(AVFilterContext *ctx, AudioFIRSegment *seg, int selir,
     seg->fft_length    = (part_size + 1) * 2;
     seg->part_size     = part_size;
     seg->coeff_size    = FFALIGN(seg->part_size + 1, cpu_align);
-    seg->block_size    = FFMAX(seg->coeff_size * 2, FFALIGN(seg->fft_length, cpu_align));
+    seg->block_size    = FFMAXI(seg->coeff_size * 2, FFALIGN(seg->fft_length, cpu_align));
     seg->nb_partitions = nb_partitions;
     seg->input_size    = offset + s->min_part_size;
     seg->input_offset  = offset;
@@ -329,7 +329,7 @@ static int convert_coeffs(AVFilterContext *ctx, int selir)
 
         for (int i = 0; left > 0; i++) {
             int step = (part_size == max_part_size) ? INT_MAX : 1 + (i == 0);
-            int nb_partitions = FFMIN(step, (left + part_size - 1) / part_size);
+            int nb_partitions = FFMINI(step, (left + part_size - 1) / part_size);
 
             s->nb_segments[selir] = i + 1;
             ret = init_segment(ctx, &s->seg[selir][i], selir, offset, nb_partitions, part_size, i);
@@ -339,7 +339,7 @@ static int convert_coeffs(AVFilterContext *ctx, int selir)
             s->max_offset[selir] = offset;
             left -= nb_partitions * part_size;
             part_size *= 2;
-            part_size = FFMIN(part_size, max_part_size);
+            part_size = FFMINI(part_size, max_part_size);
         }
     }
 
@@ -388,7 +388,7 @@ skip:
             float *time = (float *)s->norm_ir[selir]->extended_data[ch];
 
             memcpy(time, tsrc, sizeof(*time) * nb_taps);
-            for (int i = FFMAX(1, s->length * nb_taps); i < nb_taps; i++)
+            for (int i = FFMAXF(1, s->length * nb_taps); i < nb_taps; i++)
                 time[i] = 0;
 
             ir_scale_float(ctx, s, nb_taps, ch, time, s->ch_gain[ch]);
@@ -428,7 +428,7 @@ skip:
             double *time = (double *)s->norm_ir[selir]->extended_data[ch];
 
             memcpy(time, tsrc, sizeof(*time) * nb_taps);
-            for (int i = FFMAX(1, s->length * nb_taps); i < nb_taps; i++)
+            for (int i = FFMAXF(1, s->length * nb_taps); i < nb_taps; i++)
                 time[i] = 0;
 
             ir_scale_double(ctx, s, nb_taps, ch, time, s->ch_gain[ch]);
@@ -508,7 +508,7 @@ static int activate(AVFilterContext *ctx)
     }
 
     available = ff_inlink_queued_samples(ctx->inputs[0]);
-    wanted = FFMAX(s->min_part_size, (available / s->min_part_size) * s->min_part_size);
+    wanted = FFMAXI(s->min_part_size, (available / s->min_part_size) * s->min_part_size);
     ret = ff_inlink_consume_samples(ctx->inputs[0], wanted, wanted, &in);
     if (ret > 0)
         ret = fir_frame(s, in, outlink);
@@ -663,7 +663,7 @@ static av_cold int init(AVFilterContext *ctx)
     AVFilterPad pad;
     int ret;
 
-    s->prev_selir = FFMIN(s->nb_irs - 1, s->selir);
+    s->prev_selir = FFMINI(s->nb_irs - 1, s->selir);
 
     pad = (AVFilterPad) {
         .name = "main",
@@ -715,7 +715,7 @@ static int process_command(AVFilterContext *ctx,
     if (ret < 0)
         return ret;
 
-    s->selir = FFMIN(s->nb_irs - 1, s->selir);
+    s->selir = FFMINI(s->nb_irs - 1, s->selir);
     if (s->selir != prev_selir) {
         s->prev_selir = prev_selir;
 
diff --git a/libavfilter/af_afreqshift.c b/libavfilter/af_afreqshift.c
index 68969f2fdde..c35b5432d1d 100644
--- a/libavfilter/af_afreqshift.c
+++ b/libavfilter/af_afreqshift.c
@@ -326,7 +326,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in; td.out = out;
     ff_filter_execute(ctx, filter_channels, &td, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     s->in_samples += in->nb_samples;
 
diff --git a/libavfilter/af_afwtdn.c b/libavfilter/af_afwtdn.c
index 12a2c751c5c..af612130026 100644
--- a/libavfilter/af_afwtdn.c
+++ b/libavfilter/af_afwtdn.c
@@ -587,7 +587,7 @@ static int reallocate_outputs(AudioFWTDNContext *s,
         }
 
         memset(out[level] + temp_length, 0,
-               FFMAX(out_length[level] - temp_length - add, 0) * sizeof(**out));
+               FFMAXI(out_length[level] - temp_length - add, 0) * sizeof(**out));
         out_length[level] = temp_length;
     }
 
@@ -791,7 +791,7 @@ static int inverse(AudioFWTDNContext *s,
                 s->ilp, s->ihp, s->wavelet_length,
                 cp->buffer, cp->buffer2, cp->buffer_length);
         memcpy(out + cp->max_left_ext - leftext, cp->temp_in + temp_skip,
-               FFMAX(0, out_length - (cp->max_left_ext - leftext)) * sizeof(*out));
+               FFMAXI(0, out_length - (cp->max_left_ext - leftext)) * sizeof(*out));
     } else {
         double *hp1, *hp2;
         int add, add2;
@@ -834,8 +834,8 @@ static int inverse(AudioFWTDNContext *s,
     memset(cp->temp_in, 0, temp_skip * sizeof(*cp->temp_in));
     if (s->overlap_length <= out_length) {
         memcpy(out + cp->max_left_ext - leftext, cp->temp_in + temp_skip,
-               FFMAX(0, out_length - (cp->max_left_ext - leftext)) * sizeof(*out));
-        for (int i = 0;i < FFMIN(s->overlap_length, out_length); i++)
+               FFMAXI(0, out_length - (cp->max_left_ext - leftext)) * sizeof(*out));
+        for (int i = 0;i < FFMINI(s->overlap_length, out_length); i++)
             out[i] += cp->overlap[i];
 
         memcpy(cp->overlap, cp->temp_in + out_length - (cp->max_left_ext - leftext),
@@ -1071,7 +1071,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         s->drop_samples = 0;
     } else {
         if (s->padd_samples < 0 && eof) {
-            out->nb_samples = FFMAX(0, out->nb_samples + s->padd_samples);
+            out->nb_samples = FFMAXI(0, out->nb_samples + s->padd_samples);
             s->padd_samples = 0;
         }
         if (!eof)
@@ -1151,7 +1151,7 @@ static int config_output(AVFilterLink *outlink)
         av_assert0(0);
     }
 
-    s->levels = FFMIN(s->levels, lrint(log(s->nb_samples / (s->wavelet_length - 1.0)) / M_LN2));
+    s->levels = FFMINI(s->levels, lrint(log(s->nb_samples / (s->wavelet_length - 1.0)) / M_LN2));
     av_log(ctx, AV_LOG_VERBOSE, "levels: %d\n", s->levels);
     s->filter_channel = filter_channel;
 
diff --git a/libavfilter/af_agate.c b/libavfilter/af_agate.c
index 3f8a7b32028..ae8d082b316 100644
--- a/libavfilter/af_agate.c
+++ b/libavfilter/af_agate.c
@@ -100,8 +100,8 @@ static int agate_config_input(AVFilterLink *inlink)
     if (s->detection)
         lin_threshold *= lin_threshold;
 
-    s->attack_coeff  = FFMIN(1., 1. / (s->attack * inlink->sample_rate / 4000.));
-    s->release_coeff = FFMIN(1., 1. / (s->release * inlink->sample_rate / 4000.));
+    s->attack_coeff  = FFMIND(1., 1. / (s->attack * inlink->sample_rate / 4000.));
+    s->release_coeff = FFMIND(1., 1. / (s->release * inlink->sample_rate / 4000.));
     s->lin_knee_stop = lin_threshold * lin_knee_sqrt;
     s->lin_knee_start = lin_threshold / lin_knee_sqrt;
     s->thres = log(lin_threshold);
@@ -138,7 +138,7 @@ static double output_gain(double lin_slope, double ratio, double thres,
         if (knee > 1. && slope > knee_start)
             gain = hermite_interpolation(slope, knee_start, knee_stop, ((knee_start - thres) * tratio  + thres), knee_stop, delta, 1.);
     }
-    return FFMAX(range, exp(gain - slope));
+    return FFMAXD(range, exp(gain - slope));
 }
 
 static void gate(AudioGateContext *s,
@@ -159,7 +159,7 @@ static void gate(AudioGateContext *s,
 
         if (s->link == 1) {
             for (c = 1; c < sclink->ch_layout.nb_channels; c++)
-                abs_sample = FFMAX(fabs(scsrc[c] * level_sc), abs_sample);
+                abs_sample = FFMAXD(fabs(scsrc[c] * level_sc), abs_sample);
         } else {
             for (c = 1; c < sclink->ch_layout.nb_channels; c++)
                 abs_sample += fabs(scsrc[c] * level_sc);
@@ -267,7 +267,7 @@ static int activate(AVFilterContext *ctx)
     if (ret < 0)
         return ret;
 
-    nb_samples = FFMIN(av_audio_fifo_size(s->fifo[0]), av_audio_fifo_size(s->fifo[1]));
+    nb_samples = FFMINI(av_audio_fifo_size(s->fifo[0]), av_audio_fifo_size(s->fifo[1]));
     if (nb_samples) {
         out = ff_get_audio_buffer(ctx->outputs[0], nb_samples);
         if (!out)
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 9a43235ad6b..d26ec21f6c0 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -180,7 +180,7 @@ static int iir_ch_serial_## name(AVFilterContext *ctx, void *arg,       \
     IIRChannel *iir = &s->iir[ch];                                      \
     const double g = iir->g;                                            \
     int *clippings = &iir->clippings;                                   \
-    int nb_biquads = (FFMAX(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;     \
+    int nb_biquads = (FFMAXI(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;     \
     int n, i;                                                           \
                                                                         \
     for (i = nb_biquads - 1; i >= 0; i--) {                             \
@@ -240,7 +240,7 @@ static int iir_ch_parallel_## name(AVFilterContext *ctx, void *arg,     \
     const double g = iir->g;                                            \
     const double fir = iir->fir;                                        \
     int *clippings = &iir->clippings;                                   \
-    int nb_biquads = (FFMAX(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;     \
+    int nb_biquads = (FFMAXI(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;     \
     int n, i;                                                           \
                                                                         \
     for (i = 0; i < nb_biquads; i++) {                                  \
@@ -606,7 +606,7 @@ static int decompose_zp2biquads(AVFilterContext *ctx, int channels)
 
     for (ch = 0; ch < channels; ch++) {
         IIRChannel *iir = &s->iir[ch];
-        int nb_biquads = (FFMAX(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;
+        int nb_biquads = (FFMAXI(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;
         int current_biquad = 0;
 
         iir->biquads = av_calloc(nb_biquads, sizeof(BiquadContext));
@@ -819,7 +819,7 @@ static int convert_serial2parallel(AVFilterContext *ctx, int channels)
 
     for (int ch = 0; ch < channels; ch++) {
         IIRChannel *iir = &s->iir[ch];
-        int nb_biquads = (FFMAX(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;
+        int nb_biquads = (FFMAXI(iir->nb_ab[0], iir->nb_ab[1]) + 1) / 2;
         int length = nb_biquads * 2 + 1;
         double *impulse = av_calloc(length, sizeof(*impulse));
         double *y = av_calloc(length, sizeof(*y));
@@ -946,7 +946,7 @@ static double coef_sf2zf(double *a, int N, int n)
     for (int i = 0; i <= N; i++) {
         double acc = 0.;
 
-        for (int k = FFMAX(n - N + i, 0); k <= FFMIN(i, n); k++) {
+        for (int k = FFMAXI(n - N + i, 0); k <= FFMINI(i, n); k++) {
             acc += ((fact(i) * fact(N - i)) /
                     (fact(k) * fact(i - k) * fact(n - k) * fact(N - i - n + k))) *
                    ((k & 1) ? -1. : 1.);
@@ -1208,9 +1208,9 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out, int sample_rate)
         if (prev_ydelay < 0)
             prev_ydelay = ydelay;
 
-        draw_line(out, i,   ymag, FFMAX(i - 1, 0),   prev_ymag, 0xFFFF00FF);
-        draw_line(out, i, yphase, FFMAX(i - 1, 0), prev_yphase, 0xFF00FF00);
-        draw_line(out, i, ydelay, FFMAX(i - 1, 0), prev_ydelay, 0xFF00FFFF);
+        draw_line(out, i,   ymag, FFMAXI(i - 1, 0),   prev_ymag, 0xFFFF00FF);
+        draw_line(out, i, yphase, FFMAXI(i - 1, 0), prev_yphase, 0xFF00FF00);
+        draw_line(out, i, ydelay, FFMAXI(i - 1, 0), prev_ydelay, 0xFF00FFFF);
 
         prev_ymag   = ymag;
         prev_yphase = yphase;
diff --git a/libavfilter/af_alimiter.c b/libavfilter/af_alimiter.c
index 61ea7beb6ff..bcd1fb7618c 100644
--- a/libavfilter/af_alimiter.c
+++ b/libavfilter/af_alimiter.c
@@ -115,7 +115,7 @@ static double get_rdelta(AudioLimiterContext *s, double release, int sample_rate
         double a_att = limit / (s->asc_coeff * s->asc) * (double)s->asc_c;
 
         if (a_att > patt) {
-            double delta = FFMAX((a_att - patt) / (sample_rate * release), rdelta / 10);
+            double delta = FFMAXD((a_att - patt) / (sample_rate * release), rdelta / 10);
 
             if (delta < rdelta)
                 rdelta = delta;
@@ -169,7 +169,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             double sample = src[c] * level_in;
 
             buffer[s->pos + c] = sample;
-            peak = FFMAX(peak, fabs(sample));
+            peak = FFMAXD(peak, fabs(sample));
         }
 
         if (s->auto_release && peak > limit) {
@@ -178,7 +178,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         }
 
         if (peak > limit) {
-            double patt = FFMIN(limit / peak, 1.);
+            double patt = FFMIND(limit / peak, 1.);
             double rdelta = get_rdelta(s, release, inlink->sample_rate,
                                        peak, limit, patt, 0);
             double delta = (limit / peak - s->att) / buffer_size * channels;
@@ -198,7 +198,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
                     if (nextpos[j] >= 0)
                         for (c = 0; c < channels; c++) {
-                            ppeak = FFMAX(ppeak, fabs(buffer[nextpos[j] + c]));
+                            ppeak = FFMAXD(ppeak, fabs(buffer[nextpos[j] + c]));
                         }
                     pdelta = (limit / peak - limit / ppeak) / (((buffer_size - nextpos[j] + s->pos) % buffer_size) / channels);
                     if (pdelta < nextdelta[j]) {
@@ -222,7 +222,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         for (c = 0; c < channels; c++) {
             double sample = buf[c];
 
-            peak = FFMAX(peak, fabs(sample));
+            peak = FFMAXD(peak, fabs(sample));
         }
 
         if (s->pos == s->asc_pos && !s->asc_changed)
@@ -247,7 +247,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                     int pnextpos = nextpos[(s->nextiter + 1) % buffer_size];
 
                     for (c = 0; c < channels; c++) {
-                        ppeak = FFMAX(ppeak, fabs(buffer[pnextpos + c]));
+                        ppeak = FFMAXD(ppeak, fabs(buffer[pnextpos + c]));
                     }
                     pdelta = (limit / ppeak - s->att) /
                              (((buffer_size + pnextpos -
@@ -302,7 +302,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     new_out_samples = out->nb_samples;
     if (s->in_trim > 0) {
-        int trim = FFMIN(new_out_samples, s->in_trim);
+        int trim = FFMINI(new_out_samples, s->in_trim);
         new_out_samples -= trim;
         s->in_trim -= trim;
     }
@@ -345,7 +345,7 @@ static int request_frame(AVFilterLink* outlink)
     ret = ff_request_frame(ctx->inputs[0]);
 
     if (ret == AVERROR_EOF && s->out_pad > 0) {
-        AVFrame *frame = ff_get_audio_buffer(outlink, FFMIN(1024, s->out_pad));
+        AVFrame *frame = ff_get_audio_buffer(outlink, FFMINI(1024, s->out_pad));
         if (!frame)
             return AVERROR(ENOMEM);
 
diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c
index bb82128a846..d792977b4ee 100644
--- a/libavfilter/af_amerge.c
+++ b/libavfilter/af_amerge.c
@@ -286,7 +286,7 @@ static int activate(AVFilterContext *ctx)
 
     nb_samples = ff_inlink_queued_samples(ctx->inputs[0]);
     for (i = 1; i < ctx->nb_inputs && nb_samples > 0; i++) {
-        nb_samples = FFMIN(ff_inlink_queued_samples(ctx->inputs[i]), nb_samples);
+        nb_samples = FFMINI(ff_inlink_queued_samples(ctx->inputs[i]), nb_samples);
     }
 
     if (nb_samples) {
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 082d69b97fc..a852bcd6e18 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -223,7 +223,7 @@ static void calculate_scales(MixContext *s, int nb_samples)
             if (s->scale_norm[i] > weight_sum / FFABS(s->weights[i])) {
                 s->scale_norm[i] -= ((s->weight_sum / FFABS(s->weights[i])) / s->nb_inputs) *
                                     nb_samples / (s->dropout_transition * s->sample_rate);
-                s->scale_norm[i] = FFMAX(s->scale_norm[i], weight_sum / FFABS(s->weights[i]));
+                s->scale_norm[i] = FFMAXF(s->scale_norm[i], weight_sum / FFABS(s->weights[i]));
             }
         }
     }
@@ -323,7 +323,7 @@ static int output_frame(AVFilterLink *outlink)
         for (i = 1; i < s->nb_inputs; i++) {
             if (s->input_state[i] & INPUT_ON) {
                 ns = av_audio_fifo_size(s->fifos[i]);
-                nb_samples = FFMIN(nb_samples, ns);
+                nb_samples = FFMINI(nb_samples, ns);
             }
         }
         if (nb_samples == INT_MAX) {
diff --git a/libavfilter/af_amultiply.c b/libavfilter/af_amultiply.c
index 6b6d3e0a573..9bdaf6ae1c7 100644
--- a/libavfilter/af_amultiply.c
+++ b/libavfilter/af_amultiply.c
@@ -47,7 +47,7 @@ static int activate(AVFilterContext *ctx)
 
     FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
 
-    nb_samples = FFMIN(ff_inlink_queued_samples(ctx->inputs[0]),
+    nb_samples = FFMINI(ff_inlink_queued_samples(ctx->inputs[0]),
                        ff_inlink_queued_samples(ctx->inputs[1]));
     for (i = 0; i < ctx->nb_inputs && nb_samples > 0; i++) {
         if (s->frames[i])
diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c
index 26df4f7e32f..4a0076ca5cf 100644
--- a/libavfilter/af_anequalizer.c
+++ b/libavfilter/af_anequalizer.c
@@ -720,7 +720,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 
     if (!ctx->is_disabled)
         ff_filter_execute(ctx, filter_channels, buf, NULL,
-                          FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     if (s->draw_curves) {
         AVFrame *clone;
diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
index b03dd6da2a3..5603aa2d884 100644
--- a/libavfilter/af_anlms.c
+++ b/libavfilter/af_anlms.c
@@ -115,7 +115,7 @@ static int activate(AVFilterContext *ctx)
 
     FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
 
-    nb_samples = FFMIN(ff_inlink_queued_samples(ctx->inputs[0]),
+    nb_samples = FFMINI(ff_inlink_queued_samples(ctx->inputs[0]),
                        ff_inlink_queued_samples(ctx->inputs[1]));
     for (i = 0; i < ctx->nb_inputs && nb_samples > 0; i++) {
         if (s->frame[i])
@@ -139,7 +139,7 @@ static int activate(AVFilterContext *ctx)
         }
 
         ff_filter_execute(ctx, s->filter_channels, out, NULL,
-                          FFMIN(ctx->outputs[0]->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(ctx->outputs[0]->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
         out->pts = s->frame[0]->pts;
         out->duration = s->frame[0]->duration;
diff --git a/libavfilter/af_apad.c b/libavfilter/af_apad.c
index cc214f7cc88..62884152b07 100644
--- a/libavfilter/af_apad.c
+++ b/libavfilter/af_apad.c
@@ -79,7 +79,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     APadContext *s = ctx->priv;
 
     if (s->whole_len >= 0) {
-        s->whole_len_left = FFMAX(s->whole_len_left - frame->nb_samples, 0);
+        s->whole_len_left = FFMAXI(s->whole_len_left - frame->nb_samples, 0);
         av_log(ctx, AV_LOG_DEBUG,
                "n_out:%d whole_len_left:%"PRId64"\n", frame->nb_samples, s->whole_len_left);
     }
@@ -103,7 +103,7 @@ static int push_frame(AVFilterLink *outlink)
         s->pad_len = s->pad_len_left = s->whole_len_left;
     }
     if (s->pad_len >=0 || s->whole_len >= 0) {
-        n_out = FFMIN(n_out, s->pad_len_left);
+        n_out = FFMINI(n_out, s->pad_len_left);
         s->pad_len_left -= n_out;
         av_log(ctx, AV_LOG_DEBUG,
                "padding n_out:%d pad_len_left:%"PRId64"\n", n_out, s->pad_len_left);
diff --git a/libavfilter/af_apsyclip.c b/libavfilter/af_apsyclip.c
index 35ef2cef17c..da4234b0474 100644
--- a/libavfilter/af_apsyclip.c
+++ b/libavfilter/af_apsyclip.c
@@ -136,7 +136,7 @@ static void generate_spread_table(AudioPsyClipContext *s)
         float sum = 0;
         int base_idx = table_index * s->num_psy_bins;
         int start_bin = bin * 3 / 4;
-        int end_bin = FFMIN(s->num_psy_bins, ((bin + 1) * 4 + 2) / 3);
+        int end_bin = FFMINI(s->num_psy_bins, ((bin + 1) * 4 + 2) / 3);
         int next_bin;
 
         for (int j = start_bin; j < end_bin; j++) {
@@ -303,8 +303,8 @@ static void calculate_mask_curve(AudioPsyClipContext *s,
         range[0] = s->spread_table_range[table_idx][0];
         range[1] = s->spread_table_range[table_idx][1];
         base_idx = table_idx * s->num_psy_bins;
-        start_bin = FFMAX(0, i + range[0]);
-        end_bin = FFMIN(s->num_psy_bins, i + range[1]);
+        start_bin = FFMAXI(0, i + range[0]);
+        end_bin = FFMINI(s->num_psy_bins, i + range[1]);
 
         for (int j = start_bin; j < end_bin; j++)
             mask_curve[j] += s->spread_table[base_idx + s->num_psy_bins / 2 + j - i] * magnitude;
@@ -425,7 +425,7 @@ static void feed(AVFilterContext *ctx, int ch,
     // This is just for consistency with the clipped peak calculateion
     // because the inv_window zeros out samples on the edge of the window.
     for (int i = 0; i < s->fft_size; i++)
-        orig_peak = FFMAX(orig_peak, FFABS(windowed_frame[i] * s->inv_window[i]));
+        orig_peak = FFMAXF(orig_peak, FFABS(windowed_frame[i] * s->inv_window[i]));
     orig_peak *= clip_level_inv;
     peak = orig_peak;
 
@@ -459,7 +459,7 @@ static void feed(AVFilterContext *ctx, int ch,
 
         peak = 0;
         for (int i = 0; i < s->fft_size; i++)
-            peak = FFMAX(peak, FFABS((windowed_frame[i] + clipping_delta[i]) * s->inv_window[i]));
+            peak = FFMAXF(peak, FFABS((windowed_frame[i] + clipping_delta[i]) * s->inv_window[i]));
         peak *= clip_level_inv;
 
         // Automatically adjust mask_curve as necessary to reach peak target
@@ -472,12 +472,12 @@ static void feed(AVFilterContext *ctx, int ch,
                 // don't shift the mask_curve by the full peak value
                 // On the other hand, if only a little peak reduction was achieved,
                 // don't shift the mask_curve by the enormous diff_ratio.
-                diff_ratio = FFMIN(diff_ratio, peak);
-                mask_curve_shift = FFMAX(mask_curve_shift, diff_ratio);
+                diff_ratio = FFMINF(diff_ratio, peak);
+                mask_curve_shift = FFMAXF(mask_curve_shift, diff_ratio);
             } else {
                 // If the peak got higher than the input or we are in the last 1/3 rounds,
                 // go back to the heavy-handed peak heuristic.
-                mask_curve_shift = FFMAX(mask_curve_shift, peak);
+                mask_curve_shift = FFMAXF(mask_curve_shift, peak);
             }
         }
 
@@ -558,7 +558,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     s->in = in;
     av_frame_copy_props(out, in);
     ff_filter_execute(ctx, psy_channels, out, NULL,
-                      FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     out->pts = in->pts;
     out->nb_samples = in->nb_samples;
diff --git a/libavfilter/af_apulsator.c b/libavfilter/af_apulsator.c
index 71f79a44759..477b402961c 100644
--- a/libavfilter/af_apulsator.c
+++ b/libavfilter/af_apulsator.c
@@ -93,7 +93,7 @@ static void lfo_advance(SimpleLFO *lfo, unsigned count)
 
 static double lfo_get_value(SimpleLFO *lfo)
 {
-    double phs = FFMIN(100, lfo->phase / FFMIN(1.99, FFMAX(0.01, lfo->pwidth)) + lfo->offset);
+    double phs = FFMIND(100, lfo->phase / FFMIND(1.99, FFMAXD(0.01, lfo->pwidth)) + lfo->offset);
     double val;
 
     if (phs > 1)
diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index 58e09906e06..51f3963c9c8 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -222,7 +222,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
 
     delay = swr_get_delay(aresample->swr, outlink->sample_rate);
     if (delay > 0)
-        n_out += FFMIN(delay, FFMAX(4096, n_out));
+        n_out += FFMINI(delay, FFMAXI(4096, n_out));
 
     outsamplesref = ff_get_audio_buffer(outlink, n_out);
 
diff --git a/libavfilter/af_arls.c b/libavfilter/af_arls.c
index a74d632d37b..1e547cf259c 100644
--- a/libavfilter/af_arls.c
+++ b/libavfilter/af_arls.c
@@ -112,7 +112,7 @@ static int activate(AVFilterContext *ctx)
 
     FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
 
-    nb_samples = FFMIN(ff_inlink_queued_samples(ctx->inputs[0]),
+    nb_samples = FFMINI(ff_inlink_queued_samples(ctx->inputs[0]),
                        ff_inlink_queued_samples(ctx->inputs[1]));
     for (i = 0; i < ctx->nb_inputs && nb_samples > 0; i++) {
         if (s->frame[i])
@@ -136,7 +136,7 @@ static int activate(AVFilterContext *ctx)
         }
 
         ff_filter_execute(ctx, s->filter_channels, out, NULL,
-                          FFMIN(ctx->outputs[0]->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(ctx->outputs[0]->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
         out->pts = s->frame[0]->pts;
         out->duration = s->frame[0]->duration;
diff --git a/libavfilter/af_arnndn.c b/libavfilter/af_arnndn.c
index 27a35c8492e..340ff7a166c 100644
--- a/libavfilter/af_arnndn.c
+++ b/libavfilter/af_arnndn.c
@@ -511,7 +511,7 @@ static void frame_synthesis(AudioRNNContext *s, DenoiseState *st, float *out, co
     LOCAL_ALIGNED_32(float, x, [WINDOW_SIZE]);
     const float *src = st->history;
     const float mix = s->mix;
-    const float imix = 1.f - FFMAX(mix, 0.f);
+    const float imix = 1.f - FFMAXF(mix, 0.f);
 
     inverse_transform(st, x, y);
     s->fdsp->vector_fmul(x, x, s->window, WINDOW_SIZE);
@@ -829,7 +829,7 @@ static float remove_doubling(float *x, int maxperiod, int minperiod, int N,
     yy=xx;
     for (i = 1; i <= maxperiod; i++) {
         yy = yy+(x[-i] * x[-i])-(x[N-i] * x[N-i]);
-        yy_lookup[i] = FFMAX(0, yy);
+        yy_lookup[i] = FFMAXF(0, yy);
     }
     yy = yy_lookup[T0];
     best_xy = xy;
@@ -865,13 +865,13 @@ static float remove_doubling(float *x, int maxperiod, int minperiod, int N,
             cont = prev_gain * .5f;
         else
             cont = 0;
-        thresh = FFMAX(.3f, (.7f * g0) - cont);
+        thresh = FFMAXF(.3f, (.7f * g0) - cont);
         /* Bias against very high pitch (very short period) to avoid false-positives
            due to short-term correlation */
         if (T1<3*minperiod)
-            thresh = FFMAX(.4f, (.85f * g0) - cont);
+            thresh = FFMAXF(.4f, (.85f * g0) - cont);
         else if (T1<2*minperiod)
-            thresh = FFMAX(.5f, (.9f * g0) - cont);
+            thresh = FFMAXF(.5f, (.9f * g0) - cont);
         if (g1 > thresh)
         {
             best_xy = xy;
@@ -880,7 +880,7 @@ static float remove_doubling(float *x, int maxperiod, int minperiod, int N,
             g = g1;
         }
     }
-    best_xy = FFMAX(0, best_xy);
+    best_xy = FFMAXF(0, best_xy);
     if (best_yy <= best_xy)
         pg = Q15ONE;
     else
@@ -946,7 +946,7 @@ static void find_best_pitch(float *xcorr, float *y, int len,
             }
         }
         Syy += y[i+len]*y[i+len] - y[i] * y[i];
-        Syy = FFMAX(1, Syy);
+        Syy = FFMAXF(1, Syy);
     }
 }
 
@@ -982,7 +982,7 @@ static void pitch_search(const float *x_lp, float *y,
         if (FFABS(i-2*best_pitch[0])>2 && FFABS(i-2*best_pitch[1])>2)
             continue;
         sum = celt_inner_prod(x_lp, y+i, len>>1);
-        xcorr[i] = FFMAX(-1, sum);
+        xcorr[i] = FFMAXF(-1, sum);
     }
 
     find_best_pitch(xcorr, y, len>>1, max_pitch>>1, best_pitch);
@@ -1070,9 +1070,9 @@ static int compute_frame_features(AudioRNNContext *s, DenoiseState *st, AVComple
 
     for (int i = 0; i < NB_BANDS; i++) {
         Ly[i] = log10f(1e-2f + Ex[i]);
-        Ly[i] = FFMAX(logMax-7, FFMAX(follow-1.5, Ly[i]));
-        logMax = FFMAX(logMax, Ly[i]);
-        follow = FFMAX(follow-1.5, Ly[i]);
+        Ly[i] = FFMAXF(logMax-7, FFMAXD(follow-1.5, Ly[i]));
+        logMax = FFMAXF(logMax, Ly[i]);
+        follow = FFMAXD(follow-1.5, Ly[i]);
         E += Ex[i];
     }
 
@@ -1114,7 +1114,7 @@ static int compute_frame_features(AudioRNNContext *s, DenoiseState *st, AVComple
             }
 
             if (j != i)
-                mindist = FFMIN(mindist, dist);
+                mindist = FFMINF(mindist, dist);
         }
 
         spec_variability += mindist;
@@ -1270,7 +1270,7 @@ static void compute_dense(const DenseLayer *layer, float *output, const float *i
             output[i] = tansig_approx(output[i]);
     } else if (layer->activation == ACTIVATION_RELU) {
         for (int i = 0; i < N; i++)
-            output[i] = FFMAX(0, output[i]);
+            output[i] = FFMAXF(0, output[i]);
     } else {
         av_assert0(0);
     }
@@ -1318,7 +1318,7 @@ static void compute_gru(AudioRNNContext *s, const GRULayer *gru, float *state, c
         else if (gru->activation == ACTIVATION_TANH)
             sum = tansig_approx(WEIGHTS_SCALE * sum);
         else if (gru->activation == ACTIVATION_RELU)
-            sum = FFMAX(0, WEIGHTS_SCALE * sum);
+            sum = FFMAXF(0, WEIGHTS_SCALE * sum);
         else
             av_assert0(0);
         h[i] = z[i] * state[i] + (1.f - z[i]) * sum;
@@ -1383,7 +1383,7 @@ static float rnnoise_channel(AudioRNNContext *s, DenoiseState *st, float *out, c
         for (int i = 0; i < NB_BANDS; i++) {
             float alpha = .6f;
 
-            g[i] = FFMAX(g[i], alpha * st->lastg[i]);
+            g[i] = FFMAXF(g[i], alpha * st->lastg[i]);
             st->lastg[i] = g[i];
         }
 
@@ -1440,7 +1440,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in; td.out = out;
     ff_filter_execute(ctx, rnnoise_channels, &td, NULL,
-                      FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/af_asdr.c b/libavfilter/af_asdr.c
index ea74940179e..55c253d3794 100644
--- a/libavfilter/af_asdr.c
+++ b/libavfilter/af_asdr.c
@@ -152,7 +152,7 @@ static int activate(AVFilterContext *ctx)
 
     FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
 
-    available = FFMIN(ff_inlink_queued_samples(ctx->inputs[0]), ff_inlink_queued_samples(ctx->inputs[1]));
+    available = FFMINI(ff_inlink_queued_samples(ctx->inputs[0]), ff_inlink_queued_samples(ctx->inputs[1]));
     if (available > 0) {
         AVFrame *out;
 
@@ -167,7 +167,7 @@ static int activate(AVFilterContext *ctx)
 
         if (!ctx->is_disabled)
             ff_filter_execute(ctx, s->filter, NULL, NULL,
-                              FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                              FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
         av_frame_free(&s->cache[1]);
         out = s->cache[0];
diff --git a/libavfilter/af_asetrate.c b/libavfilter/af_asetrate.c
index 9cf4cb806b0..23ec285a39e 100644
--- a/libavfilter/af_asetrate.c
+++ b/libavfilter/af_asetrate.c
@@ -76,7 +76,7 @@ static av_cold int config_props(AVFilterLink *outlink)
     } else {
         outlink->time_base = intb;
         sr->rescale_pts = 1;
-        if (av_q2d(intb) > 1.0 / FFMAX(inrate, outlink->sample_rate))
+        if (av_q2d(intb) > 1.0 / FFMAXI(inrate, outlink->sample_rate))
             av_log(ctx, AV_LOG_WARNING, "Time base is inaccurate\n");
     }
     return 0;
diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c
index 19923f2c34e..448a5997e20 100644
--- a/libavfilter/af_asoftclip.c
+++ b/libavfilter/af_asoftclip.c
@@ -447,7 +447,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.nb_samples = nb_samples;
     td.channels = channels;
     ff_filter_execute(ctx, filter_channels, &td, NULL,
-                      FFMIN(channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(channels, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
diff --git a/libavfilter/af_aspectralstats.c b/libavfilter/af_aspectralstats.c
index ac7da748ee6..3bd7afdd593 100644
--- a/libavfilter/af_aspectralstats.c
+++ b/libavfilter/af_aspectralstats.c
@@ -530,7 +530,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     metadata = &out->metadata;
     ff_filter_execute(ctx, filter_channel, in, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     set_metadata(s, metadata);
 
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index aa2028d3f01..71cef441187 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -214,7 +214,7 @@ static int config_output(AVFilterLink *outlink)
     if (!s->chstats)
         return AVERROR(ENOMEM);
 
-    s->tc_samples = FFMAX(s->time_constant * outlink->sample_rate + .5, 1);
+    s->tc_samples = FFMAXD(s->time_constant * outlink->sample_rate + .5, 1);
     s->nb_channels = outlink->ch_layout.nb_channels;
 
     for (int i = 0; i < s->nb_channels; i++) {
@@ -396,8 +396,8 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
     p->sigma_x2 += nd * nd;
     p->avg_sigma_x2 = p->avg_sigma_x2 * s->mult + (1.0 - s->mult) * nd * nd;
     if (!isnan(p->last)) {
-        p->min_diff = FFMIN(p->min_diff, fabs(d - p->last));
-        p->max_diff = FFMAX(p->max_diff, fabs(d - p->last));
+        p->min_diff = FFMIND(p->min_diff, fabs(d - p->last));
+        p->max_diff = FFMAXD(p->max_diff, fabs(d - p->last));
         p->diff1_sum += fabs(d - p->last);
         p->diff1_sum_x2 += (d - p->last) * (d - p->last);
     }
@@ -412,7 +412,7 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
     drop = p->win_samples[p->win_pos];
     p->win_samples[p->win_pos] = nd;
     index = av_clip(lrint(av_clipd(FFABS(nd), 0.0, 1.0) * HISTOGRAM_MAX), 0, HISTOGRAM_MAX);
-    p->max_index = FFMAX(p->max_index, index);
+    p->max_index = FFMAXI(p->max_index, index);
     p->ehistogram[index]++;
     p->win_pos++;
 
@@ -420,8 +420,8 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
         p->win_pos = 0;
 
     if (p->nb_samples >= s->tc_samples) {
-        p->max_sigma_x2 = FFMAX(p->max_sigma_x2, p->avg_sigma_x2);
-        p->min_sigma_x2 = FFMIN(p->min_sigma_x2, p->avg_sigma_x2);
+        p->max_sigma_x2 = FFMAXD(p->max_sigma_x2, p->avg_sigma_x2);
+        p->min_sigma_x2 = FFMIND(p->min_sigma_x2, p->avg_sigma_x2);
     }
     p->nb_samples++;
 
@@ -506,18 +506,18 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
         if (p->nb_samples < s->tc_samples)
             p->min_sigma_x2 = p->max_sigma_x2 = p->sigma_x2 / p->nb_samples;
 
-        min = FFMIN(min, p->min);
-        max = FFMAX(max, p->max);
-        nmin = FFMIN(nmin, p->nmin);
-        nmax = FFMAX(nmax, p->nmax);
-        min_diff = FFMIN(min_diff, p->min_diff);
-        max_diff = FFMAX(max_diff, p->max_diff);
+        min = FFMIND(min, p->min);
+        max = FFMAXD(max, p->max);
+        nmin = FFMIND(nmin, p->nmin);
+        nmax = FFMAXD(nmax, p->nmax);
+        min_diff = FFMIND(min_diff, p->min_diff);
+        max_diff = FFMAXD(max_diff, p->max_diff);
         diff1_sum += p->diff1_sum;
         diff1_sum_x2 += p->diff1_sum_x2;
-        min_sigma_x2 = FFMIN(min_sigma_x2, p->min_sigma_x2);
-        max_sigma_x2 = FFMAX(max_sigma_x2, p->max_sigma_x2);
+        min_sigma_x2 = FFMIND(min_sigma_x2, p->min_sigma_x2);
+        max_sigma_x2 = FFMAXD(max_sigma_x2, p->max_sigma_x2);
         sigma_x2 += p->sigma_x2;
-        noise_floor = FFMAX(noise_floor, p->noise_floor);
+        noise_floor = FFMAXD(noise_floor, p->noise_floor);
         noise_floor_count += p->noise_floor_count;
         p->entropy = calc_entropy(s, p);
         entropy += p->entropy;
@@ -552,7 +552,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
         if (s->measure_perchannel & MEASURE_RMS_DIFFERENCE)
             set_meta(metadata, c + 1, "RMS_difference", "%f", sqrt(p->diff1_sum_x2 / (p->nb_samples - 1)));
         if (s->measure_perchannel & MEASURE_PEAK_LEVEL)
-            set_meta(metadata, c + 1, "Peak_level", "%f", LINEAR_TO_DB(FFMAX(-p->nmin, p->nmax)));
+            set_meta(metadata, c + 1, "Peak_level", "%f", LINEAR_TO_DB(FFMAXD(-p->nmin, p->nmax)));
         if (s->measure_perchannel & MEASURE_RMS_LEVEL)
             set_meta(metadata, c + 1, "RMS_level", "%f", LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples)));
         if (s->measure_perchannel & MEASURE_RMS_PEAK)
@@ -560,7 +560,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
         if (s->measure_perchannel & MEASURE_RMS_TROUGH)
             set_meta(metadata, c + 1, "RMS_trough", "%f", LINEAR_TO_DB(sqrt(p->min_sigma_x2)));
         if (s->measure_perchannel & MEASURE_CREST_FACTOR)
-            set_meta(metadata, c + 1, "Crest_factor", "%f", p->sigma_x2 ? FFMAX(-p->min, p->max) / sqrt(p->sigma_x2 / p->nb_samples) : 1);
+            set_meta(metadata, c + 1, "Crest_factor", "%f", p->sigma_x2 ? FFMAXD(-p->min, p->max) / sqrt(p->sigma_x2 / p->nb_samples) : 1);
         if (s->measure_perchannel & MEASURE_FLAT_FACTOR)
             set_meta(metadata, c + 1, "Flat_factor", "%f", LINEAR_TO_DB((p->min_runs + p->max_runs) / (p->min_count + p->max_count)));
         if (s->measure_perchannel & MEASURE_PEAK_COUNT)
@@ -581,7 +581,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
             set_meta(metadata, c + 1, "Bit_depth4", "%f", depth[3]);
         }
         if (s->measure_perchannel & MEASURE_DYNAMIC_RANGE)
-            set_meta(metadata, c + 1, "Dynamic_range", "%f", LINEAR_TO_DB(2 * FFMAX(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
+            set_meta(metadata, c + 1, "Dynamic_range", "%f", LINEAR_TO_DB(2 * FFMAXD(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
         if (s->measure_perchannel & MEASURE_ZERO_CROSSINGS)
             set_meta(metadata, c + 1, "Zero_crossings", "%f", p->zero_runs);
         if (s->measure_perchannel & MEASURE_ZERO_CROSSINGS_RATE)
@@ -609,7 +609,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
     if (s->measure_overall & MEASURE_RMS_DIFFERENCE)
         set_meta(metadata, 0, "Overall.RMS_difference", "%f", sqrt(diff1_sum_x2 / (nb_samples - s->nb_channels)));
     if (s->measure_overall & MEASURE_PEAK_LEVEL)
-        set_meta(metadata, 0, "Overall.Peak_level", "%f", LINEAR_TO_DB(FFMAX(-nmin, nmax)));
+        set_meta(metadata, 0, "Overall.Peak_level", "%f", LINEAR_TO_DB(FFMAXD(-nmin, nmax)));
     if (s->measure_overall & MEASURE_RMS_LEVEL)
         set_meta(metadata, 0, "Overall.RMS_level", "%f", LINEAR_TO_DB(sqrt(sigma_x2 / nb_samples)));
     if (s->measure_overall & MEASURE_RMS_PEAK)
@@ -740,7 +740,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     if (s->used == 0)
         s->used = buf->nb_samples > 0;
     ff_filter_execute(ctx, filter_channel, buf, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     if (s->metadata)
         set_metadata(s, metadata);
@@ -781,18 +781,18 @@ static void print_stats(AVFilterContext *ctx)
         if (p->nb_samples < s->tc_samples)
             p->min_sigma_x2 = p->max_sigma_x2 = p->sigma_x2 / p->nb_samples;
 
-        min = FFMIN(min, p->min);
-        max = FFMAX(max, p->max);
-        nmin = FFMIN(nmin, p->nmin);
-        nmax = FFMAX(nmax, p->nmax);
-        min_diff = FFMIN(min_diff, p->min_diff);
-        max_diff = FFMAX(max_diff, p->max_diff);
+        min = FFMIND(min, p->min);
+        max = FFMAXD(max, p->max);
+        nmin = FFMIND(nmin, p->nmin);
+        nmax = FFMAXD(nmax, p->nmax);
+        min_diff = FFMIND(min_diff, p->min_diff);
+        max_diff = FFMAXD(max_diff, p->max_diff);
         diff1_sum_x2 += p->diff1_sum_x2;
         diff1_sum += p->diff1_sum;
-        min_sigma_x2 = FFMIN(min_sigma_x2, p->min_sigma_x2);
-        max_sigma_x2 = FFMAX(max_sigma_x2, p->max_sigma_x2);
+        min_sigma_x2 = FFMIND(min_sigma_x2, p->min_sigma_x2);
+        max_sigma_x2 = FFMAXD(max_sigma_x2, p->max_sigma_x2);
         sigma_x2 += p->sigma_x2;
-        noise_floor = FFMAX(noise_floor, p->noise_floor);
+        noise_floor = FFMAXD(noise_floor, p->noise_floor);
         p->entropy = calc_entropy(s, p);
         entropy += p->entropy;
         min_count += p->min_count;
@@ -829,7 +829,7 @@ static void print_stats(AVFilterContext *ctx)
         if (s->measure_perchannel & MEASURE_RMS_DIFFERENCE)
             av_log(ctx, AV_LOG_INFO, "RMS difference: %f\n", sqrt(p->diff1_sum_x2 / (p->nb_samples - 1)));
         if (s->measure_perchannel & MEASURE_PEAK_LEVEL)
-            av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAX(-p->nmin, p->nmax)));
+            av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAXD(-p->nmin, p->nmax)));
         if (s->measure_perchannel & MEASURE_RMS_LEVEL)
             av_log(ctx, AV_LOG_INFO, "RMS level dB: %f\n", LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples)));
         if (s->measure_perchannel & MEASURE_RMS_PEAK)
@@ -838,7 +838,7 @@ static void print_stats(AVFilterContext *ctx)
             if (p->min_sigma_x2 != 1)
                 av_log(ctx, AV_LOG_INFO, "RMS trough dB: %f\n",LINEAR_TO_DB(sqrt(p->min_sigma_x2)));
         if (s->measure_perchannel & MEASURE_CREST_FACTOR)
-            av_log(ctx, AV_LOG_INFO, "Crest factor: %f\n", p->sigma_x2 ? FFMAX(-p->nmin, p->nmax) / sqrt(p->sigma_x2 / p->nb_samples) : 1);
+            av_log(ctx, AV_LOG_INFO, "Crest factor: %f\n", p->sigma_x2 ? FFMAXD(-p->nmin, p->nmax) / sqrt(p->sigma_x2 / p->nb_samples) : 1);
         if (s->measure_perchannel & MEASURE_FLAT_FACTOR)
             av_log(ctx, AV_LOG_INFO, "Flat factor: %f\n", LINEAR_TO_DB((p->min_runs + p->max_runs) / (p->min_count + p->max_count)));
         if (s->measure_perchannel & MEASURE_PEAK_COUNT)
@@ -856,7 +856,7 @@ static void print_stats(AVFilterContext *ctx)
             av_log(ctx, AV_LOG_INFO, "Bit depth: %u/%u/%u/%u\n", depth[0], depth[1], depth[2], depth[3]);
         }
         if (s->measure_perchannel & MEASURE_DYNAMIC_RANGE)
-            av_log(ctx, AV_LOG_INFO, "Dynamic range: %f\n", LINEAR_TO_DB(2 * FFMAX(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
+            av_log(ctx, AV_LOG_INFO, "Dynamic range: %f\n", LINEAR_TO_DB(2 * FFMAXD(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
         if (s->measure_perchannel & MEASURE_ZERO_CROSSINGS)
             av_log(ctx, AV_LOG_INFO, "Zero crossings: %"PRId64"\n", p->zero_runs);
         if (s->measure_perchannel & MEASURE_ZERO_CROSSINGS_RATE)
@@ -889,7 +889,7 @@ static void print_stats(AVFilterContext *ctx)
     if (s->measure_overall & MEASURE_RMS_DIFFERENCE)
         av_log(ctx, AV_LOG_INFO, "RMS difference: %f\n", sqrt(diff1_sum_x2 / (nb_samples - s->nb_channels)));
     if (s->measure_overall & MEASURE_PEAK_LEVEL)
-        av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAX(-nmin, nmax)));
+        av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAXD(-nmin, nmax)));
     if (s->measure_overall & MEASURE_RMS_LEVEL)
         av_log(ctx, AV_LOG_INFO, "RMS level dB: %f\n", LINEAR_TO_DB(sqrt(sigma_x2 / nb_samples)));
     if (s->measure_overall & MEASURE_RMS_PEAK)
diff --git a/libavfilter/af_asubboost.c b/libavfilter/af_asubboost.c
index 58135626b92..77e4f34b7b7 100644
--- a/libavfilter/af_asubboost.c
+++ b/libavfilter/af_asubboost.c
@@ -182,7 +182,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in; td.out = out;
     ff_filter_execute(ctx, filter_channels, &td, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
index 62a8e11b789..5d70bc01d7e 100644
--- a/libavfilter/af_atempo.c
+++ b/libavfilter/af_atempo.c
@@ -374,7 +374,7 @@ static int yae_update(AVFilterContext *ctx)
                 src += sizeof(scalar_type);                             \
                                                                         \
                 max = (float)tmp;                                       \
-                s = FFMIN((float)scalar_max,                            \
+                s = FFMINF((float)scalar_max,                            \
                           (float)fabsf(max));                           \
                                                                         \
                 for (i = 1; i < atempo->channels; i++) {                \
@@ -382,7 +382,7 @@ static int yae_update(AVFilterContext *ctx)
                     src += sizeof(scalar_type);                         \
                                                                         \
                     ti = (float)tmp;                                    \
-                    si = FFMIN((float)scalar_max,                       \
+                    si = FFMINF((float)scalar_max,                       \
                                (float)fabsf(ti));                       \
                                                                         \
                     if (s < si) {                                       \
@@ -448,13 +448,13 @@ static int yae_load_data(ATempoContext *atempo,
         int src_samples = (src_end - src) / atempo->stride;
 
         // load data piece-wise, in order to avoid complicating the logic:
-        int nsamples = FFMIN(read_size, src_samples);
+        int nsamples = FFMINI(read_size, src_samples);
         int na;
         int nb;
 
-        nsamples = FFMIN(nsamples, atempo->ring);
-        na = FFMIN(nsamples, atempo->ring - atempo->tail);
-        nb = FFMIN(nsamples - na, atempo->ring);
+        nsamples = FFMINI(nsamples, atempo->ring);
+        na = FFMINI(nsamples, atempo->ring - atempo->tail);
+        nb = FFMINI(nsamples - na, atempo->ring);
 
         if (na) {
             uint8_t *a = atempo->buffer + atempo->tail * atempo->stride;
@@ -463,7 +463,7 @@ static int yae_load_data(ATempoContext *atempo,
             src += na * atempo->stride;
             atempo->position[0] += na;
 
-            atempo->size = FFMIN(atempo->size + na, atempo->ring);
+            atempo->size = FFMINI(atempo->size + na, atempo->ring);
             atempo->tail = (atempo->tail + na) % atempo->ring;
             atempo->head =
                 atempo->size < atempo->ring ?
@@ -478,7 +478,7 @@ static int yae_load_data(ATempoContext *atempo,
             src += nb * atempo->stride;
             atempo->position[0] += nb;
 
-            atempo->size = FFMIN(atempo->size + nb, atempo->ring);
+            atempo->size = FFMINI(atempo->size + nb, atempo->ring);
             atempo->tail = (atempo->tail + nb) % atempo->ring;
             atempo->head =
                 atempo->size < atempo->ring ?
@@ -538,7 +538,7 @@ static int yae_load_frag(ATempoContext *atempo,
     // what we don't have we substitute with zeros:
     zeros =
       frag->position[0] < start ?
-      FFMIN(start - frag->position[0], (int64_t)nsamples) : 0;
+      FFMINI(start - frag->position[0], (int64_t)nsamples) : 0;
 
     if (zeros == nsamples) {
         return 0;
@@ -565,7 +565,7 @@ static int yae_load_frag(ATempoContext *atempo,
     i0 = frag->position[0] + zeros - start;
     i1 = i0 < na ? 0 : i0 - na;
 
-    n0 = i0 < na ? FFMIN(na - i0, (int)(nsamples - zeros)) : 0;
+    n0 = i0 < na ? FFMINI(na - i0, (int)(nsamples - zeros)) : 0;
     n1 = nsamples - zeros - n0;
 
     if (n0) {
@@ -658,11 +658,11 @@ static int yae_align(AudioFragment *frag,
                        window);
 
     // identify search window boundaries:
-    i0 = FFMAX(window / 2 - delta_max - drift, 0);
-    i0 = FFMIN(i0, window);
+    i0 = FFMAXI(window / 2 - delta_max - drift, 0);
+    i0 = FFMINI(i0, window);
 
-    i1 = FFMIN(window / 2 + delta_max - drift, window - window / 16);
-    i1 = FFMAX(i1, 0);
+    i1 = FFMINI(window / 2 + delta_max - drift, window - window / 16);
+    i1 = FFMAXI(i1, 0);
 
     // identify cross-correlation peaks within search window:
     xcorr = correlation + i0;
@@ -774,10 +774,10 @@ static int yae_overlap_add(ATempoContext *atempo,
     const AudioFragment *prev = yae_prev_frag(atempo);
     const AudioFragment *frag = yae_curr_frag(atempo);
 
-    const int64_t start_here = FFMAX(atempo->position[1],
+    const int64_t start_here = FFMAXI(atempo->position[1],
                                      frag->position[1]);
 
-    const int64_t stop_here = FFMIN(prev->position[1] + prev->nsamples,
+    const int64_t stop_here = FFMINI(prev->position[1] + prev->nsamples,
                                     frag->position[1] + frag->nsamples);
 
     const int64_t overlap = stop_here - start_here;
@@ -945,7 +945,7 @@ static int yae_flush(ATempoContext *atempo,
     }
 
     // flush the overlap region:
-    overlap_end = frag->position[1] + FFMIN(atempo->window / 2,
+    overlap_end = frag->position[1] + FFMINI(atempo->window / 2,
                                             frag->nsamples);
 
     while (atempo->position[1] < overlap_end) {
@@ -961,7 +961,7 @@ static int yae_flush(ATempoContext *atempo,
     }
 
     // flush the remainder of the current fragment:
-    start_here = FFMAX(atempo->position[1], overlap_end);
+    start_here = FFMAXI(atempo->position[1], overlap_end);
     stop_here  = frag->position[1] + frag->nsamples;
     offset     = start_here - frag->position[1];
     av_assert0(start_here <= stop_here && frag->position[1] <= start_here);
@@ -971,7 +971,7 @@ static int yae_flush(ATempoContext *atempo,
 
     src_size = (int)(stop_here - start_here) * atempo->stride;
     dst_size = dst_end - dst;
-    nbytes = FFMIN(src_size, dst_size);
+    nbytes = FFMINI(src_size, dst_size);
 
     memcpy(dst, src, nbytes);
     dst += nbytes;
diff --git a/libavfilter/af_atilt.c b/libavfilter/af_atilt.c
index b2cdef8fbb3..5a9410adc8c 100644
--- a/libavfilter/af_atilt.c
+++ b/libavfilter/af_atilt.c
@@ -196,7 +196,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     td.in = in; td.out = out;
-    ff_filter_execute(ctx, s->filter_channels, &td, NULL, FFMIN(inlink->ch_layout.nb_channels,
+    ff_filter_execute(ctx, s->filter_channels, &td, NULL, FFMINI(inlink->ch_layout.nb_channels,
                                                                ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
diff --git a/libavfilter/af_axcorrelate.c b/libavfilter/af_axcorrelate.c
index eb61536c4e3..eb93d1d9fe1 100644
--- a/libavfilter/af_axcorrelate.c
+++ b/libavfilter/af_axcorrelate.c
@@ -283,7 +283,7 @@ static int activate(AVFilterContext *ctx)
         }
     }
 
-    available = FFMIN(av_audio_fifo_size(s->fifo[0]), av_audio_fifo_size(s->fifo[1]));
+    available = FFMINI(av_audio_fifo_size(s->fifo[0]), av_audio_fifo_size(s->fifo[1]));
     if (available > s->size) {
         const int out_samples = available - s->size;
         AVFrame *out;
diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index 88992e36b9d..efc1625a2f6 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -1330,7 +1330,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf, int eof)
     td.out = out_buf;
     td.eof = eof;
     ff_filter_execute(ctx, filter_channel, &td, NULL,
-                      FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     for (ch = 0; ch < outlink->ch_layout.nb_channels; ch++) {
         if (s->clip[ch] > 0)
diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index a883934fa6f..0d83dc37b22 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -399,7 +399,7 @@ static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
 
     if (buf->data != buf->extended_data)
         memcpy(buf->data, buf->extended_data,
-           FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));
+           FFMINI(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));
 
     if ((ret = av_channel_layout_copy(&buf->ch_layout, &outlink->ch_layout)) < 0)
         return ret;
diff --git a/libavfilter/af_chorus.c b/libavfilter/af_chorus.c
index f7eeea3a238..0cd0e9b9c29 100644
--- a/libavfilter/af_chorus.c
+++ b/libavfilter/af_chorus.c
@@ -176,7 +176,7 @@ static int config_output(AVFilterLink *outlink)
 
         ff_generate_wave_table(WAVE_SIN, AV_SAMPLE_FMT_S32, s->lookup_table[n],
                                s->length[n], 0., depth_samples, 0);
-        s->max_samples = FFMAX(s->max_samples, samples);
+        s->max_samples = FFMAXI(s->max_samples, samples);
     }
 
     for (n = 0; n < s->num_chorus; n++)
@@ -271,7 +271,7 @@ static int request_frame(AVFilterLink *outlink)
     ret = ff_request_frame(ctx->inputs[0]);
 
     if (ret == AVERROR_EOF && !ctx->is_disabled && s->fade_out) {
-        int nb_samples = FFMIN(s->fade_out, 2048);
+        int nb_samples = FFMINI(s->fade_out, 2048);
         AVFrame *frame;
 
         frame = ff_get_audio_buffer(outlink, nb_samples);
diff --git a/libavfilter/af_compand.c b/libavfilter/af_compand.c
index 69de1360f17..e6bdb1e8dfa 100644
--- a/libavfilter/af_compand.c
+++ b/libavfilter/af_compand.c
@@ -270,7 +270,7 @@ static int compand_drain(AVFilterLink *outlink)
     int chan, i, dindex;
 
     /* 2048 is to limit output frame size during drain */
-    frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->delay_count));
+    frame = ff_get_audio_buffer(outlink, FFMINI(2048, s->delay_count));
     if (!frame)
         return AVERROR(ENOMEM);
     frame->pts = s->pts;
@@ -320,8 +320,8 @@ static int config_output(AVFilterLink *outlink)
     if (nb_attacks > channels || nb_decays > channels) {
         av_log(ctx, AV_LOG_WARNING,
                 "Number of attacks/decays bigger than number of channels. Ignoring rest of entries.\n");
-        nb_attacks = FFMIN(nb_attacks, channels);
-        nb_decays  = FFMIN(nb_decays, channels);
+        nb_attacks = FFMINI(nb_attacks, channels);
+        nb_decays  = FFMINI(nb_decays, channels);
     }
 
     uninit(ctx);
@@ -445,13 +445,13 @@ static int config_output(AVFilterLink *outlink)
 
         theta = atan2(L(2).y - L(4).y, L(2).x - L(4).x);
         len = hypot(L(2).x - L(4).x, L(2).y - L(4).y);
-        r = FFMIN(radius, len);
+        r = FFMIND(radius, len);
         L(3).x = L(2).x - r * cos(theta);
         L(3).y = L(2).y - r * sin(theta);
 
         theta = atan2(L(0).y - L(2).y, L(0).x - L(2).x);
         len = hypot(L(0).x - L(2).x, L(0).y - L(2).y);
-        r = FFMIN(radius, len / 2);
+        r = FFMIND(radius, len / 2);
         x = L(2).x + r * cos(theta);
         y = L(2).y + r * sin(theta);
 
diff --git a/libavfilter/af_crystalizer.c b/libavfilter/af_crystalizer.c
index 3cb5dc71d83..0bbc763592c 100644
--- a/libavfilter/af_crystalizer.c
+++ b/libavfilter/af_crystalizer.c
@@ -209,7 +209,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.channels = in->ch_layout.nb_channels;
     td.mult = ctx->is_disabled ? 0.f : s->mult;
     ff_filter_execute(ctx, s->filter[td.mult >= 0.f][s->clip], &td, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
diff --git a/libavfilter/af_deesser.c b/libavfilter/af_deesser.c
index 657604267c4..8317e5ca69b 100644
--- a/libavfilter/af_deesser.c
+++ b/libavfilter/af_deesser.c
@@ -130,7 +130,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             attackspeed = 7.0 + sense * 1024;
 
             sense = 1.0 + intensity * intensity * sense;
-            sense = FFMIN(sense, intensity);
+            sense = FFMIND(sense, intensity);
             recovery = 1.0 + (0.01 / sense);
 
             offset = 1.0 - fabs(sample);
@@ -144,7 +144,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                     dec->ratioA = 1.0 + ((dec->ratioA - 1.0) / recovery);
                 }
 
-                dec->ratioA = FFMIN(dec->ratioA, maxdess);
+                dec->ratioA = FFMIND(dec->ratioA, maxdess);
                 sample = dec->iirSampleA + ((sample - dec->iirSampleA) / dec->ratioA);
             } else {
                 dec->iirSampleB = (dec->iirSampleB * (1.0 - (offset * iirAmount))) +
@@ -155,7 +155,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                     dec->ratioB = 1.0 + ((dec->ratioB - 1.0) / recovery);
                 }
 
-                dec->ratioB = FFMIN(dec->ratioB, maxdess);
+                dec->ratioB = FFMIND(dec->ratioB, maxdess);
                 sample = dec->iirSampleB + ((sample - dec->iirSampleB) / dec->ratioB);
             }
 
diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index ddeedf62584..425e8066a2f 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -386,7 +386,7 @@ static int config_input(AVFilterLink *inlink)
     s->window = ff_get_audio_buffer(ctx->outputs[0], s->frame_len * 2);
     if (!s->window)
         return AVERROR(ENOMEM);
-    s->sample_advance = FFMAX(1, lrint(s->frame_len * (1. - s->overlap)));
+    s->sample_advance = FFMAXI(1, lrint(s->frame_len * (1. - s->overlap)));
 
     s->var_values[VAR_SR] = inlink->sample_rate;
     s->var_values[VAR_NB_CHANNELS] = s->channels;
@@ -776,7 +776,7 @@ static int analyze_frame(AVFilterContext *ctx, AVFilterLink *outlink, AVFrame **
         analyze_frame = s->window;
     } else {
         av_samples_copy(s->window->extended_data, (*frame)->extended_data, 0, 0,
-                        FFMIN(s->frame_len, (*frame)->nb_samples), (*frame)->ch_layout.nb_channels, (*frame)->format);
+                        FFMINI(s->frame_len, (*frame)->nb_samples), (*frame)->ch_layout.nb_channels, (*frame)->format);
         analyze_frame = *frame;
     }
 
@@ -789,7 +789,7 @@ static int analyze_frame(AVFilterContext *ctx, AVFilterLink *outlink, AVFrame **
             update_gain_history(s, c, gain);
     } else {
         ff_filter_execute(ctx, update_gain_histories, analyze_frame, NULL,
-                          FFMIN(s->channels, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->channels, ff_filter_get_nb_threads(ctx)));
     }
 
     return 0;
@@ -865,7 +865,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         td.out = out;
         td.enabled = is_enabled > 0.;
         ff_filter_execute(ctx, amplify_channels, &td, NULL,
-                          FFMIN(s->channels, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->channels, ff_filter_get_nb_threads(ctx)));
 
         s->pts = out->pts + av_rescale_q(out->nb_samples, av_make_q(1, outlink->sample_rate),
                                          outlink->time_base);
@@ -1002,7 +1002,7 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar
     }
 
     s->frame_len = frame_size(inlink->sample_rate, s->frame_len_msec);
-    s->sample_advance = FFMAX(1, lrint(s->frame_len * (1. - s->overlap)));
+    s->sample_advance = FFMAXI(1, lrint(s->frame_len * (1. - s->overlap)));
     if (s->expr_str) {
         ret = av_expr_parse(&s->expr, s->expr_str, var_names, NULL, NULL,
                             NULL, NULL, 0, ctx);
diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c
index 38663200ebe..f4067545f8a 100644
--- a/libavfilter/af_firequalizer.c
+++ b/libavfilter/af_firequalizer.c
@@ -550,7 +550,7 @@ static void generate_min_phase_kernel(FIREqualizerContext *s, float *rdft_buf)
     s->cepstrum_rdft_fn(s->cepstrum_rdft, s->cepstrum_tbuf, s->cepstrum_buf, sizeof(float));
 
     for (k = 0; k < cepstrum_len + 2; k += 2) {
-        s->cepstrum_tbuf[k] = log(FFMAX(s->cepstrum_tbuf[k], minval));
+        s->cepstrum_tbuf[k] = log(FFMAXD(s->cepstrum_tbuf[k], minval));
         s->cepstrum_tbuf[k+1] = 0;
     }
 
@@ -736,7 +736,7 @@ static int config_input(AVFilterLink *inlink)
     s->next_pts = 0;
     s->frame_nsamples_max = 0;
 
-    s->fir_len = FFMAX(2 * (int)(inlink->sample_rate * s->delay) + 1, 3);
+    s->fir_len = FFMAXI(2 * (int)(inlink->sample_rate * s->delay) + 1, 3);
     s->remaining = s->fir_len - 1;
 
     for (rdft_bits = RDFT_BITS_MIN; rdft_bits <= RDFT_BITS_MAX; rdft_bits++) {
@@ -768,7 +768,7 @@ static int config_input(AVFilterLink *inlink)
             return AVERROR(EINVAL);
         }
 
-        cepstrum_bits = FFMIN(RDFT_BITS_MAX, cepstrum_bits + 1);
+        cepstrum_bits = FFMINI(RDFT_BITS_MAX, cepstrum_bits + 1);
         scale = 1.f;
         ret = av_tx_init(&s->cepstrum_rdft,  &s->cepstrum_rdft_fn,  AV_TX_FLOAT_RDFT, 0, 1 << cepstrum_bits, &scale, 0);
         if (ret < 0)
@@ -862,7 +862,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         if (s->zero_phase && !s->min_phase)
             frame->pts -= av_rescale_q(s->fir_len/2, av_make_q(1, inlink->sample_rate), inlink->time_base);
     }
-    s->frame_nsamples_max = FFMAX(s->frame_nsamples_max, frame->nb_samples);
+    s->frame_nsamples_max = FFMAXI(s->frame_nsamples_max, frame->nb_samples);
     return ff_filter_frame(ctx->outputs[0], frame);
 }
 
@@ -874,7 +874,7 @@ static int request_frame(AVFilterLink *outlink)
 
     ret = ff_request_frame(ctx->inputs[0]);
     if (ret == AVERROR_EOF && s->remaining > 0 && s->frame_nsamples_max > 0) {
-        AVFrame *frame = ff_get_audio_buffer(outlink, FFMIN(s->remaining, s->frame_nsamples_max));
+        AVFrame *frame = ff_get_audio_buffer(outlink, FFMINI(s->remaining, s->frame_nsamples_max));
 
         if (!frame)
             return AVERROR(ENOMEM);
diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 6bded8ef740..576f28bb521 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -1051,7 +1051,7 @@ static int hdcd_integrate(HDCDContext *ctx, hdcd_state *states, int channels, in
     if (stride < channels) stride = channels;
 
     for (i = 0; i < channels; i++)
-        result = FFMIN(states[i].readahead, result);
+        result = FFMINI(states[i].readahead, result);
 
     for (j = result - 1; j >= 0; j--) {
         for (i = 0; i < channels; i++)
@@ -1105,7 +1105,7 @@ static int hdcd_integrate(HDCDContext *ctx, hdcd_state *states, int channels, in
                     if (states[i].control & 16) states[i].count_peak_extend++;
                     if (states[i].control & 32) states[i].count_transient_filter++;
                     states[i].gain_counts[states[i].control & 15]++;
-                    states[i].max_gain = FFMAX(states[i].max_gain, (states[i].control & 15));
+                    states[i].max_gain = FFMAXI(states[i].max_gain, (states[i].control & 15));
                 }
                 states[i].arg = 0;
             }
@@ -1224,7 +1224,7 @@ static int hdcd_analyze(int32_t *samples, int count, int stride, int gain, int t
     }
 
     if (gain <= target_gain) {
-        int len = FFMIN(count, target_gain - gain);
+        int len = FFMINI(count, target_gain - gain);
         /* attenuate slowly */
         for (i = 0; i < len; i++) {
             ++gain;
@@ -1234,7 +1234,7 @@ static int hdcd_analyze(int32_t *samples, int count, int stride, int gain, int t
         }
         count -= len;
     } else {
-        int len = FFMIN(count, (gain - target_gain) >> 3);
+        int len = FFMINI(count, (gain - target_gain) >> 3);
         /* amplify quickly */
         for (i = 0; i < len; i++) {
             gain -= 8;
@@ -1296,7 +1296,7 @@ static int hdcd_envelope(int32_t *samples, int count, int stride, int vbits, int
     }
 
     if (gain <= target_gain) {
-        int len = FFMIN(count, target_gain - gain);
+        int len = FFMINI(count, target_gain - gain);
         /* attenuate slowly */
         for (i = 0; i < len; i++) {
             ++gain;
@@ -1305,7 +1305,7 @@ static int hdcd_envelope(int32_t *samples, int count, int stride, int vbits, int
         }
         count -= len;
     } else {
-        int len = FFMIN(count, (gain - target_gain) >> 3);
+        int len = FFMINI(count, (gain - target_gain) >> 3);
         /* amplify quickly */
         for (i = 0; i < len; i++) {
             gain -= 8;
@@ -1504,7 +1504,7 @@ static void hdcd_detect_onech(hdcd_state *state, hdcd_detection_data *detect) {
         if (detect->peak_extend != HDCD_PE_INTERMITTENT)
             detect->peak_extend = pe;
     }
-    detect->max_gain_adjustment = FFMIN(detect->max_gain_adjustment, GAINTOFLOAT(state->max_gain));
+    detect->max_gain_adjustment = FFMIND(detect->max_gain_adjustment, GAINTOFLOAT(state->max_gain));
     detect->errors += state->code_counterA_almost
         + state->code_counterB_checkfails
         + state->code_counterC_unmatched;
diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c
index fd07633498e..361734a4d7c 100644
--- a/libavfilter/af_headphone.c
+++ b/libavfilter/af_headphone.c
@@ -190,7 +190,7 @@ static int headphone_convolute(AVFilterContext *ctx, void *arg, int jobnr, int n
             if (read + ir_len < buffer_length) {
                 memcpy(temp_src, bptr + read, ir_len * sizeof(*temp_src));
             } else {
-                int len = FFMIN(air_len - (read % ir_len), buffer_length - read);
+                int len = FFMINI(air_len - (read % ir_len), buffer_length - read);
 
                 memcpy(temp_src, bptr + read, len * sizeof(*temp_src));
                 memcpy(temp_src + len, bptr, (air_len - len) * sizeof(*temp_src));
@@ -244,7 +244,7 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
 
     dst += offset;
 
-    n_read = FFMIN(ir_len, in->nb_samples);
+    n_read = FFMINI(ir_len, in->nb_samples);
     for (j = 0; j < n_read; j++) {
         dst[2 * j]     = ringbuffer[wr];
         ringbuffer[wr] = 0.0;
@@ -318,7 +318,7 @@ static int check_ir(AVFilterLink *inlink, int input_number)
         return AVERROR(EINVAL);
     }
     s->hrir_in[input_number].ir_len = ir_len;
-    s->ir_len = FFMAX(ir_len, s->ir_len);
+    s->ir_len = FFMAXI(ir_len, s->ir_len);
 
     if (ff_inlink_check_available_samples(inlink, ir_len + 1) == 1) {
         s->hrir_in[input_number].eof = 1;
diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
index de13f8f2dc5..cc443d4c9c4 100644
--- a/libavfilter/af_join.c
+++ b/libavfilter/af_join.c
@@ -431,7 +431,7 @@ static int try_push_frame(AVFilterContext *ctx)
             nb_samples = 0;
             break;
         } else {
-            nb_samples = FFMIN(nb_samples, s->input_frames[i]->nb_samples);
+            nb_samples = FFMINI(nb_samples, s->input_frames[i]->nb_samples);
         }
     }
     if (!nb_samples)
@@ -457,7 +457,7 @@ static int try_push_frame(AVFilterContext *ctx)
         AVBufferRef *buf;
 
         frame->extended_data[i] = cur->extended_data[ch->in_channel_idx];
-        linesize = FFMIN(linesize, cur->linesize[0]);
+        linesize = FFMINI(linesize, cur->linesize[0]);
 
         /* add the buffer where this plan is stored to the list if it's
          * not already there */
@@ -484,7 +484,7 @@ static int try_push_frame(AVFilterContext *ctx)
             goto fail;
         }
     }
-    for (i = 0; i < FFMIN(FF_ARRAY_ELEMS(frame->buf), nb_buffers); i++) {
+    for (i = 0; i < FFMINI(FF_ARRAY_ELEMS(frame->buf), nb_buffers); i++) {
         frame->buf[i] = av_buffer_ref(s->buffers[i]);
         if (!frame->buf[i]) {
             ret = AVERROR(ENOMEM);
@@ -513,7 +513,7 @@ static int try_push_frame(AVFilterContext *ctx)
     frame->linesize[0]    = linesize;
     if (frame->data != frame->extended_data) {
         memcpy(frame->data, frame->extended_data, sizeof(*frame->data) *
-               FFMIN(FF_ARRAY_ELEMS(frame->data), s->ch_layout.nb_channels));
+               FFMINI(FF_ARRAY_ELEMS(frame->data), s->ch_layout.nb_channels));
     }
 
     s->eof_pts = frame->pts + av_rescale_q(frame->nb_samples,
diff --git a/libavfilter/af_ladspa.c b/libavfilter/af_ladspa.c
index 0ae2b902cb3..e737e72e74c 100644
--- a/libavfilter/af_ladspa.c
+++ b/libavfilter/af_ladspa.c
@@ -229,7 +229,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     new_out_samples = out->nb_samples;
     if (s->in_trim > 0) {
-        int trim = FFMIN(new_out_samples, s->in_trim);
+        int trim = FFMINI(new_out_samples, s->in_trim);
 
         new_out_samples -= trim;
         s->in_trim -= trim;
@@ -276,7 +276,7 @@ static int request_frame(AVFilterLink *outlink)
         int ret = ff_request_frame(ctx->inputs[0]);
 
         if (ret == AVERROR_EOF && s->out_pad > 0) {
-            AVFrame *frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->out_pad));
+            AVFrame *frame = ff_get_audio_buffer(outlink, FFMINI(2048, s->out_pad));
             if (!frame)
                 return AVERROR(ENOMEM);
 
diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c
index 855d8935503..15278352fd4 100644
--- a/libavfilter/af_mcompand.c
+++ b/libavfilter/af_mcompand.c
@@ -235,13 +235,13 @@ static int parse_points(char *points, int nb_points, double radius,
 
         theta = atan2(L(2).y - L(4).y, L(2).x - L(4).x);
         len = hypot(L(2).x - L(4).x, L(2).y - L(4).y);
-        r = FFMIN(radius, len);
+        r = FFMIND(radius, len);
         L(3).x = L(2).x - r * cos(theta);
         L(3).y = L(2).y - r * sin(theta);
 
         theta = atan2(L(0).y - L(2).y, L(0).x - L(2).x);
         len = hypot(L(0).x - L(2).x, L(0).y - L(2).y);
-        r = FFMIN(radius, len / 2);
+        r = FFMIND(radius, len / 2);
         x = L(2).x + r * cos(theta);
         y = L(2).y + r * sin(theta);
 
@@ -319,7 +319,7 @@ static int config_output(AVFilterLink *outlink)
     int max_delay_size = 0;
 
     count_items(s->args, &nb_bands, '|');
-    s->nb_bands = FFMAX(1, nb_bands);
+    s->nb_bands = FFMAXI(1, nb_bands);
 
     s->bands = av_calloc(nb_bands, sizeof(*s->bands));
     if (!s->bands)
@@ -357,7 +357,7 @@ static int config_output(AVFilterLink *outlink)
         if (!s->bands[i].attack_rate || !s->bands[i].decay_rate || !s->bands[i].volume)
             return AVERROR(ENOMEM);
 
-        for (k = 0; k < FFMIN(nb_attacks / 2, outlink->ch_layout.nb_channels); k++) {
+        for (k = 0; k < FFMINI(nb_attacks / 2, outlink->ch_layout.nb_channels); k++) {
             char *tstr3 = av_strtok(p3, ",", &saveptr3);
 
             p3 = NULL;
@@ -432,7 +432,7 @@ static int config_output(AVFilterLink *outlink)
         tstr2 = av_strtok(p2, " ", &saveptr2);
         if (tstr2) {
             sscanf(tstr2, "%lf", &s->bands[i].delay);
-            max_delay_size = FFMAX(max_delay_size, s->bands[i].delay * outlink->sample_rate);
+            max_delay_size = FFMAXD(max_delay_size, s->bands[i].delay * outlink->sample_rate);
 
             tstr2 = av_strtok(p2, " ", &saveptr2);
             if (tstr2) {
diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c
index db67cc6f4b7..3cad18acb78 100644
--- a/libavfilter/af_replaygain.c
+++ b/libavfilter/af_replaygain.c
@@ -408,7 +408,7 @@ static void calc_stereo_peak(const float *samples, int nb_samples,
         samples += 2;
     }
 
-    *peak_p = FFMAX(peak, *peak_p);
+    *peak_p = FFMAXF(peak, *peak_p);
 }
 
 /*
diff --git a/libavfilter/af_sidechaincompress.c b/libavfilter/af_sidechaincompress.c
index 492442df864..eecd2ecf807 100644
--- a/libavfilter/af_sidechaincompress.c
+++ b/libavfilter/af_sidechaincompress.c
@@ -155,8 +155,8 @@ static int compressor_config_output(AVFilterLink *outlink)
     s->compressed_knee_start = (s->knee_start - s->thres) / s->ratio + s->thres;
     s->compressed_knee_stop = (s->knee_stop - s->thres) / s->ratio + s->thres;
 
-    s->attack_coeff = FFMIN(1., 1. / (s->attack * outlink->sample_rate / 4000.));
-    s->release_coeff = FFMIN(1., 1. / (s->release * outlink->sample_rate / 4000.));
+    s->attack_coeff = FFMIND(1., 1. / (s->attack * outlink->sample_rate / 4000.));
+    s->release_coeff = FFMIND(1., 1. / (s->release * outlink->sample_rate / 4000.));
 
     return 0;
 }
@@ -179,7 +179,7 @@ static void compressor(SidechainCompressContext *s,
 
         if (s->link == 1) {
             for (c = 1; c < sclink->ch_layout.nb_channels; c++)
-                abs_sample = FFMAX(fabs(scsrc[c] * level_sc), abs_sample);
+                abs_sample = FFMAXD(fabs(scsrc[c] * level_sc), abs_sample);
         } else {
             for (c = 1; c < sclink->ch_layout.nb_channels; c++)
                 abs_sample += fabs(scsrc[c] * level_sc);
@@ -254,7 +254,7 @@ static int activate(AVFilterContext *ctx)
     if (ret < 0)
         return ret;
 
-    nb_samples = FFMIN(av_audio_fifo_size(s->fifo[0]), av_audio_fifo_size(s->fifo[1]));
+    nb_samples = FFMINI(av_audio_fifo_size(s->fifo[0]), av_audio_fifo_size(s->fifo[1]));
     if (nb_samples) {
         out = ff_get_audio_buffer(ctx->outputs[0], nb_samples);
         if (!out)
diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c
index fe12fd598f2..b1e151ca1fd 100644
--- a/libavfilter/af_silenceremove.c
+++ b/libavfilter/af_silenceremove.c
@@ -203,7 +203,7 @@ static int config_input(AVFilterLink *inlink)
     s->next_pts = AV_NOPTS_VALUE;
     s->window_duration = av_rescale(s->window_duration_opt, inlink->sample_rate,
                                    AV_TIME_BASE);
-    s->window_duration = FFMAX(1, s->window_duration);
+    s->window_duration = FFMAXI(1, s->window_duration);
 
     s->start_duration = av_rescale(s->start_duration_opt, inlink->sample_rate,
                                    AV_TIME_BASE);
diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c
index 3071c85bd2e..75ca01bbe53 100644
--- a/libavfilter/af_sofalizer.c
+++ b/libavfilter/af_sofalizer.c
@@ -404,7 +404,7 @@ static int sofalizer_convolute(AVFilterContext *ctx, void *arg, int jobnr, int n
             if (read + ir_samples < buffer_length) {
                 memmove(temp_src, bptr + read, ir_samples * sizeof(*temp_src));
             } else {
-                int len = FFMIN(n_samples - (read % ir_samples), buffer_length - read);
+                int len = FFMINI(n_samples - (read % ir_samples), buffer_length - read);
 
                 memmove(temp_src, bptr + read, len * sizeof(*temp_src));
                 memmove(temp_src + len, bptr, (n_samples - len) * sizeof(*temp_src));
@@ -469,7 +469,7 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
 
     /* find minimum between number of samples and output buffer length:
      * (important, if one IR is longer than the output buffer) */
-    n_read = FFMIN(ir_samples, in->nb_samples);
+    n_read = FFMINI(ir_samples, in->nb_samples);
     for (j = 0; j < n_read; j++) {
         /* initialize output buf with saved signal from overflow buf */
         dst[mult * j]  = ringbuffer[wr];
@@ -826,7 +826,7 @@ static int load_data(AVFilterContext *ctx, int azim, int elev, float radius, int
     /* then choose next power of 2 for performance optimization */
     n_current = n_samples + s->sofa.max_delay;
     /* length of longest IR plus max. delay */
-    n_max = FFMAX(n_max, n_current);
+    n_max = FFMAXI(n_max, n_current);
 
     /* buffer length is longest IR plus max. delay -> next power of 2
        (32 - count leading zeros gives required exponent)  */
diff --git a/libavfilter/af_speechnorm.c b/libavfilter/af_speechnorm.c
index 9e2ba6381c5..b1556c12e7c 100644
--- a/libavfilter/af_speechnorm.c
+++ b/libavfilter/af_speechnorm.c
@@ -151,7 +151,7 @@ static int available_samples(AVFilterContext *ctx)
     for (int ch = 1; ch < inlink->ch_layout.nb_channels && min_pi_nb_samples > 0; ch++) {
         ChannelContext *cc = &s->cc[ch];
 
-        min_pi_nb_samples = FFMIN(min_pi_nb_samples, get_pi_samples(cc->pi, cc->pi_start, cc->pi_end, cc->pi_size));
+        min_pi_nb_samples = FFMINI(min_pi_nb_samples, get_pi_samples(cc->pi, cc->pi_start, cc->pi_end, cc->pi_size));
     }
 
     return min_pi_nb_samples;
@@ -172,17 +172,17 @@ static double next_gain(AVFilterContext *ctx, double pi_max_peak, int bypass, do
     SpeechNormalizerContext *s = ctx->priv;
     const double compression = 1. / s->max_compression;
     const int type = s->invert ? pi_max_peak <= s->threshold_value : pi_max_peak >= s->threshold_value;
-    double expansion = FFMIN(s->max_expansion, s->peak_value / pi_max_peak);
+    double expansion = FFMIND(s->max_expansion, s->peak_value / pi_max_peak);
 
     if (s->rms_value > DBL_EPSILON)
-        expansion = FFMIN(expansion, s->rms_value / sqrt(pi_rms_sum / pi_size));
+        expansion = FFMIND(expansion, s->rms_value / sqrt(pi_rms_sum / pi_size));
 
     if (bypass) {
         return 1.;
     } else if (type) {
-        return FFMIN(expansion, state + s->raise_amount);
+        return FFMIND(expansion, state + s->raise_amount);
     } else {
-        return FFMIN(expansion, FFMAX(compression, state - s->fall_amount));
+        return FFMIND(expansion, FFMAXD(compression, state - s->fall_amount));
     }
 }
 
@@ -216,13 +216,13 @@ static double min_gain(AVFilterContext *ctx, ChannelContext *cc, int max_size)
     int size = cc->pi_size;
     int idx = cc->pi_start;
 
-    min_gain = FFMIN(min_gain, gain_state);
+    min_gain = FFMIND(min_gain, gain_state);
     while (size <= max_size) {
         if (idx == cc->pi_end)
             break;
         gain_state = next_gain(ctx, cc->pi[idx].max_peak, 0, gain_state,
                                cc->pi[idx].rms_sum, cc->pi[idx].size);
-        min_gain = FFMIN(min_gain, gain_state);
+        min_gain = FFMIND(min_gain, gain_state);
         size += cc->pi[idx].size;
         idx++;
         if (idx >= MAX_ITEMS)
@@ -331,7 +331,7 @@ static void filter_channels_## name (AVFilterContext *ctx,
             int size;                                                           \
                                                                                 \
             next_pi(ctx, cc, bypass);                                           \
-            size = FFMIN(nb_samples - n, cc->pi_size);                          \
+            size = FFMINI(nb_samples - n, cc->pi_size);                          \
             av_assert1(size > 0);                                               \
             gain = cc->gain_state;                                              \
             consume_pi(cc, size);                                               \
@@ -375,7 +375,7 @@ static void filter_link_channels_## name (AVFilterContext *ctx,
             cc->bypass = av_channel_layout_index_from_channel(&s->ch_layout, channel) < 0; \
                                                                                 \
             next_pi(ctx, cc, cc->bypass);                                       \
-            min_size = FFMIN(min_size, cc->pi_size);                            \
+            min_size = FFMINI(min_size, cc->pi_size);                            \
         }                                                                       \
                                                                                 \
         av_assert1(min_size > 0);                                               \
@@ -384,7 +384,7 @@ static void filter_link_channels_## name (AVFilterContext *ctx,
                                                                                 \
             if (cc->bypass)                                                     \
                 continue;                                                       \
-            gain = FFMIN(gain, min_gain(ctx, cc, min_size));                    \
+            gain = FFMIND(gain, min_gain(ctx, cc, min_size));                    \
         }                                                                       \
                                                                                 \
         for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {            \
diff --git a/libavfilter/af_stereotools.c b/libavfilter/af_stereotools.c
index 4f2e2616b64..46006188aae 100644
--- a/libavfilter/af_stereotools.c
+++ b/libavfilter/af_stereotools.c
@@ -193,8 +193,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         L *= level_in;
         R *= level_in;
 
-        gl = 1. - FFMAX(0., balance_in);
-        gr = 1. + FFMIN(0., balance_in);
+        gl = 1. - FFMAXD(0., balance_in);
+        gr = 1. + FFMIND(0., balance_in);
         switch (s->bmode_in) {
         case 1:
             gd = gl - gr;
@@ -203,10 +203,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             break;
         case 2:
             if (balance_in < 0.) {
-                gr = FFMAX(0.5, gr);
+                gr = FFMAXD(0.5, gr);
                 gl = 1. / gr;
             } else if (balance_in > 0.) {
-                gl = FFMAX(0.5, gl);
+                gl = FFMAXD(0.5, gl);
                 gr = 1. / gl;
             }
             break;
@@ -223,20 +223,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         case 0:
             m = (L + R) * 0.5;
             S = (L - R) * 0.5;
-            l = m * mlev * FFMIN(1., 2. - mpan) + S * slev * FFMIN(1., 2. - sbal);
-            r = m * mlev * FFMIN(1., mpan)      - S * slev * FFMIN(1., sbal);
+            l = m * mlev * FFMIND(1., 2. - mpan) + S * slev * FFMIND(1., 2. - sbal);
+            r = m * mlev * FFMIND(1., mpan)      - S * slev * FFMIND(1., sbal);
             L = l;
             R = r;
             break;
         case 1:
-            l = L * FFMIN(1., 2. - sbal);
-            r = R * FFMIN(1., sbal);
+            l = L * FFMIND(1., 2. - sbal);
+            r = R * FFMIND(1., sbal);
             L = 0.5 * (l + r) * mlev;
             R = 0.5 * (l - r) * slev;
             break;
         case 2:
-            l = L * mlev * FFMIN(1., 2. - mpan) + R * slev * FFMIN(1., 2. - sbal);
-            r = L * mlev * FFMIN(1., mpan)      - R * slev * FFMIN(1., sbal);
+            l = L * mlev * FFMIND(1., 2. - mpan) + R * slev * FFMIND(1., 2. - sbal);
+            r = L * mlev * FFMIND(1., mpan)      - R * slev * FFMIND(1., sbal);
             L = l;
             R = r;
             break;
@@ -256,24 +256,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             R = l;
             m = (L + R) * 0.5;
             S = (L - R) * 0.5;
-            l = m * mlev * FFMIN(1., 2. - mpan) + S * slev * FFMIN(1., 2. - sbal);
-            r = m * mlev * FFMIN(1., mpan)      - S * slev * FFMIN(1., sbal);
+            l = m * mlev * FFMIND(1., 2. - mpan) + S * slev * FFMIND(1., 2. - sbal);
+            r = m * mlev * FFMIND(1., mpan)      - S * slev * FFMIND(1., sbal);
             L = l;
             R = r;
             break;
         case 7:
-            l = L * mlev * FFMIN(1., 2. - mpan) + R * slev * FFMIN(1., 2. - sbal);
+            l = L * mlev * FFMIND(1., 2. - mpan) + R * slev * FFMIND(1., 2. - sbal);
             L = l;
             R = l;
             break;
         case 8:
-            r = L * mlev * FFMIN(1., mpan)      - R * slev * FFMIN(1., sbal);
+            r = L * mlev * FFMIND(1., mpan)      - R * slev * FFMIND(1., sbal);
             L = r;
             R = r;
             break;
         case 9:
-            l = L * mlev * FFMIN(1., 2. - mpan) + R * slev * FFMIN(1., 2. - sbal);
-            r = L * mlev * FFMIN(1., mpan)      - R * slev * FFMIN(1., sbal);
+            l = L * mlev * FFMIND(1., 2. - mpan) + R * slev * FFMIND(1., 2. - sbal);
+            r = L * mlev * FFMIND(1., mpan)      - R * slev * FFMIND(1., sbal);
             L = r;
             R = l;
             break;
@@ -312,8 +312,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         s->pos = (s->pos + 2) % s->length;
 
-        gl = 1. - FFMAX(0., balance_out);
-        gr = 1. + FFMIN(0., balance_out);
+        gl = 1. - FFMAXD(0., balance_out);
+        gr = 1. + FFMIND(0., balance_out);
         switch (s->bmode_out) {
         case 1:
             gd = gl - gr;
@@ -322,10 +322,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             break;
         case 2:
             if (balance_out < 0.) {
-                gr = FFMAX(0.5, gr);
+                gr = FFMAXD(0.5, gr);
                 gl = 1. / gr;
             } else if (balance_out > 0.) {
-                gl = FFMAX(0.5, gl);
+                gl = FFMAXD(0.5, gl);
                 gr = 1. / gl;
             }
             break;
diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c
index 46380192a21..e61be6f3de1 100644
--- a/libavfilter/af_surround.c
+++ b/libavfilter/af_surround.c
@@ -1212,7 +1212,7 @@ fail:
 
     for (int i = 0; i < s->win_size; i++)
         s->window_func_lut[i] = sqrtf(s->window_func_lut[i] / s->win_size);
-    s->hop_size = FFMAX(1, s->win_size * (1. - s->overlap));
+    s->hop_size = FFMAXD(1, s->win_size * (1. - s->overlap));
 
     {
         float max = 0.f, *temp_lut = av_calloc(s->win_size, sizeof(*temp_lut));
@@ -1322,7 +1322,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     AVFrame *out;
 
     ff_filter_execute(ctx, fft_channels, in, NULL,
-                      FFMIN(inlink->ch_layout.nb_channels,
+                      FFMINI(inlink->ch_layout.nb_channels,
                             ff_filter_get_nb_threads(ctx)));
 
     s->filter(ctx);
@@ -1332,7 +1332,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         return AVERROR(ENOMEM);
 
     ff_filter_execute(ctx, ifft_channels, out, NULL,
-                      FFMIN(outlink->ch_layout.nb_channels,
+                      FFMINI(outlink->ch_layout.nb_channels,
                             ff_filter_get_nb_threads(ctx)));
 
     av_frame_copy_props(out, in);
@@ -1423,7 +1423,7 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar
     if (ret < 0)
         return ret;
 
-    s->hop_size = FFMAX(1, s->win_size * (1. - s->overlap));
+    s->hop_size = FFMAXD(1, s->win_size * (1. - s->overlap));
 
     allchannels_spread(ctx);
     set_input_levels(ctx);
diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 471bffeceb5..4abdbd70731 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -361,7 +361,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 
             vol->volume   = ff_exp10((g + vol->replaygain_preamp) / 20);
             if (vol->replaygain_noclip)
-                vol->volume = FFMIN(vol->volume, 1.0 / p);
+                vol->volume = FFMIND(vol->volume, 1.0 / p);
             vol->volume_i = (int)(vol->volume * 256 + 0.5);
 
             volume_init(vol);
diff --git a/libavfilter/afir_template.c b/libavfilter/afir_template.c
index c45b29902e8..e3f31e64fcb 100644
--- a/libavfilter/afir_template.c
+++ b/libavfilter/afir_template.c
@@ -140,7 +140,7 @@ static int fn(fir_quantum)(AVFilterContext *ctx, AVFrame *out, int ch, int ioffs
     const ftype *in = (const ftype *)s->in->extended_data[ch] + ioffset;
     ftype *blockout, *ptr = (ftype *)out->extended_data[ch] + offset;
     const int min_part_size = s->min_part_size;
-    const int nb_samples = FFMIN(min_part_size, out->nb_samples - offset);
+    const int nb_samples = FFMINI(min_part_size, out->nb_samples - offset);
     const int nb_segments = s->nb_segments[selir];
     const float dry_gain = s->dry_gain;
     const float wet_gain = s->wet_gain;
diff --git a/libavfilter/asrc_afdelaysrc.c b/libavfilter/asrc_afdelaysrc.c
index 3efa94a9423..8dfeae4ce65 100644
--- a/libavfilter/asrc_afdelaysrc.c
+++ b/libavfilter/asrc_afdelaysrc.c
@@ -56,7 +56,7 @@ static int activate(AVFilterContext *ctx)
     if (!ff_outlink_frame_wanted(outlink))
         return FFERROR_NOT_READY;
 
-    nb_samples = FFMIN(s->nb_samples, s->nb_taps - s->pts);
+    nb_samples = FFMINI(s->nb_samples, s->nb_taps - s->pts);
     if (nb_samples <= 0) {
         ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
         return 0;
diff --git a/libavfilter/asrc_afirsrc.c b/libavfilter/asrc_afirsrc.c
index 49ee4122fb1..4d6ed1a8ad0 100644
--- a/libavfilter/asrc_afirsrc.c
+++ b/libavfilter/asrc_afirsrc.c
@@ -273,7 +273,7 @@ static int activate(AVFilterContext *ctx)
     if (!ff_outlink_frame_wanted(outlink))
         return FFERROR_NOT_READY;
 
-    nb_samples = FFMIN(s->nb_samples, s->nb_taps - s->pts);
+    nb_samples = FFMINI(s->nb_samples, s->nb_taps - s->pts);
     if (nb_samples <= 0) {
         ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
         return 0;
@@ -496,7 +496,7 @@ static av_cold int config_eq_output(AVFilterLink *outlink)
     s->magnitude[s->nb_freq] = s->magnitude[s->nb_freq-1];
 
     fft_size = s->nb_taps * 2;
-    factor = FFMIN(outlink->sample_rate * 0.5f, s->freq[s->nb_freq - 1]) / (float)fft_size;
+    factor = FFMINF(outlink->sample_rate * 0.5f, s->freq[s->nb_freq - 1]) / (float)fft_size;
     asize = FFALIGN(fft_size, av_cpu_max_align());
     s->complexf = av_calloc(asize * 2, sizeof(*s->complexf));
     if (!s->complexf)
diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c
index 7d74319dffa..d722026c213 100644
--- a/libavfilter/asrc_anullsrc.c
+++ b/libavfilter/asrc_anullsrc.c
@@ -98,7 +98,7 @@ static int activate(AVFilterContext *ctx)
     }
 
     if (ff_outlink_frame_wanted(outlink)) {
-        AVFrame *samplesref = ff_get_audio_buffer(outlink, null->duration >= 0 ? FFMIN(null->nb_samples, null->duration - null->pts) : null->nb_samples);
+        AVFrame *samplesref = ff_get_audio_buffer(outlink, null->duration >= 0 ? FFMINI(null->nb_samples, null->duration - null->pts) : null->nb_samples);
 
         if (!samplesref)
             return AVERROR(ENOMEM);
diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c
index 33576beade0..194d37c9b87 100644
--- a/libavfilter/asrc_flite.c
+++ b/libavfilter/asrc_flite.c
@@ -314,7 +314,7 @@ static int activate(AVFilterContext *ctx)
     if (!ff_outlink_frame_wanted(outlink))
         return FFERROR_NOT_READY;
 
-    nb_samples = FFMIN(av_audio_fifo_size(flite->fifo), flite->frame_nb_samples);
+    nb_samples = FFMINI(av_audio_fifo_size(flite->fifo), flite->frame_nb_samples);
     if (!nb_samples) {
         char *text;
 
diff --git a/libavfilter/asrc_hilbert.c b/libavfilter/asrc_hilbert.c
index aeaf49e6424..2ba592062f8 100644
--- a/libavfilter/asrc_hilbert.c
+++ b/libavfilter/asrc_hilbert.c
@@ -137,7 +137,7 @@ static int activate(AVFilterContext *ctx)
     if (!ff_outlink_frame_wanted(outlink))
         return FFERROR_NOT_READY;
 
-    nb_samples = FFMIN(s->nb_samples, s->nb_taps - s->pts);
+    nb_samples = FFMINI(s->nb_samples, s->nb_taps - s->pts);
     if (nb_samples <= 0) {
         ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
         return 0;
diff --git a/libavfilter/asrc_sinc.c b/libavfilter/asrc_sinc.c
index 6ff33033164..247f1256757 100644
--- a/libavfilter/asrc_sinc.c
+++ b/libavfilter/asrc_sinc.c
@@ -57,7 +57,7 @@ static int activate(AVFilterContext *ctx)
     if (!ff_outlink_frame_wanted(outlink))
         return FFERROR_NOT_READY;
 
-    nb_samples = FFMIN(s->nb_samples, s->n - s->pts);
+    nb_samples = FFMINI(s->nb_samples, s->n - s->pts);
     if (nb_samples <= 0) {
         ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
         return 0;
diff --git a/libavfilter/avf_a3dscope.c b/libavfilter/avf_a3dscope.c
index fb087204121..c3149585bef 100644
--- a/libavfilter/avf_a3dscope.c
+++ b/libavfilter/avf_a3dscope.c
@@ -98,7 +98,7 @@ static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     Audio3dScopeContext *s = ctx->priv;
 
-    s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
+    s->nb_samples = FFMAXI(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
 
     return 0;
 }
diff --git a/libavfilter/avf_abitscope.c b/libavfilter/avf_abitscope.c
index a4b21094731..243ef0cdbad 100644
--- a/libavfilter/avf_abitscope.c
+++ b/libavfilter/avf_abitscope.c
@@ -95,7 +95,7 @@ static int config_input(AVFilterLink *inlink)
     int ch;
     char *colors, *saveptr = NULL;
 
-    s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
+    s->nb_samples = FFMAXI(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
     s->nb_channels = inlink->ch_layout.nb_channels;
     s->depth = inlink->format == AV_SAMPLE_FMT_S16P ? 16 : 32;
 
diff --git a/libavfilter/avf_ahistogram.c b/libavfilter/avf_ahistogram.c
index ce0d82f9ec1..ac232500069 100644
--- a/libavfilter/avf_ahistogram.c
+++ b/libavfilter/avf_ahistogram.c
@@ -117,7 +117,7 @@ static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     AudioHistogramContext *s = ctx->priv;
 
-    s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
+    s->nb_samples = FFMAXI(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
     s->dchannels = s->dmode == SINGLE ? 1 : inlink->ch_layout.nb_channels;
     s->shistogram = av_calloc(s->w, s->dchannels * sizeof(*s->shistogram));
     if (!s->shistogram)
@@ -303,7 +303,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         s->frame_count = 0;
 
     for (n = 0; n < w * s->dchannels; n++) {
-        acmax = FFMAX(s->achistogram[n] - s->shistogram[n], acmax);
+        acmax = FFMAXI(s->achistogram[n] - s->shistogram[n], acmax);
     }
 
     for (c = 0; c < s->dchannels; c++) {
diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
index 4c6b4ae02c0..c1c738c8cb7 100644
--- a/libavfilter/avf_aphasemeter.c
+++ b/libavfilter/avf_aphasemeter.c
@@ -129,7 +129,7 @@ static int config_input(AVFilterLink *inlink)
     s->duration = av_rescale(s->duration, inlink->sample_rate, AV_TIME_BASE);
 
     if (s->do_video)
-        s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
+        s->nb_samples = FFMAXI(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
 
     return 0;
 }
@@ -286,9 +286,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         if (s->do_video) {
             dst = out->data[0] + x * 4;
-            dst[0] = FFMIN(255, dst[0] + rc);
-            dst[1] = FFMIN(255, dst[1] + gc);
-            dst[2] = FFMIN(255, dst[2] + bc);
+            dst[0] = FFMINI(255, dst[0] + rc);
+            dst[1] = FFMINI(255, dst[1] + gc);
+            dst[2] = FFMINI(255, dst[2] + bc);
             dst[3] = 255;
         }
         fphase += phase;
diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c
index 902d461d868..0c208d72827 100644
--- a/libavfilter/avf_avectorscope.c
+++ b/libavfilter/avf_avectorscope.c
@@ -125,15 +125,15 @@ static void draw_dot(AudioVectorScopeContext *s, unsigned x, unsigned y, int val
         if (y >= s->h || x >= s->w)
             return;
     } else {
-        y = FFMIN(y, s->h - 1);
-        x = FFMIN(x, s->w - 1);
+        y = FFMINI(y, s->h - 1);
+        x = FFMINI(x, s->w - 1);
     }
 
     dst = s->outpicref->data[0] + y * linesize + x * 4;
-    dst[0] = FFMIN(dst[0] + s->contrast[0], value);
-    dst[1] = FFMIN(dst[1] + s->contrast[1], value);
-    dst[2] = FFMIN(dst[2] + s->contrast[2], value);
-    dst[3] = FFMIN(dst[3] + s->contrast[3], value);
+    dst[0] = FFMINI(dst[0] + s->contrast[0], value);
+    dst[1] = FFMINI(dst[1] + s->contrast[1], value);
+    dst[2] = FFMINI(dst[2] + s->contrast[2], value);
+    dst[3] = FFMINI(dst[3] + s->contrast[3], value);
 }
 
 static void draw_line(AudioVectorScopeContext *s, int x0, int y0, int x1, int y1)
@@ -215,13 +215,13 @@ static int fade(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
         for (int i = slice_start; i < slice_end; i++) {
             for (int j = 0; j < s->w*4; j+=4) {
                 if (d[j+0])
-                    d[j+0] = FFMAX(d[j+0] - s->fade[0], 0);
+                    d[j+0] = FFMAXI(d[j+0] - s->fade[0], 0);
                 if (d[j+1])
-                    d[j+1] = FFMAX(d[j+1] - s->fade[1], 0);
+                    d[j+1] = FFMAXI(d[j+1] - s->fade[1], 0);
                 if (d[j+2])
-                    d[j+2] = FFMAX(d[j+2] - s->fade[2], 0);
+                    d[j+2] = FFMAXI(d[j+2] - s->fade[2], 0);
                 if (d[j+3])
-                    d[j+3] = FFMAX(d[j+3] - s->fade[3], 0);
+                    d[j+3] = FFMAXI(d[j+3] - s->fade[3], 0);
             }
             d += linesize;
         }
@@ -263,7 +263,7 @@ static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     AudioVectorScopeContext *s = ctx->priv;
 
-    s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
+    s->nb_samples = FFMAXI(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
 
     return 0;
 }
@@ -321,7 +321,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
         av_frame_free(&insamples);
         return ret;
     }
-    ff_filter_execute(ctx, fade, NULL, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+    ff_filter_execute(ctx, fade, NULL, NULL, FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (zoom < 1) {
         float max = 0;
@@ -330,12 +330,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
         case AV_SAMPLE_FMT_S16:
             for (int i = 0; i < insamples->nb_samples * 2; i++) {
                 float sample = samples[i] / (float)INT16_MAX;
-                max = FFMAX(FFABS(sample), max);
+                max = FFMAXF(FFABS(sample), max);
             }
             break;
         case AV_SAMPLE_FMT_FLT:
             for (int i = 0; i < insamples->nb_samples * 2; i++) {
-                max = FFMAX(FFABS(samplesf[i]), max);
+                max = FFMAXF(FFABS(samplesf[i]), max);
             }
             break;
         default:
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 531aa071a0f..83f1207a424 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -239,7 +239,7 @@ static void find_next_delta_ts(AVFilterContext *ctx, int64_t *seg_delta)
 
     pts = cat->in[i++].pts;
     for (; i < imax; i++)
-        pts = FFMAX(pts, cat->in[i].pts);
+        pts = FFMAXI(pts, cat->in[i].pts);
     cat->delta_ts += pts;
     *seg_delta = pts;
 }
@@ -263,9 +263,9 @@ static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no,
         return AVERROR_INVALIDDATA;
     nb_samples = av_rescale_q(seg_delta - cat->in[in_no].pts,
                               outlink->time_base, rate_tb);
-    frame_nb_samples = FFMAX(9600, rate_tb.den / 5); /* arbitrary */
+    frame_nb_samples = FFMAXI(9600, rate_tb.den / 5); /* arbitrary */
     while (nb_samples) {
-        frame_nb_samples = FFMIN(frame_nb_samples, nb_samples);
+        frame_nb_samples = FFMINI(frame_nb_samples, nb_samples);
         buf = ff_get_audio_buffer(outlink, frame_nb_samples);
         if (!buf)
             return AVERROR(ENOMEM);
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 8ff6ecbe090..bdff97db0c4 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -323,8 +323,8 @@ static int init_cqt(ShowCQTContext *s)
 
         flen = 8.0 * s->fft_len / (tlength * rate);
         center = s->freq[k] * s->fft_len / rate;
-        start = FFMAX(0, ceil(center - 0.5 * flen));
-        end = FFMIN(s->fft_len, floor(center + 0.5 * flen));
+        start = FFMAXD(0, ceil(center - 0.5 * flen));
+        end = FFMIND(s->fft_len, floor(center + 0.5 * flen));
 
         s->coeffs[m].start = start & ~(s->cqt_align - 1);
         s->coeffs[m].len = (end | (s->cqt_align - 1)) + 1 - s->coeffs[m].start;
@@ -736,9 +736,9 @@ static void rgb_from_cqt(ColorFloat *c, const AVComplexFloat *v, float g, int le
 {
     int x;
     for (x = 0; x < len; x++) {
-        c[x].rgb.r = 255.0f * calculate_gamma(FFMIN(1.0f, cscheme[0] * v[x].re + cscheme[3] * v[x].im), g);
-        c[x].rgb.g = 255.0f * calculate_gamma(FFMIN(1.0f, cscheme[1] * v[x].re + cscheme[4] * v[x].im), g);
-        c[x].rgb.b = 255.0f * calculate_gamma(FFMIN(1.0f, cscheme[2] * v[x].re + cscheme[5] * v[x].im), g);
+        c[x].rgb.r = 255.0f * calculate_gamma(FFMINF(1.0f, cscheme[0] * v[x].re + cscheme[3] * v[x].im), g);
+        c[x].rgb.g = 255.0f * calculate_gamma(FFMINF(1.0f, cscheme[1] * v[x].re + cscheme[4] * v[x].im), g);
+        c[x].rgb.b = 255.0f * calculate_gamma(FFMINF(1.0f, cscheme[2] * v[x].re + cscheme[5] * v[x].im), g);
     }
 }
 
@@ -747,9 +747,9 @@ static void yuv_from_cqt(ColorFloat *c, const AVComplexFloat *v, float gamma, in
     int x;
     for (x = 0; x < len; x++) {
         float r, g, b;
-        r = calculate_gamma(FFMIN(1.0f, cscheme[0] * v[x].re + cscheme[3] * v[x].im), gamma);
-        g = calculate_gamma(FFMIN(1.0f, cscheme[1] * v[x].re + cscheme[4] * v[x].im), gamma);
-        b = calculate_gamma(FFMIN(1.0f, cscheme[2] * v[x].re + cscheme[5] * v[x].im), gamma);
+        r = calculate_gamma(FFMINF(1.0f, cscheme[0] * v[x].re + cscheme[3] * v[x].im), gamma);
+        g = calculate_gamma(FFMINF(1.0f, cscheme[1] * v[x].re + cscheme[4] * v[x].im), gamma);
+        b = calculate_gamma(FFMINF(1.0f, cscheme[2] * v[x].re + cscheme[5] * v[x].im), gamma);
         c[x].yuv.y = cm[0][0] * r + cm[0][1] * g + cm[0][2] * b;
         c[x].yuv.u = cm[1][0] * r + cm[1][1] * g + cm[1][2] * b;
         c[x].yuv.v = cm[2][0] * r + cm[2][1] * g + cm[2][2] * b;
@@ -1036,14 +1036,14 @@ static void draw_sono(AVFrame *out, AVFrame *sono, int off, int idx)
     ptrdiff_t ls;
     int i, y, yh;
 
-    ls = FFABS(FFMIN(out->linesize[0], sono->linesize[0]));
+    ls = FFABS(FFMINI(out->linesize[0], sono->linesize[0]));
     for (y = 0; y < h; y++) {
         memcpy(out->data[0] + (off + y) * out->linesize[0],
                sono->data[0] + (idx + y) % h * sono->linesize[0], ls);
     }
 
     for (i = 1; i < nb_planes; i++) {
-        ls = FFABS(FFMIN(out->linesize[i], sono->linesize[i]));
+        ls = FFABS(FFMINI(out->linesize[i], sono->linesize[i]));
         for (y = 0; y < h; y += inc) {
             yh = (fmt == AV_PIX_FMT_YUV420P) ? y / 2 : y;
             memcpy(out->data[i] + (offh + yh) * out->linesize[i],
@@ -1275,9 +1275,9 @@ static av_cold int init(AVFilterContext *ctx)
         if (s->bar_h >= 0 && s->sono_h >= 0)
             s->axis_h = s->height - s->bar_h - s->sono_h;
         if (s->bar_h >= 0 && s->sono_h < 0)
-            s->axis_h = FFMIN(s->axis_h, s->height - s->bar_h);
+            s->axis_h = FFMINI(s->axis_h, s->height - s->bar_h);
         if (s->bar_h < 0 && s->sono_h >= 0)
-            s->axis_h = FFMIN(s->axis_h, s->height - s->sono_h);
+            s->axis_h = FFMINI(s->axis_h, s->height - s->sono_h);
     }
 
     if (s->bar_h < 0) {
@@ -1373,7 +1373,7 @@ static int config_output(AVFilterLink *outlink)
     if ((ret = init_volume(s)) < 0)
         return ret;
 
-    s->fft_bits = FFMAX(ceil(log2(inlink->sample_rate * s->timeclamp)), 4);
+    s->fft_bits = FFMAXD(ceil(log2(inlink->sample_rate * s->timeclamp)), 4);
     s->fft_len = 1 << s->fft_bits;
     av_log(ctx, AV_LOG_VERBOSE, "fft_len = %d, cqt_len = %d.\n", s->fft_len, s->cqt_len);
 
@@ -1389,7 +1389,7 @@ static int config_output(AVFilterLink *outlink)
     if (s->attack > 0.0) {
         int k;
 
-        s->remaining_fill_max = FFMIN(s->remaining_fill_max, ceil(inlink->sample_rate * s->attack));
+        s->remaining_fill_max = FFMIND(s->remaining_fill_max, ceil(inlink->sample_rate * s->attack));
         s->attack_data = av_malloc_array(s->remaining_fill_max, sizeof(*s->attack_data));
         if (!s->attack_data)
             return AVERROR(ENOMEM);
diff --git a/libavfilter/avf_showcwt.c b/libavfilter/avf_showcwt.c
index 8edf2fb43b2..8228aa82d81 100644
--- a/libavfilter/avf_showcwt.c
+++ b/libavfilter/avf_showcwt.c
@@ -732,8 +732,8 @@ static int compute_kernel(AVFilterContext *ctx)
         const float frequency = s->frequency_band[y*2];
         const float deviation = 1.f / (s->frequency_band[y*2+1] *
                                        output_sample_count);
-        const int a = FFMAX(frequency-12.f*sqrtf(1.f/deviation)-0.5f, -size);
-        const int b = FFMIN(frequency+12.f*sqrtf(1.f/deviation)-0.5f, size+a);
+        const int a = FFMAXF(frequency-12.f*sqrtf(1.f/deviation)-0.5f, -size);
+        const int b = FFMINF(frequency+12.f*sqrtf(1.f/deviation)-0.5f, size+a);
         const int range = -a;
 
         memset(tkernel, 0, size * sizeof(*tkernel));
@@ -781,8 +781,8 @@ static int compute_kernel(AVFilterContext *ctx)
             kernel[n].im = tkernel[n+range+start];
         }
 
-        range_min = FFMIN(range_min, stop+1-start);
-        range_max = FFMAX(range_max, stop+1-start);
+        range_min = FFMINI(range_min, stop+1-start);
+        range_max = FFMAXI(range_max, stop+1-start);
 
         s->kernel[y] = kernel;
     }
@@ -881,16 +881,16 @@ static int config_output(AVFilterLink *outlink)
                              frequency_band(s->frequency_band,
                                             s->frequency_band_count, maximum_frequency - minimum_frequency,
                                             minimum_frequency, s->frequency_scale, s->deviation);
-    s->nb_consumed_samples = FFMIN(s->nb_consumed_samples, 65536);
+    s->nb_consumed_samples = FFMINI(s->nb_consumed_samples, 65536);
 
-    s->nb_threads = FFMIN(s->frequency_band_count, ff_filter_get_nb_threads(ctx));
+    s->nb_threads = FFMINI(s->frequency_band_count, ff_filter_get_nb_threads(ctx));
     s->nb_channels = inlink->ch_layout.nb_channels;
     s->old_pts = AV_NOPTS_VALUE;
     s->eof_pts = AV_NOPTS_VALUE;
 
     s->input_sample_count = 1 << (32 - ff_clz(s->nb_consumed_samples));
     s->input_padding_size = 1 << (32 - ff_clz(s->input_sample_count));
-    s->output_sample_count = FFMAX(1, av_rescale(s->input_sample_count, s->pps, inlink->sample_rate));
+    s->output_sample_count = FFMAXI(1, av_rescale(s->input_sample_count, s->pps, inlink->sample_rate));
     s->output_padding_size = 1 << (32 - ff_clz(s->output_sample_count));
 
     s->hop_size  = s->input_sample_count;
@@ -1253,7 +1253,7 @@ static int activate(AVFilterContext *ctx)
 
             if (ret > 0 || s->eof) {
                 ff_filter_execute(ctx, run_channels_cwt_prepare, fin, NULL,
-                                  FFMIN(s->nb_threads, s->nb_channels));
+                                  FFMINI(s->nb_threads, s->nb_channels));
                 if (fin) {
                     if (s->hop_index == 0) {
                         s->in_pts = fin->pts;
diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c
index 244b013ada5..2314f492b75 100644
--- a/libavfilter/avf_showfreqs.c
+++ b/libavfilter/avf_showfreqs.c
@@ -328,12 +328,12 @@ static inline void plot_freq(ShowFreqsContext *s, int ch,
 
     switch (s->avg) {
     case 0:
-        y = s->avg_data[ch][f] = !outl->frame_count_in ? y : FFMIN(0, y);
+        y = s->avg_data[ch][f] = !outl->frame_count_in ? y : FFMINI(0, y);
         break;
     case 1:
         break;
     default:
-        s->avg_data[ch][f] = avg + y * (y - avg) / (FFMIN(outl->frame_count_in + 1, s->avg) * (float)y);
+        s->avg_data[ch][f] = avg + y * (y - avg) / (FFMINI(outl->frame_count_in + 1, s->avg) * (float)y);
         y = av_clip(s->avg_data[ch][f], 0, outlink->h - 1);
         break;
     }
diff --git a/libavfilter/avf_showspatial.c b/libavfilter/avf_showspatial.c
index 491501e3373..1c6d0ae0e81 100644
--- a/libavfilter/avf_showspatial.c
+++ b/libavfilter/avf_showspatial.c
@@ -177,7 +177,7 @@ static int config_output(AVFilterLink *outlink)
             return AVERROR(ENOMEM);
         generate_window_func(s->window_func_lut, s->win_size, s->win_func, &overlap);
 
-        s->hop_size = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
+        s->hop_size = FFMAXI(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
     }
 
     av_audio_fifo_free(s->fifo);
@@ -282,7 +282,7 @@ static int spatial_activate(AVFilterContext *ctx)
         fin->pts = s->pts + s->consumed;
         s->consumed += s->hop_size;
         ret = av_audio_fifo_peek(s->fifo, (void **)fin->extended_data,
-                                 FFMIN(s->win_size, av_audio_fifo_size(s->fifo)));
+                                 FFMINI(s->win_size, av_audio_fifo_size(s->fifo)));
         if (ret < 0) {
             av_frame_free(&fin);
             return ret;
diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
index e760caad2d0..4dfc4632580 100644
--- a/libavfilter/avf_showvolume.c
+++ b/libavfilter/avf_showvolume.c
@@ -154,7 +154,7 @@ static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     ShowVolumeContext *s = ctx->priv;
 
-    s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
+    s->nb_samples = FFMAXI(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
     s->values = av_calloc(inlink->ch_layout.nb_channels * VAR_VARS_NB, sizeof(double));
     if (!s->values)
         return AVERROR(ENOMEM);
@@ -174,7 +174,7 @@ static int config_input(AVFilterLink *inlink)
     }
 
     if (s->draw_persistent_duration > 0.) {
-        s->persistent_max_frames = (int) FFMAX(av_q2d(s->frame_rate) * s->draw_persistent_duration, 1.);
+        s->persistent_max_frames = (int) FFMAXD(av_q2d(s->frame_rate) * s->draw_persistent_duration, 1.);
         s->max_persistent = av_calloc(inlink->ch_layout.nb_channels * s->persistent_max_frames, sizeof(*s->max_persistent));
         s->nb_frames_max_display = av_calloc(inlink->ch_layout.nb_channels * s->persistent_max_frames, sizeof(*s->nb_frames_max_display));
         if (!s->max_persistent ||
@@ -336,10 +336,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
             const uint32_t alpha = s->bgopacity * 255;
 
             for (k = 0; k < outlink->w; k++) {
-                dst[k * 4 + 0] = FFMAX(dst[k * 4 + 0] * s->f, 0);
-                dst[k * 4 + 1] = FFMAX(dst[k * 4 + 1] * s->f, 0);
-                dst[k * 4 + 2] = FFMAX(dst[k * 4 + 2] * s->f, 0);
-                dst[k * 4 + 3] = FFMAX(dst[k * 4 + 3] * s->f, alpha);
+                dst[k * 4 + 0] = FFMAXD(dst[k * 4 + 0] * s->f, 0);
+                dst[k * 4 + 1] = FFMAXD(dst[k * 4 + 1] * s->f, 0);
+                dst[k * 4 + 2] = FFMAXD(dst[k * 4 + 2] * s->f, 0);
+                dst[k * 4 + 3] = FFMAXD(dst[k * 4 + 3] * s->f, alpha);
             }
         }
     } else if (s->f == 0.) {
@@ -370,7 +370,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
 
             if (s->draw_persistent_duration > 0.) {
                 calc_persistent_max(s, max, c);
-                max_draw = FFMAX(0, calc_max_draw(s, outlink, s->max_persistent[c]) - 1);
+                max_draw = FFMAXI(0, calc_max_draw(s, outlink, s->max_persistent[c]) - 1);
                 draw_max_line(s, max_draw, c);
             }
         }
@@ -399,7 +399,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
 
             if (s->draw_persistent_duration > 0.) {
                 calc_persistent_max(s, max, c);
-                max_draw = FFMAX(0, calc_max_draw(s, outlink, s->max_persistent[c]) - 1);
+                max_draw = FFMAXI(0, calc_max_draw(s, outlink, s->max_persistent[c]) - 1);
                 draw_max_line(s, max_draw, c);
             }
         }
@@ -439,7 +439,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
             drawtext(out, c * (s->h + s->b) + (s->h - 8) / 2, 2, buf, 1);
         } else { /* horizontal */
             snprintf(buf, sizeof(buf), "%.2f", s->values[c * VAR_VARS_NB + VAR_VOLUME]);
-            drawtext(out, FFMAX(0, s->w - 8 * (int)strlen(buf)), c * (s->h + s->b) + (s->h - 8) / 2, buf, 0);
+            drawtext(out, FFMAXI(0, s->w - 8 * (int)strlen(buf)), c * (s->h + s->b) + (s->h - 8) / 2, buf, 0);
         }
     }
 
diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c
index d1f1277beb9..3be3455b0f5 100644
--- a/libavfilter/avf_showwaves.c
+++ b/libavfilter/avf_showwaves.c
@@ -615,7 +615,7 @@ static int push_single_pic(AVFilterLink *outlink)
                 break;
             case FILTER_PEAK:
                 for (ch = 0; ch < nb_channels; ch++)
-                    sum[ch] = FFMAX(sum[ch], abs(p[ch + i*nb_channels]));
+                    sum[ch] = FFMAXI(sum[ch], abs(p[ch + i*nb_channels]));
                 break;
             }
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 56f635a4130..2c007e8950a 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -229,7 +229,7 @@ static void update_link_current_pts(FilterLinkInternal *li, int64_t pts)
 void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
 {
     FFFilterContext *ctxi = fffilterctx(filter);
-    ctxi->ready = FFMAX(ctxi->ready, priority);
+    ctxi->ready = FFMAXI(ctxi->ready, priority);
 }
 
 /**
@@ -512,14 +512,14 @@ static int64_t guess_status_pts(AVFilterContext *ctx, int status, AVRational lin
     for (i = 0; i < ctx->nb_inputs; i++) {
         FilterLinkInternal * const li = ff_link_internal(ctx->inputs[i]);
         if (li->status_out == status)
-            r = FFMIN(r, av_rescale_q(li->l.current_pts, ctx->inputs[i]->time_base, link_time_base));
+            r = FFMINI(r, av_rescale_q(li->l.current_pts, ctx->inputs[i]->time_base, link_time_base));
     }
     if (r < INT64_MAX)
         return r;
     av_log(ctx, AV_LOG_WARNING, "EOF timestamp not reliable\n");
     for (i = 0; i < ctx->nb_inputs; i++) {
         FilterLinkInternal * const li = ff_link_internal(ctx->inputs[i]);
-        r = FFMIN(r, av_rescale_q(li->status_in_pts, ctx->inputs[i]->time_base, link_time_base));
+        r = FFMINI(r, av_rescale_q(li->status_in_pts, ctx->inputs[i]->time_base, link_time_base));
     }
     if (r < INT64_MAX)
         return r;
@@ -840,7 +840,7 @@ void avfilter_free(AVFilterContext *filter)
 int ff_filter_get_nb_threads(AVFilterContext *ctx)
 {
     if (ctx->nb_threads > 0)
-        return FFMIN(ctx->nb_threads, ctx->graph->nb_threads);
+        return FFMINI(ctx->nb_threads, ctx->graph->nb_threads);
     return ctx->graph->nb_threads;
 }
 
@@ -1521,7 +1521,7 @@ int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max,
     if (!ff_inlink_check_available_samples(link, min))
         return 0;
     if (li->status_in)
-        min = FFMIN(min, ff_framequeue_queued_samples(&li->fifo));
+        min = FFMINI(min, ff_framequeue_queued_samples(&li->fifo));
     ret = take_samples(li, min, max, &frame);
     if (ret < 0)
         return ret;
diff --git a/libavfilter/blend_modes.c b/libavfilter/blend_modes.c
index 9b1e78b1461..032937d610a 100644
--- a/libavfilter/blend_modes.c
+++ b/libavfilter/blend_modes.c
@@ -114,7 +114,7 @@ static void fn0(NAME)(const uint8_t *_top, ptrdiff_t top_linesize, \
 fn(addition,   FFMIN(MAX, A + B))
 fn(grainmerge, CLIP(A + B - HALF))
 fn(average,    (A + B) / 2)
-fn(subtract,   FFMAX(0, A - B))
+fn(subtract,   FFMAXI(0, A - B))
 fn(multiply,   MULTIPLY(1, A, B))
 fn(multiply128,CLIP((A - HALF) * B / MDIV + HALF))
 fn(negation,   MAX - FFABS(MAX - A - B))
@@ -127,8 +127,8 @@ fn(hardlight,  (B < HALF) ? MULTIPLY(2, B, A) : SCREEN(2, B, A))
 fn(hardmix,    (A < (MAX - B)) ? 0: MAX)
 fn(heat,       (A == 0) ? 0 : MAX - FFMIN(((MAX - B) * (MAX - B)) / A, MAX))
 fn(freeze,     (B == 0) ? 0 : MAX - FFMIN(((MAX - A) * (MAX - A)) / B, MAX))
-fn(darken,     FFMIN(A, B))
-fn(lighten,    FFMAX(A, B))
+fn(darken,     FFMINI(A, B))
+fn(lighten,    FFMAXI(A, B))
 fn(divide,     CLIP(B == 0 ? MAX : MAX * A / B))
 fn(dodge,      DODGE(A, B))
 fn(burn,       BURN(A, B))
diff --git a/libavfilter/boxblur.c b/libavfilter/boxblur.c
index 43c724daeae..0a3a887517a 100644
--- a/libavfilter/boxblur.c
+++ b/libavfilter/boxblur.c
@@ -114,10 +114,10 @@ int ff_boxblur_eval_filter_params(AVFilterLink *inlink,
 
 #define CHECK_RADIUS_VAL(w_, h_, comp)                                  \
     if (comp->radius < 0 ||                                   \
-        2*comp->radius > FFMIN(w_, h_)) {                     \
+        2*comp->radius > FFMINI(w_, h_)) {                     \
         av_log(ctx, AV_LOG_ERROR,                                       \
                "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
-               comp->radius, FFMIN(w_, h_)/2);                \
+               comp->radius, FFMINI(w_, h_)/2);                \
         return AVERROR(EINVAL);                                         \
     }
     CHECK_RADIUS_VAL(w,  h,  luma_param);
diff --git a/libavfilter/bwdifdsp.c b/libavfilter/bwdifdsp.c
index e87fe414e04..a4e6dd22caf 100644
--- a/libavfilter/bwdifdsp.c
+++ b/libavfilter/bwdifdsp.c
@@ -77,8 +77,8 @@ static const uint16_t coef_sp[2] = { 5077, 981 };
             int f = ((prev2[prefs2] + next2[prefs2]) >> 1) - e; \
             int dc = d - c; \
             int de = d - e; \
-            int max = FFMAX3(de, dc, FFMIN(b, f)); \
-            int min = FFMIN3(de, dc, FFMAX(b, f)); \
+            int max = FFMAX3(de, dc, FFMINI(b, f)); \
+            int min = FFMIN3(de, dc, FFMAXI(b, f)); \
             diff = FFMAX3(diff, min, -max);
 
 #define FILTER_LINE() \
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
index 6f7dca021bd..32ed6ae0902 100644
--- a/libavfilter/drawutils.c
+++ b/libavfilter/drawutils.c
@@ -147,7 +147,7 @@ int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSp
         pixelstep[c->plane] = c->step;
         if (pixelstep[c->plane] >= 8)
             return AVERROR(ENOSYS);
-        nb_planes = FFMAX(nb_planes, c->plane + 1);
+        nb_planes = FFMAXI(nb_planes, c->plane + 1);
     }
     memset(draw, 0, sizeof(*draw));
     draw->desc      = desc;
@@ -309,7 +309,7 @@ static void subsampling_bounds(int sub, int *x, int *w, int *start, int *end)
 
     *start = (-*x) & mask;
     *x += *start;
-    *start = FFMIN(*start, *w);
+    *start = FFMINI(*start, *w);
     *w -= *start;
     *end = *w & mask;
     *w >>= sub;
diff --git a/libavfilter/edge_template.c b/libavfilter/edge_template.c
index 100fe1e4250..708a227fd6d 100644
--- a/libavfilter/edge_template.c
+++ b/libavfilter/edge_template.c
@@ -81,7 +81,7 @@ void fn(gaussian_blur)(int w, int h,
     src_linesize /= sizeof(pixel);
     dst_linesize /= sizeof(pixel);
 
-    for (j = 0; j < FFMIN(h, 2); j++) {
+    for (j = 0; j < FFMINI(h, 2); j++) {
         memcpy(dstp, srcp, w*sizeof(pixel));
         dstp += dst_linesize;
         srcp += src_linesize;
@@ -89,7 +89,7 @@ void fn(gaussian_blur)(int w, int h,
 
     for (; j < h - 2; j++) {
         int i;
-        for (i = 0; i < FFMIN(w, 2); i++)
+        for (i = 0; i < FFMINI(w, 2); i++)
             dstp[i] = srcp[i*src_stride];
         for (; i < w - 2; i++) {
             /* Gaussian mask of size 5x5 with sigma = 1.4 */
diff --git a/libavfilter/f_bench.c b/libavfilter/f_bench.c
index 9898e94c767..8387ceb459a 100644
--- a/libavfilter/f_bench.c
+++ b/libavfilter/f_bench.c
@@ -78,8 +78,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             const int64_t diff = t - start;
             s->sum += diff;
             s->n++;
-            s->min = FFMIN(s->min, diff);
-            s->max = FFMAX(s->max, diff);
+            s->min = FFMINI(s->min, diff);
+            s->max = FFMAXI(s->max, diff);
             av_log(s, AV_LOG_INFO, "t:%f avg:%f max:%f min:%f\n",
                    T2F(diff), T2F(s->sum / s->n), T2F(s->max), T2F(s->min));
         }
diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c
index f781e8c2fe3..8657b53a3cd 100644
--- a/libavfilter/f_drawgraph.c
+++ b/libavfilter/f_drawgraph.c
@@ -279,7 +279,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             for (j = y; j < outlink->h; j++) {
                 if (old != bg &&
                     (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) ||
-                    AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
+                    AV_RN32(out->data[0] + FFMINI(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
                     draw_dot(fg, x, j, out);
                     break;
                 }
@@ -380,7 +380,7 @@ static int request_frame(AVFilterLink *outlink)
                     for (j = y; j < outlink->h; j++) {
                         if (old != bg &&
                             (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) ||
-                            AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
+                            AV_RN32(out->data[0] + FFMINI(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
                             draw_dot(fg, x, j, out);
                             break;
                         }
diff --git a/libavfilter/f_latency.c b/libavfilter/f_latency.c
index 00b55ddb4b5..9ea22141258 100644
--- a/libavfilter/f_latency.c
+++ b/libavfilter/f_latency.c
@@ -66,8 +66,8 @@ static int activate(AVFilterContext *ctx)
         }
 
         if (delta > 0) {
-            s->min_latency = FFMIN(s->min_latency, delta);
-            s->max_latency = FFMAX(s->max_latency, delta);
+            s->min_latency = FFMINI(s->min_latency, delta);
+            s->max_latency = FFMAXI(s->max_latency, delta);
         }
     }
 
diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index 1984fad70d8..a05f816959e 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -113,7 +113,7 @@ static int push_samples(AVFilterContext *ctx, int nb_samples, AVFrame **frame)
     int ret = 0, i = 0;
 
     while (s->loop != 0 && i < nb_samples) {
-        out = ff_get_audio_buffer(outlink, FFMIN(nb_samples, s->nb_samples - s->current_sample));
+        out = ff_get_audio_buffer(outlink, FFMINI(nb_samples, s->nb_samples - s->current_sample));
         if (!out)
             return AVERROR(ENOMEM);
         ret = av_audio_fifo_peek_at(s->fifo, (void **)out->extended_data, out->nb_samples, s->current_sample);
@@ -155,7 +155,7 @@ static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
           frame->pts >= s->time_pts)) &&
         s->size > 0 && s->loop != 0) {
         if (s->nb_samples < s->size) {
-            int written = FFMIN(frame->nb_samples, s->size - s->nb_samples);
+            int written = FFMINI(frame->nb_samples, s->size - s->nb_samples);
             int drain = 0;
 
             if (s->start < 0)
@@ -165,7 +165,7 @@ static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
             if (ret < 0)
                 return ret;
             if (!s->nb_samples) {
-                drain = FFMAX(0, s->start - s->ignored_samples);
+                drain = FFMAXI(0, s->start - s->ignored_samples);
                 s->pts = frame->pts;
                 av_audio_fifo_drain(s->fifo, drain);
                 s->pts += av_rescale_q(s->start - s->ignored_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index f4e4aa312d5..d14d5715c0d 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -137,7 +137,7 @@ static int ends_with(MetadataContext *s, const char *value1, const char *value2)
     const int len1 = strlen(value1);
     const int len2 = strlen(value2);
 
-    return !strncmp(value1 + FFMAX(len1 - len2, 0), value2, len2);
+    return !strncmp(value1 + FFMAXI(len1 - len2, 0), value2, len2);
 }
 
 static int equal(MetadataContext *s, const char *value1, const char *value2)
diff --git a/libavfilter/f_segment.c b/libavfilter/f_segment.c
index ece53ae56d5..bf5c6ddd79e 100644
--- a/libavfilter/f_segment.c
+++ b/libavfilter/f_segment.c
@@ -212,7 +212,7 @@ static int activate(AVFilterContext *ctx)
         if (s->use_timestamps) {
             max_samples = av_rescale_q(diff, av_make_q(1, inlink->sample_rate), inlink->time_base);
         } else {
-            max_samples = FFMAX(1, FFMIN(diff, INT_MAX));
+            max_samples = FFMAXI(1, FFMINI(diff, INT_MAX));
         }
         if (max_samples <= 0 || max_samples > INT_MAX)
             ret = ff_inlink_consume_frame(inlink, &frame);
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index aa374c6ad0b..3bc418186b2 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -306,7 +306,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
 
         mafd = (double)sad / count / (1ULL << (select->bitdepth - 8));
         diff = fabs(mafd - select->prev_mafd);
-        ret  = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
+        ret  = av_clipf(FFMIND(mafd, diff) / 100., 0, 1);
         select->prev_mafd = mafd;
         av_frame_free(&prev_picref);
     }
@@ -410,7 +410,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame)
     } else if (isnan(res) || res < 0) {
         select->select_out = 0; /* first output */
     } else {
-        select->select_out = FFMIN(ceilf(res)-1, select->nb_outputs-1); /* other outputs */
+        select->select_out = FFMINF(ceilf(res)-1, select->nb_outputs-1); /* other outputs */
     }
 
     av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f select_out:%d\n", res, select->select_out);
diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
index 9201fb53814..98c7a2f7f16 100644
--- a/libavfilter/f_sendcmd.c
+++ b/libavfilter/f_sendcmd.c
@@ -242,7 +242,7 @@ static int parse_commands(Command **cmds, int *nb_cmds, int interval_count,
 
         /* (re)allocate commands array if required */
         if (*nb_cmds == n) {
-            n = FFMAX(16, 2*n); /* first allocation = 16, or double the number */
+            n = FFMAXI(16, 2*n); /* first allocation = 16, or double the number */
             *cmds = av_realloc_f(*cmds, n, 2*sizeof(Command));
             if (!*cmds) {
                 av_log(log_ctx, AV_LOG_ERROR,
@@ -381,7 +381,7 @@ static int parse_intervals(Interval **intervals, int *nb_intervals,
 
         /* (re)allocate commands array if required */
         if (*nb_intervals == n) {
-            n = FFMAX(16, 2*n); /* first allocation = 16, or double the number */
+            n = FFMAXI(16, 2*n); /* first allocation = 16, or double the number */
             *intervals = av_realloc_f(*intervals, n, 2*sizeof(Interval));
             if (!*intervals) {
                 av_log(log_ctx, AV_LOG_ERROR,
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 1a1fc0de1ed..a5a1465ff57 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -254,7 +254,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
             av_assert0(frame->nb_extended_buf == 0);
         }
 
-        for (i = 0; i < FFMIN(pool->planes, AV_NUM_DATA_POINTERS); i++) {
+        for (i = 0; i < FFMINI(pool->planes, AV_NUM_DATA_POINTERS); i++) {
             frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
             if (!frame->buf[i])
                 goto fail;
diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index 0d5779f830f..4ee17fe67d5 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -116,7 +116,7 @@ static void framesync_sync_level_update(FFFrameSync *fs, int64_t eof_pts)
 
     for (i = 0; i < fs->nb_in; i++)
         if (fs->in[i].state != STATE_EOF)
-            level = FFMAX(level, fs->in[i].sync);
+            level = FFMAXI(level, fs->in[i].sync);
     av_assert0(level <= fs->sync_level);
     if (level < fs->sync_level)
         av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level);
diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
index 1bb59e43010..18fc269bbef 100644
--- a/libavfilter/graphdump.c
+++ b/libavfilter/graphdump.c
@@ -77,20 +77,20 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph)
         for (j = 0; j < filter->nb_inputs; j++) {
             AVFilterLink *l = filter->inputs[j];
             unsigned ln = strlen(l->src->name) + 1 + strlen(l->srcpad->name);
-            max_src_name = FFMAX(max_src_name, ln);
-            max_in_name = FFMAX(max_in_name, strlen(l->dstpad->name));
-            max_in_fmt = FFMAX(max_in_fmt, print_link_prop(NULL, l));
+            max_src_name = FFMAXI(max_src_name, ln);
+            max_in_name = FFMAXI(max_in_name, strlen(l->dstpad->name));
+            max_in_fmt = FFMAXI(max_in_fmt, print_link_prop(NULL, l));
         }
         for (j = 0; j < filter->nb_outputs; j++) {
             AVFilterLink *l = filter->outputs[j];
             unsigned ln = strlen(l->dst->name) + 1 + strlen(l->dstpad->name);
-            max_dst_name = FFMAX(max_dst_name, ln);
-            max_out_name = FFMAX(max_out_name, strlen(l->srcpad->name));
-            max_out_fmt = FFMAX(max_out_fmt, print_link_prop(NULL, l));
+            max_dst_name = FFMAXI(max_dst_name, ln);
+            max_out_name = FFMAXI(max_out_name, strlen(l->srcpad->name));
+            max_out_fmt = FFMAXI(max_out_fmt, print_link_prop(NULL, l));
         }
         in_indent = max_src_name + max_in_name + max_in_fmt;
         in_indent += in_indent ? 4 : 0;
-        width = FFMAX(lname + 2, ltype + 4);
+        width = FFMAXI(lname + 2, ltype + 4);
         height = FFMAX3(2, filter->nb_inputs, filter->nb_outputs);
         av_bprint_chars(buf, ' ', in_indent);
         av_bprintf(buf, "+");
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index a23e26d2e38..22070825b27 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -661,7 +661,7 @@ find_linklabel(AVFilterGraphSegment *seg, const char *label,
             l    = output ? p->filter->outputs    : p->filter->inputs;
             nb_l = output ? p->filter->nb_outputs : p->filter->nb_inputs;
 
-            for (unsigned i = 0; i < FFMIN(nb_io, nb_l); i++)
+            for (unsigned i = 0; i < FFMINI(nb_io, nb_l); i++)
                 if (!l[i] && io[i]->label && !strcmp(io[i]->label, label)) {
                     *pp = p;
                     return i;
diff --git a/libavfilter/median_template.c b/libavfilter/median_template.c
index 6f719df57f3..107acaa6d0f 100644
--- a/libavfilter/median_template.c
+++ b/libavfilter/median_template.c
@@ -68,7 +68,7 @@ static void fn(filter_plane)(AVFilterContext *ctx, const uint8_t *ssrc, int src_
     memset(cfine, 0, s->fine_size * sizeof(*cfine));
     memset(ccoarse, 0, s->coarse_size * sizeof(*ccoarse));
 
-    srcp = src + FFMAX(0, slice_h_start - radiusV) * src_linesize;
+    srcp = src + FFMAXI(0, slice_h_start - radiusV) * src_linesize;
     if (jobnr == 0) {
         for (int i = 0; i < width; i++) {
             cfine[PICK_FINE_BIN(width, srcp[i], i)] += radiusV + 1;
@@ -76,7 +76,7 @@ static void fn(filter_plane)(AVFilterContext *ctx, const uint8_t *ssrc, int src_
         }
     }
 
-    srcp = src + FFMAX(0, slice_h_start - radiusV - (jobnr != 0)) * src_linesize;
+    srcp = src + FFMAXI(0, slice_h_start - radiusV - (jobnr != 0)) * src_linesize;
     for (int i = 0; i < radiusV + (jobnr != 0) * (1 + radiusV); i++) {
         for (int j = 0; j < width; j++) {
             cfine[PICK_FINE_BIN(width, srcp[j], j)]++;
@@ -92,13 +92,13 @@ static void fn(filter_plane)(AVFilterContext *ctx, const uint8_t *ssrc, int src_
         htype fine[BINS][BINS] = { { 0 } };
         htype luc[BINS] = { 0 };
 
-        p = srcp + src_linesize * FFMAX(0, i - radiusV - 1);
+        p = srcp + src_linesize * FFMAXI(0, i - radiusV - 1);
         for (int j = 0; j < width; j++) {
             cfine[PICK_FINE_BIN(width, p[j], j)]--;
             ccoarse[PICK_COARSE_BIN(j, p[j])]--;
         }
 
-        p = srcp + src_linesize * FFMIN(height - 1, i + radiusV);
+        p = srcp + src_linesize * FFMINI(height - 1, i + radiusV);
         for (int j = 0; j < width; j++) {
             cfine[PICK_FINE_BIN(width, p[j], j)]++;
             ccoarse[PICK_COARSE_BIN(j, p[j])]++;
diff --git a/libavfilter/motion_estimation.c b/libavfilter/motion_estimation.c
index 2bf5ce61555..6388243fbfe 100644
--- a/libavfilter/motion_estimation.c
+++ b/libavfilter/motion_estimation.c
@@ -78,10 +78,10 @@ uint64_t ff_me_cmp_sad(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int x_mv,
 uint64_t ff_me_search_esa(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
 
     if (!(cost_min = me_ctx->get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
@@ -97,10 +97,10 @@ uint64_t ff_me_search_esa(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *m
 uint64_t ff_me_search_tss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int step = ROUNDED_DIV(me_ctx->search_param, 2);
     int i;
@@ -128,10 +128,10 @@ uint64_t ff_me_search_tss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *m
 uint64_t ff_me_search_tdls(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int step = ROUNDED_DIV(me_ctx->search_param, 2);
     int i;
@@ -160,10 +160,10 @@ uint64_t ff_me_search_tdls(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *
 uint64_t ff_me_search_ntss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int step = ROUNDED_DIV(me_ctx->search_param, 2);
     int first_step = 1;
@@ -213,10 +213,10 @@ uint64_t ff_me_search_ntss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *
 uint64_t ff_me_search_fss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int step = 2;
     int i;
@@ -245,10 +245,10 @@ uint64_t ff_me_search_fss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *m
 uint64_t ff_me_search_ds(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int i;
     av_unused int dir_x, dir_y;
@@ -300,10 +300,10 @@ uint64_t ff_me_search_ds(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv
 uint64_t ff_me_search_hexbs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int i;
 
@@ -333,10 +333,10 @@ uint64_t ff_me_search_hexbs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int
 uint64_t ff_me_search_epzs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int i;
 
@@ -374,10 +374,10 @@ uint64_t ff_me_search_epzs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *
 uint64_t ff_me_search_umh(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
 {
     int x, y;
-    int x_min = FFMAX(me_ctx->x_min, x_mb - me_ctx->search_param);
-    int y_min = FFMAX(me_ctx->y_min, y_mb - me_ctx->search_param);
-    int x_max = FFMIN(x_mb + me_ctx->search_param, me_ctx->x_max);
-    int y_max = FFMIN(y_mb + me_ctx->search_param, me_ctx->y_max);
+    int x_min = FFMAXI(me_ctx->x_min, x_mb - me_ctx->search_param);
+    int y_min = FFMAXI(me_ctx->y_min, y_mb - me_ctx->search_param);
+    int x_max = FFMINI(x_mb + me_ctx->search_param, me_ctx->x_max);
+    int y_max = FFMINI(y_mb + me_ctx->search_param, me_ctx->y_max);
     uint64_t cost, cost_min;
     int d, i;
     int end_x, end_y;
@@ -404,10 +404,10 @@ uint64_t ff_me_search_umh(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *m
     }
 
     // Uneven Multi-Hexagon-Grid Search
-    end_x = FFMIN(mv[0] + 2, x_max);
-    end_y = FFMIN(mv[1] + 2, y_max);
-    for (y = FFMAX(y_min, mv[1] - 2); y <= end_y; y++)
-        for (x = FFMAX(x_min, mv[0] - 2); x <= end_x; x++)
+    end_x = FFMINI(mv[0] + 2, x_max);
+    end_y = FFMINI(mv[1] + 2, y_max);
+    for (y = FFMAXI(y_min, mv[1] - 2); y <= end_y; y++)
+        for (x = FFMAXI(x_min, mv[0] - 2); x <= end_x; x++)
             COST_P_MV(x, y);
 
     x = mv[0];
diff --git a/libavfilter/pthread.c b/libavfilter/pthread.c
index 06590fe65a2..8a314386285 100644
--- a/libavfilter/pthread.c
+++ b/libavfilter/pthread.c
@@ -76,7 +76,7 @@ static int thread_init_internal(ThreadContext *c, int nb_threads)
     nb_threads = avpriv_slicethread_create(&c->thread, c, worker_func, NULL, nb_threads);
     if (nb_threads <= 1)
         avpriv_slicethread_free(&c->thread);
-    return FFMAX(nb_threads, 1);
+    return FFMAXI(nb_threads, 1);
 }
 
 int ff_graph_thread_init(FFFilterGraph *graphi)
diff --git a/libavfilter/scale_eval.c b/libavfilter/scale_eval.c
index 53f5e22b0ef..9bfd5f9faea 100644
--- a/libavfilter/scale_eval.c
+++ b/libavfilter/scale_eval.c
@@ -156,16 +156,16 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink,
                     * force_divisible_by;
 
         if (force_original_aspect_ratio == 1) {
-             w = FFMIN(tmp_w, w);
-             h = FFMIN(tmp_h, h);
+             w = FFMINI(tmp_w, w);
+             h = FFMINI(tmp_h, h);
              if (force_divisible_by > 1) {
                  // round down in case provided w or h is not divisible.
                  w = w / force_divisible_by * force_divisible_by;
                  h = h / force_divisible_by * force_divisible_by;
              }
         } else {
-             w = FFMAX(tmp_w, w);
-             h = FFMAX(tmp_h, h);
+             w = FFMAXI(tmp_w, w);
+             h = FFMAXI(tmp_h, h);
              if (force_divisible_by > 1) {
                  // round up in case provided w or h is not divisible.
                  w = (w + force_divisible_by - 1) / force_divisible_by * force_divisible_by;
diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index 46602874dea..ef383880dd9 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -497,7 +497,7 @@ static MatchingInfo evaluate_parameters(AVFilterContext *ctx, SignatureContext *
             continue; /* matching sequence is too short */
         if ((double) goodfcount / (double) fcount < sc->thit)
             continue;
-        if ((double) goodfcount*0.5 <= FFMAX(gooda, goodb))
+        if ((double) goodfcount*0.5 <= FFMAXI(gooda, goodb))
             continue;
 
         meandist = (double) distsum / (double) goodfcount;
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index adb21e019ea..01722e06509 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -350,7 +350,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
             return AVERROR(EINVAL);
         st->discard = AVDISCARD_DEFAULT;
         movie->st[i].st = st;
-        movie->max_stream_index = FFMAX(movie->max_stream_index, st->index);
+        movie->max_stream_index = FFMAXI(movie->max_stream_index, st->index);
         movie->st[i].discontinuity_threshold =
             av_rescale_q(movie->discontinuity_threshold, AV_TIME_BASE_Q, st->time_base);
 
diff --git a/libavfilter/trim.c b/libavfilter/trim.c
index 7200680716c..05616696e5c 100644
--- a/libavfilter/trim.c
+++ b/libavfilter/trim.c
@@ -174,13 +174,13 @@ static int atrim_filter_frame(AVFilterLink *inlink, AVFrame *frame)
         if (s->start_sample >= 0 &&
             s->nb_samples + frame->nb_samples > s->start_sample) {
             drop         = 0;
-            start_sample = FFMIN(start_sample, s->start_sample - s->nb_samples);
+            start_sample = FFMINI(start_sample, s->start_sample - s->nb_samples);
         }
 
         if (s->start_pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE &&
             pts + frame->nb_samples > s->start_pts) {
             drop = 0;
-            start_sample = FFMIN(start_sample, s->start_pts - pts);
+            start_sample = FFMINI(start_sample, s->start_pts - pts);
         }
 
         if (drop)
@@ -200,18 +200,18 @@ static int atrim_filter_frame(AVFilterLink *inlink, AVFrame *frame)
         if (s->end_sample != INT64_MAX &&
             s->nb_samples < s->end_sample) {
             drop       = 0;
-            end_sample = FFMAX(end_sample, s->end_sample - s->nb_samples);
+            end_sample = FFMAXI(end_sample, s->end_sample - s->nb_samples);
         }
 
         if (s->end_pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE &&
             pts < s->end_pts) {
             drop       = 0;
-            end_sample = FFMAX(end_sample, s->end_pts - pts);
+            end_sample = FFMAXI(end_sample, s->end_pts - pts);
         }
 
         if (s->duration_tb && pts - s->first_pts < s->duration_tb) {
             drop       = 0;
-            end_sample = FFMAX(end_sample, s->first_pts + s->duration_tb - pts);
+            end_sample = FFMAXI(end_sample, s->first_pts + s->duration_tb - pts);
         }
 
         if (drop) {
@@ -223,8 +223,8 @@ static int atrim_filter_frame(AVFilterLink *inlink, AVFrame *frame)
     }
 
     s->nb_samples += frame->nb_samples;
-    start_sample   = FFMAX(0, start_sample);
-    end_sample     = FFMIN(frame->nb_samples, end_sample);
+    start_sample   = FFMAXI(0, start_sample);
+    end_sample     = FFMINI(frame->nb_samples, end_sample);
     if (start_sample >= end_sample || !frame->nb_samples)
         goto drop;
 
diff --git a/libavfilter/vaf_spectrumsynth.c b/libavfilter/vaf_spectrumsynth.c
index a2f797ec6f0..9a77db05dc2 100644
--- a/libavfilter/vaf_spectrumsynth.c
+++ b/libavfilter/vaf_spectrumsynth.c
@@ -224,7 +224,7 @@ static int config_output(AVFilterLink *outlink)
     for (factor = 0, i = 0; i < s->win_size; i++) {
         factor += s->window_func_lut[i] * s->window_func_lut[i];
     }
-    s->factor = (factor / s->win_size) / FFMAX(1 / (1 - s->overlap) - 1, 1);
+    s->factor = (factor / s->win_size) / FFMAXF(1 / (1 - s->overlap) - 1, 1);
 
     return 0;
 }
diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c
index f5779484a9a..6c2eb6d75be 100644
--- a/libavfilter/vf_alphamerge.c
+++ b/libavfilter/vf_alphamerge.c
@@ -82,7 +82,7 @@ static int do_alphamerge(FFFrameSync *fs)
         const int alpha_linesize = alpha_buf->linesize[Y];
         av_image_copy_plane(main_buf->data[A], main_linesize,
                             alpha_buf->data[Y], alpha_linesize,
-                            FFMIN(main_linesize, alpha_linesize), alpha_buf->height);
+                            FFMINI(main_linesize, alpha_linesize), alpha_buf->height);
     }
 
     return ff_filter_frame(ctx->outputs[0], main_buf);
diff --git a/libavfilter/vf_amplify.c b/libavfilter/vf_amplify.c
index 7f18012a53a..2bf60faa32c 100644
--- a/libavfilter/vf_amplify.c
+++ b/libavfilter/vf_amplify.c
@@ -227,7 +227,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         td.out = out;
         td.in = s->frames;
         ff_filter_execute(ctx, amplify_frame, &td, NULL,
-                          FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->height[1], ff_filter_get_nb_threads(ctx)));
     } else {
         out = av_frame_clone(s->frames[s->radius]);
         if (!out)
diff --git a/libavfilter/vf_avgblur.c b/libavfilter/vf_avgblur.c
index 3bd4faa5f64..dd31402a855 100644
--- a/libavfilter/vf_avgblur.c
+++ b/libavfilter/vf_avgblur.c
@@ -130,8 +130,8 @@ static int filter_##name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
     dst += dlinesize;                                                             \
                                                                                   \
     for (int y = 1; y < height; y++) {                                            \
-        const int syp = FFMIN(size_h, height - y - 1) * linesize;                 \
-        const int syn = FFMIN(y, size_h + 1) * linesize;                          \
+        const int syp = FFMINI(size_h, height - y - 1) * linesize;                 \
+        const int syn = FFMINI(y, size_h + 1) * linesize;                          \
                                                                                   \
         sum = 0;                                                                  \
                                                                                   \
@@ -221,8 +221,8 @@ static int config_input(AVFilterLink *inlink)
     s->filter[0] = s->depth <= 8 ? filter_lut8  : filter_lut16;
     s->filter[1] = s->depth <= 8 ? filter_slow8 : filter_slow16;
 
-    s->radius  = FFMIN(s->planewidth[1]  / 2, s->radius);
-    s->radiusV = FFMIN(s->planeheight[1] / 2, s->radiusV);
+    s->radius  = FFMINI(s->planewidth[1]  / 2, s->radius);
+    s->radiusV = FFMINI(s->planeheight[1] / 2, s->radiusV);
 
     build_lut(ctx, s->max);
 
@@ -316,8 +316,8 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar
     if (s->radiusV <= 0)
         s->radiusV = s->radius;
 
-    s->radius  = FFMIN(s->planewidth[1]  / 2, s->radius);
-    s->radiusV = FFMIN(s->planeheight[1] / 2, s->radiusV);
+    s->radius  = FFMINI(s->planewidth[1]  / 2, s->radius);
+    s->radiusV = FFMINI(s->planeheight[1] / 2, s->radiusV);
 
     if (area != (2 * s->radiusV + 1) * (2 * s->radius + 1))
         build_lut(ctx, s->max);
diff --git a/libavfilter/vf_avgblur_opencl.c b/libavfilter/vf_avgblur_opencl.c
index 790a51ea80d..65baaa28ef6 100644
--- a/libavfilter/vf_avgblur_opencl.c
+++ b/libavfilter/vf_avgblur_opencl.c
@@ -191,7 +191,7 @@ static int avgblur_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
         goto fail;
     }
 
-    for (p = 0; p < FFMIN(FF_ARRAY_ELEMS(output->data), AV_VIDEO_MAX_PLANES); p++) {
+    for (p = 0; p < FFMINI(FF_ARRAY_ELEMS(output->data), AV_VIDEO_MAX_PLANES); p++) {
         src = (cl_mem) input->data[p];
         dst = (cl_mem) output->data[p];
         inter = (cl_mem)intermediate->data[p];
diff --git a/libavfilter/vf_backgroundkey.c b/libavfilter/vf_backgroundkey.c
index f0a76b977e7..4053aa3482b 100644
--- a/libavfilter/vf_backgroundkey.c
+++ b/libavfilter/vf_backgroundkey.c
@@ -150,7 +150,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     }
 
     if (ret = ff_filter_execute(avctx, s->do_slice, frame, NULL,
-                                FFMIN(frame->height, s->nb_threads)))
+                                FFMINI(frame->height, s->nb_threads)))
         goto fail;
 
     for (int n = 0; n < s->nb_threads; n++)
diff --git a/libavfilter/vf_bilateral_cuda.c b/libavfilter/vf_bilateral_cuda.c
index 7115fa9e059..3897eb5f302 100644
--- a/libavfilter/vf_bilateral_cuda.c
+++ b/libavfilter/vf_bilateral_cuda.c
@@ -170,7 +170,7 @@ static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_
     for (i = 0; i < s->in_desc->nb_components; i++) {
         d = (s->in_desc->comp[i].depth + 7) / 8;
         p = s->in_desc->comp[i].plane;
-        s->in_plane_channels[p] = FFMAX(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
+        s->in_plane_channels[p] = FFMAXI(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
 
         s->in_plane_depths[p] = s->in_desc->comp[i].depth;
     }
diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c
index 8be33a814dd..40ecc2388e1 100644
--- a/libavfilter/vf_blackdetect.c
+++ b/libavfilter/vf_blackdetect.c
@@ -212,7 +212,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
         16 * factor + s->pixel_black_th * (235 - 16) * factor;
 
     ff_filter_execute(ctx, black_counter, picref, NULL,
-                      FFMIN(inlink->h, s->nb_threads));
+                      FFMINI(inlink->h, s->nb_threads));
 
     for (int i = 0; i < s->nb_threads; i++)
         s->nb_black_pixels += s->counter[i];
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 149d64399c5..cac00508581 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -223,7 +223,7 @@ static AVFrame *blend_frame(AVFilterContext *ctx, AVFrame *top_buf,
                           .inlink = inlink };
 
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN(outh, s->nb_threads));
+                          FFMINI(outh, s->nb_threads));
     }
 
     if (!s->tblend)
diff --git a/libavfilter/vf_blockdetect.c b/libavfilter/vf_blockdetect.c
index e957db6a24f..b995149eda6 100644
--- a/libavfilter/vf_blockdetect.c
+++ b/libavfilter/vf_blockdetect.c
@@ -111,7 +111,7 @@ static float calculate_blockiness(BLKContext *s, int w, int h,
             temp += abs(src[j * src_linesize + i - 0] - src[j * src_linesize + i - 1]);
             temp += abs(src[j * src_linesize + i - 1] - src[j * src_linesize + i - 2]);
             temp += abs(src[j * src_linesize + i - 2] - src[j * src_linesize + i - 3]);
-            temp = FFMAX(1, temp);
+            temp = FFMAXF(1, temp);
             grad[j * grad_linesize + i] /= temp;
 
             // use first row to store acculated results
@@ -128,7 +128,7 @@ static float calculate_blockiness(BLKContext *s, int w, int h,
         nonblock_count = 0;
         for (int i = 3; i < w - 4; i++) {
             if ((i % period) == (period - 1)) {
-                block += FFMAX(FFMAX(grad[i + 0], grad[i + 1]), grad[i - 1]);
+                block += FFMAXF(FFMAXF(grad[i + 0], grad[i + 1]), grad[i - 1]);
                 block_count++;
             } else {
                 nonblock += grad[i];
@@ -137,7 +137,7 @@ static float calculate_blockiness(BLKContext *s, int w, int h,
         }
         if (block_count && nonblock_count) {
             temp = (block / block_count) / (nonblock / nonblock_count);
-            ret = FFMAX(ret, temp);
+            ret = FFMAXF(ret, temp);
         }
     }
 
@@ -154,7 +154,7 @@ static float calculate_blockiness(BLKContext *s, int w, int h,
             temp += abs(src[(j - 0) * src_linesize + i] - src[(j - 1) * src_linesize + i]);
             temp += abs(src[(j - 1) * src_linesize + i] - src[(j - 2) * src_linesize + i]);
             temp += abs(src[(j - 2) * src_linesize + i] - src[(j - 3) * src_linesize + i]);
-            temp = FFMAX(1, temp);
+            temp = FFMAXF(1, temp);
             grad[j * grad_linesize + i] /= temp;
 
             // use first column to store accumulated results
@@ -171,7 +171,7 @@ static float calculate_blockiness(BLKContext *s, int w, int h,
         nonblock_count = 0;
         for (int j = 3; j < h - 4; j++) {
             if ((j % period) == (period - 1)) {
-                block += FFMAX(FFMAX(grad[(j + 0) * grad_linesize],
+                block += FFMAXF(FFMAXF(grad[(j + 0) * grad_linesize],
                                      grad[(j + 1) * grad_linesize]),
                                      grad[(j - 1) * grad_linesize]);
                 block_count++;
@@ -182,7 +182,7 @@ static float calculate_blockiness(BLKContext *s, int w, int h,
         }
         if (block_count && nonblock_count) {
             temp = (block / block_count) / (nonblock / nonblock_count);
-            ret = FFMAX(ret, temp);
+            ret = FFMAXF(ret, temp);
         }
     }
 
diff --git a/libavfilter/vf_bm3d.c b/libavfilter/vf_bm3d.c
index b482f7693ae..520ca64928e 100644
--- a/libavfilter/vf_bm3d.c
+++ b/libavfilter/vf_bm3d.c
@@ -594,7 +594,7 @@ static void final_block_filtering(BM3DContext *s, const uint8_t *src, int src_li
         }
     }
 
-    l2_wiener = FFMAX(l2_wiener, 1e-15f);
+    l2_wiener = FFMAXF(l2_wiener, 1e-15f);
     den_weight = 1.f / l2_wiener;
     num_weight = den_weight;
 
@@ -693,8 +693,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
     const int plane = td->plane;
     const int width = s->planewidth[plane];
     const int height = s->planeheight[plane];
-    const int block_pos_bottom = FFMAX(0, height - s->block_size);
-    const int block_pos_right  = FFMAX(0, width - s->block_size);
+    const int block_pos_bottom = FFMAXI(0, height - s->block_size);
+    const int block_pos_right  = FFMAXI(0, width - s->block_size);
     const int slice_start = (((height + block_step - 1) / block_step) * jobnr / nb_jobs) * block_step;
     const int slice_end = (jobnr == nb_jobs - 1) ? block_pos_bottom + block_step :
                           (((height + block_step - 1) / block_step) * (jobnr + 1) / nb_jobs) * block_step;
@@ -734,7 +734,7 @@ static int filter_frame(AVFilterContext *ctx, AVFrame **out, AVFrame *in, AVFram
     av_frame_copy_props(*out, in);
 
     for (p = 0; p < s->nb_planes; p++) {
-        const int nb_jobs = FFMAX(1, FFMIN(s->nb_threads, s->planeheight[p] / s->block_size));
+        const int nb_jobs = FFMAXI(1, FFMINI(s->nb_threads, s->planeheight[p] / s->block_size));
         ThreadData td;
 
         if (!((1 << p) & s->planes) || ctx->is_disabled) {
@@ -765,7 +765,7 @@ static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     BM3DContext *s = ctx->priv;
 
-    s->nb_threads = FFMIN(ff_filter_get_nb_threads(ctx), MAX_NB_THREADS);
+    s->nb_threads = FFMINI(ff_filter_get_nb_threads(ctx), MAX_NB_THREADS);
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
     s->depth = desc->comp[0].depth;
     s->max = (1 << s->depth) - 1;
diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c
index 3cb42471a73..7003563b6bf 100644
--- a/libavfilter/vf_boxblur.c
+++ b/libavfilter/vf_boxblur.c
@@ -82,8 +82,8 @@ static int config_input(AVFilterLink *inlink)
     int w = inlink->w, h = inlink->h;
     int ret;
 
-    if (!(s->temp[0] = av_malloc(2*FFMAX(w, h))) ||
-        !(s->temp[1] = av_malloc(2*FFMAX(w, h))))
+    if (!(s->temp[0] = av_malloc(2*FFMAXI(w, h))) ||
+        !(s->temp[1] = av_malloc(2*FFMAXI(w, h))))
         return AVERROR(ENOMEM);
 
     s->hsub = desc->log2_chroma_w;
diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c
index d49f3f66d6e..e14c3caf8ac 100644
--- a/libavfilter/vf_bwdif.c
+++ b/libavfilter/vf_bwdif.c
@@ -130,7 +130,7 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic,
         td.plane = i;
 
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN((h+3)/4, ff_filter_get_nb_threads(ctx)));
+                          FFMINI((h+3)/4, ff_filter_get_nb_threads(ctx)));
     }
     if (yadif->current_field == YADIF_FIELD_END) {
         yadif->current_field = YADIF_FIELD_NORMAL;
diff --git a/libavfilter/vf_cas.c b/libavfilter/vf_cas.c
index 54d164fb7fe..0322e1449d1 100644
--- a/libavfilter/vf_cas.c
+++ b/libavfilter/vf_cas.c
@@ -70,11 +70,11 @@ static int cas_slice8(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
         }
 
         for (int y = slice_start; y < slice_end; y++) {
-            const int y0 = FFMAX(y - 1, 0);
-            const int y1 = FFMIN(y + 1, h1);
+            const int y0 = FFMAXI(y - 1, 0);
+            const int y1 = FFMINI(y + 1, h1);
             for (int x = 0; x < w; x++) {
-                const int x0 = FFMAX(x - 1, 0);
-                const int x1 = FFMIN(x + 1, w1);
+                const int x0 = FFMAXI(x - 1, 0);
+                const int x1 = FFMINI(x + 1, w1);
                 int a = src[y0 * in_linesize + x0];
                 int b = src[y0 * in_linesize + x];
                 int c = src[y0 * in_linesize + x1];
@@ -97,7 +97,7 @@ static int cas_slice8(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
 
                 mx = mx + mx2;
 
-                amp = sqrtf(av_clipf(FFMIN(mn, 511 - mx) / (float)mx, 0.f, 1.f));
+                amp = sqrtf(av_clipf(FFMINI(mn, 511 - mx) / (float)mx, 0.f, 1.f));
 
                 weight = amp / strength;
 
@@ -137,11 +137,11 @@ static int cas_slice16(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs
         }
 
         for (int y = slice_start; y < slice_end; y++) {
-            const int y0 = FFMAX(y - 1, 0);
-            const int y1 = FFMIN(y + 1, h1);
+            const int y0 = FFMAXI(y - 1, 0);
+            const int y1 = FFMINI(y + 1, h1);
             for (int x = 0; x < w; x++) {
-                const int x0 = FFMAX(x - 1, 0);
-                const int x1 = FFMIN(x + 1, w1);
+                const int x0 = FFMAXI(x - 1, 0);
+                const int x1 = FFMINI(x + 1, w1);
                 int a = src[y0 * in_linesize + x0];
                 int b = src[y0 * in_linesize + x];
                 int c = src[y0 * in_linesize + x1];
@@ -164,7 +164,7 @@ static int cas_slice16(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs
 
                 mx = mx + mx2;
 
-                amp = sqrtf(av_clipf(FFMIN(mn, max - mx) / (float)mx, 0.f, 1.f));
+                amp = sqrtf(av_clipf(FFMINI(mn, max - mx) / (float)mx, 0.f, 1.f));
 
                 weight = amp / strength;
 
@@ -193,7 +193,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     s->in = in;
     ff_filter_execute(ctx, s->do_slice, out, NULL,
-                      FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
     av_frame_free(&in);
     s->in = NULL;
 
diff --git a/libavfilter/vf_chromakey.c b/libavfilter/vf_chromakey.c
index f6f6314615e..3b22ec0edc8 100644
--- a/libavfilter/vf_chromakey.c
+++ b/libavfilter/vf_chromakey.c
@@ -259,7 +259,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     int res;
 
     if (res = ff_filter_execute(avctx, ctx->do_slice, frame, NULL,
-                                FFMIN(frame->height, ff_filter_get_nb_threads(avctx))))
+                                FFMINI(frame->height, ff_filter_get_nb_threads(avctx))))
         return res;
 
     return ff_filter_frame(avctx->outputs[0], frame);
diff --git a/libavfilter/vf_chromakey_cuda.c b/libavfilter/vf_chromakey_cuda.c
index 43f50c5a9aa..d956cce4e2e 100644
--- a/libavfilter/vf_chromakey_cuda.c
+++ b/libavfilter/vf_chromakey_cuda.c
@@ -172,7 +172,7 @@ static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_
     {
         d = (s->in_desc->comp[i].depth + 7) / 8;
         p = s->in_desc->comp[i].plane;
-        s->in_plane_channels[p] = FFMAX(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
+        s->in_plane_channels[p] = FFMAXI(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
 
         s->in_plane_depths[p]   = s->in_desc->comp[i].depth;
     }
diff --git a/libavfilter/vf_chromanr.c b/libavfilter/vf_chromanr.c
index ba2c57cdf41..9132d6cc699 100644
--- a/libavfilter/vf_chromanr.c
+++ b/libavfilter/vf_chromanr.c
@@ -126,12 +126,12 @@ static int distance ## _slice##name(AVFilterContext *ctx, void *arg,
         const type *in_yptr = (const type *)(in->data[0] + y * chroma_h * in_ylinesize); \
         const type *in_uptr = (const type *)(in->data[1] + y * in_ulinesize);            \
         const type *in_vptr = (const type *)(in->data[2] + y * in_vlinesize);            \
-        const int yystart = FFMAX(0, y - sizeh);                                         \
-        const int yystop  = FFMIN(h - 1, y + sizeh);                                     \
+        const int yystart = FFMAXI(0, y - sizeh);                                         \
+        const int yystop  = FFMINI(h - 1, y + sizeh);                                     \
                                                                                          \
         for (int x = 0; x < w; x++) {                                                    \
-            const int xxstart = FFMAX(0, x - sizew);                                     \
-            const int xxstop  = FFMIN(w - 1, x + sizew);                                 \
+            const int xxstart = FFMAXI(0, x - sizew);                                     \
+            const int xxstop  = FFMINI(w - 1, x + sizew);                                 \
             const int cy = in_yptr[x * chroma_w];                                        \
             const int cu = in_uptr[x];                                                   \
             const int cv = in_vptr[x];                                                   \
diff --git a/libavfilter/vf_ciescope.c b/libavfilter/vf_ciescope.c
index 21f7dc5de3c..3f5b54dc2e7 100644
--- a/libavfilter/vf_ciescope.c
+++ b/libavfilter/vf_ciescope.c
@@ -942,7 +942,7 @@ gamma_correct_rgb(const struct ColorSystem * const cs,
    distance units.  (A normalized distance unit is 1/512 of the smaller
    dimension of the canvas)
 */
-#define Sz(x) (((x) * (int)FFMIN(w, h)) / 512)
+#define Sz(x) (((x) * (int)FFMINI(w, h)) / 512)
 
 static void
 monochrome_color_location(float waveLength, int w, int h,
@@ -1462,9 +1462,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             g = dst[pos + 1] + i;
             b = dst[pos + 2] + i;
 
-            dst[pos + 0] = FFMIN(r, 65535);
-            dst[pos + 1] = FFMIN(g, 65535);
-            dst[pos + 2] = FFMIN(b, 65535);
+            dst[pos + 0] = FFMINI(r, 65535);
+            dst[pos + 1] = FFMINI(g, 65535);
+            dst[pos + 2] = FFMINI(b, 65535);
             dst[pos + 3] = 65535;
         }
     }
diff --git a/libavfilter/vf_colorbalance.c b/libavfilter/vf_colorbalance.c
index 80e218d32ba..8775c9f26cc 100644
--- a/libavfilter/vf_colorbalance.c
+++ b/libavfilter/vf_colorbalance.c
@@ -108,10 +108,10 @@ static float get_component(float v, float l,
 
 static float hfun(float n, float h, float s, float l)
 {
-    float a = s * FFMIN(l, 1.f - l);
+    float a = s * FFMINF(l, 1.f - l);
     float k = fmodf(n + h / 30.f, 12.f);
 
-    return av_clipf(l - a * FFMAX(FFMIN3(k - 3.f, 9.f - k, 1), -1.f), 0.f, 1.f);
+    return av_clipf(l - a * FFMAXF(FFMIN3(k - 3.f, 9.f - k, 1), -1.f), 0.f, 1.f);
 }
 
 static void preservel(float *r, float *g, float *b, float l)
@@ -407,7 +407,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in;
     td.out = out;
     ff_filter_execute(ctx, s->color_balance, &td, NULL,
-                      FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (in != out)
         av_frame_free(&in);
diff --git a/libavfilter/vf_colorchannelmixer.c b/libavfilter/vf_colorchannelmixer.c
index f941e7f80a4..c77f239b5be 100644
--- a/libavfilter/vf_colorchannelmixer.c
+++ b/libavfilter/vf_colorchannelmixer.c
@@ -452,7 +452,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in;
     td.out = out;
     ff_filter_execute(ctx, s->filter_slice[pc], &td, NULL,
-                      FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (in != out)
         av_frame_free(&in);
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index d5f8fd1098a..d99ed981a93 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -367,7 +367,7 @@ get_deriv(AVFilterContext *ctx, ThreadData *td, int ord, int dir,
     td->meta_data[INDEX_SRC] = src;
     td->meta_data[INDEX_DST] = dst;
     ff_filter_execute(ctx, slice_get_derivative, td,
-                      NULL, FFMIN(dim, nb_threads));
+                      NULL, FFMINI(dim, nb_threads));
 }
 
 /**
@@ -459,7 +459,7 @@ static int filter_slice_grey_edge(AVFilterContext* ctx, void* arg, int jobnr, in
         if (!minknorm) {
             for (r = slice_start; r < slice_end; ++r) {
                 for (c = 0; c < width; ++c) {
-                    dst[jobnr] = FFMAX( dst[jobnr], fabs(src[INDX2D(r, c, width)])
+                    dst[jobnr] = FFMAXD( dst[jobnr], fabs(src[INDX2D(r, c, width)])
                                         * (img_data[INDX2D(r, c, in_linesize)] < thresh) );
                 }
             }
@@ -509,7 +509,7 @@ static int filter_grey_edge(AVFilterContext *ctx, AVFrame *in)
         for (plane = 0; plane < NUM_PLANES; ++plane) {
             white[plane] = 0; // All values are absolute
             for (job = 0; job < nb_jobs; ++job) {
-                white[plane] = FFMAX(white[plane] , td.data[INDEX_DST][plane][job]);
+                white[plane] = FFMAXD(white[plane] , td.data[INDEX_DST][plane][job]);
             }
         }
     } else {
diff --git a/libavfilter/vf_colorcontrast.c b/libavfilter/vf_colorcontrast.c
index 05f2ad56769..ea877bd8ea3 100644
--- a/libavfilter/vf_colorcontrast.c
+++ b/libavfilter/vf_colorcontrast.c
@@ -303,7 +303,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     int res;
 
     if (res = ff_filter_execute(ctx, s->do_slice, frame, NULL,
-                                FFMIN(frame->height, ff_filter_get_nb_threads(ctx))))
+                                FFMINI(frame->height, ff_filter_get_nb_threads(ctx))))
         return res;
 
     return ff_filter_frame(ctx->outputs[0], frame);
diff --git a/libavfilter/vf_colorcorrect.c b/libavfilter/vf_colorcorrect.c
index 4249bd414d6..53fade599b8 100644
--- a/libavfilter/vf_colorcorrect.c
+++ b/libavfilter/vf_colorcorrect.c
@@ -141,10 +141,10 @@ static int minmax_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
 
     for (int y = slice_start; y < slice_end; y++) {
         for (int x = 0; x < width; x++) {
-            min_u = FFMIN(min_u, uptr[x]);
-            min_v = FFMIN(min_v, vptr[x]);
-            max_u = FFMAX(max_u, uptr[x]);
-            max_v = FFMAX(max_v, vptr[x]);
+            min_u = FFMINI(min_u, uptr[x]);
+            min_v = FFMINI(min_v, vptr[x]);
+            max_u = FFMAXI(max_u, uptr[x]);
+            max_v = FFMAXI(max_v, vptr[x]);
         }
 
         uptr += ulinesize;
@@ -177,10 +177,10 @@ static int minmax_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_job
 
     for (int y = slice_start; y < slice_end; y++) {
         for (int x = 0; x < width; x++) {
-            min_u = FFMIN(min_u, uptr[x]);
-            min_v = FFMIN(min_v, vptr[x]);
-            max_u = FFMAX(max_u, uptr[x]);
-            max_v = FFMAX(max_v, vptr[x]);
+            min_u = FFMINI(min_u, uptr[x]);
+            min_v = FFMINI(min_v, vptr[x]);
+            max_u = FFMAXI(max_u, uptr[x]);
+            max_v = FFMAXI(max_v, vptr[x]);
         }
 
         uptr += ulinesize;
@@ -397,7 +397,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 {
     AVFilterContext *ctx = inlink->dst;
     ColorCorrectContext *s = ctx->priv;
-    const int nb_threads = s->analyze == MEDIAN ? 1 : FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx));
+    const int nb_threads = s->analyze == MEDIAN ? 1 : FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx));
 
     if (s->analyze) {
         const int nb_athreads = s->analyze == MEDIAN ? 1 : nb_threads;
diff --git a/libavfilter/vf_colorize.c b/libavfilter/vf_colorize.c
index 1ab71b2b87c..525a5943f0e 100644
--- a/libavfilter/vf_colorize.c
+++ b/libavfilter/vf_colorize.c
@@ -203,7 +203,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     rgb2yuv(c[0], c[1], c[2], &s->c[0], &s->c[1], &s->c[2], s->depth);
 
     ff_filter_execute(ctx, do_slice, frame, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     return ff_filter_frame(ctx->outputs[0], frame);
 }
diff --git a/libavfilter/vf_colorkey.c b/libavfilter/vf_colorkey.c
index 4781e53bb2e..1e23efbd449 100644
--- a/libavfilter/vf_colorkey.c
+++ b/libavfilter/vf_colorkey.c
@@ -152,7 +152,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     int res;
 
     if (res = ff_filter_execute(avctx, ctx->do_slice, frame, NULL,
-                                FFMIN(frame->height, ff_filter_get_nb_threads(avctx))))
+                                FFMINI(frame->height, ff_filter_get_nb_threads(avctx))))
         return res;
 
     return ff_filter_frame(avctx->outputs[0], frame);
diff --git a/libavfilter/vf_colorlevels.c b/libavfilter/vf_colorlevels.c
index 5fa378ca38c..b0ca86303da 100644
--- a/libavfilter/vf_colorlevels.c
+++ b/libavfilter/vf_colorlevels.c
@@ -435,7 +435,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                     const uint8_t *src = srcrow;
 
                     for (int x = 0; x < s->linesize; x += step)
-                        imin = FFMIN(imin, src[x + offset]);
+                        imin = FFMINI(imin, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
             }
@@ -446,7 +446,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                     const uint8_t *src = srcrow;
 
                     for (int x = 0; x < s->linesize; x += step)
-                        imax = FFMAX(imax, src[x + offset]);
+                        imax = FFMAXI(imax, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
             }
@@ -475,7 +475,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                     const uint16_t *src = (const uint16_t *)srcrow;
 
                     for (int x = 0; x < s->linesize; x += step)
-                        imin = FFMIN(imin, src[x + offset]);
+                        imin = FFMINI(imin, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
             }
@@ -486,7 +486,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                     const uint16_t *src = (const uint16_t *)srcrow;
 
                     for (int x = 0; x < s->linesize; x += step)
-                        imax = FFMAX(imax, src[x + offset]);
+                        imax = FFMAXI(imax, src[x + offset]);
                     srcrow += in->linesize[0];
                 }
             }
@@ -541,7 +541,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     ff_filter_execute(ctx, s->colorlevels_slice[s->preserve_color > 0], &td, NULL,
-                      FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (in != out)
         av_frame_free(&in);
diff --git a/libavfilter/vf_colormap.c b/libavfilter/vf_colormap.c
index e0afc471ef4..8f64610cc07 100644
--- a/libavfilter/vf_colormap.c
+++ b/libavfilter/vf_colormap.c
@@ -412,9 +412,9 @@ static int import_map(AVFilterLink *inlink, AVFrame *in)
     if (changed)
         s->changed[is_target] = 1;
     if (!s->size)
-        s->size = FFMIN(idx, MAX_SIZE);
+        s->size = FFMINI(idx, MAX_SIZE);
     if (!is_target)
-        s->nb_maps = FFMIN(idx, s->size);
+        s->nb_maps = FFMINI(idx, s->size);
 
     return 0;
 }
@@ -467,7 +467,7 @@ static int process_frame(FFFrameSync *fs)
         td.in = in;
         td.out = out;
         ff_filter_execute(ctx, colormap_slice, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
 
         if (out != in)
             av_frame_free(&in);
diff --git a/libavfilter/vf_colormatrix.c b/libavfilter/vf_colormatrix.c
index 04504cd3fb8..221db9e079e 100644
--- a/libavfilter/vf_colormatrix.c
+++ b/libavfilter/vf_colormatrix.c
@@ -457,16 +457,16 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 
     if (in->format == AV_PIX_FMT_YUV444P)
         ff_filter_execute(ctx, process_slice_yuv444p, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
     else if (in->format == AV_PIX_FMT_YUV422P)
         ff_filter_execute(ctx, process_slice_yuv422p, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
     else if (in->format == AV_PIX_FMT_YUV420P)
         ff_filter_execute(ctx, process_slice_yuv420p, &td, NULL,
-                          FFMIN(in->height / 2, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height / 2, ff_filter_get_nb_threads(ctx)));
     else
         ff_filter_execute(ctx, process_slice_uyvy422, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index e1f4725f635..c5f89a5ca16 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -439,7 +439,7 @@ static int create_filtergraph(AVFilterContext *ctx,
     if (!s->out_primaries || !s->in_primaries) {
         s->in_prm = in->color_primaries;
         if (s->user_iall != CS_UNSPECIFIED)
-            s->in_prm = default_prm[FFMIN(s->user_iall, CS_NB)];
+            s->in_prm = default_prm[FFMINI(s->user_iall, CS_NB)];
         if (s->user_iprm != AVCOL_PRI_UNSPECIFIED)
             s->in_prm = s->user_iprm;
         s->in_primaries = av_csp_primaries_desc_from_id(s->in_prm);
@@ -502,7 +502,7 @@ static int create_filtergraph(AVFilterContext *ctx,
         av_freep(&s->lin_lut);
         s->in_trc = in->color_trc;
         if (s->user_iall != CS_UNSPECIFIED)
-            s->in_trc = default_trc[FFMIN(s->user_iall, CS_NB)];
+            s->in_trc = default_trc[FFMINI(s->user_iall, CS_NB)];
         if (s->user_itrc != AVCOL_TRC_UNSPECIFIED)
             s->in_trc = s->user_itrc;
         s->in_txchr = get_transfer_characteristics(s->in_trc);
@@ -547,7 +547,7 @@ static int create_filtergraph(AVFilterContext *ctx,
     if (!s->in_lumacoef) {
         s->in_csp = in->colorspace;
         if (s->user_iall != CS_UNSPECIFIED)
-            s->in_csp = default_csp[FFMIN(s->user_iall, CS_NB)];
+            s->in_csp = default_csp[FFMINI(s->user_iall, CS_NB)];
         if (s->user_icsp != AVCOL_SPC_UNSPECIFIED)
             s->in_csp = s->user_icsp;
         s->in_rng = in->color_range;
@@ -670,7 +670,7 @@ static av_cold int init(AVFilterContext *ctx)
     ColorSpaceContext *s = ctx->priv;
 
     s->out_csp  = s->user_csp == AVCOL_SPC_UNSPECIFIED ?
-                  default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp;
+                  default_csp[FFMINI(s->user_all, CS_NB)] : s->user_csp;
     s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp);
     if (!s->out_lumacoef) {
         if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
@@ -741,11 +741,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     out->color_range =     s->user_rng == AVCOL_RANGE_UNSPECIFIED ?
                            in->color_range : s->user_rng;
     out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ?
-                           default_prm[FFMIN(s->user_all, CS_NB)] : s->user_prm;
+                           default_prm[FFMINI(s->user_all, CS_NB)] : s->user_prm;
     if (s->user_trc == AVCOL_TRC_UNSPECIFIED) {
         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format);
 
-        out->color_trc   = default_trc[FFMIN(s->user_all, CS_NB)];
+        out->color_trc   = default_trc[FFMINI(s->user_all, CS_NB)];
         if (out->color_trc == AVCOL_TRC_BT2020_10 && desc && desc->comp[0].depth >= 12)
             out->color_trc = AVCOL_TRC_BT2020_12;
     } else {
@@ -830,7 +830,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
         }
     } else {
         ff_filter_execute(ctx, convert, &td, NULL,
-                          FFMIN((in->height + 1) >> 1, ff_filter_get_nb_threads(ctx)));
+                          FFMINI((in->height + 1) >> 1, ff_filter_get_nb_threads(ctx)));
     }
     av_frame_free(&in);
 
diff --git a/libavfilter/vf_colortemperature.c b/libavfilter/vf_colortemperature.c
index b56bf837fbe..5a813c41d0e 100644
--- a/libavfilter/vf_colortemperature.c
+++ b/libavfilter/vf_colortemperature.c
@@ -311,7 +311,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     kelvin2rgb(s->temperature, s->color);
 
     ff_filter_execute(ctx, s->do_slice, frame, NULL,
-                      FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(frame->height, ff_filter_get_nb_threads(ctx)));
 
     return ff_filter_frame(ctx->outputs[0], frame);
 }
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 1f4efea9aae..f2d6d4fe938 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -196,13 +196,13 @@ static void filter16_kirsch(uint8_t *dstp, int width,
                    c3[x] * -3 + c5[x] * -3 +
                    c6[x] * -3 + c7[x] * -3 + c8[x] *  5;
 
-        sum0 = FFMAX(sum0, sum1);
-        sum2 = FFMAX(sum2, sum3);
-        sum4 = FFMAX(sum4, sum5);
-        sum6 = FFMAX(sum6, sum7);
-        sum0 = FFMAX(sum0, sum2);
-        sum4 = FFMAX(sum4, sum6);
-        sum0 = FFMAX(sum0, sum4);
+        sum0 = FFMAXI(sum0, sum1);
+        sum2 = FFMAXI(sum2, sum3);
+        sum4 = FFMAXI(sum4, sum5);
+        sum6 = FFMAXI(sum6, sum7);
+        sum0 = FFMAXI(sum0, sum2);
+        sum4 = FFMAXI(sum4, sum6);
+        sum0 = FFMAXI(sum0, sum4);
 
         dst[x] = av_clip(FFABS(sum0) * scale + delta, 0, peak);
     }
@@ -301,13 +301,13 @@ static void filter_kirsch(uint8_t *dst, int width,
                    c3[x] * -3 + c5[x] * -3 +
                    c6[x] * -3 + c7[x] * -3 + c8[x] *  5;
 
-        sum0 = FFMAX(sum0, sum1);
-        sum2 = FFMAX(sum2, sum3);
-        sum4 = FFMAX(sum4, sum5);
-        sum6 = FFMAX(sum6, sum7);
-        sum0 = FFMAX(sum0, sum2);
-        sum4 = FFMAX(sum4, sum6);
-        sum0 = FFMAX(sum0, sum4);
+        sum0 = FFMAXI(sum0, sum1);
+        sum2 = FFMAXI(sum2, sum3);
+        sum4 = FFMAXI(sum4, sum5);
+        sum6 = FFMAXI(sum6, sum7);
+        sum0 = FFMAXI(sum0, sum2);
+        sum4 = FFMAXI(sum4, sum6);
+        sum0 = FFMAXI(sum0, sum4);
 
         dst[x] = av_clip_uint8(FFABS(sum0) * scale + delta);
     }
@@ -400,7 +400,7 @@ static void filter16_column(uint8_t *dstp, int height,
 {
     DECLARE_ALIGNED(64, int, sum)[16];
     uint16_t *dst = (uint16_t *)dstp;
-    const int width = FFMIN(16, size);
+    const int width = FFMINI(16, size);
 
     for (int y = 0; y < height; y++) {
 
diff --git a/libavfilter/vf_convolve.c b/libavfilter/vf_convolve.c
index ea9cc45882f..42e07078b64 100644
--- a/libavfilter/vf_convolve.c
+++ b/libavfilter/vf_convolve.c
@@ -130,7 +130,7 @@ static int config_input(AVFilterLink *inlink)
     for (int i = 0; i < s->nb_planes; i++) {
         int w = s->planewidth[i];
         int h = s->planeheight[i];
-        int n = FFMAX(w, h);
+        int n = FFMAXI(w, h);
 
         s->fft_len[i] = 1 << (av_log2(2 * n - 1));
 
@@ -626,7 +626,7 @@ static void prepare_impulse(AVFilterContext *ctx, AVFrame *impulsepic, int plane
             }
         }
     }
-    total = FFMAX(1, total);
+    total = FFMAXF(1, total);
 
     s->get_input(s, s->fft_hdata_impulse_in[plane], impulsepic, w, h, n, plane, 1.f / total);
 
diff --git a/libavfilter/vf_corr.c b/libavfilter/vf_corr.c
index 7b87fa2c485..b8e81061c08 100644
--- a/libavfilter/vf_corr.c
+++ b/libavfilter/vf_corr.c
@@ -204,7 +204,7 @@ static int do_corr(FFFrameSync *fs)
     td.master = master;
     td.ref = ref;
     ff_filter_execute(ctx, s->sum_slice, &td, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     for (int c = 0; c < s->nb_components; c++) {
         const double scale = 1.f / s->max[c];
@@ -220,7 +220,7 @@ static int do_corr(FFFrameSync *fs)
     }
 
     ff_filter_execute(ctx, s->corr_slice, &td, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     for (int c = 0; c < s->nb_components; c++) {
         double sumq, sum12 = 0.0, sum1q = 0.0, sum2q = 0.0;
diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c
index 410869d9c3e..5fb5cef266c 100644
--- a/libavfilter/vf_cover_rect.c
+++ b/libavfilter/vf_cover_rect.c
@@ -154,8 +154,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         h += y;
         y = 0;
     }
-    w = FFMIN(w, in->width  - x);
-    h = FFMIN(h, in->height - y);
+    w = FFMINI(w, in->width  - x);
+    h = FFMINI(h, in->height - y);
 
     if (w > in->width || h > in->height || w <= 0 || h <= 0)
         return AVERROR(EINVAL);
diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 7c14cd117e1..882ed191294 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -221,7 +221,7 @@ static int config_input(AVFilterLink *inlink)
     s->x2 = 0;
     s->y2 = 0;
 
-    s->window_size = FFMAX(s->reset_count, 15);
+    s->window_size = FFMAXI(s->reset_count, 15);
     s->tmpbuf      = av_malloc(bufsize);
     s->filterbuf   = av_malloc(bufsize * s->max_pixsteps[0]);
     s->gradients   = av_calloc(bufsize, sizeof(*s->gradients));
@@ -296,9 +296,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 
         if (s->mode == MODE_BLACK) {
             FIND(s->y1,                 0,               y < s->y1, +1, frame->linesize[0], bpp, frame->width);
-            FIND(s->y2, frame->height - 1, y > FFMAX(s->y2, s->y1), -1, frame->linesize[0], bpp, frame->width);
+            FIND(s->y2, frame->height - 1, y > FFMAXI(s->y2, s->y1), -1, frame->linesize[0], bpp, frame->width);
             FIND(s->x1,                 0,               y < s->x1, +1, bpp, frame->linesize[0], frame->height);
-            FIND(s->x2,  frame->width - 1, y > FFMAX(s->x2, s->x1), -1, bpp, frame->linesize[0], frame->height);
+            FIND(s->x2,  frame->width - 1, y > FFMAXI(s->x2, s->x1), -1, bpp, frame->linesize[0], frame->height);
         } else { // MODE_MV_EDGES
             sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);
             s->x1 = 0;
@@ -384,7 +384,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
                 s->bboxes[3][bboff] = s->y2;
 
                 // sort queue
-                bboff = FFMIN(s->frame_nb, s->window_size);
+                bboff = FFMINI(s->frame_nb, s->window_size);
                 AV_QSORT(s->bboxes[0], bboff, int, comp);
                 AV_QSORT(s->bboxes[1], bboff, int, comp);
                 AV_QSORT(s->bboxes[2], bboff, int, comp);
diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index 6efeb875a66..df900ece2af 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -187,7 +187,7 @@ static int filter_color2(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
     const int PP = td->PP;
     const int xoff = td->xoff;
     const int yoff = td->yoff;
-    const int P = FFMAX(s->nb_planes, s->nb_comps);
+    const int P = FFMAXI(s->nb_planes, s->nb_comps);
     const int C = s->chars;
     const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
     const int W = (outlink->w - xoff) / (C * 10);
@@ -234,7 +234,7 @@ static int filter_color(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
     const int PP = td->PP;
     const int xoff = td->xoff;
     const int yoff = td->yoff;
-    const int P = FFMAX(s->nb_planes, s->nb_comps);
+    const int P = FFMAXI(s->nb_planes, s->nb_comps);
     const int C = s->chars;
     const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
     const int W = (outlink->w - xoff) / (C * 10);
@@ -277,7 +277,7 @@ static int filter_mono(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
     const int PP = td->PP;
     const int xoff = td->xoff;
     const int yoff = td->yoff;
-    const int P = FFMAX(s->nb_planes, s->nb_comps);
+    const int P = FFMAXI(s->nb_planes, s->nb_comps);
     const int C = s->chars;
     const int D = ((s->chars - s->dformat) >> 2) + s->dformat * 2;
     const int W = (outlink->w - xoff) / (C * 10);
@@ -313,7 +313,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     AVFilterContext *ctx  = inlink->dst;
     DatascopeContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    const int P = FFMAX(s->nb_planes, s->nb_comps);
+    const int P = FFMAXI(s->nb_planes, s->nb_comps);
     ThreadData td = { 0 };
     int ymaxlen = 0;
     int xmaxlen = 0;
@@ -334,7 +334,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         if (s->components & (1 << p))
             PP++;
     }
-    PP = FFMAX(PP, 1);
+    PP = FFMAXI(PP, 1);
 
     if (s->axis) {
         const int C = s->chars;
@@ -374,7 +374,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in; td.out = out, td.yoff = xmaxlen, td.xoff = ymaxlen, td.PP = PP;
     ff_filter_execute(ctx, s->filter, &td, NULL,
-                      FFMIN(ff_filter_get_nb_threads(ctx), FFMAX(outlink->w / 20, 1)));
+                      FFMINI(ff_filter_get_nb_threads(ctx), FFMAXI(outlink->w / 20, 1)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
@@ -569,8 +569,8 @@ static int pixscope_config_input(AVFilterLink *inlink)
     s->y = s->ypos * (inlink->h - 1);
     if (s->x + s->w >= inlink->w || s->y + s->h >= inlink->h) {
         av_log(inlink->dst, AV_LOG_WARNING, "scope position is out of range, clipping\n");
-        s->x = FFMIN(s->x, inlink->w - s->w);
-        s->y = FFMIN(s->y, inlink->h - s->h);
+        s->x = FFMINI(s->x, inlink->w - s->w);
+        s->y = FFMINI(s->y, inlink->h - s->h);
     }
 
     return 0;
@@ -646,8 +646,8 @@ static int pixscope_filter_frame(AVFilterLink *inlink, AVFrame *in)
                 s->values[i][x][y] = value[i];
                 rms[i]     += (double)value[i] * (double)value[i];
                 average[i] += value[i];
-                min[i]      = FFMIN(min[i], value[i]);
-                max[i]      = FFMAX(max[i], value[i]);
+                min[i]      = FFMINI(min[i], value[i]);
+                max[i]      = FFMAXI(max[i], value[i]);
             }
         }
     }
@@ -1098,8 +1098,8 @@ static int oscilloscope_filter_frame(AVFilterLink *inlink, AVFrame *frame)
     for (i = 0; i < s->nb_values; i++) {
         for (c = 0; c < s->nb_comps; c++) {
             if ((1 << c) & s->components) {
-                max[c] = FFMAX(max[c], s->values[i].p[s->rgba_map[c]]);
-                min[c] = FFMIN(min[c], s->values[i].p[s->rgba_map[c]]);
+                max[c] = FFMAXI(max[c], s->values[i].p[s->rgba_map[c]]);
+                min[c] = FFMINI(min[c], s->values[i].p[s->rgba_map[c]]);
                 average[c] += s->values[i].p[s->rgba_map[c]];
             }
         }
diff --git a/libavfilter/vf_deblock.c b/libavfilter/vf_deblock.c
index e3f4c80ae14..e6a0beb1e95 100644
--- a/libavfilter/vf_deblock.c
+++ b/libavfilter/vf_deblock.c
@@ -334,21 +334,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         for (x = block; x < width; x += block)
             s->deblockv(dst + x * s->bpc, out->linesize[plane],
-                        FFMIN(block, height), s->ath, s->bth, s->gth, s->dth, s->max);
+                        FFMINI(block, height), s->ath, s->bth, s->gth, s->dth, s->max);
 
         for (y = block; y < height - block; y += block) {
             dst += out->linesize[plane] * block;
 
             s->deblockh(dst, out->linesize[plane],
-                        FFMIN(block, width),
+                        FFMINI(block, width),
                         s->ath, s->bth, s->gth, s->dth, s->max);
 
             for (x = block; x < width; x += block) {
                 s->deblockh(dst + x * s->bpc, out->linesize[plane],
-                            FFMIN(block, width - x),
+                            FFMINI(block, width - x),
                             s->ath, s->bth, s->gth, s->dth, s->max);
                 s->deblockv(dst + x * s->bpc, out->linesize[plane],
-                            FFMIN(block, height - y),
+                            FFMINI(block, height - y),
                             s->ath, s->bth, s->gth, s->dth, s->max);
             }
         }
@@ -356,7 +356,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         dst += out->linesize[plane] * block;
         for (x = block; x < width; x += block)
             s->deblockv(dst + x * s->bpc, out->linesize[plane],
-                        FFMIN(block, height - y), s->ath, s->bth, s->gth, s->dth, s->max);
+                        FFMINI(block, height - y), s->ath, s->bth, s->gth, s->dth, s->max);
 
     }
 
diff --git a/libavfilter/vf_dedot.c b/libavfilter/vf_dedot.c
index 69b92141d15..425650d205b 100644
--- a/libavfilter/vf_dedot.c
+++ b/libavfilter/vf_dedot.c
@@ -290,17 +290,17 @@ static int activate(AVFilterContext *ctx)
                 if (ret >= 0) {
                     if (s->m & 1)
                         ff_filter_execute(ctx, s->dedotcrawl, out, NULL,
-                                          FFMIN(ff_filter_get_nb_threads(ctx),
+                                          FFMINI(ff_filter_get_nb_threads(ctx),
                                                 s->planeheight[0]));
                     if (s->m & 2) {
                         ThreadData td;
                         td.out = out; td.plane = 1;
                         ff_filter_execute(ctx, s->derainbow, &td, NULL,
-                                          FFMIN(ff_filter_get_nb_threads(ctx),
+                                          FFMINI(ff_filter_get_nb_threads(ctx),
                                                 s->planeheight[1]));
                         td.plane = 2;
                         ff_filter_execute(ctx, s->derainbow, &td, NULL,
-                                          FFMIN(ff_filter_get_nb_threads(ctx),
+                                          FFMINI(ff_filter_get_nb_threads(ctx),
                                                 s->planeheight[2]));
                     }
                 } else
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index bfbf8e6f4cb..9aacc943408 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -109,10 +109,10 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
     int xclipl, xclipr, yclipt, yclipb;
     int logo_x1, logo_x2, logo_y1, logo_y2;
 
-    xclipl = FFMAX(-logo_x, 0);
-    xclipr = FFMAX(logo_x+logo_w-w, 0);
-    yclipt = FFMAX(-logo_y, 0);
-    yclipb = FFMAX(logo_y+logo_h-h, 0);
+    xclipl = FFMAXI(-logo_x, 0);
+    xclipr = FFMAXI(logo_x+logo_w-w, 0);
+    yclipt = FFMAXI(-logo_y, 0);
+    yclipb = FFMAXI(logo_y+logo_h-h, 0);
 
     logo_x1 = logo_x + xclipl;
     logo_x2 = logo_x + logo_w - xclipr - 1;
@@ -175,14 +175,14 @@ static void apply_delogo(uint8_t *dst, int dst_linesize,
                 unsigned dist = 0;
 
                 if      (x < logo_x+band)
-                    dist = FFMAX(dist, logo_x-x+band);
+                    dist = FFMAXI(dist, logo_x-x+band);
                 else if (x >= logo_x+logo_w-band)
-                    dist = FFMAX(dist, x-(logo_x+logo_w-1-band));
+                    dist = FFMAXI(dist, x-(logo_x+logo_w-1-band));
 
                 if      (y < logo_y+band)
-                    dist = FFMAX(dist, logo_y-y+band);
+                    dist = FFMAXI(dist, logo_y-y+band);
                 else if (y >= logo_y+logo_h-band)
-                    dist = FFMAX(dist, y-(logo_y+logo_h-1-band));
+                    dist = FFMAXI(dist, y-(logo_y+logo_h-1-band));
 
                 *xdst = (*xsrc*dist + interp*(band-dist))/band;
             }
@@ -362,7 +362,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                       * into width and height to avoid error accumulation */
                      AV_CEIL_RSHIFT(s->w + (s->x & ((1<<hsub)-1)), hsub),
                      AV_CEIL_RSHIFT(s->h + (s->y & ((1<<vsub)-1)), vsub),
-                     s->band>>FFMIN(hsub, vsub),
+                     s->band>>FFMINI(hsub, vsub),
                      s->show, direct);
     }
 
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index afd0989e05e..63f2d872a21 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -490,8 +490,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
         uint8_t *src1 = (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0];
         uint8_t *src2 = in->data[0];
 
-        deshake->cx = FFMIN(deshake->cx, link->w);
-        deshake->cy = FFMIN(deshake->cy, link->h);
+        deshake->cx = FFMINI(deshake->cx, link->w);
+        deshake->cy = FFMINI(deshake->cy, link->h);
 
         if ((unsigned)deshake->cx + (unsigned)deshake->cw > link->w) deshake->cw = link->w - deshake->cx;
         if ((unsigned)deshake->cy + (unsigned)deshake->ch > link->h) deshake->ch = link->h - deshake->cy;
diff --git a/libavfilter/vf_deshake_opencl.c b/libavfilter/vf_deshake_opencl.c
index dc3df0e9893..66fa5588a60 100644
--- a/libavfilter/vf_deshake_opencl.c
+++ b/libavfilter/vf_deshake_opencl.c
@@ -500,7 +500,7 @@ static int ransac_update_num_iters(double confidence, double num_outliers, int m
     num_outliers = av_clipd(num_outliers, 0.0, 1.0);
 
     // avoid inf's & nan's
-    num = FFMAX(1.0 - confidence, DBL_MIN);
+    num = FFMAXD(1.0 - confidence, DBL_MIN);
     denom = 1.0 - pow(1.0 - num_outliers, 3);
     if (denom < DBL_MIN) {
         return 0;
@@ -528,7 +528,7 @@ static int estimate_affine_2d(
     double best_model[6], model[6];
     MotionVector pairs_subset[3], best_pairs[3];
 
-    int iter, niters = FFMAX(max_iters, 1);
+    int iter, niters = FFMAXI(max_iters, 1);
     int good_count, max_good_count = 0;
 
     // We need at least 3 points to build a model from
@@ -559,7 +559,7 @@ static int estimate_affine_2d(
         run_estimate_kernel(pairs_subset, model);
         good_count = find_inliers(point_pairs, num_point_pairs, model, deshake_ctx->ransac_err, threshold);
 
-        if (good_count > FFMAX(max_good_count, 2)) {
+        if (good_count > FFMAXI(max_good_count, 2)) {
             for (int mi = 0; mi < 6; ++mi) {
                 best_model[mi] = model[mi];
             }
diff --git a/libavfilter/vf_despill.c b/libavfilter/vf_despill.c
index 25bdd1acd7a..8c0abd846cd 100644
--- a/libavfilter/vf_despill.c
+++ b/libavfilter/vf_despill.c
@@ -65,14 +65,14 @@ static int do_despill_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_j
             blue  = dst[x * 4 + bo] / 255.f;
 
             if (s->type) {
-                spillmap = FFMAX(blue  - (red * spillmix + green * factor), 0.f);
+                spillmap = FFMAXF(blue  - (red * spillmix + green * factor), 0.f);
             } else {
-                spillmap = FFMAX(green - (red * spillmix + blue  * factor), 0.f);
+                spillmap = FFMAXF(green - (red * spillmix + blue  * factor), 0.f);
             }
 
-            red   = FFMAX(red   + spillmap * redscale   + brightness * spillmap, 0.f);
-            green = FFMAX(green + spillmap * greenscale + brightness * spillmap, 0.f);
-            blue  = FFMAX(blue  + spillmap * bluescale  + brightness * spillmap, 0.f);
+            red   = FFMAXF(red   + spillmap * redscale   + brightness * spillmap, 0.f);
+            green = FFMAXF(green + spillmap * greenscale + brightness * spillmap, 0.f);
+            blue  = FFMAXF(blue  + spillmap * bluescale  + brightness * spillmap, 0.f);
 
             dst[x * 4 + ro] = av_clip_uint8(red   * 255);
             dst[x * 4 + go] = av_clip_uint8(green * 255);
@@ -93,7 +93,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     int ret;
 
     if (ret = ff_filter_execute(ctx, do_despill_slice, frame, NULL,
-                                FFMIN(frame->height, ff_filter_get_nb_threads(ctx))))
+                                FFMINI(frame->height, ff_filter_get_nb_threads(ctx))))
         return ret;
 
     return ff_filter_frame(ctx->outputs[0], frame);
diff --git a/libavfilter/vf_detelecine.c b/libavfilter/vf_detelecine.c
index 65e4731418d..d004b59c677 100644
--- a/libavfilter/vf_detelecine.c
+++ b/libavfilter/vf_detelecine.c
@@ -89,7 +89,7 @@ static av_cold int init(AVFilterContext *ctx)
         }
 
         sum += *p - '0';
-        max = FFMAX(*p - '0', max);
+        max = FFMAXI(*p - '0', max);
         s->pts.num += *p - '0';
         s->pts.den += 2;
     }
diff --git a/libavfilter/vf_displace.c b/libavfilter/vf_displace.c
index 055488e6c99..5d7caed33b7 100644
--- a/libavfilter/vf_displace.c
+++ b/libavfilter/vf_displace.c
@@ -278,7 +278,7 @@ static int process_frame(FFFrameSync *fs)
         td.yin = yin;
         td.out = out;
         ff_filter_execute(ctx, s->displace_slice, &td, NULL,
-                          FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index bc9a1777ff0..e7f92952930 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -111,8 +111,8 @@ static int dnn_detect_get_label_id(int nb_classes, int cell_size, float *label_d
 /* Calculate Intersection Over Union */
 static float dnn_detect_IOU(AVDetectionBBox *bbox1, AVDetectionBBox *bbox2)
 {
-    float overlapping_width = FFMIN(bbox1->x + bbox1->w, bbox2->x + bbox2->w) - FFMAX(bbox1->x, bbox2->x);
-    float overlapping_height = FFMIN(bbox1->y + bbox1->h, bbox2->y + bbox2->h) - FFMAX(bbox1->y, bbox2->y);
+    float overlapping_width = FFMINI(bbox1->x + bbox1->w, bbox2->x + bbox2->w) - FFMAXI(bbox1->x, bbox2->x);
+    float overlapping_height = FFMINI(bbox1->y + bbox1->h, bbox2->y + bbox2->h) - FFMAXI(bbox1->y, bbox2->y);
     float intersection_area =
         (overlapping_width < 0 || overlapping_height < 0) ? 0 : overlapping_height * overlapping_width;
     float union_area = bbox1->w * bbox1->h + bbox2->w * bbox2->h - intersection_area;
diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index 18a0ead167b..2a3cbdb59ee 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -397,8 +397,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
             s->w = bbox->w;
         }
 
-        s->draw_region(frame, s, FFMAX(s->x, 0), FFMAX(s->y, 0), FFMIN(s->x + s->w, frame->width),
-                       FFMIN(s->y + s->h, frame->height), pixel_belongs_to_box);
+        s->draw_region(frame, s, FFMAXI(s->x, 0), FFMAXI(s->y, 0), FFMINI(s->x + s->w, frame->width),
+                       FFMINI(s->y + s->h, frame->height), pixel_belongs_to_box);
     }
 
     return ff_filter_frame(inlink->dst->outputs[0], frame);
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 029076bf970..3bd91b49385 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1300,8 +1300,8 @@ static int draw_glyphs(DrawTextContext *s, AVFrame *frame,
         av_log(s, AV_LOG_WARNING, "Tab characters are only supported with left horizontal alignment\n");
     }
 
-    clip_x = FFMIN(metrics->rect_x + s->box_width + s->bb_right, frame->width);
-    clip_y = FFMIN(metrics->rect_y + s->box_height + s->bb_bottom, frame->height);
+    clip_x = FFMINI(metrics->rect_x + s->box_width + s->bb_right, frame->width);
+    clip_y = FFMINI(metrics->rect_y + s->box_height + s->bb_bottom, frame->height);
 
     for (l = 0; l < s->line_count; ++l) {
         TextLine *line = &s->lines[l];
@@ -1346,8 +1346,8 @@ static int draw_glyphs(DrawTextContext *s, AVFrame *frame,
             }
 
             pdx = dx + dy * bitmap.pitch;
-            w1 = FFMIN(clip_x - x1, w1 - dx);
-            h1 = FFMIN(clip_y - y1, h1 - dy);
+            w1 = FFMINI(clip_x - x1, w1 - dx);
+            h1 = FFMINI(clip_y - y1, h1 - dy);
 
             ff_blend_mask(&s->dc, color, frame->data, frame->linesize, clip_x, clip_y,
                 bitmap.buffer + pdx, bitmap.pitch, w1, h1, 3, 0, x1, y1);
@@ -1475,11 +1475,11 @@ continue_on_failed2:
                     goto done;
                 }
                 if (line_count == 0) {
-                    first_max_y64 = FFMAX(glyph->bbox.yMax, first_max_y64);
+                    first_max_y64 = FFMAXI(glyph->bbox.yMax, first_max_y64);
                 }
                 if (t == 0) {
                     cur_line->offset_left64 = glyph->bbox.xMin;
-                    first_min_x64 = FFMIN(glyph->bbox.xMin, first_min_x64);
+                    first_min_x64 = FFMINI(glyph->bbox.xMin, first_min_x64);
                 }
                 if (t == hb->glyph_count - 1) {
                     // The following code measures the width of the line up to the last
@@ -1491,7 +1491,7 @@ continue_on_failed2:
                     // int last_char_width = glyph->bbox.xMax;
 
                     w64 += last_char_width;
-                    last_max_x64 = FFMAX(last_char_width, last_max_x64);
+                    last_max_x64 = FFMAXI(last_char_width, last_max_x64);
                     cur_line->offset_right64 = last_char_width;
                 } else {
                     if (is_tab) {
@@ -1501,11 +1501,11 @@ continue_on_failed2:
                         w64 += hb->glyph_pos[t].x_advance;
                     }
                 }
-                cur_min_y64 = FFMIN(glyph->bbox.yMin, cur_min_y64);
-                min_y64 = FFMIN(glyph->bbox.yMin, min_y64);
-                max_y64 = FFMAX(glyph->bbox.yMax, max_y64);
-                min_x64 = FFMIN(glyph->bbox.xMin, min_x64);
-                max_x64 = FFMAX(glyph->bbox.xMax, max_x64);
+                cur_min_y64 = FFMINI(glyph->bbox.yMin, cur_min_y64);
+                min_y64 = FFMINI(glyph->bbox.yMin, min_y64);
+                max_y64 = FFMAXI(glyph->bbox.yMax, max_y64);
+                min_x64 = FFMINI(glyph->bbox.xMin, min_x64);
+                max_x64 = FFMAXI(glyph->bbox.xMax, max_x64);
             }
 
             cur_line->width64 = w64;
@@ -1533,7 +1533,7 @@ continue_on_failed2:
         metrics->height = POS_CEIL(metrics->line_height64 * line_count, 64);
     } else {
         int height64 = (metrics->line_height64 + s->line_spacing * 64) *
-            (FFMAX(0, line_count - 1)) + first_max_y64 - cur_min_y64;
+            (FFMAXI(0, line_count - 1)) + first_max_y64 - cur_min_y64;
         metrics->height = POS_CEIL(height64, 64);
     }
     metrics->offset_top64 = first_max_y64;
@@ -1686,24 +1686,24 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame)
 
     if (s->fix_bounds) {
         /* calculate footprint of text effects */
-        int borderoffset  = s->borderw  ? FFMAX(s->borderw, 0) : 0;
+        int borderoffset  = s->borderw  ? FFMAXI(s->borderw, 0) : 0;
 
-        int offsetleft = FFMAX3(FFMAX(s->bb_left, 0), borderoffset,
+        int offsetleft = FFMAX3(FFMAXI(s->bb_left, 0), borderoffset,
                                 (s->shadowx < 0 ? FFABS(s->shadowx) : 0));
-        int offsettop = FFMAX3(FFMAX(s->bb_top, 0), borderoffset,
+        int offsettop = FFMAX3(FFMAXI(s->bb_top, 0), borderoffset,
                                 (s->shadowy < 0 ? FFABS(s->shadowy) : 0));
-        int offsetright = FFMAX3(FFMAX(s->bb_right, 0), borderoffset,
+        int offsetright = FFMAX3(FFMAXI(s->bb_right, 0), borderoffset,
                                  (s->shadowx > 0 ? s->shadowx : 0));
-        int offsetbottom = FFMAX3(FFMAX(s->bb_bottom, 0), borderoffset,
+        int offsetbottom = FFMAX3(FFMAXI(s->bb_bottom, 0), borderoffset,
                                   (s->shadowy > 0 ? s->shadowy : 0));
 
         if (s->x - offsetleft < 0) s->x = offsetleft;
         if (s->y - offsettop < 0)  s->y = offsettop;
 
         if (s->x + metrics.width + offsetright > width)
-            s->x = FFMAX(width - metrics.width - offsetright, 0);
+            s->x = FFMAXI(width - metrics.width - offsetright, 0);
         if (s->y + metrics.height + offsetbottom > height)
-            s->y = FFMAX(height - metrics.height - offsetbottom, 0);
+            s->y = FFMAXI(height - metrics.height - offsetbottom, 0);
     }
 
     x = 0;
@@ -1771,7 +1771,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame)
     if (!s->draw_box) {
         // Create a border for the clipping region to take into account subpixel
         // errors in text measurement and effects.
-        int borderoffset = s->borderw ? FFMAX(s->borderw, 0) : 0;
+        int borderoffset = s->borderw ? FFMAXI(s->borderw, 0) : 0;
         s->bb_left = borderoffset + (s->shadowx < 0 ? FFABS(s->shadowx) : 0) + 1;
         s->bb_top = borderoffset + (s->shadowy < 0 ? FFABS(s->shadowy) : 0) + 1;
         s->bb_right = borderoffset + (s->shadowx > 0 ? s->shadowx : 0) + 1;
diff --git a/libavfilter/vf_epx.c b/libavfilter/vf_epx.c
index af40917b661..31d06daa433 100644
--- a/libavfilter/vf_epx.c
+++ b/libavfilter/vf_epx.c
@@ -60,9 +60,9 @@ static int epx2_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
         uint32_t *dst = (uint32_t *)out->data[p];
         const uint32_t *src_line[3];
 
-        src_line[0] = src + src_linesize * FFMAX(slice_start - 1, 0);
+        src_line[0] = src + src_linesize * FFMAXI(slice_start - 1, 0);
         src_line[1] = src + src_linesize * slice_start;
-        src_line[2] = src + src_linesize * FFMIN(slice_start + 1, height-1);
+        src_line[2] = src + src_linesize * FFMINI(slice_start + 1, height-1);
 
         for (int y = slice_start; y < slice_end; y++) {
             uint32_t *dst_line[2];
@@ -75,9 +75,9 @@ static int epx2_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
                 uint32_t B, D, E, F, H;
 
                 B = src_line[0][x];
-                D = src_line[1][FFMAX(x-1, 0)];
+                D = src_line[1][FFMAXI(x-1, 0)];
                 E = src_line[1][x];
-                F = src_line[1][FFMIN(x+1, width - 1)];
+                F = src_line[1][FFMINI(x+1, width - 1)];
                 H = src_line[2][x];
 
                 if (B != H && D != F) {
@@ -127,9 +127,9 @@ static int epx3_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
         uint32_t *dst = (uint32_t *)out->data[p];
         const uint32_t *src_line[3];
 
-        src_line[0] = src + src_linesize * FFMAX(slice_start - 1, 0);
+        src_line[0] = src + src_linesize * FFMAXI(slice_start - 1, 0);
         src_line[1] = src + src_linesize * slice_start;
-        src_line[2] = src + src_linesize * FFMIN(slice_start + 1, height-1);
+        src_line[2] = src + src_linesize * FFMINI(slice_start + 1, height-1);
 
         for (int y = slice_start; y < slice_end; y++) {
             uint32_t *dst_line[3];
@@ -142,15 +142,15 @@ static int epx3_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
                 uint32_t E0, E1, E2, E3, E4, E5, E6, E7, E8;
                 uint32_t A, B, C, D, E, F, G, H, I;
 
-                A = src_line[0][FFMAX(x-1, 0)];
+                A = src_line[0][FFMAXI(x-1, 0)];
                 B = src_line[0][x];
-                C = src_line[0][FFMIN(x+1, width - 1)];
-                D = src_line[1][FFMAX(x-1, 0)];
+                C = src_line[0][FFMINI(x+1, width - 1)];
+                D = src_line[1][FFMAXI(x-1, 0)];
                 E = src_line[1][x];
-                F = src_line[1][FFMIN(x+1, width - 1)];
-                G = src_line[2][FFMAX(x-1, 0)];
+                F = src_line[1][FFMINI(x+1, width - 1)];
+                G = src_line[2][FFMAXI(x-1, 0)];
                 H = src_line[2][x];
-                I = src_line[2][FFMIN(x+1, width - 1)];
+                I = src_line[2][FFMINI(x+1, width - 1)];
 
                 if (B != H && D != F) {
                     E0 = D == B ? D : E;
@@ -245,7 +245,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in, td.out = out;
     ff_filter_execute(ctx, s->epx_slice, &td, NULL,
-                      FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->h, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c
index b8289a6e961..7027b468267 100644
--- a/libavfilter/vf_estdif.c
+++ b/libavfilter/vf_estdif.c
@@ -446,7 +446,7 @@ static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts, int64_t durati
 
     td.out = out; td.in = in;
     ff_filter_execute(ctx, deinterlace_slice, &td, NULL,
-                      FFMIN(s->planeheight[1] / 2, s->nb_threads));
+                      FFMINI(s->planeheight[1] / 2, s->nb_threads));
 
     if (s->mode)
         s->field = !s->field;
diff --git a/libavfilter/vf_exposure.c b/libavfilter/vf_exposure.c
index 833aa953d53..fada6d71c12 100644
--- a/libavfilter/vf_exposure.c
+++ b/libavfilter/vf_exposure.c
@@ -105,7 +105,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = in;
     ff_filter_execute(ctx, s->do_slice, &td, NULL,
-                      FFMIN(out->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(out->height, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index 69198ea1d12..424ed047bd8 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -310,7 +310,7 @@ static int filter_slice_chroma(AVFilterContext *ctx, void *arg, int jobnr,
     const int width = AV_CEIL_RSHIFT(frame->width, s->hsub);
     const int height= AV_CEIL_RSHIFT(frame->height, s->vsub);
     int slice_start = (height *  jobnr   ) / nb_jobs;
-    int slice_end   = FFMIN(((height * (jobnr+1)) / nb_jobs), frame->height);
+    int slice_end   = FFMINI(((height * (jobnr+1)) / nb_jobs), frame->height);
 
     for (plane = 1; plane < 3; plane++) {
         for (i = slice_start; i < slice_end; i++) {
@@ -339,7 +339,7 @@ static int filter_slice_chroma16(AVFilterContext *ctx, void *arg, int jobnr,
     const int mid = 1 << (s->depth - 1);
     const int add = ((mid << 1) + 1) << 15;
     int slice_start = (height *  jobnr   ) / nb_jobs;
-    int slice_end   = FFMIN(((height * (jobnr+1)) / nb_jobs), frame->height);
+    int slice_end   = FFMINI(((height * (jobnr+1)) / nb_jobs), frame->height);
 
     for (plane = 1; plane < 3; plane++) {
         for (i = slice_start; i < slice_end; i++) {
@@ -497,19 +497,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     if (s->factor < UINT16_MAX) {
         if (s->alpha) {
             ff_filter_execute(ctx, s->filter_slice_alpha, frame, NULL,
-                              FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
+                              FFMINI(frame->height, ff_filter_get_nb_threads(ctx)));
         } else if (s->is_rgb && !s->black_fade) {
             ff_filter_execute(ctx, filter_slice_rgb, frame, NULL,
-                              FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
+                              FFMINI(frame->height, ff_filter_get_nb_threads(ctx)));
         } else {
             /* luma, or rgb plane in case of black */
             ff_filter_execute(ctx, s->filter_slice_luma, frame, NULL,
-                              FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
+                              FFMINI(frame->height, ff_filter_get_nb_threads(ctx)));
 
             if (frame->data[1] && frame->data[2] && !s->is_rgb) {
                 /* chroma planes */
                 ff_filter_execute(ctx, s->filter_slice_chroma, frame, NULL,
-                                  FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
+                                  FFMINI(frame->height, ff_filter_get_nb_threads(ctx)));
             }
         }
     }
diff --git a/libavfilter/vf_fftdnoiz.c b/libavfilter/vf_fftdnoiz.c
index 13afbf03778..69cadc16692 100644
--- a/libavfilter/vf_fftdnoiz.c
+++ b/libavfilter/vf_fftdnoiz.c
@@ -207,7 +207,7 @@ static int config_input(AVFilterLink *inlink)
     s->planes[0].planeheight = s->planes[3].planeheight = inlink->h;
 
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-    s->nb_threads = FFMIN(ff_filter_get_nb_threads(ctx), MAX_THREADS);
+    s->nb_threads = FFMINI(ff_filter_get_nb_threads(ctx), MAX_THREADS);
 
     for (int i = 0; i < s->nb_threads; i++) {
         float scale = 1.f, iscale = 1.f;
@@ -293,8 +293,8 @@ static void import_block(FFTdnoizContext *s,
     AVComplexFloat *vdata_out = p->vdata_out[jobnr];
     const int woff = -hoverlap;
     const int hoff = -hoverlap;
-    const int rh = FFMIN(block, height - y * size + hoverlap);
-    const int rw = FFMIN(block, width  - x * size + hoverlap);
+    const int rh = FFMINI(block, height - y * size + hoverlap);
+    const int rw = FFMINI(block, width  - x * size + hoverlap);
     AVComplexFloat *ssrc, *ddst, *dst = hdata, *dst_out = hdata_out;
     float *bdst = buffer;
 
@@ -355,8 +355,8 @@ static void export_block(FFTdnoizContext *s,
     AVComplexFloat *hdata = p->hdata[jobnr];
     AVComplexFloat *hdata_out = p->hdata_out[jobnr];
     AVComplexFloat *vdata_out = p->vdata_out[jobnr];
-    const int rw = FFMIN(size, width  - x * size);
-    const int rh = FFMIN(size, height - y * size);
+    const int rw = FFMINI(size, width  - x * size);
+    const int rh = FFMINI(size, height - y * size);
     AVComplexFloat *hdst, *vdst = vdata_out, *hdst_out = hdata_out;
     float *bsrc = buffer;
 
@@ -646,7 +646,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     ff_filter_execute(ctx, denoise, out, NULL,
-                      FFMIN(s->planes[0].noy, s->nb_threads));
+                      FFMINI(s->planes[0].noy, s->nb_threads));
 
     for (plane = 0; plane < s->nb_planes; plane++) {
         PlaneContext *p = &s->planes[plane];
diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c
index b94008fc15b..7353018c2a4 100644
--- a/libavfilter/vf_fftfilt.c
+++ b/libavfilter/vf_fftfilt.c
@@ -318,7 +318,7 @@ static int config_props(AVFilterLink *inlink)
     s->planeheight[0] = s->planeheight[3] = inlink->h;
 
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-    s->nb_threads = FFMIN(32, ff_filter_get_nb_threads(inlink->dst));
+    s->nb_threads = FFMINI(32, ff_filter_get_nb_threads(inlink->dst));
 
     for (i = 0; i < desc->nb_components; i++) {
         int w = s->planewidth[i];
@@ -512,13 +512,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     av_frame_copy_props(out, in);
 
     ff_filter_execute(ctx, s->rdft_horizontal, in, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     ff_filter_execute(ctx, copy_vertical, NULL, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     ff_filter_execute(ctx, rdft_vertical, NULL, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     for (int plane = 0; plane < s->nb_planes; plane++) {
         if (s->eval_mode == EVAL_MODE_FRAME)
@@ -526,19 +526,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     ff_filter_execute(ctx, multiply_data, NULL, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     for (int plane = 0; plane < s->nb_planes; plane++)
         s->rdft_vdata_out[plane][0] += s->rdft_hlen[plane] * s->rdft_vlen[plane] * s->dc[plane] * (1 << (s->depth - 8));
 
     ff_filter_execute(ctx, irdft_vertical, NULL, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     ff_filter_execute(ctx, copy_horizontal, NULL, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     ff_filter_execute(ctx, s->irdft_horizontal, out, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index 6f4403a48da..9dd55b90344 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -157,8 +157,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             }
             switch (s->mode) {
             case ABSOLUTE_HINT:
-                if (tf > outl->frame_count_in + 1 || tf < FFMAX(0, outl->frame_count_in - 1) ||
-                    bf > outl->frame_count_in + 1 || bf < FFMAX(0, outl->frame_count_in - 1)) {
+                if (tf > outl->frame_count_in + 1 || tf < FFMAXI(0, outl->frame_count_in - 1) ||
+                    bf > outl->frame_count_in + 1 || bf < FFMAXI(0, outl->frame_count_in - 1)) {
                     av_log(ctx, AV_LOG_ERROR, "Out of range frames %"PRId64" and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, inl->frame_count_out);
                     return AVERROR_INVALIDDATA;
                 }
diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index 037be36fc5a..fd0f6596299 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -152,10 +152,10 @@ static float search(FOCContext *foc, int pass, int maxpass, int xmin, int xmax,
     if (pass + 1 <= maxpass) {
         int sub_x, sub_y;
         search(foc, pass+1, maxpass, xmin>>1, (xmax+1)>>1, ymin>>1, (ymax+1)>>1, &sub_x, &sub_y, 2.0);
-        xmin = FFMAX(xmin, 2*sub_x - 4);
-        xmax = FFMIN(xmax, 2*sub_x + 4);
-        ymin = FFMAX(ymin, 2*sub_y - 4);
-        ymax = FFMIN(ymax, 2*sub_y + 4);
+        xmin = FFMAXI(xmin, 2*sub_x - 4);
+        xmax = FFMINI(xmax, 2*sub_x + 4);
+        ymin = FFMAXI(ymin, 2*sub_y - 4);
+        ymax = FFMINI(ymax, 2*sub_y + 4);
     }
 
     for (y = ymin; y <= ymax; y++) {
@@ -187,10 +187,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     best_score = search(foc, 0, 0,
-                        FFMAX(foc->xmin, foc->last_x - 8),
-                        FFMIN(foc->xmax, foc->last_x + 8),
-                        FFMAX(foc->ymin, foc->last_y - 8),
-                        FFMIN(foc->ymax, foc->last_y + 8),
+                        FFMAXI(foc->xmin, foc->last_x - 8),
+                        FFMINI(foc->xmax, foc->last_x + 8),
+                        FFMAXI(foc->ymin, foc->last_y - 8),
+                        FFMINI(foc->ymax, foc->last_y + 8),
                         &best_x, &best_y, 2.0);
 
     best_score = search(foc, 0, foc->mipmaps - 1, foc->xmin, foc->xmax, foc->ymin, foc->ymax,
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 9976db8d935..065cf539324 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -77,7 +77,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next
         s->sad(crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height, &sad);
         mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << s->bitdepth);
         diff = fabs(mafd - s->prev_mafd);
-        ret  = av_clipf(FFMIN(mafd, diff), 0, 100.0);
+        ret  = av_clipf(FFMIND(mafd, diff), 0, 100.0);
         s->prev_mafd = mafd;
     }
     ff_dlog(ctx, "get_scene_score() result is:%f\n", ret);
@@ -145,7 +145,7 @@ static int blend_frames(AVFilterContext *ctx, int interpolate)
 
         ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN(FFMAX(1, outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
+                          FFMINI(FFMAXI(1, outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
         return 1;
     }
     return 0;
diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index 0b37562663c..6bf9ab75cba 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -130,11 +130,11 @@ static void gaussianiir2d(AVFilterContext *ctx, int plane)
     td.width = width;
     td.height = height;
     ff_filter_execute(ctx, filter_horizontally, &td,
-                      NULL, FFMIN(height, nb_threads));
+                      NULL, FFMINI(height, nb_threads));
     ff_filter_execute(ctx, filter_vertically, &td,
-                      NULL, FFMIN(width, nb_threads));
+                      NULL, FFMINI(width, nb_threads));
     ff_filter_execute(ctx, filter_postscale, &td,
-                      NULL, FFMIN(width * height, nb_threads));
+                      NULL, FFMINI(width * height, nb_threads));
 }
 
 static const enum AVPixelFormat pix_fmts[] = {
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index 088b3c91432..3d2f4feb43b 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -62,7 +62,7 @@ void ff_gradfun_filter_line_c(uint8_t *dst, const uint8_t *src, const uint16_t *
         int pix = src[x] << 7;
         int delta = dc[0] - pix;
         int m = abs(delta) * thresh >> 16;
-        m = FFMAX(0, 127 - m);
+        m = FFMAXI(0, 127 - m);
         m = m * m * delta >> 14;
         pix += m + dithers[x & 7];
         dst[x] = av_clip_uint8(pix >> 7);
@@ -205,7 +205,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             r = s->chroma_r;
         }
 
-        if (FFMIN(w, h) > 2 * r)
+        if (FFMINI(w, h) > 2 * r)
             filter(s, out->data[p], in->data[p], w, h, out->linesize[p], in->linesize[p], r);
         else if (out->data[p] != in->data[p])
             av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p], w, h);
diff --git a/libavfilter/vf_grayworld.c b/libavfilter/vf_grayworld.c
index 21d6aafd9ad..fe7ea5a806d 100644
--- a/libavfilter/vf_grayworld.c
+++ b/libavfilter/vf_grayworld.c
@@ -275,9 +275,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in;
     td.out = out;
 
-    ff_filter_execute(ctx, convert_frame, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+    ff_filter_execute(ctx, convert_frame, &td, NULL, FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
     compute_correction(s, &td);
-    ff_filter_execute(ctx, correct_frame, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+    ff_filter_execute(ctx, correct_frame, &td, NULL, FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (in != out) {
         av_image_copy_plane(out->data[3], out->linesize[3],
diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c
index 4749beab488..aaa1650e501 100644
--- a/libavfilter/vf_guided.c
+++ b/libavfilter/vf_guided.c
@@ -239,16 +239,16 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s,
     t.dstStride = w;                                                                    \
     t.src = I;                                                                          \
     t.dst = meanI;                                                                      \
-    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads));               \
+    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMINI(h, nb_threads));               \
     t.src = II;                                                                         \
     t.dst = meanII;                                                                     \
-    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads));               \
+    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMINI(h, nb_threads));               \
     t.src = P;                                                                          \
     t.dst = meanP;                                                                      \
-    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads));               \
+    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMINI(h, nb_threads));               \
     t.src = IP;                                                                         \
     t.dst = meanIP;                                                                     \
-    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads));               \
+    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMINI(h, nb_threads));               \
                                                                                         \
     for (int i = 0;i < h;i++) {                                                         \
         for (int j = 0;j < w;j++) {                                                     \
@@ -262,10 +262,10 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s,
                                                                                         \
     t.src = A;                                                                          \
     t.dst = meanA;                                                                      \
-    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads));               \
+    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMINI(h, nb_threads));               \
     t.src = B;                                                                          \
     t.dst = meanB;                                                                      \
-    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads));               \
+    ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMINI(h, nb_threads));               \
                                                                                         \
     for (int i = 0;i < height;i++) {                                                    \
         for (int j = 0;j < width;j++) {                                                 \
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index 8f8dd142403..4353a63345d 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -131,7 +131,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in, td.out = out;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index f77148cdfef..956a89ea1df 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -385,11 +385,11 @@ static int config_output(AVFilterLink *outlink)
     if (s->thistogram) {
         if (!s->width)
             s->width = ctx->inputs[0]->w;
-        outlink->w = s->width * FFMAX(ncomp * (s->display_mode == 1), 1);
-        outlink->h = s->histogram_size * FFMAX(ncomp * (s->display_mode == 2), 1);
+        outlink->w = s->width * FFMAXI(ncomp * (s->display_mode == 1), 1);
+        outlink->h = s->histogram_size * FFMAXI(ncomp * (s->display_mode == 2), 1);
     } else {
-        outlink->w = s->histogram_size * FFMAX(ncomp * (s->display_mode == 1), 1);
-        outlink->h = (s->level_height + s->scale_height) * FFMAX(ncomp * (s->display_mode == 2), 1);
+        outlink->w = s->histogram_size * FFMAXI(ncomp * (s->display_mode == 1), 1);
+        outlink->h = (s->level_height + s->scale_height) * FFMAXI(ncomp * (s->display_mode == 2), 1);
     }
 
     s->odesc = av_pix_fmt_desc_get(outlink->format);
@@ -472,7 +472,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         }
 
         for (i = 0; i < s->histogram_size; i++)
-            max_hval = FFMAX(max_hval, s->histogram[i]);
+            max_hval = FFMAXI(max_hval, s->histogram[i]);
         max_hval_log = log2(max_hval + 1);
 
         if (s->thistogram) {
@@ -500,8 +500,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                 int value = s->start[p];
 
                 if (s->envelope && s->histogram[idx]) {
-                    minh = FFMIN(minh, i);
-                    maxh = FFMAX(maxh, i);
+                    minh = FFMINI(minh, i);
+                    maxh = FFMAXI(maxh, i);
                 }
 
                 if (s->levels_mode)
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index 1136931b9be..40786439844 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -178,11 +178,11 @@ static void precalc_coefs(double dist25, int depth, int16_t *ct)
     int i;
     double gamma, simil, C;
 
-    gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);
+    gamma = log(0.25) / log(1.0 - FFMIND(dist25,252.0)/255.0 - 0.00001);
 
     for (i = -(256<<LUT_BITS); i < 256<<LUT_BITS; i++) {
         double f = (i * (1 << (9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0; // midpoint of the bin
-        simil = FFMAX(0, 1.0 - fabs(f) / 255.0);
+        simil = FFMAXD(0, 1.0 - fabs(f) / 255.0);
         C = pow(simil, gamma) * 256.0 * f;
         ct[(256<<LUT_BITS)+i] = lrint(C);
     }
diff --git a/libavfilter/vf_hsvkey.c b/libavfilter/vf_hsvkey.c
index 9a1a897a942..42e62952f54 100644
--- a/libavfilter/vf_hsvkey.c
+++ b/libavfilter/vf_hsvkey.c
@@ -216,7 +216,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
 
     s->hue = FFSIGN(s->hue_opt) *M_PI * fmodf(526.f - fabsf(s->hue_opt), 360.f) / 180.f;
     if (res = ff_filter_execute(avctx, s->do_slice, frame, NULL,
-                                FFMIN(frame->height, ff_filter_get_nb_threads(avctx))))
+                                FFMINI(frame->height, ff_filter_get_nb_threads(avctx))))
         return res;
 
     return ff_filter_frame(avctx->outputs[0], frame);
diff --git a/libavfilter/vf_huesaturation.c b/libavfilter/vf_huesaturation.c
index 7e1b4d1e9d5..6c3619187b0 100644
--- a/libavfilter/vf_huesaturation.c
+++ b/libavfilter/vf_huesaturation.c
@@ -137,18 +137,18 @@ static int do_slice_##name##_##xall(AVFilterContext *ctx,            \
                     int f = 0;                                       \
                                                                      \
                     if (colors & RED)                                \
-                        f = FFMAX(f, ir - FFMAX(ig, ib));            \
+                        f = FFMAXI(f, ir - FFMAXI(ig, ib));            \
                     if (colors & YELLOW)                             \
-                        f = FFMAX(f, FFMIN(ir, ig) - ib);            \
+                        f = FFMAXI(f, FFMINI(ir, ig) - ib);            \
                     if (colors & GREEN)                              \
-                        f = FFMAX(f, ig - FFMAX(ir, ib));            \
+                        f = FFMAXI(f, ig - FFMAXI(ir, ib));            \
                     if (colors & CYAN)                               \
-                        f = FFMAX(f, FFMIN(ig, ib) - ir);            \
+                        f = FFMAXI(f, FFMINI(ig, ib) - ir);            \
                     if (colors & BLUE)                               \
-                        f = FFMAX(f, ib - FFMAX(ir, ig));            \
+                        f = FFMAXI(f, ib - FFMAXI(ir, ig));            \
                     if (colors & MAGENTA)                            \
-                        f = FFMAX(f, FFMIN(ir, ib) - ig);            \
-                    f = FFMIN(f * strength, imax);                   \
+                        f = FFMAXI(f, FFMINI(ir, ib) - ig);            \
+                    f = FFMINF(f * strength, imax);                   \
                     get_triplet(s->imatrix, &ir, &ig, &ib);          \
                     ir = lerpi##name(ro, ir, f, imax);               \
                     ig = lerpi##name(go, ig, f, imax);               \
@@ -385,7 +385,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     init_matrix(s);
 
     ff_filter_execute(ctx, s->do_slice[(s->strength >= 99.f) && (s->colors == ALL)], frame, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     return ff_filter_frame(ctx->outputs[0], frame);
 }
diff --git a/libavfilter/vf_identity.c b/libavfilter/vf_identity.c
index fc44bfaea0c..397fbdbbecc 100644
--- a/libavfilter/vf_identity.c
+++ b/libavfilter/vf_identity.c
@@ -198,7 +198,7 @@ static int do_identity(FFFrameSync *fs)
     }
 
     ff_filter_execute(ctx, s->filter_slice, &td, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     for (int j = 0; j < s->nb_threads; j++) {
         for (int c = 0; c < s->nb_components; c++)
@@ -215,8 +215,8 @@ static int do_identity(FFFrameSync *fs)
         score += comp_score[c];
     score /= s->nb_components;
 
-    s->min_score = FFMIN(s->min_score, score);
-    s->max_score = FFMAX(s->max_score, score);
+    s->min_score = FFMIND(s->min_score, score);
+    s->max_score = FFMAXD(s->max_score, score);
 
     s->score += score;
 
diff --git a/libavfilter/vf_lagfun.c b/libavfilter/vf_lagfun.c
index 9ec936212c0..1b5ef26ede1 100644
--- a/libavfilter/vf_lagfun.c
+++ b/libavfilter/vf_lagfun.c
@@ -177,7 +177,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = in;
     ff_filter_execute(ctx, s->lagfun[!!ctx->is_disabled], &td, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_lcevc.c b/libavfilter/vf_lcevc.c
index 8ac2b212c31..120e5c90375 100644
--- a/libavfilter/vf_lcevc.c
+++ b/libavfilter/vf_lcevc.c
@@ -272,8 +272,8 @@ static int config_props(AVFilterLink *outlink)
     AVFilterLink *inlink = ctx->inputs[0];
     LCEVCContext *lcevc = ctx->priv;
 
-    outlink->w = lcevc->w = inlink->w * 2 / FFMAX(inlink->sample_aspect_ratio.den, 1);
-    outlink->h = lcevc->h = inlink->h * 2 / FFMAX(inlink->sample_aspect_ratio.den, 1);
+    outlink->w = lcevc->w = inlink->w * 2 / FFMAXI(inlink->sample_aspect_ratio.den, 1);
+    outlink->h = lcevc->h = inlink->h * 2 / FFMAXI(inlink->sample_aspect_ratio.den, 1);
     outlink->sample_aspect_ratio = (AVRational) { 0, 1 };
 
     return 0;
diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c
index 15c2e99e4b4..16de0caa20f 100644
--- a/libavfilter/vf_lenscorrection.c
+++ b/libavfilter/vf_lenscorrection.c
@@ -147,8 +147,8 @@ static int filter##name##_slice_bilinear(AVFilterContext *ctx, void *arg,      \
             const char isvalid = x >= 0 && x <= w - 1 && y >= 0 && y <= h - 1; \
                                                                                \
             if (isvalid) {                                                     \
-                const int nx = FFMIN(x + 1, w - 1);                            \
-                const int ny = FFMIN(y + 1, h - 1);                            \
+                const int nx = FFMINI(x + 1, w - 1);                            \
+                const int ny = FFMINI(y + 1, h - 1);                            \
                 const uint64_t du = off_x >= 0 ? (radius_mult * off_x + add) & max : max - ((radius_mult * -off_x + add) & max); \
                 const uint64_t dv = off_y >= 0 ? (radius_mult * off_y + add) & max : max - ((radius_mult * -off_y + add) & max); \
                 const uint64_t p0 = indata[ y * inlinesize +  x];              \
@@ -312,7 +312,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in; td.out = out;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(rect->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(rect->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_lensfun.c b/libavfilter/vf_lensfun.c
index 668c68562c3..fdc908a4179 100644
--- a/libavfilter/vf_lensfun.c
+++ b/libavfilter/vf_lensfun.c
@@ -461,7 +461,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         ff_filter_execute(ctx, vignetting_filter_slice,
                           &vignetting_thread_data, NULL,
-                          FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
     }
 
     if (lensfun->mode & (GEOMETRY_DISTORTION | SUBPIXEL_DISTORTION)) {
@@ -487,7 +487,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         ff_filter_execute(ctx, distortion_correction_filter_slice,
                           &distortion_correction_thread_data, NULL,
-                          FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
         av_frame_free(&in);
         return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 7dc27144fed..12298bfc2cd 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -151,7 +151,7 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char *
                 goto end;
             }
             ++(*rows);
-            *cols = FFMAX(*cols, w);
+            *cols = FFMAXI(*cols, w);
             w = 0;
         } else if (w == INT_MAX) {
             av_log(log_ctx, AV_LOG_ERROR, "Overflow on the number of columns in the file\n");
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 9ff64053cc0..23631bac750 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -1084,7 +1084,7 @@ static int libplacebo_activate(AVFilterContext *ctx)
             for (int i = 0; i < s->nb_inputs; i++) {
                 LibplaceboInput *in = &s->inputs[i];
                 if (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0) {
-                    out_pts = FFMIN(out_pts, pts);
+                    out_pts = FFMINI(out_pts, pts);
                 } else if (!in->status) {
                     ff_inlink_request_frame(ctx->inputs[in->idx]);
                     retry = true;
diff --git a/libavfilter/vf_limitdiff.c b/libavfilter/vf_limitdiff.c
index d8232755284..52e04ebb5b2 100644
--- a/libavfilter/vf_limitdiff.c
+++ b/libavfilter/vf_limitdiff.c
@@ -230,7 +230,7 @@ static int process_frame(FFFrameSync *fs)
         td.dst = out;
 
         ff_filter_execute(ctx, limitdiff_slice, &td, NULL,
-                          FFMIN(s->planeheight[0], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->planeheight[0], ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
diff --git a/libavfilter/vf_limiter.c b/libavfilter/vf_limiter.c
index 61f6c9e1bfe..05a2a5350b0 100644
--- a/libavfilter/vf_limiter.c
+++ b/libavfilter/vf_limiter.c
@@ -131,8 +131,8 @@ static int config_input(AVFilterLink *inlink)
     s->width[1]  = s->width[2]  = AV_CEIL_RSHIFT(inlink->w, hsub);
     s->width[0]  = s->width[3]  = inlink->w;
 
-    s->max = FFMIN(s->max, (1 << depth) - 1);
-    s->min = FFMIN(s->min, (1 << depth) - 1);
+    s->max = FFMINI(s->max, (1 << depth) - 1);
+    s->min = FFMINI(s->min, (1 << depth) - 1);
 
     if (depth == 8) {
         s->dsp.limiter = limiter8;
@@ -202,7 +202,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = in;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(s->height[2], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->height[2], ff_filter_get_nb_threads(ctx)));
     if (out != in)
         av_frame_free(&in);
 
diff --git a/libavfilter/vf_lumakey.c b/libavfilter/vf_lumakey.c
index a827d31b48a..a73a8012434 100644
--- a/libavfilter/vf_lumakey.c
+++ b/libavfilter/vf_lumakey.c
@@ -135,7 +135,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     int ret;
 
     if (ret = ff_filter_execute(ctx, s->do_lumakey_slice, frame, NULL,
-                                FFMIN(frame->height, ff_filter_get_nb_threads(ctx))))
+                                FFMINI(frame->height, ff_filter_get_nb_threads(ctx))))
         return ret;
 
     return ff_filter_frame(ctx->outputs[0], frame);
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index d15fb85c4e1..8dc71bfb836 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -546,22 +546,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         /* packed, 16-bit */
         PACKED_THREAD_DATA
         ff_filter_execute(ctx, lut_packed_16bits, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
     } else if (s->is_rgb && !s->is_planar) {
         /* packed 8 bits */
         PACKED_THREAD_DATA
         ff_filter_execute(ctx, lut_packed_8bits, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
     } else if (s->is_16bit) {
         /* planar >8 bit depth */
         PLANAR_THREAD_DATA
         ff_filter_execute(ctx, lut_planar_16bits, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
     } else {
         /* planar 8bit depth */
         PLANAR_THREAD_DATA
         ff_filter_execute(ctx, lut_planar_8bits, &td, NULL,
-                          FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
     }
 
     if (!direct)
diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c
index a37c0db9490..f1f45f2dca5 100644
--- a/libavfilter/vf_lut2.c
+++ b/libavfilter/vf_lut2.c
@@ -320,7 +320,7 @@ static int process_frame(FFFrameSync *fs)
         td.srcx = srcx;
         td.srcy = srcy;
         ff_filter_execute(ctx, s->lut2, &td, NULL,
-                          FFMIN(s->heightx[1], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->heightx[1], ff_filter_get_nb_threads(ctx)));
     }
 
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
@@ -626,7 +626,7 @@ static int tlut2_filter_frame(AVFilterLink *inlink, AVFrame *frame)
             td.srcx = frame;
             td.srcy = s->prev_frame;
             ff_filter_execute(ctx, s->lut2, &td, NULL,
-                              FFMIN(s->heightx[1], ff_filter_get_nb_threads(ctx)));
+                              FFMINI(s->heightx[1], ff_filter_get_nb_threads(ctx)));
         }
         av_frame_free(&s->prev_frame);
         s->prev_frame = frame;
diff --git a/libavfilter/vf_maskedclamp.c b/libavfilter/vf_maskedclamp.c
index 39bd596827a..265e215a1e1 100644
--- a/libavfilter/vf_maskedclamp.c
+++ b/libavfilter/vf_maskedclamp.c
@@ -154,7 +154,7 @@ static int process_frame(FFFrameSync *fs)
         td.d = out;
 
         ff_filter_execute(ctx, maskedclamp_slice, &td, NULL,
-                          FFMIN(s->height[0], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->height[0], ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
@@ -172,8 +172,8 @@ static void maskedclamp##name(const uint8_t *bbsrc, uint8_t *ddst,
     type *dst = (type *)ddst;                                                     \
                                                                                   \
     for (int x = 0; x < w; x++) {                                                 \
-        dst[x] = FFMAX(bsrc[x], darksrc[x] - undershoot);                         \
-        dst[x] = FFMIN(dst[x], brightsrc[x] + overshoot);                         \
+        dst[x] = FFMAXI(bsrc[x], darksrc[x] - undershoot);                         \
+        dst[x] = FFMINI(dst[x], brightsrc[x] + overshoot);                         \
     }                                                                             \
 }
 
@@ -200,8 +200,8 @@ static int config_input(AVFilterLink *inlink)
     s->width[0]  = s->width[3]  = inlink->w;
 
     s->depth = desc->comp[0].depth;
-    s->undershoot = FFMIN(s->undershoot, (1 << s->depth) - 1);
-    s->overshoot = FFMIN(s->overshoot, (1 << s->depth) - 1);
+    s->undershoot = FFMINI(s->undershoot, (1 << s->depth) - 1);
+    s->overshoot = FFMINI(s->overshoot, (1 << s->depth) - 1);
 
     if (s->depth <= 8)
         s->dsp.maskedclamp = maskedclamp8;
diff --git a/libavfilter/vf_maskedmerge.c b/libavfilter/vf_maskedmerge.c
index 93da0a0edf1..302f850e7bc 100644
--- a/libavfilter/vf_maskedmerge.c
+++ b/libavfilter/vf_maskedmerge.c
@@ -130,7 +130,7 @@ static int process_frame(FFFrameSync *fs)
         td.overlay = overlay;
         td.mask = mask;
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN(s->height[2], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->height[2], ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
diff --git a/libavfilter/vf_maskedminmax.c b/libavfilter/vf_maskedminmax.c
index b6762e16bf8..92262b0df5e 100644
--- a/libavfilter/vf_maskedminmax.c
+++ b/libavfilter/vf_maskedminmax.c
@@ -206,7 +206,7 @@ static int process_frame(FFFrameSync *fs)
         td.dst = out;
 
         ff_filter_execute(ctx, maskedminmax_slice, &td, NULL,
-                          FFMIN(s->planeheight[0], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->planeheight[0], ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
diff --git a/libavfilter/vf_maskedthreshold.c b/libavfilter/vf_maskedthreshold.c
index 41c204f6f54..9d2825e8d2e 100644
--- a/libavfilter/vf_maskedthreshold.c
+++ b/libavfilter/vf_maskedthreshold.c
@@ -84,7 +84,7 @@ static const enum AVPixelFormat pix_fmts[] = {
 static void threshold8_diff(const uint8_t *src, const uint8_t *ref, uint8_t *dst, int threshold, int w)
 {
     for (int x = 0; x < w; x++)
-        dst[x] = (ref[x] - src[x] <= threshold) ? FFMAX(ref[x] - threshold, 0): src[x];
+        dst[x] = (ref[x] - src[x] <= threshold) ? FFMAXI(ref[x] - threshold, 0): src[x];
 }
 
 static void threshold8_abs(const uint8_t *src, const uint8_t *ref, uint8_t *dst, int threshold, int w)
@@ -100,7 +100,7 @@ static void threshold16_diff(const uint8_t *ssrc, const uint8_t *rref, uint8_t *
     uint16_t *dst = (uint16_t *)ddst;
 
     for (int x = 0; x < w; x++)
-        dst[x] = (ref[x] - src[x] <= threshold) ? FFMAX(ref[x] - threshold, 0): src[x];
+        dst[x] = (ref[x] - src[x] <= threshold) ? FFMAXI(ref[x] - threshold, 0): src[x];
 }
 
 static void threshold16_abs(const uint8_t *ssrc, const uint8_t *rref, uint8_t *ddst, int threshold, int w)
@@ -207,7 +207,7 @@ static int process_frame(FFFrameSync *fs)
         td.dst = out;
 
         ff_filter_execute(ctx, threshold_slice, &td, NULL,
-                          FFMIN(s->planeheight[2], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->planeheight[2], ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
diff --git a/libavfilter/vf_maskfun.c b/libavfilter/vf_maskfun.c
index 9869ae4e338..ac4274711f7 100644
--- a/libavfilter/vf_maskfun.c
+++ b/libavfilter/vf_maskfun.c
@@ -113,7 +113,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     s->in = in;
     ff_filter_execute(ctx, s->maskfun, out, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
@@ -202,7 +202,7 @@ static void fill_frame(AVFilterContext *ctx)
 {
     MaskFunContext *s = ctx->priv;
 
-    s->fill = FFMIN(s->fill, s->max);
+    s->fill = FFMINI(s->fill, s->max);
     if (s->depth == 8) {
         for (int p = 0; p < s->nb_planes; p++) {
             uint8_t *dst = s->empty->data[p];
diff --git a/libavfilter/vf_median.c b/libavfilter/vf_median.c
index 6e00cdf885b..fc368134fab 100644
--- a/libavfilter/vf_median.c
+++ b/libavfilter/vf_median.c
@@ -141,7 +141,7 @@ static int config_input(AVFilterLink *inlink)
 
     check_params(s, inlink);
 
-    s->nb_threads = FFMAX(1, FFMIN(s->planeheight[1] / (s->radiusV + 1), ff_filter_get_nb_threads(inlink->dst)));
+    s->nb_threads = FFMAXI(1, FFMINI(s->planeheight[1] / (s->radiusV + 1), ff_filter_get_nb_threads(inlink->dst)));
     s->bins   = 1 << ((s->depth + 1) / 2);
     s->fine_size = s->bins * s->bins * inlink->w;
     s->coarse_size = s->bins * inlink->w;
diff --git a/libavfilter/vf_mergeplanes.c b/libavfilter/vf_mergeplanes.c
index 0073e46665e..8e174ba3327 100644
--- a/libavfilter/vf_mergeplanes.c
+++ b/libavfilter/vf_mergeplanes.c
@@ -101,7 +101,7 @@ static av_cold int init(AVFilterContext *ctx)
             return AVERROR(EINVAL);
         }
 
-        s->nb_inputs = FFMAX(s->nb_inputs, s->map[i].input + 1);
+        s->nb_inputs = FFMAXI(s->nb_inputs, s->map[i].input + 1);
     }
 
     av_assert0(s->nb_inputs && s->nb_inputs <= 4);
diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index 93d331f2fff..cd56f64bb95 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -258,8 +258,8 @@ static uint64_t get_sbad(AVMotionEstContext *me_ctx, int x, int y, int x_mv, int
 
     x = av_clip(x, me_ctx->x_min, me_ctx->x_max);
     y = av_clip(y, me_ctx->y_min, me_ctx->y_max);
-    mv_x = av_clip(x_mv - x, -FFMIN(x - me_ctx->x_min, me_ctx->x_max - x), FFMIN(x - me_ctx->x_min, me_ctx->x_max - x));
-    mv_y = av_clip(y_mv - y, -FFMIN(y - me_ctx->y_min, me_ctx->y_max - y), FFMIN(y - me_ctx->y_min, me_ctx->y_max - y));
+    mv_x = av_clip(x_mv - x, -FFMINI(x - me_ctx->x_min, me_ctx->x_max - x), FFMINI(x - me_ctx->x_min, me_ctx->x_max - x));
+    mv_y = av_clip(y_mv - y, -FFMINI(y - me_ctx->y_min, me_ctx->y_max - y), FFMINI(y - me_ctx->y_min, me_ctx->y_max - y));
 
     data_cur += (y + mv_y) * linesize;
     data_next += (y - mv_y) * linesize;
@@ -287,8 +287,8 @@ static uint64_t get_sbad_ob(AVMotionEstContext *me_ctx, int x, int y, int x_mv,
 
     x = av_clip(x, x_min, x_max);
     y = av_clip(y, y_min, y_max);
-    mv_x = av_clip(x_mv - x, -FFMIN(x - x_min, x_max - x), FFMIN(x - x_min, x_max - x));
-    mv_y = av_clip(y_mv - y, -FFMIN(y - y_min, y_max - y), FFMIN(y - y_min, y_max - y));
+    mv_x = av_clip(x_mv - x, -FFMINI(x - x_min, x_max - x), FFMINI(x - x_min, x_max - x));
+    mv_y = av_clip(y_mv - y, -FFMINI(y - y_min, y_max - y), FFMINI(y - y_min, y_max - y));
 
     for (j = -me_ctx->mb_size / 2; j < me_ctx->mb_size * 3 / 2; j++)
         for (i = -me_ctx->mb_size / 2; i < me_ctx->mb_size * 3 / 2; i++)
@@ -668,8 +668,8 @@ static int cluster_mvs(MIContext *mi_ctx)
                 if (FFABS(dx) > CLUSTER_THRESHOLD || FFABS(dy) > CLUSTER_THRESHOLD) {
 
                     for (d = 1; d < 5; d++)
-                        for (y = FFMAX(mb_y - d, 0); y < FFMIN(mb_y + d + 1, mi_ctx->b_height); y++)
-                            for (x = FFMAX(mb_x - d, 0); x < FFMIN(mb_x + d + 1, mi_ctx->b_width); x++) {
+                        for (y = FFMAXI(mb_y - d, 0); y < FFMINI(mb_y + d + 1, mi_ctx->b_height); y++)
+                            for (x = FFMAXI(mb_x - d, 0); x < FFMINI(mb_x + d + 1, mi_ctx->b_width); x++) {
                                 Block *nb = &mi_ctx->int_blocks[x + y * mi_ctx->b_width];
                                 if (nb->cid > block->cid) {
                                     if (nb->cid < c || c == block->cid)
@@ -692,7 +692,7 @@ static int cluster_mvs(MIContext *mi_ctx)
                     cluster_new->nb++;
                     cluster->nb--;
 
-                    c_max = FFMAX(c_max, c);
+                    c_max = FFMAXI(c_max, c);
                     block->cid = c;
 
                     changed = 1;
@@ -704,8 +704,8 @@ static int cluster_mvs(MIContext *mi_ctx)
     for (mb_y = 0; mb_y < mi_ctx->b_height; mb_y++)
         for (mb_x = 0; mb_x < mi_ctx->b_width; mb_x++) {
             block = &mi_ctx->int_blocks[mb_x + mb_y * mi_ctx->b_width];
-            for (y = FFMAX(mb_y - 1, 0); y < FFMIN(mb_y + 2, mi_ctx->b_height); y++)
-                for (x = FFMAX(mb_x - 1, 0); x < FFMIN(mb_x + 2, mi_ctx->b_width); x++) {
+            for (y = FFMAXI(mb_y - 1, 0); y < FFMINI(mb_y + 2, mi_ctx->b_height); y++)
+                for (x = FFMAXI(mb_x - 1, 0); x < FFMINI(mb_x + 2, mi_ctx->b_width); x++) {
                     dx = x - mb_x;
                     dy = y - mb_y;
 
@@ -829,7 +829,7 @@ static int detect_scene_change(AVFilterContext *ctx)
         mi_ctx->sad(p1, linesize1, p2, linesize2, input->w, input->h, &sad);
         mafd = (double) sad * 100.0 / (input->h * input->w) / (1 << mi_ctx->bitdepth);
         diff = fabs(mafd - mi_ctx->prev_mafd);
-        ret  = av_clipf(FFMIN(mafd, diff), 0, 100.0);
+        ret  = av_clipf(FFMIND(mafd, diff), 0, 100.0);
         mi_ctx->prev_mafd = mafd;
 
         return ret >= mi_ctx->scd_threshold;
@@ -1017,8 +1017,8 @@ static void bilateral_obmc(MIContext *mi_ctx, Block *block, int mb_x, int mb_y,
     int startc_x, startc_y, endc_x, endc_y;
 
     if (mi_ctx->mc_mode == MC_MODE_AOBMC)
-        for (nb_y = FFMAX(0, mb_y - 1); nb_y < FFMIN(mb_y + 2, mi_ctx->b_height); nb_y++)
-            for (nb_x = FFMAX(0, mb_x - 1); nb_x < FFMIN(mb_x + 2, mi_ctx->b_width); nb_x++) {
+        for (nb_y = FFMAXI(0, mb_y - 1); nb_y < FFMINI(mb_y + 2, mi_ctx->b_height); nb_y++)
+            for (nb_x = FFMAXI(0, mb_x - 1); nb_x < FFMINI(mb_x + 2, mi_ctx->b_width); nb_x++) {
                 int x_nb = nb_x << mi_ctx->log2_mb_size;
                 int y_nb = nb_y << mi_ctx->log2_mb_size;
 
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 517bb2450fd..4816e562119 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -166,7 +166,7 @@ typedef struct ThreadData {
         type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]);                    \
         const ptrdiff_t sum_linesize = (s->linesizes[p] * 2) / sizeof(stype);                   \
         const ptrdiff_t dst_linesize = out->linesize[p] / sizeof(type);                         \
-        const int idx = FFMAX(0, nb_inputs - nb_unique);                                        \
+        const int idx = FFMAXI(0, nb_inputs - nb_unique);                                        \
         const ptrdiff_t src_linesize[2] = { in[idx]->linesize[p],                               \
                                             in[nb_inputs-1]->linesize[p] };                     \
         const type *src[2];                                                                     \
@@ -310,7 +310,7 @@ static int process_frame(FFFrameSync *fs)
     td.in = in;
     td.out = out;
     ff_filter_execute(ctx, mix_frames, &td, NULL,
-                      FFMIN(s->height[1], s->nb_threads));
+                      FFMINI(s->height[1], s->nb_threads));
 
     return ff_filter_frame(outlink, out);
 }
@@ -499,7 +499,7 @@ static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in)
             s->nb_frames++;
         }
     } else {
-        s->nb_unique_frames = FFMIN(s->nb_unique_frames + 1, s->nb_inputs);
+        s->nb_unique_frames = FFMINI(s->nb_unique_frames + 1, s->nb_inputs);
         av_frame_free(&s->frames[0]);
         memmove(&s->frames[0], &s->frames[1], sizeof(*s->frames) * (s->nb_inputs - 1));
         s->frames[s->nb_inputs - 1] = in;
@@ -520,7 +520,7 @@ static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = s->frames;
     ff_filter_execute(ctx, mix_frames, &td, NULL,
-                      FFMIN(s->height[1], s->nb_threads));
+                      FFMINI(s->height[1], s->nb_threads));
 
     return ff_filter_frame(outlink, out);
 }
diff --git a/libavfilter/vf_monochrome.c b/libavfilter/vf_monochrome.c
index 4718642921a..9ba648140e6 100644
--- a/libavfilter/vf_monochrome.c
+++ b/libavfilter/vf_monochrome.c
@@ -214,9 +214,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     MonochromeContext *s = ctx->priv;
 
     ff_filter_execute(ctx, s->do_slice, frame, NULL,
-                      FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(frame->height, ff_filter_get_nb_threads(ctx)));
     ff_filter_execute(ctx, s->clear_uv, frame, NULL,
-                      FFMIN(frame->height >> s->subh, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(frame->height >> s->subh, ff_filter_get_nb_threads(ctx)));
 
     return ff_filter_frame(ctx->outputs[0], frame);
 }
diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c
index 098d00dfd1b..79aa712827f 100644
--- a/libavfilter/vf_morpho.c
+++ b/libavfilter/vf_morpho.c
@@ -171,37 +171,37 @@ static const enum AVPixelFormat pix_fmts[] = {
 static void min_fun(uint8_t *c, const uint8_t *a, const uint8_t *b, int x)
 {
     for (int i = 0; i < x; i++)
-        c[i] = FFMIN(b[i], a[i]);
+        c[i] = FFMINI(b[i], a[i]);
 }
 
 static void mininplace_fun(uint8_t *a, const uint8_t *b, int x)
 {
     for (int i = 0; i < x; i++)
-        a[i] = FFMIN(a[i], b[i]);
+        a[i] = FFMINI(a[i], b[i]);
 }
 
 static void max_fun(uint8_t *c, const uint8_t *a, const uint8_t *b, int x)
 {
     for (int i = 0; i < x; i++)
-        c[i] = FFMAX(a[i], b[i]);
+        c[i] = FFMAXI(a[i], b[i]);
 }
 
 static void maxinplace_fun(uint8_t *a, const uint8_t *b, int x)
 {
     for (int i = 0; i < x; i++)
-        a[i] = FFMAX(a[i], b[i]);
+        a[i] = FFMAXI(a[i], b[i]);
 }
 
 static void diff_fun(uint8_t *a, const uint8_t *b, int x)
 {
     for (int i = 0; i < x; i++)
-        a[i] = FFMAX(b[i] - a[i], 0);
+        a[i] = FFMAXI(b[i] - a[i], 0);
 }
 
 static void diffinplace_fun(uint8_t *a, const uint8_t *b, int x)
 {
     for (int i = 0; i < x; i++)
-        a[i] = FFMAX(a[i] - b[i], 0);
+        a[i] = FFMAXI(a[i] - b[i], 0);
 }
 
 static void min16_fun(uint8_t *cc, const uint8_t *aa, const uint8_t *bb, int x)
@@ -211,7 +211,7 @@ static void min16_fun(uint8_t *cc, const uint8_t *aa, const uint8_t *bb, int x)
     uint16_t *c = (uint16_t *)cc;
 
     for (int i = 0; i < x; i++)
-        c[i] = FFMIN(b[i], a[i]);
+        c[i] = FFMINI(b[i], a[i]);
 }
 
 static void mininplace16_fun(uint8_t *aa, const uint8_t *bb, int x)
@@ -220,7 +220,7 @@ static void mininplace16_fun(uint8_t *aa, const uint8_t *bb, int x)
     const uint16_t *b = (const uint16_t *)bb;
 
     for (int i = 0; i < x; i++)
-        a[i] = FFMIN(a[i], b[i]);
+        a[i] = FFMINI(a[i], b[i]);
 }
 
 static void diff16_fun(uint8_t *aa, const uint8_t *bb, int x)
@@ -229,7 +229,7 @@ static void diff16_fun(uint8_t *aa, const uint8_t *bb, int x)
     uint16_t *a = (uint16_t *)aa;
 
     for (int i = 0; i < x; i++)
-        a[i] = FFMAX(b[i] - a[i], 0);
+        a[i] = FFMAXI(b[i] - a[i], 0);
 }
 
 static void diffinplace16_fun(uint8_t *aa, const uint8_t *bb, int x)
@@ -238,7 +238,7 @@ static void diffinplace16_fun(uint8_t *aa, const uint8_t *bb, int x)
     const uint16_t *b = (const uint16_t *)bb;
 
     for (int i = 0; i < x; i++)
-        a[i] = FFMAX(a[i] - b[i], 0);
+        a[i] = FFMAXI(a[i] - b[i], 0);
 }
 
 static void max16_fun(uint8_t *cc, const uint8_t *aa, const uint8_t *bb, int x)
@@ -248,7 +248,7 @@ static void max16_fun(uint8_t *cc, const uint8_t *aa, const uint8_t *bb, int x)
     uint16_t *c = (uint16_t *)cc;
 
     for (int i = 0; i < x; i++)
-        c[i] = FFMAX(a[i], b[i]);
+        c[i] = FFMAXI(a[i], b[i]);
 }
 
 static void maxinplace16_fun(uint8_t *aa, const uint8_t *bb, int x)
@@ -257,12 +257,12 @@ static void maxinplace16_fun(uint8_t *aa, const uint8_t *bb, int x)
     const uint16_t *b = (const uint16_t *)bb;
 
     for (int i = 0; i < x; i++)
-        a[i] = FFMAX(a[i], b[i]);
+        a[i] = FFMAXI(a[i], b[i]);
 }
 
 static int alloc_lut(LUT *Ty, chord_set *SE, int type_size, int mode)
 {
-    const int min = FFMAX(Ty->min_r, 0);
+    const int min = FFMAXI(Ty->min_r, 0);
     const int max = min + (Ty->max_r - Ty->min_r);
     int pre_pad_x = 0;
 
@@ -298,7 +298,7 @@ static int alloc_lut(LUT *Ty, chord_set *SE, int type_size, int mode)
 
 static void free_lut(LUT *table)
 {
-    const int min = FFMAX(table->min_r, 0);
+    const int min = FFMAXI(table->min_r, 0);
     const int max = min + (table->max_r - table->min_r);
 
     if (!table->base_arr)
@@ -520,11 +520,11 @@ static int insert_chord_set(chord_set *chords, chord c)
     chords->C[chords->size++].l = c.l;
 
     // Update minimum/maximum x/y offsets of the chord set.
-    chords->minX = FFMIN(chords->minX, c.x);
-    chords->maxX = FFMAX(chords->maxX, c.x);
+    chords->minX = FFMINI(chords->minX, c.x);
+    chords->maxX = FFMAXI(chords->maxX, c.x);
 
-    chords->minY = FFMIN(chords->minY, c.y);
-    chords->maxY = FFMAX(chords->maxY, c.y);
+    chords->minY = FFMINI(chords->minY, c.y);
+    chords->maxY = FFMAXI(chords->maxY, c.y);
 
     return 0;
 }
@@ -981,11 +981,11 @@ static int do_morpho(FFFrameSync *fs)
     td.in = in; td.out = out;
     ret = ff_filter_execute(ctx, morpho_slice, &td, NULL,
                             FFMIN3(s->planeheight[1], s->planeheight[2],
-                                   FFMIN(MAX_THREADS, ff_filter_get_nb_threads(ctx))));
+                                   FFMINI(MAX_THREADS, ff_filter_get_nb_threads(ctx))));
     if (ret == 0 && (s->mode != ERODE && s->mode != DILATE)) {
         ff_filter_execute(ctx, morpho_sliceX, NULL, NULL,
                           FFMIN3(s->planeheight[1], s->planeheight[2],
-                                 FFMIN(MAX_THREADS, ff_filter_get_nb_threads(ctx))));
+                                 FFMINI(MAX_THREADS, ff_filter_get_nb_threads(ctx))));
     }
 
     av_frame_free(&in);
diff --git a/libavfilter/vf_mpdecimate.c b/libavfilter/vf_mpdecimate.c
index d4851c15400..fb67c0b336a 100644
--- a/libavfilter/vf_mpdecimate.c
+++ b/libavfilter/vf_mpdecimate.c
@@ -202,12 +202,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *cur)
     int ret;
 
     if (decimate->ref && decimate_frame(inlink->dst, cur, decimate->ref)) {
-        decimate->drop_count = FFMAX(1, decimate->drop_count+1);
+        decimate->drop_count = FFMAXI(1, decimate->drop_count+1);
         decimate->keep_count = -1; // do not keep any more frames until non-similar frames are detected
     } else {
         av_frame_free(&decimate->ref);
         decimate->ref = cur;
-        decimate->drop_count = FFMIN(-1, decimate->drop_count-1);
+        decimate->drop_count = FFMINI(-1, decimate->drop_count-1);
         if (decimate->keep_count < 0) // re-enable counting similiar frames to ignore before dropping
             decimate->keep_count = 0;
 
diff --git a/libavfilter/vf_multiply.c b/libavfilter/vf_multiply.c
index f7db2195db8..2c7ff34c290 100644
--- a/libavfilter/vf_multiply.c
+++ b/libavfilter/vf_multiply.c
@@ -151,7 +151,7 @@ static int process_frame(FFFrameSync *fs)
         td.dst = out;
 
         ff_filter_execute(ctx, multiply_slice, &td, NULL,
-                          FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
diff --git a/libavfilter/vf_negate.c b/libavfilter/vf_negate.c
index f61f7ebbbb6..02df0f73dc3 100644
--- a/libavfilter/vf_negate.c
+++ b/libavfilter/vf_negate.c
@@ -322,7 +322,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = in;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(s->height[2], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->height[2], ff_filter_get_nb_threads(ctx)));
     if (out != in)
         av_frame_free(&in);
 
diff --git a/libavfilter/vf_neighbor.c b/libavfilter/vf_neighbor.c
index 7bdc2ab91f7..0071ecd2a1f 100644
--- a/libavfilter/vf_neighbor.c
+++ b/libavfilter/vf_neighbor.c
@@ -80,13 +80,13 @@ static void erosion(uint8_t *dst, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int min = p1[x];
-        int limit = FFMAX(min - threshold, 0);
+        int limit = FFMAXI(min - threshold, 0);
 
         for (i = 0; i < 8; i++) {
             if (coord & (1 << i)) {
-                min = FFMIN(min, *(coordinates[i] + x));
+                min = FFMINI(min, *(coordinates[i] + x));
             }
-            min = FFMAX(min, limit);
+            min = FFMAXI(min, limit);
         }
 
         dst[x] = min;
@@ -102,13 +102,13 @@ static void erosion16(uint8_t *dstp, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int min = AV_RN16A(&p1[2 * x]);
-        int limit = FFMAX(min - threshold, 0);
+        int limit = FFMAXI(min - threshold, 0);
 
         for (i = 0; i < 8; i++) {
             if (coord & (1 << i)) {
-                min = FFMIN(min, AV_RN16A(coordinates[i] + x * 2));
+                min = FFMINI(min, AV_RN16A(coordinates[i] + x * 2));
             }
-            min = FFMAX(min, limit);
+            min = FFMAXI(min, limit);
         }
 
         dst[x] = min;
@@ -123,13 +123,13 @@ static void dilation(uint8_t *dst, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int max = p1[x];
-        int limit = FFMIN(max + threshold, 255);
+        int limit = FFMINI(max + threshold, 255);
 
         for (i = 0; i < 8; i++) {
             if (coord & (1 << i)) {
-                max = FFMAX(max, *(coordinates[i] + x));
+                max = FFMAXI(max, *(coordinates[i] + x));
             }
-            max = FFMIN(max, limit);
+            max = FFMINI(max, limit);
         }
 
         dst[x] = max;
@@ -145,13 +145,13 @@ static void dilation16(uint8_t *dstp, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int max = AV_RN16A(&p1[x * 2]);
-        int limit = FFMIN(max + threshold, maxc);
+        int limit = FFMINI(max + threshold, maxc);
 
         for (i = 0; i < 8; i++) {
             if (coord & (1 << i)) {
-                max = FFMAX(max, AV_RN16A(coordinates[i] + x * 2));
+                max = FFMAXI(max, AV_RN16A(coordinates[i] + x * 2));
             }
-            max = FFMIN(max, limit);
+            max = FFMINI(max, limit);
         }
 
         dst[x] = max;
@@ -166,11 +166,11 @@ static void deflate(uint8_t *dst, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int sum = 0;
-        int limit = FFMAX(p1[x] - threshold, 0);
+        int limit = FFMAXI(p1[x] - threshold, 0);
 
         for (i = 0; i < 8; sum += *(coordinates[i++] + x));
 
-        dst[x] = FFMAX(FFMIN(sum / 8, p1[x]), limit);
+        dst[x] = FFMAXI(FFMINI(sum / 8, p1[x]), limit);
     }
 }
 
@@ -183,11 +183,11 @@ static void deflate16(uint8_t *dstp, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int sum = 0;
-        int limit = FFMAX(AV_RN16A(&p1[2 * x]) - threshold, 0);
+        int limit = FFMAXI(AV_RN16A(&p1[2 * x]) - threshold, 0);
 
         for (i = 0; i < 8; sum += AV_RN16A(coordinates[i++] + x * 2));
 
-        dst[x] = FFMAX(FFMIN(sum / 8, AV_RN16A(&p1[2 * x])), limit);
+        dst[x] = FFMAXI(FFMINI(sum / 8, AV_RN16A(&p1[2 * x])), limit);
     }
 }
 
@@ -199,11 +199,11 @@ static void inflate(uint8_t *dst, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int sum = 0;
-        int limit = FFMIN(p1[x] + threshold, 255);
+        int limit = FFMINI(p1[x] + threshold, 255);
 
         for (i = 0; i < 8; sum += *(coordinates[i++] + x));
 
-        dst[x] = FFMIN(FFMAX(sum / 8, p1[x]), limit);
+        dst[x] = FFMINI(FFMAXI(sum / 8, p1[x]), limit);
     }
 }
 
@@ -216,11 +216,11 @@ static void inflate16(uint8_t *dstp, const uint8_t *p1, int width,
 
     for (x = 0; x < width; x++) {
         int sum = 0;
-        int limit = FFMIN(AV_RN16A(&p1[2 * x]) + threshold, maxc);
+        int limit = FFMINI(AV_RN16A(&p1[2 * x]) + threshold, maxc);
 
         for (i = 0; i < 8; sum += AV_RN16A(coordinates[i++] + x * 2));
 
-        dst[x] = FFMIN(FFMAX(sum / 8, AV_RN16A(&p1[x * 2])), limit);
+        dst[x] = FFMINI(FFMAXI(sum / 8, AV_RN16A(&p1[x * 2])), limit);
     }
 }
 
@@ -325,7 +325,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in;
     td.out = out;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_nlmeans_vulkan.c b/libavfilter/vf_nlmeans_vulkan.c
index 22a2a73eaed..3e2f0dda0ee 100644
--- a/libavfilter/vf_nlmeans_vulkan.c
+++ b/libavfilter/vf_nlmeans_vulkan.c
@@ -219,7 +219,7 @@ static av_cold int init_weights_pipeline(FFVulkanContext *vkctx, FFVkExecPool *e
     size_t spv_len;
     void *spv_opaque = NULL;
     FFVulkanDescriptorSetBinding *desc_set;
-    int max_dim = FFMAX(width, height);
+    int max_dim = FFMAXI(width, height);
     uint32_t max_wg = vkctx->props.properties.limits.maxComputeWorkGroupSize[0];
     int wg_size, wg_rows;
 
@@ -639,7 +639,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
 
     RET(ff_vk_unmap_buffer(&s->vkctx, &s->xyoffsets_buf, 1));
 
-    s->opts.t = FFMIN(s->opts.t, (FFALIGN(s->nb_offsets, TYPE_ELEMS) / TYPE_ELEMS));
+    s->opts.t = FFMINI(s->opts.t, (FFALIGN(s->nb_offsets, TYPE_ELEMS) / TYPE_ELEMS));
     if (!vkctx->atomic_float_feats.shaderBufferFloat32AtomicAdd) {
         av_log(ctx, AV_LOG_WARNING, "Device doesn't support atomic float adds, "
                "disabling dispatch parallelism\n");
@@ -674,8 +674,8 @@ static av_cold int init_filter(AVFilterContext *ctx)
                                     VK_FORMAT_UNDEFINED));
 
     do {
-        int wg_invoc = FFMIN((s->nb_offsets - offsets_dispatched)/TYPE_ELEMS, s->opts.t);
-        wg_invoc = FFMIN(wg_invoc, vkctx->props.properties.limits.maxComputeWorkGroupCount[2]);
+        int wg_invoc = FFMINI((s->nb_offsets - offsets_dispatched)/TYPE_ELEMS, s->opts.t);
+        wg_invoc = FFMINI(wg_invoc, vkctx->props.properties.limits.maxComputeWorkGroupCount[2]);
         offsets_dispatched += wg_invoc * TYPE_ELEMS;
         nb_dispatches++;
     } while (offsets_dispatched < s->nb_offsets);
@@ -1014,8 +1014,8 @@ static int nlmeans_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
             integral_vk->access = buf_bar[1].dstAccessMask;
         }
 
-        wg_invoc = FFMIN((s->nb_offsets - offsets_dispatched)/TYPE_ELEMS, s->opts.t);
-        wg_invoc = FFMIN(wg_invoc, vkctx->props.properties.limits.maxComputeWorkGroupCount[2]);
+        wg_invoc = FFMINI((s->nb_offsets - offsets_dispatched)/TYPE_ELEMS, s->opts.t);
+        wg_invoc = FFMINI(wg_invoc, vkctx->props.properties.limits.maxComputeWorkGroupCount[2]);
 
         /* End of horizontal pass */
         vk->CmdDispatch(exec->buf, 1, 1, wg_invoc);
diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c
index d3f52b3f94a..69bf5418797 100644
--- a/libavfilter/vf_nnedi.c
+++ b/libavfilter/vf_nnedi.c
@@ -263,7 +263,7 @@ static void process_old(AVFilterContext *ctx,
         for (int n = 0; n < 4; n++)
             state[n + 8] = dot_dsp(s, m_data->kernel_l2[n], state, 8, 1.0f, m_data->bias_l2[n]);
 
-        prescreen[j] = FFMAX(state[10], state[11]) <= FFMAX(state[8], state[9]) ? 255 : 0;
+        prescreen[j] = FFMAXF(state[10], state[11]) <= FFMAXF(state[8], state[9]) ? 255 : 0;
     }
 }
 
@@ -590,25 +590,25 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
         y_out = slice_start + ((!tff) ^ (slice_start & 1));
 
-        s->read(src_data + FFMAX(y_out - 5, tff) * src_linesize,
+        s->read(src_data + FFMAXI(y_out - 5, tff) * src_linesize,
                 srcbuf + 32,
                 src_linesize * 2, srcbuf_stride,
                 width, 1, in_scale);
         srcbuf += srcbuf_stride;
 
-        s->read(src_data + FFMAX(y_out - 3, tff) * src_linesize,
+        s->read(src_data + FFMAXI(y_out - 3, tff) * src_linesize,
                 srcbuf + 32,
                 src_linesize * 2, srcbuf_stride,
                 width, 1, in_scale);
         srcbuf += srcbuf_stride;
 
-        s->read(src_data + FFMAX(y_out - 1, tff) * src_linesize,
+        s->read(src_data + FFMAXI(y_out - 1, tff) * src_linesize,
                 srcbuf + 32,
                 src_linesize * 2, srcbuf_stride,
                 width, 1, in_scale);
         srcbuf += srcbuf_stride;
 
-        in_line  = src_data + FFMIN(y_out + 1, height - 1 - !tff) * src_linesize;
+        in_line  = src_data + FFMINI(y_out + 1, height - 1 - !tff) * src_linesize;
         out_line = dst_data + (y_out * dst_linesize);
 
         s->read(in_line, srcbuf + 32, src_linesize * 2, srcbuf_stride,
@@ -616,17 +616,17 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
         y_out += (slice_height - last_slice) * 2;
 
-        s->read(src_data + FFMIN(y_out + 1, height - 1 - !tff) * src_linesize,
+        s->read(src_data + FFMINI(y_out + 1, height - 1 - !tff) * src_linesize,
                 srcbuf + 32 + srcbuf_stride * (slice_height - last_slice),
                 src_linesize * 2, srcbuf_stride,
                 width, 1, in_scale);
 
-        s->read(src_data + FFMIN(y_out + 3, height - 1 - !tff) * src_linesize,
+        s->read(src_data + FFMINI(y_out + 3, height - 1 - !tff) * src_linesize,
                 srcbuf + 32 + srcbuf_stride * (slice_height + 1 - last_slice),
                 src_linesize * 2, srcbuf_stride,
                 width, 1, in_scale);
 
-        s->read(src_data + FFMIN(y_out + 5, height - 1 - !tff) * src_linesize,
+        s->read(src_data + FFMINI(y_out + 5, height - 1 - !tff) * src_linesize,
                 srcbuf + 32 + srcbuf_stride * (slice_height + 2 - last_slice),
                 src_linesize * 2, srcbuf_stride,
                 width, 1, in_scale);
@@ -672,7 +672,7 @@ static int get_frame(AVFilterContext *ctx, int is_second)
     dst->pts = s->pts;
 
     ff_filter_execute(ctx, filter_slice, dst, NULL,
-                      FFMIN(s->planeheight[1] / 2, s->nb_threads));
+                      FFMINI(s->planeheight[1] / 2, s->nb_threads));
 
     if (s->field == -2 || s->field > 1)
         s->field_n = !s->field_n;
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index a6613f663e4..daace517fb2 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -209,7 +209,7 @@ static void noise(uint8_t *dst, const uint8_t *src,
         const int ix = y & (MAX_RES - 1);
         int x;
         for (x=0; x < width; x+= MAX_RES) {
-            int w = FFMIN(width - x, MAX_RES);
+            int w = FFMINI(width - x, MAX_RES);
             int shift = p->rand_shift[ix];
 
             if (flags & NOISE_AVERAGED) {
@@ -276,7 +276,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
 
     td.in = inpicref; td.out = out;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(n->height[0], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(n->height[0], ff_filter_get_nb_threads(ctx)));
     emms_c();
 
     if (inpicref != out)
diff --git a/libavfilter/vf_normalize.c b/libavfilter/vf_normalize.c
index 6d32bc85fcb..b7585d2848e 100644
--- a/libavfilter/vf_normalize.c
+++ b/libavfilter/vf_normalize.c
@@ -144,8 +144,8 @@ static void find_min_max(NormalizeContext *s, AVFrame *in, NormalizeLocal min[3]
         uint8_t *inp = in->data[0] + y * in->linesize[0];
         for (int x = 0; x < in->width; x++) {
             for (int c = 0; c < 3; c++) {
-                min[c].in = FFMIN(min[c].in, inp[s->co[c]]);
-                max[c].in = FFMAX(max[c].in, inp[s->co[c]]);
+                min[c].in = FFMINI(min[c].in, inp[s->co[c]]);
+                max[c].in = FFMAXI(max[c].in, inp[s->co[c]]);
             }
             inp += s->step;
         }
@@ -179,12 +179,12 @@ static void find_min_max_planar(NormalizeContext *s, AVFrame *in, NormalizeLocal
         uint8_t *ingp = in->data[0] + y * in->linesize[0];
         uint8_t *inbp = in->data[1] + y * in->linesize[1];
         for (int x = 0; x < in->width; x++) {
-            min[0].in = FFMIN(min[0].in, inrp[x]);
-            max[0].in = FFMAX(max[0].in, inrp[x]);
-            min[1].in = FFMIN(min[1].in, ingp[x]);
-            max[1].in = FFMAX(max[1].in, ingp[x]);
-            min[2].in = FFMIN(min[2].in, inbp[x]);
-            max[2].in = FFMAX(max[2].in, inbp[x]);
+            min[0].in = FFMINI(min[0].in, inrp[x]);
+            max[0].in = FFMAXI(max[0].in, inrp[x]);
+            min[1].in = FFMINI(min[1].in, ingp[x]);
+            max[1].in = FFMAXI(max[1].in, ingp[x]);
+            min[2].in = FFMINI(min[2].in, inbp[x]);
+            max[2].in = FFMAXI(max[2].in, inbp[x]);
         }
     }
 }
@@ -218,8 +218,8 @@ static void find_min_max_16(NormalizeContext *s, AVFrame *in, NormalizeLocal min
         uint16_t *inp = (uint16_t *)(in->data[0] + y * in->linesize[0]);
         for (int x = 0; x < in->width; x++) {
             for (int c = 0; c < 3; c++) {
-                min[c].in = FFMIN(min[c].in, inp[s->co[c]]);
-                max[c].in = FFMAX(max[c].in, inp[s->co[c]]);
+                min[c].in = FFMINI(min[c].in, inp[s->co[c]]);
+                max[c].in = FFMAXI(max[c].in, inp[s->co[c]]);
             }
             inp += s->step;
         }
@@ -253,12 +253,12 @@ static void find_min_max_planar_16(NormalizeContext *s, AVFrame *in, NormalizeLo
         uint16_t *ingp = (uint16_t *)(in->data[0] + y * in->linesize[0]);
         uint16_t *inbp = (uint16_t *)(in->data[1] + y * in->linesize[1]);
         for (int x = 0; x < in->width; x++) {
-            min[0].in = FFMIN(min[0].in, inrp[x]);
-            max[0].in = FFMAX(max[0].in, inrp[x]);
-            min[1].in = FFMIN(min[1].in, ingp[x]);
-            max[1].in = FFMAX(max[1].in, ingp[x]);
-            min[2].in = FFMIN(min[2].in, inbp[x]);
-            max[2].in = FFMAX(max[2].in, inbp[x]);
+            min[0].in = FFMINI(min[0].in, inrp[x]);
+            max[0].in = FFMAXI(max[0].in, inrp[x]);
+            min[1].in = FFMINI(min[1].in, ingp[x]);
+            max[1].in = FFMAXI(max[1].in, ingp[x]);
+            min[2].in = FFMINI(min[2].in, inbp[x]);
+            max[2].in = FFMAXI(max[2].in, inbp[x]);
         }
     }
 }
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 8560ed7c173..0b6a4f1fd0d 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -382,8 +382,8 @@ static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx,
     int slice_start, slice_end;
     uint8_t *S, *sp, *d, *dp;
 
-    i = FFMAX(-y, 0);
-    imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h);
+    i = FFMAXI(-y, 0);
+    imax = FFMIN3(-y + dst_h, FFMINI(src_h, dst_h), y + src_h);
 
     slice_start = i + (imax * jobnr) / nb_jobs;
     slice_end = i + (imax * (jobnr+1)) / nb_jobs;
@@ -392,11 +392,11 @@ static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx,
     dp = dst->data[0] + (y + slice_start) * dst->linesize[0];
 
     for (i = slice_start; i < slice_end; i++) {
-        j = FFMAX(-x, 0);
+        j = FFMAXI(-x, 0);
         S = sp + j     * sstep;
         d = dp + (x+j) * dstep;
 
-        for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) {
+        for (jmax = FFMINI(-x + dst_w, src_w); j < jmax; j++) {
             alpha = S[sa];
 
             // if the main channel has an alpha channel, alpha has to be calculated
@@ -418,11 +418,11 @@ static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx,
                 // main_value = main_value * (1 - alpha) + overlay_value * alpha
                 // since alpha is in the range 0-255, the result must divided by 255
                 d[dr] = is_straight ? FAST_DIV255(d[dr] * (255 - alpha) + S[sr] * alpha) :
-                        FFMIN(FAST_DIV255(d[dr] * (255 - alpha)) + S[sr], 255);
+                        FFMINI(FAST_DIV255(d[dr] * (255 - alpha)) + S[sr], 255);
                 d[dg] = is_straight ? FAST_DIV255(d[dg] * (255 - alpha) + S[sg] * alpha) :
-                        FFMIN(FAST_DIV255(d[dg] * (255 - alpha)) + S[sg], 255);
+                        FFMINI(FAST_DIV255(d[dg] * (255 - alpha)) + S[sg], 255);
                 d[db] = is_straight ? FAST_DIV255(d[db] * (255 - alpha) + S[sb] * alpha) :
-                        FFMIN(FAST_DIV255(d[db] * (255 - alpha)) + S[sb], 255);
+                        FFMINI(FAST_DIV255(d[db] * (255 - alpha)) + S[sb], 255);
             }
             if (main_has_alpha) {
                 switch (alpha) {
@@ -475,8 +475,8 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext
     int bytes = depth / 8;                                                                                 \
                                                                                                            \
     dst_step /= bytes;                                                                                     \
-    j = FFMAX(-yp, 0);                                                                                     \
-    jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp);                                       \
+    j = FFMAXI(-yp, 0);                                                                                     \
+    jmax = FFMIN3(-yp + dst_hp, FFMINI(src_hp, dst_hp), yp + src_hp);                                       \
                                                                                                            \
     slice_start = j + (jmax * jobnr) / nb_jobs;                                                            \
     slice_end = j + (jmax * (jobnr+1)) / nb_jobs;                                                          \
@@ -489,12 +489,12 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext
     dap = (uint##depth##_t *)(dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3]);             \
                                                                                                            \
     for (j = slice_start; j < slice_end; j++) {                                                            \
-        k = FFMAX(-xp, 0);                                                                                 \
+        k = FFMAXI(-xp, 0);                                                                                 \
         d = dp + (xp+k) * dst_step;                                                                        \
         s = sp + k;                                                                                        \
         a = ap + (k<<hsub);                                                                                \
         da = dap + ((xp+k) << hsub);                                                                       \
-        kmax = FFMIN(-xp + dst_wp, src_wp);                                                                \
+        kmax = FFMINI(-xp + dst_wp, src_wp);                                                                \
                                                                                                            \
         if (nbits == 8 && ((vsub && j+1 < src_hp) || !vsub) && octx->blend_row[i]) {                       \
             int c = octx->blend_row[i]((uint8_t*)d, (uint8_t*)da, (uint8_t*)s,                             \
@@ -586,8 +586,8 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
     const uint##depth##_t max = (1 << nbits) - 1;                                                          \
     int bytes = depth / 8;                                                                                 \
                                                                                                            \
-    imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h);                                             \
-    i = FFMAX(-y, 0);                                                                                      \
+    imax = FFMIN3(-y + dst_h, FFMINI(src_h, dst_h), y + src_h);                                             \
+    i = FFMAXI(-y, 0);                                                                                      \
                                                                                                            \
     slice_start = i + (imax * jobnr) / nb_jobs;                                                            \
     slice_end = i + ((imax * (jobnr+1)) / nb_jobs);                                                        \
@@ -596,11 +596,11 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
     da = (uint##depth##_t *)(dst->data[3] + (y + slice_start) * dst->linesize[3]);                         \
                                                                                                            \
     for (i = slice_start; i < slice_end; i++) {                                                            \
-        j = FFMAX(-x, 0);                                                                                  \
+        j = FFMAXI(-x, 0);                                                                                  \
         s = sa + j;                                                                                        \
         d = da + x+j;                                                                                      \
                                                                                                            \
-        for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) {                                             \
+        for (jmax = FFMINI(-x + dst_w, src_w); j < jmax; j++) {                                             \
             alpha = *s;                                                                                    \
             if (alpha != 0 && alpha != max) {                                                              \
                 uint8_t alpha_d = *d;                                                                      \
@@ -910,7 +910,7 @@ static int do_blend(FFFrameSync *fs)
 
         td.dst = mainpic;
         td.src = second;
-        ff_filter_execute(ctx, s->blend_slice, &td, NULL, FFMIN(FFMAX(1, FFMIN3(s->y + second->height, FFMIN(second->height, mainpic->height), mainpic->height - s->y)),
+        ff_filter_execute(ctx, s->blend_slice, &td, NULL, FFMINI(FFMAXI(1, FFMIN3(s->y + second->height, FFMINI(second->height, mainpic->height), mainpic->height - s->y)),
                                                                 ff_filter_get_nb_threads(ctx)));
     }
     return ff_filter_frame(ctx->outputs[0], mainpic);
diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c
index e930aced046..7b81e85abf7 100644
--- a/libavfilter/vf_overlay_opencl.c
+++ b/libavfilter/vf_overlay_opencl.c
@@ -61,10 +61,10 @@ static int overlay_opencl_load(AVFilterContext *avctx,
 
     main_planes = overlay_planes = 0;
     for (i = 0; i < main_desc->nb_components; i++)
-        main_planes = FFMAX(main_planes,
+        main_planes = FFMAXI(main_planes,
                             main_desc->comp[i].plane + 1);
     for (i = 0; i < overlay_desc->nb_components; i++)
-        overlay_planes = FFMAX(overlay_planes,
+        overlay_planes = FFMAXI(overlay_planes,
                                overlay_desc->comp[i].plane + 1);
 
     ctx->nb_planes = main_planes;
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index 0c7a1d2b445..c3900878097 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -363,8 +363,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     if (needs_copy) {
         av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible allocating new frame\n");
         out = ff_get_video_buffer(outlink,
-                                  FFMAX(inlink->w, s->w),
-                                  FFMAX(inlink->h, s->h));
+                                  FFMAXI(inlink->w, s->w),
+                                  FFMAXI(inlink->h, s->h));
         if (!out) {
             av_frame_free(&in);
             return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_perspective.c b/libavfilter/vf_perspective.c
index 58510f6f138..68e2b8abf60 100644
--- a/libavfilter/vf_perspective.c
+++ b/libavfilter/vf_perspective.c
@@ -474,7 +474,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
                          .hsub = hsub,
                          .vsub = vsub };
         ff_filter_execute(ctx, s->perspective, &td, NULL,
-                          FFMIN(td.h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(td.h, ff_filter_get_nb_threads(ctx)));
     }
 
     av_frame_free(&frame);
diff --git a/libavfilter/vf_photosensitivity.c b/libavfilter/vf_photosensitivity.c
index 7c8476b446e..aad6dcd034a 100644
--- a/libavfilter/vf_photosensitivity.c
+++ b/libavfilter/vf_photosensitivity.c
@@ -131,7 +131,7 @@ static void convert_frame(AVFilterContext *ctx, AVFrame *in, PhotosensitivityFra
     td.out = out;
     td.skip = skip;
     ff_filter_execute(ctx, convert_frame_partial, &td, NULL,
-                      FFMIN(NUM_CELLS, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(NUM_CELLS, ff_filter_get_nb_threads(ctx)));
 }
 
 typedef struct ThreadData_blend_frame
@@ -171,7 +171,7 @@ static void blend_frame(AVFilterContext *ctx, AVFrame *target, AVFrame *source,
     td.source = source;
     td.s_mul = (uint16_t)(factor * 0x100);
     ff_filter_execute(ctx, blend_frame_partial, &td, NULL,
-                      FFMIN(ctx->outputs[0]->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(ctx->outputs[0]->h, ff_filter_get_nb_threads(ctx)));
 }
 
 static int get_badness(PhotosensitivityFrame *a, PhotosensitivityFrame *b)
diff --git a/libavfilter/vf_pixelize.c b/libavfilter/vf_pixelize.c
index a6f0e38dd77..b0dd7bf76fa 100644
--- a/libavfilter/vf_pixelize.c
+++ b/libavfilter/vf_pixelize.c
@@ -129,7 +129,7 @@ static int pixelize_min##name(const uint8_t *ssrc, uint8_t *ddst, \
                                                   \
     for (int y = 0; y < h; y++) {                 \
         for (int x = 0; x < w; x++)               \
-            fill = FFMIN(src[x], fill);           \
+            fill = FFMINI(src[x], fill);           \
                                                   \
         src += src_linesize / sizeof(type);       \
     }                                             \
@@ -155,7 +155,7 @@ static int pixelize_max##name(const uint8_t *ssrc, uint8_t *ddst, \
                                                   \
     for (int y = 0; y < h; y++) {                 \
         for (int x = 0; x < w; x++)               \
-            fill = FFMAX(src[x], fill);           \
+            fill = FFMAXI(src[x], fill);           \
                                                   \
         src += src_linesize / sizeof(type);       \
     }                                             \
@@ -208,9 +208,9 @@ static int pixelize_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_job
         }
 
         for (int y = slice_start; y < slice_end; y++) {
-            const int block_h = FFMIN(s->block_h[p], s->planeheight[p] - y * s->block_h[p]);
+            const int block_h = FFMINI(s->block_h[p], s->planeheight[p] - y * s->block_h[p]);
             for (int x = 0; x < w; x++) {
-                const int block_w = FFMIN(s->block_w[p], s->planewidth[p] - x * s->block_w[p]);
+                const int block_w = FFMINI(s->block_w[p], s->planewidth[p] - x * s->block_w[p]);
 
                 s->pixelize[mode](src + s->block_h[p] * y * in_linesize  +
                                   x * s->block_w[p] * (1 + (s->depth > 8)),
@@ -266,10 +266,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     AVFrame *out;
     int ret;
 
-    s->block_w[1] = s->block_w[2] = FFMAX(1, s->block_w[0] >> s->log2_chroma_w);
+    s->block_w[1] = s->block_w[2] = FFMAXI(1, s->block_w[0] >> s->log2_chroma_w);
     s->block_w[3] = s->block_w[0] = s->block_w[1] << s->log2_chroma_w;
 
-    s->block_h[1] = s->block_h[2] = FFMAX(1, s->block_h[0] >> s->log2_chroma_h);
+    s->block_h[1] = s->block_h[2] = FFMAXI(1, s->block_h[0] >> s->log2_chroma_h);
     s->block_h[3] = s->block_h[0] = s->block_h[1] << s->log2_chroma_h;
 
     if (av_frame_is_writable(in)) {
@@ -291,7 +291,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = in;
     ff_filter_execute(ctx, pixelize_slice, &td, NULL,
-                      FFMIN((s->planeheight[1] + s->block_h[1] - 1) / s->block_h[1],
+                      FFMINI((s->planeheight[1] + s->block_h[1] - 1) / s->block_h[1],
                             ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
diff --git a/libavfilter/vf_pp7.c b/libavfilter/vf_pp7.c
index e7aae87df09..908d4aa30fc 100644
--- a/libavfilter/vf_pp7.c
+++ b/libavfilter/vf_pp7.c
@@ -91,7 +91,7 @@ static void init_thres2(PP7Context *p)
 
     for (qp = 0; qp < 99; qp++) {
         for (i = 0; i < 16; i++) {
-            p->thres2[qp][i] = ((i&1) ? SN2 : SN0) * ((i&4) ? SN2 : SN0) * FFMAX(1, qp) * (1<<2) - 1 - bias;
+            p->thres2[qp][i] = ((i&1) ? SN2 : SN0) * ((i&4) ? SN2 : SN0) * FFMAXI(1, qp) * (1<<2) - 1 - bias;
         }
     }
 }
@@ -239,12 +239,12 @@ static void filter(PP7Context *p, uint8_t *dst, uint8_t *src,
         for (x = 0; x < width; ) {
             const int qps = 3 + is_luma;
             int qp;
-            int end = FFMIN(x + 8, width);
+            int end = FFMINI(x + 8, width);
 
             if (p->qp)
                 qp = p->qp;
             else {
-                qp = qp_store[ (FFMIN(x, width - 1) >> qps) + (FFMIN(y, height - 1) >> qps) * qp_stride];
+                qp = qp_store[ (FFMINI(x, width - 1) >> qps) + (FFMINI(y, height - 1) >> qps) * qp_stride];
                 qp = ff_norm_qscale(qp, p->qscale_type);
             }
             for (; x < end; x++) {
diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c
index 322fc390943..384eb5a4efb 100644
--- a/libavfilter/vf_premultiply.c
+++ b/libavfilter/vf_premultiply.c
@@ -281,7 +281,7 @@ static void unpremultiply8(const uint8_t *msrc, const uint8_t *asrc,
     for (y = 0; y < h; y++) {
         for (x = 0; x < w; x++) {
             if (asrc[x] > 0 && asrc[x] < 255)
-                dst[x] = FFMIN(msrc[x] * 255 / asrc[x], 255);
+                dst[x] = FFMINI(msrc[x] * 255 / asrc[x], 255);
             else
                 dst[x] = msrc[x];
         }
@@ -304,7 +304,7 @@ static void unpremultiply8yuv(const uint8_t *msrc, const uint8_t *asrc,
     for (y = 0; y < h; y++) {
         for (x = 0; x < w; x++) {
             if (asrc[x] > 0 && asrc[x] < 255)
-                dst[x] = FFMIN((msrc[x] - 128) * 255 / asrc[x] + 128, 255);
+                dst[x] = FFMINI((msrc[x] - 128) * 255 / asrc[x] + 128, 255);
             else
                 dst[x] = msrc[x];
         }
@@ -327,7 +327,7 @@ static void unpremultiply8offset(const uint8_t *msrc, const uint8_t *asrc,
     for (y = 0; y < h; y++) {
         for (x = 0; x < w; x++) {
             if (asrc[x] > 0 && asrc[x] < 255)
-                dst[x] = FFMIN(FFMAX(msrc[x] - offset, 0) * 255 / asrc[x] + offset, 255);
+                dst[x] = FFMINI(FFMAXI(msrc[x] - offset, 0) * 255 / asrc[x] + offset, 255);
             else
                 dst[x] = msrc[x];
         }
@@ -353,7 +353,7 @@ static void unpremultiply16(const uint8_t *mmsrc, const uint8_t *aasrc,
     for (y = 0; y < h; y++) {
         for (x = 0; x < w; x++) {
             if (asrc[x] > 0 && asrc[x] < max)
-                dst[x] = FFMIN(msrc[x] * (unsigned)max / asrc[x], max);
+                dst[x] = FFMINI(msrc[x] * (unsigned)max / asrc[x], max);
             else
                 dst[x] = msrc[x];
         }
@@ -379,7 +379,7 @@ static void unpremultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc,
     for (y = 0; y < h; y++) {
         for (x = 0; x < w; x++) {
             if (asrc[x] > 0 && asrc[x] < max)
-                dst[x] = FFMAX(FFMIN((msrc[x] - half) * max / asrc[x], half - 1), -half) + half;
+                dst[x] = FFMAXI(FFMINI((msrc[x] - half) * max / asrc[x], half - 1), -half) + half;
             else
                 dst[x] = msrc[x];
         }
@@ -405,7 +405,7 @@ static void unpremultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc,
     for (y = 0; y < h; y++) {
         for (x = 0; x < w; x++) {
             if (asrc[x] > 0 && asrc[x] < max)
-                dst[x] = FFMAX(FFMIN(FFMAX(msrc[x] - offset, 0) * (unsigned)max / asrc[x] + offset, max), 0);
+                dst[x] = FFMAXI(FFMINI(FFMAXI(msrc[x] - offset, 0) * (unsigned)max / asrc[x] + offset, max), 0);
             else
                 dst[x] = msrc[x];
         }
@@ -639,7 +639,7 @@ static int filter_frame(AVFilterContext *ctx,
         td.a = alpha;
         td.m = base;
         ff_filter_execute(ctx, premultiply_slice, &td, NULL,
-                          FFMIN(s->height[0], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->height[0], ff_filter_get_nb_threads(ctx)));
     }
 
     return 0;
diff --git a/libavfilter/vf_pseudocolor.c b/libavfilter/vf_pseudocolor.c
index 7d5657f26cc..304bb49c55a 100644
--- a/libavfilter/vf_pseudocolor.c
+++ b/libavfilter/vf_pseudocolor.c
@@ -1016,7 +1016,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.out = out, td.in = in;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->height[1], ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_pullup.c b/libavfilter/vf_pullup.c
index 1e4289aab1e..527a0f04521 100644
--- a/libavfilter/vf_pullup.c
+++ b/libavfilter/vf_pullup.c
@@ -383,8 +383,8 @@ static void compute_affinity(PullupContext *s, PullupField *f)
         int lc = f->      combs[i] - 2*(v < lv ? v : lv);
         int rc = f->next->combs[i] - 2*(v < rv ? v : rv);
 
-        lc = FFMAX(lc, 0);
-        rc = FFMAX(rc, 0);
+        lc = FFMAXI(lc, 0);
+        rc = FFMAXI(rc, 0);
         l  = lc - rc;
 
         if ( l > max_l)
diff --git a/libavfilter/vf_readeia608.c b/libavfilter/vf_readeia608.c
index 605ca86d173..c89f6b1a781 100644
--- a/libavfilter/vf_readeia608.c
+++ b/libavfilter/vf_readeia608.c
@@ -320,12 +320,12 @@ static void read_##name(AVFrame *in, int nb_line, LineItem *line, int lp, int w)
                                                                               \
     if (lp) {                                                                 \
         for (int i = 0; i < w; i++) {                                         \
-            int a = FFMAX(i - 3, 0);                                          \
-            int b = FFMAX(i - 2, 0);                                          \
-            int c = FFMAX(i - 1, 0);                                          \
-            int d = FFMIN(i + 3, w-1);                                        \
-            int e = FFMIN(i + 2, w-1);                                        \
-            int f = FFMIN(i + 1, w-1);                                        \
+            int a = FFMAXI(i - 3, 0);                                          \
+            int b = FFMAXI(i - 2, 0);                                          \
+            int c = FFMAXI(i - 1, 0);                                          \
+            int d = FFMINI(i + 3, w-1);                                        \
+            int e = FFMINI(i + 2, w-1);                                        \
+            int f = FFMINI(i + 1, w-1);                                        \
                                                                               \
             line[LAG + i].input = (src[a] + src[b] + src[c] + src[i] +        \
                                    src[d] + src[e] + src[f] + 6) / 7;         \
@@ -467,7 +467,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     int nb_found;
 
     ff_filter_execute(ctx, extract_lines, in, NULL,
-                      FFMIN(FFMAX(s->end - s->start + 1, 1), ff_filter_get_nb_threads(ctx)));
+                      FFMINI(FFMAXI(s->end - s->start + 1, 1), ff_filter_get_nb_threads(ctx)));
 
     nb_found = 0;
     for (int i = 0; i < s->end - s->start + 1; i++) {
diff --git a/libavfilter/vf_readvitc.c b/libavfilter/vf_readvitc.c
index fa3953a4266..fd5faa17e7c 100644
--- a/libavfilter/vf_readvitc.c
+++ b/libavfilter/vf_readvitc.c
@@ -92,7 +92,7 @@ static int read_vitc_line( ReadVitcContext *ctx, uint8_t *src, int line_size, in
     int x, y, res = 0;
 
     if (ctx->scan_max >= 0)
-        height = FFMIN(height, ctx->scan_max);
+        height = FFMINI(height, ctx->scan_max);
 
     // scan lines for VITC data, starting from the top
     for (y = 0; y < height; y++) {
@@ -106,7 +106,7 @@ static int read_vitc_line( ReadVitcContext *ctx, uint8_t *src, int line_size, in
                 x++;
             while ((x < width) && (scan_line[x] > ctx->threshold_black))
                 x++;
-            x = FFMAX(x - ((ctx->grp_width+10) / 20), 1);  // step back a half pit
+            x = FFMAXI(x - ((ctx->grp_width+10) / 20), 1);  // step back a half pit
             grp_start_pos = x;
             if ((grp_start_pos + ctx->grp_width) > width)
                 break;  // not enough pixels for reading a whole pit group
diff --git a/libavfilter/vf_remap.c b/libavfilter/vf_remap.c
index 8146159d93d..0093dd40e64 100644
--- a/libavfilter/vf_remap.c
+++ b/libavfilter/vf_remap.c
@@ -301,7 +301,7 @@ static int process_frame(FFFrameSync *fs)
         td.nb_components = s->nb_components;
         td.step = s->step;
         ff_filter_execute(ctx, s->remap_slice, &td, NULL,
-                          FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
     }
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
diff --git a/libavfilter/vf_remap_opencl.c b/libavfilter/vf_remap_opencl.c
index bb83944b2f5..deb00019679 100644
--- a/libavfilter/vf_remap_opencl.c
+++ b/libavfilter/vf_remap_opencl.c
@@ -98,7 +98,7 @@ static int remap_opencl_load(AVFilterContext *avctx,
 
     main_planes = 0;
     for (int i = 0; i < main_desc->nb_components; i++)
-        main_planes = FFMAX(main_planes,
+        main_planes = FFMAXI(main_planes,
                             main_desc->comp[i].plane + 1);
 
     ctx->nb_planes = main_planes;
diff --git a/libavfilter/vf_removegrain.c b/libavfilter/vf_removegrain.c
index 3209c7db862..7a54934a519 100644
--- a/libavfilter/vf_removegrain.c
+++ b/libavfilter/vf_removegrain.c
@@ -55,19 +55,19 @@ static const enum AVPixelFormat pix_fmts[] = {
 };
 
 #define REMOVE_GRAIN_SORT_AXIS       \
-    const int ma1 = FFMAX(a1, a8);   \
-    const int mi1 = FFMIN(a1, a8);   \
-    const int ma2 = FFMAX(a2, a7);   \
-    const int mi2 = FFMIN(a2, a7);   \
-    const int ma3 = FFMAX(a3, a6);   \
-    const int mi3 = FFMIN(a3, a6);   \
-    const int ma4 = FFMAX(a4, a5);   \
-    const int mi4 = FFMIN(a4, a5);
+    const int ma1 = FFMAXI(a1, a8);   \
+    const int mi1 = FFMINI(a1, a8);   \
+    const int ma2 = FFMAXI(a2, a7);   \
+    const int mi2 = FFMINI(a2, a7);   \
+    const int ma3 = FFMAXI(a3, a6);   \
+    const int mi3 = FFMINI(a3, a6);   \
+    const int ma4 = FFMAXI(a4, a5);   \
+    const int mi4 = FFMINI(a4, a5);
 
 static int mode01(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
 {
-    const int mi = FFMIN(FFMIN(FFMIN(a1, a2), FFMIN(a3, a4)), FFMIN(FFMIN(a5, a6), FFMIN(a7, a8)));
-    const int ma = FFMAX(FFMAX(FFMAX(a1, a2), FFMAX(a3, a4)), FFMAX(FFMAX(a5, a6), FFMAX(a7, a8)));
+    const int mi = FFMINI(FFMINI(FFMINI(a1, a2), FFMINI(a3, a4)), FFMINI(FFMINI(a5, a6), FFMINI(a7, a8)));
+    const int ma = FFMAXI(FFMAXI(FFMAXI(a1, a2), FFMAXI(a3, a4)), FFMAXI(FFMAXI(a5, a6), FFMAXI(a7, a8)));
 
     return av_clip(c, mi, ma);
 }
@@ -115,7 +115,7 @@ static int mode05(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int c3 = FFABS(c - av_clip(c, mi3, ma3));
     const int c4 = FFABS(c - av_clip(c, mi4, ma4));
 
-    const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4));
+    const int mindiff = FFMINI(FFMINI(c1, c2), FFMINI(c3, c4));
 
     /* When adding SIMD notice the return order here: 4, 2, 3, 1. */
     if (mindiff == c4) {
@@ -148,7 +148,7 @@ static int mode06(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int c3 = av_clip_uint16((FFABS(c - cli3) << 1) + d3);
     const int c4 = av_clip_uint16((FFABS(c - cli4) << 1) + d4);
 
-    const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4));
+    const int mindiff = FFMINI(FFMINI(c1, c2), FFMINI(c3, c4));
 
     if (mindiff == c4) {
         return cli4;
@@ -180,7 +180,7 @@ static int mode07(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int c3 = FFABS(c - cli3) + d3;
     const int c4 = FFABS(c - cli4) + d4;
 
-    const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4));
+    const int mindiff = FFMINI(FFMINI(c1, c2), FFMINI(c3, c4));
 
     if (mindiff == c4) {
         return cli4;
@@ -212,7 +212,7 @@ static int mode08(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int c3 = av_clip_uint16(FFABS(c - cli3) + (d3 << 1));
     const int c4 = av_clip_uint16(FFABS(c - cli4) + (d4 << 1));
 
-    const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4));
+    const int mindiff = FFMINI(FFMINI(c1, c2), FFMINI(c3, c4));
 
     if (mindiff == c4) {
         return cli4;
@@ -234,7 +234,7 @@ static int mode09(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int d3 = ma3 - mi3;
     const int d4 = ma4 - mi4;
 
-    const int mindiff = FFMIN(FFMIN(d1, d2), FFMIN(d3, d4));
+    const int mindiff = FFMINI(FFMINI(d1, d2), FFMINI(d3, d4));
 
     if (mindiff == d4) {
         return av_clip(c, mi4, ma4);
@@ -258,8 +258,8 @@ static int mode10(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int d7 = FFABS(c - a7);
     const int d8 = FFABS(c - a8);
 
-    const int mindiff = FFMIN(FFMIN(FFMIN(d1, d2), FFMIN(d3, d4)),
-                              FFMIN(FFMIN(d5, d6), FFMIN(d7, d8)));
+    const int mindiff = FFMINI(FFMINI(FFMINI(d1, d2), FFMINI(d3, d4)),
+                              FFMINI(FFMINI(d5, d6), FFMINI(d7, d8)));
 
     if (mindiff == d7) return a7;
     if (mindiff == d8) return a8;
@@ -286,7 +286,7 @@ static int mode1314(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a
     const int d2 = FFABS(a2 - a7);
     const int d3 = FFABS(a3 - a6);
 
-    const int mindiff = FFMIN(FFMIN(d1, d2), d3);
+    const int mindiff = FFMINI(FFMINI(d1, d2), d3);
 
     if (mindiff == d2) {
         return (a2 + a7 + 1) >> 1;
@@ -304,49 +304,49 @@ static int mode1516(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a
     const int d2 = FFABS(a2 - a7);
     const int d3 = FFABS(a3 - a6);
 
-    const int mindiff = FFMIN(FFMIN(d1, d2), d3);
+    const int mindiff = FFMINI(FFMINI(d1, d2), d3);
     const int average = (2 * (a2 + a7) + a1 + a3 + a6 + a8 + 4) >> 3;
 
     if (mindiff == d2) {
-        return av_clip(average, FFMIN(a2, a7), FFMAX(a2, a7));
+        return av_clip(average, FFMINI(a2, a7), FFMAXI(a2, a7));
     }
     if (mindiff == d3) {
-        return av_clip(average, FFMIN(a3, a6), FFMAX(a3, a6));
+        return av_clip(average, FFMINI(a3, a6), FFMAXI(a3, a6));
     }
 
-    return av_clip(average, FFMIN(a1, a8), FFMAX(a1, a8));
+    return av_clip(average, FFMINI(a1, a8), FFMAXI(a1, a8));
 }
 
 static int mode17(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
 {
     REMOVE_GRAIN_SORT_AXIS
 
-    const int l = FFMAX(FFMAX(mi1, mi2), FFMAX(mi3, mi4));
-    const int u = FFMIN(FFMIN(ma1, ma2), FFMIN(ma3, ma4));
+    const int l = FFMAXI(FFMAXI(mi1, mi2), FFMAXI(mi3, mi4));
+    const int u = FFMINI(FFMINI(ma1, ma2), FFMINI(ma3, ma4));
 
-    return av_clip(c, FFMIN(l, u), FFMAX(l, u));
+    return av_clip(c, FFMINI(l, u), FFMAXI(l, u));
 }
 
 static int mode18(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
 {
-    const int d1 = FFMAX(FFABS(c - a1), FFABS(c - a8));
-    const int d2 = FFMAX(FFABS(c - a2), FFABS(c - a7));
-    const int d3 = FFMAX(FFABS(c - a3), FFABS(c - a6));
-    const int d4 = FFMAX(FFABS(c - a4), FFABS(c - a5));
+    const int d1 = FFMAXI(FFABS(c - a1), FFABS(c - a8));
+    const int d2 = FFMAXI(FFABS(c - a2), FFABS(c - a7));
+    const int d3 = FFMAXI(FFABS(c - a3), FFABS(c - a6));
+    const int d4 = FFMAXI(FFABS(c - a4), FFABS(c - a5));
 
-    const int mindiff = FFMIN(FFMIN(d1, d2), FFMIN(d3, d4));
+    const int mindiff = FFMINI(FFMINI(d1, d2), FFMINI(d3, d4));
 
     if (mindiff == d4) {
-        return av_clip(c, FFMIN(a4, a5), FFMAX(a4, a5));
+        return av_clip(c, FFMINI(a4, a5), FFMAXI(a4, a5));
     }
     if (mindiff == d2) {
-        return av_clip(c, FFMIN(a2, a7), FFMAX(a2, a7));
+        return av_clip(c, FFMINI(a2, a7), FFMAXI(a2, a7));
     }
     if (mindiff == d3) {
-        return av_clip(c, FFMIN(a3, a6), FFMAX(a3, a6));
+        return av_clip(c, FFMINI(a3, a6), FFMAXI(a3, a6));
     }
 
-    return av_clip(c, FFMIN(a1, a8), FFMAX(a1, a8));
+    return av_clip(c, FFMINI(a1, a8), FFMAXI(a1, a8));
 }
 
 static int mode19(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
@@ -377,8 +377,8 @@ static int mode21(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int l3h = (a3 + a6 + 1) >> 1;
     const int l4h = (a4 + a5 + 1) >> 1;
 
-    const int mi = FFMIN(FFMIN(l1l, l2l), FFMIN(l3l, l4l));
-    const int ma = FFMAX(FFMAX(l1h, l2h), FFMAX(l3h, l4h));
+    const int mi = FFMINI(FFMINI(l1l, l2l), FFMINI(l3l, l4l));
+    const int ma = FFMAXI(FFMAXI(l1h, l2h), FFMAXI(l3h, l4h));
 
     return av_clip(c, mi, ma);
 }
@@ -390,8 +390,8 @@ static int mode22(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int l3 = (a3 + a6 + 1) >> 1;
     const int l4 = (a4 + a5 + 1) >> 1;
 
-    const int mi = FFMIN(FFMIN(l1, l2), FFMIN(l3, l4));
-    const int ma = FFMAX(FFMAX(l1, l2), FFMAX(l3, l4));
+    const int mi = FFMINI(FFMINI(l1, l2), FFMINI(l3, l4));
+    const int ma = FFMAXI(FFMAXI(l1, l2), FFMAXI(l3, l4));
 
     return av_clip(c, mi, ma);
 }
@@ -405,17 +405,17 @@ static int mode23(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int linediff3 = ma3 - mi3;
     const int linediff4 = ma4 - mi4;
 
-    const int u1 = FFMIN(c - ma1, linediff1);
-    const int u2 = FFMIN(c - ma2, linediff2);
-    const int u3 = FFMIN(c - ma3, linediff3);
-    const int u4 = FFMIN(c - ma4, linediff4);
-    const int u = FFMAX(FFMAX(FFMAX(u1, u2), FFMAX(u3, u4)), 0);
+    const int u1 = FFMINI(c - ma1, linediff1);
+    const int u2 = FFMINI(c - ma2, linediff2);
+    const int u3 = FFMINI(c - ma3, linediff3);
+    const int u4 = FFMINI(c - ma4, linediff4);
+    const int u = FFMAXI(FFMAXI(FFMAXI(u1, u2), FFMAXI(u3, u4)), 0);
 
-    const int d1 = FFMIN(mi1 - c, linediff1);
-    const int d2 = FFMIN(mi2 - c, linediff2);
-    const int d3 = FFMIN(mi3 - c, linediff3);
-    const int d4 = FFMIN(mi4 - c, linediff4);
-    const int d = FFMAX(FFMAX(FFMAX(d1, d2), FFMAX(d3, d4)), 0);
+    const int d1 = FFMINI(mi1 - c, linediff1);
+    const int d2 = FFMINI(mi2 - c, linediff2);
+    const int d3 = FFMINI(mi3 - c, linediff3);
+    const int d4 = FFMINI(mi4 - c, linediff4);
+    const int d = FFMAXI(FFMAXI(FFMAXI(d1, d2), FFMAXI(d3, d4)), 0);
 
     return c - u + d;  // This probably will never overflow.
 }
@@ -434,22 +434,22 @@ static int mode24(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
     const int tu3 = c - ma3;
     const int tu4 = c - ma4;
 
-    const int u1 = FFMIN(tu1, linediff1 - tu1);
-    const int u2 = FFMIN(tu2, linediff2 - tu2);
-    const int u3 = FFMIN(tu3, linediff3 - tu3);
-    const int u4 = FFMIN(tu4, linediff4 - tu4);
-    const int u = FFMAX(FFMAX(FFMAX(u1, u2), FFMAX(u3, u4)), 0);
+    const int u1 = FFMINI(tu1, linediff1 - tu1);
+    const int u2 = FFMINI(tu2, linediff2 - tu2);
+    const int u3 = FFMINI(tu3, linediff3 - tu3);
+    const int u4 = FFMINI(tu4, linediff4 - tu4);
+    const int u = FFMAXI(FFMAXI(FFMAXI(u1, u2), FFMAXI(u3, u4)), 0);
 
     const int td1 = mi1 - c;
     const int td2 = mi2 - c;
     const int td3 = mi3 - c;
     const int td4 = mi4 - c;
 
-    const int d1 = FFMIN(td1, linediff1 - td1);
-    const int d2 = FFMIN(td2, linediff2 - td2);
-    const int d3 = FFMIN(td3, linediff3 - td3);
-    const int d4 = FFMIN(td4, linediff4 - td4);
-    const int d = FFMAX(FFMAX(FFMAX(d1, d2), FFMAX(d3, d4)), 0);
+    const int d1 = FFMINI(td1, linediff1 - td1);
+    const int d2 = FFMINI(td2, linediff2 - td2);
+    const int d3 = FFMINI(td3, linediff3 - td3);
+    const int d4 = FFMINI(td4, linediff4 - td4);
+    const int d = FFMAXI(FFMAXI(FFMAXI(d1, d2), FFMAXI(d3, d4)), 0);
 
     return c - u + d;  // This probably will never overflow.
 }
@@ -527,8 +527,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
     int end   = (height * (jobnr+1)) / nb_jobs;
     int x, y;
 
-    start = FFMAX(1, start);
-    end   = FFMIN(height-1, end);
+    start = FFMAXI(1, start);
+    end   = FFMINI(height-1, end);
     for (y = start; y < end; y++) {
         uint8_t *dst = out->data[i];
         uint8_t *src = in->data[i];
@@ -611,7 +611,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         td.in = in; td.out = out; td.plane = i;
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN(s->planeheight[i], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->planeheight[i], ff_filter_get_nb_threads(ctx)));
 
         src = in->data[i] + (s->planeheight[i] - 1) * in->linesize[i];
         dst = out->data[i] + (s->planeheight[i] - 1) * out->linesize[i];
diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c
index 49259026ff6..1ef3ea598b1 100644
--- a/libavfilter/vf_removelogo.c
+++ b/libavfilter/vf_removelogo.c
@@ -262,7 +262,7 @@ static void generate_half_size_image(const uint8_t *src_data, int src_linesize,
                 src_data[((y << 1) * src_linesize) + (x << 1) + 1] ||
                 src_data[(((y << 1) + 1) * src_linesize) + (x << 1)] ||
                 src_data[(((y << 1) + 1) * src_linesize) + (x << 1) + 1];
-            dst_data[(y * dst_linesize) + x] = FFMIN(1, dst_data[(y * dst_linesize) + x]);
+            dst_data[(y * dst_linesize) + x] = FFMINI(1, dst_data[(y * dst_linesize) + x]);
         }
     }
 
@@ -299,7 +299,7 @@ static av_cold int init(AVFilterContext *ctx)
                              s->half_mask_data, w/2,
                              w, h, &half_max_mask_size);
 
-    s->max_mask_size = FFMAX(full_max_mask_size, half_max_mask_size);
+    s->max_mask_size = FFMAXI(full_max_mask_size, half_max_mask_size);
 
     /* Create a circular mask for each size up to max_mask_size. When
        the filter is applied, the mask size is determined on a pixel
@@ -394,10 +394,10 @@ static unsigned int blur_pixel(int ***mask,
 
     /* Prepare our bounding rectangle and clip it if need be. */
     mask_size  = mask_data[y * mask_linesize + x];
-    start_posx = FFMAX(0, x - mask_size);
-    start_posy = FFMAX(0, y - mask_size);
-    end_posx   = FFMIN(w - 1, x + mask_size);
-    end_posy   = FFMIN(h - 1, y + mask_size);
+    start_posx = FFMAXI(0, x - mask_size);
+    start_posy = FFMAXI(0, y - mask_size);
+    end_posx   = FFMINI(w - 1, x + mask_size);
+    end_posy   = FFMINI(h - 1, y + mask_size);
 
     image_read_position = image_data + image_linesize * start_posy + start_posx;
     mask_read_position  = mask_data  + mask_linesize  * start_posy + start_posx;
diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c
index 3dc57bbb086..f436427ed6f 100644
--- a/libavfilter/vf_rotate.c
+++ b/libavfilter/vf_rotate.c
@@ -163,8 +163,8 @@ static double get_rotated_w(void *opaque, double angle)
     float sinx = sin(angle);
     float cosx = cos(angle);
 
-    return FFMAX(0, inh * sinx) + FFMAX(0, -inw * cosx) +
-           FFMAX(0, inw * cosx) + FFMAX(0, -inh * sinx);
+    return FFMAXD(0, inh * sinx) + FFMAXD(0, -inw * cosx) +
+           FFMAXD(0, inw * cosx) + FFMAXD(0, -inh * sinx);
 }
 
 static double get_rotated_h(void *opaque, double angle)
@@ -175,8 +175,8 @@ static double get_rotated_h(void *opaque, double angle)
     float sinx = sin(angle);
     float cosx = cos(angle);
 
-    return FFMAX(0, -inh * cosx) + FFMAX(0, -inw * sinx) +
-           FFMAX(0,  inh * cosx) + FFMAX(0,  inw * sinx);
+    return FFMAXD(0, -inh * cosx) + FFMAXD(0, -inw * sinx) +
+           FFMAXD(0,  inh * cosx) + FFMAXD(0,  inw * sinx);
 }
 
 static double (* const func1[])(void *, double) = {
@@ -231,8 +231,8 @@ static uint8_t *interpolate_bilinear8(uint8_t *dst_color,
     int frac_x = x&0xFFFF;
     int frac_y = y&0xFFFF;
     int i;
-    int int_x1 = FFMIN(int_x+1, max_x);
-    int int_y1 = FFMIN(int_y+1, max_y);
+    int int_x1 = FFMINI(int_x+1, max_x);
+    int int_y1 = FFMINI(int_y+1, max_y);
 
     for (i = 0; i < src_linestep; i++) {
         int s00 = src[src_linestep * int_x  + i + src_linesize * int_y ];
@@ -261,8 +261,8 @@ static uint8_t *interpolate_bilinear16(uint8_t *dst_color,
     int64_t frac_x = x&0xFFFF;
     int64_t frac_y = y&0xFFFF;
     int i;
-    int int_x1 = FFMIN(int_x+1, max_x);
-    int int_y1 = FFMIN(int_y+1, max_y);
+    int int_x1 = FFMINI(int_x+1, max_x);
+    int int_y1 = FFMINI(int_y+1, max_y);
 
     for (i = 0; i < src_linestep; i+=2) {
         int s00 = AV_RL16(&src[src_linestep * int_x  + i + src_linesize * int_y ]);
@@ -547,7 +547,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                           .plane = plane, .c = c, .s = s };
 
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN(outh, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(outh, ff_filter_get_nb_threads(ctx)));
     }
 
     av_frame_free(&in);
diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index 44eef207ca8..5e8c13839d5 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -212,7 +212,7 @@ static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_
     for (i = 0; i < s->in_desc->nb_components; i++) {
         d = (s->in_desc->comp[i].depth + 7) / 8;
         p = s->in_desc->comp[i].plane;
-        s->in_plane_channels[p] = FFMAX(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
+        s->in_plane_channels[p] = FFMAXI(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
 
         s->in_plane_depths[p] = s->in_desc->comp[i].depth;
     }
diff --git a/libavfilter/vf_scdet.c b/libavfilter/vf_scdet.c
index 1568a0a4960..0bdef766bdb 100644
--- a/libavfilter/vf_scdet.c
+++ b/libavfilter/vf_scdet.c
@@ -128,7 +128,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
 
         mafd = (double)sad * 100. / count / (1ULL << s->bitdepth);
         diff = fabs(mafd - s->prev_mafd);
-        ret  = av_clipf(FFMIN(mafd, diff), 0, 100.);
+        ret  = av_clipf(FFMIND(mafd, diff), 0, 100.);
         s->prev_mafd = mafd;
         av_frame_free(&prev_picref);
     }
diff --git a/libavfilter/vf_scdet_vulkan.c b/libavfilter/vf_scdet_vulkan.c
index fadc0842aeb..1e963b3661d 100644
--- a/libavfilter/vf_scdet_vulkan.c
+++ b/libavfilter/vf_scdet_vulkan.c
@@ -171,7 +171,7 @@ static double evaluate(AVFilterContext *ctx, const SceneDetectBuf *buf)
     diff = fabs(mafd - s->prev_mafd);
     s->prev_mafd = mafd;
 
-    return av_clipf(FFMIN(mafd, diff), 0.0, 100.0);
+    return av_clipf(FFMIND(mafd, diff), 0.0, 100.0);
 }
 
 static int scdet_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
diff --git a/libavfilter/vf_scroll.c b/libavfilter/vf_scroll.c
index cd728a4968a..97281b87341 100644
--- a/libavfilter/vf_scroll.c
+++ b/libavfilter/vf_scroll.c
@@ -124,7 +124,7 @@ static void scroll(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
 
     td.in = in; td.out = out;
     ff_filter_execute(ctx, scroll_slice, &td, NULL,
-                      FFMIN(out->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(out->height, ff_filter_get_nb_threads(ctx)));
 
     s->h_pos += s->h_speed * in->width;
     s->v_pos += s->v_speed * in->height;
diff --git a/libavfilter/vf_shear.c b/libavfilter/vf_shear.c
index 2e558c00443..f9e5286b6a9 100644
--- a/libavfilter/vf_shear.c
+++ b/libavfilter/vf_shear.c
@@ -196,8 +196,8 @@ static int filter_slice_bl##name(AVFilterContext *ctx, void *arg, int jobnr, \
                     int ay = floorf(sy);                                     \
                     float du = sx - ax;                                      \
                     float dv = sy - ay;                                      \
-                    int bx = FFMIN(ax + 1, width - 1);                       \
-                    int by = FFMIN(ay + 1, height - 1);                      \
+                    int bx = FFMINI(ax + 1, width - 1);                       \
+                    int by = FFMINI(ay + 1, height - 1);                      \
                                                                              \
                     sum += (1.f - du) * (1.f - dv) * src[ay * src_linesize + ax];\
                     sum += (      du) * (1.f - dv) * src[ay * src_linesize + bx];\
@@ -239,7 +239,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in, td.out = out;
     ff_filter_execute(ctx, s->filter_slice[s->interp], &td, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_shufflepixels.c b/libavfilter/vf_shufflepixels.c
index 3ba950f7b69..c2e8cb2a02b 100644
--- a/libavfilter/vf_shufflepixels.c
+++ b/libavfilter/vf_shufflepixels.c
@@ -82,10 +82,10 @@ static void make_horizontal_map(AVFilterContext *ctx)
             int width;
 
             if (s->direction) {
-                width = FFMIN(s->block_w, s->planewidth[0] - x);
+                width = FFMINI(s->block_w, s->planewidth[0] - x);
                 map[rand * s->block_w] = x;
             } else {
-                width = FFMIN(s->block_w, s->planewidth[0] - rand * s->block_w);
+                width = FFMINI(s->block_w, s->planewidth[0] - rand * s->block_w);
                 map[x] = rand * s->block_w;
             }
             used[rand] = 1;
@@ -120,10 +120,10 @@ static void make_vertical_map(AVFilterContext *ctx)
             int height;
 
             if (s->direction) {
-                height = FFMIN(s->block_h, s->planeheight[0] - y);
+                height = FFMINI(s->block_h, s->planeheight[0] - y);
                 map[rand * s->block_h] = y;
             } else {
-                height = FFMIN(s->block_h, s->planeheight[0] - rand * s->block_h);
+                height = FFMINI(s->block_h, s->planeheight[0] - rand * s->block_h);
                 map[y] = rand * s->block_h;
             }
             used[rand] = 1;
@@ -384,7 +384,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = in;
     ff_filter_execute(ctx, s->shuffle_pixels, &td, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(ctx->outputs[0], out);
diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index 3b6e9f99556..b052b2894b9 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -308,7 +308,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
 
     /* confidence */
     qsort(conflist, DIFFELEM_SIZE, sizeof(uint64_t), cmp);
-    fs->confidence = FFMIN(conflist[DIFFELEM_SIZE/2], 255);
+    fs->confidence = FFMINI(conflist[DIFFELEM_SIZE/2], 255);
 
     /* coarsesignature */
     if (sc->coarsecount == 0) {
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index 15c71cf6b90..f2f7fc7f2e9 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -249,7 +249,7 @@ static int ssim_plane_16bit(AVFilterContext *ctx, void *arg,
         int height = td->planeheight[c];
         const int slice_start = ((height >> 2) * jobnr) / nb_jobs;
         const int slice_end = ((height >> 2) * (jobnr+1)) / nb_jobs;
-        const int ystart = FFMAX(1, slice_start);
+        const int ystart = FFMAXI(1, slice_start);
         int z = ystart - 1;
         double ssim = 0.0;
         int64_t (*sum0)[4] = temp;
@@ -292,7 +292,7 @@ static int ssim_plane(AVFilterContext *ctx, void *arg,
         int height = td->planeheight[c];
         const int slice_start = ((height >> 2) * jobnr) / nb_jobs;
         const int slice_end = ((height >> 2) * (jobnr+1)) / nb_jobs;
-        const int ystart = FFMAX(1, slice_start);
+        const int ystart = FFMAXI(1, slice_start);
         int z = ystart - 1;
         double ssim = 0.0;
         int (*sum0)[4] = temp;
@@ -365,7 +365,7 @@ static int do_ssim(FFFrameSync *fs)
     }
 
     ff_filter_execute(ctx, s->ssim_plane, &td, NULL,
-                      FFMIN((s->planeheight[1] + 3) >> 2, s->nb_threads));
+                      FFMINI((s->planeheight[1] + 3) >> 2, s->nb_threads));
 
     for (i = 0; i < s->nb_components; i++) {
         for (int j = 0; j < s->nb_threads; j++)
diff --git a/libavfilter/vf_ssim360.c b/libavfilter/vf_ssim360.c
index ad357df4278..db82a46f9e2 100644
--- a/libavfilter/vf_ssim360.c
+++ b/libavfilter/vf_ssim360.c
@@ -619,7 +619,7 @@ static float get_radius_between_negative_and_positive_pi(float theta)
     // Convert theta to range [-pi, pi]
     floor_theta_by_pi = theta / M_PI_F;
     theta -= 2.0f * M_PI_F * floor_theta_by_pi;
-    return FFMIN(M_PI_F, FFMAX(-M_PI_F, theta));
+    return FFMINF(M_PI_F, FFMAXF(-M_PI_F, theta));
 }
 
 static float get_heat(HeatmapList *heatmaps, float angular_resoluation, float norm_tape_pos)
@@ -639,8 +639,8 @@ static float get_heat(HeatmapList *heatmaps, float angular_resoluation, float no
     norm_yaw   = yaw / 2.0f / M_PI_F + 0.5f;
 
     // get heat on map
-    w = FFMIN(heatmaps->map.w - 1, FFMAX(0, heatmaps->map.w * norm_yaw));
-    h = FFMIN(heatmaps->map.h - 1, FFMAX(0, heatmaps->map.h * norm_pitch));
+    w = FFMINI(heatmaps->map.w - 1, FFMAXF(0, heatmaps->map.w * norm_yaw));
+    h = FFMINI(heatmaps->map.h - 1, FFMAXF(0, heatmaps->map.h * norm_pitch));
     return heatmaps->map.value[h * heatmaps->map.w + w];
 }
 
@@ -1002,14 +1002,14 @@ static float get_tape_angular_resolution(int projection, float expand_coef, int
         // Approximating atanf(pixel_width / half_face_width) = pixel_width / half_face_width
         return DEFAULT_EXPANSION_COEF / (image_width / 6.f);
     case PROJECTION_BARREL:
-        return FFMAX(BARREL_THETA_RANGE / (0.8f * image_width), BARREL_PHI_RANGE / image_height);
+        return FFMAXF(BARREL_THETA_RANGE / (0.8f * image_width), BARREL_PHI_RANGE / image_height);
     case PROJECTION_BARREL_SPLIT:
-        return FFMAX((expand_coef * M_PI_F) / (2.0f / 3.0f * image_width),
+        return FFMAXF((expand_coef * M_PI_F) / (2.0f / 3.0f * image_width),
                      expand_coef * M_PI_2_F / (image_height / 2.0f));
     // Assume PROJECTION_EQUIRECT as the default
     case PROJECTION_EQUIRECT:
     default:
-        return FFMAX(2.0f * M_PI_F / image_width, M_PI_F / image_height);
+        return FFMAXF(2.0f * M_PI_F / image_width, M_PI_F / image_height);
     }
 }
 
@@ -1205,7 +1205,7 @@ static int do_ssim360(FFFrameSync *fs)
 
                 // Target weight = total number of samples above the specified percentile
                 target_weight = (1. - PERCENTILE_LIST[p]) * s->ssim360_hist_net[i];
-                target_weight = FFMAX(target_weight, 1);
+                target_weight = FFMAXD(target_weight, 1);
                 while(hist_indices[i] >= 0 && hist_weight[i] < target_weight) {
                     hist_weight[i] += s->ssim360_hist[i][hist_indices[i]];
                     hist_indices[i] --;
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index fa202ee0cce..d71e8aa30b3 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -191,7 +191,7 @@ static int process_frame(FFFrameSync *fs)
                           0, 0, outlink->w, outlink->h);
 
     ff_filter_execute(ctx, process_slice, out, NULL,
-                      FFMIN(s->nb_inputs, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->nb_inputs, ff_filter_get_nb_threads(ctx)));
 
     return ff_filter_frame(outlink, out);
 }
@@ -384,8 +384,8 @@ static int config_output(AVFilterLink *outlink)
             item->y[1] = item->y[2] = AV_CEIL_RSHIFT(inh, s->desc->log2_chroma_h);
             item->y[0] = item->y[3] = inh;
 
-            width  = FFMAX(width,  inlink->w + inw);
-            height = FFMAX(height, inlink->h + inh);
+            width  = FFMAXI(width,  inlink->w + inw);
+            height = FFMAXI(height, inlink->h + inh);
         }
     }
 
diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c
index 8e1fdc5eb37..aaff75103c4 100644
--- a/libavfilter/vf_stereo3d.c
+++ b/libavfilter/vf_stereo3d.c
@@ -943,7 +943,7 @@ copy:
 
             td.ileft = ileft; td.iright = iright; td.out = out;
             ff_filter_execute(ctx, filter_slice, &td, NULL,
-                              FFMIN(s->out.height, ff_filter_get_nb_threads(ctx)));
+                              FFMINI(s->out.height, ff_filter_get_nb_threads(ctx)));
         }
         break;
     }
diff --git a/libavfilter/vf_super2xsai.c b/libavfilter/vf_super2xsai.c
index cf3aaebd646..9c84f810579 100644
--- a/libavfilter/vf_super2xsai.c
+++ b/libavfilter/vf_super2xsai.c
@@ -80,10 +80,10 @@ static int super2xsai(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
     const int slice_end = (height * (jobnr+1)) / nb_jobs;
 
     /* Point to the first 4 lines, first line is duplicated */
-    src_line[0] = src + src_linesize*FFMAX(slice_start - 1, 0);
+    src_line[0] = src + src_linesize*FFMAXI(slice_start - 1, 0);
     src_line[1] = src + src_linesize*slice_start;
-    src_line[2] = src + src_linesize*FFMIN(slice_start + 1, height-1);
-    src_line[3] = src + src_linesize*FFMIN(slice_start + 2, height-1);
+    src_line[2] = src + src_linesize*FFMINI(slice_start + 1, height-1);
+    src_line[3] = src + src_linesize*FFMINI(slice_start + 2, height-1);
 
 #define READ_COLOR4(dst, src_line, off) dst = *((const uint32_t *)src_line + off)
 #define READ_COLOR3(dst, src_line, off) dst = AV_RL24 (src_line + 3*off)
@@ -326,7 +326,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in, td.out = out;
     ff_filter_execute(ctx, super2xsai, &td, NULL,
-                      FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_swaprect.c b/libavfilter/vf_swaprect.c
index 5d93f51c30f..93777f045be 100644
--- a/libavfilter/vf_swaprect.c
+++ b/libavfilter/vf_swaprect.c
@@ -175,8 +175,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     y2[0] = y2[3] = y2[0];
 
 
-    av_assert0(FFMAX(x1[1], x2[1]) + pw[1] <= lw[1]);
-    av_assert0(FFMAX(y1[1], y2[1]) + ph[1] <= lh[1]);
+    av_assert0(FFMAXI(x1[1], x2[1]) + pw[1] <= lw[1]);
+    av_assert0(FFMAXI(y1[1], y2[1]) + ph[1] <= lh[1]);
 
     for (p = 0; p < s->nb_planes; p++) {
         if (ph[p] == ah[p] && pw[p] == aw[p]) {
diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 292b2ee625a..9f8a0687a3e 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -85,7 +85,7 @@ static av_cold int init(AVFilterContext *ctx)
             return AVERROR_INVALIDDATA;
         }
 
-        max = FFMAX(*p - '0', max);
+        max = FFMAXI(*p - '0', max);
         s->pts.num += 2;
         s->pts.den += *p - '0';
     }
diff --git a/libavfilter/vf_threshold.c b/libavfilter/vf_threshold.c
index 633deb94742..17db4b3436a 100644
--- a/libavfilter/vf_threshold.c
+++ b/libavfilter/vf_threshold.c
@@ -143,7 +143,7 @@ static int process_frame(FFFrameSync *fs)
         td.min = min;
         td.max = max;
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN(s->height[2], ff_filter_get_nb_threads(ctx)));
+                          FFMINI(s->height[2], ff_filter_get_nb_threads(ctx)));
     }
 
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
diff --git a/libavfilter/vf_tiltandshift.c b/libavfilter/vf_tiltandshift.c
index d7bce064bb5..36ac1508f83 100644
--- a/libavfilter/vf_tiltandshift.c
+++ b/libavfilter/vf_tiltandshift.c
@@ -147,7 +147,7 @@ static int config_props(AVFilterLink *outlink)
         if (ret < 0)
             return ret;
 
-        for (i = 0; i < FFMIN(desc->nb_components, 4); i++)
+        for (i = 0; i < FFMINI(desc->nb_components, 4); i++)
             for (j = 0; j < (!i ? outlink->h
                                 : -((-outlink->h) >> desc->log2_chroma_h)); j++)
                 memset(s->black_buffers[i] + j * s->black_linesizes[i],
diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
index 2f09487d3f2..f97dff467fa 100644
--- a/libavfilter/vf_tonemap.c
+++ b/libavfilter/vf_tonemap.c
@@ -100,7 +100,7 @@ static float mobius(float in, float j, double peak)
         return in;
 
     a = -j * j * (peak - 1.0f) / (j * j - 2.0f * j + peak);
-    b = (j * j - 2.0f * j * peak + peak) / FFMAX(peak - 1.0f, 1e-6);
+    b = (j * j - 2.0f * j * peak + peak) / FFMAXD(peak - 1.0f, 1e-6);
 
     return (b * b + 2.0f * b * j + j * j) / (b - a) * (in + a) / (in + b);
 }
@@ -126,7 +126,7 @@ static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in,
     /* desaturate to prevent unnatural colors */
     if (s->desat > 0) {
         float luma = av_q2d(s->coeffs->cr) * *r_in + av_q2d(s->coeffs->cg) * *g_in + av_q2d(s->coeffs->cb) * *b_in;
-        float overbright = FFMAX(luma - s->desat, 1e-6) / FFMAX(luma, 1e-6);
+        float overbright = FFMAXD(luma - s->desat, 1e-6) / FFMAXD(luma, 1e-6);
         *r_out = MIX(*r_in, luma, overbright);
         *g_out = MIX(*g_in, luma, overbright);
         *b_out = MIX(*b_in, luma, overbright);
@@ -135,7 +135,7 @@ static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in,
     /* pick the brightest component, reducing the value range as necessary
      * to keep the entire signal in range and preventing discoloration due to
      * out-of-bounds clipping */
-    sig = FFMAX(FFMAX3(*r_out, *g_out, *b_out), 1e-6);
+    sig = FFMAXD(FFMAX3(*r_out, *g_out, *b_out), 1e-6);
     sig_orig = sig;
 
     switch(s->tonemap) {
@@ -256,7 +256,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     td.desc = desc;
     td.peak = peak;
     ff_filter_execute(ctx, tonemap_slice, &td, NULL,
-                      FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(in->height, ff_filter_get_nb_threads(ctx)));
 
     /* copy/generate alpha if needed */
     if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c
index 9fe82cbb1b6..27fb42cd141 100644
--- a/libavfilter/vf_tonemap_vaapi.c
+++ b/libavfilter/vf_tonemap_vaapi.c
@@ -73,7 +73,7 @@ static int tonemap_vaapi_save_metadata(AVFilterContext *avctx, AVFrame *input_fr
             ctx->in_metadata.max_display_mastering_luminance =
                 lrint(luma_den * av_q2d(hdr_meta->max_luminance));
             ctx->in_metadata.min_display_mastering_luminance =
-                FFMIN(lrint(luma_den * av_q2d(hdr_meta->min_luminance)),
+                FFMINI(lrint(luma_den * av_q2d(hdr_meta->min_luminance)),
                       ctx->in_metadata.max_display_mastering_luminance);
 
             av_log(avctx, AV_LOG_DEBUG,
@@ -92,20 +92,20 @@ static int tonemap_vaapi_save_metadata(AVFilterContext *avctx, AVFrame *input_fr
             for (i = 0; i < 3; i++) {
                 const int j = mapping[i];
                 ctx->in_metadata.display_primaries_x[i] =
-                    FFMIN(lrint(chroma_den *
+                    FFMINI(lrint(chroma_den *
                                 av_q2d(hdr_meta->display_primaries[j][0])),
                           chroma_den);
                 ctx->in_metadata.display_primaries_y[i] =
-                    FFMIN(lrint(chroma_den *
+                    FFMINI(lrint(chroma_den *
                                 av_q2d(hdr_meta->display_primaries[j][1])),
                           chroma_den);
             }
 
             ctx->in_metadata.white_point_x =
-                FFMIN(lrint(chroma_den * av_q2d(hdr_meta->white_point[0])),
+                FFMINI(lrint(chroma_den * av_q2d(hdr_meta->white_point[0])),
                       chroma_den);
             ctx->in_metadata.white_point_y =
-                FFMIN(lrint(chroma_den * av_q2d(hdr_meta->white_point[1])),
+                FFMINI(lrint(chroma_den * av_q2d(hdr_meta->white_point[1])),
                       chroma_den);
 
             av_log(avctx, AV_LOG_DEBUG,
@@ -218,8 +218,8 @@ static int tonemap_vaapi_update_sidedata(AVFilterContext *avctx, AVFrame *output
 
     hdr_meta_lt = (AVContentLightMetadata *)metadata_lt->data;
 
-    hdr_meta_lt->MaxCLL = FFMIN(ctx->out_metadata.max_content_light_level, 65535);
-    hdr_meta_lt->MaxFALL = FFMIN(ctx->out_metadata.max_pic_average_light_level, 65535);
+    hdr_meta_lt->MaxCLL = FFMINI(ctx->out_metadata.max_content_light_level, 65535);
+    hdr_meta_lt->MaxFALL = FFMINI(ctx->out_metadata.max_pic_average_light_level, 65535);
 
     av_log(avctx, AV_LOG_DEBUG,
            "Content light level information(out):\n");
diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 88cc008f692..7b2f188e72e 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -359,7 +359,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in = in, td.out = out;
     ff_filter_execute(ctx, filter_slice, &td, NULL,
-                      FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 71d40447c0e..0251b94d274 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -196,7 +196,7 @@ static int apply_unsharp(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
         td.dst_stride = out->linesize[i];
         td.src_stride = in->linesize[i];
         ff_filter_execute(ctx, s->unsharp_slice, &td, NULL,
-                          FFMIN(plane_h[i], s->nb_threads));
+                          FFMINI(plane_h[i], s->nb_threads));
     }
     return 0;
 }
@@ -300,7 +300,7 @@ static int config_input(AVFilterLink *inlink)
 
     // ensure (height / nb_threads) > 4 * steps_y,
     // so that we don't have too much overlap between two threads
-    s->nb_threads = FFMIN(ff_filter_get_nb_threads(inlink->dst),
+    s->nb_threads = FFMINI(ff_filter_get_nb_threads(inlink->dst),
                           inlink->h / (4 * s->luma.steps_y));
 
     ret = init_filter_param(inlink->dst, &s->luma,   "luma",   inlink->w);
diff --git a/libavfilter/vf_unsharp_opencl.c b/libavfilter/vf_unsharp_opencl.c
index 15853e8db3a..045533f2d58 100644
--- a/libavfilter/vf_unsharp_opencl.c
+++ b/libavfilter/vf_unsharp_opencl.c
@@ -117,7 +117,7 @@ static int unsharp_opencl_make_filter_params(AVFilterContext *avctx)
 
     ctx->nb_planes = 0;
     for (p = 0; p < desc->nb_components; p++)
-        ctx->nb_planes = FFMAX(ctx->nb_planes, desc->comp[p].plane + 1);
+        ctx->nb_planes = FFMAXI(ctx->nb_planes, desc->comp[p].plane + 1);
 
     for (p = 0; p < ctx->nb_planes; p++) {
         if (p == 0 || (desc->flags & AV_PIX_FMT_FLAG_RGB)) {
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 63412aef872..cbd3216eb78 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -1841,8 +1841,8 @@ static int prepare_stereographic_out(AVFilterContext *ctx)
 {
     V360Context *s = ctx->priv;
 
-    s->flat_range[0] = tanf(FFMIN(s->h_fov, 359.f) * M_PI / 720.f);
-    s->flat_range[1] = tanf(FFMIN(s->v_fov, 359.f) * M_PI / 720.f);
+    s->flat_range[0] = tanf(FFMINF(s->h_fov, 359.f) * M_PI / 720.f);
+    s->flat_range[1] = tanf(FFMINF(s->v_fov, 359.f) * M_PI / 720.f);
 
     return 0;
 }
@@ -1885,8 +1885,8 @@ static int prepare_stereographic_in(AVFilterContext *ctx)
 {
     V360Context *s = ctx->priv;
 
-    s->iflat_range[0] = tanf(FFMIN(s->ih_fov, 359.f) * M_PI / 720.f);
-    s->iflat_range[1] = tanf(FFMIN(s->iv_fov, 359.f) * M_PI / 720.f);
+    s->iflat_range[0] = tanf(FFMINF(s->ih_fov, 359.f) * M_PI / 720.f);
+    s->iflat_range[1] = tanf(FFMINF(s->iv_fov, 359.f) * M_PI / 720.f);
 
     return 0;
 }
@@ -1989,8 +1989,8 @@ static int prepare_equisolid_in(AVFilterContext *ctx)
 {
     V360Context *s = ctx->priv;
 
-    s->iflat_range[0] = sinf(FFMIN(s->ih_fov, 359.f) * M_PI / 720.f);
-    s->iflat_range[1] = sinf(FFMIN(s->iv_fov, 359.f) * M_PI / 720.f);
+    s->iflat_range[0] = sinf(FFMINF(s->ih_fov, 359.f) * M_PI / 720.f);
+    s->iflat_range[1] = sinf(FFMINF(s->iv_fov, 359.f) * M_PI / 720.f);
 
     return 0;
 }
@@ -2049,8 +2049,8 @@ static int prepare_orthographic_out(AVFilterContext *ctx)
 {
     V360Context *s = ctx->priv;
 
-    s->flat_range[0] = sinf(FFMIN(s->h_fov, 180.f) * M_PI / 360.f);
-    s->flat_range[1] = sinf(FFMIN(s->v_fov, 180.f) * M_PI / 360.f);
+    s->flat_range[0] = sinf(FFMINF(s->h_fov, 180.f) * M_PI / 360.f);
+    s->flat_range[1] = sinf(FFMINF(s->v_fov, 180.f) * M_PI / 360.f);
 
     return 0;
 }
@@ -2100,8 +2100,8 @@ static int prepare_orthographic_in(AVFilterContext *ctx)
 {
     V360Context *s = ctx->priv;
 
-    s->iflat_range[0] = sinf(FFMIN(s->ih_fov, 180.f) * M_PI / 360.f);
-    s->iflat_range[1] = sinf(FFMIN(s->iv_fov, 180.f) * M_PI / 360.f);
+    s->iflat_range[0] = sinf(FFMINF(s->ih_fov, 180.f) * M_PI / 360.f);
+    s->iflat_range[1] = sinf(FFMINF(s->iv_fov, 180.f) * M_PI / 360.f);
 
     return 0;
 }
@@ -3350,7 +3350,7 @@ static int xyz_to_tetrahedron(const V360Context *s,
     const float d1 = vec[0] *-1.f + vec[1] *-1.f + vec[2] *-1.f;
     const float d2 = vec[0] * 1.f + vec[1] *-1.f + vec[2] * 1.f;
     const float d3 = vec[0] *-1.f + vec[1] * 1.f + vec[2] * 1.f;
-    const float d = FFMAX(d0, FFMAX3(d1, d2, d3));
+    const float d = FFMAXF(d0, FFMAX3(d1, d2, d3));
 
     float uf, vf, x, y, z;
     int ui, vi;
@@ -4210,7 +4210,7 @@ static void fov_from_dfov(int format, float d_fov, float w, float h, float *h_fo
     case FLAT:
     default:
         {
-            const float da = tanf(0.5f * FFMIN(d_fov, 359.f) * M_PI / 180.f);
+            const float da = tanf(0.5f * FFMINF(d_fov, 359.f) * M_PI / 180.f);
             const float d = hypotf(w, h);
 
             *h_fov = atan2f(da * w, d) * 360.f / M_PI;
@@ -4866,7 +4866,7 @@ static int config_output(AVFilterLink *outlink)
     outlink->h = h;
     outlink->w = w;
 
-    s->nb_threads = FFMIN(outlink->h, ff_filter_get_nb_threads(ctx));
+    s->nb_threads = FFMINI(outlink->h, ff_filter_get_nb_threads(ctx));
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
     have_alpha   = !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
 
diff --git a/libavfilter/vf_vaguedenoiser.c b/libavfilter/vf_vaguedenoiser.c
index 9a9bf77233c..2e15de1d738 100644
--- a/libavfilter/vf_vaguedenoiser.c
+++ b/libavfilter/vf_vaguedenoiser.c
@@ -146,9 +146,9 @@ static int config_input(AVFilterLink *inlink)
     s->planewidth[0]  = s->planewidth[3]  = inlink->w;
 
     s->block = av_malloc_array(inlink->w * inlink->h, sizeof(*s->block));
-    s->in    = av_malloc_array(32 + FFMAX(inlink->w, inlink->h), sizeof(*s->in));
-    s->out   = av_malloc_array(32 + FFMAX(inlink->w, inlink->h), sizeof(*s->out));
-    s->tmp   = av_malloc_array(32 + FFMAX(inlink->w, inlink->h), sizeof(*s->tmp));
+    s->in    = av_malloc_array(32 + FFMAXI(inlink->w, inlink->h), sizeof(*s->in));
+    s->out   = av_malloc_array(32 + FFMAXI(inlink->w, inlink->h), sizeof(*s->out));
+    s->tmp   = av_malloc_array(32 + FFMAXI(inlink->w, inlink->h), sizeof(*s->tmp));
 
     if (!s->block || !s->in || !s->out || !s->tmp)
         return AVERROR(ENOMEM);
@@ -164,7 +164,7 @@ static int config_input(AVFilterLink *inlink)
             break;
     }
 
-    s->nsteps = FFMIN(s->nsteps, nsteps_max - 2);
+    s->nsteps = FFMINI(s->nsteps, nsteps_max - 2);
 
     for (p = 0; p < 4; p++) {
         s->hlowsize[p][0]  = (s->planewidth[p] + 1) >> 1;
@@ -399,7 +399,7 @@ static float bayes_threshold(float *block, const int width, const int height,
 
     mean /= width * height;
 
-    return threshold * threshold / (FFMAX(sqrtf(mean - threshold), FLT_EPSILON));
+    return threshold * threshold / (FFMAXF(sqrtf(mean - threshold), FLT_EPSILON));
 }
 
 static void filter(VagueDenoiserContext *s, AVFrame *in, AVFrame *out)
diff --git a/libavfilter/vf_varblur.c b/libavfilter/vf_varblur.c
index 6a9aa89ce14..4f49764ee32 100644
--- a/libavfilter/vf_varblur.c
+++ b/libavfilter/vf_varblur.c
@@ -160,18 +160,18 @@ static int blur_plane##bits(AVFilterContext *ctx,              \
                                                                \
     for (int y = slice_start; y < slice_end; y++) {            \
         for (int x = 0; x < w; x++) {                          \
-            const float radiusf = minr + (FFMAX(0.f, 2 * rptr[x] + 1 - minr)) * scaler; \
+            const float radiusf = minr + (FFMAXF(0.f, 2 * rptr[x] + 1 - minr)) * scaler; \
             const int radius = floorf(radiusf);                \
             const float factor = radiusf - radius;             \
             const int nradius = radius + 1;                    \
-            const int l = FFMIN(radius, x);                    \
-            const int r = FFMIN(radius, w - x - 1);            \
-            const int t = FFMIN(radius, y);                    \
-            const int b = FFMIN(radius, h - y - 1);            \
-            const int nl = FFMIN(nradius, x);                  \
-            const int nr = FFMIN(nradius, w - x - 1);          \
-            const int nt = FFMIN(nradius, y);                  \
-            const int nb = FFMIN(nradius, h - y - 1);          \
+            const int l = FFMINI(radius, x);                    \
+            const int r = FFMINI(radius, w - x - 1);            \
+            const int t = FFMINI(radius, y);                    \
+            const int b = FFMINI(radius, h - y - 1);            \
+            const int nl = FFMINI(nradius, x);                  \
+            const int nr = FFMINI(nradius, w - x - 1);          \
+            const int nt = FFMINI(nradius, y);                  \
+            const int nb = FFMINI(nradius, h - y - 1);          \
             stype tl = ptr[(y - t) * ptr_linesize + x - l];    \
             stype tr = ptr[(y - t) * ptr_linesize + x + r];    \
             stype bl = ptr[(y + b) * ptr_linesize + x - l];    \
@@ -284,7 +284,7 @@ static int blur_frame(AVFilterContext *ctx, AVFrame *in, AVFrame *radius)
     td.out = out;
     td.radius = radius;
     ff_filter_execute(ctx, blur_planes, &td, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
diff --git a/libavfilter/vf_vectorscope.c b/libavfilter/vf_vectorscope.c
index 2143f9dcc2a..d080ffba0bc 100644
--- a/libavfilter/vf_vectorscope.c
+++ b/libavfilter/vf_vectorscope.c
@@ -458,15 +458,15 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
             const int iwy = i * slinesizey;
             const int iwd = i * slinesized;
             for (j = 0; j < w; j++) {
-                const int x = FFMIN(spx[iwx + j], max);
-                const int y = FFMIN(spy[iwy + j], max);
+                const int x = FFMINI(spx[iwx + j], max);
+                const int y = FFMINI(spy[iwy + j], max);
                 const int z = spd[iwd + j];
                 const int pos = y * dlinesize + x;
 
                 if (z < tmin || z > tmax)
                     continue;
 
-                dpd[pos] = FFMIN(dpd[pos] + intensity, max);
+                dpd[pos] = FFMINI(dpd[pos] + intensity, max);
             }
         }
         break;
@@ -477,8 +477,8 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
                 const int iw2 = i * slinesizey;
                 const int iwd = i * slinesized;
                 for (j = 0; j < w; j++) {
-                    const int x = FFMIN(spx[iw1 + j], max);
-                    const int y = FFMIN(spy[iw2 + j], max);
+                    const int x = FFMINI(spx[iw1 + j], max);
+                    const int y = FFMINI(spy[iw2 + j], max);
                     const int z = spd[iwd + j];
                     const int pos = y * dlinesize + x;
 
@@ -497,8 +497,8 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
                 const int iw2 = i * slinesizey;
                 const int iwd = i * slinesized;
                 for (j = 0; j < w; j++) {
-                    const int x = FFMIN(spx[iw1 + j], max);
-                    const int y = FFMIN(spy[iw2 + j], max);
+                    const int x = FFMINI(spx[iw1 + j], max);
+                    const int y = FFMINI(spy[iw2 + j], max);
                     const int z = spd[iwd + j];
                     const int pos = y * dlinesize + x;
 
@@ -506,7 +506,7 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
                         continue;
 
                     if (!dpd[pos])
-                        dpd[pos] = FFMIN(x + y, max);
+                        dpd[pos] = FFMINI(x + y, max);
                     dpx[pos] = x;
                     dpy[pos] = y;
                 }
@@ -519,15 +519,15 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
             const int iw2 = i * slinesizey;
             const int iwd = i * slinesized;
             for (j = 0; j < w; j++) {
-                const int x = FFMIN(spx[iw1 + j], max);
-                const int y = FFMIN(spy[iw2 + j], max);
+                const int x = FFMINI(spx[iw1 + j], max);
+                const int y = FFMINI(spy[iw2 + j], max);
                 const int z = spd[iwd + j];
                 const int pos = y * dlinesize + x;
 
                 if (z < tmin || z > tmax)
                     continue;
 
-                dpd[pos] = FFMIN(max, dpd[pos] + intensity);
+                dpd[pos] = FFMINI(max, dpd[pos] + intensity);
                 dpx[pos] = x;
                 dpy[pos] = y;
             }
@@ -539,15 +539,15 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
             const int iwy = (i >> vsub) * slinesizey;
             const int iwd = i * slinesized;
             for (j = 0; j < in->width; j++) {
-                const int x = FFMIN(spx[iwx + (j >> hsub)], max);
-                const int y = FFMIN(spy[iwy + (j >> hsub)], max);
+                const int x = FFMINI(spx[iwx + (j >> hsub)], max);
+                const int y = FFMINI(spy[iwy + (j >> hsub)], max);
                 const int z = spd[iwd + j];
                 const int pos = y * dlinesize + x;
 
                 if (z < tmin || z > tmax)
                     continue;
 
-                dpd[pos] = FFMAX(z, dpd[pos]);
+                dpd[pos] = FFMAXI(z, dpd[pos]);
                 dpx[pos] = x;
                 dpy[pos] = y;
             }
@@ -662,7 +662,7 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p
                 if (z < tmin || z > tmax)
                     continue;
 
-                dpd[pos] = FFMIN(dpd[pos] + intensity, 255);
+                dpd[pos] = FFMINI(dpd[pos] + intensity, 255);
             }
         }
         break;
@@ -702,7 +702,7 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p
                         continue;
 
                     if (!dpd[pos])
-                        dpd[pos] = FFMIN(x + y, 255);
+                        dpd[pos] = FFMINI(x + y, 255);
                     dpx[pos] = x;
                     dpy[pos] = y;
                 }
@@ -723,7 +723,7 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p
                 if (z < tmin || z > tmax)
                     continue;
 
-                dpd[pos] = FFMIN(255, dpd[pos] + intensity);
+                dpd[pos] = FFMINI(255, dpd[pos] + intensity);
                 dpx[pos] = x;
                 dpy[pos] = y;
             }
@@ -743,7 +743,7 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p
                 if (z < tmin || z > tmax)
                     continue;
 
-                dpd[pos] = FFMAX(z, dpd[pos]);
+                dpd[pos] = FFMAXI(z, dpd[pos]);
                 dpx[pos] = x;
                 dpy[pos] = y;
             }
diff --git a/libavfilter/vf_vfrdet.c b/libavfilter/vf_vfrdet.c
index f99bc71de77..1b4bd2afbf1 100644
--- a/libavfilter/vf_vfrdet.c
+++ b/libavfilter/vf_vfrdet.c
@@ -54,8 +54,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         if (s->delta != delta) {
             s->vfr++;
             s->delta = delta;
-            s->min_delta = FFMIN(delta, s->min_delta);
-            s->max_delta = FFMAX(delta, s->max_delta);
+            s->min_delta = FFMINI(delta, s->min_delta);
+            s->max_delta = FFMAXI(delta, s->max_delta);
             s->avg_delta += delta;
         } else {
             s->cfr++;
diff --git a/libavfilter/vf_vibrance.c b/libavfilter/vf_vibrance.c
index 960b7e1b136..f342d0dff59 100644
--- a/libavfilter/vf_vibrance.c
+++ b/libavfilter/vf_vibrance.c
@@ -359,7 +359,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     td.out = out;
     td.in = in;
     if (res = ff_filter_execute(avctx, s->do_slice, &td, NULL,
-                                FFMIN(out->height, ff_filter_get_nb_threads(avctx))))
+                                FFMINI(out->height, ff_filter_get_nb_threads(avctx))))
         return res;
 
     if (out != in)
diff --git a/libavfilter/vf_vif.c b/libavfilter/vf_vif.c
index 6ec8a8d0669..eeb00430a8a 100644
--- a/libavfilter/vf_vif.c
+++ b/libavfilter/vf_vif.c
@@ -135,9 +135,9 @@ static void vif_statistic(const float *mu1_sq, const float *mu2_sq,
             sigma2_sq = yy_filt_val - mu2_sq_val;
             sigma12   = xy_filt_val - mu1_mu2_val;
 
-            sigma1_sq = FFMAX(sigma1_sq, 0.0f);
-            sigma2_sq = FFMAX(sigma2_sq, 0.0f);
-            sigma12   = FFMAX(sigma12,   0.0f);
+            sigma1_sq = FFMAXF(sigma1_sq, 0.0f);
+            sigma2_sq = FFMAXF(sigma2_sq, 0.0f);
+            sigma12   = FFMAXF(sigma12,   0.0f);
 
             g = sigma12 / (sigma1_sq + eps);
             sv_sq = sigma2_sq - g * sigma12;
@@ -157,9 +157,9 @@ static void vif_statistic(const float *mu1_sq, const float *mu2_sq,
                 sv_sq = sigma2_sq;
                 g = 0.0f;
             }
-            sv_sq = FFMAX(sv_sq, eps);
+            sv_sq = FFMAXF(sv_sq, eps);
 
-            g = FFMIN(g, gain_limit);
+            g = FFMINF(g, gain_limit);
 
             num_val = log2f(1.0f + g * g * sigma1_sq / (sv_sq + sigma_nsq));
             den_val = log2f(1.0f + sigma1_sq / sigma_nsq);
@@ -313,7 +313,7 @@ static int compute_vif2(AVFilterContext *ctx,
     for (int scale = 0; scale < 4; scale++) {
         const float *filter = vif_filter1d_table[scale];
         int filter_width = vif_filter1d_width1[scale];
-        const int nb_threads = FFMIN(h, gnb_threads);
+        const int nb_threads = FFMINI(h, gnb_threads);
         int buf_valid_w = w;
         int buf_valid_h = h;
 
@@ -456,8 +456,8 @@ static AVFrame *do_vif(AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
     set_meta(metadata, "lavfi.vif.scale.3", score[3]);
 
     for (int i = 0; i < 4; i++) {
-        s->vif_min[i]  = FFMIN(s->vif_min[i], score[i]);
-        s->vif_max[i]  = FFMAX(s->vif_max[i], score[i]);
+        s->vif_min[i]  = FFMIND(s->vif_min[i], score[i]);
+        s->vif_max[i]  = FFMAXD(s->vif_max[i], score[i]);
         s->vif_sum[i] += score[i];
     }
 
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 0a33c377c83..57ba2ff1d14 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -350,8 +350,8 @@ static int config_input(AVFilterLink *inlink)
     vpp->out_height = oh;
 
     if (vpp->use_crop) {
-        vpp->crop_x = FFMAX(vpp->crop_x, 0);
-        vpp->crop_y = FFMAX(vpp->crop_y, 0);
+        vpp->crop_x = FFMAXI(vpp->crop_x, 0);
+        vpp->crop_y = FFMAXI(vpp->crop_y, 0);
 
         if(vpp->crop_w + vpp->crop_x > inlink->w)
            vpp->crop_x = inlink->w - vpp->crop_w;
diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index 5b4c83bbd9c..4be334c3af0 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -507,7 +507,7 @@ static int filter(AVFilterContext *ctx, int is_second)
     adj = s->field ? s->next : s->prev;
     td.out = out; td.cur = s->cur; td.adj = adj;
     ff_filter_execute(ctx, deinterlace_slice, &td, NULL,
-                      FFMIN(s->planeheight[1], s->nb_threads));
+                      FFMINI(s->planeheight[1], s->nb_threads));
 
     if (s->mode)
         s->field = !s->field;
diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 6d2b529e881..e76599bb23a 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -726,7 +726,7 @@ static av_always_inline void lowpass16(WaveformContext *s,
 
         for (p = src_data + slicew_start; p < src_data_end; p++) {
             uint16_t *target;
-            int i = 0, v = FFMIN(*p, limit);
+            int i = 0, v = FFMINI(*p, limit);
 
             if (column) {
                 do {
@@ -1008,8 +1008,8 @@ static av_always_inline void flat16(WaveformContext *s,
             uint16_t * const d1 = (mirror ? d1_bottom_line : d1_data);
 
             for (y = 0; y < src_h; y++) {
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit) + s->max;
-                const int c1 = FFMIN(FFABS(c1_data[x >> c1_shift_w] - mid) + FFABS(c2_data[x >> c2_shift_w] - mid), limit);
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit) + s->max;
+                const int c1 = FFMINI(FFABS(c1_data[x >> c1_shift_w] - mid) + FFABS(c2_data[x >> c2_shift_w] - mid), limit);
                 uint16_t *target;
 
                 target = d0 + x + d0_signed_linesize * c0;
@@ -1043,8 +1043,8 @@ static av_always_inline void flat16(WaveformContext *s,
 
         for (y = sliceh_start; y < sliceh_end; y++) {
             for (x = 0; x < src_w; x++) {
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit) + s->max;
-                const int c1 = FFMIN(FFABS(c1_data[x >> c1_shift_w] - mid) + FFABS(c2_data[x >> c2_shift_w] - mid), limit);
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit) + s->max;
+                const int c1 = FFMINI(FFABS(c1_data[x >> c1_shift_w] - mid) + FFABS(c2_data[x >> c2_shift_w] - mid), limit);
                 uint16_t *target;
 
                 if (mirror) {
@@ -1295,9 +1295,9 @@ static int name(AVFilterContext *ctx,
             uint16_t * const d2 = (mirror ? d2_bottom_line : d2_data);                                             \
                                                                                                                    \
             for (y = 0; y < src_h; y++) {                                                                          \
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit) + mid;                                       \
-                const int c1 = FFMIN(c1_data[x >> c1_shift_w], limit) - mid;                                       \
-                const int c2 = FFMIN(c2_data[x >> c2_shift_w], limit) - mid;                                       \
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit) + mid;                                       \
+                const int c1 = FFMINI(c1_data[x >> c1_shift_w], limit) - mid;                                       \
+                const int c2 = FFMINI(c2_data[x >> c2_shift_w], limit) - mid;                                       \
                 uint16_t *target;                                                                                  \
                                                                                                                    \
                 target = d0 + x + d0_signed_linesize * c0;                                                         \
@@ -1336,9 +1336,9 @@ static int name(AVFilterContext *ctx,
                                                                                                                    \
         for (y = sliceh_start; y < sliceh_end; y++) {                                                              \
             for (x = 0; x < src_w; x++) {                                                                          \
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit) + mid;                                       \
-                const int c1 = FFMIN(c1_data[x >> c1_shift_w], limit) - mid;                                       \
-                const int c2 = FFMIN(c2_data[x >> c2_shift_w], limit) - mid;                                       \
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit) + mid;                                       \
+                const int c1 = FFMINI(c1_data[x >> c1_shift_w], limit) - mid;                                       \
+                const int c2 = FFMINI(c2_data[x >> c2_shift_w], limit) - mid;                                       \
                 uint16_t *target;                                                                                  \
                                                                                                                    \
                 if (mirror) {                                                                                      \
@@ -1568,7 +1568,7 @@ static av_always_inline void chroma16(WaveformContext *s,
             uint16_t *dst = dst_line;
 
             for (y = 0; y < src_h; y++) {
-                const int sum = FFMIN(FFABS(c0_data[x >> c0_shift_w] - mid) + FFABS(c1_data[x >> c1_shift_w] - mid - 1), limit);
+                const int sum = FFMINI(FFABS(c0_data[x >> c0_shift_w] - mid) + FFABS(c1_data[x >> c1_shift_w] - mid - 1), limit);
                 uint16_t *target;
 
                 target = dst + x + dst_signed_linesize * sum;
@@ -1590,7 +1590,7 @@ static av_always_inline void chroma16(WaveformContext *s,
             dst_data += s->size - 1;
         for (y = sliceh_start; y < sliceh_end; y++) {
             for (x = 0; x < src_w; x++) {
-                const int sum = FFMIN(FFABS(c0_data[x >> c0_shift_w] - mid) + FFABS(c1_data[x >> c1_shift_w] - mid - 1), limit);
+                const int sum = FFMINI(FFABS(c0_data[x >> c0_shift_w] - mid) + FFABS(c1_data[x >> c1_shift_w] - mid - 1), limit);
                 uint16_t *target;
 
                 if (mirror) {
@@ -1788,7 +1788,7 @@ static av_always_inline void color16(WaveformContext *s,
 
         for (y = 0; y < src_h; y++) {
             for (x = slicew_start; x < slicew_end; x++) {
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit);
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit);
                 const int c1 = c1_data[x >> c1_shift_w];
                 const int c2 = c2_data[x >> c2_shift_w];
 
@@ -1820,7 +1820,7 @@ static av_always_inline void color16(WaveformContext *s,
 
         for (y = sliceh_start; y < sliceh_end; y++) {
             for (x = 0; x < src_w; x++) {
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit);
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit);
                 const int c1 = c1_data[x >> c1_shift_w];
                 const int c2 = c2_data[x >> c2_shift_w];
 
@@ -2054,7 +2054,7 @@ static av_always_inline void acolor16(WaveformContext *s,
 
         for (y = 0; y < src_h; y++) {
             for (x = slicew_start; x < slicew_end; x++) {
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit);
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit);
                 const int c1 = c1_data[x >> c1_shift_w];
                 const int c2 = c2_data[x >> c2_shift_w];
 
@@ -2086,7 +2086,7 @@ static av_always_inline void acolor16(WaveformContext *s,
 
         for (y = sliceh_start; y < sliceh_end; y++) {
             for (x = 0; x < src_w; x++) {
-                const int c0 = FFMIN(c0_data[x >> c0_shift_w], limit);
+                const int c0 = FFMINI(c0_data[x >> c0_shift_w], limit);
                 const int c1 = c1_data[x >> c1_shift_w];
                 const int c2 = c2_data[x >> c2_shift_w];
 
@@ -3331,12 +3331,12 @@ static int config_output(AVFilterLink *outlink)
     av_freep(&s->peak);
 
     if (s->mode) {
-        outlink->h = s->size * FFMAX(comp * (s->display == STACK), 1);
-        outlink->w = inlink->w * FFMAX(comp * (s->display == PARADE), 1);
+        outlink->h = s->size * FFMAXI(comp * (s->display == STACK), 1);
+        outlink->w = inlink->w * FFMAXI(comp * (s->display == PARADE), 1);
         size = inlink->w;
     } else {
-        outlink->w = s->size * FFMAX(comp * (s->display == STACK), 1);
-        outlink->h = inlink->h * FFMAX(comp * (s->display == PARADE), 1);
+        outlink->w = s->size * FFMAXI(comp * (s->display == STACK), 1);
+        outlink->h = inlink->h * FFMAXI(comp * (s->display == PARADE), 1);
         size = inlink->h;
     }
 
diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
index 91c98e0e661..9a23a057bac 100644
--- a/libavfilter/vf_weave.c
+++ b/libavfilter/vf_weave.c
@@ -158,7 +158,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.out = out, td.in = in;
     ff_filter_execute(ctx, weave_slice, &td, NULL,
-                      FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
+                      FFMINI(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
 
     out->pts = s->double_weave ? s->prev->pts : in->pts / 2;
     out->flags |= AV_FRAME_FLAG_INTERLACED;
diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c
index c9a4bc5be7c..adf7be74d4b 100644
--- a/libavfilter/vf_xbr.c
+++ b/libavfilter/vf_xbr.c
@@ -361,7 +361,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.rgbtoyuv = s->rgbtoyuv;
     ff_filter_execute(ctx, s->func, &td, NULL,
-                      FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(inlink->h, ff_filter_get_nb_threads(ctx)));
 
     out->width  = outlink->w;
     out->height = outlink->h;
diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c
index 4517e4e6b36..d1fdffb2811 100644
--- a/libavfilter/vf_xfade.c
+++ b/libavfilter/vf_xfade.c
@@ -1104,13 +1104,13 @@ static void pixelize##name##_transition(AVFilterContext *ctx,
     const int h = out->height;                                                       \
     const float d = fminf(progress, 1.f - progress);                                 \
     const float dist = ceilf(d * 50.f) / 50.f;                                       \
-    const float sqx = 2.f * dist * FFMIN(w, h) / 20.f;                               \
-    const float sqy = 2.f * dist * FFMIN(w, h) / 20.f;                               \
+    const float sqx = 2.f * dist * FFMINI(w, h) / 20.f;                               \
+    const float sqy = 2.f * dist * FFMINI(w, h) / 20.f;                               \
                                                                                      \
     for (int y = slice_start; y < slice_end; y++) {                                  \
         for (int x = 0; x < w; x++) {                                                \
-            int sx = dist > 0.f ? FFMIN((floorf(x / sqx) + .5f) * sqx, w - 1) : x;   \
-            int sy = dist > 0.f ? FFMIN((floorf(y / sqy) + .5f) * sqy, h - 1) : y;   \
+            int sx = dist > 0.f ? FFMINF((floorf(x / sqx) + .5f) * sqx, w - 1) : x;   \
+            int sy = dist > 0.f ? FFMINF((floorf(y / sqy) + .5f) * sqy, h - 1) : y;   \
             for (int p = 0; p < nb_planes; p++) {                                    \
                 const type *xf0 = (const type *)(a->data[p] + sy * a->linesize[p]);  \
                 const type *xf1 = (const type *)(b->data[p] + sy * b->linesize[p]);  \
@@ -2005,8 +2005,8 @@ static inline double getpix(void *priv, double x, double y, int plane, int nb)
 {
     XFadeContext *s = priv;
     AVFrame *in = s->xf[nb];
-    const uint8_t *src = in->data[FFMIN(plane, s->nb_planes - 1)];
-    int linesize = in->linesize[FFMIN(plane, s->nb_planes - 1)];
+    const uint8_t *src = in->data[FFMINI(plane, s->nb_planes - 1)];
+    int linesize = in->linesize[FFMINI(plane, s->nb_planes - 1)];
     const int w = in->width;
     const int h = in->height;
 
@@ -2216,7 +2216,7 @@ static int xfade_frame(AVFilterContext *ctx, AVFrame *a, AVFrame *b)
 
     td.xf[0] = a, td.xf[1] = b, td.out = out, td.progress = progress;
     ff_filter_execute(ctx, xfade_slice, &td, NULL,
-                      FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     out->pts = s->pts;
 
diff --git a/libavfilter/vf_xfade_opencl.c b/libavfilter/vf_xfade_opencl.c
index 96dc7e4554a..9a3cadbd762 100644
--- a/libavfilter/vf_xfade_opencl.c
+++ b/libavfilter/vf_xfade_opencl.c
@@ -84,7 +84,7 @@ static int xfade_opencl_load(AVFilterContext *avctx,
 
     main_planes = 0;
     for (int i = 0; i < main_desc->nb_components; i++)
-        main_planes = FFMAX(main_planes,
+        main_planes = FFMAXI(main_planes,
                             main_desc->comp[i].plane + 1);
 
     ctx->nb_planes = main_planes;
diff --git a/libavfilter/vf_xmedian.c b/libavfilter/vf_xmedian.c
index f411d063f1b..89c72b93d46 100644
--- a/libavfilter/vf_xmedian.c
+++ b/libavfilter/vf_xmedian.c
@@ -229,7 +229,7 @@ static int process_frame(FFFrameSync *fs)
         td.in = in;
         td.out = out;
         ff_filter_execute(ctx, s->median_frames, &td, NULL,
-                          FFMIN(s->height[1], s->nb_threads));
+                          FFMINI(s->height[1], s->nb_threads));
     }
 
     return ff_filter_frame(outlink, out);
@@ -431,7 +431,7 @@ static int tmedian_filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.out = out;
     td.in = s->frames;
     ff_filter_execute(ctx, s->median_frames, &td, NULL,
-                      FFMIN(s->height[1], s->nb_threads));
+                      FFMINI(s->height[1], s->nb_threads));
 
     return ff_filter_frame(outlink, out);
 }
diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c
index 34c875456e6..7a845048947 100644
--- a/libavfilter/vf_xpsnr.c
+++ b/libavfilter/vf_xpsnr.c
@@ -273,10 +273,10 @@ static int get_wsse(AVFilterContext *ctx, int16_t **org, int16_t *org_m1,
     const uint32_t       w = s->plane_width [0]; /* luma image width in pixels */
     const uint32_t       h = s->plane_height[0];/* luma image height in pixels */
     const double         r = (double)(w * h) / (3840.0 * 2160.0); /* UHD ratio */
-    const uint32_t       b = FFMAX(0, 4 * (int32_t) (32.0 * sqrt(r) +
+    const uint32_t       b = FFMAXI(0, 4 * (int32_t) (32.0 * sqrt(r) +
                                                      0.5)); /* block size, integer multiple of 4 for SIMD */
     const uint32_t   w_blk = (w + b - 1) / b; /* luma width in units of blocks */
-    const double   avg_act = sqrt(16.0 * (double) (1 << (2 * s->depth - 9)) / sqrt(FFMAX(0.00001,
+    const double   avg_act = sqrt(16.0 * (double) (1 << (2 * s->depth - 9)) / sqrt(FFMAXD(0.00001,
                                                                                    r))); /* the sqrt(a_pic) */
     const int  *stride_org = (s->bpp == 1 ? s->plane_width : s->line_sizes);
     uint32_t x, y, idx_blk = 0; /* the "16.0" above is due to fixed-point code */
@@ -321,15 +321,15 @@ static int get_wsse(AVFilterContext *ctx, int16_t **org, int16_t *org_m1,
                     if (x == 0) /* first column */
                         ms_act_prev = (idx_blk > 1 ? weights[idx_blk - 2] : 0);
                     else  /* after first column */
-                        ms_act_prev = (x > b ? FFMAX(weights[idx_blk - 2], weights[idx_blk]) : weights[idx_blk]);
+                        ms_act_prev = (x > b ? FFMAXD(weights[idx_blk - 2], weights[idx_blk]) : weights[idx_blk]);
 
                     if (idx_blk > w_blk) /* after the first row and first column */
-                        ms_act_prev = FFMAX(ms_act_prev, weights[idx_blk - 1 - w_blk]); /* min (L, T) */
+                        ms_act_prev = FFMAXD(ms_act_prev, weights[idx_blk - 1 - w_blk]); /* min (L, T) */
                     if ((idx_blk > 0) && (weights[idx_blk - 1] > ms_act_prev))
                         weights[idx_blk - 1] = ms_act_prev;
 
                     if ((x + b >= w) && (y + b >= h) && (idx_blk > w_blk)) { /* last block in picture */
-                        ms_act_prev = FFMAX(weights[idx_blk - 1], weights[idx_blk - w_blk]);
+                        ms_act_prev = FFMAXD(weights[idx_blk - 1], weights[idx_blk - w_blk]);
                         if (weights[idx_blk] > ms_act_prev)
                             weights[idx_blk] = ms_act_prev;
                     }
@@ -399,7 +399,7 @@ static int do_xpsnr(FFFrameSync *fs)
     XPSNRContext *const s = ctx->priv;
     const uint32_t      w = s->plane_width [0];  /* luma image width in pixels */
     const uint32_t      h = s->plane_height[0]; /* luma image height in pixels */
-    const uint32_t      b = FFMAX(0, 4 * (int32_t) (32.0 * sqrt((double) (w * h) / (3840.0 * 2160.0)) + 0.5)); /* block size */
+    const uint32_t      b = FFMAXI(0, 4 * (int32_t) (32.0 * sqrt((double) (w * h) / (3840.0 * 2160.0)) + 0.5)); /* block size */
     const uint32_t  w_blk = (w + b - 1) / b;  /* luma width in units of blocks */
     const uint32_t  h_blk = (h + b - 1) / b; /* luma height in units of blocks */
     AVFrame *master, *ref = NULL;
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 6e0e5008864..1e55c85cdb6 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -65,8 +65,8 @@ typedef struct ThreadData {
         if (!(mode&2)) { \
             int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
             int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
-            int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
-            int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
+            int max = FFMAX3(d - e, d - c, FFMINI(b - c, f - e)); \
+            int min = FFMIN3(d - e, d - c, FFMAXI(b - c, f - e)); \
  \
             diff = FFMAX3(diff, min, -max); \
         } \
@@ -118,11 +118,11 @@ static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1,
     uint8_t *next2 = parity ? cur  : next;
 
     const int edge = MAX_ALIGN - 1;
-    int offset = FFMAX(w - edge, 3);
+    int offset = FFMAXI(w - edge, 3);
 
     /* Only edge pixels need to be processed here.  A constant value of false
      * for is_not_edge should let the compiler ignore the whole branch. */
-    FILTER(0, FFMIN(3, w), 0)
+    FILTER(0, FFMINI(3, w), 0)
 
     dst  = (uint8_t*)dst1  + offset;
     prev = (uint8_t*)prev1 + offset;
@@ -132,7 +132,7 @@ static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1,
     next2 = (uint8_t*)(parity ? cur  : next);
 
     FILTER(offset, w - 3, 1)
-    offset = FFMAX(offset, w - 3);
+    offset = FFMAXI(offset, w - 3);
     FILTER(offset, w, 0)
 }
 
@@ -167,12 +167,12 @@ static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1,
     uint16_t *next2 = parity ? cur  : next;
 
     const int edge = MAX_ALIGN / 2 - 1;
-    int offset = FFMAX(w - edge, 3);
+    int offset = FFMAXI(w - edge, 3);
 
     mrefs /= 2;
     prefs /= 2;
 
-    FILTER(0,  FFMIN(3, w), 0)
+    FILTER(0,  FFMINI(3, w), 0)
 
     dst   = (uint16_t*)dst1  + offset;
     prev  = (uint16_t*)prev1 + offset;
@@ -182,7 +182,7 @@ static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1,
     next2 = (uint16_t*)(parity ? cur  : next);
 
     FILTER(offset, w - 3, 1)
-    offset = FFMAX(offset, w - 3);
+    offset = FFMAXI(offset, w - 3);
     FILTER(offset, w, 0)
 }
 
@@ -247,7 +247,7 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic,
         td.plane   = i;
 
         ff_filter_execute(ctx, filter_slice, &td, NULL,
-                          FFMIN(h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(h, ff_filter_get_nb_threads(ctx)));
     }
 }
 
diff --git a/libavfilter/vf_yaepblur.c b/libavfilter/vf_yaepblur.c
index 50fe78df5aa..f8a5290a5b3 100644
--- a/libavfilter/vf_yaepblur.c
+++ b/libavfilter/vf_yaepblur.c
@@ -251,14 +251,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         td.src          = in->data[plane];
         td.src_linesize = in->linesize[plane];
         ff_filter_execute(ctx, s->pre_calculate_row, &td, NULL,
-                          FFMIN(td.height, nb_threads));
+                          FFMINI(td.height, nb_threads));
         ff_filter_execute(ctx, pre_calculate_col, &td, NULL,
-                          FFMIN(td.width,  nb_threads));
+                          FFMINI(td.width,  nb_threads));
 
         td.dst          = out->data[plane];
         td.dst_linesize = out->linesize[plane];
         ff_filter_execute(ctx, s->filter_slice, &td, NULL,
-                          FFMIN(td.height, nb_threads));
+                          FFMINI(td.height, nb_threads));
     }
 
     if (out != in)
@@ -279,7 +279,7 @@ static int config_input(AVFilterLink *inlink)
     s->planeheight[0] = s->planeheight[3] = inlink->h;
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
-    s->radius = FFMIN(s->radius, AV_CEIL_RSHIFT(FFMIN(inlink->w, inlink->h), 1));
+    s->radius = FFMINI(s->radius, AV_CEIL_RSHIFT(FFMINI(inlink->w, inlink->h), 1));
 
     if (s->depth <= 8) {
         s->pre_calculate_row = pre_calculate_row_byte;
diff --git a/libavfilter/vf_zoompan.c b/libavfilter/vf_zoompan.c
index 762f1d213dc..4afa8ed92e9 100644
--- a/libavfilter/vf_zoompan.c
+++ b/libavfilter/vf_zoompan.c
@@ -183,13 +183,13 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va
 
     *dx = av_expr_eval(s->x_expr, var_values, NULL);
 
-    x = *dx = av_clipd(*dx, 0, FFMAX(in->width - w, 0));
+    x = *dx = av_clipd(*dx, 0, FFMAXI(in->width - w, 0));
     var_values[VAR_X] = *dx;
     x &= ~((1 << s->desc->log2_chroma_w) - 1);
 
     *dy = av_expr_eval(s->y_expr, var_values, NULL);
 
-    y = *dy = av_clipd(*dy, 0, FFMAX(in->height - h, 0));
+    y = *dy = av_clipd(*dy, 0, FFMAXI(in->height - h, 0));
     var_values[VAR_Y] = *dy;
     y &= ~((1 << s->desc->log2_chroma_h) - 1);
 
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index ef40dea0549..5f6ad206d1b 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -338,11 +338,11 @@ static int config_props(AVFilterLink *outlink)
         int tmp_h = av_rescale(w, inlink->h, inlink->w);
 
         if (s->force_original_aspect_ratio == 1) {
-             w = FFMIN(tmp_w, w);
-             h = FFMIN(tmp_h, h);
+             w = FFMINI(tmp_w, w);
+             h = FFMINI(tmp_h, h);
         } else {
-             w = FFMAX(tmp_w, w);
-             h = FFMAX(tmp_h, h);
+             w = FFMAXI(tmp_w, w);
+             h = FFMAXI(tmp_h, h);
         }
     }
 
@@ -836,7 +836,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
         link->dst->inputs[0]->colorspace  = in->colorspace;
         link->dst->inputs[0]->color_range = in->color_range;
 
-        s->nb_threads = av_clip(FFMIN(ff_filter_get_nb_threads(ctx), FFMIN(link->h, outlink->h) / MIN_TILESIZE), 1, MAX_THREADS);
+        s->nb_threads = av_clip(FFMINI(ff_filter_get_nb_threads(ctx), FFMINI(link->h, outlink->h) / MIN_TILESIZE), 1, MAX_THREADS);
         slice_params(s, out->height, in->height);
 
         zimg_image_format_default(&s->src_format, ZIMG_API_VERSION);
diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 49d5873c2f4..b3629320ccf 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -899,8 +899,8 @@ static int ddagrab_config_props(AVFilterLink *outlink)
         return AVERROR(ENOTSUP);
     }
 
-    dda->width -= FFMAX(dda->width - dda->raw_width + dda->offset_x, 0);
-    dda->height -= FFMAX(dda->height - dda->raw_height + dda->offset_y, 0);
+    dda->width -= FFMAXI(dda->width - dda->raw_width + dda->offset_x, 0);
+    dda->height -= FFMAXI(dda->height - dda->raw_height + dda->offset_y, 0);
 
     dda->time_base  = av_inv_q(dda->framerate);
     dda->time_frame = av_gettime_relative() / av_q2d(dda->time_base);
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index cb1b73773f6..c3e8302a047 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -416,7 +416,7 @@ static int activate(AVFilterContext *ctx)
         frame->duration = 1;
 
         ff_filter_execute(ctx, s->draw_slice, frame, NULL,
-                          FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                          FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 
         return ff_filter_frame(outlink, frame);
     }
diff --git a/libavfilter/vsrc_life.c b/libavfilter/vsrc_life.c
index cacdcfd9633..2a5306e8a16 100644
--- a/libavfilter/vsrc_life.c
+++ b/libavfilter/vsrc_life.c
@@ -199,7 +199,7 @@ static void fill_picture_rgb(AVFilterContext *ctx, AVFrame *picref)
             if (life->mold && v != ALIVE_CELL) {
                 const uint8_t *c1 = life-> mold_color;
                 const uint8_t *c2 = life->death_color;
-                int death_age = FFMIN((0xff - v) * life->mold, 0xff);
+                int death_age = FFMINI((0xff - v) * life->mold, 0xff);
                 *p++ = FAST_DIV255((c2[0] << 8) + ((int)c1[0] - (int)c2[0]) * death_age);
                 *p++ = FAST_DIV255((c2[1] << 8) + ((int)c1[1] - (int)c2[1]) * death_age);
                 *p++ = FAST_DIV255((c2[2] << 8) + ((int)c1[2] - (int)c2[2]) * death_age);
@@ -227,7 +227,7 @@ static int init_pattern_from_file(AVFilterContext *ctx)
     w = 0;
     for (i = 0; i < life->file_bufsize; i++) {
         if (life->file_buf[i] == '\n') {
-            h++; max_w = FFMAX(w, max_w); w = 0;
+            h++; max_w = FFMAXI(w, max_w); w = 0;
         } else {
             w++;
         }
diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 3f14f1e7f9f..bb358a03c89 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -192,7 +192,7 @@ static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
     if(!x || !y || x+1==s->w || y+1==s->h)
         return 0;
 
-    dist= FFMAX(FFABS(x-(s->w>>1))*s->h, FFABS(y-(s->h>>1))*s->w);
+    dist= FFMAXI(FFABS(x-(s->w>>1))*s->h, FFABS(y-(s->h>>1))*s->w);
 
     if(dist<(s->w*s->h>>3))
         return 0;
@@ -317,7 +317,7 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
                 i++;
                 Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
                 if(zr*zr + zi*zi > s->bailout){
-                    i-= FFMIN(7, i);
+                    i-= FFMINI(7, i);
                     for(; i<s->maxiter; i++){
                         zr= s->zyklus[i][0];
                         zi= s->zyklus[i][1];
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index 2eb9a46d88b..9f471b02dbc 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -160,7 +160,7 @@ static void draw_cbp(uint8_t *dst[3], int dst_linesize[3], int cbp, int amp, int
 
 static void dc_test(uint8_t *dst, int dst_linesize, int w, int h, int off)
 {
-    const int step = FFMAX(256/(w*h/256), 1);
+    const int step = FFMAXI(256/(w*h/256), 1);
     int x, y, color = off;
 
     for (y = 0; y < h; y += 16) {
diff --git a/libavfilter/vsrc_sierpinski.c b/libavfilter/vsrc_sierpinski.c
index c9134184a52..5742e2745bd 100644
--- a/libavfilter/vsrc_sierpinski.c
+++ b/libavfilter/vsrc_sierpinski.c
@@ -182,7 +182,7 @@ static void draw_sierpinski(AVFilterContext *ctx, AVFrame *frame)
     }
 
     ff_filter_execute(ctx, s->draw_slice, frame, NULL,
-                      FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(outlink->h, ff_filter_get_nb_threads(ctx)));
 }
 
 static int sierpinski_request_frame(AVFilterLink *link)
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 78680441a8d..d863e789122 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -795,8 +795,8 @@ static void test2_fill_picture(AVFilterContext *ctx, AVFrame *frame)
 
     /* top right: draw clock hands */
     if (s->w >= 64 && s->h >= 64) {
-        int l = (FFMIN(s->w, s->h) - 32) >> 1;
-        int steps = FFMAX(4, l >> 5);
+        int l = (FFMINI(s->w, s->h) - 32) >> 1;
+        int steps = FFMAXI(4, l >> 5);
         int xc = (s->w >> 2) + (s->w >> 1);
         int yc = (s->h >> 2);
         int cycle = l << 2;
@@ -828,7 +828,7 @@ static void test2_fill_picture(AVFilterContext *ctx, AVFrame *frame)
 
     /* bottom left: beating rectangles */
     if (s->w >= 64 && s->h >= 64) {
-        int l = (FFMIN(s->w, s->h) - 16) >> 2;
+        int l = (FFMINI(s->w, s->h) - 16) >> 2;
         int cycle = l << 3;
         int xc = (s->w >> 2);
         int yc = (s->h >> 2) + (s->h >> 1);
@@ -1087,7 +1087,7 @@ static void rgbtest_fill_picture_complement(AVFilterContext *ctx, AVFrame *frame
 
     for (y = 0; y < h; y++) {
          for (x = 0; x < w; x++) {
-             int c = (1 << FFMAX(test->depth, 8))*x/w;
+             int c = (1 << FFMAXI(test->depth, 8))*x/w;
              int r = 0, g = 0, b = 0;
 
              if      (6*y < h  ) r = c;
@@ -1110,7 +1110,7 @@ static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
 
     for (y = 0; y < h; y++) {
          for (x = 0; x < w; x++) {
-             int c = (1 << FFMAX(test->depth, 8))*x/w;
+             int c = (1 << FFMAXI(test->depth, 8))*x/w;
              int r = 0, g = 0, b = 0;
 
              if      (3*y < h  ) r = c;
@@ -1428,10 +1428,10 @@ static void draw_bar(TestSourceContext *test, const uint8_t color[4],
     uint8_t *p, *p0;
     int plane;
 
-    x = FFMIN(x, test->w - 1);
-    y = FFMIN(y, test->h - 1);
-    w = FFMAX(FFMIN(w, test->w - x), 0);
-    h = FFMAX(FFMIN(h, test->h - y), 0);
+    x = FFMINI(x, test->w - 1);
+    y = FFMINI(y, test->h - 1);
+    w = FFMAXI(FFMINI(w, test->w - x), 0);
+    h = FFMAXI(FFMINI(h, test->h - y), 0);
 
     av_assert0(x + w <= test->w);
     av_assert0(y + h <= test->h);
@@ -2193,7 +2193,7 @@ static void zoneplate_fill_picture(AVFilterContext *ctx, AVFrame *frame)
 {
     TestSourceContext *test = ctx->priv;
     ff_filter_execute(ctx, test->fill_slice_fn, frame, NULL,
-                      FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
+                      FFMINI(frame->height, ff_filter_get_nb_threads(ctx)));
 }
 
 static int zoneplate_config_props(AVFilterLink *outlink)
diff --git a/libavfilter/window_func.h b/libavfilter/window_func.h
index d4e39c3efed..766435be818 100644
--- a/libavfilter/window_func.h
+++ b/libavfilter/window_func.h
@@ -173,7 +173,7 @@ static inline void generate_window_func(float *lut, int N, int win_func,
             if (x <= -.5 || x >= .5) {
                 lut[n] = 0;
             } else {
-                lut[n] = FFMIN(1, fabs(1/(1+4*16*x*x)));
+                lut[n] = FFMIND(1, fabs(1/(1+4*16*x*x)));
             }
         }
         *overlap = 0.75;
diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index 0b4bd69dd28..ebc1c44f01c 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -61,10 +61,10 @@ static int adts_aac_probe(const AVProbeData *p)
             fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
             if (fsize < 7)
                 break;
-            fsize = FFMIN(fsize, end - buf2);
+            fsize = FFMINI(fsize, end - buf2);
             buf2 += fsize;
         }
-        max_frames = FFMAX(max_frames, frames);
+        max_frames = FFMAXI(max_frames, frames);
         if (buf == buf0)
             first_frames = frames;
     }
diff --git a/libavformat/ac3dec.c b/libavformat/ac3dec.c
index 0b1557d68c5..ea0270409f2 100644
--- a/libavformat/ac3dec.c
+++ b/libavformat/ac3dec.c
@@ -85,7 +85,7 @@ static int ac3_eac3_probe(const AVProbeData *p, enum AVCodecID expected_codec_id
                 codec_id = AV_CODEC_ID_EAC3;
             buf2 += frame_size;
         }
-        max_frames = FFMAX(max_frames, frames);
+        max_frames = FFMAXI(max_frames, frames);
         if(buf == p->buf)
             first_frames = frames;
     }
diff --git a/libavformat/ac4dec.c b/libavformat/ac4dec.c
index dc6638de3a4..6d4f7edfe51 100644
--- a/libavformat/ac4dec.c
+++ b/libavformat/ac4dec.c
@@ -53,7 +53,7 @@ static int ac4_probe(const AVProbeData *p)
         }
     }
 
-    return FFMIN(AVPROBE_SCORE_MAX, max_frames * 7);
+    return FFMINI(AVPROBE_SCORE_MAX, max_frames * 7);
 }
 
 static int ac4_read_header(AVFormatContext *s)
diff --git a/libavformat/aeadec.c b/libavformat/aeadec.c
index be18e7b7256..bba2d0fa22b 100644
--- a/libavformat/aeadec.c
+++ b/libavformat/aeadec.c
@@ -53,7 +53,7 @@ static int aea_read_probe(const AVProbeData *p)
                 return 0;
             score++;
         }
-        return FFMIN(AVPROBE_SCORE_MAX / 4 + score, AVPROBE_SCORE_MAX);
+        return FFMINI(AVPROBE_SCORE_MAX / 4 + score, AVPROBE_SCORE_MAX);
     }
     return 0;
 }
diff --git a/libavformat/afc.c b/libavformat/afc.c
index 3113554c0f5..a89588f021b 100644
--- a/libavformat/afc.c
+++ b/libavformat/afc.c
@@ -60,7 +60,7 @@ static int afc_read_packet(AVFormatContext *s, AVPacket *pkt)
     int64_t size = c->data_end - avio_tell(s->pb);
     int ret;
 
-    size = FFMIN(size, 18 * 128);
+    size = FFMINI(size, 18 * 128);
     if (size <= 0)
         return AVERROR_EOF;
 
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index bd5bd2e4bbc..ccbddb4500a 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -423,7 +423,7 @@ static int aiff_read_packet(AVFormatContext *s,
         if (!size)
             return AVERROR_INVALIDDATA;
     }
-    size = FFMIN(max_size, size);
+    size = FFMINI(max_size, size);
     res = av_get_packet(s->pb, pkt, size);
     if (res < 0)
         return res;
diff --git a/libavformat/amvenc.c b/libavformat/amvenc.c
index 5ff4f69cfa5..c58ff1bb0c3 100644
--- a/libavformat/amvenc.c
+++ b/libavformat/amvenc.c
@@ -381,7 +381,7 @@ static int amv_write_trailer(AVFormatContext *s)
         return ret;
 
     /* Go back and write the duration. */
-    maxpts = FFMAX(
+    maxpts = FFMAXI(
         av_rescale_q(amv->lastpts[AMV_STREAM_VIDEO], vst->time_base, AV_TIME_BASE_Q),
         av_rescale_q(amv->lastpts[AMV_STREAM_AUDIO], ast->time_base, AV_TIME_BASE_Q)
     );
diff --git a/libavformat/anm.c b/libavformat/anm.c
index 789780d606f..3cf4d08ab51 100644
--- a/libavformat/anm.c
+++ b/libavformat/anm.c
@@ -112,7 +112,7 @@ static int read_header(AVFormatContext *s)
 
     /* ignore last delta record (used for looping) */
     if (avio_r8(pb))  /* has_last_delta */
-        anm->nb_records = FFMAX(anm->nb_records - 1, 0);
+        anm->nb_records = FFMAXI(anm->nb_records - 1, 0);
 
     avio_skip(pb, 1); /* last_delta_valid */
 
diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index e08f029f80c..65ef4e1e048 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -229,7 +229,7 @@ static int argo_asf_read_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR_EOF;
 
     ret = av_get_packet(pb, pkt, st->codecpar->block_align *
-                        FFMIN(ASF_NB_BLOCKS, asf->ckhdr.num_blocks - asf->blocks_read));
+                        FFMINI(ASF_NB_BLOCKS, asf->ckhdr.num_blocks - asf->blocks_read));
     if (ret < 0)
         return ret;
 
@@ -368,7 +368,7 @@ static int argo_asf_write_header(AVFormatContext *s)
     } else {
         len = end - name;
     }
-    memcpy(fhdr.name, name, FFMIN(len, ASF_NAME_SIZE));
+    memcpy(fhdr.name, name, FFMINI(len, ASF_NAME_SIZE));
 
     chdr.num_blocks    = 0;
     chdr.num_samples   = ASF_SAMPLE_COUNT;
diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index 9d898d31937..b2bc952a0a0 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -152,7 +152,7 @@ static int argo_brp_read_header(AVFormatContext *s)
     int64_t ret;
     AVIOContext *pb = s->pb;
     ArgoBRPDemuxContext *brp = s->priv_data;
-    uint8_t buf[FFMAX(BRP_MIN_BUFFER_SIZE, ASF_MIN_BUFFER_SIZE)];
+    uint8_t buf[FFMAXI(BRP_MIN_BUFFER_SIZE, ASF_MIN_BUFFER_SIZE)];
 
     ret = ffio_read_size(pb, buf, BRP_FILE_HEADER_SIZE);
     if (ret < 0)
diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index 03ae6fa59e9..830bb30cba8 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -234,7 +234,7 @@ static int argo_cvg_read_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR_EOF;
 
     ret = av_get_packet(s->pb, pkt, st->codecpar->block_align *
-                        FFMIN(ARGO_CVG_NB_BLOCKS, ctx->num_blocks - ctx->blocks_read));
+                        FFMINI(ARGO_CVG_NB_BLOCKS, ctx->num_blocks - ctx->blocks_read));
 
     if (ret < 0)
         return ret;
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index ea6e8ef4f3a..31efa1d72c2 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -327,7 +327,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
     if (!(asf->hdr.flags & 0x01)) { // if we aren't streaming...
         int64_t fsize = avio_size(pb);
         if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 ||
-            FFABS(fsize - (int64_t)asf->hdr.file_size) < FFMIN(fsize, asf->hdr.file_size)/20)
+            FFABS(fsize - (int64_t)asf->hdr.file_size) < FFMINI(fsize, asf->hdr.file_size)/20)
             st->duration = asf->hdr.play_time /
                        (10000000 / 1000) - start_time;
     }
@@ -439,7 +439,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
                 asf_st->palette[i] = av_bswap32(((uint32_t *)st->codecpar->extradata)[i]);
 #else
             memcpy(asf_st->palette, st->codecpar->extradata,
-                   FFMIN(st->codecpar->extradata_size, AVPALETTE_SIZE));
+                   FFMINI(st->codecpar->extradata_size, AVPALETTE_SIZE));
 #endif
             asf_st->palette_changed = 1;
         }
@@ -1538,7 +1538,7 @@ static int asf_build_simple_index(AVFormatContext *s, int stream_index)
             int pktnum        = avio_rl32(s->pb);
             int pktct         = avio_rl16(s->pb);
             int64_t pos       = ffformatcontext(s)->data_offset + s->packet_size * (int64_t)pktnum;
-            int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
+            int64_t index_pts = FFMAXI(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
 
             if (avio_feof(s->pb)) {
                 ret = AVERROR_INVALIDDATA;
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 75285b065cb..63137ee0628 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -1002,7 +1002,7 @@ static int update_index(AVFormatContext *s, int start_sec,
 
         }
     }
-    asf->maximum_packet     = FFMAX(asf->maximum_packet, packet_count);
+    asf->maximum_packet     = FFMAXI(asf->maximum_packet, packet_count);
     asf->next_packet_number = packet_number;
     asf->next_packet_count  = packet_count;
     asf->next_packet_offset = packet_offset;
@@ -1038,7 +1038,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR(EINVAL);
     }
     pts *= 10000;
-    asf->duration = FFMAX(asf->duration, pts + pkt->duration * 10000);
+    asf->duration = FFMAXI(asf->duration, pts + pkt->duration * 10000);
 
     packet_number = asf->nb_packets;
     put_frame(s, stream, s->streams[pkt->stream_index],
diff --git a/libavformat/async.c b/libavformat/async.c
index e0329e23ec8..ea587a780f1 100644
--- a/libavformat/async.c
+++ b/libavformat/async.c
@@ -230,7 +230,7 @@ static void *async_buffer_task(void *arg)
         }
         pthread_mutex_unlock(&c->mutex);
 
-        to_copy = FFMIN(4096, fifo_space);
+        to_copy = FFMINI(4096, fifo_space);
         ret = ring_write(ring, h, to_copy);
 
         pthread_mutex_lock(&c->mutex);
@@ -354,7 +354,7 @@ static int async_read_internal(URLContext *h, void *dest, int size)
             break;
         }
         fifo_size = ring_size(ring);
-        to_copy   = FFMIN(to_read, fifo_size);
+        to_copy   = FFMINI(to_read, fifo_size);
         if (to_copy > 0) {
             ring_read(ring, dest, to_copy);
             if (dest)
diff --git a/libavformat/au.c b/libavformat/au.c
index 22449958258..29cbfc6ca4c 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -227,7 +227,7 @@ static int au_read_header(AVFormatContext *s)
     st->codecpar->sample_rate = rate;
     st->codecpar->bits_per_coded_sample = bps;
     st->codecpar->bit_rate    = channels * rate * bps;
-    st->codecpar->block_align = ba ? ba : FFMAX(bps * channels / 8, 1);
+    st->codecpar->block_align = ba ? ba : FFMAXI(bps * channels / 8, 1);
     if (data_size != AU_UNKNOWN_SIZE)
         st->duration = (((int64_t)data_size)<<3) / (channels * (int64_t)bps);
 
diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
index 0a81db4ef04..60fcd3657bd 100644
--- a/libavformat/av1dec.c
+++ b/libavformat/av1dec.c
@@ -191,7 +191,7 @@ static int annexb_probe(const AVProbeData *p)
         return 0;
 
     // Check that the first OBU is a Temporal Delimiter.
-    ret = read_obu(p->buf + cnt, FFMIN(p->buf_size - cnt, obu_unit_size), &obu_size, &type);
+    ret = read_obu(p->buf + cnt, FFMINI(p->buf_size - cnt, obu_unit_size), &obu_size, &type);
     if (ret < 0 || type != AV1_OBU_TEMPORAL_DELIMITER || obu_size > 0)
         return 0;
     cnt += obu_unit_size;
@@ -206,7 +206,7 @@ static int annexb_probe(const AVProbeData *p)
         if (pb->eof_reached || pb->error)
             return 0;
 
-        ret = read_obu(p->buf + cnt, FFMIN(p->buf_size - cnt, obu_unit_size), &obu_size, &type);
+        ret = read_obu(p->buf + cnt, FFMINI(p->buf_size - cnt, obu_unit_size), &obu_size, &type);
         if (ret < 0)
             return 0;
         cnt += obu_unit_size;
@@ -314,7 +314,7 @@ static int read_obu_with_size(const uint8_t *buf, int buf_size, int64_t *obu_siz
     int ret, extension_flag, start_pos;
     int64_t size;
 
-    ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE));
+    ret = init_get_bits8(&gb, buf, FFMINI(buf_size, MAX_OBU_HEADER_SIZE));
     if (ret < 0)
         return ret;
 
@@ -363,7 +363,7 @@ static int obu_probe(const AVProbeData *p)
         ret = read_obu_with_size(p->buf + cnt, p->buf_size - cnt, &obu_size, &type);
         if (ret < 0 || obu_size <= 0)
             return 0;
-        cnt += FFMIN(ret, p->buf_size - cnt);
+        cnt += FFMINI(ret, p->buf_size - cnt);
 
         ret = get_score(type, &seq);
         if (ret >= 0)
diff --git a/libavformat/avc.c b/libavformat/avc.c
index e4040928cdb..da9486a1250 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -66,7 +66,7 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
     while (end - buf > 4) {
         uint32_t size;
         uint8_t nal_type;
-        size = FFMIN(AV_RB32(buf), end - buf - 4);
+        size = FFMINI(AV_RB32(buf), end - buf - 4);
         buf += 4;
         nal_type = buf[0] & 0x1f;
 
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 18ca4643eec..d834bc1224d 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -415,7 +415,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
                       + !! (st->disposition & AV_DISPOSITION_DEFAULT);
         count = ffstream(st)->codec_info_nb_frames;
         bitrate = par->bit_rate;
-        multiframe = FFMIN(5, count);
+        multiframe = FFMINI(5, count);
         if ((best_disposition >  disposition) ||
             (best_disposition == disposition && best_multiframe >  multiframe) ||
             (best_disposition == disposition && best_multiframe == multiframe && best_bitrate >  bitrate) ||
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 81a0ae31bab..50f4985877c 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -225,7 +225,7 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num)
     }
 
     for (i = 0; i < entries_in_use; i++) {
-        avi->odml_max_pos = FFMAX(avi->odml_max_pos, avio_tell(pb));
+        avi->odml_max_pos = FFMAXI(avi->odml_max_pos, avio_tell(pb));
 
         // If we read more than there are bytes then we must have been reading something twice
         if (avi->odml_read > avi->odml_max_pos)
@@ -314,7 +314,7 @@ static void clean_index(AVFormatContext *s)
         ts   = sti->index_entries[0].timestamp;
 
         for (j = 0; j < size; j += max)
-            av_add_index_entry(st, pos + j, ts + j, FFMIN(max, size - j), 0,
+            av_add_index_entry(st, pos + j, ts + j, FFMINI(max, size - j), 0,
                                AVINDEX_KEYFRAME);
     }
 }
@@ -382,9 +382,9 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
                 const char *name = NULL;
                 char buffer[64]  = { 0 };
                 uint64_t remaining = tag_end - avio_tell(s->pb);
-                size = FFMIN(size, remaining);
+                size = FFMINI(size, remaining);
                 size -= avio_read(s->pb, buffer,
-                                  FFMIN(size, sizeof(buffer) - 1));
+                                  FFMINI(size, sizeof(buffer) - 1));
                 switch (tag) {
                 case 0x03:
                     name = "maker";
@@ -465,7 +465,7 @@ static int calculate_bitrate(AVFormatContext *s)
 
         for (j = 0; j < sti->nb_index_entries; j++)
             len += sti->index_entries[j].size;
-        maxpos = FFMAX(maxpos, sti->index_entries[j-1].pos);
+        maxpos = FFMAXI(maxpos, sti->index_entries[j-1].pos);
         lensum += len;
     }
     if (maxpos < av_rescale(avi->io_fsize, 9, 10)) // index does not cover the whole file
@@ -566,7 +566,7 @@ static int avi_read_header(AVFormatContext *s)
         {
             unsigned char date[64] = { 0 };
             size += (size & 1);
-            size -= avio_read(pb, date, FFMIN(size, sizeof(date) - 1));
+            size -= avio_read(pb, date, FFMINI(size, sizeof(date) - 1));
             avio_skip(pb, size);
             avi_metadata_creation_time(&s->metadata, date);
             break;
@@ -702,7 +702,7 @@ static int avi_read_header(AVFormatContext *s)
                 ast->cum_len = 0;
             }
             ast->sample_size = avio_rl32(pb);
-            ast->cum_len    *= FFMAX(1, ast->sample_size);
+            ast->cum_len    *= FFMAXI(1, ast->sample_size);
             av_log(s, AV_LOG_TRACE, "%"PRIu32" %"PRIu32" %d\n",
                     ast->rate, ast->scale, ast->sample_size);
 
@@ -764,7 +764,7 @@ static int avi_read_header(AVFormatContext *s)
                 FFStream *sti;
                 unsigned esize;
                 if (cur_pos < list_end)
-                    size = FFMIN(size, list_end - cur_pos);
+                    size = FFMINI(size, list_end - cur_pos);
                 st = s->streams[stream_index];
                 sti = ffstream(st);
                 if (st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN) {
@@ -818,7 +818,7 @@ static int avi_read_header(AVFormatContext *s)
                         int pal_size = (1 << st->codecpar->bits_per_coded_sample) << 2;
                         const uint8_t *pal_src;
 
-                        pal_size = FFMIN(pal_size, st->codecpar->extradata_size);
+                        pal_size = FFMINI(pal_size, st->codecpar->extradata_size);
                         pal_src  = st->codecpar->extradata +
                                    st->codecpar->extradata_size - pal_size;
                         /* Exclude the "BottomUp" field from the palette */
@@ -965,7 +965,7 @@ static int avi_read_header(AVFormatContext *s)
             } else {
                 uint64_t cur_pos = avio_tell(pb);
                 if (cur_pos < list_end)
-                    size = FFMIN(size, list_end - cur_pos);
+                    size = FFMINI(size, list_end - cur_pos);
                 st = s->streams[stream_index];
 
                 if (size<(1<<30)) {
@@ -1418,7 +1418,7 @@ static int ni_prepare_read(AVFormatContext *s)
             continue;
 
         ts = av_rescale_q(ts, st->time_base,
-                          (AVRational) { FFMAX(1, ast->sample_size),
+                          (AVRational) { FFMAXI(1, ast->sample_size),
                                          AV_TIME_BASE });
 
         av_log(s, AV_LOG_TRACE, "%"PRId64" %d/%d %"PRId64"\n", ts,
@@ -1559,7 +1559,7 @@ resync:
                         int key=1;
                         uint32_t state=-1;
                         if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
-                            const uint8_t *ptr = pkt->data, *end = ptr + FFMIN(size, 256);
+                            const uint8_t *ptr = pkt->data, *end = ptr + FFMINI(size, 256);
                             while (ptr < end) {
                                 ptr = avpriv_find_start_code(ptr, end, &state);
                                 if (state == 0x1B6 && ptr < end) {
@@ -1724,10 +1724,10 @@ static int check_stream_max_drift(AVFormatContext *s)
             if (idx[i] < n) {
                 int64_t dts;
                 dts = av_rescale_q(sti->index_entries[idx[i]].timestamp /
-                                   FFMAX(ast->sample_size, 1),
+                                   FFMAXI(ast->sample_size, 1),
                                    st->time_base, AV_TIME_BASE_Q);
-                min_dts = FFMIN(min_dts, dts);
-                min_pos = FFMIN(min_pos, sti->index_entries[idx[i]].pos);
+                min_dts = FFMINI(min_dts, dts);
+                min_pos = FFMINI(min_pos, sti->index_entries[idx[i]].pos);
             }
         }
         for (i = 0; i < s->nb_streams; i++) {
@@ -1738,11 +1738,11 @@ static int check_stream_max_drift(AVFormatContext *s)
             if (idx[i] && min_dts != INT64_MAX / 2) {
                 int64_t dts, delta_dts;
                 dts = av_rescale_q(sti->index_entries[idx[i] - 1].timestamp /
-                                   FFMAX(ast->sample_size, 1),
+                                   FFMAXI(ast->sample_size, 1),
                                    st->time_base, AV_TIME_BASE_Q);
                 delta_dts = av_sat_sub64(dts, min_dts);
-                max_dts = FFMAX(max_dts, dts);
-                max_buffer = FFMAX(max_buffer,
+                max_dts = FFMAXI(max_dts, dts);
+                max_buffer = FFMAXI(max_buffer,
                                    av_rescale(delta_dts,
                                               st->codecpar->bit_rate,
                                               AV_TIME_BASE));
@@ -1887,7 +1887,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
         timestamp = av_rescale_q(timestamp, st->time_base,
                                  (AVRational){ ast->scale, ast->rate });
     } else
-        timestamp *= FFMAX(ast->sample_size, 1);
+        timestamp *= FFMAXI(ast->sample_size, 1);
 
     index = av_index_search_timestamp(st, timestamp, flags);
     if (index < 0) {
@@ -1923,7 +1923,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
         avi->stream_index = -1;
         return 0;
     }
-    timestamp /= FFMAX(ast->sample_size, 1);
+    timestamp /= FFMAXI(ast->sample_size, 1);
 
     pos_min = pos;
     for (i = 0; i < s->nb_streams; i++) {
@@ -1947,14 +1947,14 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
                                           av_rescale_q(timestamp,
                                                        st->time_base,
                                                        st2->time_base) *
-                                          FFMAX(ast2->sample_size, 1),
+                                          FFMAXI(ast2->sample_size, 1),
                                           flags |
                                           AVSEEK_FLAG_BACKWARD |
                                           (st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
         if (index < 0)
             index = 0;
         ast2->seek_pos = sti2->index_entries[index].pos;
-        pos_min = FFMIN(pos_min,ast2->seek_pos);
+        pos_min = FFMINI(pos_min,ast2->seek_pos);
     }
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st2 = s->streams[i];
@@ -1966,7 +1966,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
 
         index = av_index_search_timestamp(
                 st2,
-                av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
+                av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAXI(ast2->sample_size, 1),
                 flags | AVSEEK_FLAG_BACKWARD | (st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
         if (index < 0)
             index = 0;
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 2a3cff1210d..f74de8eca65 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -138,7 +138,7 @@ static int avi_add_ientry(AVFormatContext *s, int stream_index, char *tag,
     idx->cluster[cl][id].flags = flags;
     idx->cluster[cl][id].pos   = avio_tell(pb) - avi->movi_list;
     idx->cluster[cl][id].len   = size;
-    avist->max_size = FFMAX(avist->max_size, size);
+    avist->max_size = FFMAXI(avist->max_size, size);
     idx->entry++;
 
     return 0;
@@ -150,7 +150,7 @@ static av_cold int avi_init(struct AVFormatContext *s)
 
     if (avi->reserve_index_space > 0) {
         avi->master_index_max_size = (avi->reserve_index_space - AVI_MASTER_INDEX_PREFIX_SIZE) / AVI_MASTER_INDEX_ENTRY_SIZE;
-        avi->master_index_max_size = FFMAX(avi->master_index_max_size, 16);
+        avi->master_index_max_size = FFMAXI(avi->master_index_max_size, 16);
     } else
         avi->master_index_max_size = AVI_MASTER_INDEX_SIZE_DEFAULT;
     av_log(s, AV_LOG_DEBUG, "reserve_index_space:%d master_index_max_size:%d\n",
@@ -220,7 +220,7 @@ static int avi_write_counters(AVFormatContext *s, int riff_id)
         else
             avio_wl32(pb, avist->audio_strm_length / au_ssize);
         if (par->codec_type == AVMEDIA_TYPE_VIDEO)
-            nb_frames = FFMAX(nb_frames, avist->packet_count);
+            nb_frames = FFMAXI(nb_frames, avist->packet_count);
     }
     if (riff_id == 1) {
         av_assert0(avi->frames_hdr_all);
@@ -296,10 +296,10 @@ static int avi_write_header(AVFormatContext *s)
     for (n = 0; n < s->nb_streams; n++) {
         AVCodecParameters *par = s->streams[n]->codecpar;
         AVStream *st = s->streams[n];
-        bitrate = FFMIN(bitrate + par->bit_rate, INT32_MAX);
+        bitrate = FFMINI(bitrate + par->bit_rate, INT32_MAX);
         if (st->duration > 0) {
             int64_t stream_duration = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
-            max_stream_duration = FFMAX(stream_duration, max_stream_duration);
+            max_stream_duration = FFMAXI(stream_duration, max_stream_duration);
         }
         if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
             video_par = par;
@@ -317,7 +317,7 @@ static int avi_write_header(AVFormatContext *s)
         else
             duration_est = 10 * 60 * 60; /* default to 10 hours */
         filesize_est = duration_est * (bitrate / 8) * 1.10; /* add 10% safety margin for muxer+bitrate */
-        avi->master_index_max_size = FFMAX((int)ceil(filesize_est / AVI_MAX_RIFF_SIZE) + 1,
+        avi->master_index_max_size = FFMAXI((int)ceil(filesize_est / AVI_MAX_RIFF_SIZE) + 1,
                                            avi->master_index_max_size);
         av_log(s, AV_LOG_DEBUG, "duration_est:%0.3f, filesize_est:%0.1fGiB, master_index_max_size:%d\n",
                duration_est, filesize_est / (1024*1024*1024), avi->master_index_max_size);
diff --git a/libavformat/avio.c b/libavformat/avio.c
index d109f3adff0..74ff6660f2a 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -317,7 +317,7 @@ static const struct URLProtocol *url_find_protocol(const char *filename)
         strcpy(proto_str, "file");
     else
         av_strlcpy(proto_str, filename,
-                   FFMIN(proto_len + 1, sizeof(proto_str)));
+                   FFMINI(proto_len + 1, sizeof(proto_str)));
 
     av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
     if ((ptr = strchr(proto_nested, '+')))
@@ -537,7 +537,7 @@ static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
         else if (ret < 0)
             return ret;
         if (ret) {
-            fast_retries = FFMAX(fast_retries, 2);
+            fast_retries = FFMAXI(fast_retries, 2);
             wait_since = 0;
         }
         len += ret;
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 6a74c1ce68a..804e0e4f5fb 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -187,7 +187,7 @@ void avio_w8(AVIOContext *s, int b)
 void ffio_fill(AVIOContext *s, int b, int64_t count)
 {
     while (count > 0) {
-        int len = FFMIN(s->buf_end - s->buf_ptr, count);
+        int len = FFMINI(s->buf_end - s->buf_ptr, count);
         memset(s->buf_ptr, b, len);
         s->buf_ptr += len;
 
@@ -208,7 +208,7 @@ void avio_write(AVIOContext *s, const unsigned char *buf, int size)
         return;
     }
     do {
-        int len = FFMIN(s->buf_end - s->buf_ptr, size);
+        int len = FFMINI(s->buf_end - s->buf_ptr, size);
         memcpy(s->buf_ptr, buf, len);
         s->buf_ptr += len;
 
@@ -222,7 +222,7 @@ void avio_write(AVIOContext *s, const unsigned char *buf, int size)
 
 void avio_flush(AVIOContext *s)
 {
-    int seekback = s->write_flag ? FFMIN(0, s->buf_ptr - s->buf_ptr_max) : 0;
+    int seekback = s->write_flag ? FFMINI(0, s->buf_ptr - s->buf_ptr_max) : 0;
     flush_buffer(s);
     if (seekback)
         avio_seek(s, seekback, SEEK_CUR);
@@ -265,7 +265,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
     short_seek = ctx->short_seek_threshold;
     if (ctx->short_seek_get) {
         int tmp = ctx->short_seek_get(s->opaque);
-        short_seek = FFMAX(tmp, short_seek);
+        short_seek = FFMAXI(tmp, short_seek);
     }
 
     offset1 = offset - pos; // "offset1" is the relative offset from the beginning of s->buffer
@@ -287,7 +287,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
     } else if(!s->write_flag && offset1 < 0 && -offset1 < buffer_size>>1 && s->seek && offset > 0) {
         int64_t res;
 
-        pos -= FFMIN(buffer_size>>1, pos);
+        pos -= FFMINI(buffer_size>>1, pos);
         if ((res = s->seek(s->opaque, pos, SEEK_SET)) < 0)
             return res;
         s->buf_end =
@@ -615,7 +615,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
 
     size1 = size;
     while (size > 0) {
-        len = FFMIN(s->buf_end - s->buf_ptr, size);
+        len = FFMINI(s->buf_end - s->buf_ptr, size);
         if (len == 0 || s->write_flag) {
             if((s->direct || size > s->buffer_size) && !s->update_checksum && s->read_packet) {
                 // bypass the buffer and read data directly into buf
@@ -870,7 +870,7 @@ int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
     if (buflen <= 0)
         return AVERROR(EINVAL);
     // reserve 1 byte for terminating 0
-    buflen = FFMIN(buflen - 1, maxlen);
+    buflen = FFMINI(buflen - 1, maxlen);
     for (i = 0; i < buflen; i++)
         if (!(buf[i] = avio_r8(s)))
             return i + 1;
@@ -1168,7 +1168,7 @@ int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **bufp, int buf_si
     overlap = buf_size - buffer_start;
     new_size = buf_size + buffer_size - overlap;
 
-    alloc_size = FFMAX(s->buffer_size, new_size);
+    alloc_size = FFMAXI(s->buffer_size, new_size);
     if (alloc_size > buf_size)
         if (!(buf = (*bufp) = av_realloc_f(buf, 1, alloc_size)))
             return AVERROR(ENOMEM);
@@ -1253,7 +1253,7 @@ int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
     int ret;
     char buf[1024];
     while (max_size) {
-        ret = avio_read(h, buf, FFMIN(max_size, sizeof(buf)));
+        ret = avio_read(h, buf, FFMINI(max_size, sizeof(buf)));
         if (ret == AVERROR_EOF)
             return 0;
         if (ret <= 0)
@@ -1291,7 +1291,7 @@ static int dyn_buf_write(void *opaque, const uint8_t *buf, int buf_size)
         while (new_size > new_allocated_size)
             new_allocated_size += new_allocated_size / 2 + 1;
 
-        new_allocated_size = FFMIN(new_allocated_size, INT_MAX);
+        new_allocated_size = FFMINI(new_allocated_size, INT_MAX);
 
         if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) {
             d->allocated_size = 0;
diff --git a/libavformat/cache.c b/libavformat/cache.c
index 5d71e56f3d7..2ba48daaf82 100644
--- a/libavformat/cache.c
+++ b/libavformat/cache.c
@@ -184,7 +184,7 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
 
             if (r >= 0) {
                 c->cache_pos = r;
-                r = read(c->fd, buf, FFMIN(size, entry->size - in_block_pos));
+                r = read(c->fd, buf, FFMINI(size, entry->size - in_block_pos));
             }
 
             if (r > 0) {
@@ -220,7 +220,7 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
 
     add_entry(h, buf, r);
     c->logical_pos += r;
-    c->end = FFMAX(c->end, c->logical_pos);
+    c->end = FFMAXI(c->end, c->logical_pos);
 
     return r;
 }
@@ -239,7 +239,7 @@ static int64_t cache_seek(URLContext *h, int64_t pos, int whence)
         }
         if (pos > 0)
             c->is_true_eof = 1;
-        c->end = FFMAX(c->end, pos);
+        c->end = FFMAXI(c->end, pos);
         return pos;
     }
 
@@ -268,7 +268,7 @@ resolve_eof:
             while (c->logical_pos < pos || whence == SEEK_END) {
                 int size = sizeof(tmp);
                 if (whence == SEEK_SET)
-                    size = FFMIN(sizeof(tmp), pos - c->logical_pos);
+                    size = FFMINI(sizeof(tmp), pos - c->logical_pos);
                 ret = cache_read(h, tmp, size);
                 if (ret == AVERROR_EOF && whence == SEEK_END) {
                     av_assert0(c->is_true_eof);
@@ -284,7 +284,7 @@ resolve_eof:
 
     if (ret >= 0) {
         c->logical_pos = ret;
-        c->end = FFMAX(c->end, ret);
+        c->end = FFMAXI(c->end, ret);
     }
 
     return ret;
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 5d7dbe8f419..90899b3999c 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -451,7 +451,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 
     if (pkt_size > 0 && pkt_frames == 1) {
         pkt_size   = (CAF_MAX_PKT_SIZE / pkt_size) * pkt_size;
-        pkt_size   = FFMIN(pkt_size, left);
+        pkt_size   = FFMINI(pkt_size, left);
         pkt_frames = pkt_size / caf->bytes_per_packet;
     } else if (sti->nb_index_entries) {
         if (caf->packet_cnt < sti->nb_index_entries - 1) {
@@ -490,13 +490,13 @@ static int read_seek(AVFormatContext *s, int stream_index,
     CafContext *caf = s->priv_data;
     int64_t pos, packet_cnt, frame_cnt;
 
-    timestamp = FFMAX(timestamp, 0);
+    timestamp = FFMAXI(timestamp, 0);
 
     if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
         /* calculate new byte position based on target frame position */
         pos = caf->bytes_per_packet * (timestamp / caf->frames_per_packet);
         if (caf->data_size > 0)
-            pos = FFMIN(pos, caf->data_size);
+            pos = FFMINI(pos, caf->data_size);
         packet_cnt = pos / caf->bytes_per_packet;
         frame_cnt  = caf->frames_per_packet * packet_cnt;
     } else if (sti->nb_index_entries) {
diff --git a/libavformat/cdg.c b/libavformat/cdg.c
index 43d919e302e..e34ef6a0034 100644
--- a/libavformat/cdg.c
+++ b/libavformat/cdg.c
@@ -40,7 +40,7 @@ static int read_probe(const AVProbeData *p)
             return 0;
     }
 
-    return FFMIN(score, AVPROBE_SCORE_MAX);
+    return FFMINI(score, AVPROBE_SCORE_MAX);
 }
 
 static int read_header(AVFormatContext *s)
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index fe65d0c7688..3502865e428 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -142,7 +142,7 @@ static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,
     }
 
     if (cat->nb_files >= *nb_files_alloc) {
-        size_t n = FFMAX(*nb_files_alloc * 2, 16);
+        size_t n = FFMAXI(*nb_files_alloc * 2, 16);
         ConcatFile *new_files;
         if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||
             !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))
diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index da8aa0f0ec8..ef968b7ad98 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -185,7 +185,7 @@ static int crypto_read(URLContext *h, uint8_t *buf, int size)
     int blocks;
 retry:
     if (c->outdata > 0) {
-        size = FFMIN(size, c->outdata);
+        size = FFMINI(size, c->outdata);
         memcpy(buf, c->outptr, size);
         c->outptr  += size;
         c->outdata -= size;
diff --git a/libavformat/dash.c b/libavformat/dash.c
index d7ba8540d75..c26c250e27a 100644
--- a/libavformat/dash.c
+++ b/libavformat/dash.c
@@ -104,7 +104,7 @@ void ff_dash_fill_tmpl_params(char *dst, size_t buffer_size,
         DASHTmplId id_type;
         const char *t_next = strchr(t_cur, '$'); // copy over everything up to the first '$' character
         if (t_next) {
-            int num_copy_bytes = FFMIN(t_next - t_cur, buffer_size - dst_pos - 1);
+            int num_copy_bytes = FFMINI(t_next - t_cur, buffer_size - dst_pos - 1);
             av_strlcpy(&dst[dst_pos], t_cur, num_copy_bytes + 1);
             // advance
             dst_pos += num_copy_bytes;
@@ -148,7 +148,7 @@ void ff_dash_fill_tmpl_params(char *dst, size_t buffer_size,
         // (may have failed to write all because buffer_size).
 
         // advance
-        dst_pos += FFMIN(n, buffer_size - dst_pos - 1);
+        dst_pos += FFMINI(n, buffer_size - dst_pos - 1);
         t_cur = t_next;
     }
 }
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index af92e38bbdb..2b0228d22e1 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -493,8 +493,8 @@ static void get_start_index_number(OutputStream *os, DASHContext *c,
     *start_index = 0;
     *start_number = 1;
     if (c->window_size) {
-        *start_index  = FFMAX(os->nb_segments   - c->window_size, 0);
-        *start_number = FFMAX(os->segment_index - c->window_size, 1);
+        *start_index  = FFMAXI(os->nb_segments   - c->window_size, 0);
+        *start_number = FFMAXI(os->segment_index - c->window_size, 1);
     }
 }
 
@@ -687,7 +687,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatCont
         avio_printf(out, "\t\t\t\t</SegmentTemplate>\n");
     } else if (c->single_file) {
         avio_printf(out, "\t\t\t\t<BaseURL>%s</BaseURL>\n", os->initfile);
-        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%"PRId64"\" startNumber=\"%d\">\n", AV_TIME_BASE, FFMIN(os->seg_duration, os->last_duration), start_number);
+        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%"PRId64"\" startNumber=\"%d\">\n", AV_TIME_BASE, FFMINI(os->seg_duration, os->last_duration), start_number);
         avio_printf(out, "\t\t\t\t\t<Initialization range=\"%"PRId64"-%"PRId64"\" />\n", os->init_start_pos, os->init_start_pos + os->init_range_length - 1);
         for (i = start_index; i < os->nb_segments; i++) {
             Segment *seg = os->segments[i];
@@ -698,7 +698,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatCont
         }
         avio_printf(out, "\t\t\t\t</SegmentList>\n");
     } else {
-        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%"PRId64"\" startNumber=\"%d\">\n", AV_TIME_BASE, FFMIN(os->seg_duration, os->last_duration), start_number);
+        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%"PRId64"\" startNumber=\"%d\">\n", AV_TIME_BASE, FFMINI(os->seg_duration, os->last_duration), start_number);
         avio_printf(out, "\t\t\t\t\t<Initialization sourceURL=\"%s\" />\n", os->initfile);
         for (i = start_index; i < os->nb_segments; i++) {
             Segment *seg = os->segments[i];
@@ -847,7 +847,7 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind
             if (as->trick_idx >= 0) {
                 AdaptationSet *tas = &c->as[as->trick_idx];
                 if (!as->ambiguous_frame_rate && !tas->ambiguous_frame_rate)
-                    avio_printf(out, " maxPlayoutRate=\"%d\"", FFMAX((int)av_q2d(av_div_q(tas->min_frame_rate, as->min_frame_rate)), 1));
+                    avio_printf(out, " maxPlayoutRate=\"%d\"", FFMAXI((int)av_q2d(av_div_q(tas->min_frame_rate, as->min_frame_rate)), 1));
             }
             if (!os->coding_dependency)
                 avio_printf(out, " codingDependency=\"false\"");
@@ -1215,7 +1215,7 @@ static int write_manifest(AVFormatContext *s, int final)
 
     if (c->window_size && s->nb_streams > 0 && c->streams[0].nb_segments > 0 && !c->use_template) {
         OutputStream *os = &c->streams[0];
-        int start_index = FFMAX(os->nb_segments - c->window_size, 0);
+        int start_index = FFMAXI(os->nb_segments - c->window_size, 0);
         int64_t start_time = av_rescale_q(os->segments[start_index]->time, s->streams[0]->time_base, AV_TIME_BASE_Q);
         avio_printf(out, "\t<Period id=\"0\" start=\"");
         write_time(out, start_time);
@@ -1285,7 +1285,7 @@ static int write_manifest(AVFormatContext *s, int final)
                 ff_hls_write_audio_rendition(c->m3u8_out, audio_group,
                                              playlist_file, NULL, i, is_default,
                                              s->streams[i]->codecpar->ch_layout.nb_channels);
-                max_audio_bitrate = FFMAX(st->codecpar->bit_rate +
+                max_audio_bitrate = FFMAXI(st->codecpar->bit_rate +
                                           os->muxer_overhead, max_audio_bitrate);
                 if (!av_strnstr(audio_codec_str, os->codec_str, sizeof(audio_codec_str))) {
                     if (strlen(audio_codec_str))
@@ -1602,7 +1602,7 @@ static int dash_init(AVFormatContext *s)
         os->frag_duration = as->frag_duration;
         os->frag_type = as->frag_type;
 
-        c->max_segment_duration = FFMAX(c->max_segment_duration, as->seg_duration);
+        c->max_segment_duration = FFMAXI(c->max_segment_duration, as->seg_duration);
 
         if (c->profile & MPD_PROFILE_DVB && (os->seg_duration > 15000000 || os->seg_duration < 960000)) {
             av_log(s, AV_LOG_ERROR, "Segment duration %"PRId64" is outside the allowed range for DVB-DASH profile\n", os->seg_duration);
@@ -1971,7 +1971,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
         }
 
         duration = av_rescale_q(os->max_pts - os->start_pts, st->time_base, AV_TIME_BASE_Q);
-        os->last_duration = FFMAX(os->last_duration, duration);
+        os->last_duration = FFMAXI(os->last_duration, duration);
 
         if (!os->muxer_overhead && os->max_pts > os->start_pts)
             os->muxer_overhead = ((int64_t) (range_length - os->total_pkt_size) *
@@ -2131,7 +2131,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
 
          os->availability_time_offset = ((double) os->seg_duration -
                                          frame_duration) / AV_TIME_BASE;
-        as->max_frag_duration = FFMAX(frame_duration, as->max_frag_duration);
+        as->max_frag_duration = FFMAXI(frame_duration, as->max_frag_duration);
     }
 
     if (c->use_template && !c->use_timeline) {
@@ -2197,7 +2197,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (os->max_pts == AV_NOPTS_VALUE)
         os->max_pts = pkt->pts + pkt->duration;
     else
-        os->max_pts = FFMAX(os->max_pts, pkt->pts + pkt->duration);
+        os->max_pts = FFMAXI(os->max_pts, pkt->pts + pkt->duration);
 
     if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
         os->frag_type == FRAG_TYPE_PFRAMES &&
@@ -2216,14 +2216,14 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
                                                      AV_TIME_BASE_Q);
                 os->availability_time_offset = ((double) os->seg_duration -
                                                  frag_duration) / AV_TIME_BASE;
-               as->max_frag_duration = FFMAX(frag_duration, as->max_frag_duration);
+               as->max_frag_duration = FFMAXI(frag_duration, as->max_frag_duration);
             }
         }
     }
 
     if (pkt->flags & AV_PKT_FLAG_KEY && (os->packets_written || os->nb_segments) && !os->gop_size && as->trick_idx < 0) {
         os->gop_size = os->last_duration + av_rescale_q(os->total_pkt_duration, st->time_base, AV_TIME_BASE_Q);
-        c->max_gop_size = FFMAX(c->max_gop_size, os->gop_size);
+        c->max_gop_size = FFMAXI(c->max_gop_size, os->gop_size);
     }
 
     if ((ret = ff_write_chained(os->ctx, 0, pkt, s, 0)) < 0)
diff --git a/libavformat/data_uri.c b/libavformat/data_uri.c
index 3868a196305..c4feea8a335 100644
--- a/libavformat/data_uri.c
+++ b/libavformat/data_uri.c
@@ -105,7 +105,7 @@ static int data_read(URLContext *h, unsigned char *buf, int size)
 
     if (dc->pos >= dc->size)
         return AVERROR_EOF;
-    size = FFMIN(size, dc->size - dc->pos);
+    size = FFMINI(size, dc->size - dc->pos);
     memcpy(buf, dc->data + dc->pos, size);
     dc->pos += size;
     return size;
diff --git a/libavformat/demux.c b/libavformat/demux.c
index ecd4f40da9b..28edb9c2bac 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -803,7 +803,7 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t
                 if (pts_buffer[i] != AV_NOPTS_VALUE) {
                     int64_t diff = FFABS(pts_buffer[i] - dts)
                                    + (uint64_t)sti->pts_reorder_error[i];
-                    diff = FFMAX(diff, sti->pts_reorder_error[i]);
+                    diff = FFMAXI(diff, sti->pts_reorder_error[i]);
                     sti->pts_reorder_error[i] = diff;
                     sti->pts_reorder_error_count[i]++;
                     if (sti->pts_reorder_error_count[i] > 250) {
@@ -1480,11 +1480,11 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
             int64_t end_sample = sample + duration;
             if (duration > 0 && end_sample >= sti->first_discard_sample &&
                 sample < sti->last_discard_sample)
-                discard_padding = FFMIN(end_sample - sti->first_discard_sample, duration);
+                discard_padding = FFMINI(end_sample - sti->first_discard_sample, duration);
         }
         if (sti->start_skip_samples && (pkt->pts == 0 || pkt->pts == RELATIVE_TS_BASE))
             sti->skip_samples = sti->start_skip_samples;
-        sti->skip_samples = FFMAX(0, sti->skip_samples);
+        sti->skip_samples = FFMAXI(0, sti->skip_samples);
         if (sti->skip_samples || discard_padding) {
             uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
             if (p) {
@@ -1663,18 +1663,18 @@ static void update_stream_timings(AVFormatContext *ic)
             start_time1 = av_rescale_q(st->start_time, st->time_base,
                                        AV_TIME_BASE_Q);
             if (is_text)
-                start_time_text = FFMIN(start_time_text, start_time1);
+                start_time_text = FFMINI(start_time_text, start_time1);
             else
-                start_time = FFMIN(start_time, start_time1);
+                start_time = FFMINI(start_time, start_time1);
             end_time1 = av_rescale_q_rnd(st->duration, st->time_base,
                                          AV_TIME_BASE_Q,
                                          AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
             if (end_time1 != AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
                 end_time1 += start_time1;
                 if (is_text)
-                    end_time_text = FFMAX(end_time_text, end_time1);
+                    end_time_text = FFMAXI(end_time_text, end_time1);
                 else
-                    end_time = FFMAX(end_time, end_time1);
+                    end_time = FFMAXI(end_time, end_time1);
             }
             for (AVProgram *p = NULL; (p = av_find_program_from_stream(ic, p, i)); ) {
                 if (p->start_time == AV_NOPTS_VALUE || p->start_time > start_time1)
@@ -1687,9 +1687,9 @@ static void update_stream_timings(AVFormatContext *ic)
             duration1 = av_rescale_q(st->duration, st->time_base,
                                      AV_TIME_BASE_Q);
             if (is_text)
-                duration_text = FFMAX(duration_text, duration1);
+                duration_text = FFMAXI(duration_text, duration1);
             else
-                duration = FFMAX(duration, duration1);
+                duration = FFMAXI(duration, duration1);
         }
     }
     if (start_time == INT64_MAX || (start_time > start_time_text && start_time - (uint64_t)start_time_text < AV_TIME_BASE))
@@ -1717,10 +1717,10 @@ static void update_stream_timings(AVFormatContext *ic)
                     if (p->start_time != AV_NOPTS_VALUE &&
                         p->end_time > p->start_time &&
                         p->end_time - (uint64_t)p->start_time <= INT64_MAX)
-                        duration = FFMAX(duration, p->end_time - p->start_time);
+                        duration = FFMAXI(duration, p->end_time - p->start_time);
                 }
             } else if (end_time >= start_time && end_time - (uint64_t)start_time <= INT64_MAX) {
-                duration = FFMAX(duration, end_time - start_time);
+                duration = FFMAXI(duration, end_time - start_time);
             }
         }
     }
@@ -1862,7 +1862,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
         for (;;) {
             AVStream *st;
             FFStream *sti;
-            if (read_size >= duration_max_read_size << (FFMAX(retry - 1, 0)))
+            if (read_size >= duration_max_read_size << (FFMAXI(retry - 1, 0)))
                 break;
 
             do {
@@ -1973,7 +1973,7 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
         file_size = 0;
     } else {
         file_size = avio_size(ic->pb);
-        file_size = FFMAX(0, file_size);
+        file_size = FFMAXI(0, file_size);
     }
 
     if ((!strcmp(ic->iformat->name, "mpeg") ||
@@ -2345,7 +2345,7 @@ void ff_rfps_calculate(AVFormatContext *ic)
         // the check for tb_unreliable() is not completely correct, since this is not about handling
         // an unreliable/inexact time base, but a time base that is finer than necessary, as e.g.
         // ipmovie.c produces.
-        if (tb_unreliable(ic, st) && sti->info->duration_count > 15 && sti->info->duration_gcd > FFMAX(1, st->time_base.den/(500LL*st->time_base.num)) && !st->r_frame_rate.num &&
+        if (tb_unreliable(ic, st) && sti->info->duration_count > 15 && sti->info->duration_gcd > FFMAXI(1, st->time_base.den/(500LL*st->time_base.num)) && !st->r_frame_rate.num &&
             sti->info->duration_gcd < INT64_MAX / st->time_base.num)
             av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * sti->info->duration_gcd, INT_MAX);
         if (sti->info->duration_count > 1 && !st->r_frame_rate.num
@@ -2769,14 +2769,14 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
             if (st->time_base.den > 0)
                 t = av_rescale_q(sti->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q);
             if (st->avg_frame_rate.num > 0)
-                t = FFMAX(t, av_rescale_q(sti->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q));
+                t = FFMAXI(t, av_rescale_q(sti->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q));
 
             if (   t == 0
                 && sti->codec_info_nb_frames > 30
                 && sti->info->fps_first_dts != AV_NOPTS_VALUE
                 && sti->info->fps_last_dts  != AV_NOPTS_VALUE) {
                 int64_t dur = av_sat_sub64(sti->info->fps_last_dts, sti->info->fps_first_dts);
-                t = FFMAX(t, av_rescale_q(dur, st->time_base, AV_TIME_BASE_Q));
+                t = FFMAXI(t, av_rescale_q(dur, st->time_base, AV_TIME_BASE_Q));
             }
 
             if (analyzed_all_streams)                                limit = max_analyze_duration;
@@ -2796,7 +2796,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
                 if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && st->start_time != AV_NOPTS_VALUE && pkt->pts >= st->start_time
                     && (uint64_t)pkt->pts - st->start_time < INT64_MAX
                 ) {
-                    sti->info->codec_info_duration = FFMIN(pkt->pts - st->start_time, sti->info->codec_info_duration + pkt->duration);
+                    sti->info->codec_info_duration = FFMINI(pkt->pts - st->start_time, sti->info->codec_info_duration + pkt->duration);
                 } else
                     sti->info->codec_info_duration += pkt->duration;
                 sti->info->codec_info_duration_fields += sti->parser && sti->need_parsing && fields
diff --git a/libavformat/dhav.c b/libavformat/dhav.c
index d9db775802d..d6f094509e4 100644
--- a/libavformat/dhav.c
+++ b/libavformat/dhav.c
@@ -258,7 +258,7 @@ static int64_t get_duration(AVFormatContext *s)
     get_timeinfo(date, &timeinfo);
     start = av_timegm(&timeinfo) * 1000LL;
 
-    end_buffer_size = FFMIN(MAX_DURATION_BUFFER_SIZE, avio_size(s->pb));
+    end_buffer_size = FFMINI(MAX_DURATION_BUFFER_SIZE, avio_size(s->pb));
     end_buffer = av_malloc(end_buffer_size);
     if (!end_buffer) {
         avio_seek(s->pb, start_pos, SEEK_SET);
diff --git a/libavformat/dsfdec.c b/libavformat/dsfdec.c
index 17e109e3453..972b89e144d 100644
--- a/libavformat/dsfdec.c
+++ b/libavformat/dsfdec.c
@@ -199,7 +199,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
             return 0;
         }
     }
-    ret = av_get_packet(pb, pkt, FFMIN(dsf->data_end - pos, st->codecpar->block_align));
+    ret = av_get_packet(pb, pkt, FFMINI(dsf->data_end - pos, st->codecpar->block_align));
     if (ret < 0)
         return ret;
 
diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index 38ba3e73d46..b522b1cd2c8 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -41,7 +41,7 @@ static int dts_probe(const AVProbeData *p)
     int diffcount = 1;
     uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
 
-    for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) {
+    for (pos = FFMINI(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) {
         int marker, wide_hdr, hdr_size, framesize;
         DCACoreFrameHeader h;
         GetBitContext gb;
@@ -79,7 +79,7 @@ static int dts_probe(const AVProbeData *p)
             if (pos == exss_nextpos)
                 exss_markers++;
             else
-                exss_markers = FFMAX(1, exss_markers - 1);
+                exss_markers = FFMAXI(1, exss_markers - 1);
             exss_nextpos = pos + framesize;
             continue;
         }
diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c
index 28d3aeb47a5..52263d9136f 100644
--- a/libavformat/dtshddec.c
+++ b/libavformat/dtshddec.c
@@ -110,7 +110,7 @@ static int dtshd_read_header(AVFormatContext *s)
             orig_nb_samples |= avio_r8(pb);
             st->codecpar->ch_layout.nb_channels = ff_dca_count_chs_for_mask(avio_rb16(pb));
             st->codecpar->initial_padding = avio_rb16(pb);
-            st->codecpar->trailing_padding = FFMAX(st->duration - orig_nb_samples - st->codecpar->initial_padding, 0);
+            st->codecpar->trailing_padding = FFMAXI(st->duration - orig_nb_samples - st->codecpar->initial_padding, 0);
             avio_skip(pb, chunk_size - 21);
             break;
         case FILEINFO:
@@ -151,7 +151,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
     int ret;
 
     left = dtshd->data_end - avio_tell(s->pb);
-    size = FFMIN(left, 1024);
+    size = FFMINI(left, 1024);
     if (size <= 0)
         return AVERROR_EOF;
 
diff --git a/libavformat/dump.c b/libavformat/dump.c
index c263921b991..d89c1eeb13e 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -155,7 +155,7 @@ static void dump_dictionary(void *ctx, const AVDictionary *m,
                    "%s  %-16s: ", indent, tag->key);
             while (*p) {
                 size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
-                av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
+                av_log(ctx, log_level, "%.*s", (int)(FFMINI(255, len)), p);
                 p += len;
                 if (*p == 0xd) av_log(ctx, log_level, " ");
                 if (*p == 0xa) av_log(ctx, log_level, "\n%s  %-16s: ", indent, "");
diff --git a/libavformat/dvbsub.c b/libavformat/dvbsub.c
index ba5d56a862a..ea79ab3f5a0 100644
--- a/libavformat/dvbsub.c
+++ b/libavformat/dvbsub.c
@@ -54,7 +54,7 @@ static int dvbsub_probe(const AVProbeData *p)
                 ptr += 6 + len;
             }
             for (k=0; k < 4; k++) {
-                min = FFMIN(min, histogram[k]);
+                min = FFMINI(min, histogram[k]);
             }
             if (min && j > max_score)
                 max_score = j;
diff --git a/libavformat/dxa.c b/libavformat/dxa.c
index 56b19a7fca9..8cfbcfdd35f 100644
--- a/libavformat/dxa.c
+++ b/libavformat/dxa.c
@@ -166,7 +166,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
     if(!c->readvid && c->has_sound && c->bytes_left){
         c->readvid = 1;
         avio_seek(s->pb, c->wavpos, SEEK_SET);
-        size = FFMIN(c->bytes_left, c->bpc);
+        size = FFMINI(c->bytes_left, c->bpc);
         ret = av_get_packet(s->pb, pkt, size);
         pkt->stream_index = 1;
         if(ret != size)
diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index e66002b9023..9cdb69a90b1 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -417,9 +417,9 @@ static int fifo_thread_recover(FifoThreadContext *ctx, FifoMessage *msg, int err
     do {
         if (!fifo->recovery_wait_streamtime && ctx->recovery_nr > 0) {
             int64_t time_since_recovery = av_gettime_relative() - ctx->last_recovery_ts;
-            int64_t time_to_wait = FFMAX(0, fifo->recovery_wait_time - time_since_recovery);
+            int64_t time_to_wait = FFMAXI(0, fifo->recovery_wait_time - time_since_recovery);
             if (time_to_wait)
-                av_usleep(FFMIN(10000, time_to_wait));
+                av_usleep(FFMINI(10000, time_to_wait));
         }
 
         ret = fifo_thread_attempt_recovery(ctx, msg, err_no);
diff --git a/libavformat/file.c b/libavformat/file.c
index 6a66040b659..d7be210febb 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -140,7 +140,7 @@ static int file_read(URLContext *h, unsigned char *buf, int size)
 {
     FileContext *c = h->priv_data;
     int ret;
-    size = FFMIN(size, c->blocksize);
+    size = FFMINI(size, c->blocksize);
     ret = read(c->fd, buf, size);
     if (ret == 0 && c->follow)
         return AVERROR(EAGAIN);
@@ -153,7 +153,7 @@ static int file_write(URLContext *h, const unsigned char *buf, int size)
 {
     FileContext *c = h->priv_data;
     int ret;
-    size = FFMIN(size, c->blocksize);
+    size = FFMINI(size, c->blocksize);
     ret = write(c->fd, buf, size);
     return (ret == -1) ? AVERROR(errno) : ret;
 }
diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c
index 5ce0af234ca..752f094cc54 100644
--- a/libavformat/filmstripdec.c
+++ b/libavformat/filmstripdec.c
@@ -100,7 +100,7 @@ static int read_packet(AVFormatContext *s,
 static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 {
     AVStream *st = s->streams[stream_index];
-    if (avio_seek(s->pb, FFMAX(timestamp, 0) * st->codecpar->width * st->codecpar->height * 4, SEEK_SET) < 0)
+    if (avio_seek(s->pb, FFMAXI(timestamp, 0) * st->codecpar->width * st->codecpar->height * 4, SEEK_SET) < 0)
         return -1;
     return 0;
 }
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index b90ed34b1c5..0bcb8b03ad4 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -575,7 +575,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m
     }
 
     if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) {
-        for (i = 0; i < FFMIN(2,fileposlen); i++) {
+        for (i = 0; i < FFMINI(2,fileposlen); i++) {
             flv->validate_index[i].pos = filepositions[i];
             flv->validate_index[i].dts = times[i];
             flv->validate_count        = i + 1;
@@ -1166,10 +1166,10 @@ static int resync(AVFormatContext *s)
 
         if (i > 22) {
             unsigned lsize2 = AV_RB32(flv->resync_buffer + j1 - 4);
-            if (lsize2 >= 11 && lsize2 + 8LL < FFMIN(i, RESYNC_BUFFER_SIZE)) {
+            if (lsize2 >= 11 && lsize2 + 8LL < FFMINI(i, RESYNC_BUFFER_SIZE)) {
                 unsigned  size2 = AV_RB24(flv->resync_buffer + j1 - lsize2 + 1 - 4);
                 unsigned lsize1 = AV_RB32(flv->resync_buffer + j1 - lsize2 - 8);
-                if (lsize1 >= 11 && lsize1 + 8LL + lsize2 < FFMIN(i, RESYNC_BUFFER_SIZE)) {
+                if (lsize1 >= 11 && lsize1 + 8LL + lsize2 < FFMINI(i, RESYNC_BUFFER_SIZE)) {
                     unsigned  size1 = AV_RB24(flv->resync_buffer + j1 - lsize1 + 1 - lsize2 - 8);
                     if (size1 == lsize1 - 11 && size2  == lsize2 - 11) {
                         avio_seek(s->pb, pos + i - lsize1 - lsize2 - 8, SEEK_SET);
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index f026f0e53b1..ccb2b6421b1 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -1433,7 +1433,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         avio_write(pb, data ? data : pkt->data, size);
 
         avio_wb32(pb, size + flags_size + 11); // previous tag size
-        flv->duration = FFMAX(flv->duration,
+        flv->duration = FFMAXI(flv->duration,
                               pkt->pts + flv->delay + pkt->duration);
     }
 
diff --git a/libavformat/format.c b/libavformat/format.c
index 71018ea6ab5..331b5fe9b5f 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -196,14 +196,14 @@ const AVInputFormat *av_probe_input_format3(const AVProbeData *pd,
             if (fmt1->extensions && av_match_ext(lpd.filename, fmt1->extensions)) {
                 switch (nodat) {
                 case NO_ID3:
-                    score = FFMAX(score, 1);
+                    score = FFMAXI(score, 1);
                     break;
                 case ID3_GREATER_PROBE:
                 case ID3_ALMOST_GREATER_PROBE:
-                    score = FFMAX(score, AVPROBE_SCORE_EXTENSION / 2 - 1);
+                    score = FFMAXI(score, AVPROBE_SCORE_EXTENSION / 2 - 1);
                     break;
                 case ID3_GREATER_MAX_PROBE:
-                    score = FFMAX(score, AVPROBE_SCORE_EXTENSION);
+                    score = FFMAXI(score, AVPROBE_SCORE_EXTENSION);
                     break;
                 }
             }
@@ -224,7 +224,7 @@ const AVInputFormat *av_probe_input_format3(const AVProbeData *pd,
             fmt = NULL;
     }
     if (nodat == ID3_GREATER_PROBE)
-        score_max = FFMIN(AVPROBE_SCORE_EXTENSION / 2 - 1, score_max);
+        score_max = FFMINI(AVPROBE_SCORE_EXTENSION / 2 - 1, score_max);
     *score_ret = score_max;
 
     return fmt;
@@ -282,8 +282,8 @@ int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
     }
 
     for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt && !eof;
-         probe_size = FFMIN(probe_size << 1,
-                            FFMAX(max_probe_size, probe_size + 1))) {
+         probe_size = FFMINI(probe_size << 1,
+                            FFMAXI(max_probe_size, probe_size + 1))) {
         score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0;
 
         /* Read probe data. */
diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index fba32715ec5..f698ba86f11 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -838,7 +838,7 @@ static int ftp_read(URLContext *h, unsigned char *buf, int size)
         read = ffurl_read(s->conn_data, buf, size);
         if (read >= 0) {
             s->position += read;
-            s->filesize = FFMAX(s->filesize, s->position);
+            s->filesize = FFMAXI(s->filesize, s->position);
         }
         if (read == AVERROR_EOF) {
            static const int retr_codes[] = {226, 250, 425, 426, 451, 0};
@@ -892,7 +892,7 @@ static int ftp_write(URLContext *h, const unsigned char *buf, int size)
         written = ffurl_write(s->conn_data, buf, size);
         if (written > 0) {
             s->position += written;
-            s->filesize = FFMAX(s->filesize, s->position);
+            s->filesize = FFMAXI(s->filesize, s->position);
         }
         return written;
     }
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 1a9f0d75b07..45db12499b0 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -578,7 +578,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
     pos = sti->index_entries[idx].pos;
     if (idx < sti->nb_index_entries - 2)
         maxlen = sti->index_entries[idx + 2].pos - pos;
-    maxlen = FFMAX(maxlen, 200 * 1024);
+    maxlen = FFMAXI(maxlen, 200 * 1024);
     res = avio_seek(s->pb, pos, SEEK_SET);
     if (res < 0)
         return res;
diff --git a/libavformat/h261dec.c b/libavformat/h261dec.c
index 0fca1a340ad..0023b7825c3 100644
--- a/libavformat/h261dec.c
+++ b/libavformat/h261dec.c
@@ -34,7 +34,7 @@ static int h261_probe(const AVProbeData *p)
     for(i=0; i<p->buf_size; i++){
         if ((AV_RB16(&p->buf[i]) - 1) < 0xFFU) {
             int shift = av_log2_16bit(p->buf[i+1]);
-            uint32_t code = AV_RB64(&p->buf[FFMAX(i-1, 0)]) >> (24+shift);
+            uint32_t code = AV_RB64(&p->buf[FFMAXI(i-1, 0)]) >> (24+shift);
             if ((code & 0xffff0000) == 0x10000) {
                 int gn= (code>>12)&0xf;
                 if(!gn)
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 01efa1f8da5..dd7c510ff4a 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -225,7 +225,7 @@ static int write_abst(AVFormatContext *s, OutputStream *os, int final)
     int index = s->streams[os->first_stream]->id;
     int64_t cur_media_time = 0;
     if (c->window_size)
-        start = FFMAX(os->nb_fragments - c->window_size, 0);
+        start = FFMAXI(os->nb_fragments - c->window_size, 0);
     fragments = os->nb_fragments - start;
     if (final)
         cur_media_time = os->last_ts;
diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index fc1fa8be740..0c93070b136 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -112,13 +112,13 @@ static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc,
     if (hvcc->general_tier_flag < ptl->tier_flag)
         hvcc->general_level_idc = ptl->level_idc;
     else
-        hvcc->general_level_idc = FFMAX(hvcc->general_level_idc, ptl->level_idc);
+        hvcc->general_level_idc = FFMAXI(hvcc->general_level_idc, ptl->level_idc);
 
     /*
      * The tier indication general_tier_flag must indicate a tier equal to or
      * greater than the highest tier indicated in all the parameter sets.
      */
-    hvcc->general_tier_flag = FFMAX(hvcc->general_tier_flag, ptl->tier_flag);
+    hvcc->general_tier_flag = FFMAXI(hvcc->general_tier_flag, ptl->tier_flag);
 
     /*
      * The profile indication general_profile_idc must indicate a profile to
@@ -134,7 +134,7 @@ static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc,
      *
      * Note: set the profile to the highest value for the sake of simplicity.
      */
-    hvcc->general_profile_idc = FFMAX(hvcc->general_profile_idc, ptl->profile_idc);
+    hvcc->general_profile_idc = FFMAXI(hvcc->general_profile_idc, ptl->profile_idc);
 
     /*
      * Each bit in general_profile_compatibility_flags may only be set if all
@@ -373,7 +373,7 @@ static void hvcc_parse_vui(GetBitContext *gb,
          * spatial segmentation equal to or less than the lowest level of
          * spatial segmentation indicated in all the parameter sets.
          */
-        hvcc->min_spatial_segmentation_idc = FFMIN(hvcc->min_spatial_segmentation_idc,
+        hvcc->min_spatial_segmentation_idc = FFMINI(hvcc->min_spatial_segmentation_idc,
                                                    min_spatial_segmentation_idc);
 
         get_ue_golomb_long(gb); // max_bytes_per_pic_denom
@@ -396,7 +396,7 @@ static int hvcc_parse_vps_extension(GetBitContext *gb, HVCCNALUnit *nal,
                                     uint8_t vps_base_layer_internal_flag)
 {
     uint8_t num_scalability_types = 0;
-    uint8_t max_layers_minus_1 = FFMIN(62, vps_max_layers_minus1);
+    uint8_t max_layers_minus_1 = FFMINI(62, vps_max_layers_minus1);
     uint8_t splitting_flag, vps_nuh_layer_id_present_flag;
     uint8_t scalability_mask_flag[16] = { 0 };
     uint8_t dimension_id_len[16] = { 0 };
@@ -481,7 +481,7 @@ static int hvcc_parse_vps(GetBitContext *gb, HVCCNALUnit *nal,
      * indicates that the stream is not temporally scalable. Value 0 indicates
      * that it is unknown whether the stream is temporally scalable.
      */
-    hvcc->numTemporalLayers = FFMAX(hvcc->numTemporalLayers,
+    hvcc->numTemporalLayers = FFMAXI(hvcc->numTemporalLayers,
                                     nal->vps_max_sub_layers_minus1 + 1);
 
     /*
@@ -548,7 +548,7 @@ static void skip_scaling_list_data(GetBitContext *gb)
             if (!get_bits1(gb))         // scaling_list_pred_mode_flag[i][j]
                 get_ue_golomb_long(gb); // scaling_list_pred_matrix_id_delta[i][j]
             else {
-                num_coeffs = FFMIN(64, 1 << (4 + (i << 1)));
+                num_coeffs = FFMINI(64, 1 << (4 + (i << 1)));
 
                 if (i > 1)
                     get_se_golomb_long(gb); // scaling_list_dc_coef_minus8[i-2][j]
@@ -666,7 +666,7 @@ static int hvcc_parse_sps(GetBitContext *gb, HVCCNALUnit *nal,
      * indicates that the stream is not temporally scalable. Value 0 indicates
      * that it is unknown whether the stream is temporally scalable.
      */
-    hvcc->numTemporalLayers = FFMAX(hvcc->numTemporalLayers,
+    hvcc->numTemporalLayers = FFMAXI(hvcc->numTemporalLayers,
                                     sps_max_sub_layers_minus1 + 1);
 
     if (!multi_layer_ext_sps_flag) {
@@ -750,7 +750,7 @@ static int hvcc_parse_sps(GetBitContext *gb, HVCCNALUnit *nal,
         if (num_long_term_ref_pics_sps > 31U)
             return AVERROR_INVALIDDATA;
         for (i = 0; i < num_long_term_ref_pics_sps; i++) { // num_long_term_ref_pics_sps
-            int len = FFMIN(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
+            int len = FFMINI(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
             skip_bits (gb, len); // lt_ref_pic_poc_lsb_sps[i]
             skip_bits1(gb);      // used_by_curr_pic_lt_sps_flag[i]
         }
diff --git a/libavformat/hls.c b/libavformat/hls.c
index c7b655c83cb..68c115efc79 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1126,7 +1126,7 @@ static int read_from_url(struct playlist *pls, struct segment *seg,
 
      /* limit read if the segment was only a part of a file */
     if (seg->size >= 0)
-        buf_size = FFMIN(buf_size, seg->size - pls->cur_seg_offset);
+        buf_size = FFMINI(buf_size, seg->size - pls->cur_seg_offset);
 
     ret = avio_read(pls->input, buf, buf_size);
     if (ret > 0)
@@ -1273,7 +1273,7 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf,
         if (ff_id3v2_match(buf, ID3v2_DEFAULT_MAGIC)) {
             int64_t maxsize = seg->size >= 0 ? seg->size : 1024*1024;
             int taglen = ff_id3v2_tag_len(buf);
-            int tag_got_bytes = FFMIN(taglen, *len);
+            int tag_got_bytes = FFMINI(taglen, *len);
             int remaining = taglen - tag_got_bytes;
 
             if (taglen > maxsize) {
@@ -1475,7 +1475,7 @@ static int update_init_section(struct playlist *pls, struct segment *seg)
            "Downloading an initialization section of size %"PRId64"\n",
            sec_size);
 
-    sec_size = FFMIN(sec_size, max_init_section_size);
+    sec_size = FFMINI(sec_size, max_init_section_size);
 
     av_fast_malloc(&pls->init_sec_buf, &pls->init_sec_buf_size, sec_size);
 
@@ -1712,7 +1712,7 @@ restart:
 
     if (v->init_sec_buf_read_offset < v->init_sec_data_len) {
         /* Push init section out first before first actual segment */
-        int copy_size = FFMIN(v->init_sec_data_len - v->init_sec_buf_read_offset, buf_size);
+        int copy_size = FFMINI(v->init_sec_data_len - v->init_sec_buf_read_offset, buf_size);
         memcpy(buf, v->init_sec_buf, copy_size);
         v->init_sec_buf_read_offset += copy_size;
         return copy_size;
@@ -1962,10 +1962,10 @@ static int64_t select_cur_seq_no(HLSContext *c, struct playlist *pls)
         /* If this is a live stream, start live_start_index segments from the
          * start or end */
         if (c->live_start_index < 0)
-            seq_no = pls->start_seq_no + FFMAX(pls->n_segments +
+            seq_no = pls->start_seq_no + FFMAXI(pls->n_segments +
                                             c->live_start_index, 0);
         else
-            seq_no = pls->start_seq_no + FFMIN(c->live_start_index,
+            seq_no = pls->start_seq_no + FFMINI(c->live_start_index,
                                             pls->n_segments - 1);
 
         /* If #EXT-X-START in playlist, need to recalculate */
@@ -2211,7 +2211,7 @@ static int hls_read_header(AVFormatContext *s)
             continue;
 
         pls->cur_seq_no = select_cur_seq_no(c, pls);
-        highest_cur_seq_no = FFMAX(highest_cur_seq_no, pls->cur_seq_no);
+        highest_cur_seq_no = FFMAXI(highest_cur_seq_no, pls->cur_seq_no);
     }
 
     av_dict_set(&c->seg_format_opts, "prefer_hls_mpegts_pts", "1", 0);
diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c
index f9f410f3da1..0198ad95600 100644
--- a/libavformat/hls_sample_encryption.c
+++ b/libavformat/hls_sample_encryption.c
@@ -224,8 +224,8 @@ static int decrypt_nal_unit(HLSCryptoContext *crypto_ctx, NALUnit *nalu)
             data += 16;
             rem_bytes -= 16;
         }
-        data += FFMIN(144, rem_bytes);
-        rem_bytes -= FFMIN(144, rem_bytes);
+        data += FFMINI(144, rem_bytes);
+        rem_bytes -= FFMINI(144, rem_bytes);
     }
 
     return 0;
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a93d35ab75c..33903715163 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1630,7 +1630,7 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
     int ret = 0;
     char temp_filename[MAX_URL_SIZE];
     char temp_vtt_filename[MAX_URL_SIZE];
-    int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - vs->nb_entries);
+    int64_t sequence = FFMAXI(hls->start_sequence, vs->sequence - vs->nb_entries);
     const char *proto = avio_find_protocol_name(vs->m3u8_name);
     int is_file_proto = proto && !strcmp(proto, "file");
     int use_temp_file = is_file_proto && ((hls->flags & HLS_TEMP_FILE) || !(hls->pl_type == PLAYLIST_TYPE_VOD));
diff --git a/libavformat/http.c b/libavformat/http.c
index f7b2a8a0293..c85b3328bcf 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1268,7 +1268,7 @@ static int process_line(URLContext *h, char *line, int line_count, int *parsed_h
                 time_t retry   = av_timegm(&tm);
                 int64_t now    = av_gettime() / 1000000;
                 int64_t diff   = ((int64_t) retry) - now;
-                s->retry_after = (unsigned int) FFMAX(0, diff);
+                s->retry_after = (unsigned int) FFMAXI(0, diff);
             } else {
                 s->retry_after = strtoul(p, NULL, 10);
             }
@@ -1660,7 +1660,7 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size)
                 return AVERROR(EINVAL);
             }
         }
-        size = FFMIN(size, s->chunksize);
+        size = FFMINI(size, s->chunksize);
     }
 
     /* read bytes from input buffer first */
@@ -1870,7 +1870,7 @@ static int store_icy(URLContext *h, int size)
         remaining        = s->icy_metaint;
     }
 
-    return FFMIN(size, remaining);
+    return FFMINI(size, remaining);
 }
 
 static int http_read(URLContext *h, uint8_t *buf, int size)
diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 71497876ac3..f8074b29d73 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -286,7 +286,7 @@ static int update_extradata(AVCodecParameters *codecpar)
         break;
     case AV_CODEC_ID_AAC: {
         uint8_t buf[6];
-        int size = FFMIN(codecpar->extradata_size, sizeof(buf));
+        int size = FFMINI(codecpar->extradata_size, sizeof(buf));
 
         init_put_bits(&pb, buf, size);
         ret = init_get_bits8(&gb, codecpar->extradata, size);
@@ -1046,7 +1046,7 @@ int ff_iamf_parse_obu_header(const uint8_t *buf, int buf_size,
     unsigned skip = 0, discard = 0;
     unsigned size;
 
-    ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_IAMF_OBU_HEADER_SIZE));
+    ret = init_get_bits8(&gb, buf, FFMINI(buf_size, MAX_IAMF_OBU_HEADER_SIZE));
     if (ret < 0)
         return ret;
 
@@ -1103,9 +1103,9 @@ int ff_iamfdec_read_descriptors(IAMFContext *c, AVIOContext *pb,
         enum IAMF_OBU_Type type;
         int start_pos, len, size;
 
-        if ((ret = ffio_ensure_seekback(pb, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, max_size))) < 0)
+        if ((ret = ffio_ensure_seekback(pb, FFMINI(MAX_IAMF_OBU_HEADER_SIZE, max_size))) < 0)
             return ret;
-        size = avio_read(pb, header, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, max_size));
+        size = avio_read(pb, header, FFMINI(MAX_IAMF_OBU_HEADER_SIZE, max_size));
         if (size < 0)
             return size;
         memset(header + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
diff --git a/libavformat/iamf_reader.c b/libavformat/iamf_reader.c
index 5cbe89ca68d..263d9611ebe 100644
--- a/libavformat/iamf_reader.c
+++ b/libavformat/iamf_reader.c
@@ -288,13 +288,13 @@ int ff_iamf_read_packet(AVFormatContext *s, IAMFDemuxContext *c,
         unsigned skip_samples, discard_padding;
         int ret, len, size, start_pos;
 
-        ret = ffio_ensure_seekback(pb, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, max_size));
+        ret = ffio_ensure_seekback(pb, FFMINI(MAX_IAMF_OBU_HEADER_SIZE, max_size));
         if (ret < 0)
             return ret;
-        size = avio_read(pb, header, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, max_size));
+        size = avio_read(pb, header, FFMINI(MAX_IAMF_OBU_HEADER_SIZE, max_size));
         if (size < 0)
             return size;
-        if (size != FFMIN(MAX_IAMF_OBU_HEADER_SIZE, max_size))
+        if (size != FFMINI(MAX_IAMF_OBU_HEADER_SIZE, max_size))
             return AVERROR_INVALIDDATA;
 
         len = ff_iamf_parse_obu_header(header, size, &obu_size, &start_pos, &type,
diff --git a/libavformat/iamfdec.c b/libavformat/iamfdec.c
index 3a6276dcdea..14f737bf9a5 100644
--- a/libavformat/iamfdec.c
+++ b/libavformat/iamfdec.c
@@ -64,7 +64,7 @@ static int iamf_probe(const AVProbeData *p)
         if (ret >= 0)
             return ret;
 
-        cnt += FFMIN(size, p->buf_size - cnt);
+        cnt += FFMINI(size, p->buf_size - cnt);
     }
     return 0;
 }
diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index b09d0060a65..6cd817b5529 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -56,23 +56,23 @@ static int probe(const AVProbeData *p)
     for (i = 0; i < frames && i * 16 + 22 <= p->buf_size; i++) {
         unsigned offset;
         if (AV_RL16(p->buf + 10 + i * 16) & ~1)
-            return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+            return FFMINI(i, AVPROBE_SCORE_MAX / 4);
         if (p->buf[13 + i * 16])
-            return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+            return FFMINI(i, AVPROBE_SCORE_MAX / 4);
         if (AV_RL32(p->buf + 14 + i * 16) < 40)
-            return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+            return FFMINI(i, AVPROBE_SCORE_MAX / 4);
         offset = AV_RL32(p->buf + 18 + i * 16);
         if (offset < 22)
-            return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+            return FFMINI(i, AVPROBE_SCORE_MAX / 4);
         if (offset > p->buf_size - 8)
             continue;
         if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG)
-            return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+            return FFMINI(i, AVPROBE_SCORE_MAX / 4);
         checked++;
     }
 
     if (checked < frames)
-        return AVPROBE_SCORE_MAX / 4 + FFMIN(checked, 1);
+        return AVPROBE_SCORE_MAX / 4 + FFMINI(checked, 1);
     return AVPROBE_SCORE_MAX / 2 + 1;
 }
 
diff --git a/libavformat/iff.c b/libavformat/iff.c
index 9402be48c98..10b6e8f122a 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -239,7 +239,7 @@ static int parse_dsd_diin(AVFormatContext *s, AVStream *st, uint64_t eof)
 
         if (metadata_tag && size > 4) {
             unsigned int tag_size = avio_rb32(pb);
-            int ret = get_metadata(s, metadata_tag, FFMIN(tag_size, size - 4));
+            int ret = get_metadata(s, metadata_tag, FFMINI(tag_size, size - 4));
             if (ret < 0) {
                 av_log(s, AV_LOG_ERROR, "cannot allocate metadata tag %s!\n", metadata_tag);
                 return ret;
@@ -955,7 +955,7 @@ static int iff_read_packet(AVFormatContext *s,
     if (iff->audio_stream_index >= 0 && iff->video_stream_index < 0) { /* audio only */
         AVStream *sta = s->streams[iff->audio_stream_index];
         if (sta->codecpar->codec_tag == ID_DSD || iff->form_tag == ID_MAUD) {
-            ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * sta->codecpar->block_align));
+            ret = av_get_packet(pb, pkt, FFMINI(iff->body_end - pos, 1024 * sta->codecpar->block_align));
         } else if (sta->codecpar->codec_tag == ID_DST) {
             return read_dst_frame(s, pkt);
         } else {
diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index c4580b6a019..d805bd84260 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -207,7 +207,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
                 return 0;
             }
         case JV_PADDING:
-            avio_skip(pb, FFMAX(e->size - jvf->audio_size - jvf->video_size
+            avio_skip(pb, FFMAXI(e->size - jvf->audio_size - jvf->video_size
                                         - jvf->palette_size, 0));
             jv->state = JV_AUDIO;
             jv->pts++;
diff --git a/libavformat/lc3.c b/libavformat/lc3.c
index 16c12a98d72..b506a704886 100644
--- a/libavformat/lc3.c
+++ b/libavformat/lc3.c
@@ -165,8 +165,8 @@ static int lc3_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->pos = pos;
 
     remaining_samples = lc3->end_dts < 0 ? lc3->frame_samples :
-                        FFMAX(lc3->end_dts - ffstream(st)->cur_dts, 0);
-    pkt->duration = FFMIN(lc3->frame_samples, remaining_samples);
+                        FFMAXI(lc3->end_dts - ffstream(st)->cur_dts, 0);
+    pkt->duration = FFMINI(lc3->frame_samples, remaining_samples);
 
     return 0;
 }
diff --git a/libavformat/libzmq.c b/libavformat/libzmq.c
index da84efee736..6189feed7b8 100644
--- a/libavformat/libzmq.c
+++ b/libavformat/libzmq.c
@@ -173,7 +173,7 @@ static int zmq_proto_read(URLContext *h, unsigned char *buf, int size)
         return AVERROR_EXTERNAL;
     }
     if (ret > size) {
-        s->pkt_size_overflow = FFMAX(s->pkt_size_overflow, ret);
+        s->pkt_size_overflow = FFMAXI(s->pkt_size_overflow, ret);
         av_log(h, AV_LOG_WARNING, "Message exceeds available space in the buffer. Message will be truncated. Setting -pkt_size %d may resolve the issue.\n", s->pkt_size_overflow);
         ret = size;
     }
diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c
index fcb812f5caf..86e4db5db81 100644
--- a/libavformat/loasdec.c
+++ b/libavformat/loasdec.c
@@ -48,10 +48,10 @@ static int loas_probe(const AVProbeData *p)
             fsize = (header & 0x1FFF) + 3;
             if (fsize < 7)
                 break;
-            fsize = FFMIN(fsize, end - buf2);
+            fsize = FFMINI(fsize, end - buf2);
             buf2 += fsize;
         }
-        max_frames = FFMAX(max_frames, frames);
+        max_frames = FFMAXI(max_frames, frames);
         if (buf == buf0)
             first_frames = frames;
     }
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index da5166319e9..b27c8e39793 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -874,7 +874,7 @@ static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
         av_log(matroska->ctx, AV_LOG_WARNING,
                "Seek to desired resync point failed. Seeking to "
                "earliest point available instead.\n");
-        avio_seek(pb, FFMAX(avio_tell(pb) + (pb->buffer - pb->buf_ptr),
+        avio_seek(pb, FFMAXI(avio_tell(pb) + (pb->buffer - pb->buf_ptr),
                             last_pos + 1), SEEK_SET);
     }
 
@@ -2614,7 +2614,7 @@ static int mka_parse_audio_codec(MatroskaTrack *track, AVCodecParameters *par,
                                 track->codec_priv.size, 0);
         if (ret < 0)
             return ret;
-        *extradata_offset = FFMIN(track->codec_priv.size, 18);
+        *extradata_offset = FFMINI(track->codec_priv.size, 18);
         return 0;
     } else if (!strcmp(track->codec_id, "A_QUICKTIME") &&
                /* Normally 36, but allow noncompliant private data */
@@ -4189,7 +4189,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
 
     if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time))
         track->end_timecode =
-            FFMAX(track->end_timecode, timecode + block_duration);
+            FFMAXI(track->end_timecode, timecode + block_duration);
 
     for (n = 0; n < laces; n++) {
         int64_t lace_duration = block_duration*(n+1) / laces - block_duration*n / laces;
@@ -4333,7 +4333,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
 
     if (!sti->nb_index_entries)
         goto err;
-    timestamp = FFMAX(timestamp, sti->index_entries[0].timestamp);
+    timestamp = FFMAXI(timestamp, sti->index_entries[0].timestamp);
 
     if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 ||
          index == sti->nb_index_entries - 1) {
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 408890fa899..426423f578c 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -78,7 +78,7 @@
 #define MAX_EBML_LENGTH ((1ULL << 56) - 2)
 /* The dynamic buffer API we rely upon has a limit of INT_MAX;
  * and so has avio_write(). */
-#define MAX_SUPPORTED_EBML_LENGTH FFMIN(MAX_EBML_LENGTH, INT_MAX)
+#define MAX_SUPPORTED_EBML_LENGTH FFMINI(MAX_EBML_LENGTH, INT_MAX)
 
 #define MODE_MATROSKAv2 0x01
 #define MODE_WEBM       0x02
@@ -2160,10 +2160,10 @@ static int mkv_write_tracks(AVFormatContext *s)
             }
         }
 
-        video_default_idx = FFMAX(video_default_idx, video_idx);
-        audio_default_idx = FFMAX(audio_default_idx, audio_idx);
+        video_default_idx = FFMAXI(video_default_idx, video_idx);
+        audio_default_idx = FFMAXI(audio_default_idx, audio_idx);
         if (mkv->default_mode != DEFAULT_MODE_INFER_NO_SUBS)
-            subtitle_default_idx = FFMAX(subtitle_default_idx, subtitle_idx);
+            subtitle_default_idx = FFMAXI(subtitle_default_idx, subtitle_idx);
     }
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
@@ -2512,7 +2512,7 @@ static int64_t get_metadata_duration(AVFormatContext *s)
         duration = av_dict_get(s->streams[i]->metadata, "DURATION", NULL, 0);
 
         if (duration && (av_parse_time(&us, duration->value, 1) == 0))
-            max = FFMAX(max, us);
+            max = FFMAXI(max, us);
     }
 
     av_log(s, AV_LOG_DEBUG, "get_metadata_duration returned: %" PRId64 "\n", max);
@@ -2857,7 +2857,7 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv,
         (additional_id = AV_RB64(side_data)) == MATROSKA_BLOCK_ADD_ID_TYPE_OPAQUE) {
         mkv_write_blockadditional(&writer, side_data + 8, side_data_size - 8,
                                   additional_id);
-        track->max_blockaddid = FFMAX(track->max_blockaddid, additional_id);
+        track->max_blockaddid = FFMAXI(track->max_blockaddid, additional_id);
     }
 
     if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
@@ -2880,7 +2880,7 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv,
 
             mkv_write_blockadditional(&writer, t35_buf, payload_size + 6,
                                       MATROSKA_BLOCK_ADD_ID_ITU_T_T35);
-            track->max_blockaddid = FFMAX(track->max_blockaddid,
+            track->max_blockaddid = FFMAXI(track->max_blockaddid,
                                           MATROSKA_BLOCK_ADD_ID_ITU_T_T35);
         }
     }
@@ -3002,7 +3002,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, const AVPacket *pkt)
     int is_sub              = par->codec_type == AVMEDIA_TYPE_SUBTITLE;
     /* All subtitle blocks are considered to be keyframes. */
     int keyframe            = is_sub || !!(pkt->flags & AV_PKT_FLAG_KEY);
-    int64_t duration        = FFMAX(pkt->duration, 0);
+    int64_t duration        = FFMAXI(pkt->duration, 0);
     int64_t cue_duration    = is_sub ? duration : 0;
     int ret;
     int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
@@ -3030,8 +3030,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, const AVPacket *pkt)
             return ret;
         mkv->cluster_bc->direct = 1;
         mkv->cluster_pos = avio_tell(s->pb);
-        put_ebml_uint(mkv->cluster_bc, MATROSKA_ID_CLUSTERTIMECODE, FFMAX(0, ts));
-        mkv->cluster_pts = FFMAX(0, ts);
+        put_ebml_uint(mkv->cluster_bc, MATROSKA_ID_CLUSTERTIMECODE, FFMAXI(0, ts));
+        mkv->cluster_pts = FFMAXI(0, ts);
         av_log(s, AV_LOG_DEBUG,
                "Starting new cluster with timestamp "
                "%" PRId64 " at offset %" PRId64 " bytes\n",
@@ -3062,8 +3062,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, const AVPacket *pkt)
     }
 
     track->last_timestamp = ts;
-    mkv->duration   = FFMAX(mkv->duration,   ts + duration);
-    track->duration = FFMAX(track->duration, ts + duration);
+    mkv->duration   = FFMAXI(mkv->duration,   ts + duration);
+    track->duration = FFMAXI(track->duration, ts + duration);
 
     return 0;
 }
diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
index 44f5c207559..17fec93e537 100644
--- a/libavformat/mlvdec.c
+++ b/libavformat/mlvdec.c
@@ -417,7 +417,7 @@ static int read_header(AVFormatContext *avctx)
     }
 
     if (vst && ast)
-        avio_seek(pb, FFMIN(vsti->index_entries[0].pos, asti->index_entries[0].pos), SEEK_SET);
+        avio_seek(pb, FFMINI(vsti->index_entries[0].pos, asti->index_entries[0].pos), SEEK_SET);
     else if (vst)
         avio_seek(pb, vsti->index_entries[0].pos, SEEK_SET);
     else if (ast)
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index 42a88cff90c..869db871662 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -285,7 +285,7 @@ static int mmf_read_packet(AVFormatContext *s, AVPacket *pkt)
     int ret;
 
     left = mmf->data_end - avio_tell(s->pb);
-    size = FFMIN(left, MAX_SIZE);
+    size = FFMINI(left, MAX_SIZE);
     if (avio_feof(s->pb) || size <= 0)
         return AVERROR_EOF;
 
diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c
index aeadb12dab7..1a4c010d3f5 100644
--- a/libavformat/mmsh.c
+++ b/libavformat/mmsh.c
@@ -384,7 +384,7 @@ static int64_t mmsh_read_seek(void *opaque, int stream_index,
         return AVERROR(ENOMEM);
 
     h->priv_data = mmsh;
-    ret= mmsh_open_internal(h, mmsh_old->location, 0, FFMAX(timestamp, 0), 0);
+    ret= mmsh_open_internal(h, mmsh_old->location, 0, FFMAXI(timestamp, 0), 0);
     if(ret>=0){
         h->priv_data = mmsh_old;
         mmsh_close(h);
diff --git a/libavformat/moflex.c b/libavformat/moflex.c
index 85511a04be5..fa463742390 100644
--- a/libavformat/moflex.c
+++ b/libavformat/moflex.c
@@ -150,7 +150,7 @@ static int moflex_probe(const AVProbeData *p)
         bytestream2_skip(&gb, size);
     }
 
-    return FFMIN(AVPROBE_SCORE_MAX, score);
+    return FFMINI(AVPROBE_SCORE_MAX, score);
 }
 
 static int moflex_read_sync(AVFormatContext *s)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8a094b1ea0a..7bd815275c8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -685,7 +685,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             avio_skip(pb, 10);
 
             volume_len = avio_r8(pb);
-            volume_len = FFMIN(volume_len, 27);
+            volume_len = FFMINI(volume_len, 27);
             ret = ffio_read_size(pb, dref->volume, 27);
             if (ret < 0)
                 return ret;
@@ -695,7 +695,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             avio_skip(pb, 12);
 
             len = avio_r8(pb);
-            len = FFMIN(len, 63);
+            len = FFMINI(len, 63);
             ret = ffio_read_size(pb, dref->filename, 63);
             if (ret < 0)
                 return ret;
@@ -820,7 +820,7 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     title_size = atom.size - 24;
     if (title_size > 0) {
-        if (title_size > FFMIN(INT_MAX, SIZE_MAX-1))
+        if (title_size > FFMINI(INT_MAX, SIZE_MAX-1))
             return AVERROR_INVALIDDATA;
         title_str = av_malloc(title_size + 1); /* Add null terminator */
         if (!title_str)
@@ -2574,8 +2574,8 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     // invalid count since the EOF path doesn't throw either.
     entries = avio_rb32(pb);
     entries =
-        FFMIN(entries,
-              FFMAX(0, (atom.size - 8) /
+        FFMINI(entries,
+              FFMAXI(0, (atom.size - 8) /
                            (atom.type == MKTAG('s', 't', 'c', 'o') ? 4 : 8)));
 
     if (!entries)
@@ -3239,11 +3239,11 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
                     sc->stsc_count --;
                     continue;
                 }
-                sc->stsc_data[i].first = FFMAX(sc->stsc_data[i].first, first_min);
+                sc->stsc_data[i].first = FFMAXI(sc->stsc_data[i].first, first_min);
                 if (i > 0 && sc->stsc_data[i].first <= sc->stsc_data[i-1].first)
-                    sc->stsc_data[i].first = FFMIN(sc->stsc_data[i-1].first + 1LL, INT_MAX);
-                sc->stsc_data[i].count = FFMAX(sc->stsc_data[i].count, 1);
-                sc->stsc_data[i].id    = FFMAX(sc->stsc_data[i].id, 1);
+                    sc->stsc_data[i].first = FFMINI(sc->stsc_data[i-1].first + 1LL, INT_MAX);
+                sc->stsc_data[i].count = FFMAXI(sc->stsc_data[i].count, 1);
+                sc->stsc_data[i].id    = FFMAXI(sc->stsc_data[i].id, 1);
                 continue;
             }
             av_assert0(sc->stsc_data[i+1].first >= 2);
@@ -3509,7 +3509,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     for (i = 0; i < entries && !pb->eof_reached; i++) {
         unsigned int sample_duration;
         unsigned int sample_count;
-        unsigned int min_entries = FFMIN(FFMAX(i + 1, 1024 * 1024), entries);
+        unsigned int min_entries = FFMINI(FFMAXI(i + 1, 1024 * 1024), entries);
         MOVStts *stts_data = av_fast_realloc(sc->stts_data, &sc->stts_allocated_size,
                                              min_entries * sizeof(*sc->stts_data));
         if (!stts_data) {
@@ -3546,7 +3546,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         current_dts += sc->stts_data[i].duration * (uint64_t)sample_count;
 
         if (current_dts > corrected_dts) {
-            int64_t drift = av_sat_sub64(current_dts, corrected_dts) / FFMAX(sample_count, 1);
+            int64_t drift = av_sat_sub64(current_dts, corrected_dts) / FFMAXI(sample_count, 1);
             uint32_t correction = (sc->stts_data[i].duration > drift) ? drift : sc->stts_data[i].duration - 1;
             current_dts -= correction * (uint64_t)sample_count;
             sc->stts_data[i].duration -= correction;
@@ -3572,7 +3572,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     st->nb_frames= total_sample_count;
     if (duration)
-        st->duration= FFMIN(st->duration, duration);
+        st->duration= FFMINI(st->duration, duration);
 
     // All samples have zero duration. They have higher chance be chose by
     // mov_find_next_sample, which leads to seek again and again.
@@ -3633,7 +3633,7 @@ static void mov_update_dts_shift(MOVStreamContext *sc, int duration, void *logct
             av_log(logctx, AV_LOG_WARNING, "mov_update_dts_shift(): dts_shift set to %d\n", INT_MAX);
             duration++;
         }
-        sc->dts_shift = FFMAX(sc->dts_shift, -duration);
+        sc->dts_shift = FFMAXI(sc->dts_shift, -duration);
     }
 }
 
@@ -3673,7 +3673,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         const size_t min_size_needed = (ctts_count + 1) * sizeof(MOVCtts);
         const size_t requested_size =
             min_size_needed > sc->ctts_allocated_size ?
-            FFMAX(min_size_needed, 2 * sc->ctts_allocated_size) :
+            FFMAXI(min_size_needed, 2 * sc->ctts_allocated_size) :
             min_size_needed;
         int count    = avio_rb32(pb);
         int duration = avio_rb32(pb);
@@ -3989,7 +3989,7 @@ static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
     // Another difference from ff_add_index_entry function.
     const size_t requested_size =
         min_size_needed > sti->index_entries_allocated_size ?
-        FFMAX(min_size_needed, 2 * sti->index_entries_allocated_size) :
+        FFMAXI(min_size_needed, 2 * sti->index_entries_allocated_size) :
         min_size_needed;
 
     if (sti->nb_index_entries + 1U >= UINT_MAX / sizeof(AVIndexEntry))
@@ -4037,7 +4037,7 @@ static int add_tts_entry(MOVTimeToSample **tts_data, unsigned int *tts_count, un
     const size_t min_size_needed = (*tts_count + 1) * sizeof(MOVTimeToSample);
     const size_t requested_size =
         min_size_needed > *allocated_size ?
-        FFMAX(min_size_needed, 2 * (*allocated_size)) :
+        FFMAXI(min_size_needed, 2 * (*allocated_size)) :
         min_size_needed;
 
     if ((unsigned)(*tts_count) >= UINT_MAX / sizeof(MOVTimeToSample) - 1)
@@ -4102,7 +4102,7 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st)
                 }
                 j = r;
             }
-            st->codecpar->video_delay = FFMAX(st->codecpar->video_delay, num_swaps);
+            st->codecpar->video_delay = FFMAXI(st->codecpar->video_delay, num_swaps);
 
             ctts_sample++;
             if (ctts_sample == msc->tts_data[ctts_ind].count) {
@@ -4275,7 +4275,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
             // Audio decoders like AAC need need a decoder delay samples previous to the current sample,
             // to correctly decode this frame. Hence for audio we seek to a frame 1 sec. before the
             // edit_list_media_time to cover the decoder delay.
-            search_timestamp = FFMAX(search_timestamp - msc->time_scale, e_old[0].timestamp);
+            search_timestamp = FFMAXI(search_timestamp - msc->time_scale, e_old[0].timestamp);
         }
 
         if (find_prev_closest_index(st, e_old, nb_old, tts_data_old, tts_count_old, search_timestamp, 0,
@@ -4379,7 +4379,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
                 if (msc->min_corrected_pts < 0) {
                     msc->min_corrected_pts = edit_list_dts_counter + curr_ctts + msc->dts_shift;
                 } else {
-                    msc->min_corrected_pts = FFMIN(msc->min_corrected_pts, edit_list_dts_counter + curr_ctts + msc->dts_shift);
+                    msc->min_corrected_pts = FFMINI(msc->min_corrected_pts, edit_list_dts_counter + curr_ctts + msc->dts_shift);
                 }
                 if (edit_list_start_encountered == 0) {
                     edit_list_start_encountered = 1;
@@ -4456,7 +4456,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
     st->start_time = empty_edits_sum_duration;
 
     // Update av stream length, if it ends up shorter than the track's media duration
-    st->duration = FFMIN(st->duration, edit_list_dts_entry_end - start_dts);
+    st->duration = FFMINI(st->duration, edit_list_dts_entry_end - start_dts);
     msc->start_pad = sti->skip_samples;
 
     // Free the old index and the old CTTS structures
@@ -4538,7 +4538,7 @@ static int build_open_gop_key_points(AVStream *st)
     /* Identify the minimal time step between samples */
     sc->min_sample_duration = UINT_MAX;
     for (uint32_t i = 0; i < sc->stts_count; i++)
-        sc->min_sample_duration = FFMIN(sc->min_sample_duration, sc->stts_data[i].duration);
+        sc->min_sample_duration = FFMINI(sc->min_sample_duration, sc->stts_data[i].duration);
 
     return 0;
 }
@@ -4604,7 +4604,7 @@ static int mov_merge_tts_data(MOVContext *mov, AVStream *st, int flags)
                 sc->tts_data[idx++].count = 1;
             }
 
-        sc->tts_count = FFMAX(sc->tts_count, idx);
+        sc->tts_count = FFMAXI(sc->tts_count, idx);
     } else
         sc->stts_count = 0;
     av_freep(&sc->stts_data);
@@ -4872,11 +4872,11 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
                     size = sc->bytes_per_frame;
                 } else {
                     if (sc->samples_per_frame > 1) {
-                        samples = FFMIN((1024 / sc->samples_per_frame)*
+                        samples = FFMINI((1024 / sc->samples_per_frame)*
                                         sc->samples_per_frame, chunk_samples);
                         size = (samples / sc->samples_per_frame) * sc->bytes_per_frame;
                     } else {
-                        samples = FFMIN(1024, chunk_samples);
+                        samples = FFMINI(1024, chunk_samples);
                         size = samples * sc->sample_size;
                     }
                 }
@@ -7128,7 +7128,7 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd,
     };
 
-    if (atom.size < AV_UUID_LEN || atom.size >= FFMIN(INT_MAX, SIZE_MAX))
+    if (atom.size < AV_UUID_LEN || atom.size >= FFMINI(INT_MAX, SIZE_MAX))
         return AVERROR_INVALIDDATA;
 
     if (c->fc->nb_streams < 1)
@@ -7222,7 +7222,7 @@ static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if (atom.size < 8)
         return 0;
 
-    ret = ffio_read_size(pb, content, FFMIN(sizeof(content), atom.size));
+    ret = ffio_read_size(pb, content, FFMINI(sizeof(content), atom.size));
     if (ret < 0)
         return ret;
 
@@ -7414,7 +7414,7 @@ static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         return AVERROR(ENOMEM);
 
     for (i = 0; i < sample_count; i++) {
-        unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), sample_count);
+        unsigned int min_samples = FFMINI(FFMAXI(i + 1, 1024 * 1024), sample_count);
         encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size,
                                             min_samples * sizeof(*encrypted_samples));
         if (encrypted_samples) {
@@ -7470,7 +7470,7 @@ static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOCon
     }
 
     for (i = 0; i < sample_count && !pb->eof_reached; i++) {
-        unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), sample_count);
+        unsigned int min_samples = FFMINI(FFMAXI(i + 1, 1024 * 1024), sample_count);
         encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size,
                                             min_samples * sizeof(*encrypted_samples));
         if (!encrypted_samples) {
@@ -7650,7 +7650,7 @@ static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         return AVERROR(ENOMEM);
 
     for (i = 0; i < entry_count && !pb->eof_reached; i++) {
-        unsigned int min_offsets = FFMIN(FFMAX(i + 1, 1024), entry_count);
+        unsigned int min_offsets = FFMINI(FFMAXI(i + 1, 1024), entry_count);
         auxiliary_offsets = av_fast_realloc(
             encryption_index->auxiliary_offsets, &alloc_size,
             min_offsets * sizeof(*auxiliary_offsets));
@@ -7721,7 +7721,7 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
 
         for (unsigned int i = 0; i < kid_count && !pb->eof_reached; i++) {
-            unsigned int min_kid_count = FFMIN(FFMAX(i + 1, 1024), kid_count);
+            unsigned int min_kid_count = FFMINI(FFMAXI(i + 1, 1024), kid_count);
             key_ids = av_fast_realloc(info->key_ids, &alloc_size,
                                       min_kid_count * sizeof(*key_ids));
             if (!key_ids) {
@@ -8111,8 +8111,8 @@ static int cens_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption
             av_aes_ctr_crypt(sc->cenc.aes_ctr, data, data, 16*sample->crypt_byte_block);
             data += 16*sample->crypt_byte_block;
             rem_bytes -= 16*sample->crypt_byte_block;
-            data += FFMIN(16*sample->skip_byte_block, rem_bytes);
-            rem_bytes -= FFMIN(16*sample->skip_byte_block, rem_bytes);
+            data += FFMINI(16*sample->skip_byte_block, rem_bytes);
+            rem_bytes -= FFMINI(16*sample->skip_byte_block, rem_bytes);
         }
         input += sample->subsamples[i].bytes_of_protected_data;
         size -= sample->subsamples[i].bytes_of_protected_data;
@@ -8177,8 +8177,8 @@ static int cbcs_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryption
             av_aes_crypt(sc->cenc.aes_ctx, data, data, sample->crypt_byte_block, iv, 1);
             data += 16*sample->crypt_byte_block;
             rem_bytes -= 16*sample->crypt_byte_block;
-            data += FFMIN(16*sample->skip_byte_block, rem_bytes);
-            rem_bytes -= FFMIN(16*sample->skip_byte_block, rem_bytes);
+            data += FFMINI(16*sample->skip_byte_block, rem_bytes);
+            rem_bytes -= FFMINI(16*sample->skip_byte_block, rem_bytes);
         }
         input += sample->subsamples[i].bytes_of_protected_data;
         size -= sample->subsamples[i].bytes_of_protected_data;
@@ -8399,7 +8399,7 @@ static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     st = c->fc->streams[c->fc->nb_streams-1];
 
     // At most 24 bytes
-    read_size = FFMIN(read_size, ISOM_DVCC_DVVC_SIZE);
+    read_size = FFMINI(read_size, ISOM_DVCC_DVVC_SIZE);
 
     if ((ret = ffio_read_size(pb, buf, read_size)) < 0)
         return ret;
@@ -8722,14 +8722,14 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     }
     item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
 
-    heif_item = av_realloc_array(c->heif_item, FFMAX(item_count, c->nb_heif_item), sizeof(*c->heif_item));
+    heif_item = av_realloc_array(c->heif_item, FFMAXI(item_count, c->nb_heif_item), sizeof(*c->heif_item));
     if (!heif_item)
         return AVERROR(ENOMEM);
     c->heif_item = heif_item;
     if (item_count > c->nb_heif_item)
         memset(&c->heif_item[c->nb_heif_item], 0,
                sizeof(*c->heif_item) * (item_count - c->nb_heif_item));
-    c->nb_heif_item = FFMAX(c->nb_heif_item, item_count);
+    c->nb_heif_item = FFMAXI(c->nb_heif_item, item_count);
 
     av_log(c->fc, AV_LOG_TRACE, "iloc: item_count %d\n", item_count);
     for (int i = 0; i < item_count; i++) {
@@ -8859,14 +8859,14 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     avio_rb24(pb);  // flags.
     entry_count = version ? avio_rb32(pb) : avio_rb16(pb);
 
-    heif_item = av_realloc_array(c->heif_item, FFMAX(entry_count, c->nb_heif_item), sizeof(*c->heif_item));
+    heif_item = av_realloc_array(c->heif_item, FFMAXI(entry_count, c->nb_heif_item), sizeof(*c->heif_item));
     if (!heif_item)
         return AVERROR(ENOMEM);
     c->heif_item = heif_item;
     if (entry_count > c->nb_heif_item)
         memset(&c->heif_item[c->nb_heif_item], 0,
                sizeof(*c->heif_item) * (entry_count - c->nb_heif_item));
-    c->nb_heif_item = FFMAX(c->nb_heif_item, entry_count);
+    c->nb_heif_item = FFMAXI(c->nb_heif_item, entry_count);
 
     for (i = 0; i < entry_count; i++) {
         MOVAtom infe;
@@ -9387,7 +9387,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         a.size -= 8;
         if (a.size < 0)
             break;
-        a.size = FFMIN(a.size, atom.size - total_size);
+        a.size = FFMINI(a.size, atom.size - total_size);
 
         for (i = 0; mov_default_parse_table[i].type; i++)
             if (mov_default_parse_table[i].type == a.type) {
@@ -9488,7 +9488,7 @@ static int mov_probe(const AVProbeData *p)
                         || AV_RL32(p->buf + offset + 8) == MKTAG('j','p','x',' ')
                         || AV_RL32(p->buf + offset + 8) == MKTAG('j','x','l',' ')
                     )) {
-                score = FFMAX(score, 5);
+                score = FFMAXI(score, 5);
             } else {
                 score = AVPROBE_SCORE_MAX;
             }
@@ -9499,16 +9499,16 @@ static int mov_probe(const AVProbeData *p)
         case MKTAG('f','r','e','e'):
         case MKTAG('j','u','n','k'):
         case MKTAG('p','i','c','t'):
-            score  = FFMAX(score, AVPROBE_SCORE_MAX - 5);
+            score  = FFMAXI(score, AVPROBE_SCORE_MAX - 5);
             break;
         case MKTAG(0x82,0x82,0x7f,0x7d):
-            score  = FFMAX(score, AVPROBE_SCORE_EXTENSION - 5);
+            score  = FFMAXI(score, AVPROBE_SCORE_EXTENSION - 5);
             break;
         case MKTAG('s','k','i','p'):
         case MKTAG('u','u','i','d'):
         case MKTAG('p','r','f','l'):
             /* if we only find those cause probedata is too small at least rate them */
-            score  = FFMAX(score, AVPROBE_SCORE_EXTENSION);
+            score  = FFMAXI(score, AVPROBE_SCORE_EXTENSION);
             break;
         }
         if (size > INT64_MAX - offset)
@@ -10437,7 +10437,7 @@ static void fix_stream_ids(AVFormatContext *s)
         const AVStream *st = s->streams[i];
         const MOVStreamContext *sc = st->priv_data;
         if (!sc->iamf)
-            highest_id = FFMAX(highest_id, st->id);
+            highest_id = FFMAXI(highest_id, st->id);
     }
     highest_id += !highest_id;
     for (int i = 0; highest_id > 1 && i < s->nb_stream_groups; i++) {
@@ -10978,8 +10978,8 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
     mov_current_sample_inc(sc);
 
     if (mov->next_root_atom) {
-        sample->pos = FFMIN(sample->pos, mov->next_root_atom);
-        sample->size = FFMIN(sample->size, (mov->next_root_atom - sample->pos));
+        sample->pos = FFMINI(sample->pos, mov->next_root_atom);
+        sample->size = FFMINI(sample->size, (mov->next_root_atom - sample->pos));
     }
 
     if (st->discard != AVDISCARD_ALL) {
@@ -11169,7 +11169,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp,
         if (!sample || can_seek_to_key_sample(st, sample, timestamp))
             break;
 
-        next_ts = timestamp - FFMAX(sc->min_sample_duration, 1);
+        next_ts = timestamp - FFMAXI(sc->min_sample_duration, 1);
         requested_sample = av_index_search_timestamp(st, next_ts, flags);
 
         // If we've reached a different sample trying to find a good pts to
@@ -11229,7 +11229,7 @@ static int64_t mov_get_skip_samples(AVStream *st, int sample)
     /* compute skip samples according to stream start_pad, seek ts and first ts */
     off = av_rescale_q(ts - first_ts, st->time_base,
                        (AVRational){1, st->codecpar->sample_rate});
-    return FFMAX(sc->start_pad - off, 0);
+    return FFMAXI(sc->start_pad - off, 0);
 }
 
 static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 9392ba53702..f1b8e8a6a09 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -227,7 +227,7 @@ static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track)
     }
     if (equalChunks && track->entry) {
         int sSize = track->entry ? track->cluster[0].size / track->cluster[0].entries : 0;
-        sSize = FFMAX(1, sSize); // adpcm mono case could make sSize == 0
+        sSize = FFMAXI(1, sSize); // adpcm mono case could make sSize == 0
         avio_wb32(pb, sSize); // sample size
         avio_wb32(pb, entries); // sample count
     } else {
@@ -471,8 +471,8 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
         goto end;
     }
 
-    info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);
-    info->ac3_bit_rate_code = FFMAX(info->ac3_bit_rate_code,
+    info->data_rate = FFMAXI(info->data_rate, hdr->bit_rate / 1000);
+    info->ac3_bit_rate_code = FFMAXI(info->ac3_bit_rate_code,
                                     hdr->ac3_bit_rate_code);
     num_blocks = hdr->num_blocks;
 
@@ -732,7 +732,7 @@ static struct mpeg4_bit_rate_values calculate_mpeg4_bit_rates(MOVTrack *track)
     }
 
     // (FIXME should be max rate in any 1 sec window)
-    bit_rates.max_bit_rate = FFMAX(track->par->bit_rate,
+    bit_rates.max_bit_rate = FFMAXI(track->par->bit_rate,
                                    bit_rates.avg_bit_rate);
 
     // utilize values from properties if we have them available
@@ -740,7 +740,7 @@ static struct mpeg4_bit_rate_values calculate_mpeg4_bit_rates(MOVTrack *track)
         // no avg_bitrate signals that the track is VBR
         if (!props->avg_bitrate)
             bit_rates.avg_bit_rate = props->avg_bitrate;
-        bit_rates.max_bit_rate = FFMAX(bit_rates.max_bit_rate,
+        bit_rates.max_bit_rate = FFMAXI(bit_rates.max_bit_rate,
                                        props->max_bitrate);
         bit_rates.buffer_size = props->buffer_size / 8;
     }
@@ -4025,7 +4025,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
          * here, but use FFMIN in case dts is a small positive integer
          * rounded to 0 when represented in movie timescale units. */
         av_assert0(av_rescale_rnd(start_dts, mov->movie_timescale, track->timescale, AV_ROUND_DOWN) <= 0);
-        start_ct  = -FFMIN(start_dts, 0);
+        start_ct  = -FFMINI(start_dts, 0);
 
 #if CONFIG_IAMFENC
         if (track->iamf && track->par->codec_id == AV_CODEC_ID_OPUS)
@@ -4810,7 +4810,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
 static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
 {
     int64_t pos = avio_tell(pb);
-    int i, nb_chapters = FFMIN(s->nb_chapters, 255);
+    int i, nb_chapters = FFMINI(s->nb_chapters, 255);
 
     avio_wb32(pb, 0);            // size
     ffio_wfourcc(pb, "chpl");
@@ -4824,7 +4824,7 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
         avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
 
         if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
-            int len = FFMIN(strlen(t->value), 255);
+            int len = FFMINI(strlen(t->value), 255);
             avio_w8(pb, len);
             avio_write(pb, t->value, len);
         } else
@@ -5043,8 +5043,8 @@ static int mov_setup_track_ids(MOVMuxContext *mov, AVFormatContext *s)
 
             last_track_id =
             mov->tracks[i].track_id = (mov->tracks[i].st
-                                       ? FFMAX(mov->tracks[i].st->index, last_track_id)
-                                       : FFMAX(i, last_track_id)) + 1;
+                                       ? FFMAXI(mov->tracks[i].st->index, last_track_id)
+                                       : FFMAXI(i, last_track_id)) + 1;
         }
     }
 
@@ -5145,7 +5145,7 @@ static void param_write_string(AVIOContext *pb, const char *name, const char *va
 static void param_write_hex(AVIOContext *pb, const char *name, const uint8_t *value, int len)
 {
     char buf[150];
-    len = FFMIN(sizeof(buf) / 2 - 1, len);
+    len = FFMINI(sizeof(buf) / 2 - 1, len);
     ff_data_to_hex(buf, value, len, 0);
     avio_printf(pb, "<param name=\"%s\" value=\"%s\" valuetype=\"data\"/>\n", name, buf);
 }
@@ -6040,7 +6040,7 @@ static int mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
                         (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den :
                         0;
     int audio_kbitrate = audio_par->bit_rate / 1000;
-    int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate);
+    int video_kbitrate = FFMINI(video_par->bit_rate / 1000, 800 - audio_kbitrate);
 
     if (frame_rate < 0 || frame_rate > INT32_MAX) {
         av_log(s, AV_LOG_ERROR, "Frame rate %f outside supported range\n", frame_rate / (double)0x10000);
@@ -6934,7 +6934,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         trk->end_pts = trk->cluster[trk->entry].dts +
                        trk->cluster[trk->entry].cts + pkt->duration;
     else
-        trk->end_pts = FFMAX(trk->end_pts, trk->cluster[trk->entry].dts +
+        trk->end_pts = FFMAXI(trk->end_pts, trk->cluster[trk->entry].dts +
                                            trk->cluster[trk->entry].cts +
                                            pkt->duration);
 
@@ -7655,8 +7655,8 @@ static int mov_init_iamf_track(AVFormatContext *s)
         switch(stg->type) {
         case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT:
             for (int j = 0; j < stg->nb_streams; j++) {
-                first_iamf_idx = FFMIN(stg->streams[j]->index, first_iamf_idx);
-                last_iamf_idx  = FFMAX(stg->streams[j]->index, last_iamf_idx);
+                first_iamf_idx = FFMINI(stg->streams[j]->index, first_iamf_idx);
+                last_iamf_idx  = FFMAXI(stg->streams[j]->index, last_iamf_idx);
             }
 
             ret = ff_iamf_add_audio_element(iamf, stg, s);
diff --git a/libavformat/movenc_ttml.c b/libavformat/movenc_ttml.c
index 413eccfc0f9..c96ad904d0e 100644
--- a/libavformat/movenc_ttml.c
+++ b/libavformat/movenc_ttml.c
@@ -72,7 +72,7 @@ static int mov_write_ttml_document_from_queue(AVFormatContext *s,
     }
 
     while (!avpriv_packet_list_get(&track->squashed_packet_queue, pkt)) {
-        end_ts = FFMAX(end_ts, pkt->pts + pkt->duration);
+        end_ts = FFMAXI(end_ts, pkt->pts + pkt->duration);
 
         // in case of the 'dfxp' muxing mode, each written document is offset
         // to its containing sample's beginning.
diff --git a/libavformat/movenccenc.c b/libavformat/movenccenc.c
index 32094ebd7bf..9669a2393e1 100644
--- a/libavformat/movenccenc.c
+++ b/libavformat/movenccenc.c
@@ -34,7 +34,7 @@ static int auxiliary_info_alloc_size(MOVMuxCencContext* ctx, int size)
     size_t new_alloc_size;
 
     if (ctx->auxiliary_info_size + size > ctx->auxiliary_info_alloc_size) {
-        new_alloc_size = FFMAX(ctx->auxiliary_info_size + size, ctx->auxiliary_info_alloc_size * 2);
+        new_alloc_size = FFMAXI(ctx->auxiliary_info_size + size, ctx->auxiliary_info_alloc_size * 2);
         if (av_reallocp(&ctx->auxiliary_info, new_alloc_size)) {
             return AVERROR(ENOMEM);
         }
@@ -100,7 +100,7 @@ static void mov_cenc_write_encrypted(MOVMuxCencContext* ctx, AVIOContext *pb,
     int cur_size;
 
     while (size_left > 0) {
-        cur_size = FFMIN(size_left, sizeof(chunk));
+        cur_size = FFMINI(size_left, sizeof(chunk));
         av_aes_ctr_crypt(ctx->aes_ctr, chunk, cur_pos, cur_size);
         avio_write(pb, chunk, cur_size);
         cur_pos += cur_size;
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 31eeb68ebb0..e8bb63241ae 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -95,7 +95,7 @@ static int mp3_read_probe(const AVProbeData *p)
             if (ret != 0)
                 break;
 
-            available = FFMIN(h.frame_size, end - buf2);
+            available = FFMINI(h.frame_size, end - buf2);
             for (buf3 = buf2 + 4; buf3 < buf2 + available; buf3++) {
                 uint32_t next_sync = AV_RB32(buf3);
                 header_emu += (next_sync & MP3_MASK) == (header & MP3_MASK);
@@ -109,8 +109,8 @@ static int mp3_read_probe(const AVProbeData *p)
             }
             buf2 += h.frame_size;
         }
-        max_frames = FFMAX(max_frames, frames);
-        max_framesizes = FFMAX(max_framesizes, framesizes);
+        max_frames = FFMAXI(max_frames, frames);
+        max_framesizes = FFMAXI(max_framesizes, framesizes);
         if (buf == buf0) {
             first_frames= frames;
             if (buf2 == end + sizeof(uint32_t))
@@ -191,8 +191,8 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st,
         mp3->header_filesize = avio_rb32(s->pb);
     if (fsize && mp3->header_filesize) {
         uint64_t min, delta;
-        min = FFMIN(fsize, mp3->header_filesize);
-        delta = FFMAX(fsize, mp3->header_filesize) - min;
+        min = FFMINI(fsize, mp3->header_filesize);
+        delta = FFMAXI(fsize, mp3->header_filesize) - min;
         if (fsize > mp3->header_filesize && delta > min >> 4) {
             mp3->frames = 0;
             av_log(s, AV_LOG_WARNING,
@@ -457,7 +457,7 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
     size = MP3_PACKET_SIZE;
     pos = avio_tell(s->pb);
     if (mp3->filesize > ID3v1_TAG_SIZE && pos < mp3->filesize)
-        size= FFMIN(size, mp3->filesize - pos);
+        size= FFMINI(size, mp3->filesize - pos);
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret <= 0) {
@@ -506,7 +506,7 @@ static int64_t mp3_sync(AVFormatContext *s, int64_t target_pos, int flags)
     int best_score, i, j;
     int64_t ret;
 
-    avio_seek(s->pb, FFMAX(target_pos - SEEK_WINDOW, 0), SEEK_SET);
+    avio_seek(s->pb, FFMAXI(target_pos - SEEK_WINDOW, 0), SEEK_SET);
     ret = avio_seek(s->pb, target_pos, SEEK_SET);
     if (ret < 0)
         return ret;
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 5695eeec9ed..a7d967929f1 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -252,7 +252,7 @@ static int mp3_write_xing(AVFormatContext *s)
             && !strcmp("Lavc libmp3lame", enc->value)) {
             memcpy(encoder_str, "Lavf lame", 9);
         } else
-            memcpy(encoder_str, enc->value, FFMIN(strlen(enc->value), sizeof(encoder_str)));
+            memcpy(encoder_str, enc->value, FFMINI(strlen(enc->value), sizeof(encoder_str)));
 
         avio_write(dyn_ctx, encoder_str, sizeof(encoder_str));
     } else
@@ -368,9 +368,9 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
                                                 AV_PKT_DATA_SKIP_SAMPLES,
                                                 &side_data_size);
             if (side_data && side_data_size >= 10) {
-                mp3->padding = FFMAX(AV_RL32(side_data + 4) + 528 + 1, 0);
+                mp3->padding = FFMAXI(AV_RL32(side_data + 4) + 528 + 1, 0);
                 if (!mp3->delay)
-                    mp3->delay =  FFMAX(AV_RL32(side_data) - 528 - 1, 0);
+                    mp3->delay =  FFMAXI(AV_RL32(side_data) - 528 - 1, 0);
             } else {
                 mp3->padding = 0;
             }
@@ -420,7 +420,7 @@ static void mp3_update_xing(AVFormatContext *s)
     for (i = 1; i < XING_TOC_SIZE; ++i) {
         int j = i * mp3->pos / XING_TOC_SIZE;
         int seek_point = 256LL * mp3->bag[j] / mp3->size;
-        toc[i] = FFMIN(seek_point, 255);
+        toc[i] = FFMINI(seek_point, 255);
     }
 
     /* write replaygain */
diff --git a/libavformat/mpc.c b/libavformat/mpc.c
index 1e0e170c7d8..b73c90574a7 100644
--- a/libavformat/mpc.c
+++ b/libavformat/mpc.c
@@ -192,7 +192,7 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
     MPCContext *c = s->priv_data;
     AVPacket pkt1, *pkt = &pkt1;
     int ret;
-    int index = av_index_search_timestamp(st, FFMAX(timestamp - DELAY_FRAMES, 0), flags);
+    int index = av_index_search_timestamp(st, FFMAXI(timestamp - DELAY_FRAMES, 0), flags);
     uint32_t lastframe;
 
     /* if found, seek there */
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index c41aa1095ce..4d029a3ea4e 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -1077,7 +1077,7 @@ retry:
                     "packet too large, ignoring buffer limits to mux it\n");
                 ignore_constraints = 1;
             }
-            scr = FFMAX(best_dts + 1, scr);
+            scr = FFMAXI(best_dts + 1, scr);
             if (remove_decoded_packets(ctx, scr) < 0)
                 return -1;
         } else if (has_premux && flush) {
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index deb69a0548b..5139af2cc96 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -605,7 +605,7 @@ static int analyze(const uint8_t *buf, int size, int packet_size,
         }
     }
 
-    return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
+    return best_score - FFMAXI(stat_all - 10*best_score, 0)/10;
 }
 
 /* autodetect fec presence */
@@ -1068,7 +1068,7 @@ static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
     int dts_flag = -1, cts_flag = -1;
     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
     uint8_t buf_padded[128 + AV_INPUT_BUFFER_PADDING_SIZE];
-    int buf_padded_size = FFMIN(buf_size, sizeof(buf_padded) - AV_INPUT_BUFFER_PADDING_SIZE);
+    int buf_padded_size = FFMINI(buf_size, sizeof(buf_padded) - AV_INPUT_BUFFER_PADDING_SIZE);
 
     memcpy(buf_padded, buf, buf_padded_size);
 
@@ -1134,7 +1134,7 @@ static AVBufferRef *buffer_pool_get(MpegTSContext *ts, int size)
 {
     int index = av_log2(size + AV_INPUT_BUFFER_PADDING_SIZE);
     if (!ts->pools[index]) {
-        int pool_size = FFMIN(ts->max_packet_size + AV_INPUT_BUFFER_PADDING_SIZE, 2 << index);
+        int pool_size = FFMINI(ts->max_packet_size + AV_INPUT_BUFFER_PADDING_SIZE, 2 << index);
         ts->pools[index] = av_buffer_pool_init(pool_size, NULL);
         if (!ts->pools[index])
             return NULL;
@@ -2921,7 +2921,7 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren
     AVIOContext *pb = s->pb;
     int c, i;
     uint64_t pos = avio_tell(pb);
-    int64_t back = FFMIN(seekback, pos);
+    int64_t back = FFMINI(seekback, pos);
 
     //Special case for files like 01c56b0dc1.ts
     if (current_packet[0] == 0x80 && current_packet[12] == SYNC_BYTE && pos >= TS_PACKET_SIZE) {
@@ -3068,13 +3068,13 @@ static int mpegts_probe(const AVProbeData *p)
         return 0;
 
     for (i = 0; i<check_count; i+=CHECK_BLOCK) {
-        int left = FFMIN(check_count - i, CHECK_BLOCK);
+        int left = FFMINI(check_count - i, CHECK_BLOCK);
         int score      = analyze(p->buf + TS_PACKET_SIZE     *i, TS_PACKET_SIZE     *left, TS_PACKET_SIZE     , 1);
         int dvhs_score = analyze(p->buf + TS_DVHS_PACKET_SIZE*i, TS_DVHS_PACKET_SIZE*left, TS_DVHS_PACKET_SIZE, 1);
         int fec_score  = analyze(p->buf + TS_FEC_PACKET_SIZE *i, TS_FEC_PACKET_SIZE *left, TS_FEC_PACKET_SIZE , 1);
         score = FFMAX3(score, dvhs_score, fec_score);
         sumscore += score;
-        maxscore = FFMAX(maxscore, score);
+        maxscore = FFMAXI(maxscore, score);
     }
 
     sumscore = sumscore * CHECK_COUNT / check_count;
@@ -3137,7 +3137,7 @@ static int mpegts_read_header(AVFormatContext *s)
     MpegTSContext *ts = s->priv_data;
     AVIOContext *pb   = s->pb;
     int64_t pos, probesize = s->probesize;
-    int64_t seekback = FFMAX(s->probesize, (int64_t)ts->resync_size + PROBE_PACKET_MAX_BUF);
+    int64_t seekback = FFMAXI(s->probesize, (int64_t)ts->resync_size + PROBE_PACKET_MAX_BUF);
 
     if (ffio_ensure_seekback(pb, seekback) < 0)
         av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n");
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 6935b71cfe4..ec1c1dabf22 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1318,14 +1318,14 @@ static void retransmit_si_info(AVFormatContext *s, int force_pat, int force_sdt,
         force_sdt
     ) {
         if (pcr != AV_NOPTS_VALUE)
-            ts->last_sdt_ts = FFMAX(pcr, ts->last_sdt_ts);
+            ts->last_sdt_ts = FFMAXI(pcr, ts->last_sdt_ts);
         mpegts_write_sdt(s);
     }
     if ((pcr != AV_NOPTS_VALUE && ts->last_pat_ts == AV_NOPTS_VALUE) ||
         (pcr != AV_NOPTS_VALUE && pcr - ts->last_pat_ts >= ts->pat_period) ||
         force_pat) {
         if (pcr != AV_NOPTS_VALUE)
-            ts->last_pat_ts = FFMAX(pcr, ts->last_pat_ts);
+            ts->last_pat_ts = FFMAXI(pcr, ts->last_pat_ts);
         mpegts_write_pat(s);
         for (i = 0; i < ts->nb_services; i++)
             mpegts_write_pmt(s, ts->services[i]);
@@ -1335,7 +1335,7 @@ static void retransmit_si_info(AVFormatContext *s, int force_pat, int force_sdt,
         force_nit
     ) {
         if (pcr != AV_NOPTS_VALUE)
-            ts->last_nit_ts = FFMAX(pcr, ts->last_nit_ts);
+            ts->last_nit_ts = FFMAXI(pcr, ts->last_nit_ts);
         if (ts->flags & MPEGTS_FLAG_NIT)
             mpegts_write_nit(s);
     }
@@ -1537,7 +1537,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
                     MpegTSWriteStream *ts_st2 = st2->priv_data;
                     if (ts_st2->pcr_period) {
                         if (pcr - ts_st2->last_pcr >= ts_st2->pcr_period) {
-                            ts_st2->last_pcr = FFMAX(pcr - ts_st2->pcr_period, ts_st2->last_pcr + ts_st2->pcr_period);
+                            ts_st2->last_pcr = FFMAXI(pcr - ts_st2->pcr_period, ts_st2->last_pcr + ts_st2->pcr_period);
                             if (st2 != st) {
                                 mpegts_insert_pcr_only(s, st2);
                                 pcr = get_pcr(ts);
@@ -1545,7 +1545,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
                                 write_pcr = 1;
                             }
                         }
-                        next_pcr = FFMIN(next_pcr, ts_st2->last_pcr + ts_st2->pcr_period);
+                        next_pcr = FFMINI(next_pcr, ts_st2->last_pcr + ts_st2->pcr_period);
                     }
                 }
                 ts->next_pcr = next_pcr;
@@ -1561,7 +1561,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
             }
         } else if (ts_st->pcr_period && pcr != AV_NOPTS_VALUE) {
             if (pcr - ts_st->last_pcr >= ts_st->pcr_period && is_start) {
-                ts_st->last_pcr = FFMAX(pcr - ts_st->pcr_period, ts_st->last_pcr + ts_st->pcr_period);
+                ts_st->last_pcr = FFMAXI(pcr - ts_st->pcr_period, ts_st->last_pcr + ts_st->pcr_period);
                 write_pcr = 1;
             }
         }
@@ -2107,7 +2107,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
             n = pkt->size;
             i = 2;
             do {
-                data[i] = FFMIN(n, 255);
+                data[i] = FFMINI(n, 255);
                 n -= 255;
                 i++;
             } while (n >= 0);
@@ -2115,13 +2115,13 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
             av_assert0(2 + pkt->size / 255 + 1 == i);
 
             if (ts_st->opus_pending_trim_start) {
-                trim_start = FFMIN(ts_st->opus_pending_trim_start, opus_samples);
+                trim_start = FFMINI(ts_st->opus_pending_trim_start, opus_samples);
                 AV_WB16(data + i, trim_start);
                 i += 2;
                 ts_st->opus_pending_trim_start -= trim_start;
             }
             if (trim_end) {
-                trim_end = FFMIN(trim_end, opus_samples - trim_start);
+                trim_end = FFMINI(trim_end, opus_samples - trim_start);
                 AV_WB16(data + i, trim_end);
                 i += 2;
             }
diff --git a/libavformat/mux.c b/libavformat/mux.c
index db3b6c2bfee..edf159b8d66 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -991,7 +991,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
             last_dts = av_rescale_q(last->pkt.dts,
                                     st->time_base,
                                     AV_TIME_BASE_Q);
-            delta_dts = FFMAX(delta_dts, last_dts - top_dts);
+            delta_dts = FFMAXI(delta_dts, last_dts - top_dts);
         }
 
         if (delta_dts > s->max_interleave_delta) {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index ffb207576a2..87dc7133a2a 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2080,7 +2080,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
             int temporal_offset = 0;
 
             if (!(mxf->index_entries[i].flags & 0x33)) { // I-frame
-                sc->max_gop = FFMAX(sc->max_gop, i - mxf->last_key_index);
+                sc->max_gop = FFMAXI(sc->max_gop, i - mxf->last_key_index);
                 mxf->last_key_index = key_index;
                 key_index = i;
             }
@@ -2100,7 +2100,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
             avio_w8(pb, temporal_offset);
 
             if ((mxf->index_entries[i].flags & 0x30) == 0x30) { // back and forward prediction
-                sc->b_picture_count = FFMAX(sc->b_picture_count, i - prev_non_b_picture);
+                sc->b_picture_count = FFMAXI(sc->b_picture_count, i - prev_non_b_picture);
                 avio_w8(pb, mxf->last_key_index - i);
             } else {
                 avio_w8(pb, key_index - i); // key frame offset
@@ -2595,7 +2595,7 @@ static inline int get_ffv1_unsigned_symbol(RangeCoder *c, uint8_t *state) {
         int i, e;
         unsigned a;
         e= 0;
-        while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
+        while(get_rac(c, state+1 + FFMINI(e,9))){ //1..10
             e++;
             if (e > 31)
                 return AVERROR_INVALIDDATA;
@@ -2603,7 +2603,7 @@ static inline int get_ffv1_unsigned_symbol(RangeCoder *c, uint8_t *state) {
 
         a= 1;
         for(i=e-1; i>=0; i--){
-            a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
+            a += a + get_rac(c, state+22 + FFMINI(i,9)); //22..31
         }
 
         return a;
diff --git a/libavformat/network.c b/libavformat/network.c
index 2eabd0c1674..4b7c4aec72a 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -114,7 +114,7 @@ int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
         if (time_left <= 0)
             return AVERROR(ETIMEDOUT);
 
-        av_usleep(FFMIN(time_left, POLLING_TIME * 1000));
+        av_usleep(FFMINI(time_left, POLLING_TIME * 1000));
     }
 }
 
@@ -465,7 +465,7 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
         next_deadline_us = attempts[0].deadline_us;
         // If we can start another attempt in parallel, wait until that time.
         if (nb_attempts < parallel && addrs)
-            next_deadline_us = FFMIN(next_deadline_us, next_attempt_us);
+            next_deadline_us = FFMINI(next_deadline_us, next_attempt_us);
         last_err = ff_poll_interrupt(pfd, nb_attempts,
                                      (next_deadline_us - av_gettime_relative())/1000,
                                      &h->interrupt_callback);
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index dd01765d7d2..de3d16d7697 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -606,7 +606,7 @@ null_chunk_retry:
         pkt->stream_index = st[NSV_ST_VIDEO]->index;//NSV_ST_VIDEO;
         pkt->dts = nst->frame_offset;
         pkt->flags |= nsv->state == NSV_HAS_READ_NSVS ? AV_PKT_FLAG_KEY : 0; /* keyframe only likely on a sync frame */
-        for (i = 0; i < FFMIN(8, vsize); i++)
+        for (i = 0; i < FFMINI(8, vsize); i++)
             av_log(s, AV_LOG_TRACE, "NSV video: [%d] = %02x\n", i, pkt->data[i]);
     }
     if(st[NSV_ST_VIDEO])
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 34b7e3cb9af..7a0c421008e 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -45,7 +45,7 @@ static int get_str(AVIOContext *bc, char *string, unsigned int maxlen)
     unsigned int len = ffio_read_varlen(bc);
 
     if (len && maxlen)
-        avio_read(bc, string, FFMIN(len, maxlen));
+        avio_read(bc, string, FFMINI(len, maxlen));
     while (len > maxlen) {
         avio_r8(bc);
         len--;
@@ -54,7 +54,7 @@ static int get_str(AVIOContext *bc, char *string, unsigned int maxlen)
     }
 
     if (maxlen)
-        string[FFMIN(len, maxlen - 1)] = 0;
+        string[FFMINI(len, maxlen - 1)] = 0;
 
     if (bc->eof_reached)
         return AVERROR_EOF;
@@ -621,7 +621,7 @@ static int decode_info_header(NUTContext *nut)
         return AVERROR_INVALIDDATA;
     }
 fail:
-    return FFMIN(ret, 0);
+    return FFMINI(ret, 0);
 }
 
 static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr)
@@ -1191,7 +1191,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
         default:
 resync:
             av_log(s, AV_LOG_DEBUG, "syncing from %"PRId64"\n", pos);
-            tmp = find_any_startcode(bc, FFMAX(nut->last_syncpoint_pos, nut->last_resync_pos) + 1);
+            tmp = find_any_startcode(bc, FFMAXI(nut->last_syncpoint_pos, nut->last_resync_pos) + 1);
             nut->last_resync_pos = avio_tell(bc);
             if (tmp == 0)
                 return AVERROR_INVALIDDATA;
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 55efb114c3c..9b48ba96d39 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -724,7 +724,7 @@ static int nut_write_header(AVFormatContext *s)
 
     nut->avf = s;
 
-    nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags);
+    nut->version = FFMAXI(NUT_STABLE_VERSION, 3 + !!nut->flags);
     if (nut->version > 3 && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
         av_log(s, AV_LOG_ERROR,
                "The additional syncpoint modes require version %d, "
@@ -769,7 +769,7 @@ static int nut_write_header(AVFormatContext *s)
         else
             nut->stream[i].msb_pts_shift = 14;
         nut->stream[i].max_pts_distance =
-            FFMAX(time_base.den, time_base.num) / time_base.num;
+            FFMAXI(time_base.den, time_base.num) / time_base.num;
     }
 
     for (i = 0; i < s->nb_chapters; i++) {
@@ -1024,7 +1024,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
             int index = av_index_search_timestamp(st, dts_tb,
                                                   AVSEEK_FLAG_BACKWARD);
             if (index >= 0) {
-                sp_pos = FFMIN(sp_pos, sti->index_entries[index].pos);
+                sp_pos = FFMINI(sp_pos, sti->index_entries[index].pos);
                 if (!nut->write_index && 2*index > sti->nb_index_entries) {
                     memmove(sti->index_entries,
                             sti->index_entries + index,
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index e1bb7dd9724..4d6b631e236 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -231,7 +231,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
     for (i = 0; i < total_segments; ) {
         OGGPage *page = &oggstream->page;
 
-        segments = FFMIN(total_segments - i, 255 - page->segments_count);
+        segments = FFMINI(total_segments - i, 255 - page->segments_count);
 
         if (i && !page->segments_count)
             page->flags |= 1; // continued packet
@@ -239,7 +239,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
         memset(page->segments+page->segments_count, 255, segments - 1);
         page->segments_count += segments - 1;
 
-        len = FFMIN(size, segments*255);
+        len = FFMINI(size, segments*255);
         page->segments[page->segments_count++] = len - (segments-1)*255;
         if (len)
             memcpy(page->data+page->size, p, len);
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index 65b93b40532..872298a37e8 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -115,7 +115,7 @@ static int opus_duration(uint8_t *src, int size)
     unsigned toc        = src[0];
     unsigned toc_config = toc >> 3;
     unsigned toc_count  = toc & 3;
-    unsigned frame_size = toc_config < 12 ? FFMAX(480, 960 * (toc_config & 3)) :
+    unsigned frame_size = toc_config < 12 ? FFMAXI(480, 960 * (toc_config & 3)) :
                           toc_config < 16 ? 480 << (toc_config & 1) :
                                             120 << (toc_config & 3);
     if (toc_count == 3) {
@@ -199,7 +199,7 @@ static int opus_packet(AVFormatContext *avf, int idx)
     priv->cur_dts += os->pduration;
     if ((os->flags & OGG_FLAG_EOS)) {
         int64_t skip = priv->cur_dts - os->granule + priv->pre_skip;
-        skip = FFMIN(skip, os->pduration);
+        skip = FFMINI(skip, os->pduration);
         if (skip > 0) {
             os->pduration = skip < os->pduration ? os->pduration - skip : 1;
             os->end_trimming = skip;
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index 552a37df18c..516386a9fd4 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -103,7 +103,7 @@ static void hex_log(AVFormatContext *s, int level,
                     const char *name, const uint8_t *value, int len)
 {
     char buf[33];
-    len = FFMIN(len, 16);
+    len = FFMINI(len, 16);
     if (av_log_get_level() < level)
         return;
     ff_data_to_hex(buf, value, len, 1);
@@ -118,7 +118,7 @@ static int kset(AVFormatContext *s, const uint8_t *r_val, const uint8_t *n_val,
     if (!r_val && !n_val)
         return -1;
 
-    len = FFMIN(len, 16);
+    len = FFMINI(len, 16);
 
     /* use first 64 bits in the third round again */
     if (r_val) {
diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c
index 5360b7c5d7d..87c2640d1ee 100644
--- a/libavformat/pp_bnk.c
+++ b/libavformat/pp_bnk.c
@@ -114,7 +114,7 @@ static int pp_bnk_read_header(AVFormatContext *s)
     AVStream *st;
     AVCodecParameters *par;
     PPBnkCtx *ctx = s->priv_data;
-    uint8_t buf[FFMAX(PP_BNK_FILE_HEADER_SIZE, PP_BNK_TRACK_SIZE)];
+    uint8_t buf[FFMAXI(PP_BNK_FILE_HEADER_SIZE, PP_BNK_TRACK_SIZE)];
     PPBnkHeader hdr;
 
     if ((ret = avio_read(s->pb, buf, PP_BNK_FILE_HEADER_SIZE)) < 0)
@@ -248,7 +248,7 @@ static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt)
         else if (ret != trk->data_offset + trk->bytes_read)
             return AVERROR(EIO);
 
-        size = FFMIN(trk->data_size - trk->bytes_read, PP_BNK_MAX_READ_SIZE);
+        size = FFMINI(trk->data_size - trk->bytes_read, PP_BNK_MAX_READ_SIZE);
 
         if (!ctx->is_music) {
             ret = av_get_packet(s->pb, pkt, size);
diff --git a/libavformat/pva.c b/libavformat/pva.c
index 047c93c9c44..c6f36f53a9f 100644
--- a/libavformat/pva.c
+++ b/libavformat/pva.c
@@ -207,7 +207,7 @@ static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index,
     int length, streamid;
     int64_t res = AV_NOPTS_VALUE;
 
-    pos_limit = FFMIN(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit);
+    pos_limit = FFMINI(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit);
 
     while (*pos < pos_limit) {
         res = AV_NOPTS_VALUE;
diff --git a/libavformat/qcp.c b/libavformat/qcp.c
index 288e321e896..a9d6ddb3e8b 100644
--- a/libavformat/qcp.c
+++ b/libavformat/qcp.c
@@ -133,7 +133,7 @@ static int qcp_read_header(AVFormatContext *s)
 
     memset(c->rates_per_mode, -1, sizeof(c->rates_per_mode));
     nb_rates = avio_rl32(pb);
-    nb_rates = FFMIN(nb_rates, 8);
+    nb_rates = FFMINI(nb_rates, 8);
     for (i=0; i<nb_rates; i++) {
         int size = avio_r8(pb);
         int mode = avio_r8(pb);
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index d0c829dc429..95095ffeb59 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -213,7 +213,7 @@ static int mjpeg_probe(const AVProbeData *p)
         static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n";
         int i;
 
-        for (i=0; i<FFMIN(p->buf_size - (int)sizeof(ct_jpeg), 100); i++)
+        for (i=0; i<FFMINI(p->buf_size - (int)sizeof(ct_jpeg), 100); i++)
             if (!memcmp(p->buf + i, ct_jpeg, sizeof(ct_jpeg) - 1))
                 return AVPROBE_SCORE_EXTENSION;
 
diff --git a/libavformat/rawutils.c b/libavformat/rawutils.c
index e44c946d470..fe6370c5f07 100644
--- a/libavformat/rawutils.c
+++ b/libavformat/rawutils.c
@@ -34,7 +34,7 @@ int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters
     int contains_pal = bpc == 8 && pkt->size == with_pal_size;
     int size = contains_pal ? min_stride * par->height : pkt->size;
     int stride = size / par->height;
-    int padding = expected_stride - FFMIN(expected_stride, stride);
+    int padding = expected_stride - FFMINI(expected_stride, stride);
     int y;
     AVPacket *new_pkt;
 
@@ -56,7 +56,7 @@ int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters
         goto fail;
 
     for (y = 0; y<par->height; y++) {
-        memcpy(new_pkt->data + y*expected_stride, pkt->data + y*stride, FFMIN(expected_stride, stride));
+        memcpy(new_pkt->data + y*expected_stride, pkt->data + y*stride, FFMINI(expected_stride, stride));
         memset(new_pkt->data + y*expected_stride + expected_stride - padding, 0, padding);
     }
 
diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 2b269b16822..68d9390e116 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -144,7 +144,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
             return AVERROR_PATCHWELCOME;
         }
         size  -= 18;
-        cbSize = FFMIN(size, cbSize);
+        cbSize = FFMINI(size, cbSize);
         if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
             parse_waveformatex(s, pb, par);
             cbSize -= 22;
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 85643a358fb..65753d6ee59 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -754,7 +754,7 @@ static int rm_sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stre
             num = avio_rb16(pb);
             *timestamp = avio_rb32(pb);
             mlti_id = (avio_r8(pb) >> 1) - 1;
-            mlti_id = FFMAX(mlti_id, 0) << 16;
+            mlti_id = FFMAXI(mlti_id, 0) << 16;
             *flags = avio_r8(pb); /* flags */
         }
         for(i=0;i<s->nb_streams;i++) {
@@ -844,7 +844,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
         vst->pktpos = avio_tell(pb);
     }
     if(type == 2)
-        len = FFMIN(len, pos);
+        len = FFMINI(len, pos);
 
     if(++vst->cur_slice > vst->slices) {
         av_log(s, AV_LOG_ERROR, "cur slice %d, too large\n", vst->cur_slice);
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index ec10c89fc8a..70c57e4a4cc 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -113,7 +113,7 @@ int ff_amf_get_string(GetByteContext *bc, uint8_t *str,
                "Unable to read as many bytes as AMF string signaled\n");
     }
     str[readsize] = '\0';
-    *length = FFMIN(stringlen, readsize);
+    *length = FFMINI(stringlen, readsize);
     return 0;
 }
 
@@ -270,7 +270,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
     prev_pkt[channel_id].extra      = extra;
     size = size - p->offset;
 
-    toread = FFMIN(size, chunk_size);
+    toread = FFMINI(size, chunk_size);
     if (ffurl_read_complete(h, p->data + p->offset, toread) != toread) {
         ff_rtmp_packet_destroy(p);
         return AVERROR(EIO);
@@ -389,7 +389,7 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
         return ret;
     written = p - pkt_hdr + pkt->size;
     while (off < pkt->size) {
-        int towrite = FFMIN(chunk_size, pkt->size - off);
+        int towrite = FFMINI(chunk_size, pkt->size - off);
         if ((ret = ffurl_write(h, pkt->data + off, towrite)) < 0)
             return ret;
         off += towrite;
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 846376e6686..081806dee06 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2745,7 +2745,7 @@ reconnect:
         // Strip any further query parameters from fname
         amp = strchr(fname, '&');
         if (amp) {
-            av_strlcpy(fname_buffer, fname, FFMIN(amp - fname + 1,
+            av_strlcpy(fname_buffer, fname, FFMINI(amp - fname + 1,
                                                   sizeof(fname_buffer)));
             fname = fname_buffer;
         }
@@ -2770,10 +2770,10 @@ reconnect:
             fname = strchr(p + 1, '/');
             if (!fname || (c && c < fname)) {
                 fname = p + 1;
-                av_strlcpy(rt->app, path + 1, FFMIN(p - path, APP_MAX_LENGTH));
+                av_strlcpy(rt->app, path + 1, FFMINI(p - path, APP_MAX_LENGTH));
             } else {
                 fname++;
-                av_strlcpy(rt->app, path + 1, FFMIN(fname - path - 1, APP_MAX_LENGTH));
+                av_strlcpy(rt->app, path + 1, FFMINI(fname - path - 1, APP_MAX_LENGTH));
             }
         }
     }
@@ -3004,7 +3004,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
 
     do {
         if (rt->skip_bytes) {
-            int skip = FFMIN(rt->skip_bytes, size_temp);
+            int skip = FFMINI(rt->skip_bytes, size_temp);
             buf_temp       += skip;
             size_temp      -= skip;
             rt->skip_bytes -= skip;
@@ -3015,7 +3015,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
             const uint8_t *header = rt->flv_header;
             int channel = RTMP_AUDIO_CHANNEL;
 
-            copy = FFMIN(RTMP_HEADER - rt->flv_header_bytes, size_temp);
+            copy = FFMINI(RTMP_HEADER - rt->flv_header_bytes, size_temp);
             bytestream_get_buffer(&buf_temp, rt->flv_header + rt->flv_header_bytes, copy);
             rt->flv_header_bytes += copy;
             size_temp            -= copy;
@@ -3058,7 +3058,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
             rt->flv_data = rt->out_pkt.data;
         }
 
-        copy = FFMIN(rt->flv_size - rt->flv_off, size_temp);
+        copy = FFMINI(rt->flv_size - rt->flv_off, size_temp);
         bytestream_get_buffer(&buf_temp, rt->flv_data + rt->flv_off, copy);
         rt->flv_off += copy;
         size_temp   -= copy;
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index ebd5402bce8..33cd8a61e1c 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -183,7 +183,7 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,
 {
     int payload_len;
     while (len >= 4) {
-        payload_len = FFMIN(len, (AV_RB16(buf + 2) + 1) * 4);
+        payload_len = FFMINI(len, (AV_RB16(buf + 2) + 1) * 4);
 
         switch (buf[1]) {
         case RTCP_SR:
@@ -350,7 +350,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, URLContext *fd,
     extended_max          = stats->cycles + stats->max_seq;
     expected              = extended_max - stats->base_seq;
     lost                  = expected - stats->received;
-    lost                  = FFMIN(lost, 0xffffff); // clamp it since it's only 24 bits...
+    lost                  = FFMINI(lost, 0xffffff); // clamp it since it's only 24 bits...
     expected_interval     = expected - stats->expected_prior;
     stats->expected_prior = expected;
     received_interval     = stats->received - stats->received_prior;
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
index 9664623e574..bf952cabded 100644
--- a/libavformat/rtpdec_asf.c
+++ b/libavformat/rtpdec_asf.c
@@ -260,12 +260,12 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
                 int cur_len = start_off + len_off - off;
                 int prev_len = out_len;
                 out_len += cur_len;
-                if (FFMIN(cur_len, len - off) < 0)
+                if (FFMINI(cur_len, len - off) < 0)
                     return -1;
                 if ((res = av_reallocp(&asf->buf, out_len)) < 0)
                     return res;
                 memcpy(asf->buf + prev_len, buf + off,
-                       FFMIN(cur_len, len - off));
+                       FFMINI(cur_len, len - off));
                 avio_skip(pb, cur_len);
             }
         }
diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c
index 80e89bda70f..faaa125a717 100644
--- a/libavformat/rtpdec_mpeg4.c
+++ b/libavformat/rtpdec_mpeg4.c
@@ -63,7 +63,7 @@ struct PayloadContext {
     int au_headers_length_bytes;
     int cur_au_index;
 
-    uint8_t buf[FFMAX(RTP_MAX_PACKET_LENGTH, MAX_AAC_HBR_FRAME_SIZE)];
+    uint8_t buf[FFMAXI(RTP_MAX_PACKET_LENGTH, MAX_AAC_HBR_FRAME_SIZE)];
     int buf_pos, buf_size;
     uint32_t timestamp;
 };
@@ -280,7 +280,7 @@ static int aac_parse_packet(AVFormatContext *ctx, PayloadContext *data,
     pkt->stream_index = st->index;
 
     if (len > 0 && data->nb_au_headers > 1) {
-        data->buf_size = FFMIN(len, sizeof(data->buf));
+        data->buf_size = FFMINI(len, sizeof(data->buf));
         memcpy(data->buf, buf, data->buf_size);
         data->cur_au_index = 1;
         data->buf_pos = 0;
diff --git a/libavformat/rtpdec_mpegts.c b/libavformat/rtpdec_mpegts.c
index 405271f744a..735c3b6f230 100644
--- a/libavformat/rtpdec_mpegts.c
+++ b/libavformat/rtpdec_mpegts.c
@@ -81,7 +81,7 @@ static int mpegts_handle_packet(AVFormatContext *ctx, PayloadContext *data,
     if (ret < 0)
         return AVERROR(EAGAIN);
     if (ret < len) {
-        data->read_buf_size = FFMIN(len - ret, sizeof(data->buf));
+        data->read_buf_size = FFMINI(len - ret, sizeof(data->buf));
         memcpy(data->buf, buf + ret, data->read_buf_size);
         data->read_buf_index = 0;
         return 1;
diff --git a/libavformat/rtpdec_opus.c b/libavformat/rtpdec_opus.c
index 4ed9d8842bd..99aba905e1b 100644
--- a/libavformat/rtpdec_opus.c
+++ b/libavformat/rtpdec_opus.c
@@ -32,7 +32,7 @@ static int opus_duration(const uint8_t *src, int size)
     unsigned toc        = src[0];
     unsigned toc_config = toc >> 3;
     unsigned toc_count  = toc & 3;
-    unsigned frame_size = toc_config < 12 ? FFMAX(480, 960 * (toc_config & 3)) :
+    unsigned frame_size = toc_config < 12 ? FFMAXI(480, 960 * (toc_config & 3)) :
                           toc_config < 16 ? 480 << (toc_config & 1) :
                                             120 << (toc_config & 3);
     if (toc_count == 3) {
diff --git a/libavformat/rtpdec_qdm2.c b/libavformat/rtpdec_qdm2.c
index dce3c48bcc0..90ce67256b2 100644
--- a/libavformat/rtpdec_qdm2.c
+++ b/libavformat/rtpdec_qdm2.c
@@ -172,7 +172,7 @@ static int qdm2_parse_subpacket(PayloadContext *qdm, AVStream *st,
         type |= *p++ << 8;
 
     /* copy data into a temporary buffer */
-    to_copy = FFMIN(len + (p - &buf[1]), 0x800 - qdm->len[id]);
+    to_copy = FFMINI(len + (p - &buf[1]), 0x800 - qdm->len[id]);
     memcpy(&qdm->buf[id][qdm->len[id]], buf + 1, to_copy);
     qdm->len[id] += to_copy;
 
@@ -217,7 +217,7 @@ static int qdm2_restore_block(PayloadContext *qdm, AVStream *st, AVPacket *pkt)
     }
 
     /* subpacket data */
-    to_copy = FFMIN(qdm->len[n], pkt->size - (p - pkt->data));
+    to_copy = FFMINI(qdm->len[n], pkt->size - (p - pkt->data));
     memcpy(p, qdm->buf[n], to_copy);
     qdm->len[n] = 0;
 
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index b220a941a27..b2c31a662f5 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -147,7 +147,7 @@ static int rtp_write_header(AVFormatContext *s1)
 
     if (s1->packet_size) {
         if (s1->pb->max_packet_size)
-            s1->packet_size = FFMIN(s1->packet_size,
+            s1->packet_size = FFMINI(s1->packet_size,
                                     s1->pb->max_packet_size);
     } else
         s1->packet_size = s1->pb->max_packet_size;
@@ -326,7 +326,7 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time, int bye)
     avio_wb32(s1->pb, s->octet_count);
 
     if (s->cname) {
-        int len = FFMIN(strlen(s->cname), 255);
+        int len = FFMINI(strlen(s->cname), 255);
         avio_w8(s1->pb, (RTP_VERSION << 6) + 1);
         avio_w8(s1->pb, RTCP_SDES);
         avio_wb16(s1->pb, (7 + len + 3) / 4); /* length in words - 1 */
@@ -390,7 +390,7 @@ static int rtp_send_samples(AVFormatContext *s1,
     n = 0;
     while (size > 0) {
         s->buf_ptr = s->buf;
-        len = FFMIN(max_packet_size, size);
+        len = FFMINI(max_packet_size, size);
 
         /* copy data */
         memcpy(s->buf_ptr, buf1, len);
diff --git a/libavformat/rtpenc_aac.c b/libavformat/rtpenc_aac.c
index fad8ea2a5b3..7848c6b41c8 100644
--- a/libavformat/rtpenc_aac.c
+++ b/libavformat/rtpenc_aac.c
@@ -75,7 +75,7 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
         p = s->buf;
         AV_WB16(p, 2 * 8);
         while (size > 0) {
-            len = FFMIN(size, max_packet_size);
+            len = FFMINI(size, max_packet_size);
             AV_WB16(&p[2], au_size * 8);
             memcpy(p + 4, buff, len);
             ff_rtp_send_data(s1, p, len + 4, len == size);
diff --git a/libavformat/rtpenc_h261.c b/libavformat/rtpenc_h261.c
index be417963636..2f203898c1e 100644
--- a/libavformat/rtpenc_h261.c
+++ b/libavformat/rtpenc_h261.c
@@ -80,7 +80,7 @@ void ff_rtp_send_h261(AVFormatContext *ctx, const uint8_t *frame_buf, int frame_
                    "RTP/H.261 packet not cut at a GOB boundary, not signaled correctly\n");
         }
 
-        cur_frame_size = FFMIN(rtp_ctx->max_payload_size - RTP_H261_HEADER_SIZE, frame_size);
+        cur_frame_size = FFMINI(rtp_ctx->max_payload_size - RTP_H261_HEADER_SIZE, frame_size);
 
         /* look for a better place to split the frame into packets */
         if (cur_frame_size < frame_size) {
diff --git a/libavformat/rtpenc_h263.c b/libavformat/rtpenc_h263.c
index e14aaf1dbdb..2d67f75a660 100644
--- a/libavformat/rtpenc_h263.c
+++ b/libavformat/rtpenc_h263.c
@@ -59,7 +59,7 @@ void ff_rtp_send_h263(AVFormatContext *s1, const uint8_t *buf1, int size)
         }
         *q++ = 0;
 
-        len = FFMIN(max_packet_size - 2, size);
+        len = FFMINI(max_packet_size - 2, size);
 
         /* Look for a better place to split the frame into packets. */
         if (len < size) {
diff --git a/libavformat/rtpenc_h263_rfc2190.c b/libavformat/rtpenc_h263_rfc2190.c
index 3567202d8d4..30ff0c1d14c 100644
--- a/libavformat/rtpenc_h263_rfc2190.c
+++ b/libavformat/rtpenc_h263_rfc2190.c
@@ -126,7 +126,7 @@ void ff_rtp_send_h263_rfc2190(AVFormatContext *s1, const uint8_t *buf, int size,
 
     while (size > 0) {
         struct H263State packet_start_state = state;
-        len = FFMIN(s->max_payload_size - 8, size);
+        len = FFMINI(s->max_payload_size - 8, size);
 
         /* Look for a better place to split the frame into packets. */
         if (len < size) {
diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
index e4e95931f45..4919e864e36 100644
--- a/libavformat/rtpenc_jpeg.c
+++ b/libavformat/rtpenc_jpeg.c
@@ -204,7 +204,7 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
             hdr_size += 4 + 64 * nb_qtables;
 
         /* payload max in one packet */
-        len = FFMIN(size, s->max_payload_size - hdr_size);
+        len = FFMINI(size, s->max_payload_size - hdr_size);
 
         /* set main header */
         bytestream_put_byte(&p, 0);
diff --git a/libavformat/rtpenc_latm.c b/libavformat/rtpenc_latm.c
index 7bda66af956..10462b7d2cb 100644
--- a/libavformat/rtpenc_latm.c
+++ b/libavformat/rtpenc_latm.c
@@ -48,7 +48,7 @@ void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size)
 
     /* PayloadMux() */
     while (size > 0) {
-        len   = FFMIN(size, s->max_payload_size - (!offset ? header_size : 0));
+        len   = FFMINI(size, s->max_payload_size - (!offset ? header_size : 0));
         size -= len;
         if (!offset) {
             memcpy(s->buf + header_size, buff, len);
diff --git a/libavformat/rtpenc_vc2hq.c b/libavformat/rtpenc_vc2hq.c
index cf548191d2e..4c8c56be8bc 100644
--- a/libavformat/rtpenc_vc2hq.c
+++ b/libavformat/rtpenc_vc2hq.c
@@ -90,7 +90,7 @@ static int send_picture(AVFormatContext *ctx, const uint8_t *buf, int size, int
     size -= frag_len;
 
     while (size > 0) {
-        frag_len = FFMIN(rtp_ctx->max_payload_size - 20 /* pl header */, size);
+        frag_len = FFMINI(rtp_ctx->max_payload_size - 20 /* pl header */, size);
         AV_WB16(&info_hdr[ 8], frag_len);
         AV_WB16(&info_hdr[10], 1 /* nr. of slices */);
         AV_WB16(&info_hdr[12], 0 /* slice x */);
diff --git a/libavformat/rtpenc_vp8.c b/libavformat/rtpenc_vp8.c
index 655d44517e4..3b391e19bbd 100644
--- a/libavformat/rtpenc_vp8.c
+++ b/libavformat/rtpenc_vp8.c
@@ -42,7 +42,7 @@ void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buf, int size)
     max_packet_size = s->max_payload_size - header_size;
 
     while (size > 0) {
-        len = FFMIN(size, max_packet_size);
+        len = FFMINI(size, max_packet_size);
 
         memcpy(s->buf_ptr, buf, len);
         // marker bit is last packet in frame
diff --git a/libavformat/rtpenc_vp9.c b/libavformat/rtpenc_vp9.c
index 172ab21f1eb..a585cef9722 100644
--- a/libavformat/rtpenc_vp9.c
+++ b/libavformat/rtpenc_vp9.c
@@ -35,7 +35,7 @@ void ff_rtp_send_vp9(AVFormatContext *ctx, const uint8_t *buf, int size)
     *rtp_ctx->buf_ptr++ = 0x08;
 
     while (size > 0) {
-        len = FFMIN(size, rtp_ctx->max_payload_size - RTP_VP9_DESC_REQUIRED_SIZE);
+        len = FFMINI(size, rtp_ctx->max_payload_size - RTP_VP9_DESC_REQUIRED_SIZE);
 
         if (len == size) {
             /* mark the last fragment */
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 5ea471b40cc..f02ff0b5e28 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -209,7 +209,7 @@ static int get_sockaddr(AVFormatContext *s,
                gai_strerror(ret));
         return -1;
     }
-    memcpy(sock, ai->ai_addr, FFMIN(sizeof(*sock), ai->ai_addrlen));
+    memcpy(sock, ai->ai_addr, FFMINI(sizeof(*sock), ai->ai_addrlen));
     freeaddrinfo(ai);
     return 0;
 }
diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index bf319be228d..631accb47cd 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -165,7 +165,7 @@ static void *alloc_array_elem(void **array, size_t elsize,
     void *ret;
 
     if (*size == *max_size) {
-        int m = FFMAX(32, FFMIN(*max_size, INT_MAX / 2) * 2);
+        int m = FFMAXI(32, FFMINI(*max_size, INT_MAX / 2) * 2);
         if (*size >= m)
             return NULL;
         *array = av_realloc_f(*array, m, elsize);
@@ -1059,7 +1059,7 @@ static int add_bell(struct ws_intervals *inter, struct sbg_script *s,
     int i, r;
     int64_t dt = s->sample_rate / 20, ts3 = ts1, ts4;
     for (i = 0; i < FF_ARRAY_ELEMS(cpoints); i++) {
-        ts4 = FFMIN(ts2, ts1 + cpoints[i][0] * dt);
+        ts4 = FFMINI(ts2, ts1 + cpoints[i][0] * dt);
         r = add_interval(inter, WS_SINE, 3, -1,
                          ts3, f, a, ts4, f, cpoints[i][1]);
         if (r < 0)
@@ -1187,7 +1187,7 @@ static int generate_transition(void *log, struct sbg_script *s,
     /* (ts1 + ts2) / 2 without overflow */
     int64_t tsmid = (ts1 >> 1) + (ts2 >> 1) + (ts1 & ts2 & 1);
     enum sbg_fade_type type = ev1->fade.slide | (ev1->fade.out & ev2->fade.in);
-    int nb_elements = FFMAX(ev1->nb_elements, ev2->nb_elements);
+    int nb_elements = FFMAXI(ev1->nb_elements, ev2->nb_elements);
     struct sbg_script_synth *s1, *s2, s1mod, s2mod, smid;
     int pass, i, r;
 
@@ -1280,7 +1280,7 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate,
         return AVERROR_INVALIDDATA;
 
     period = (period + (DAY_TS - 1)) / DAY_TS * DAY_TS;
-    period = FFMAX(period, DAY_TS);
+    period = FFMAXI(period, DAY_TS);
 
     /* Prepare timestamps for transitions */
     for (i = 0; i < s->nb_events; i++) {
@@ -1298,8 +1298,8 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate,
         ev1 = &s->events[i];
         ev2 = &s->events[(i + 1) % s->nb_events];
         if (!ev1->fade.slide) {
-            ev1->ts_trans = FFMAX(ev1->ts_int,   ev1->ts_trans - trans_time);
-            ev2->ts_int   = FFMIN(ev2->ts_trans, ev2->ts_int   + trans_time);
+            ev1->ts_trans = FFMAXI(ev1->ts_int,   ev1->ts_trans - trans_time);
+            ev2->ts_int   = FFMINI(ev2->ts_trans, ev2->ts_int   + trans_time);
         }
         ev1->ts_next  = ev2->ts_int + (ev1 < ev2 ? 0 : period);
     }
@@ -1416,7 +1416,7 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
     else
         script.sample_rate = sbg->sample_rate;
     if (!sbg->frame_size)
-        sbg->frame_size = FFMAX(1, sbg->sample_rate / 10);
+        sbg->frame_size = FFMAXI(1, sbg->sample_rate / 10);
     if (script.opt_mix)
         av_log(avf, AV_LOG_WARNING, "Mix feature not implemented: "
                "-m is ignored and mix channels will be silent.\n");
@@ -1481,7 +1481,7 @@ static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet)
     ts = ffstream(avf->streams[0])->cur_dts;
     end_ts = av_sat_add64(ts, avf->streams[0]->codecpar->frame_size);
     if (avf->streams[0]->duration != AV_NOPTS_VALUE)
-        end_ts = FFMIN(avf->streams[0]->start_time + avf->streams[0]->duration,
+        end_ts = FFMINI(avf->streams[0]->start_time + avf->streams[0]->duration,
                        end_ts);
     if (end_ts <= ts)
         return AVERROR_EOF;
diff --git a/libavformat/scd.c b/libavformat/scd.c
index ee118c1668f..f938a736dbb 100644
--- a/libavformat/scd.c
+++ b/libavformat/scd.c
@@ -315,7 +315,7 @@ static int scd_read_packet(AVFormatContext *s, AVPacket *pkt)
                 break;
             case SCD_TRACK_ID_MP3:
             default:
-                size = FFMIN(trk->length - trk->bytes_read, 4096);
+                size = FFMINI(trk->length - trk->bytes_read, 4096);
                 break;
         }
 
diff --git a/libavformat/sdns.c b/libavformat/sdns.c
index 9d1e356a235..989296b835d 100644
--- a/libavformat/sdns.c
+++ b/libavformat/sdns.c
@@ -66,7 +66,7 @@ static int sdns_read_header(AVFormatContext *s)
     memset(par->extradata, 0, 28);
     par->extradata[4] = (channels + 1) / 2;
     for (int i = 0; i < par->extradata[4]; i++)
-        par->extradata[8 + 20 * i + 17] = FFMIN(2, channels - i * 2);
+        par->extradata[8 + 20 * i + 17] = FFMINI(2, channels - i * 2);
     avpriv_set_pts_info(st, 64, 1, par->sample_rate);
     avio_seek(pb, 0x1000, SEEK_SET);
 
diff --git a/libavformat/seek.c b/libavformat/seek.c
index c0d94371e6e..19e9620f4f3 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -207,7 +207,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
                 int64_t e1_pts = av_rescale_q(e1->timestamp, st1->time_base, AV_TIME_BASE_Q);
 
                 if (e1->size < (1 << 23))
-                    skip = FFMAX(skip, e1->size);
+                    skip = FFMAXI(skip, e1->size);
 
                 for (; i2 < sti2->nb_index_entries; i2++) {
                     const AVIndexEntry *const e2 = &sti2->index_entries[i2];
@@ -217,7 +217,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
                         continue;
                     cur_delta = FFABS(e1->pos - e2->pos);
                     if (cur_delta < (1 << 23))
-                        pos_delta = FFMAX(pos_delta, cur_delta);
+                        pos_delta = FFMAXI(pos_delta, cur_delta);
                     break;
                 }
             }
@@ -236,10 +236,10 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
             return;
         }
 
-        ctx->short_seek_threshold = FFMAX(ctx->short_seek_threshold, pos_delta/2);
+        ctx->short_seek_threshold = FFMAXI(ctx->short_seek_threshold, pos_delta/2);
     }
 
-    ctx->short_seek_threshold = FFMAX(ctx->short_seek_threshold, skip);
+    ctx->short_seek_threshold = FFMAXI(ctx->short_seek_threshold, skip);
 }
 
 int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)
@@ -316,7 +316,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
          * index case, especially read_timestamp(). */
         index = av_index_search_timestamp(st, target_ts,
                                           flags | AVSEEK_FLAG_BACKWARD);
-        index = FFMAX(index, 0);
+        index = FFMAXI(index, 0);
         e     = &sti->index_entries[index];
 
         if (e->timestamp <= target_ts || e->pos == e->min_distance) {
@@ -366,7 +366,7 @@ int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *
     int64_t pos_max  = filesize - 1;
     do {
         limit   = pos_max;
-        pos_max = FFMAX(0, (pos_max) - step);
+        pos_max = FFMAXI(0, (pos_max) - step);
         ts_max  = read_timestamp(s, stream_index,
                                  &pos_max, limit, read_timestamp_func);
         step   += step;
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 65323ec6781..f98d5979fec 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -300,7 +300,7 @@ static int segment_list_open(AVFormatContext *s)
                seg->segment_list_entries->index);
 
         for (entry = seg->segment_list_entries; entry; entry = entry->next)
-            max_duration = FFMAX(max_duration, entry->end_time - entry->start_time);
+            max_duration = FFMAXD(max_duration, entry->end_time - entry->start_time);
         avio_printf(seg->list_pb, "#EXT-X-TARGETDURATION:%"PRId64"\n", (int64_t)ceil(max_duration));
     } else if (seg->list_type == LIST_TYPE_FFCONCAT) {
         avio_printf(seg->list_pb, "ffconcat version 1.0\n");
@@ -947,7 +947,7 @@ calc_times:
     if (pkt->stream_index == seg->reference_stream_index) {
         if (pkt->pts != AV_NOPTS_VALUE)
             seg->cur_entry.end_time =
-                FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base));
+                FFMAXD(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base));
         seg->cur_entry.last_duration = pkt->duration;
     }
 
diff --git a/libavformat/sga.c b/libavformat/sga.c
index 23a18657cf1..48572fbaa6a 100644
--- a/libavformat/sga.c
+++ b/libavformat/sga.c
@@ -100,7 +100,7 @@ static int sga_probe(const AVProbeData *p)
             offset = i + left + 2;
         } else if (sectors && i > 0) {
             i += 2048;
-            last_left -= FFMIN(last_left, 2046);
+            last_left -= FFMINI(last_left, 2046);
             continue;
         } else {
             offset = 0;
@@ -170,7 +170,7 @@ static int sga_probe(const AVProbeData *p)
         }
 
         i += sectors ? 2048 : size + 4;
-        last_left -= FFMIN(last_left, 2046);
+        last_left -= FFMINI(last_left, 2046);
 
         if (score < 0)
             break;
diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c
index 5b8f41d76d5..5067a72ec84 100644
--- a/libavformat/smjpegenc.c
+++ b/libavformat/smjpegenc.c
@@ -107,7 +107,7 @@ static int smjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
     avio_wb32(pb, pkt->size);
     avio_write(pb, pkt->data, pkt->size);
 
-    smc->duration = FFMAX(smc->duration, pkt->pts + pkt->duration);
+    smc->duration = FFMAXI(smc->duration, pkt->pts + pkt->duration);
     return 0;
 }
 
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index adf3008003c..918874ef72d 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -191,7 +191,7 @@ static void output_chunk_list(OutputStream *os, AVIOContext *out, int final, int
     if (final)
         skip = 0;
     if (window_size)
-        start = FFMAX(os->nb_fragments - skip - window_size, 0);
+        start = FFMAXI(os->nb_fragments - skip - window_size, 0);
     for (i = start; i < os->nb_fragments - skip; i++) {
         Fragment *frag = os->fragments[i];
         if (!final || removed)
@@ -236,8 +236,8 @@ static int write_manifest(AVFormatContext *s, int final)
         video_chunks = audio_chunks = 0;
     }
     if (c->window_size) {
-        video_chunks = FFMIN(video_chunks, c->window_size);
-        audio_chunks = FFMIN(audio_chunks, c->window_size);
+        video_chunks = FFMINI(video_chunks, c->window_size);
+        audio_chunks = FFMINI(audio_chunks, c->window_size);
     }
     avio_printf(out, "<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" Duration=\"%"PRIu64"\"", duration);
     if (!final)
@@ -481,7 +481,7 @@ static int copy_moof(AVFormatContext *s, const char* infile, const char *outfile
     }
     while (size > 0) {
         uint8_t buf[8192];
-        int n = FFMIN(size, sizeof(buf));
+        int n = FFMINI(size, sizeof(buf));
         n = avio_read(in, buf, n);
         if (n <= 0) {
             ret = AVERROR(EIO);
diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
index dcfe471f450..559e743c168 100644
--- a/libavformat/spdifdec.c
+++ b/libavformat/spdifdec.c
@@ -122,7 +122,7 @@ static int spdif_probe(const AVProbeData *p)
 int ff_spdif_probe(const uint8_t *p_buf, int buf_size, enum AVCodecID *codec)
 {
     const uint8_t *buf = p_buf;
-    const uint8_t *probe_end = p_buf + FFMIN(2 * SPDIF_MAX_OFFSET, buf_size - 1);
+    const uint8_t *probe_end = p_buf + FFMINI(2 * SPDIF_MAX_OFFSET, buf_size - 1);
     const uint8_t *expected_code = buf + 7;
     uint32_t state = 0;
     int sync_codes = 0;
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index ab3f73da0de..f3cb6e4b077 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -516,7 +516,7 @@ static int spdif_header_truehd(AVFormatContext *s, AVPacket *pkt)
 
             if (padding_remaining) {
                 /* consider the MAT code as padding */
-                int counted_as_padding = FFMIN(padding_remaining,
+                int counted_as_padding = FFMINI(padding_remaining,
                                                code_len_remaining);
                 padding_remaining -= counted_as_padding;
                 code_len_remaining -= counted_as_padding;
@@ -527,7 +527,7 @@ static int spdif_header_truehd(AVFormatContext *s, AVPacket *pkt)
         }
 
         if (padding_remaining) {
-            int padding_to_insert = FFMIN(mat_codes[next_code_idx].pos - ctx->hd_buf_filled,
+            int padding_to_insert = FFMINI(mat_codes[next_code_idx].pos - ctx->hd_buf_filled,
                                           padding_remaining);
 
             memset(hd_buf + ctx->hd_buf_filled, 0, padding_to_insert);
@@ -539,7 +539,7 @@ static int spdif_header_truehd(AVFormatContext *s, AVPacket *pkt)
         }
 
         if (data_remaining) {
-            int data_to_insert = FFMIN(mat_codes[next_code_idx].pos - ctx->hd_buf_filled,
+            int data_to_insert = FFMINI(mat_codes[next_code_idx].pos - ctx->hd_buf_filled,
                                        data_remaining);
 
             memcpy(hd_buf + ctx->hd_buf_filled, dataptr, data_to_insert);
diff --git a/libavformat/srtp.c b/libavformat/srtp.c
index 7e5a42e327f..b3ee14081e3 100644
--- a/libavformat/srtp.c
+++ b/libavformat/srtp.c
@@ -165,7 +165,7 @@ int ff_srtp_decrypt(struct SRTPContext *s, uint8_t *buf, int *lenptr)
                 v = roc + 1;
         }
         if (v == roc) {
-            seq_largest = FFMAX(seq_largest, seq);
+            seq_largest = FFMAXI(seq_largest, seq);
         } else if (v == roc + 1) {
             seq_largest = seq;
             roc = v;
diff --git a/libavformat/srtpproto.c b/libavformat/srtpproto.c
index 02cf1563278..044217c5be6 100644
--- a/libavformat/srtpproto.c
+++ b/libavformat/srtpproto.c
@@ -81,7 +81,7 @@ static int srtp_open(URLContext *h, const char *uri, int flags, AVDictionary **o
                                     options, h->protocol_whitelist, h->protocol_blacklist, h)) < 0)
         goto fail;
 
-    h->max_packet_size = FFMIN(s->rtp_hd->max_packet_size,
+    h->max_packet_size = FFMINI(s->rtp_hd->max_packet_size,
                                sizeof(s->encryptbuf)) - 14;
     h->is_streamed = 1;
     return 0;
diff --git a/libavformat/subfile.c b/libavformat/subfile.c
index be48ef72ef2..a165b2a4861 100644
--- a/libavformat/subfile.c
+++ b/libavformat/subfile.c
@@ -105,7 +105,7 @@ static int subfile_read(URLContext *h, unsigned char *buf, int size)
 
     if (rest <= 0)
         return AVERROR_EOF;
-    size = FFMIN(size, rest);
+    size = FFMINI(size, rest);
     ret = ffurl_read(c->h, buf, size);
     if (ret >= 0)
         c->pos += ret;
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 29eefc68a22..bea01fcef1b 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -546,7 +546,7 @@ bitmap_end_skip:
     skip:
         if(len<0)
             av_log(s, AV_LOG_WARNING, "Clipping len %d\n", len);
-        len = FFMAX(0, len);
+        len = FFMAXI(0, len);
         avio_skip(pb, len);
     }
 }
diff --git a/libavformat/takdec.c b/libavformat/takdec.c
index b8f76aaa671..c78c070e528 100644
--- a/libavformat/takdec.c
+++ b/libavformat/takdec.c
@@ -202,7 +202,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
         int64_t size, left;
 
         left = tc->data_end - avio_tell(pb);
-        size = FFMIN(left, 1024);
+        size = FFMINI(left, 1024);
         if (size <= 0)
             return AVERROR_EOF;
 
diff --git a/libavformat/thp.c b/libavformat/thp.c
index 76db7fc5816..1051b20f1c6 100644
--- a/libavformat/thp.c
+++ b/libavformat/thp.c
@@ -176,7 +176,7 @@ static int thp_read_packet(AVFormatContext *s,
         avio_seek(pb, thp->next_frame, SEEK_SET);
 
         /* Locate the next frame and read out its size.  */
-        thp->next_frame += FFMAX(thp->next_framesz, 1);
+        thp->next_frame += FFMAXI(thp->next_framesz, 1);
         thp->next_framesz = avio_rb32(pb);
 
                         avio_rb32(pb); /* Previous total size.  */
diff --git a/libavformat/tls_schannel.c b/libavformat/tls_schannel.c
index ae9a311d2a5..c63c427c2c0 100644
--- a/libavformat/tls_schannel.c
+++ b/libavformat/tls_schannel.c
@@ -517,7 +517,7 @@ static int tls_read(URLContext *h, uint8_t *buf, int len)
     ret = 0;
 
 cleanup:
-    size = FFMIN(len, c->dec_buf_offset);
+    size = FFMINI(len, c->dec_buf_offset);
     if (size) {
         memcpy(buf, c->dec_buf, size);
         memmove(c->dec_buf, c->dec_buf + size, c->dec_buf_offset - size);
diff --git a/libavformat/tls_securetransport.c b/libavformat/tls_securetransport.c
index a5a3bd87a1d..47c7ece8b74 100644
--- a/libavformat/tls_securetransport.c
+++ b/libavformat/tls_securetransport.c
@@ -368,7 +368,7 @@ static int tls_read(URLContext *h, uint8_t *buf, int size)
     int ret;
     SSLGetBufferedReadSize(c->ssl_context, &available);
     if (available)
-        size = FFMIN(available, size);
+        size = FFMINI(available, size);
     ret = SSLRead(c->ssl_context, buf, size, &processed);
     ret = map_ssl_error(ret, processed);
     if (ret > 0)
diff --git a/libavformat/tty.c b/libavformat/tty.c
index c3956ccf34e..4dd411461c0 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -120,7 +120,7 @@ static int read_header(AVFormatContext *avctx)
     st->avg_frame_rate = s->framerate;
 
     /* simulate tty display speed */
-    s->chars_per_frame = FFMAX(av_q2d(st->time_base)*s->chars_per_frame, 1);
+    s->chars_per_frame = FFMAXD(av_q2d(st->time_base)*s->chars_per_frame, 1);
 
     if (avctx->pb->seekable & AVIO_SEEKABLE_NORMAL) {
         int64_t fsize = avio_size(avctx->pb);
diff --git a/libavformat/usmdec.c b/libavformat/usmdec.c
index fd28e935ce0..ce8330d513e 100644
--- a/libavformat/usmdec.c
+++ b/libavformat/usmdec.c
@@ -256,7 +256,7 @@ static int64_t parse_chunk(AVFormatContext *s, AVIOContext *pb,
     ret = avio_tell(pb);
     if (ret < 0)
         return ret;
-    ret = avio_skip(pb, FFMAX(0, (ret - chunk_start) - payload_offset));
+    ret = avio_skip(pb, FFMAXI(0, (ret - chunk_start) - payload_offset));
     if (ret < 0)
         return ret;
 
@@ -360,7 +360,7 @@ static int64_t parse_chunk(AVFormatContext *s, AVIOContext *pb,
     ret = avio_tell(pb);
     if (ret < 0)
         return ret;
-    ret = avio_skip(pb, FFMAX(0, chunk_size - (ret - chunk_start)));
+    ret = avio_skip(pb, FFMAXI(0, chunk_size - (ret - chunk_start)));
     if (ret < 0)
         return ret;
     return FFERROR_REDO;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index eee7b9e0e3c..d1827ca67fd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -68,7 +68,7 @@ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size)
             read_size = ffio_limit(s, read_size);
             // If filesize/maxsize is unknown, limit to SANE_CHUNK_SIZE
             if (ffiocontext(s)->maxsize < 0)
-                read_size = FFMIN(read_size, SANE_CHUNK_SIZE);
+                read_size = FFMINI(read_size, SANE_CHUNK_SIZE);
         }
 
         ret = av_grow_packet(pkt, read_size);
@@ -77,7 +77,7 @@ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size)
 
         ret = avio_read(s, pkt->data + prev_size, read_size);
         if (ret != read_size) {
-            av_shrink_packet(pkt, prev_size + FFMAX(ret, 0));
+            av_shrink_packet(pkt, prev_size + FFMAXI(ret, 0));
             break;
         }
 
@@ -371,7 +371,7 @@ void av_url_split(char *proto, int proto_size,
 
     /* parse protocol */
     if ((p = strchr(url, ':'))) {
-        av_strlcpy(proto, url, FFMIN(proto_size, p + 1 - url));
+        av_strlcpy(proto, url, FFMINI(proto_size, p + 1 - url));
         p++; /* skip ':' */
         if (*p == '/')
             p++;
@@ -393,24 +393,24 @@ void av_url_split(char *proto, int proto_size,
         at2 = p;
         while ((at = strchr(p, '@')) && at < ls) {
             av_strlcpy(authorization, at2,
-                       FFMIN(authorization_size, at + 1 - at2));
+                       FFMINI(authorization_size, at + 1 - at2));
             p = at + 1; /* skip '@' */
         }
 
         if (*p == '[' && (brk = strchr(p, ']')) && brk < ls) {
             /* [host]:port */
             av_strlcpy(hostname, p + 1,
-                       FFMIN(hostname_size, brk - p));
+                       FFMINI(hostname_size, brk - p));
             if (brk[1] == ':' && port_ptr)
                 *port_ptr = atoi(brk + 2);
         } else if ((col = strchr(p, ':')) && col < ls) {
             av_strlcpy(hostname, p,
-                       FFMIN(col + 1 - p, hostname_size));
+                       FFMINI(col + 1 - p, hostname_size));
             if (port_ptr)
                 *port_ptr = atoi(col + 1);
         } else
             av_strlcpy(hostname, p,
-                       FFMIN(ls + 1 - p, hostname_size));
+                       FFMINI(ls + 1 - p, hostname_size));
     }
 }
 
diff --git a/libavformat/vapoursynth.c b/libavformat/vapoursynth.c
index 0fa5affa63b..7234407f7a2 100644
--- a/libavformat/vapoursynth.c
+++ b/libavformat/vapoursynth.c
@@ -526,7 +526,7 @@ static int read_seek_vs(AVFormatContext *s, int stream_idx, int64_t ts, int flag
     if (!vs->is_cfr)
         return AVERROR(ENOSYS);
 
-    vs->current_frame = FFMIN(FFMAX(0, ts), s->streams[0]->duration);
+    vs->current_frame = FFMINI(FFMAXI(0, ts), s->streams[0]->duration);
     return 0;
 }
 
diff --git a/libavformat/voc_packet.c b/libavformat/voc_packet.c
index 32f8b29aa7a..dc753da70a9 100644
--- a/libavformat/voc_packet.c
+++ b/libavformat/voc_packet.c
@@ -145,7 +145,7 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
 
     if (max_size <= 0)
         max_size = 2048;
-    size = FFMIN(voc->remaining_size, max_size);
+    size = FFMINI(voc->remaining_size, max_size);
     voc->remaining_size -= size;
 
     ret = av_get_packet(pb, pkt, size);
diff --git a/libavformat/vqf.c b/libavformat/vqf.c
index 053720ea22f..c335b509e76 100644
--- a/libavformat/vqf.c
+++ b/libavformat/vqf.c
@@ -55,7 +55,7 @@ static int vqf_probe(const AVProbeData *probe_packet)
 static int add_metadata(AVFormatContext *s, uint32_t tag,
                          unsigned int tag_len, unsigned int remaining)
 {
-    int len = FFMIN(tag_len, remaining);
+    int len = FFMINI(tag_len, remaining);
     char *buf, key[5] = {0};
     int ret;
 
@@ -168,7 +168,7 @@ static int vqf_read_header(AVFormatContext *s)
         case MKTAG('_','Y','M','H'): // reserved
         case MKTAG('_','N','T','T'): // reserved
         case MKTAG('_','I','D','3'): // reserved for ID3 tags
-            avio_skip(s->pb, FFMIN(len, header_size));
+            avio_skip(s->pb, FFMINI(len, header_size));
             break;
         default:
             ret = add_metadata(s, chunk_tag, len, header_size);
diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index b293ff46de1..d4d8877d6a9 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -93,14 +93,14 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
         vvcc->ptl.general_level_idc = ptl->general_level_idc;
     else
         vvcc->ptl.general_level_idc =
-            FFMAX(vvcc->ptl.general_level_idc, ptl->general_level_idc);
+            FFMAXI(vvcc->ptl.general_level_idc, ptl->general_level_idc);
 
     /*
      * The tier indication general_tier_flag must indicate a tier equal to or
      * greater than the highest tier indicated in all the parameter sets.
      */
     vvcc->ptl.general_tier_flag =
-        FFMAX(vvcc->ptl.general_tier_flag, ptl->general_tier_flag);
+        FFMAXI(vvcc->ptl.general_tier_flag, ptl->general_tier_flag);
 
     /*
      * The profile indication general_profile_idc must indicate a profile to
@@ -117,7 +117,7 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
      * Note: set the profile to the highest value for the sake of simplicity.
      */
     vvcc->ptl.general_profile_idc =
-        FFMAX(vvcc->ptl.general_profile_idc, ptl->general_profile_idc);
+        FFMAXI(vvcc->ptl.general_profile_idc, ptl->general_profile_idc);
 
     /*
      * Each bit in flags may only be set if all
@@ -153,7 +153,7 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
             ptl->ptl_sublayer_level_present_flag[i];
         if (vvcc->ptl.ptl_sublayer_level_present_flag[i]) {
             vvcc->ptl.sublayer_level_idc[i] =
-                FFMAX(vvcc->ptl.sublayer_level_idc[i],
+                FFMAXI(vvcc->ptl.sublayer_level_idc[i],
                       ptl->sublayer_level_idc[i]);
         } else {
             if (i == vvcc->num_sublayers - 1) {
@@ -166,7 +166,7 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
     }
 
     vvcc->ptl.ptl_num_sub_profiles =
-        FFMAX(vvcc->ptl.ptl_num_sub_profiles, ptl->ptl_num_sub_profiles);
+        FFMAXI(vvcc->ptl.ptl_num_sub_profiles, ptl->ptl_num_sub_profiles);
     if (vvcc->ptl.ptl_num_sub_profiles) {
         for (int i = 0; i < vvcc->ptl.ptl_num_sub_profiles; i++) {
             vvcc->ptl.general_sub_profile_idc[i] =
@@ -254,7 +254,7 @@ static int vvcc_parse_vps(GetBitContext *gb,
      * indicates that the stream is not temporally scalable. Value 0 indicates
      * that it is unknown whether the stream is temporally scalable.
      */
-    vvcc->num_sublayers = FFMAX(vvcc->num_sublayers,
+    vvcc->num_sublayers = FFMAXI(vvcc->num_sublayers,
                                 vps_max_sublayers_minus1 + 1);
 
     if (vps_max_layers_minus1 > 0 && vps_max_sublayers_minus1 > 0)
@@ -345,7 +345,7 @@ static int vvcc_parse_sps(GetBitContext *gb,
      * indicates that the stream is not temporally scalable. Value 0 indicates
      * that it is unknown whether the stream is temporally scalable.
      */
-    vvcc->num_sublayers = FFMAX(vvcc->num_sublayers,
+    vvcc->num_sublayers = FFMAXI(vvcc->num_sublayers,
                                 sps_max_sublayers_minus1 + 1);
 
     vvcc->chroma_format_idc = get_bits(gb, 2);
@@ -362,10 +362,10 @@ static int vvcc_parse_sps(GetBitContext *gb,
 
     sps_pic_width_max_in_luma_samples = get_ue_golomb_long(gb);
     vvcc->max_picture_width =
-        FFMAX(vvcc->max_picture_width, sps_pic_width_max_in_luma_samples);
+        FFMAXI(vvcc->max_picture_width, sps_pic_width_max_in_luma_samples);
     sps_pic_height_max_in_luma_samples = get_ue_golomb_long(gb);
     vvcc->max_picture_height =
-        FFMAX(vvcc->max_picture_height, sps_pic_height_max_in_luma_samples);
+        FFMAXI(vvcc->max_picture_height, sps_pic_height_max_in_luma_samples);
 
     if (get_bits1(gb)) {
         get_ue_golomb_long(gb); // sps_conf_win_left_offset
diff --git a/libavformat/wavarc.c b/libavformat/wavarc.c
index 9d7029f2092..0dda4dce62a 100644
--- a/libavformat/wavarc.c
+++ b/libavformat/wavarc.c
@@ -124,7 +124,7 @@ static int wavarc_read_packet(AVFormatContext *s, AVPacket *pkt)
     int64_t size, left = w->data_end - avio_tell(pb);
     int ret;
 
-    size = FFMIN(left, 1024);
+    size = FFMINI(left, 1024);
     if (size <= 0)
         return AVERROR_EOF;
 
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index c65e0a2723c..d01a26f9d69 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -179,7 +179,7 @@ static void handle_stream_probing(AVStream *st)
     if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
         FFStream *const sti = ffstream(st);
         sti->request_probe = AVPROBE_SCORE_EXTENSION + 1;
-        sti->probe_packets = FFMIN(sti->probe_packets, 32);
+        sti->probe_packets = FFMINI(sti->probe_packets, 32);
     }
 }
 
@@ -789,7 +789,7 @@ smv_out:
             size = st->codecpar->block_align;
         size = (size / st->codecpar->block_align) * st->codecpar->block_align;
     }
-    size = FFMIN(size, left);
+    size = FFMINI(size, left);
     ret  = av_get_packet(s->pb, pkt, size);
     if (ret < 0)
         return ret;
@@ -917,7 +917,7 @@ static int w64_read_header(AVFormatContext *s)
                 st->codecpar->bits_per_coded_sample < 128) {
                 int64_t block_align = st->codecpar->block_align;
 
-                block_align = FFMAX(block_align,
+                block_align = FFMAXI(block_align,
                                     ((st->codecpar->bits_per_coded_sample + 7LL) / 8) *
                                     st->codecpar->ch_layout.nb_channels);
                 if (block_align > st->codecpar->block_align) {
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index 679eb2ce54d..dd7dc33b825 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -98,7 +98,7 @@ static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, in
 
     if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
         len = strlen(tag->value);
-        len = FFMIN(len, maxlen);
+        len = FFMINI(len, maxlen);
         avio_write(s->pb, tag->value, len);
     }
 
@@ -220,7 +220,7 @@ static int peak_write_frame(AVFormatContext *s)
 
         if (wav->peak_ppv == 1)
             wav->peak_maxpos[c] =
-                FFMAX(wav->peak_maxpos[c], wav->peak_maxneg[c]);
+                FFMAXI(wav->peak_maxpos[c], wav->peak_maxneg[c]);
 
         if (wav->peak_format == PEAK_FORMAT_UINT8) {
             wav->peak_output[wav->peak_outbuf_bytes++] =
@@ -378,11 +378,11 @@ static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
         int i;
         for (i = 0; i < pkt->size; i += wav->peak_bps) {
             if (wav->peak_bps == 1) {
-                wav->peak_maxpos[c] = FFMAX(wav->peak_maxpos[c], *(int8_t*)(pkt->data + i));
-                wav->peak_maxneg[c] = FFMIN(wav->peak_maxneg[c], *(int8_t*)(pkt->data + i));
+                wav->peak_maxpos[c] = FFMAXI(wav->peak_maxpos[c], *(int8_t*)(pkt->data + i));
+                wav->peak_maxneg[c] = FFMINI(wav->peak_maxneg[c], *(int8_t*)(pkt->data + i));
             } else {
-                wav->peak_maxpos[c] = FFMAX(wav->peak_maxpos[c], (int16_t)AV_RL16(pkt->data + i));
-                wav->peak_maxneg[c] = FFMIN(wav->peak_maxneg[c], (int16_t)AV_RL16(pkt->data + i));
+                wav->peak_maxpos[c] = FFMAXI(wav->peak_maxpos[c], (int16_t)AV_RL16(pkt->data + i));
+                wav->peak_maxneg[c] = FFMINI(wav->peak_maxneg[c], (int16_t)AV_RL16(pkt->data + i));
             }
             if (++c == s->streams[0]->codecpar->ch_layout.nb_channels) {
                 c = 0;
@@ -397,8 +397,8 @@ static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     if(pkt->pts != AV_NOPTS_VALUE) {
-        wav->minpts        = FFMIN(wav->minpts, pkt->pts);
-        wav->maxpts        = FFMAX(wav->maxpts, pkt->pts);
+        wav->minpts        = FFMINI(wav->minpts, pkt->pts);
+        wav->maxpts        = FFMAXI(wav->maxpts, pkt->pts);
         wav->last_duration = pkt->duration;
     } else
         av_log(s, AV_LOG_ERROR, "wav_write_packet: NOPTS\n");
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 9d26e35e222..d9542faaa4f 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -82,10 +82,10 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size)
     if (wf->position >= wf->length || avio_feof(pb))
         return AVERROR_EOF;
 
-    buf_size = FFMIN(buf_size, wf->length - wf->position);
+    buf_size = FFMINI(buf_size, wf->length - wf->position);
     while(nread < buf_size) {
         int remaining_in_sector = (1 << wf->sector_bits) - (wf->position & ((1 << wf->sector_bits) - 1));
-        int read_request        = FFMIN(buf_size - nread, remaining_in_sector);
+        int read_request        = FFMINI(buf_size - nread, remaining_in_sector);
 
         n = avio_read(pb, buf, read_request);
         if (n <= 0)
@@ -473,7 +473,7 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
     if (type == 0 && length == 4) {
         snprintf(buf, sizeof(buf), "%u", avio_rl32(pb));
     } else if (type == 1) {
-        int buflen = FFMIN(length + length / 2U + 1, INT_MAX);
+        int buflen = FFMINI(length + length / 2U + 1, INT_MAX);
         bufp = av_malloc(buflen);
         if (!bufp)
             return;
@@ -685,11 +685,11 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
             return NULL;
         if (!ff_guidcmp(formattype, ff_format_videoinfo2)) {
             int consumed = parse_videoinfoheader2(s, st);
-            avio_skip(pb, FFMAX(size - consumed, 0));
+            avio_skip(pb, FFMAXI(size - consumed, 0));
         } else if (!ff_guidcmp(formattype, ff_format_mpeg2_video)) {
             uint64_t consumed = parse_videoinfoheader2(s, st);
             /* ignore extradata; files produced by windows media center contain meaningless mpeg1 sequence header */
-            avio_skip(pb, FFMAX(size - consumed, 0));
+            avio_skip(pb, FFMAXI(size - consumed, 0));
         } else {
             if (ff_guidcmp(formattype, ff_format_none))
                 av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
@@ -847,7 +847,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
                     consumed += 6;
                 }
 
-                buf_size = FFMIN(len - consumed, sizeof(buf));
+                buf_size = FFMINI(len - consumed, sizeof(buf));
                 ret = ffio_read_size(pb, buf, buf_size);
                 if (ret < 0)
                     return ret;
diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index ed59f7b85bd..73f789b3665 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -452,7 +452,7 @@ static int xmv_fetch_audio_packet(AVFormatContext *s,
 
     if ((xmv->video.current_frame + 1) < xmv->video.frame_count)
         /* Not the last frame, get at most frame_size bytes. */
-        data_size = FFMIN(audio->frame_size, audio->data_size);
+        data_size = FFMINI(audio->frame_size, audio->data_size);
     else
         /* Last frame, get the rest. */
         data_size = audio->data_size;
diff --git a/libavformat/xwma.c b/libavformat/xwma.c
index b77c6ed6055..fa664937868 100644
--- a/libavformat/xwma.c
+++ b/libavformat/xwma.c
@@ -305,7 +305,7 @@ static int xwma_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     /* read a single block; the default block size is 2230. */
     size = (st->codecpar->block_align > 1) ? st->codecpar->block_align : 2230;
-    size = FFMIN(size, left);
+    size = FFMINI(size, left);
 
     ret  = av_get_packet(s->pb, pkt, size);
     if (ret < 0)
diff --git a/libavformat/yop.c b/libavformat/yop.c
index fd11acafc1b..887e21d4acd 100644
--- a/libavformat/yop.c
+++ b/libavformat/yop.c
@@ -191,7 +191,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index,
     pos_max        = avio_size(s->pb) - yop->frame_size;
     frame_count    = (pos_max - pos_min) / yop->frame_size;
 
-    timestamp      = FFMAX(0, FFMIN(frame_count, timestamp));
+    timestamp      = FFMAXI(0, FFMINI(frame_count, timestamp));
 
     frame_pos      = timestamp * yop->frame_size + pos_min;
 
diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index 2b66a1e5969..7324a8d6fc1 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -305,7 +305,7 @@ static int yuv4_read_seek(AVFormatContext *s, int stream_index,
     int64_t pos;
 
     if (flags & AVSEEK_FLAG_BACKWARD)
-        pts = FFMAX(0, pts - 1);
+        pts = FFMAXI(0, pts - 1);
     if (pts < 0)
         return -1;
     pos = pts * s->packet_size;
diff --git a/libavutil/adler32.c b/libavutil/adler32.c
index 7124f188029..c01346d5c25 100644
--- a/libavutil/adler32.c
+++ b/libavutil/adler32.c
@@ -48,7 +48,7 @@ AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len)
 
     while (len > 0) {
 #if HAVE_FAST_64BIT && HAVE_FAST_UNALIGNED && !CONFIG_SMALL
-        unsigned len2 = FFMIN((len-1) & ~7, 23*8);
+        unsigned len2 = FFMINI((len-1) & ~7, 23*8);
         if (len2) {
             uint64_t a1= 0;
             uint64_t a2= 0;
diff --git a/libavutil/audio_fifo.c b/libavutil/audio_fifo.c
index dc2dea9b2dc..c57e9a43bf1 100644
--- a/libavutil/audio_fifo.c
+++ b/libavutil/audio_fifo.c
@@ -156,7 +156,7 @@ int av_audio_fifo_peek_at(const AVAudioFifo *af, void * const *data,
         return AVERROR(EINVAL);
     if (nb_samples < 0)
         return AVERROR(EINVAL);
-    nb_samples = FFMIN(nb_samples, af->nb_samples);
+    nb_samples = FFMINI(nb_samples, af->nb_samples);
     if (!nb_samples)
         return 0;
     if (offset > af->nb_samples - nb_samples)
@@ -178,7 +178,7 @@ int av_audio_fifo_read(AVAudioFifo *af, void * const *data, int nb_samples)
 
     if (nb_samples < 0)
         return AVERROR(EINVAL);
-    nb_samples = FFMIN(nb_samples, af->nb_samples);
+    nb_samples = FFMINI(nb_samples, af->nb_samples);
     if (!nb_samples)
         return 0;
 
@@ -198,7 +198,7 @@ int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
 
     if (nb_samples < 0)
         return AVERROR(EINVAL);
-    nb_samples = FFMIN(nb_samples, af->nb_samples);
+    nb_samples = FFMINI(nb_samples, af->nb_samples);
 
     if (nb_samples) {
         size = nb_samples * af->sample_size;
diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 875eb691db6..526e1e2897b 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -357,8 +357,8 @@ int av_match_name(const char *name, const char *names)
         if (!p)
             p = names + strlen(names);
         names += negate;
-        len = FFMAX(p - names, namelen);
-        if (!av_strncasecmp(name, names, len) || !strncmp("ALL", names, FFMAX(3, p - names)))
+        len = FFMAXI(p - names, namelen);
+        if (!av_strncasecmp(name, names, len) || !strncmp("ALL", names, FFMAXI(3, p - names)))
             return !negate;
         names = p + (*p == ',');
     }
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index 4e9571715c1..d6d13f80267 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -30,7 +30,7 @@
 #include "macros.h"
 #include "mem.h"
 
-#define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size))
+#define av_bprint_room(buf) ((buf)->size - FFMINI((buf)->len, (buf)->size))
 #define av_bprint_is_allocated(buf) ((buf)->str != (buf)->reserved_internal_buffer)
 
 static int av_bprint_alloc(AVBPrint *buf, unsigned room)
@@ -42,10 +42,10 @@ static int av_bprint_alloc(AVBPrint *buf, unsigned room)
         return AVERROR(EIO);
     if (!av_bprint_is_complete(buf))
         return AVERROR_INVALIDDATA; /* it is already truncated anyway */
-    min_size = buf->len + 1 + FFMIN(UINT_MAX - buf->len - 1, room);
+    min_size = buf->len + 1 + FFMINI(UINT_MAX - buf->len - 1, room);
     new_size = buf->size > buf->size_max / 2 ? buf->size_max : buf->size * 2;
     if (new_size < min_size)
-        new_size = FFMIN(buf->size_max, min_size);
+        new_size = FFMINI(buf->size_max, min_size);
     old_str = av_bprint_is_allocated(buf) ? buf->str : NULL;
     new_str = av_realloc(old_str, new_size);
     if (!new_str)
@@ -60,10 +60,10 @@ static int av_bprint_alloc(AVBPrint *buf, unsigned room)
 static void av_bprint_grow(AVBPrint *buf, unsigned extra_len)
 {
     /* arbitrary margin to avoid small overflows */
-    extra_len = FFMIN(extra_len, UINT_MAX - 5 - buf->len);
+    extra_len = FFMINI(extra_len, UINT_MAX - 5 - buf->len);
     buf->len += extra_len;
     if (buf->size)
-        buf->str[FFMIN(buf->len, buf->size - 1)] = 0;
+        buf->str[FFMINI(buf->len, buf->size - 1)] = 0;
 }
 
 void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
@@ -75,7 +75,7 @@ void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
         size_max = size_auto;
     buf->str      = buf->reserved_internal_buffer;
     buf->len      = 0;
-    buf->size     = FFMIN(size_auto, size_max);
+    buf->size     = FFMINI(size_auto, size_max);
     buf->size_max = size_max;
     *buf->str = 0;
     if (size_init > buf->size)
@@ -154,7 +154,7 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
             break;
     }
     if (room) {
-        real_n = FFMIN(n, room - 1);
+        real_n = FFMINI(n, room - 1);
         memset(buf->str + buf->len, c, real_n);
     }
     av_bprint_grow(buf, n);
@@ -172,7 +172,7 @@ void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
             break;
     }
     if (room) {
-        real_n = FFMIN(size, room - 1);
+        real_n = FFMINI(size, room - 1);
         memcpy(buf->str + buf->len, data, real_n);
     }
     av_bprint_grow(buf, size);
@@ -211,7 +211,7 @@ void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
                    truncated, let us add a stock string and force truncation */
                 static const char txt[] = "[truncated strftime output]";
                 memset(buf->str + buf->len, '!', room);
-                memcpy(buf->str + buf->len, txt, FFMIN(sizeof(txt) - 1, room));
+                memcpy(buf->str + buf->len, txt, FFMINI(sizeof(txt) - 1, room));
                 av_bprint_grow(buf, room); /* force truncation */
             }
             return;
@@ -239,7 +239,7 @@ void av_bprint_clear(AVBPrint *buf)
 
 int av_bprint_finalize(AVBPrint *buf, char **ret_str)
 {
-    unsigned real_size = FFMIN(buf->len + 1, buf->size);
+    unsigned real_size = FFMINI(buf->len + 1, buf->size);
     char *str;
     int ret = 0;
 
diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index a8101d83f01..c2b90feea89 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -215,7 +215,7 @@ int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
         if (ret < 0)
             return ret;
 
-        memcpy(new->data, buf->data, FFMIN(size, buf->size));
+        memcpy(new->data, buf->data, FFMINI(size, buf->size));
 
         buffer_replace(pbuf, &new);
         return 0;
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index cfa8e05d56f..dfda1889b77 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -756,7 +756,7 @@ int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout,
         if (chname) {
             char buf[16];
             chname++;
-            av_strlcpy(buf, str, FFMIN(sizeof(buf), chname - str));
+            av_strlcpy(buf, str, FFMINI(sizeof(buf), chname - str));
             if (!*chname)
                 chname = NULL;
             ch = av_channel_from_string(buf);
diff --git a/libavutil/common.h b/libavutil/common.h
index 3b830daf308..f70acaf4cc3 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -409,7 +409,7 @@ static av_always_inline av_const float av_clipf_c(float a, float amin, float ama
 #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
     if (amin > amax) abort();
 #endif
-    return FFMIN(FFMAX(a, amin), amax);
+    return FFMINF(FFMAXF(a, amin), amax);
 }
 
 /**
@@ -426,7 +426,7 @@ static av_always_inline av_const double av_clipd_c(double a, double amin, double
 #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
     if (amin > amax) abort();
 #endif
-    return FFMIN(FFMAX(a, amin), amax);
+    return FFMIND(FFMAXD(a, amin), amax);
 }
 
 /** Compute ceil(log2(x)).
diff --git a/libavutil/executor.c b/libavutil/executor.c
index bfce2ac444c..b31122c39c4 100644
--- a/libavutil/executor.c
+++ b/libavutil/executor.c
@@ -151,11 +151,11 @@ AVExecutor* av_executor_alloc(const AVTaskCallbacks *cb, int thread_count)
         return NULL;
     e->cb = *cb;
 
-    e->local_contexts = av_calloc(FFMAX(thread_count, 1), e->cb.local_context_size);
+    e->local_contexts = av_calloc(FFMAXI(thread_count, 1), e->cb.local_context_size);
     if (!e->local_contexts)
         goto free_executor;
 
-    e->threads = av_calloc(FFMAX(thread_count, 1), sizeof(*e->threads));
+    e->threads = av_calloc(FFMAXI(thread_count, 1), sizeof(*e->threads));
     if (!e->threads)
         goto free_executor;
 
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index 8806c668d7e..11571df9eb7 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -69,7 +69,7 @@ AVFifo *av_fifo_alloc2(size_t nb_elems, size_t elem_size,
     f->is_empty  = 1;
 
     f->flags           = flags;
-    f->auto_grow_limit = FFMAX(AUTO_GROW_DEFAULT_BYTES / elem_size, 1);
+    f->auto_grow_limit = FFMAXI(AUTO_GROW_DEFAULT_BYTES / elem_size, 1);
 
     return f;
 }
@@ -111,7 +111,7 @@ int av_fifo_grow2(AVFifo *f, size_t inc)
     // move the data from the beginning of the ring buffer
     // to the newly allocated space
     if (f->offset_w <= f->offset_r && !f->is_empty) {
-        const size_t copy = FFMIN(inc, f->offset_w);
+        const size_t copy = FFMINI(inc, f->offset_w);
         memcpy(tmp + f->nb_elems * f->elem_size, tmp, copy * f->elem_size);
         if (copy < f->offset_w) {
             memmove(tmp, tmp + copy * f->elem_size,
@@ -160,7 +160,7 @@ static int fifo_write_common(AVFifo *f, const uint8_t *buf, size_t *nb_elems,
     offset_w = f->offset_w;
 
     while (to_write > 0) {
-        size_t    len = FFMIN(f->nb_elems - offset_w, to_write);
+        size_t    len = FFMINI(f->nb_elems - offset_w, to_write);
         uint8_t *wptr = f->buffer + offset_w * f->elem_size;
 
         if (read_cb) {
@@ -215,7 +215,7 @@ static int fifo_peek_common(const AVFifo *f, uint8_t *buf, size_t *nb_elems,
         offset_r += offset;
 
     while (to_read > 0) {
-        size_t    len = FFMIN(f->nb_elems - offset_r, to_read);
+        size_t    len = FFMINI(f->nb_elems - offset_r, to_read);
         uint8_t *rptr = f->buffer + offset_r * f->elem_size;
 
         if (write_cb) {
diff --git a/libavutil/frame.c b/libavutil/frame.c
index dcfc835626c..91aabb3a300 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -180,7 +180,7 @@ static int get_audio_buffer(AVFrame *frame, int align)
         return AVERROR(EINVAL);
     size = frame->linesize[0] + (size_t)align;
 
-    for (int i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) {
+    for (int i = 0; i < FFMINI(planes, AV_NUM_DATA_POINTERS); i++) {
         frame->buf[i] = av_buffer_alloc(size);
         if (!frame->buf[i]) {
             av_frame_unref(frame);
@@ -416,7 +416,7 @@ int av_frame_replace(AVFrame *dst, const AVFrame *src)
 
     if (src->extended_buf) {
         if (dst->nb_extended_buf != src->nb_extended_buf) {
-            int nb_extended_buf = FFMIN(dst->nb_extended_buf, src->nb_extended_buf);
+            int nb_extended_buf = FFMINI(dst->nb_extended_buf, src->nb_extended_buf);
             void *tmp;
 
             for (int i = nb_extended_buf; i < dst->nb_extended_buf; i++)
@@ -802,7 +802,7 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
 
         for (int i = 0; frame->data[i]; i++) {
             int log2_align = offsets[i] ? ff_ctz(offsets[i]) : INT_MAX;
-            min_log2_align = FFMIN(log2_align, min_log2_align);
+            min_log2_align = FFMINI(log2_align, min_log2_align);
         }
 
         /* we assume, and it should always be true, that the data alignment is
diff --git a/libavutil/hwcontext_amf.c b/libavutil/hwcontext_amf.c
index 24731c20ecb..04fb5882808 100644
--- a/libavutil/hwcontext_amf.c
+++ b/libavutil/hwcontext_amf.c
@@ -274,8 +274,8 @@ static int amf_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
     int       planes;
     int       i;
     int       res;
-    int w = FFMIN(dst->width,  src->width);
-    int h = FFMIN(dst->height, src->height);
+    int w = FFMINI(dst->width,  src->width);
+    int h = FFMINI(dst->height, src->height);
 
     if (dst->hw_frames_ctx->data != (uint8_t *)ctx || src->format != ctx->sw_format)
         return AVERROR(EINVAL);
@@ -318,8 +318,8 @@ static int amf_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
     int       src_linesize[4];
     int       planes;
     int       i;
-    int w = FFMIN(dst->width,  src->width);
-    int h = FFMIN(dst->height, src->height);
+    int w = FFMINI(dst->width,  src->width);
+    int h = FFMINI(dst->height, src->height);
     int ret;
 
     if (src->hw_frames_ctx->data != (uint8_t *)ctx || dst->format != ctx->sw_format)
diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 1a047ce57b4..7ee7020274b 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -429,8 +429,8 @@ static int d3d11va_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
     ID3D11Resource *texture = (ID3D11Resource *)(ID3D11Texture2D *)frame->data[0];
     int index = (intptr_t)frame->data[1];
     ID3D11Resource *staging;
-    int w = FFMIN(dst->width,  src->width);
-    int h = FFMIN(dst->height, src->height);
+    int w = FFMINI(dst->width,  src->width);
+    int h = FFMINI(dst->height, src->height);
     uint8_t *map_data[4];
     int map_linesize[4];
     D3D11_TEXTURE2D_DESC desc;
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 721c841c2ae..edb54e5cb9a 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -252,7 +252,7 @@ static int qsv_fill_border(AVFrame *dst, const AVFrame *src)
     desc = av_pix_fmt_desc_get(dst->format);
 
     for (i = 0; i < desc->nb_components; i++)
-        planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
+        planes_nb = FFMAXI(planes_nb, desc->comp[i].plane + 1);
 
     for (i = 0; i < planes_nb; i++) {
         int sheight, dheight, y;
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index ce485a85a21..6b70711454f 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -3894,7 +3894,7 @@ static int vulkan_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst,
             goto end;
         }
 
-        drm_desc->layers[i].planes[0].object_index = FFMIN(i, drm_desc->nb_objects - 1);
+        drm_desc->layers[i].planes[0].object_index = FFMINI(i, drm_desc->nb_objects - 1);
 
         if (f->tiling == VK_IMAGE_TILING_OPTIMAL)
             continue;
@@ -4243,8 +4243,8 @@ static int vulkan_transfer_frame(AVHWFramesContext *hwfc,
     });
 
     for (int i = 0; i < planes; i++) {
-        int buf_idx = FFMIN(i, (nb_bufs - 1));
-        int img_idx = FFMIN(i, (nb_images - 1));
+        int buf_idx = FFMINI(i, (nb_bufs - 1));
+        int img_idx = FFMINI(i, (nb_images - 1));
         FFVkBuffer *vkbuf = (FFVkBuffer *)bufs[buf_idx]->data;
 
         uint32_t orig_stride = region[i].bufferRowLength;
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 7b88738e2dc..9814e9ca119 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -400,7 +400,7 @@ static void image_copy(uint8_t *const dst_data[4], const ptrdiff_t dst_linesizes
         int i, planes_nb = 0;
 
         for (i = 0; i < desc->nb_components; i++)
-            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
+            planes_nb = FFMAXI(planes_nb, desc->comp[i].plane + 1);
 
         for (i = 0; i < planes_nb; i++) {
             int h = height;
@@ -513,7 +513,7 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
         return AVERROR(EINVAL);
 
     for (i = 0; i < desc->nb_components; i++)
-        nb_planes = FFMAX(desc->comp[i].plane, nb_planes);
+        nb_planes = FFMAXI(desc->comp[i].plane, nb_planes);
 
     nb_planes++;
 
@@ -603,7 +603,7 @@ int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
 
         // We try to operate on entire non-subsampled pixel groups (for
         // AV_PIX_FMT_UYVY422 this would mean two consecutive pixels).
-        clear_block_size[comp.plane] = FFMAX(clear_block_size[comp.plane], comp.step);
+        clear_block_size[comp.plane] = FFMAXI(clear_block_size[comp.plane], comp.step);
 
         if (clear_block_size[comp.plane] > MAX_BLOCK_SIZE)
             return AVERROR(EINVAL);
diff --git a/libavutil/lzo.c b/libavutil/lzo.c
index bcbe2c861d7..96c723d6c90 100644
--- a/libavutil/lzo.c
+++ b/libavutil/lzo.c
@@ -90,11 +90,11 @@ static inline void copy(LZOContext *c, int cnt)
     register uint8_t *dst       = c->out;
     av_assert0(cnt >= 0);
     if (cnt > c->in_end - src) {
-        cnt       = FFMAX(c->in_end - src, 0);
+        cnt       = FFMAXI(c->in_end - src, 0);
         c->error |= AV_LZO_INPUT_DEPLETED;
     }
     if (cnt > c->out_end - dst) {
-        cnt       = FFMAX(c->out_end - dst, 0);
+        cnt       = FFMAXI(c->out_end - dst, 0);
         c->error |= AV_LZO_OUTPUT_FULL;
     }
 #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
@@ -126,7 +126,7 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt)
         return;
     }
     if (cnt > c->out_end - dst) {
-        cnt       = FFMAX(c->out_end - dst, 0);
+        cnt       = FFMAXI(c->out_end - dst, 0);
         c->error |= AV_LZO_OUTPUT_FULL;
     }
     av_memcpy_backptr(dst, back, cnt);
diff --git a/libavutil/macros.h b/libavutil/macros.h
index 2a7567c3ea8..141180b3eb4 100644
--- a/libavutil/macros.h
+++ b/libavutil/macros.h
@@ -45,8 +45,14 @@
 #define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y)))
 
 #define FFMAX(a,b) ((a) > (b) ? (a) : (b))
+#define FFMAXI(a,b) ((a) > (b) ? (a) : (b))
+#define FFMAXF(a,b) ((a) > (b) ? (a) : (b))
+#define FFMAXD(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 FFMINI(a,b) ((a) > (b) ? (b) : (a))
+#define FFMINF(a,b) ((a) > (b) ? (b) : (a))
+#define FFMIND(a,b) ((a) > (b) ? (b) : (a))
 #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
 
 #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 61aeb7c0292..c09cb97b52d 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -43,7 +43,7 @@ int64_t av_gcd(int64_t a, int64_t b) {
         return a;
     za = ff_ctzll(a);
     zb = ff_ctzll(b);
-    k  = FFMIN(za, zb);
+    k  = FFMINI(za, zb);
     u = llabs(a >> za);
     v = llabs(b >> zb);
     while (u != v) {
@@ -72,7 +72,7 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
     }
 
     if (a < 0)
-        return -(uint64_t)av_rescale_rnd(-FFMAX(a, -INT64_MAX), b, c, rnd ^ ((rnd >> 1) & 1));
+        return -(uint64_t)av_rescale_rnd(-FFMAXI(a, -INT64_MAX), b, c, rnd ^ ((rnd >> 1) & 1));
 
     if (rnd == AV_ROUND_NEAR_INF)
         r = c / 2;
diff --git a/libavutil/md5.c b/libavutil/md5.c
index c01820da2df..c63f5dae9f9 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -159,7 +159,7 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
     ctx->len += len;
 
     if (j) {
-        int cnt = FFMIN(len, 64 - j);
+        int cnt = FFMINI(len, 64 - j);
         memcpy(ctx->block + j, src, cnt);
         src += cnt;
         len -= cnt;
diff --git a/libavutil/mem.c b/libavutil/mem.c
index b205d3fb256..b2e97d109c2 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -503,14 +503,14 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
 
     max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
     /* *size is an unsigned, so the real maximum is <= UINT_MAX. */
-    max_size = FFMIN(max_size, UINT_MAX);
+    max_size = FFMINI(max_size, UINT_MAX);
 
     if (min_size > max_size) {
         *size = 0;
         return NULL;
     }
 
-    min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size));
+    min_size = FFMINI(max_size, FFMAXI(min_size + min_size / 16 + 32, min_size));
 
     ptr = av_realloc(ptr, min_size);
     /* we could set this to the unmodified min_size but this is safer
@@ -537,14 +537,14 @@ static inline void fast_malloc(void *ptr, unsigned int *size, size_t min_size, i
 
     max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
     /* *size is an unsigned, so the real maximum is <= UINT_MAX. */
-    max_size = FFMIN(max_size, UINT_MAX);
+    max_size = FFMINI(max_size, UINT_MAX);
 
     if (min_size > max_size) {
         av_freep(ptr);
         *size = 0;
         return;
     }
-    min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size));
+    min_size = FFMINI(max_size, FFMAXI(min_size + min_size / 16 + 32, min_size));
     av_freep(ptr);
     val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
     memcpy(ptr, &val, sizeof(val));
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 9f57b16ec27..ff4cc879889 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -371,7 +371,7 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
     if (slen < 0)
         slen = strlen(color_string);
     av_strlcpy(color_string2, color_string + hex_offset,
-               FFMIN(slen-hex_offset+1, sizeof(color_string2)));
+               FFMINI(slen-hex_offset+1, sizeof(color_string2)));
     if ((tail = strchr(color_string2, ALPHA_SEP)))
         *tail++ = 0;
     len = strlen(color_string2);
diff --git a/libavutil/pca.c b/libavutil/pca.c
index 7c3eb42b146..4ee1992fcf1 100644
--- a/libavutil/pca.c
+++ b/libavutil/pca.c
@@ -157,7 +157,7 @@ int ff_pca(PCA *pca, double *eigenvector, double *eigenvalue){
     a[l + k*n]=h+s*(g-h*tau); }
                 for(k=0; k<n; k++) {
                     if(k!=i && k!=j){
-                        ROTATE(pca->covariance,FFMIN(k,i),FFMAX(k,i),FFMIN(k,j),FFMAX(k,j))
+                        ROTATE(pca->covariance,FFMINI(k,i),FFMAXI(k,i),FFMINI(k,j),FFMAXI(k,j))
                     }
                     ROTATE(eigenvector,k,i,k,j)
                 }
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 53adde5abac..051a38d06b0 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -3458,8 +3458,8 @@ static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt)
 
     *min = INT_MAX, *max = -INT_MAX;
     for (i = 0; i < desc->nb_components; i++) {
-        *min = FFMIN(desc->comp[i].depth, *min);
-        *max = FFMAX(desc->comp[i].depth, *max);
+        *min = FFMINI(desc->comp[i].depth, *min);
+        *max = FFMAXI(desc->comp[i].depth, *max);
     }
     return 0;
 }
@@ -3500,9 +3500,9 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
     src_color = get_color_type(src_desc);
     dst_color = get_color_type(dst_desc);
     if (dst_pix_fmt == AV_PIX_FMT_PAL8)
-        nb_components = FFMIN(src_desc->nb_components, 4);
+        nb_components = FFMINI(src_desc->nb_components, 4);
     else
-        nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
+        nb_components = FFMINI(src_desc->nb_components, dst_desc->nb_components);
 
     for (i = 0; i < nb_components; i++) {
         int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : (dst_desc->comp[i].depth - 1);
@@ -3585,7 +3585,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
         break;
     }
     if(loss & FF_LOSS_COLORSPACE)
-        score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth - 1, src_desc->comp[0].depth - 1);
+        score -= (nb_components * 65536) >> FFMINI(dst_desc->comp[0].depth - 1, src_desc->comp[0].depth - 1);
 
     if (dst_color == FF_COLOR_GRAY &&
         src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) {
diff --git a/libavutil/rational.c b/libavutil/rational.c
index 1b7c6350e99..1c853591f44 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -56,7 +56,7 @@ int av_reduce(int *dst_num, int *dst_den,
 
         if (a2n > max || a2d > max) {
             if (a1.num) x =          (max - a0.num) / a1.num;
-            if (a1.den) x = FFMIN(x, (max - a0.den) / a1.den);
+            if (a1.den) x = FFMINI(x, (max - a0.den) / a1.den);
 
             if (den * (2 * x * a1.den + a0.den) > num * a1.den)
                 a1 = (AVRational) { x * a1.num + a0.num, x * a1.den + a0.den };
@@ -113,7 +113,7 @@ AVRational av_d2q(double d, int max)
     if (fabs(d) > INT_MAX + 3LL)
         return (AVRational) { d < 0 ? -1 : 1, 0 };
     frexp(d, &exponent);
-    exponent = FFMAX(exponent-1, 0);
+    exponent = FFMAXI(exponent-1, 0);
     den = 1LL << (62 - exponent);
     // (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64,
     // see Ticket2713 for affected gcc/glibc versions
diff --git a/libavutil/refstruct.c b/libavutil/refstruct.c
index 7a5eb248266..9c30e1d5674 100644
--- a/libavutil/refstruct.c
+++ b/libavutil/refstruct.c
@@ -46,7 +46,7 @@
                                MKTAG('R', 'e', 'f', 'S') | (uint64_t)MKTAG('t', 'r', 'u', 'c') << 32)
 
 #ifndef _MSC_VER
-#define REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), FFMAX(ALIGN_64, _Alignof(max_align_t)))
+#define REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), FFMAXI(ALIGN_64, _Alignof(max_align_t)))
 #else
 #define REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), ALIGN_64)
 #endif
diff --git a/libavutil/side_data.c b/libavutil/side_data.c
index 17965f2d3c6..18a734666d9 100644
--- a/libavutil/side_data.c
+++ b/libavutil/side_data.c
@@ -146,7 +146,7 @@ static AVFrameSideData *add_side_data_from_buf_ext(AVFrameSideData ***sd,
     AVFrameSideData *ret, **tmp;
 
     // *nb_sd + 1 needs to fit into an int and a size_t.
-    if ((unsigned)*nb_sd >= FFMIN(INT_MAX, SIZE_MAX))
+    if ((unsigned)*nb_sd >= FFMINI(INT_MAX, SIZE_MAX))
         return NULL;
 
     tmp = av_realloc_array(*sd, sizeof(**sd), *nb_sd + 1);
diff --git a/libavutil/slicethread.c b/libavutil/slicethread.c
index 7650fc66ad7..3702416f91e 100644
--- a/libavutil/slicethread.c
+++ b/libavutil/slicethread.c
@@ -109,7 +109,7 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv,
     if (!nb_threads) {
         int nb_cpus = av_cpu_count();
         if (nb_cpus > 1)
-            nb_threads = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
+            nb_threads = FFMINI(nb_cpus + 1, MAX_AUTO_THREADS);
         else
             nb_threads = 1;
     }
@@ -194,7 +194,7 @@ void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_mai
 
     av_assert0(nb_jobs > 0);
     ctx->nb_jobs           = nb_jobs;
-    ctx->nb_active_threads = FFMIN(nb_jobs, ctx->nb_threads);
+    ctx->nb_active_threads = FFMINI(nb_jobs, ctx->nb_threads);
     atomic_store_explicit(&ctx->first_job, 0, memory_order_relaxed);
     atomic_store_explicit(&ctx->current_job, ctx->nb_active_threads, memory_order_relaxed);
     nb_workers             = ctx->nb_active_threads;
diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c
index c9d6bfc7db5..a15bc8fed68 100644
--- a/libavutil/tests/audio_fifo.c
+++ b/libavutil/tests/audio_fifo.c
@@ -84,7 +84,7 @@ static void print_audio_bytes(const TestStruct *test_sample, void **data_planes,
 static int read_samples_from_audio_fifo(AVAudioFifo* afifo, void ***output, int nb_samples)
 {
     int i;
-    int samples        = FFMIN(nb_samples, afifo->nb_samples);
+    int samples        = FFMINI(nb_samples, afifo->nb_samples);
     int tot_elements   = !av_sample_fmt_is_planar(afifo->sample_fmt)
                          ? samples : afifo->channels * samples;
     void **data_planes = av_malloc_array(afifo->nb_buffers, sizeof(void*));
diff --git a/libavutil/tests/fifo.c b/libavutil/tests/fifo.c
index 8cbc44c4399..21cd497bdff 100644
--- a/libavutil/tests/fifo.c
+++ b/libavutil/tests/fifo.c
@@ -35,7 +35,7 @@ static int read_cb(void *opaque, void *buf, size_t *nb_elems)
     CBState  *s = opaque;
     unsigned *b = buf;
 
-    *nb_elems = FFMIN(*nb_elems, s->to_process);
+    *nb_elems = FFMINI(*nb_elems, s->to_process);
 
     for (unsigned i = 0; i < *nb_elems; i++)
         if (b[i] != s->read_idx + s->offset + i) {
@@ -55,7 +55,7 @@ static int write_cb(void *opaque, void *buf, size_t *nb_elems)
     CBState  *s = opaque;
     unsigned *b = buf;
 
-    *nb_elems = FFMIN(*nb_elems, s->to_process);
+    *nb_elems = FFMINI(*nb_elems, s->to_process);
 
     for (unsigned i = 0; i < *nb_elems; i++)
         b[i] = s->write_idx + i;
diff --git a/libavutil/tests/pca.c b/libavutil/tests/pca.c
index 2d9eb8f56ab..6410c0c03ab 100644
--- a/libavutil/tests/pca.c
+++ b/libavutil/tests/pca.c
@@ -82,7 +82,7 @@ int main(void){
         memset(v, 0, sizeof(v));
         for(j=0; j<LEN; j++){
             for(k=0; k<LEN; k++){
-                v[j] += pca->covariance[FFMIN(k,j) + FFMAX(k,j)*LEN] * eigenvector[i + k*LEN];
+                v[j] += pca->covariance[FFMINI(k,j) + FFMAXI(k,j)*LEN] * eigenvector[i + k*LEN];
             }
             v[j] /= eigenvalue[i];
             error += fabs(v[j] - eigenvector[i + j*LEN]);
diff --git a/libavutil/tests/tree.c b/libavutil/tests/tree.c
index 5cd3e70de67..e94d9aba4e8 100644
--- a/libavutil/tests/tree.c
+++ b/libavutil/tests/tree.c
@@ -37,7 +37,7 @@ static int check(AVTreeNode *t)
             return 1000;
         if (t->state > 1 || t->state < -1)
             return 1000;
-        return FFMAX(left, right) + 1;
+        return FFMAXI(left, right) + 1;
     }
     return 0;
 }
diff --git a/libavutil/timestamp.c b/libavutil/timestamp.c
index 6c231a517d3..9217de5dddf 100644
--- a/libavutil/timestamp.c
+++ b/libavutil/timestamp.c
@@ -27,7 +27,7 @@ char *av_ts_make_time_string2(char *buf, int64_t ts, AVRational tb)
         double log = (fpclassify(val) == FP_ZERO ? -INFINITY : floor(log10(fabs(val))));
         int precision = (isfinite(log) && log < 0) ? -log + 5 : 6;
         int last = snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.*f", precision, val);
-        last = FFMIN(last, AV_TS_MAX_STRING_SIZE - 1) - 1;
+        last = FFMINI(last, AV_TS_MAX_STRING_SIZE - 1) - 1;
         for (; last && buf[last] == '0'; last--);
         for (; last && buf[last] != 'f' && (buf[last] < '0' || buf[0] > '9'); last--);
         buf[last + 1] = '\0';
diff --git a/libavutil/tx.c b/libavutil/tx.c
index 0aae4c7cf71..fdec39a85df 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -206,7 +206,7 @@ static void parity_revtab_generator(int *revtab, int n, int inv, int offset,
 
         is_dual = is_dual && dual_stride;
         dual_high = is_dual & dual_high;
-        stride = is_dual ? FFMIN(dual_stride, len) : 0;
+        stride = is_dual ? FFMINI(dual_stride, len) : 0;
 
         even_idx = offset + dual_high*(stride - 2*len);
         odd_idx  = even_idx + len + (is_dual && !dual_high)*len + dual_high*len;
@@ -390,7 +390,7 @@ static int get_codelet_prio(const FFTXCodelet *cd, int cpu_flags, int len)
 
     /* Larger factors are generally better */
     for (int i = 0; i < TX_MAX_SUB; i++)
-        max_factor = FFMAX(cd->factors[i], max_factor);
+        max_factor = FFMAXI(cd->factors[i], max_factor);
     if (max_factor)
         prio += 16*max_factor;
 
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index a989e080abd..85229d941ae 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -1857,7 +1857,7 @@ int ff_vk_create_imageview(FFVulkanContext *s,
     VkImageViewCreateInfo view_create_info = {
         .sType      = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
         .pNext      = &view_usage_info,
-        .image      = vkf->img[FFMIN(plane, nb_images - 1)],
+        .image      = vkf->img[FFMINI(plane, nb_images - 1)],
         .viewType   = VK_IMAGE_VIEW_TYPE_2D,
         .format     = map_fmt_to_rep(rep_fmts[plane], rep_fmt),
         .components = ff_comp_identity_map,
@@ -1918,7 +1918,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e,
         VkImageViewCreateInfo view_create_info = {
             .sType      = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
             .pNext      = &view_usage_info,
-            .image      = vkf->img[FFMIN(i, nb_images - 1)],
+            .image      = vkf->img[FFMINI(i, nb_images - 1)],
             .viewType   = VK_IMAGE_VIEW_TYPE_2D,
             .format     = map_fmt_to_rep(rep_fmts[i], rep_fmt),
             .components = ff_comp_identity_map,
@@ -2259,7 +2259,7 @@ static int init_descriptors(FFVulkanContext *s, FFVulkanShader *shd)
         int has_singular = 0;
         int max_descriptors = 0;
         for (int i = 0; i < shd->nb_descriptor_sets; i++) {
-            max_descriptors = FFMAX(max_descriptors, shd->desc_set[i].nb_bindings);
+            max_descriptors = FFMAXI(max_descriptors, shd->desc_set[i].nb_bindings);
             if (shd->desc_set[i].singular)
                 has_singular = 1;
         }
@@ -2419,7 +2419,7 @@ int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd,
     for (int i = 0; i < nb; i++) {
         set->binding[i].binding            = i;
         set->binding[i].descriptorType     = desc[i].type;
-        set->binding[i].descriptorCount    = FFMAX(desc[i].elems, 1);
+        set->binding[i].descriptorCount    = FFMAXI(desc[i].elems, 1);
         set->binding[i].stageFlags         = desc[i].stages;
         set->binding[i].pImmutableSamplers = desc[i].samplers;
 
@@ -2452,7 +2452,7 @@ int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd,
                 memset(&desc_pool_size[j], 0, sizeof(VkDescriptorPoolSize));
             }
             shd->desc_pool_size[j].type             = desc[i].type;
-            shd->desc_pool_size[j].descriptorCount += FFMAX(desc[i].elems, 1);
+            shd->desc_pool_size[j].descriptorCount += FFMAXI(desc[i].elems, 1);
         }
     }
 
@@ -2464,7 +2464,7 @@ print:
     /* Write shader info */
     for (int i = 0; i < nb; i++) {
         const struct descriptor_props *prop = &descriptor_props[desc[i].type];
-        GLSLA("layout (set = %i, binding = %i", FFMAX(shd->nb_descriptor_sets - 1, 0), i);
+        GLSLA("layout (set = %i, binding = %i", FFMAXI(shd->nb_descriptor_sets - 1, 0), i);
 
         if (desc[i].mem_layout &&
             (desc[i].type != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE))
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 5929ae40982..674fd128874 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -328,7 +328,7 @@ static void build_matrix(const AVChannelLayout *in_ch_layout, const AVChannelLay
                  && av_channel_layout_index_from_channel(out_ch_layout, i) >= 0);
             sum += fabs(matrix_param[stride*out_i + in_i]);
         }
-        maxcoef= FFMAX(maxcoef, sum);
+        maxcoef= FFMAXD(maxcoef, sum);
     }
     if(rematrix_volume  < 0)
         maxcoef = -rematrix_volume;
@@ -490,7 +490,7 @@ av_cold int swri_rematrix_init(SwrContext *s){
                 rem += target - ((int*)s->native_matrix)[i * nb_in + j];
                 sum += FFABS(((int*)s->native_matrix)[i * nb_in + j]);
             }
-            maxsum = FFMAX(maxsum, sum);
+            maxsum = FFMAXI(maxsum, sum);
         }
         *((int*)s->native_one) = 32768;
         if (maxsum <= 32768) {
diff --git a/libswresample/resample.c b/libswresample/resample.c
index 2b8571bbd6c..e0c230e77ae 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -85,7 +85,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
                 break;
             case SWR_FILTER_TYPE_KAISER:
                 w = 2.0*x / (factor*tap_count*M_PI);
-                y *= av_bessel_i0(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));
+                y *= av_bessel_i0(kaiser_beta*sqrt(FFMAXD(1-w*w, 0)));
                 break;
             default:
                 av_assert0(0);
@@ -186,10 +186,10 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r
                                     double precision, int cheby, int exact_rational)
 {
     double cutoff = cutoff0? cutoff0 : 0.97;
-    double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
+    double factor= FFMIND(out_rate * cutoff / in_rate, 1.0);
     int phase_count= 1<<phase_shift;
     int phase_count_compensation = phase_count;
-    int filter_length = FFMAX((int)ceil(filter_size/factor), 1);
+    int filter_length = FFMAXI((int)ceil(filter_size/factor), 1);
 
     if (filter_length > 1)
         filter_length = FFALIGN(filter_length, 2);
@@ -351,8 +351,8 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A
     int64_t max_src_size = (INT64_MAX/2 / c->phase_count) / c->src_incr;
 
     if (c->compensation_distance)
-        dst_size = FFMIN(dst_size, c->compensation_distance);
-    src_size = FFMIN(src_size, max_src_size);
+        dst_size = FFMINI(dst_size, c->compensation_distance);
+    src_size = FFMINI(src_size, max_src_size);
 
     *consumed = 0;
 
@@ -361,7 +361,7 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A
         int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr + 1;
         int new_size = (src_size * (int64_t)c->src_incr - c->frac + c->dst_incr - 1) / c->dst_incr;
 
-        dst_size = FFMAX(FFMIN(dst_size, new_size), 0);
+        dst_size = FFMAXI(FFMINI(dst_size, new_size), 0);
         if (dst_size > 0) {
             for (i = 0; i < dst->ch_count; i++) {
                 c->dsp.resample_one(dst->ch[i], src->ch[i], dst_size, index2, incr);
@@ -382,7 +382,7 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A
         int (*resample_func)(struct ResampleContext *c, void *dst,
                              const void *src, int n, int update_ctx);
 
-        dst_size = FFMAX(FFMIN(dst_size, delta_n), 0);
+        dst_size = FFMAXI(FFMINI(dst_size, delta_n), 0);
         if (dst_size > 0) {
             /* resample_linear and resample_common should have same behavior
              * when frac and dst_incr_mod are zero */
@@ -429,7 +429,7 @@ static int64_t get_out_samples(struct SwrContext *s, int in_samples) {
         if (num > INT_MAX)
             return AVERROR(EINVAL);
 
-        num = FFMAX(num, (num * c->ideal_dst_incr - 1) / c->dst_incr + 1);
+        num = FFMAXI(num, (num * c->ideal_dst_incr - 1) / c->dst_incr + 1);
     }
     return num;
 }
@@ -438,7 +438,7 @@ static int resample_flush(struct SwrContext *s) {
     ResampleContext *c = s->resample;
     AudioData *a= &s->in_buffer;
     int i, j, ret;
-    int reflection = (FFMIN(s->in_buffer_count, c->filter_length) + 1) / 2;
+    int reflection = (FFMINI(s->in_buffer_count, c->filter_length) + 1) / 2;
 
     if((ret = swri_realloc_audio(a, s->in_buffer_index + s->in_buffer_count + reflection)) < 0)
         return ret;
@@ -457,7 +457,7 @@ static int resample_flush(struct SwrContext *s) {
 static int invert_initial_buffer(ResampleContext *c, AudioData *dst, const AudioData *src,
                                  int in_count, int *out_idx, int *out_sz)
 {
-    int n, ch, num = FFMIN(in_count + *out_sz, c->filter_length + 1), res;
+    int n, ch, num = FFMINI(in_count + *out_sz, c->filter_length + 1), res;
 
     if (c->index >= 0)
         return 0;
@@ -495,10 +495,10 @@ static int invert_initial_buffer(ResampleContext *c, AudioData *dst, const Audio
         --*out_idx;
         c->index += c->phase_count;
     }
-    *out_sz = FFMAX(*out_sz + c->filter_length,
+    *out_sz = FFMAXI(*out_sz + c->filter_length,
                     1 + c->filter_length * 2) - *out_idx;
 
-    return FFMAX(res, 0);
+    return FFMAXI(res, 0);
 }
 
 struct Resampler const swri_resampler={
diff --git a/libswresample/soxr_resample.c b/libswresample/soxr_resample.c
index 8181c749b86..eb0133457d0 100644
--- a/libswresample/soxr_resample.c
+++ b/libswresample/soxr_resample.c
@@ -50,7 +50,7 @@ static struct ResampleContext *create(struct ResampleContext *c, int out_rate, i
 #if !defined SOXR_VERSION /* Deprecated @ March 2013: */
     q_spec.bw_pc = cutoff? FFMAX(FFMIN(cutoff,.995),.8)*100 : q_spec.bw_pc;
 #else
-    q_spec.passband_end = cutoff? FFMAX(FFMIN(cutoff,.995),.8) : q_spec.passband_end;
+    q_spec.passband_end = cutoff? FFMAXD(FFMIND(cutoff,.995),.8) : q_spec.passband_end;
 #endif
 
     soxr_delete((soxr_t)c);
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 0a4e216f9b8..f19148d5298 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -537,7 +537,7 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count,
 
         if((s->flushed || in_count > padless) && !s->in_buffer_count){
             s->in_buffer_index=0;
-            ret= s->resampler->multiple_resample(s->resample, &out, out_count, &in, FFMAX(in_count-padless, 0), &consumed);
+            ret= s->resampler->multiple_resample(s->resample, &out, out_count, &in, FFMAXI(in_count-padless, 0), &consumed);
             out_count -= ret;
             ret_sum += ret;
             buf_set(&out, &out, ret);
@@ -630,7 +630,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
     if(s->int_sample_fmt == s->out_sample_fmt && s->out.planar
        && !(s->out_sample_fmt==AV_SAMPLE_FMT_S32P && (s->dither.output_sample_bits&31))){
         if(preout==in){
-            out_count= FFMIN(out_count, in_count); //TODO check at the end if this is needed or redundant
+            out_count= FFMINI(out_count, in_count); //TODO check at the end if this is needed or redundant
             av_assert0(s->in.planar); //we only support planar internally so it has to be, we support copying non planar though
             copy(out, in, out_count);
             return out_count;
@@ -662,7 +662,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
         AudioData *conv_src = preout;
         if(s->dither.method){
             int ch;
-            int dither_count= FFMAX(out_count, 1<<16);
+            int dither_count= FFMAXI(out_count, 1<<16);
 
             if (preout == in) {
                 conv_src = &s->dither.temp;
@@ -736,12 +736,12 @@ int attribute_align_arg swr_convert(struct SwrContext *s,
         int ret;
         uint8_t *tmp_arg[SWR_CH_MAX];
 #define MAX_DROP_STEP 16384
-        if((ret=swri_realloc_audio(&s->drop_temp, FFMIN(s->drop_output, MAX_DROP_STEP)))<0)
+        if((ret=swri_realloc_audio(&s->drop_temp, FFMINI(s->drop_output, MAX_DROP_STEP)))<0)
             return ret;
 
         reversefill_audiodata(&s->drop_temp, tmp_arg);
         s->drop_output *= -1; //FIXME find a less hackish solution
-        ret = swr_convert(s, tmp_arg, FFMIN(-s->drop_output, MAX_DROP_STEP), in_arg, in_count); //FIXME optimize but this is as good as never called so maybe it doesn't matter
+        ret = swr_convert(s, tmp_arg, FFMINI(-s->drop_output, MAX_DROP_STEP), in_arg, in_count); //FIXME optimize but this is as good as never called so maybe it doesn't matter
         s->drop_output *= -1;
         in_count = 0;
         if(ret>0) {
@@ -781,7 +781,7 @@ int attribute_align_arg swr_convert(struct SwrContext *s,
         AudioData tmp= *in;
         int ret2=0;
         int ret, size;
-        size = FFMIN(out_count, s->in_buffer_count);
+        size = FFMINI(out_count, s->in_buffer_count);
         if(size){
             buf_set(&tmp, &s->in_buffer, s->in_buffer_index);
             ret= swr_convert_internal(s, out, size, &tmp, size);
@@ -811,7 +811,7 @@ int attribute_align_arg swr_convert(struct SwrContext *s,
             }
 
             if(out_count){
-                size = FFMIN(in_count, out_count);
+                size = FFMINI(in_count, out_count);
                 ret= swr_convert_internal(s, out, size, in, size);
                 if(ret<0)
                     return ret;
diff --git a/libswresample/tests/swresample.c b/libswresample/tests/swresample.c
index b627aa4ad06..ffaefd8145e 100644
--- a/libswresample/tests/swresample.c
+++ b/libswresample/tests/swresample.c
@@ -365,7 +365,7 @@ int main(int argc, char **argv){
                 sum_aa+= a*a;
                 sum_bb+= b*b;
                 sum_ab+= a*b;
-                maxdiff= FFMAX(maxdiff, fabs(a-b));
+                maxdiff= FFMAXD(maxdiff, fabs(a-b));
             }
             sse= sum_aa + sum_bb - 2*sum_ab;
             if(sse < 0 && sse > -0.00001) sse=0; //fix rounding error
@@ -391,7 +391,7 @@ int main(int argc, char **argv){
                     sum_aa+= a*a;
                     sum_bb+= b*b;
                     sum_ab+= a*b;
-                    maxdiff= FFMAX(maxdiff, fabs(a-b));
+                    maxdiff= FFMAXD(maxdiff, fabs(a-b));
                 }
                 sse= sum_aa + sum_bb - 2*sum_ab;
                 if(sse < 0 && sse > -0.00001) sse=0; //fix rounding error
diff --git a/libswresample/x86/rematrix_init.c b/libswresample/x86/rematrix_init.c
index 623e154f5d4..4a09c76f847 100644
--- a/libswresample/x86/rematrix_init.c
+++ b/libswresample/x86/rematrix_init.c
@@ -55,8 +55,8 @@ av_cold int swri_rematrix_init_x86(struct SwrContext *s){
         for(i=0; i<nb_out; i++){
             int sh = 0;
             for(j=0; j<nb_in; j++)
-                sh = FFMAX(sh, FFABS(((int*)s->native_matrix)[i * nb_in + j]));
-            sh = FFMAX(av_log2(sh) - 14, 0);
+                sh = FFMAXI(sh, FFABS(((int*)s->native_matrix)[i * nb_in + j]));
+            sh = FFMAXI(av_log2(sh) - 14, 0);
             for(j=0; j<nb_in; j++) {
                 ((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)+1] = 15 - sh;
                 ((int16_t*)s->native_simd_matrix)[2*(i * nb_in + j)] =
diff --git a/libswscale/cms.c b/libswscale/cms.c
index a23d7a9772f..5f757f17a8c 100644
--- a/libswscale/cms.c
+++ b/libswscale/cms.c
@@ -591,13 +591,13 @@ static void generate_slice(void *priv, int jobnr, int threadnr, int nb_jobs,
 
     const int slice_start  = jobnr * ctx.slice_size;
     const int slice_stride = ctx.size_input * ctx.size_input;
-    const int slice_end    = FFMIN((jobnr + 1) * ctx.slice_size, ctx.size_input);
+    const int slice_end    = FFMINI((jobnr + 1) * ctx.slice_size, ctx.size_input);
     v3u16_t *input = &ctx.input[slice_start * slice_stride];
 
     const int output_slice_h = (ctx.size_output_PT + nb_jobs - 1) / nb_jobs;
     const int output_start   = jobnr * output_slice_h;
     const int output_stride  = ctx.size_output_PT * ctx.size_output_I;
-    const int output_end     = FFMIN((jobnr + 1) * output_slice_h, ctx.size_output_PT);
+    const int output_end     = FFMINI((jobnr + 1) * output_slice_h, ctx.size_output_PT);
     v3u16_t *output = ctx.output ? &ctx.output[output_start * output_stride] : NULL;
 
     const float I_scale   = 1.0f / (ctx.src.Imax - ctx.src.Imin);
diff --git a/libswscale/graph.c b/libswscale/graph.c
index dc7784aa499..c0b08c07c09 100644
--- a/libswscale/graph.c
+++ b/libswscale/graph.c
@@ -107,7 +107,7 @@ static void run_copy(const SwsImg *out_base, const SwsImg *in_base,
         if (in.linesize[i] == out.linesize[i]) {
             memcpy(out.data[i], in.data[i], lines * out.linesize[i]);
         } else {
-            const int linesize = FFMIN(out.linesize[i], in.linesize[i]);
+            const int linesize = FFMINI(out.linesize[i], in.linesize[i]);
             for (int j = 0; j < lines; j++) {
                 memcpy(out.data[i], in.data[i], linesize);
                 in.data[i]  += in.linesize[i];
@@ -591,7 +591,7 @@ static void sws_graph_worker(void *priv, int jobnr, int threadnr, int nb_jobs,
     const SwsImg *input  = pass->input ? &pass->input->output : &graph->exec.input;
     const SwsImg *output = pass->output.fmt != AV_PIX_FMT_NONE ? &pass->output : &graph->exec.output;
     const int slice_y = jobnr * pass->slice_h;
-    const int slice_h = FFMIN(pass->slice_h, pass->height - slice_y);
+    const int slice_h = FFMINI(pass->slice_h, pass->height - slice_y);
 
     pass->run(output, input, slice_y, slice_h, pass);
 }
diff --git a/libswscale/loongarch/swscale_lasx.c b/libswscale/loongarch/swscale_lasx.c
index fcaca3123bc..618f4017854 100644
--- a/libswscale/loongarch/swscale_lasx.c
+++ b/libswscale/loongarch/swscale_lasx.c
@@ -356,7 +356,7 @@ void ff_hscale_8_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             src0    = __lasx_xvhaddw_d_w(src0, src0);
             src0    = __lasx_xvhaddw_q_d(src0, src0);
             val     = __lasx_xvpickve2gr_w(src0, 0);
-            dst[0]  = FFMIN(val >> 7, max);
+            dst[0]  = FFMINI(val >> 7, max);
         }
     } else if (filterSize == 4) {
         __m256i src0, src1, src2, src3, src4, src5, src6, src7;
@@ -394,7 +394,7 @@ void ff_hscale_8_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[0] = FFMIN(val >> 7, max);
+            dst[0] = FFMINI(val >> 7, max);
         }
     } else if (filterSize > 8) {
         int filterlen = filterSize - 7;
@@ -429,10 +429,10 @@ void ff_hscale_8_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
                 val3 += ((int)srcPos3[j]) * filterStart3[j];
                 val4 += ((int)srcPos4[j]) * filterStart4[j];
             }
-            dst[0] = FFMIN(val1 >> 7, max);
-            dst[1] = FFMIN(val2 >> 7, max);
-            dst[2] = FFMIN(val3 >> 7, max);
-            dst[3] = FFMIN(val4 >> 7, max);
+            dst[0] = FFMINI(val1 >> 7, max);
+            dst[1] = FFMINI(val2 >> 7, max);
+            dst[2] = FFMINI(val3 >> 7, max);
+            dst[3] = FFMINI(val4 >> 7, max);
             dst       += 4;
             filterPos += 4;
             filter     = filterStart4 + filterSize;
@@ -454,7 +454,7 @@ void ff_hscale_8_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             for (; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> 7, max);
+            dst[i]  = FFMINI(val >> 7, max);
             filter += filterSize;
         }
     } else {
@@ -465,7 +465,7 @@ void ff_hscale_8_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> 7, max);
+            dst[i]  = FFMINI(val >> 7, max);
             filter += filterSize;
         }
     }
@@ -512,7 +512,7 @@ void ff_hscale_8_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             out0    = __lasx_xvhaddw_d_w(out0, out0);
             out0    = __lasx_xvhaddw_q_d(out0, out0);
             val     = __lasx_xvpickve2gr_w(out0, 0);
-            dst[0]  = FFMIN(val >> 3, max);
+            dst[0]  = FFMINI(val >> 3, max);
         }
     } else if (filterSize == 4) {
         __m256i src0, src1, src2, src3, src4, src5, src6, src7;
@@ -544,7 +544,7 @@ void ff_hscale_8_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[0] = FFMIN(val >> 3, max);
+            dst[0] = FFMINI(val >> 3, max);
         }
     } else if (filterSize > 8) {
         int len = dstW >> 2;
@@ -579,10 +579,10 @@ void ff_hscale_8_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
                 val3 += ((int)srcPos3[j]) * filterStart3[j];
                 val4 += ((int)srcPos4[j]) * filterStart4[j];
             }
-            dst[0] = FFMIN(val1 >> 3, max);
-            dst[1] = FFMIN(val2 >> 3, max);
-            dst[2] = FFMIN(val3 >> 3, max);
-            dst[3] = FFMIN(val4 >> 3, max);
+            dst[0] = FFMINI(val1 >> 3, max);
+            dst[1] = FFMINI(val2 >> 3, max);
+            dst[2] = FFMINI(val3 >> 3, max);
+            dst[3] = FFMINI(val4 >> 3, max);
             dst       += 4;
             filterPos += 4;
             filter     = filterStart4 + filterSize;
@@ -604,7 +604,7 @@ void ff_hscale_8_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             for (; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i] = FFMIN(val >> 3, max);
+            dst[i] = FFMINI(val >> 3, max);
             filter += filterSize;
         }
     } else {
@@ -615,7 +615,7 @@ void ff_hscale_8_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> 3, max);
+            dst[i]  = FFMINI(val >> 3, max);
             filter += filterSize;
         }
     }
@@ -710,7 +710,7 @@ void ff_hscale_16_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             out0    = __lasx_xvhaddw_d_w(out0, out0);
             out0    = __lasx_xvhaddw_q_d(out0, out0);
             val     = __lasx_xvpickve2gr_w(out0, 0);
-            dst[i]  = FFMIN(val >> sh, max);
+            dst[i]  = FFMINI(val >> sh, max);
             filter += 8;
         }
     } else if (filterSize == 4) {
@@ -745,7 +745,7 @@ void ff_hscale_16_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> sh, max);
+            dst[i]  = FFMINI(val >> sh, max);
             filter += 4;
         }
     } else if (filterSize > 8) {
@@ -778,10 +778,10 @@ void ff_hscale_16_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
                 val3 += ((int)srcPos3[j]) * filterStart3[j];
                 val4 += ((int)srcPos4[j]) * filterStart4[j];
             }
-            dst[0] = FFMIN(val1 >> sh, max);
-            dst[1] = FFMIN(val2 >> sh, max);
-            dst[2] = FFMIN(val3 >> sh, max);
-            dst[3] = FFMIN(val4 >> sh, max);
+            dst[0] = FFMINI(val1 >> sh, max);
+            dst[1] = FFMINI(val2 >> sh, max);
+            dst[2] = FFMINI(val3 >> sh, max);
+            dst[3] = FFMINI(val4 >> sh, max);
             dst       += 4;
             filterPos += 4;
             filter     = filterStart4 + filterSize;
@@ -803,7 +803,7 @@ void ff_hscale_16_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             for (; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> sh, max);
+            dst[i]  = FFMINI(val >> sh, max);
             filter += filterSize;
         }
     } else {
@@ -814,7 +814,7 @@ void ff_hscale_16_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> sh, max);
+            dst[i]  = FFMINI(val >> sh, max);
             filter += filterSize;
         }
     }
@@ -858,7 +858,7 @@ void ff_hscale_16_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             out0 = __lasx_xvhaddw_d_w(out0, out0);
             out0 = __lasx_xvhaddw_q_d(out0, out0);
             val  = __lasx_xvpickve2gr_w(out0, 0);
-            dst[i] = FFMIN(val >> sh, max);
+            dst[i] = FFMINI(val >> sh, max);
             filter += 8;
         }
     } else if (filterSize == 4) {
@@ -893,7 +893,7 @@ void ff_hscale_16_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> sh, max);
+            dst[i]  = FFMINI(val >> sh, max);
             filter += 4;
         }
     } else if (filterSize > 8) {
@@ -926,10 +926,10 @@ void ff_hscale_16_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
                 val3 += ((int)srcPos3[j]) * filterStart3[j];
                 val4 += ((int)srcPos4[j]) * filterStart4[j];
             }
-            dst[0] = FFMIN(val1 >> sh, max);
-            dst[1] = FFMIN(val2 >> sh, max);
-            dst[2] = FFMIN(val3 >> sh, max);
-            dst[3] = FFMIN(val4 >> sh, max);
+            dst[0] = FFMINI(val1 >> sh, max);
+            dst[1] = FFMINI(val2 >> sh, max);
+            dst[2] = FFMINI(val3 >> sh, max);
+            dst[3] = FFMINI(val4 >> sh, max);
             dst       += 4;
             filterPos += 4;
             filter     = filterStart4 + filterSize;
@@ -951,7 +951,7 @@ void ff_hscale_16_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             for (; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> sh, max);
+            dst[i]  = FFMINI(val >> sh, max);
             filter += filterSize;
         }
     } else {
@@ -962,7 +962,7 @@ void ff_hscale_16_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW,
             for (int j = 0; j < filterSize; j++) {
                 val += ((int)srcPos[j]) * filter[j];
             }
-            dst[i]  = FFMIN(val >> sh, max);
+            dst[i]  = FFMINI(val >> sh, max);
             filter += filterSize;
         }
     }
diff --git a/libswscale/lut3d.c b/libswscale/lut3d.c
index f42958cd92e..4473103daf1 100644
--- a/libswscale/lut3d.c
+++ b/libswscale/lut3d.c
@@ -82,9 +82,9 @@ v3u16_t tetrahedral(const SwsLut3D *lut3d, int Rx, int Gx, int Bx,
                     int Rf, int Gf, int Bf)
 {
     const int shift = 16 - INPUT_LUT_BITS;
-    const int Rn = FFMIN(Rx + 1, INPUT_LUT_SIZE - 1);
-    const int Gn = FFMIN(Gx + 1, INPUT_LUT_SIZE - 1);
-    const int Bn = FFMIN(Bx + 1, INPUT_LUT_SIZE - 1);
+    const int Rn = FFMINI(Rx + 1, INPUT_LUT_SIZE - 1);
+    const int Gn = FFMINI(Gx + 1, INPUT_LUT_SIZE - 1);
+    const int Bn = FFMINI(Bx + 1, INPUT_LUT_SIZE - 1);
 
     const v3u16_t c000 = lut3d->input[Bx][Gx][Rx];
     const v3u16_t c111 = lut3d->input[Bn][Gn][Rn];
@@ -180,9 +180,9 @@ static av_always_inline v3u16_t lookup_output(const SwsLut3D *lut3d, v3u16_t ipt
     const int If = ipt.x & ((1 << Ishift) - 1);
     const int Pf = ipt.y & ((1 << Cshift) - 1);
     const int Tf = ipt.z & ((1 << Cshift) - 1);
-    const int In = FFMIN(Ix + 1, OUTPUT_LUT_SIZE_I  - 1);
-    const int Pn = FFMIN(Px + 1, OUTPUT_LUT_SIZE_PT - 1);
-    const int Tn = FFMIN(Tx + 1, OUTPUT_LUT_SIZE_PT - 1);
+    const int In = FFMINI(Ix + 1, OUTPUT_LUT_SIZE_I  - 1);
+    const int Pn = FFMINI(Px + 1, OUTPUT_LUT_SIZE_PT - 1);
+    const int Tn = FFMINI(Tx + 1, OUTPUT_LUT_SIZE_PT - 1);
 
     /* Trilinear interpolation */
     const v3u16_t c000 = lut3d->output[Tx][Px][Ix];
@@ -208,7 +208,7 @@ static av_always_inline v3u16_t apply_tone_map(const SwsLut3D *lut3d, v3u16_t ip
     const int shift = 16 - TONE_LUT_BITS;
     const int Ix = ipt.x >> shift;
     const int If = ipt.x & ((1 << shift) - 1);
-    const int In = FFMIN(Ix + 1, TONE_LUT_SIZE - 1);
+    const int In = FFMINI(Ix + 1, TONE_LUT_SIZE - 1);
 
     const v2u16_t w0 = lut3d->tone_map[Ix];
     const v2u16_t w1 = lut3d->tone_map[In];
diff --git a/libswscale/slice.c b/libswscale/slice.c
index 44c3bd74b44..edc3fae501e 100644
--- a/libswscale/slice.c
+++ b/libswscale/slice.c
@@ -171,7 +171,7 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *const src[4], const int stride
         int tot_lines = end[i] - first;
 
         if (start[i] >= first && n >= tot_lines) {
-            s->plane[i].sliceH = FFMAX(tot_lines, s->plane[i].sliceH);
+            s->plane[i].sliceH = FFMAXI(tot_lines, s->plane[i].sliceH);
             for (j = 0; j < lines; j+= 1)
                 s->plane[i].line[start[i] - first + j] = src_i +  j * stride[i];
         } else {
@@ -230,14 +230,14 @@ static void get_min_buffer_size(SwsInternal *c, int *out_lum_size, int *out_chr_
 
     for (lumY = 0; lumY < dstH; lumY++) {
         int chrY      = (int64_t)lumY * chrDstH / dstH;
-        int nextSlice = FFMAX(lumFilterPos[lumY] + lumFilterSize - 1,
+        int nextSlice = FFMAXI(lumFilterPos[lumY] + lumFilterSize - 1,
                               ((chrFilterPos[chrY] + chrFilterSize - 1)
                                << chrSubSample));
 
         nextSlice >>= chrSubSample;
         nextSlice <<= chrSubSample;
-        (*out_lum_size) = FFMAX((*out_lum_size), nextSlice - lumFilterPos[lumY]);
-        (*out_chr_size) = FFMAX((*out_chr_size), (nextSlice >> chrSubSample) - chrFilterPos[chrY]);
+        (*out_lum_size) = FFMAXI((*out_lum_size), nextSlice - lumFilterPos[lumY]);
+        (*out_chr_size) = FFMAXI((*out_chr_size), (nextSlice >> chrSubSample) - chrFilterPos[chrY]);
     }
 }
 
@@ -263,8 +263,8 @@ int ff_init_filters(SwsInternal * c)
     int chrBufSize;
 
     get_min_buffer_size(c, &lumBufSize, &chrBufSize);
-    lumBufSize = FFMAX(lumBufSize, c->vLumFilterSize + MAX_LINES_AHEAD);
-    chrBufSize = FFMAX(chrBufSize, c->vChrFilterSize + MAX_LINES_AHEAD);
+    lumBufSize = FFMAXI(lumBufSize, c->vLumFilterSize + MAX_LINES_AHEAD);
+    chrBufSize = FFMAXI(chrBufSize, c->vChrFilterSize + MAX_LINES_AHEAD);
 
     if (c->dstBpc == 16)
         dst_stride <<= 1;
@@ -275,7 +275,7 @@ int ff_init_filters(SwsInternal * c)
     num_ydesc = need_lum_conv ? 2 : 1;
     num_cdesc = need_chr_conv ? 2 : 1;
 
-    c->numSlice = FFMAX(num_ydesc, num_cdesc) + 2;
+    c->numSlice = FFMAXI(num_ydesc, num_cdesc) + 2;
     c->numDesc = num_ydesc + num_cdesc + num_vdesc + (need_gamma ? 2 : 0);
     c->descIndex[0] = num_ydesc + (need_gamma ? 1 : 0);
     c->descIndex[1] = num_ydesc + num_cdesc + (need_gamma ? 1 : 0);
@@ -337,7 +337,7 @@ int ff_init_filters(SwsInternal * c)
     }
 
 
-    dstIdx = FFMAX(num_ydesc, num_cdesc);
+    dstIdx = FFMAXI(num_ydesc, num_cdesc);
     res = ff_init_desc_hscale(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], c->hLumFilter, c->hLumFilterPos, c->hLumFilterSize, c->lumXInc);
     if (res < 0) goto cleanup;
     c->desc[index].alpha = c->needAlpha;
@@ -354,7 +354,7 @@ int ff_init_filters(SwsInternal * c)
             srcIdx = dstIdx;
         }
 
-        dstIdx = FFMAX(num_ydesc, num_cdesc);
+        dstIdx = FFMAXI(num_ydesc, num_cdesc);
         if (c->needs_hcscale)
             res = ff_init_desc_chscale(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], c->hChrFilter, c->hChrFilterPos, c->hChrFilterSize, c->chrXInc);
         else
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index c3d64a67b8a..083c76138ae 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -88,7 +88,7 @@ static void hScale16To19_c(SwsInternal *c, int16_t *_dst, int dstW,
             val += src[srcPos + j] * filter[filterSize * i + j];
         }
         // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit
-        dst[i] = FFMIN(val >> sh, (1 << 19) - 1);
+        dst[i] = FFMINI(val >> sh, (1 << 19) - 1);
     }
 }
 
@@ -116,7 +116,7 @@ static void hScale16To15_c(SwsInternal *c, int16_t *dst, int dstW,
             val += src[srcPos + j] * filter[filterSize * i + j];
         }
         // filter=14 bit, input=16 bit, output=30 bit, >> 15 makes 15 bit
-        dst[i] = FFMIN(val >> sh, (1 << 15) - 1);
+        dst[i] = FFMINI(val >> sh, (1 << 15) - 1);
     }
 }
 
@@ -133,7 +133,7 @@ static void hScale8To15_c(SwsInternal *c, int16_t *dst, int dstW,
         for (j = 0; j < filterSize; j++) {
             val += ((int)src[srcPos + j]) * filter[filterSize * i + j];
         }
-        dst[i] = FFMIN(val >> 7, (1 << 15) - 1); // the cubic equation does overflow ...
+        dst[i] = FFMINI(val >> 7, (1 << 15) - 1); // the cubic equation does overflow ...
     }
 }
 
@@ -150,7 +150,7 @@ static void hScale8To19_c(SwsInternal *c, int16_t *_dst, int dstW,
         for (j = 0; j < filterSize; j++) {
             val += ((int)src[srcPos + j]) * filter[filterSize * i + j];
         }
-        dst[i] = FFMIN(val >> 3, (1 << 19) - 1); // the cubic equation does overflow ...
+        dst[i] = FFMINI(val >> 3, (1 << 19) - 1); // the cubic equation does overflow ...
     }
 }
 
@@ -165,8 +165,8 @@ static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width,
     for (i = 0; i < width; i++) {
         int U = (dstU[i] * coeff + offset) >> 14;
         int V = (dstV[i] * coeff + offset) >> 14;
-        dstU[i] = FFMIN(U, (1 << 15) - 1);
-        dstV[i] = FFMIN(V, (1 << 15) - 1);
+        dstU[i] = FFMINI(U, (1 << 15) - 1);
+        dstV[i] = FFMINI(V, (1 << 15) - 1);
     }
 }
 
@@ -190,7 +190,7 @@ static void lumRangeToJpeg_c(int16_t *dst, int width,
     int i;
     for (i = 0; i < width; i++) {
         int Y = (dst[i] * coeff + offset) >> 14;
-        dst[i] = FFMIN(Y, (1 << 15) - 1);
+        dst[i] = FFMINI(Y, (1 << 15) - 1);
     }
 }
 
@@ -213,8 +213,8 @@ static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width,
     for (i = 0; i < width; i++) {
         int U = ((int64_t) dstU[i] * coeff + offset) >> 18;
         int V = ((int64_t) dstV[i] * coeff + offset) >> 18;
-        dstU[i] = FFMIN(U, (1 << 19) - 1);
-        dstV[i] = FFMIN(V, (1 << 19) - 1);
+        dstU[i] = FFMINI(U, (1 << 19) - 1);
+        dstV[i] = FFMINI(V, (1 << 19) - 1);
     }
 }
 
@@ -237,7 +237,7 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width,
     int32_t *dst = (int32_t *) _dst;
     for (i = 0; i < width; i++) {
         int Y = ((int64_t) dst[i] * coeff + offset) >> 18;
-        dst[i] = FFMIN(Y, (1 << 19) - 1);
+        dst[i] = FFMINI(Y, (1 << 19) - 1);
     }
 }
 
@@ -411,15 +411,15 @@ int ff_swscale(SwsInternal *c, const uint8_t *const src[], const int srcStride[]
         int use_mmx_vfilter= c->use_mmx_vfilter;
 
         // First line needed as input
-        const int firstLumSrcY  = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]);
-        const int firstLumSrcY2 = FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1 << c->chrDstVSubSample) - 1), c->opts.dst_h - 1)]);
+        const int firstLumSrcY  = FFMAXI(1 - vLumFilterSize, vLumFilterPos[dstY]);
+        const int firstLumSrcY2 = FFMAXI(1 - vLumFilterSize, vLumFilterPos[FFMINI(dstY | ((1 << c->chrDstVSubSample) - 1), c->opts.dst_h - 1)]);
         // First line needed as input
-        const int firstChrSrcY  = FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]);
+        const int firstChrSrcY  = FFMAXI(1 - vChrFilterSize, vChrFilterPos[chrDstY]);
 
         // Last line needed as input
-        int lastLumSrcY  = FFMIN(c->opts.src_h,    firstLumSrcY  + vLumFilterSize) - 1;
-        int lastLumSrcY2 = FFMIN(c->opts.src_h,    firstLumSrcY2 + vLumFilterSize) - 1;
-        int lastChrSrcY  = FFMIN(c->chrSrcH, firstChrSrcY  + vChrFilterSize) - 1;
+        int lastLumSrcY  = FFMINI(c->opts.src_h,    firstLumSrcY  + vLumFilterSize) - 1;
+        int lastLumSrcY2 = FFMINI(c->opts.src_h,    firstLumSrcY2 + vLumFilterSize) - 1;
+        int lastChrSrcY  = FFMINI(c->chrSrcH, firstChrSrcY  + vChrFilterSize) - 1;
         int enough_lines;
 
         int i;
@@ -474,8 +474,8 @@ int ff_swscale(SwsInternal *c, const uint8_t *const src[], const int srcStride[]
 
         posY = hout_slice->plane[0].sliceY + hout_slice->plane[0].sliceH;
         if (posY <= lastLumSrcY && !hasLumHoles) {
-            firstPosY = FFMAX(firstLumSrcY, posY);
-            lastPosY = FFMIN(firstLumSrcY + hout_slice->plane[0].available_lines - 1, srcSliceY + srcSliceH - 1);
+            firstPosY = FFMAXI(firstLumSrcY, posY);
+            lastPosY = FFMINI(firstLumSrcY + hout_slice->plane[0].available_lines - 1, srcSliceY + srcSliceH - 1);
         } else {
             firstPosY = posY;
             lastPosY = lastLumSrcY;
@@ -483,8 +483,8 @@ int ff_swscale(SwsInternal *c, const uint8_t *const src[], const int srcStride[]
 
         cPosY = hout_slice->plane[1].sliceY + hout_slice->plane[1].sliceH;
         if (cPosY <= lastChrSrcY && !hasChrHoles) {
-            firstCPosY = FFMAX(firstChrSrcY, cPosY);
-            lastCPosY = FFMIN(firstChrSrcY + hout_slice->plane[1].available_lines - 1, AV_CEIL_RSHIFT(srcSliceY + srcSliceH, c->chrSrcVSubSample) - 1);
+            firstCPosY = FFMAXI(firstChrSrcY, cPosY);
+            lastCPosY = FFMINI(firstChrSrcY + hout_slice->plane[1].available_lines - 1, AV_CEIL_RSHIFT(srcSliceY + srcSliceH, c->chrSrcVSubSample) - 1);
         } else {
             firstCPosY = cPosY;
             lastCPosY = lastChrSrcY;
@@ -586,7 +586,7 @@ static void solve_range_convert(uint16_t src_min, uint16_t src_max,
 
 static void init_range_convert_constants(SwsInternal *c)
 {
-    const int bit_depth = c->dstBpc ? FFMIN(c->dstBpc, 16) : 8;
+    const int bit_depth = c->dstBpc ? FFMINI(c->dstBpc, 16) : 8;
     const int src_bits = bit_depth <= 14 ? 15 : 19;
     const int src_shift = src_bits - bit_depth;
     const int mult_shift = bit_depth <= 14 ? 14 : 18;
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 61073c6c0a4..0d784e7301f 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -548,7 +548,7 @@ static int bswap_16bpc(SwsInternal *c, const uint8_t *const src[],
         int dststr = dstStride[p] / 2;
         uint16_t       *dstPtr =       (uint16_t *) dst[p];
         const uint16_t *srcPtr = (const uint16_t *) src[p];
-        int min_stride         = FFMIN(FFABS(srcstr), FFABS(dststr));
+        int min_stride         = FFMINI(FFABS(srcstr), FFABS(dststr));
         if(!dstPtr || !srcPtr)
             continue;
         dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
@@ -575,7 +575,7 @@ static int bswap_32bpc(SwsInternal *c, const uint8_t *const src[],
         int dststr = dstStride[p] / 4;
         uint32_t       *dstPtr =       (uint32_t *) dst[p];
         const uint32_t *srcPtr = (const uint32_t *) src[p];
-        int min_stride         = FFMIN(FFABS(srcstr), FFABS(dststr));
+        int min_stride         = FFMINI(FFABS(srcstr), FFABS(dststr));
         if(!dstPtr || !srcPtr)
             continue;
         dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
diff --git a/libswscale/tests/floatimg_cmp.c b/libswscale/tests/floatimg_cmp.c
index 0744e64f8ef..2c6e29ef450 100644
--- a/libswscale/tests/floatimg_cmp.c
+++ b/libswscale/tests/floatimg_cmp.c
@@ -267,8 +267,8 @@ bad_option:
 
                     diff = fabsf(v0.f - v1.f);
                     sum += diff;
-                    minimum = FFMIN(minimum, diff);
-                    maximum = FFMAX(maximum, diff);
+                    minimum = FFMINF(minimum, diff);
+                    maximum = FFMAXF(maximum, diff);
 
                     count++;
                     in++;
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 0f1f8311c9f..31752d918ab 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -331,7 +331,7 @@ static int run_test(enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
          * higher than it theoretically "should" be. */
         if (src_var > dst_var) {
             const float src_loss = (2 * ref_var + c1) / (2 * ref_var + src_var + c1);
-            ssim_sws[0] = FFMIN(ssim_sws[0], src_loss);
+            ssim_sws[0] = FFMINF(ssim_sws[0], src_loss);
         }
 
         ssim_ref = ssim_sws;
@@ -352,9 +352,9 @@ static int run_test(enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
 
     if (opts.bench && time_ref) {
         double ratio = (double) time_ref / time;
-        if (FFMIN(time, time_ref) > 100 /* don't pollute stats with low precision */) {
-            speedup_min = FFMIN(speedup_min, ratio);
-            speedup_max = FFMAX(speedup_max, ratio);
+        if (FFMINI(time, time_ref) > 100 /* don't pollute stats with low precision */) {
+            speedup_min = FFMIND(speedup_min, ratio);
+            speedup_max = FFMAXD(speedup_max, ratio);
             speedup_logavg += log(ratio);
             speedup_count++;
         }
@@ -563,7 +563,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(argv[i], "-bench")) {
             opts.bench = 1;
             opts.iters = atoi(argv[i + 1]);
-            opts.iters = FFMAX(opts.iters, 1);
+            opts.iters = FFMAXI(opts.iters, 1);
             opts.w = 1920;
             opts.h = 1080;
         } else if (!strcmp(argv[i], "-flags")) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 94a47ea5d0f..65b65facdde 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -202,7 +202,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
     int minFilterSize;
     int64_t *filter    = NULL;
     int64_t *filter2   = NULL;
-    const int64_t fone = 1LL << (54 - FFMIN(av_log2(srcW/dstW), 8));
+    const int64_t fone = 1LL << (54 - FFMINI(av_log2(srcW/dstW), 8));
     int ret            = -1;
 
     emms_c(); // FIXME should not be required but IS (even for non-MMX versions)
@@ -279,8 +279,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
         else
             filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
 
-        filterSize = FFMIN(filterSize, srcW - 2);
-        filterSize = FFMAX(filterSize, 1);
+        filterSize = FFMINI(filterSize, srcW - 2);
+        filterSize = FFMAXI(filterSize, 1);
 
         if (!FF_ALLOC_TYPED_ARRAY(filter, dstW * filterSize))
             goto nomem;
@@ -510,7 +510,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
         if ((*filterPos)[i] < 0) {
             // move filter coefficients left to compensate for filterPos
             for (j = 1; j < filterSize; j++) {
-                int left = FFMAX(j + (*filterPos)[i], 0);
+                int left = FFMAXI(j + (*filterPos)[i], 0);
                 filter[i * filterSize + left] += filter[i * filterSize + j];
                 filter[i * filterSize + j]     = 0;
             }
@@ -518,7 +518,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
         }
 
         if ((*filterPos)[i] + filterSize > srcW) {
-            int shift = (*filterPos)[i] + FFMIN(filterSize - srcW, 0);
+            int shift = (*filterPos)[i] + FFMINI(filterSize - srcW, 0);
             int64_t acc = 0;
 
             for (j = filterSize - 1; j >= 0; j--) {
@@ -2043,7 +2043,7 @@ void sws_normalizeVec(SwsVector *a, double height)
 
 static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b)
 {
-    int length = FFMAX(a->length, b->length);
+    int length = FFMAXI(a->length, b->length);
     int i;
     SwsVector *vec = sws_getConstVec(0.0, length);
 
diff --git a/libswscale/vscale.c b/libswscale/vscale.c
index e972bd70e28..6440f46347a 100644
--- a/libswscale/vscale.c
+++ b/libswscale/vscale.c
@@ -43,7 +43,7 @@ static int lum_planar_vscale(SwsInternal *c, SwsFilterDescriptor *desc, int slic
     VScalerContext *inst = desc->instance;
     int dstW = desc->dst->width;
 
-    int first = FFMAX(1-inst->filter_size, inst->filter_pos[sliceY]);
+    int first = FFMAXI(1-inst->filter_size, inst->filter_pos[sliceY]);
     int sp = first - desc->src->plane[0].sliceY;
     int dp = sliceY - desc->dst->plane[0].sliceY;
     uint8_t **src = desc->src->plane[0].line + sp;
@@ -81,7 +81,7 @@ static int chr_planar_vscale(SwsInternal *c, SwsFilterDescriptor *desc, int slic
         int dstW = AV_CEIL_RSHIFT(desc->dst->width, desc->dst->h_chr_sub_sample);
         int chrSliceY = sliceY >> desc->dst->v_chr_sub_sample;
 
-        int first = FFMAX(1-inst->filter_size, inst->filter_pos[chrSliceY]);
+        int first = FFMAXI(1-inst->filter_size, inst->filter_pos[chrSliceY]);
         int sp1 = first - desc->src->plane[1].sliceY;
         int sp2 = first - desc->src->plane[2].sliceY;
         int dp1 = chrSliceY - desc->dst->plane[1].sliceY;
@@ -117,8 +117,8 @@ static int packed_vscale(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY,
     uint16_t *lum_filter = inst[0].filter[0];
     uint16_t *chr_filter = inst[1].filter[0];
 
-    int firstLum = FFMAX(1-lum_fsize, inst[0].filter_pos[   sliceY]);
-    int firstChr = FFMAX(1-chr_fsize, inst[1].filter_pos[chrSliceY]);
+    int firstLum = FFMAXI(1-lum_fsize, inst[0].filter_pos[   sliceY]);
+    int firstChr = FFMAXI(1-chr_fsize, inst[1].filter_pos[chrSliceY]);
 
     int sp0 = firstLum - desc->src->plane[0].sliceY;
     int sp1 = firstChr - desc->src->plane[1].sliceY;
@@ -181,8 +181,8 @@ static int any_vscale(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY, int
     uint16_t *lum_filter = inst[0].filter[0];
     uint16_t *chr_filter = inst[1].filter[0];
 
-    int firstLum = FFMAX(1-lum_fsize, inst[0].filter_pos[   sliceY]);
-    int firstChr = FFMAX(1-chr_fsize, inst[1].filter_pos[chrSliceY]);
+    int firstLum = FFMAXI(1-lum_fsize, inst[0].filter_pos[   sliceY]);
+    int firstChr = FFMAXI(1-chr_fsize, inst[1].filter_pos[chrSliceY]);
 
     int sp0 = firstLum - desc->src->plane[0].sliceY;
     int sp1 = firstChr - desc->src->plane[1].sliceY;
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index e9ad2a1e95d..08d9cbc66ed 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -94,7 +94,7 @@ void ff_updateMMXDitherTables(SwsInternal *c, int dstY)
         if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->opts.src_h) {
             const int16_t **tmpY = (const int16_t **) lumPlane->tmp;
 
-            int neg = -firstLumSrcY, i, end = FFMIN(c->opts.src_h - firstLumSrcY, vLumFilterSize);
+            int neg = -firstLumSrcY, i, end = FFMINI(c->opts.src_h - firstLumSrcY, vLumFilterSize);
             for (i = 0; i < neg;            i++)
                 tmpY[i] = lumSrcPtr[neg];
             for (     ; i < end;            i++)
@@ -116,7 +116,7 @@ void ff_updateMMXDitherTables(SwsInternal *c, int dstY)
         }
         if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
             const int16_t **tmpU = (const int16_t **) chrUPlane->tmp;
-            int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
+            int neg = -firstChrSrcY, i, end = FFMINI(c->chrSrcH - firstChrSrcY, vChrFilterSize);
             for (i = 0; i < neg;            i++) {
                 tmpU[i] = chrUSrcPtr[neg];
             }
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index ff8e013da4d..68345028499 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -779,10 +779,10 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsInternal *c, const int inv_table[4],
     c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu * (1 << 13));
 
     //scale coefficients by cy
-    crv = ((crv * (1 << 16)) + 0x8000) / FFMAX(cy, 1);
-    cbu = ((cbu * (1 << 16)) + 0x8000) / FFMAX(cy, 1);
-    cgu = ((cgu * (1 << 16)) + 0x8000) / FFMAX(cy, 1);
-    cgv = ((cgv * (1 << 16)) + 0x8000) / FFMAX(cy, 1);
+    crv = ((crv * (1 << 16)) + 0x8000) / FFMAXI(cy, 1);
+    cbu = ((cbu * (1 << 16)) + 0x8000) / FFMAXI(cy, 1);
+    cgu = ((cgu * (1 << 16)) + 0x8000) / FFMAXI(cy, 1);
+    cgv = ((cgv * (1 << 16)) + 0x8000) / FFMAXI(cy, 1);
 
     av_freep(&c->yuvTable);
 
diff --git a/tests/checkasm/audiodsp.c b/tests/checkasm/audiodsp.c
index 7980b550d21..053f83bff43 100644
--- a/tests/checkasm/audiodsp.c
+++ b/tests/checkasm/audiodsp.c
@@ -66,12 +66,12 @@ void checkasm_check_audiodsp(void)
         // generate random 5-12bit vector length
         len_bits_minus4 = rnd() % 8;
         len = rnd() & ((1 << len_bits_minus4) - 1);
-        len = 16 * FFMAX(len, 1);
+        len = 16 * FFMAXI(len, 1);
 
         // generate the bit counts for each of the vectors such that the result
         // fits into int32
         v1_bits = 1 + rnd() % 15;
-        v2_bits = FFMIN(32 - (len_bits_minus4 + 4) - v1_bits - 1, 15);
+        v2_bits = FFMINI(32 - (len_bits_minus4 + 4) - v1_bits - 1, 15);
 
         randomize_int(v1, MAX_SIZE, 16, v1_bits + 1);
         randomize_int(v2, MAX_SIZE, 16, v2_bits + 1);
@@ -98,13 +98,13 @@ void checkasm_check_audiodsp(void)
         val2 = ((int32_t)rnd());
         val2 = FFSIGN(val2) * (val2 & ((1 << 24) - 1));
 
-        min = FFMIN(val1, val2);
-        max = FFMAX(val1, val2);
+        min = FFMINI(val1, val2);
+        max = FFMAXI(val1, val2);
 
         randomize_int(src, MAX_SIZE, 32, 32);
 
         len = rnd() % 128;
-        len = 32 * FFMAX(len, 1);
+        len = 32 * FFMAXI(len, 1);
 
         call_ref(dst0, src, min, max, len);
         call_new(dst1, src, min, max, len);
@@ -126,13 +126,13 @@ void checkasm_check_audiodsp(void)
         val1 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
         val2 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
 
-        min = FFMIN(val1, val2);
-        max = FFMAX(val1, val2);
+        min = FFMINF(val1, val2);
+        max = FFMAXF(val1, val2);
 
         randomize_float(src, MAX_SIZE);
 
         len = rnd() % 128;
-        len = 16 * FFMAX(len, 1);
+        len = 16 * FFMAXI(len, 1);
 
         call_ref(dst0, src, len, min, max);
         call_new(dst1, src, len, min, max);
diff --git a/tests/checkasm/hevc_deblock.c b/tests/checkasm/hevc_deblock.c
index 89dd8a308b0..d2859da72a9 100644
--- a/tests/checkasm/hevc_deblock.c
+++ b/tests/checkasm/hevc_deblock.c
@@ -105,7 +105,7 @@ static void check_deblock_chroma(HEVCDSPContext *h, int bit_depth, int c)
         *(uint16_t*)(&x) = z; \
 } while (0)
 #define RANDCLIP(x, diff) av_clip(GET(x) - (diff), 0, \
-    (1 << (bit_depth)) - 1) + rnd() % FFMAX(2 * (diff), 1)
+    (1 << (bit_depth)) - 1) + rnd() % FFMAXI(2 * (diff), 1)
 
 // NOTE: this function doesn't work 'correctly' in that it won't always choose
 // strong/strong or weak/weak, in most cases it tends to but will sometimes mix
@@ -130,7 +130,7 @@ static void randomize_luma_buffers(int type, int *beta, int32_t tc[2],
     case 0: // strong
         for (j = 0; j < 2; j++) {
             tc25 = TC25(j) << (bit_depth - 8);
-            tc25diff = FFMAX(tc25 - 1, 0);
+            tc25diff = FFMAXI(tc25 - 1, 0);
             // 4 lines per tc
             for (i = 0; i < 4; i++) {
                 b3 = (*beta << (bit_depth - 8)) >> 3;
@@ -142,19 +142,19 @@ static void randomize_luma_buffers(int type, int *beta, int32_t tc[2],
                 b3diff = rnd() % b3;
                 SET(P3, RANDCLIP(P0, b3diff));
                 // q3 - q0, reduced budget
-                b3diff = rnd() % FFMAX(b3 - b3diff, 1);
+                b3diff = rnd() % FFMAXI(b3 - b3diff, 1);
                 SET(Q3, RANDCLIP(Q0, b3diff));
 
                 // same concept, budget across 4 pixels
-                b3 -= b3diff = rnd() % FFMAX(b3, 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3, 1);
                 SET(P2, RANDCLIP(P0, b3diff));
-                b3 -= b3diff = rnd() % FFMAX(b3, 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3, 1);
                 SET(Q2, RANDCLIP(Q0, b3diff));
 
                 // extra reduced budget for weighted pixels
-                b3 -= b3diff = rnd() % FFMAX(b3 - (1 << (bit_depth - 8)), 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3 - (1 << (bit_depth - 8)), 1);
                 SET(P1, RANDCLIP(P0, b3diff));
-                b3 -= b3diff = rnd() % FFMAX(b3 - (1 << (bit_depth - 8)), 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3 - (1 << (bit_depth - 8)), 1);
                 SET(Q1, RANDCLIP(Q0, b3diff));
 
                 buf += ystride;
@@ -164,7 +164,7 @@ static void randomize_luma_buffers(int type, int *beta, int32_t tc[2],
     case 1: // weak
         for (j = 0; j < 2; j++) {
             tc25 = TC25(j) << (bit_depth - 8);
-            tc25diff = FFMAX(tc25 - 1, 0);
+            tc25diff = FFMAXI(tc25 - 1, 0);
             // 4 lines per tc
             for (i = 0; i < 4; i++) {
                 // Weak filtering is signficantly simpler to activate as
@@ -183,19 +183,19 @@ static void randomize_luma_buffers(int type, int *beta, int32_t tc[2],
                 b3diff = rnd() % b3;
                 SET(P3, RANDCLIP(P0, b3diff));
                 // q3 - q0, reduced budget
-                b3diff = rnd() % FFMAX(b3 - b3diff, 1);
+                b3diff = rnd() % FFMAXI(b3 - b3diff, 1);
                 SET(Q3, RANDCLIP(Q0, b3diff));
 
                 // same concept, budget across 4 pixels
-                b3 -= b3diff = rnd() % FFMAX(b3, 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3, 1);
                 SET(P2, RANDCLIP(P0, b3diff));
-                b3 -= b3diff = rnd() % FFMAX(b3, 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3, 1);
                 SET(Q2, RANDCLIP(Q0, b3diff));
 
                 // extra reduced budget for weighted pixels
-                b3 -= b3diff = rnd() % FFMAX(b3 - (1 << (bit_depth - 8)), 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3 - (1 << (bit_depth - 8)), 1);
                 SET(P1, RANDCLIP(P0, b3diff));
-                b3 -= b3diff = rnd() % FFMAX(b3 - (1 << (bit_depth - 8)), 1);
+                b3 -= b3diff = rnd() % FFMAXI(b3 - (1 << (bit_depth - 8)), 1);
                 SET(Q1, RANDCLIP(Q0, b3diff));
 
                 buf += ystride;
diff --git a/tests/checkasm/lls.c b/tests/checkasm/lls.c
index 4251032e024..a7a377e6aaf 100644
--- a/tests/checkasm/lls.c
+++ b/tests/checkasm/lls.c
@@ -47,7 +47,7 @@ static void test_update(LLSModel *lls, const double *var)
 
     for (size_t i = 0; i < lls->indep_count; i++)
         for (size_t j = i; j < lls->indep_count; j++) {
-            double eps = FFMAX(2 * DBL_EPSILON * fabs(refcovar[i][j]),
+            double eps = FFMAXD(2 * DBL_EPSILON * fabs(refcovar[i][j]),
                                8 * DBL_EPSILON);
             if (!double_near_abs_eps(refcovar[i][j], lls->covariance[i][j],
                                      eps)) {
@@ -69,7 +69,7 @@ static void test_evaluate(LLSModel *lls, const double *param, int order)
     refprod = call_ref(lls, param, order);
     newprod = call_new(lls, param, order);
 
-    eps = FFMAX(2 * DBL_EPSILON * fabs(refprod), 0.2);
+    eps = FFMAXD(2 * DBL_EPSILON * fabs(refprod), 0.2);
 
     if (!double_near_abs_eps(refprod, newprod, eps)) {
         fprintf(stderr, "%- .12f - %- .12f = % .12g\n",
diff --git a/tests/checkasm/vp9dsp.c b/tests/checkasm/vp9dsp.c
index bddc9a79fc5..f844b212e26 100644
--- a/tests/checkasm/vp9dsp.c
+++ b/tests/checkasm/vp9dsp.c
@@ -37,7 +37,7 @@ static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff };
     do {                                                           \
         uint32_t mask = pixel_mask[(bit_depth - 8) >> 1];          \
         int k;                                                     \
-        for (k = -4;  k < SIZEOF_PIXEL * FFMAX(8, size); k += 4) { \
+        for (k = -4;  k < SIZEOF_PIXEL * FFMAXI(8, size); k += 4) { \
             uint32_t r = rnd() & mask;                             \
             AV_WN32A(a + k, r);                                    \
         }                                                          \
diff --git a/tools/ismindex.c b/tools/ismindex.c
index b110420bf09..48644632053 100644
--- a/tools/ismindex.c
+++ b/tools/ismindex.c
@@ -118,7 +118,7 @@ static int copy_tag(AVIOContext *in, AVIOContext *out, int32_t tag_name)
     size -= 8;
     while (size > 0) {
         char buf[1024];
-        int len = FFMIN(sizeof(buf), size);
+        int len = FFMINI(sizeof(buf), size);
         int got;
         if ((got = avio_read(in, buf, len)) != len) {
             fprintf(stderr, "short read, wanted %d, got %d\n", len, got);
@@ -258,7 +258,7 @@ static int64_t read_trun_duration(AVIOContext *in, int default_duration,
         }
         if (i == 0)
             first_pts = pts;
-        max_pts = FFMAX(max_pts, pts + sample_duration);
+        max_pts = FFMAXI(max_pts, pts + sample_duration);
         dts += sample_duration;
         pos = avio_tell(in);
     }
@@ -563,7 +563,7 @@ static int handle_file(struct Tracks *tracks, const char *file, int split,
             continue;
         }
 
-        tracks->duration = FFMAX(tracks->duration,
+        tracks->duration = FFMAXI(tracks->duration,
                                  av_rescale_rnd(track->duration, AV_TIME_BASE,
                                                 track->timescale, AV_ROUND_UP));
 
diff --git a/tools/probetest.c b/tools/probetest.c
index a8ce4047928..5084fe416b6 100644
--- a/tools/probetest.c
+++ b/tools/probetest.c
@@ -145,7 +145,7 @@ int main(int argc, char **argv)
 
         fprintf(stderr, "testing size=%d\n", size);
 
-        for (retry = 0; retry < retry_count; retry += FFMAX(size, 32)) {
+        for (retry = 0; retry < retry_count; retry += FFMAXI(size, 32)) {
             for (type = 0; type < 4; type++) {
                 for (p = 0; p < 4096; p++) {
                     unsigned hist = 0;
diff --git a/tools/scale_slice_test.c b/tools/scale_slice_test.c
index 4480bf85697..83deaf5d966 100644
--- a/tools/scale_slice_test.c
+++ b/tools/scale_slice_test.c
@@ -79,7 +79,7 @@ static int process_frame(DecodeContext *dc, AVFrame *frame)
         const uint8_t *src[4];
 
         slice_height = av_lfg_get(&pd->lfg) % (frame->height - slice_start);
-        slice_height = FFALIGN(FFMAX(1, slice_height), 1 << pd->v_shift_src);
+        slice_height = FFALIGN(FFMAXI(1, slice_height), 1 << pd->v_shift_src);
 
         for (int j = 0; j < FF_ARRAY_ELEMS(src) && frame->data[j]; j++) {
             int shift = (j == 1 || j == 2) ? pd->v_shift_src : 0;
diff --git a/tools/sidxindex.c b/tools/sidxindex.c
index 96b1fce8c43..1fa24c1ee21 100644
--- a/tools/sidxindex.c
+++ b/tools/sidxindex.c
@@ -185,7 +185,7 @@ static int handle_file(struct Tracks *tracks, const char *file)
             continue;
         }
 
-        tracks->duration = FFMAX(tracks->duration,
+        tracks->duration = FFMAXI(tracks->duration,
                                  av_rescale_rnd(track->duration, AV_TIME_BASE,
                                                 track->timescale, AV_ROUND_UP));
 
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index dfff167f781..876e47d161e 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -336,8 +336,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     case AV_CODEC_ID_ZLIB:        maxpixels  /= 4096;  break;
     }
 
-    maxsamples_per_frame = FFMIN(maxsamples_per_frame, maxsamples);
-    maxpixels_per_frame  = FFMIN(maxpixels_per_frame , maxpixels);
+    maxsamples_per_frame = FFMINI(maxsamples_per_frame, maxsamples);
+    maxpixels_per_frame  = FFMINI(maxpixels_per_frame , maxpixels);
 
     AVCodecContext* ctx = avcodec_alloc_context3(&c->p);
     AVCodecContext* parser_avctx = avcodec_alloc_context3(NULL);
diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c
index 8e96fad7f8d..56a6893f525 100644
--- a/tools/target_dem_fuzzer.c
+++ b/tools/target_dem_fuzzer.c
@@ -51,10 +51,10 @@ static void error(const char *err)
 static int io_read(void *opaque, uint8_t *buf, int buf_size)
 {
     IOContext *c = opaque;
-    int size = FFMIN(buf_size, c->fuzz_size);
+    int size = FFMINI(buf_size, c->fuzz_size);
 
     if (!c->fuzz_size) {
-        c->filesize = FFMIN(c->pos, c->filesize);
+        c->filesize = FFMINI(c->pos, c->filesize);
         return AVERROR_EOF;
     }
     if (c->pos > INT64_MAX - size)
@@ -64,7 +64,7 @@ static int io_read(void *opaque, uint8_t *buf, int buf_size)
     c->fuzz      += size;
     c->fuzz_size -= size;
     c->pos       += size;
-    c->filesize   = FFMAX(c->filesize, c->pos);
+    c->filesize   = FFMAXI(c->filesize, c->pos);
 
     return size;
 }
diff --git a/tools/target_enc_fuzzer.c b/tools/target_enc_fuzzer.c
index 059d7830710..6610ea6f9b8 100644
--- a/tools/target_enc_fuzzer.c
+++ b/tools/target_enc_fuzzer.c
@@ -99,7 +99,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     case AV_CODEC_ID_A64_MULTI5:        maxpixels  /= 65536;  break;
     }
 
-    maxpixels_per_frame  = FFMIN(maxpixels_per_frame , maxpixels);
+    maxpixels_per_frame  = FFMINI(maxpixels_per_frame , maxpixels);
 
     AVCodecContext* ctx = avcodec_alloc_context3(&c->p);
     if (!ctx)
@@ -183,7 +183,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 
         for (int i=0; i<FF_ARRAY_ELEMS(frame->buf); i++) {
             if (frame->buf[i]) {
-                int buf_size = FFMIN(end-data, frame->buf[i]->size);
+                int buf_size = FFMINI(end-data, frame->buf[i]->size);
                 memcpy(frame->buf[i]->data, data, buf_size);
                 memset(frame->buf[i]->data + buf_size, 0, frame->buf[i]->size - buf_size);
                 data += buf_size;
-- 
2.49.0



More information about the ffmpeg-devel mailing list