/src/ffmpeg/libavcodec/h264qpel.c
Line | Count | Source |
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 "libavutil/attributes.h" |
23 | | #include "libavutil/common.h" |
24 | | #include "h264qpel.h" |
25 | | |
26 | 9.15M | #define pixeltmp int16_t |
27 | 7.41M | #define BIT_DEPTH 8 |
28 | | #include "h264qpel_template.c" |
29 | | #undef BIT_DEPTH |
30 | | |
31 | 1.10G | #define BIT_DEPTH 9 |
32 | | #include "h264qpel_template.c" |
33 | | #undef BIT_DEPTH |
34 | | |
35 | 1.83G | #define BIT_DEPTH 10 |
36 | | #include "h264qpel_template.c" |
37 | | #undef BIT_DEPTH |
38 | | #undef pixeltmp |
39 | | |
40 | 2.61M | #define pixeltmp int32_t |
41 | 907M | #define BIT_DEPTH 12 |
42 | | #include "h264qpel_template.c" |
43 | | #undef BIT_DEPTH |
44 | | |
45 | 803M | #define BIT_DEPTH 14 |
46 | | #include "h264qpel_template.c" |
47 | | #undef BIT_DEPTH |
48 | | |
49 | | |
50 | | av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth) |
51 | 610k | { |
52 | 610k | #undef FUNCC |
53 | 58.5M | #define FUNCC(f, depth) f ## _ ## depth ## _c |
54 | | |
55 | 610k | #define dspfunc2(PFX, IDX, NUM, depth) \ |
56 | 3.66M | c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth); \ |
57 | 3.66M | c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth); \ |
58 | 3.66M | c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth); \ |
59 | 3.66M | c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth); \ |
60 | 3.66M | c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth); \ |
61 | 3.66M | c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth); \ |
62 | 3.66M | c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth); \ |
63 | 3.66M | c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth); \ |
64 | 3.66M | c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth); \ |
65 | 3.66M | c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth); \ |
66 | 3.66M | c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth); \ |
67 | 3.66M | c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth); \ |
68 | 3.66M | c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth); \ |
69 | 3.66M | c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth); \ |
70 | 3.66M | c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth) |
71 | | |
72 | 610k | #define SET_QPEL(M, depth) \ |
73 | 1.22M | M(put_h264_qpel, 0, 16, depth); \ |
74 | 1.22M | M(put_h264_qpel, 1, 8, depth); \ |
75 | 1.22M | M(put_h264_qpel, 2, 4, depth); \ |
76 | 1.22M | M(avg_h264_qpel, 0, 16, depth); \ |
77 | 1.22M | M(avg_h264_qpel, 1, 8, depth); \ |
78 | 1.22M | M(avg_h264_qpel, 2, 4, depth) |
79 | | |
80 | 3.66M | #define FPEL(PFX, IDX, NUM, depth) c->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## NUM ## _mc00, depth); |
81 | 610k | if (bit_depth <= 8) { |
82 | 1.59M | SET_QPEL(FPEL, 8); |
83 | 344k | } else { |
84 | 2.06M | SET_QPEL(FPEL, 16); |
85 | 344k | } |
86 | | |
87 | 610k | switch (bit_depth) { |
88 | 265k | default: |
89 | 1.59M | SET_QPEL(dspfunc2, 8); |
90 | 265k | break; |
91 | 106k | case 9: |
92 | 638k | SET_QPEL(dspfunc2, 9); |
93 | 106k | break; |
94 | 56.1k | case 10: |
95 | 336k | SET_QPEL(dspfunc2, 10); |
96 | 56.1k | break; |
97 | 106k | case 12: |
98 | 640k | SET_QPEL(dspfunc2, 12); |
99 | 106k | break; |
100 | 75.2k | case 14: |
101 | 451k | SET_QPEL(dspfunc2, 14); |
102 | 75.2k | break; |
103 | 610k | } |
104 | | |
105 | | #if ARCH_AARCH64 |
106 | | ff_h264qpel_init_aarch64(c, bit_depth); |
107 | | #elif ARCH_ARM |
108 | | ff_h264qpel_init_arm(c, bit_depth); |
109 | | #elif ARCH_PPC |
110 | | ff_h264qpel_init_ppc(c, bit_depth); |
111 | | #elif ARCH_RISCV |
112 | | ff_h264qpel_init_riscv(c, bit_depth); |
113 | | #elif ARCH_X86 && HAVE_X86ASM |
114 | | ff_h264qpel_init_x86(c, bit_depth); |
115 | | #elif ARCH_MIPS |
116 | | ff_h264qpel_init_mips(c, bit_depth); |
117 | | #elif ARCH_LOONGARCH64 |
118 | | ff_h264qpel_init_loongarch(c, bit_depth); |
119 | | #endif |
120 | 610k | } |