1 /*
2 * Copyright (c) 2015 Henrik Gramner
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <string.h>
29
31
33 { /* H.264 */
46 },
47 { /* VP8 */
54 },
55 { /* RV40 */
62 },
63 { /* SVQ3 */
65 },
66 };
67
69 { /* H.264 */
81 },
82 { /* VP8 */
86 },
87 { /* RV40 */
91 },
92 /* nothing for SVQ3 */
93 };
94
96 { /* H.264 */
104 },
105 { /* VP8 */
109 },
110 { /* RV40 */
112 },
113 { /* SVQ3 */
115 },
116 };
117
118 static const uint32_t
pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
119
120 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
121 #define BUF_SIZE (3 * 16 * 17)
122
123 #define check_pred_func(func, name, mode_name) \
124 (mode_name && ((codec_ids[codec] == AV_CODEC_ID_H264) ? \
125 check_func(func, "pred%s_%s_%d", name, mode_name, bit_depth) : \
126 check_func(func, "pred%s_%s", name, mode_name)))
127
128 #define randomize_buffers() \
129 do { \
130 uint32_t mask = pixel_mask[bit_depth - 8]; \
131 int i; \
132 for (i = 0; i < BUF_SIZE; i += 4) { \
133 uint32_t r = rnd() & mask; \
134 AV_WN32A(buf0 + i, r); \
135 AV_WN32A(buf1 + i, r); \
136 } \
137 } while (0)
138
139 #define src0 (buf0 + 4 * 16) /* Offset to allow room for top and left */
140 #define src1 (buf1 + 4 * 16)
141
143 int codec,
int chroma_format,
int bit_depth)
144 {
145 if (chroma_format == 1) {
146 uint8_t *topright = buf0 + 2*16;
147 int pred_mode;
149
150 for (pred_mode = 0; pred_mode < 15; pred_mode++) {
158 }
159 }
160 }
161 }
162
164 int codec,
int chroma_format,
int bit_depth)
165 {
166 int pred_mode;
168
169 for (pred_mode = 0; pred_mode < 11; pred_mode++) {
170 if (
check_pred_func(
h->pred8x8[pred_mode], (chroma_format == 2) ?
"8x16" :
"8x8",
178 }
179 }
180 }
181
183 int codec,
int chroma_format,
int bit_depth)
184 {
185 if (chroma_format == 1) {
186 int pred_mode;
188
189 for (pred_mode = 0; pred_mode < 9; pred_mode++) {
197 }
198 }
199 }
200 }
201
203 int codec,
int chroma_format,
int bit_depth)
204 {
206 int pred_mode;
208
209 for (pred_mode = 0; pred_mode < 12; pred_mode++) {
211 int neighbors;
212 for (neighbors = 0; neighbors <= 0xc000; neighbors += 0x4000) {
213 int has_topleft = neighbors & 0x8000;
214 int has_topright = neighbors & 0x4000;
215
217 continue; /* Those aren't allowed according to the spec */
218
225 }
226 }
227 }
228 }
229 }
230
231 /* TODO: Add tests for H.264 lossless H/V prediction */
232
234 {
235 static const struct {
243 };
244
249
251 for (codec = 0; codec < 4; codec++) {
257 }
258 }
260 }
261 }