Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | * HEVC video Decoder |
||
3 | * |
||
4 | * Copyright (C) 2012 - 2013 Guillaume Martres |
||
5 | * |
||
6 | * This file is part of FFmpeg. |
||
7 | * |
||
8 | * FFmpeg is free software; you can redistribute it and/or |
||
9 | * modify it under the terms of the GNU Lesser General Public |
||
10 | * License as published by the Free Software Foundation; either |
||
11 | * version 2.1 of the License, or (at your option) any later version. |
||
12 | * |
||
13 | * FFmpeg is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
16 | * Lesser General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Lesser General Public |
||
19 | * License along with FFmpeg; if not, write to the Free Software |
||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||
21 | */ |
||
22 | |||
23 | #include "hevc.h" |
||
24 | #include "hevcdsp.h" |
||
25 | |||
26 | static const int8_t transform[32][32] = { |
||
27 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, |
||
28 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }, |
||
29 | { 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4, |
||
30 | -4, -13, -22, -31, -38, -46, -54, -61, -67, -73, -78, -82, -85, -88, -90, -90 }, |
||
31 | { 90, 87, 80, 70, 57, 43, 25, 9, -9, -25, -43, -57, -70, -80, -87, -90, |
||
32 | -90, -87, -80, -70, -57, -43, -25, -9, 9, 25, 43, 57, 70, 80, 87, 90 }, |
||
33 | { 90, 82, 67, 46, 22, -4, -31, -54, -73, -85, -90, -88, -78, -61, -38, -13, |
||
34 | 13, 38, 61, 78, 88, 90, 85, 73, 54, 31, 4, -22, -46, -67, -82, -90 }, |
||
35 | { 89, 75, 50, 18, -18, -50, -75, -89, -89, -75, -50, -18, 18, 50, 75, 89, |
||
36 | 89, 75, 50, 18, -18, -50, -75, -89, -89, -75, -50, -18, 18, 50, 75, 89 }, |
||
37 | { 88, 67, 31, -13, -54, -82, -90, -78, -46, -4, 38, 73, 90, 85, 61, 22, |
||
38 | -22, -61, -85, -90, -73, -38, 4, 46, 78, 90, 82, 54, 13, -31, -67, -88 }, |
||
39 | { 87, 57, 9, -43, -80, -90, -70, -25, 25, 70, 90, 80, 43, -9, -57, -87, |
||
40 | -87, -57, -9, 43, 80, 90, 70, 25, -25, -70, -90, -80, -43, 9, 57, 87 }, |
||
41 | { 85, 46, -13, -67, -90, -73, -22, 38, 82, 88, 54, -4, -61, -90, -78, -31, |
||
42 | 31, 78, 90, 61, 4, -54, -88, -82, -38, 22, 73, 90, 67, 13, -46, -85 }, |
||
43 | { 83, 36, -36, -83, -83, -36, 36, 83, 83, 36, -36, -83, -83, -36, 36, 83, |
||
44 | 83, 36, -36, -83, -83, -36, 36, 83, 83, 36, -36, -83, -83, -36, 36, 83 }, |
||
45 | { 82, 22, -54, -90, -61, 13, 78, 85, 31, -46, -90, -67, 4, 73, 88, 38, |
||
46 | -38, -88, -73, -4, 67, 90, 46, -31, -85, -78, -13, 61, 90, 54, -22, -82 }, |
||
47 | { 80, 9, -70, -87, -25, 57, 90, 43, -43, -90, -57, 25, 87, 70, -9, -80, |
||
48 | -80, -9, 70, 87, 25, -57, -90, -43, 43, 90, 57, -25, -87, -70, 9, 80 }, |
||
49 | { 78, -4, -82, -73, 13, 85, 67, -22, -88, -61, 31, 90, 54, -38, -90, -46, |
||
50 | 46, 90, 38, -54, -90, -31, 61, 88, 22, -67, -85, -13, 73, 82, 4, -78 }, |
||
51 | { 75, -18, -89, -50, 50, 89, 18, -75, -75, 18, 89, 50, -50, -89, -18, 75, |
||
52 | 75, -18, -89, -50, 50, 89, 18, -75, -75, 18, 89, 50, -50, -89, -18, 75 }, |
||
53 | { 73, -31, -90, -22, 78, 67, -38, -90, -13, 82, 61, -46, -88, -4, 85, 54, |
||
54 | -54, -85, 4, 88, 46, -61, -82, 13, 90, 38, -67, -78, 22, 90, 31, -73 }, |
||
55 | { 70, -43, -87, 9, 90, 25, -80, -57, 57, 80, -25, -90, -9, 87, 43, -70, |
||
56 | -70, 43, 87, -9, -90, -25, 80, 57, -57, -80, 25, 90, 9, -87, -43, 70 }, |
||
57 | { 67, -54, -78, 38, 85, -22, -90, 4, 90, 13, -88, -31, 82, 46, -73, -61, |
||
58 | 61, 73, -46, -82, 31, 88, -13, -90, -4, 90, 22, -85, -38, 78, 54, -67 }, |
||
59 | { 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, |
||
60 | 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64 }, |
||
61 | { 61, -73, -46, 82, 31, -88, -13, 90, -4, -90, 22, 85, -38, -78, 54, 67, |
||
62 | -67, -54, 78, 38, -85, -22, 90, 4, -90, 13, 88, -31, -82, 46, 73, -61 }, |
||
63 | { 57, -80, -25, 90, -9, -87, 43, 70, -70, -43, 87, 9, -90, 25, 80, -57, |
||
64 | -57, 80, 25, -90, 9, 87, -43, -70, 70, 43, -87, -9, 90, -25, -80, 57 }, |
||
65 | { 54, -85, -4, 88, -46, -61, 82, 13, -90, 38, 67, -78, -22, 90, -31, -73, |
||
66 | 73, 31, -90, 22, 78, -67, -38, 90, -13, -82, 61, 46, -88, 4, 85, -54 }, |
||
67 | { 50, -89, 18, 75, -75, -18, 89, -50, -50, 89, -18, -75, 75, 18, -89, 50, |
||
68 | 50, -89, 18, 75, -75, -18, 89, -50, -50, 89, -18, -75, 75, 18, -89, 50 }, |
||
69 | { 46, -90, 38, 54, -90, 31, 61, -88, 22, 67, -85, 13, 73, -82, 4, 78, |
||
70 | -78, -4, 82, -73, -13, 85, -67, -22, 88, -61, -31, 90, -54, -38, 90, -46 }, |
||
71 | { 43, -90, 57, 25, -87, 70, 9, -80, 80, -9, -70, 87, -25, -57, 90, -43, |
||
72 | -43, 90, -57, -25, 87, -70, -9, 80, -80, 9, 70, -87, 25, 57, -90, 43 }, |
||
73 | { 38, -88, 73, -4, -67, 90, -46, -31, 85, -78, 13, 61, -90, 54, 22, -82, |
||
74 | 82, -22, -54, 90, -61, -13, 78, -85, 31, 46, -90, 67, 4, -73, 88, -38 }, |
||
75 | { 36, -83, 83, -36, -36, 83, -83, 36, 36, -83, 83, -36, -36, 83, -83, 36, |
||
76 | 36, -83, 83, -36, -36, 83, -83, 36, 36, -83, 83, -36, -36, 83, -83, 36 }, |
||
77 | { 31, -78, 90, -61, 4, 54, -88, 82, -38, -22, 73, -90, 67, -13, -46, 85, |
||
78 | -85, 46, 13, -67, 90, -73, 22, 38, -82, 88, -54, -4, 61, -90, 78, -31 }, |
||
79 | { 25, -70, 90, -80, 43, 9, -57, 87, -87, 57, -9, -43, 80, -90, 70, -25, |
||
80 | -25, 70, -90, 80, -43, -9, 57, -87, 87, -57, 9, 43, -80, 90, -70, 25 }, |
||
81 | { 22, -61, 85, -90, 73, -38, -4, 46, -78, 90, -82, 54, -13, -31, 67, -88, |
||
82 | 88, -67, 31, 13, -54, 82, -90, 78, -46, 4, 38, -73, 90, -85, 61, -22 }, |
||
83 | { 18, -50, 75, -89, 89, -75, 50, -18, -18, 50, -75, 89, -89, 75, -50, 18, |
||
84 | 18, -50, 75, -89, 89, -75, 50, -18, -18, 50, -75, 89, -89, 75, -50, 18 }, |
||
85 | { 13, -38, 61, -78, 88, -90, 85, -73, 54, -31, 4, 22, -46, 67, -82, 90, |
||
86 | -90, 82, -67, 46, -22, -4, 31, -54, 73, -85, 90, -88, 78, -61, 38, -13 }, |
||
87 | { 9, -25, 43, -57, 70, -80, 87, -90, 90, -87, 80, -70, 57, -43, 25, -9, |
||
88 | -9, 25, -43, 57, -70, 80, -87, 90, -90, 87, -80, 70, -57, 43, -25, 9 }, |
||
89 | { 4, -13, 22, -31, 38, -46, 54, -61, 67, -73, 78, -82, 85, -88, 90, -90, |
||
90 | 90, -90, 88, -85, 82, -78, 73, -67, 61, -54, 46, -38, 31, -22, 13, -4 }, |
||
91 | }; |
||
92 | |||
93 | DECLARE_ALIGNED(16, const int8_t, ff_hevc_epel_filters[7][16]) = { |
||
94 | { -2, 58, 10, -2,-2, 58, 10, -2,-2, 58, 10, -2,-2, 58, 10, -2 }, |
||
95 | { -4, 54, 16, -2,-4, 54, 16, -2,-4, 54, 16, -2,-4, 54, 16, -2 }, |
||
96 | { -6, 46, 28, -4,-6, 46, 28, -4,-6, 46, 28, -4,-6, 46, 28, -4 }, |
||
97 | { -4, 36, 36, -4,-4, 36, 36, -4,-4, 36, 36, -4,-4, 36, 36, -4 }, |
||
98 | { -4, 28, 46, -6,-4, 28, 46, -6,-4, 28, 46, -6,-4, 28, 46, -6 }, |
||
99 | { -2, 16, 54, -4,-2, 16, 54, -4,-2, 16, 54, -4,-2, 16, 54, -4 }, |
||
100 | { -2, 10, 58, -2,-2, 10, 58, -2,-2, 10, 58, -2,-2, 10, 58, -2 }, |
||
101 | }; |
||
102 | |||
103 | #define BIT_DEPTH 8 |
||
104 | #include "hevcdsp_template.c" |
||
105 | #undef BIT_DEPTH |
||
106 | |||
107 | #define BIT_DEPTH 9 |
||
108 | #include "hevcdsp_template.c" |
||
109 | #undef BIT_DEPTH |
||
110 | |||
111 | #define BIT_DEPTH 10 |
||
112 | #include "hevcdsp_template.c" |
||
113 | #undef BIT_DEPTH |
||
114 | |||
115 | void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth) |
||
116 | { |
||
117 | #undef FUNC |
||
118 | #define FUNC(a, depth) a ## _ ## depth |
||
119 | |||
120 | #define HEVC_DSP(depth) \ |
||
121 | hevcdsp->put_pcm = FUNC(put_pcm, depth); \ |
||
122 | hevcdsp->transquant_bypass[0] = FUNC(transquant_bypass4x4, depth); \ |
||
123 | hevcdsp->transquant_bypass[1] = FUNC(transquant_bypass8x8, depth); \ |
||
124 | hevcdsp->transquant_bypass[2] = FUNC(transquant_bypass16x16, depth); \ |
||
125 | hevcdsp->transquant_bypass[3] = FUNC(transquant_bypass32x32, depth); \ |
||
126 | hevcdsp->transform_skip = FUNC(transform_skip, depth); \ |
||
127 | hevcdsp->transform_4x4_luma_add = FUNC(transform_4x4_luma_add, depth); \ |
||
128 | hevcdsp->transform_add[0] = FUNC(transform_4x4_add, depth); \ |
||
129 | hevcdsp->transform_add[1] = FUNC(transform_8x8_add, depth); \ |
||
130 | hevcdsp->transform_add[2] = FUNC(transform_16x16_add, depth); \ |
||
131 | hevcdsp->transform_add[3] = FUNC(transform_32x32_add, depth); \ |
||
132 | \ |
||
133 | hevcdsp->sao_band_filter[0] = FUNC(sao_band_filter_0, depth); \ |
||
134 | hevcdsp->sao_band_filter[1] = FUNC(sao_band_filter_1, depth); \ |
||
135 | hevcdsp->sao_band_filter[2] = FUNC(sao_band_filter_2, depth); \ |
||
136 | hevcdsp->sao_band_filter[3] = FUNC(sao_band_filter_3, depth); \ |
||
137 | \ |
||
138 | hevcdsp->sao_edge_filter[0] = FUNC(sao_edge_filter_0, depth); \ |
||
139 | hevcdsp->sao_edge_filter[1] = FUNC(sao_edge_filter_1, depth); \ |
||
140 | hevcdsp->sao_edge_filter[2] = FUNC(sao_edge_filter_2, depth); \ |
||
141 | hevcdsp->sao_edge_filter[3] = FUNC(sao_edge_filter_3, depth); \ |
||
142 | \ |
||
143 | hevcdsp->put_hevc_qpel[0][0] = FUNC(put_hevc_qpel_pixels, depth); \ |
||
144 | hevcdsp->put_hevc_qpel[0][1] = FUNC(put_hevc_qpel_h1, depth); \ |
||
145 | hevcdsp->put_hevc_qpel[0][2] = FUNC(put_hevc_qpel_h2, depth); \ |
||
146 | hevcdsp->put_hevc_qpel[0][3] = FUNC(put_hevc_qpel_h3, depth); \ |
||
147 | hevcdsp->put_hevc_qpel[1][0] = FUNC(put_hevc_qpel_v1, depth); \ |
||
148 | hevcdsp->put_hevc_qpel[1][1] = FUNC(put_hevc_qpel_h1v1, depth); \ |
||
149 | hevcdsp->put_hevc_qpel[1][2] = FUNC(put_hevc_qpel_h2v1, depth); \ |
||
150 | hevcdsp->put_hevc_qpel[1][3] = FUNC(put_hevc_qpel_h3v1, depth); \ |
||
151 | hevcdsp->put_hevc_qpel[2][0] = FUNC(put_hevc_qpel_v2, depth); \ |
||
152 | hevcdsp->put_hevc_qpel[2][1] = FUNC(put_hevc_qpel_h1v2, depth); \ |
||
153 | hevcdsp->put_hevc_qpel[2][2] = FUNC(put_hevc_qpel_h2v2, depth); \ |
||
154 | hevcdsp->put_hevc_qpel[2][3] = FUNC(put_hevc_qpel_h3v2, depth); \ |
||
155 | hevcdsp->put_hevc_qpel[3][0] = FUNC(put_hevc_qpel_v3, depth); \ |
||
156 | hevcdsp->put_hevc_qpel[3][1] = FUNC(put_hevc_qpel_h1v3, depth); \ |
||
157 | hevcdsp->put_hevc_qpel[3][2] = FUNC(put_hevc_qpel_h2v3, depth); \ |
||
158 | hevcdsp->put_hevc_qpel[3][3] = FUNC(put_hevc_qpel_h3v3, depth); \ |
||
159 | \ |
||
160 | hevcdsp->put_hevc_epel[0][0] = FUNC(put_hevc_epel_pixels, depth); \ |
||
161 | hevcdsp->put_hevc_epel[0][1] = FUNC(put_hevc_epel_h, depth); \ |
||
162 | hevcdsp->put_hevc_epel[1][0] = FUNC(put_hevc_epel_v, depth); \ |
||
163 | hevcdsp->put_hevc_epel[1][1] = FUNC(put_hevc_epel_hv, depth); \ |
||
164 | \ |
||
165 | \ |
||
166 | hevcdsp->put_unweighted_pred = FUNC(put_unweighted_pred, depth); \ |
||
167 | hevcdsp->put_weighted_pred_avg = FUNC(put_weighted_pred_avg, depth); \ |
||
168 | \ |
||
169 | hevcdsp->weighted_pred = FUNC(weighted_pred, depth); \ |
||
170 | hevcdsp->weighted_pred_avg = FUNC(weighted_pred_avg, depth); \ |
||
171 | hevcdsp->hevc_h_loop_filter_luma = FUNC(hevc_h_loop_filter_luma, depth); \ |
||
172 | hevcdsp->hevc_v_loop_filter_luma = FUNC(hevc_v_loop_filter_luma, depth); \ |
||
173 | hevcdsp->hevc_h_loop_filter_chroma = FUNC(hevc_h_loop_filter_chroma, depth); \ |
||
174 | hevcdsp->hevc_v_loop_filter_chroma = FUNC(hevc_v_loop_filter_chroma, depth); \ |
||
175 | hevcdsp->hevc_h_loop_filter_luma_c = FUNC(hevc_h_loop_filter_luma, depth); \ |
||
176 | hevcdsp->hevc_v_loop_filter_luma_c = FUNC(hevc_v_loop_filter_luma, depth); \ |
||
177 | hevcdsp->hevc_h_loop_filter_chroma_c = FUNC(hevc_h_loop_filter_chroma, depth); \ |
||
178 | hevcdsp->hevc_v_loop_filter_chroma_c = FUNC(hevc_v_loop_filter_chroma, depth); |
||
179 | |||
180 | |||
181 | switch (bit_depth) { |
||
182 | case 9: |
||
183 | HEVC_DSP(9); |
||
184 | break; |
||
185 | case 10: |
||
186 | HEVC_DSP(10); |
||
187 | break; |
||
188 | default: |
||
189 | HEVC_DSP(8); |
||
190 | break; |
||
191 | } |
||
192 | } |