annotate h264dsp.c @ 4350:a3a9e4996276 libavcodec

er and strict also apply to audio theoretically
author michael
date Sun, 14 Jan 2007 23:19:22 +0000
parents 4bfaef73d6ed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4296
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
1 /*
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
2 * H.264/MPEG-4 Part 10 (Base profile) encoder.
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
3 *
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
4 * DSP functions
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
5 *
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
6 * Copyright (c) 2006 Expertisecentrum Digitale Media, UHasselt
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
7 *
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
12 *
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
16 * Lesser General Public License for more details.
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
17 *
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
21 */
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
22
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
23 /**
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
24 * @file h264dsp.c
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
25 * H.264 encoder related DSP utils
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
26 *
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
27 */
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
28
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
29 #include "dsputil.h"
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
30
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
31 extern const uint8_t ff_div6[52];
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
32 extern const uint8_t ff_rem6[52];
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
33
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
34 #define H264_DCT_PART1(X) \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
35 a = block[0][X]+block[3][X]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
36 c = block[0][X]-block[3][X]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
37 b = block[1][X]+block[2][X]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
38 d = block[1][X]-block[2][X]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
39 pieces[0][X] = a+b; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
40 pieces[2][X] = a-b; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
41 pieces[1][X] = (c<<1)+d; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
42 pieces[3][X] = c-(d<<1);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
43
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
44 #define H264_DCT_PART2(X) \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
45 a = pieces[X][0]+pieces[X][3]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
46 c = pieces[X][0]-pieces[X][3]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
47 b = pieces[X][1]+pieces[X][2]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
48 d = pieces[X][1]-pieces[X][2]; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
49 block[0][X] = a+b; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
50 block[2][X] = a-b; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
51 block[1][X] = (c<<1)+d; \
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
52 block[3][X] = c-(d<<1);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
53
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
54 /**
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
55 * Transform the provided matrix using the H.264 modified DCT.
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
56 * @note
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
57 * we'll always work with transposed input blocks, to avoid having to make a
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
58 * distinction between C and mmx implementations.
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
59 *
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
60 * @param block transposed input block
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
61 */
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
62 static void h264_dct_c(DCTELEM block[4][4])
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
63 {
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
64 DCTELEM pieces[4][4];
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
65 DCTELEM a, b, c, d;
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
66
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
67 H264_DCT_PART1(0);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
68 H264_DCT_PART1(1);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
69 H264_DCT_PART1(2);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
70 H264_DCT_PART1(3);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
71 H264_DCT_PART2(0);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
72 H264_DCT_PART2(1);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
73 H264_DCT_PART2(2);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
74 H264_DCT_PART2(3);
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
75 }
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
76
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
77 void ff_h264dsp_init(DSPContext* c, AVCodecContext *avctx)
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
78 {
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
79 c->h264_dct = h264_dct_c;
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
80 }
4bfaef73d6ed Adding H.264 DCT.
takis
parents:
diff changeset
81