]> git.sesse.net Git - ffmpeg/blob - libavcodec/h264qpel.c
Merge commit '399663be9d4a839b894c48a21b62926eb8497d72'
[ffmpeg] / libavcodec / h264qpel.c
1 /*
2  * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3  * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #include "h264qpel.h"
23
24 #define pixeltmp int16_t
25 #define BIT_DEPTH 8
26 #include "h264qpel_template.c"
27 #undef BIT_DEPTH
28
29 #define BIT_DEPTH 9
30 #include "h264qpel_template.c"
31 #undef BIT_DEPTH
32
33 #define BIT_DEPTH 10
34 #include "h264qpel_template.c"
35 #undef BIT_DEPTH
36 #undef pixeltmp
37
38 #define pixeltmp int32_t
39 #define BIT_DEPTH 12
40 #include "h264qpel_template.c"
41 #undef BIT_DEPTH
42
43 #define BIT_DEPTH 14
44 #include "h264qpel_template.c"
45 #undef BIT_DEPTH
46
47
48 void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
49 {
50 #undef FUNCC
51 #define FUNCC(f, depth) f ## _ ## depth ## _c
52
53 #define dspfunc2(PFX, IDX, NUM, depth)                                  \
54     c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth); \
55     c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth); \
56     c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth); \
57     c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth); \
58     c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth); \
59     c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth); \
60     c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth); \
61     c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth); \
62     c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth); \
63     c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth); \
64     c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth); \
65     c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth); \
66     c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth); \
67     c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth); \
68     c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth); \
69     c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth)
70
71 #define SET_QPEL(depth)                         \
72     dspfunc2(put_h264_qpel, 0, 16, depth);      \
73     dspfunc2(put_h264_qpel, 1,  8, depth);      \
74     dspfunc2(put_h264_qpel, 2,  4, depth);      \
75     dspfunc2(put_h264_qpel, 3,  2, depth);      \
76     dspfunc2(avg_h264_qpel, 0, 16, depth);      \
77     dspfunc2(avg_h264_qpel, 1,  8, depth);      \
78     dspfunc2(avg_h264_qpel, 2,  4, depth)
79
80     switch (bit_depth) {
81     default:
82         SET_QPEL(8);
83         break;
84     case 9:
85         SET_QPEL(9);
86         break;
87     case 10:
88         SET_QPEL(10);
89         break;
90     case 12:
91         SET_QPEL(12);
92         break;
93     case 14:
94         SET_QPEL(14);
95         break;
96     }
97
98     if (ARCH_ARM)
99         ff_h264qpel_init_arm(c, bit_depth);
100     if (ARCH_PPC)
101         ff_h264qpel_init_ppc(c, bit_depth);
102     if (ARCH_X86)
103         ff_h264qpel_init_x86(c, bit_depth);
104 }