Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
motion_comp.c
Go to the documentation of this file.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 "mpeg2_internal.h"
00030 
00031 mpeg2_mc_t mpeg2_mc;
00032 
00033 void mpeg2_mc_init (uint32_t accel)
00034 {
00035 #ifdef ARCH_X86
00036     if (accel & MPEG2_ACCEL_X86_MMXEXT)
00037         mpeg2_mc = mpeg2_mc_mmxext;
00038     else if (accel & MPEG2_ACCEL_X86_3DNOW)
00039         mpeg2_mc = mpeg2_mc_3dnow;
00040     else if (accel & MPEG2_ACCEL_X86_MMX)
00041         mpeg2_mc = mpeg2_mc_mmx;
00042     else
00043 #endif
00044 #ifdef ARCH_PPC
00045     if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
00046         mpeg2_mc = mpeg2_mc_altivec;
00047     else
00048 #endif
00049 #ifdef ARCH_ALPHA
00050     if (accel & MPEG2_ACCEL_ALPHA)
00051         mpeg2_mc = mpeg2_mc_alpha;
00052     else
00053 #endif
00054 #ifdef LIBMPEG2_MLIB
00055     if (accel & MPEG2_ACCEL_MLIB)
00056         mpeg2_mc = mpeg2_mc_mlib;
00057     else
00058 #endif
00059         mpeg2_mc = mpeg2_mc_c;
00060 }
00061 
00062 #define avg2(a,b) ((a+b+1)>>1)
00063 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
00064 
00065 #define predict_o(i) (ref[i])
00066 #define predict_x(i) (avg2 (ref[i], ref[i+1]))
00067 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
00068 #define predict_xy(i) (avg4 (ref[i], ref[i+1], \
00069                              (ref+stride)[i], (ref+stride)[i+1]))
00070 
00071 #define put(predictor,i) dest[i] = predictor (i)
00072 #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
00073 
00074 
00075 
00076 #define MC_FUNC(op,xy)                                                  \
00077 static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
00078                                    const int stride, int height)        \
00079 {                                                                       \
00080     do {                                                                \
00081         op (predict_##xy, 0);                                           \
00082         op (predict_##xy, 1);                                           \
00083         op (predict_##xy, 2);                                           \
00084         op (predict_##xy, 3);                                           \
00085         op (predict_##xy, 4);                                           \
00086         op (predict_##xy, 5);                                           \
00087         op (predict_##xy, 6);                                           \
00088         op (predict_##xy, 7);                                           \
00089         op (predict_##xy, 8);                                           \
00090         op (predict_##xy, 9);                                           \
00091         op (predict_##xy, 10);                                          \
00092         op (predict_##xy, 11);                                          \
00093         op (predict_##xy, 12);                                          \
00094         op (predict_##xy, 13);                                          \
00095         op (predict_##xy, 14);                                          \
00096         op (predict_##xy, 15);                                          \
00097         ref += stride;                                                  \
00098         dest += stride;                                                 \
00099     } while (--height);                                                 \
00100 }                                                                       \
00101 static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref,  \
00102                                   const int stride, int height)         \
00103 {                                                                       \
00104     do {                                                                \
00105         op (predict_##xy, 0);                                           \
00106         op (predict_##xy, 1);                                           \
00107         op (predict_##xy, 2);                                           \
00108         op (predict_##xy, 3);                                           \
00109         op (predict_##xy, 4);                                           \
00110         op (predict_##xy, 5);                                           \
00111         op (predict_##xy, 6);                                           \
00112         op (predict_##xy, 7);                                           \
00113         ref += stride;                                                  \
00114         dest += stride;                                                 \
00115     } while (--height);                                                 \
00116 }
00117 
00118 
00119 
00120 MC_FUNC (put,o)
00121 MC_FUNC (avg,o)
00122 MC_FUNC (put,x)
00123 MC_FUNC (avg,x)
00124 MC_FUNC (put,y)
00125 MC_FUNC (avg,y)
00126 MC_FUNC (put,xy)
00127 MC_FUNC (avg,xy)
00128 
00129 MPEG2_MC_EXTERN (c)