]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ppc/mpegvideo_altivec.c
Add stereo rematrixing support to the AC-3 encoders.
[ffmpeg] / libavcodec / ppc / mpegvideo_altivec.c
index f2e4fae09235bf738a3ea37bb9d8b2ce5dbadd72..64898a10d0fb57cc995c2599e18a19cb26bffc9b 100644 (file)
 
 #include <stdlib.h>
 #include <stdio.h>
+#include "libavutil/cpu.h"
 #include "libavcodec/dsputil.h"
 #include "libavcodec/mpegvideo.h"
 
-#include "gcc_fixes.h"
-
-#include "dsputil_ppc.h"
 #include "util_altivec.h"
+#include "types_altivec.h"
+#include "dsputil_altivec.h"
+
 // Swaps two variables (used for altivec registers)
 #define SWAP(a,b) \
 do { \
@@ -66,9 +67,9 @@ do { \
 }
 
 
-#define FOUROF(a) AVV(a,a,a,a)
+#define FOUROF(a) {a,a,a,a}
 
-int dct_quantize_altivec(MpegEncContext* s,
+static int dct_quantize_altivec(MpegEncContext* s,
                          DCTELEM* data, int n,
                          int qscale, int* overflow)
 {
@@ -475,17 +476,14 @@ int dct_quantize_altivec(MpegEncContext* s,
 
 /* AltiVec version of dct_unquantize_h263
    this code assumes `block' is 16 bytes-aligned */
-void dct_unquantize_h263_altivec(MpegEncContext *s,
+static void dct_unquantize_h263_altivec(MpegEncContext *s,
                                  DCTELEM *block, int n, int qscale)
 {
-POWERPC_PERF_DECLARE(altivec_dct_unquantize_h263_num, 1);
     int i, level, qmul, qadd;
     int nCoeffs;
 
     assert(s->block_last_index[n]>=0);
 
-POWERPC_PERF_START_COUNT(altivec_dct_unquantize_h263_num, 1);
-
     qadd = (qscale - 1) | 1;
     qmul = qscale << 1;
 
@@ -506,29 +504,16 @@ POWERPC_PERF_START_COUNT(altivec_dct_unquantize_h263_num, 1);
 
     {
         register const vector signed short vczero = (const vector signed short)vec_splat_s16(0);
-        DECLARE_ALIGNED_16(short, qmul8[]) =
-            {
-              qmul, qmul, qmul, qmul,
-              qmul, qmul, qmul, qmul
-            };
-        DECLARE_ALIGNED_16(short, qadd8[]) =
-            {
-              qadd, qadd, qadd, qadd,
-              qadd, qadd, qadd, qadd
-            };
-        DECLARE_ALIGNED_16(short, nqadd8[]) =
-            {
-              -qadd, -qadd, -qadd, -qadd,
-              -qadd, -qadd, -qadd, -qadd
-            };
+        DECLARE_ALIGNED(16, short, qmul8) = qmul;
+        DECLARE_ALIGNED(16, short, qadd8) = qadd;
         register vector signed short blockv, qmulv, qaddv, nqaddv, temp1;
         register vector bool short blockv_null, blockv_neg;
         register short backup_0 = block[0];
         register int j = 0;
 
-        qmulv = vec_ld(0, qmul8);
-        qaddv = vec_ld(0, qadd8);
-        nqaddv = vec_ld(0, nqadd8);
+        qmulv = vec_splat((vec_s16)vec_lde(0, &qmul8), 0);
+        qaddv = vec_splat((vec_s16)vec_lde(0, &qadd8), 0);
+        nqaddv = vec_sub(vczero, qaddv);
 
 #if 0   // block *is* 16 bytes-aligned, it seems.
         // first make sure block[j] is 16 bytes-aligned
@@ -581,16 +566,12 @@ POWERPC_PERF_START_COUNT(altivec_dct_unquantize_h263_num, 1);
             block[0] = backup_0;
         }
     }
-POWERPC_PERF_STOP_COUNT(altivec_dct_unquantize_h263_num, nCoeffs == 63);
 }
 
 
-extern void idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
-extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
-
 void MPV_common_init_altivec(MpegEncContext *s)
 {
-    if ((mm_flags & MM_ALTIVEC) == 0) return;
+    if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return;
 
     if (s->avctx->lowres==0) {
         if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||