Libav
|
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 #define H264_DCT_PART1(X) \ 00032 a = block[0][X]+block[3][X]; \ 00033 c = block[0][X]-block[3][X]; \ 00034 b = block[1][X]+block[2][X]; \ 00035 d = block[1][X]-block[2][X]; \ 00036 pieces[0][X] = a+b; \ 00037 pieces[2][X] = a-b; \ 00038 pieces[1][X] = (c<<1)+d; \ 00039 pieces[3][X] = c-(d<<1); 00040 00041 #define H264_DCT_PART2(X) \ 00042 a = pieces[X][0]+pieces[X][3]; \ 00043 c = pieces[X][0]-pieces[X][3]; \ 00044 b = pieces[X][1]+pieces[X][2]; \ 00045 d = pieces[X][1]-pieces[X][2]; \ 00046 block[0][X] = a+b; \ 00047 block[2][X] = a-b; \ 00048 block[1][X] = (c<<1)+d; \ 00049 block[3][X] = c-(d<<1); 00050 00059 static void h264_dct_c(DCTELEM block[4][4]) 00060 { 00061 DCTELEM pieces[4][4]; 00062 DCTELEM a, b, c, d; 00063 00064 H264_DCT_PART1(0); 00065 H264_DCT_PART1(1); 00066 H264_DCT_PART1(2); 00067 H264_DCT_PART1(3); 00068 H264_DCT_PART2(0); 00069 H264_DCT_PART2(1); 00070 H264_DCT_PART2(2); 00071 H264_DCT_PART2(3); 00072 } 00073 00074 av_cold void ff_h264dspenc_init(DSPContext* c, AVCodecContext *avctx) 00075 { 00076 c->h264_dct = h264_dct_c; 00077 } 00078