diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index b8308110f64b67767647439f559883e996c71c24..829d4a0c660ee1bab7477d2d6ff1e038d354cd6e 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "bitstream.h" #include "golomb.h" +#include "mathops.h" #include "cavs.h" #include "cavsdata.h" diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 795e2079a3acc02ce123053648f4c94c8768a14b..d53bbed395b79a1f2efc2409f535d770c57352b3 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -32,6 +32,7 @@ #include "simple_idct.h" #include "faandct.h" #include "faanidct.h" +#include "mathops.h" #include "h263.h" #include "snow.h" diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 25007f51a5038269ede0b13ec0e139a79b1fd800..6c7d895e3a6a62926ad39ee47b4a37d0c0999848 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -30,6 +30,7 @@ #include "dsputil.h" #include "rangecoder.h" #include "golomb.h" +#include "mathops.h" #define MAX_PLANES 4 #define CONTEXT_SIZE 32 diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 5f151bfd71c38fcfdb0ddd3dad116f3d0dbce1ba..dc3ae07c60e8dbd3c3ad247a84258404a13a64cf 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -39,6 +39,7 @@ #include "mpegvideo.h" #include "h263data.h" #include "mpeg4data.h" +#include "mathops.h" //#undef NDEBUG //#include diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 6399b4fa51d4ccd603239dccee12a2f06aa5b0c6..8b023f635c5d841cc441af48c6ac9be0e9916dbc 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -32,6 +32,7 @@ #include "h264data.h" #include "h264_parser.h" #include "golomb.h" +#include "mathops.h" #include "rectangle.h" #include "vdpau_internal.h" diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index c494f355bf990dbfb1a89c2fbec8fe27c7d39deb..7bb825bb0cd8360ad0b36351ed09731c504efa72 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "bitstream.h" #include "dsputil.h" +#include "mathops.h" #define VLC_BITS 11 diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 7842759996350be36300ae1e7bd05a8fd79dd12e..02e15841fb21d161b2313cb931f65ab327399d42 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "bitstream.h" #include "golomb.h" +#include "mathops.h" #include "mjpeg.h" #include "mjpegdec.h" #include "jpegls.h" diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index f799550b315034adcbb2821aa8e175ae2aabdc09..14a81bee172a3eab17d4bcc15de3330879142dac 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "bitstream.h" #include "golomb.h" +#include "mathops.h" #include "dsputil.h" #include "mjpeg.h" #include "jpegls.h" diff --git a/libavcodec/loco.c b/libavcodec/loco.c index ad5737ec5b625bfc36c03fae995669dc3d31b5ba..0bd356f6330cbaf9b39e16d782a5193649c9060c 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -27,6 +27,7 @@ #include "avcodec.h" #include "bitstream.h" #include "golomb.h" +#include "mathops.h" enum LOCO_MODE {LOCO_UNKN=0, LOCO_CYUY2=-1, LOCO_CRGB=-2, LOCO_CRGBA=-3, LOCO_CYV12=-4, LOCO_YUY2=1, LOCO_UYVY=2, LOCO_RGB=3, LOCO_RGBA=4, LOCO_YV12=5}; diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index 9ef62cfb3181d3089cf4133642eaebf04d8ff6ee..33e8cd6aec71e5212b162eb478ed5b29a739088e 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -83,5 +83,35 @@ static av_always_inline int MULH(int a, int b){ # define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb)) #endif +/* median of 3 */ +#ifndef mid_pred +#define mid_pred mid_pred +static inline av_const int mid_pred(int a, int b, int c) +{ +#if 0 + int t= (a-b)&((a-b)>>31); + a-=t; + b+=t; + b-= (b-c)&((b-c)>>31); + b+= (a-b)&((a-b)>>31); + + return b; +#else + if(a>b){ + if(c>b){ + if(c>a) b=a; + else b=c; + } + }else{ + if(b>c){ + if(c>a) b=c; + else b=a; + } + } + return b; +#endif +} +#endif + #endif /* AVCODEC_MATHOPS_H */ diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index d9d48a643e5bec4d21928ab0df104ec023a6f82d..b960e8802562923550e589be65894a6a3a3a399a 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -32,6 +32,7 @@ #include #include "avcodec.h" #include "dsputil.h" +#include "mathops.h" #include "mpegvideo.h" #undef NDEBUG diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 3b405ccc90b1518d337fa1b4e8e121583f6d5057..a5622cd6fee2058be9f8e463818d1a0e0759fcf8 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -60,6 +60,7 @@ #include "roqvideo.h" #include "bytestream.h" #include "elbg.h" +#include "mathops.h" #define CHROMA_BIAS 1 diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 450327e14ddac501243364e594936399eb21d95e..8a14e08e76597fdb2025e2bf582d296514b2bd98 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -28,6 +28,7 @@ #include "dsputil.h" #include "mpegvideo.h" #include "golomb.h" +#include "mathops.h" #include "rectangle.h" #include "rv34vlc.h" diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 3f8783be02912a9cf88b09f77afb5052f19ee946..b4a0d5a8fd42b22077a5d8ec0df3e5f41fe44495 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -23,6 +23,7 @@ #include "snow.h" #include "rangecoder.h" +#include "mathops.h" #include "mpegvideo.h" diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index d306149007f528b96b46b05bc3f20ed3a187d4b7..fe1d7edaf7558b9ecb063995c37a277a9d5d2ad8 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -37,6 +37,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "mathops.h" #include "svq1.h" diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 433df7b07b18ee3842c39f1524c4a58897f74dfe..dee0adcd98cb97ffd8595e168624d3360eb5abcd 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -34,6 +34,7 @@ #include "msmpeg4data.h" #include "unary.h" #include "simple_idct.h" +#include "mathops.h" #undef NDEBUG #include diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 696d73bccef1fdbb8f3fde371a38eada23411f65..e5d8269e0fcfa99467c95cdb52d167ba8a92e9ad 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "mathops.h" #include "msmpeg4.h" #include "msmpeg4data.h" #include "intrax8.h" diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c index d45dfabe211605fda29a7681cf4173648497eabb..d1ee1114cf1dc1dd1b2cbdb1d061e1449ebd8c39 100644 --- a/libavcodec/x86/dsputilenc_mmx.c +++ b/libavcodec/x86/dsputilenc_mmx.c @@ -25,6 +25,7 @@ #include "libavutil/x86_cpu.h" #include "libavcodec/dsputil.h" #include "libavcodec/mpegvideo.h" +#include "libavcodec/mathops.h" #include "dsputil_mmx.h" diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 95377acab8022074e5a1ada15ff5b6dc55ab5e25..6bd4b17705d02c5bad2a292444cd378b65fc14ec 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -22,6 +22,9 @@ #ifndef AVCODEC_X86_MATHOPS_H #define AVCODEC_X86_MATHOPS_H +#include "config.h" +#include "libavutil/common.h" + #define MULL(ra, rb, shift) \ ({ int rt, dummy; __asm__ (\ "imull %3 \n\t"\ @@ -40,4 +43,25 @@ __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)ra), "g" ((int)rb));\ rt; }) +#if HAVE_CMOV +/* median of 3 */ +#define mid_pred mid_pred +static inline av_const int mid_pred(int a, int b, int c) +{ + int i=b; + __asm__ volatile( + "cmp %2, %1 \n\t" + "cmovg %1, %0 \n\t" + "cmovg %2, %1 \n\t" + "cmp %3, %1 \n\t" + "cmovl %3, %1 \n\t" + "cmp %1, %0 \n\t" + "cmovg %1, %0 \n\t" + :"+&r"(i), "+&r"(a) + :"r"(b), "r"(c) + ); + return i; +} +#endif + #endif /* AVCODEC_X86_MATHOPS_H */ diff --git a/libavutil/common.h b/libavutil/common.h index f9ab84417a0390ade955ca6355c77720c1fc0de5..f701d233ca9e6150f66c65c9f91256dc19177a32 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -151,47 +151,6 @@ static inline av_const int av_log2_16bit(unsigned int v) return n; } -/* median of 3 */ -static inline av_const int mid_pred(int a, int b, int c) -{ -#if HAVE_CMOV - int i=b; - __asm__ volatile( - "cmp %2, %1 \n\t" - "cmovg %1, %0 \n\t" - "cmovg %2, %1 \n\t" - "cmp %3, %1 \n\t" - "cmovl %3, %1 \n\t" - "cmp %1, %0 \n\t" - "cmovg %1, %0 \n\t" - :"+&r"(i), "+&r"(a) - :"r"(b), "r"(c) - ); - return i; -#elif 0 - int t= (a-b)&((a-b)>>31); - a-=t; - b+=t; - b-= (b-c)&((b-c)>>31); - b+= (a-b)&((a-b)>>31); - - return b; -#else - if(a>b){ - if(c>b){ - if(c>a) b=a; - else b=c; - } - }else{ - if(b>c){ - if(c>a) b=c; - else b=a; - } - } - return b; -#endif -} - /** * clip a signed integer value into the amin-amax range * @param a value to clip