00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "config.h"
00025
00026 #include <inttypes.h>
00027
00028 #include "mpeg2.h"
00029 #include "attributes.h"
00030 #include "mpeg2_internal.h"
00031
00032 mpeg2_mc_t mpeg2_mc;
00033
00034 void mpeg2_mc_init (uint32_t accel)
00035 {
00036 #ifdef ARCH_X86
00037 #ifdef MMX
00038 if (accel & MPEG2_ACCEL_X86_MMXEXT)
00039 mpeg2_mc = mpeg2_mc_mmxext;
00040 else if (accel & MPEG2_ACCEL_X86_3DNOW)
00041 mpeg2_mc = mpeg2_mc_3dnow;
00042 else if (accel & MPEG2_ACCEL_X86_MMX)
00043 mpeg2_mc = mpeg2_mc_mmx;
00044 else
00045 #endif
00046 #endif
00047 #ifdef HAVE_ALTIVEC
00048 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
00049 mpeg2_mc = mpeg2_mc_altivec;
00050 else
00051 #endif
00052 #ifdef ARCH_ALPHA
00053 if (accel & MPEG2_ACCEL_ALPHA)
00054 mpeg2_mc = mpeg2_mc_alpha;
00055 else
00056 #endif
00057 #ifdef ARCH_SPARC
00058 if (accel & MPEG2_ACCEL_SPARC_VIS)
00059 mpeg2_mc = mpeg2_mc_vis;
00060 else
00061 #endif
00062 mpeg2_mc = mpeg2_mc_c;
00063 }
00064
00065 #define avg2(a,b) ((a+b+1)>>1)
00066 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
00067
00068 #define predict_o(i) (ref[i])
00069 #define predict_x(i) (avg2 (ref[i], ref[i+1]))
00070 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
00071 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \
00072 (ref+stride)[i], (ref+stride)[i+1]))
00073
00074 #define put(predictor,i) dest[i] = predictor (i)
00075 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
00076
00077
00078
00079 #define MC_FUNC(op,xy) \
00080 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
00081 const int stride, int height) \
00082 { \
00083 do { \
00084 op (predict_##xy, 0); \
00085 op (predict_##xy, 1); \
00086 op (predict_##xy, 2); \
00087 op (predict_##xy, 3); \
00088 op (predict_##xy, 4); \
00089 op (predict_##xy, 5); \
00090 op (predict_##xy, 6); \
00091 op (predict_##xy, 7); \
00092 op (predict_##xy, 8); \
00093 op (predict_##xy, 9); \
00094 op (predict_##xy, 10); \
00095 op (predict_##xy, 11); \
00096 op (predict_##xy, 12); \
00097 op (predict_##xy, 13); \
00098 op (predict_##xy, 14); \
00099 op (predict_##xy, 15); \
00100 ref += stride; \
00101 dest += stride; \
00102 } while (--height); \
00103 } \
00104 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
00105 const int stride, int height) \
00106 { \
00107 do { \
00108 op (predict_##xy, 0); \
00109 op (predict_##xy, 1); \
00110 op (predict_##xy, 2); \
00111 op (predict_##xy, 3); \
00112 op (predict_##xy, 4); \
00113 op (predict_##xy, 5); \
00114 op (predict_##xy, 6); \
00115 op (predict_##xy, 7); \
00116 ref += stride; \
00117 dest += stride; \
00118 } while (--height); \
00119 }
00120
00121
00122
00123 MC_FUNC (put,o)
00124 MC_FUNC (avg,o)
00125 MC_FUNC (put,x)
00126 MC_FUNC (avg,x)
00127 MC_FUNC (put,y)
00128 MC_FUNC (avg,y)
00129 MC_FUNC (put,xy)
00130 MC_FUNC (avg,xy)
00131
00132 MPEG2_MC_EXTERN (c)