aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2009-01-18 22:57:40 +0000
committerAurelien Jacobs <aurel@gnuage.org>2009-01-18 22:57:40 +0000
commit199436b952c198e14d53a389438e232ef60f1982 (patch)
treea4f1f4426da39f1af73f474f8df7c430025a2044
parent48a81c0ff591347e58b9402534c5cf596ddf0072 (diff)
downloadffmpeg-199436b952c198e14d53a389438e232ef60f1982.tar.gz
moves mid_pred() into mathops.h (with arch specific code split by directory)
Originally committed as revision 16681 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/cavs.c1
-rw-r--r--libavcodec/dsputil.c1
-rw-r--r--libavcodec/ffv1.c1
-rw-r--r--libavcodec/h263.c1
-rw-r--r--libavcodec/h264.c1
-rw-r--r--libavcodec/huffyuv.c1
-rw-r--r--libavcodec/jpeglsdec.c1
-rw-r--r--libavcodec/jpeglsenc.c1
-rw-r--r--libavcodec/loco.c1
-rw-r--r--libavcodec/mathops.h30
-rw-r--r--libavcodec/motion_est.c1
-rw-r--r--libavcodec/roqvideoenc.c1
-rw-r--r--libavcodec/rv34.c1
-rw-r--r--libavcodec/snow.c1
-rw-r--r--libavcodec/svq1dec.c1
-rw-r--r--libavcodec/vc1.c1
-rw-r--r--libavcodec/wmv2dec.c1
-rw-r--r--libavcodec/x86/dsputilenc_mmx.c1
-rw-r--r--libavcodec/x86/mathops.h24
-rw-r--r--libavutil/common.h41
20 files changed, 71 insertions, 41 deletions
diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index b8308110f6..829d4a0c66 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 795e2079a3..d53bbed395 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 25007f51a5..6c7d895e3a 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 5f151bfd71..dc3ae07c60 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 <assert.h>
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 6399b4fa51..8b023f635c 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 c494f355bf..7bb825bb0c 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 7842759996..02e15841fb 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 f799550b31..14a81bee17 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 ad5737ec5b..0bd356f633 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 9ef62cfb31..33e8cd6aec 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 d9d48a643e..b960e88025 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -32,6 +32,7 @@
#include <limits.h>
#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 3b405ccc90..a5622cd6fe 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 450327e14d..8a14e08e76 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 3f8783be02..b4a0d5a8fd 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 d306149007..fe1d7edaf7 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 433df7b07b..dee0adcd98 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 <assert.h>
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 696d73bcce..e5d8269e0f 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 d45dfabe21..d1ee1114cf 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 95377acab8..6bd4b17705 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 f9ab84417a..f701d233ca 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