00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00028 #include <stdint.h>
00029 #include "libavutil/avassert.h"
00030 #include "avcodec.h"
00031 #include "h264dsp.h"
00032 #include "libavutil/common.h"
00033 
00034 #define BIT_DEPTH 8
00035 #include "h264dsp_template.c"
00036 #undef BIT_DEPTH
00037 
00038 #define BIT_DEPTH 9
00039 #include "h264dsp_template.c"
00040 #undef BIT_DEPTH
00041 
00042 #define BIT_DEPTH 10
00043 #include "h264dsp_template.c"
00044 #undef BIT_DEPTH
00045 
00046 #define BIT_DEPTH 12
00047 #include "h264dsp_template.c"
00048 #undef BIT_DEPTH
00049 
00050 #define BIT_DEPTH 14
00051 #include "h264dsp_template.c"
00052 #undef BIT_DEPTH
00053 
00054 void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
00055 {
00056 #undef FUNC
00057 #define FUNC(a, depth) a ## _ ## depth ## _c
00058 
00059 #define H264_DSP(depth) \
00060     c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
00061     c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\
00062     c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\
00063     c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
00064     c->h264_idct_add16     = FUNC(ff_h264_idct_add16, depth);\
00065     c->h264_idct8_add4     = FUNC(ff_h264_idct8_add4, depth);\
00066     if (chroma_format_idc == 1)\
00067         c->h264_idct_add8  = FUNC(ff_h264_idct_add8, depth);\
00068     else\
00069         c->h264_idct_add8  = FUNC(ff_h264_idct_add8_422, depth);\
00070     c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
00071     c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
00072     if (chroma_format_idc == 1)\
00073         c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
00074     else\
00075         c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
00076 \
00077     c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\
00078     c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\
00079     c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\
00080     c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\
00081     c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\
00082     c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\
00083     c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\
00084     c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\
00085 \
00086     c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\
00087     c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\
00088     c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
00089     c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\
00090     c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
00091     c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
00092     c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
00093     if (chroma_format_idc == 1)\
00094         c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
00095     else\
00096         c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
00097     if (chroma_format_idc == 1)\
00098         c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
00099     else\
00100         c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
00101     c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
00102     if (chroma_format_idc == 1)\
00103         c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
00104     else\
00105         c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
00106     if (chroma_format_idc == 1)\
00107         c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
00108     else\
00109         c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
00110     c->h264_loop_filter_strength= NULL;
00111 
00112     switch (bit_depth) {
00113     case 9:
00114         H264_DSP(9);
00115         break;
00116     case 10:
00117         H264_DSP(10);
00118         break;
00119     case 12:
00120         H264_DSP(12);
00121         break;
00122     case 14:
00123         H264_DSP(14);
00124         break;
00125     default:
00126         av_assert0(bit_depth<=8);
00127         H264_DSP(8);
00128         break;
00129     }
00130 
00131     if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
00132     if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
00133     if (HAVE_MMX) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);
00134 }