changeset 12473:06abedae2906 libavcodec

Merge has_altivec() function into mm_support(), remove it and use mm_support() instead. Reduce complexity and simplify pending move to libavutil.
author stefano
date Wed, 08 Sep 2010 10:02:40 +0000
parents 9c9be94124f8
children cf54b8e98e7a
files ppc/check_altivec.c ppc/dsputil_altivec.h ppc/dsputil_ppc.c ppc/h264_altivec.c ppc/mpegvideo_altivec.c ppc/vp8dsp_altivec.c
diffstat 6 files changed, 15 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ppc/check_altivec.c	Wed Sep 08 05:51:31 2010 +0000
+++ b/ppc/check_altivec.c	Wed Sep 08 10:02:40 2010 +0000
@@ -43,14 +43,16 @@
  * is present.
  */
 
-int has_altivec(void)
+int mm_support(void)
 {
+#if HAVE_ALTIVEC
 #ifdef __AMIGAOS4__
     ULONG result = 0;
     extern struct ExecIFace *IExec;
 
     IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);
-    if (result == VECTORTYPE_ALTIVEC) return 1;
+    if (result == VECTORTYPE_ALTIVEC)
+        return AV_CPU_FLAG_ALTIVEC;
     return 0;
 #elif defined(__APPLE__) || defined(__OpenBSD__)
 #ifdef __OpenBSD__
@@ -64,7 +66,8 @@
 
     err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
 
-    if (err == 0) return has_vu != 0;
+    if (err == 0)
+        return has_vu ? AV_CPU_FLAG_ALTIVEC : 0;
     return 0;
 #elif CONFIG_RUNTIME_CPUDETECT
     int proc_ver;
@@ -76,12 +79,14 @@
         proc_ver == 0x0039 || proc_ver == 0x003c ||
         proc_ver == 0x0044 || proc_ver == 0x0045 ||
         proc_ver == 0x0070)
-        return 1;
+        return AV_CPU_FLAG_ALTIVEC;
     return 0;
 #else
     // Since we were compiled for AltiVec, just assume we have it
     // until someone comes up with a proper way (not involving signal hacks).
-    return 1;
+    return AV_CPU_FLAG_ALTIVEC;
 #endif /* __AMIGAOS4__ */
+#endif /* HAVE_ALTIVEC */
+    return 0;
 }
 
--- a/ppc/dsputil_altivec.h	Wed Sep 08 05:51:31 2010 +0000
+++ b/ppc/dsputil_altivec.h	Wed Sep 08 10:02:40 2010 +0000
@@ -30,8 +30,6 @@
 
 void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
 
-int has_altivec(void);
-
 void fdct_altivec(int16_t *block);
 void gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h,
                   int x16, int y16, int rounder);
--- a/ppc/dsputil_ppc.c	Wed Sep 08 05:51:31 2010 +0000
+++ b/ppc/dsputil_ppc.c	Wed Sep 08 10:02:40 2010 +0000
@@ -23,17 +23,6 @@
 #include "libavcodec/dsputil.h"
 #include "dsputil_altivec.h"
 
-int mm_support(void)
-{
-    int result = 0;
-#if HAVE_ALTIVEC
-    if (has_altivec()) {
-        result |= AV_CPU_FLAG_ALTIVEC;
-    }
-#endif /* result */
-    return result;
-}
-
 /* ***** WARNING ***** WARNING ***** WARNING ***** */
 /*
 clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with a
@@ -179,7 +168,7 @@
 #if HAVE_ALTIVEC
     if(CONFIG_H264_DECODER) dsputil_h264_init_ppc(c, avctx);
 
-    if (has_altivec()) {
+    if (mm_support() & AV_CPU_FLAG_ALTIVEC) {
         dsputil_init_altivec(c, avctx);
         if(CONFIG_VC1_DECODER)
             vc1dsp_init_altivec(c, avctx);
--- a/ppc/h264_altivec.c	Wed Sep 08 05:51:31 2010 +0000
+++ b/ppc/h264_altivec.c	Wed Sep 08 10:02:40 2010 +0000
@@ -969,7 +969,7 @@
 
 void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
 
-    if (has_altivec()) {
+    if (mm_support() & AV_CPU_FLAG_ALTIVEC) {
         c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
         c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
         c->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec;
@@ -1001,7 +1001,7 @@
 
 void ff_h264dsp_init_ppc(H264DSPContext *c)
 {
-    if (has_altivec()) {
+    if (mm_support() & AV_CPU_FLAG_ALTIVEC) {
         c->h264_idct_add = ff_h264_idct_add_altivec;
         c->h264_idct_add8 = ff_h264_idct_add8_altivec;
         c->h264_idct_add16 = ff_h264_idct_add16_altivec;
--- a/ppc/mpegvideo_altivec.c	Wed Sep 08 05:51:31 2010 +0000
+++ b/ppc/mpegvideo_altivec.c	Wed Sep 08 10:02:40 2010 +0000
@@ -570,7 +570,7 @@
 
 void MPV_common_init_altivec(MpegEncContext *s)
 {
-    if (!has_altivec()) return;
+    if (!(mm_support() & AV_CPU_FLAG_ALTIVEC)) return;
 
     if (s->avctx->lowres==0) {
         if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
--- a/ppc/vp8dsp_altivec.c	Wed Sep 08 05:51:31 2010 +0000
+++ b/ppc/vp8dsp_altivec.c	Wed Sep 08 10:02:40 2010 +0000
@@ -265,7 +265,7 @@
 
 av_cold void ff_vp8dsp_init_altivec(VP8DSPContext *c)
 {
-    if (!has_altivec())
+    if (!(mm_support() & AV_CPU_FLAG_ALTIVEC))
         return;
 
     c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;