00001 /* 00002 * H.264/MPEG-4 Part 10 (Base profile) encoder. 00003 * 00004 * DSP functions 00005 * 00006 * Copyright (c) 2006 Expertisecentrum Digitale Media, UHasselt 00007 * 00008 * FFmpeg is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * FFmpeg is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with FFmpeg; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00029 #include "dsputil.h" 00030 00031 extern const uint8_t ff_div6[52]; 00032 extern const uint8_t ff_rem6[52]; 00033 00034 #define H264_DCT_PART1(X) \ 00035 a = block[0][X]+block[3][X]; \ 00036 c = block[0][X]-block[3][X]; \ 00037 b = block[1][X]+block[2][X]; \ 00038 d = block[1][X]-block[2][X]; \ 00039 pieces[0][X] = a+b; \ 00040 pieces[2][X] = a-b; \ 00041 pieces[1][X] = (c<<1)+d; \ 00042 pieces[3][X] = c-(d<<1); 00043 00044 #define H264_DCT_PART2(X) \ 00045 a = pieces[X][0]+pieces[X][3]; \ 00046 c = pieces[X][0]-pieces[X][3]; \ 00047 b = pieces[X][1]+pieces[X][2]; \ 00048 d = pieces[X][1]-pieces[X][2]; \ 00049 block[0][X] = a+b; \ 00050 block[2][X] = a-b; \ 00051 block[1][X] = (c<<1)+d; \ 00052 block[3][X] = c-(d<<1); 00053 00062 static void h264_dct_c(DCTELEM block[4][4]) 00063 { 00064 DCTELEM pieces[4][4]; 00065 DCTELEM a, b, c, d; 00066 00067 H264_DCT_PART1(0); 00068 H264_DCT_PART1(1); 00069 H264_DCT_PART1(2); 00070 H264_DCT_PART1(3); 00071 H264_DCT_PART2(0); 00072 H264_DCT_PART2(1); 00073 H264_DCT_PART2(2); 00074 H264_DCT_PART2(3); 00075 } 00076 00077 void ff_h264dspenc_init(DSPContext* c, AVCodecContext *avctx) 00078 { 00079 c->h264_dct = h264_dct_c; 00080 } 00081