1 /*
2 * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
3 * Copyright (c) 2014 Arwa Arif <arwaarif1994@gmail.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 /**
23 * @file
24 * Postprocessing filter - 7
25 *
26 * Originally written by Michael Niedermayer for the MPlayer
27 * project, and ported by Arwa Arif for FFmpeg.
28 */
29
39
44 };
45
46 #define OFFSET(x) offsetof(PP7Context, x)
47 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
55 };
56
58
60 { 0, 48, 12, 60, 3, 51, 15, 63, },
61 { 32, 16, 44, 28, 35, 19, 47, 31, },
62 { 8, 56, 4, 52, 11, 59, 7, 55, },
63 { 40, 24, 36, 20, 43, 27, 39, 23, },
64 { 2, 50, 14, 62, 1, 49, 13, 61, },
65 { 34, 18, 46, 30, 33, 17, 45, 29, },
66 { 10, 58, 6, 54, 9, 57, 5, 53, },
67 { 42, 26, 38, 22, 41, 25, 37, 21, },
68 };
69
74 #define SN1 2.2360679775
75 #define SN2 3.16227766017
77
83 };
84
86 {
89
90 for (qp = 0; qp < 99; qp++) {
91 for (
i = 0;
i < 16;
i++) {
93 }
94 }
95 }
96
98 {
100
101 for (
i = 0;
i < 4;
i++) {
113 dst[1] = 2 *
s3 +
s2;
114 dst[3] =
s3 - 2 *
s2;
116 dst += 4;
117 }
118 }
119
121 {
123
124 for (
i = 0;
i < 4;
i++) {
136 dst[1 * 4] = 2 *
s3 +
s2;
137 dst[3 * 4] =
s3 - 2 *
s2;
139 dst++;
140 }
141 }
142
144 {
147
149 for (
i = 1;
i < 16;
i++) {
150 unsigned int threshold1 = p->
thres2[qp][
i];
151 unsigned int threshold2 = threshold1 << 1;
153 if (((
unsigned)(
level + threshold1)) > threshold2)
155 }
156 return (
a + (1 << 11)) >> 12;
157 }
158
160 {
163
165 for (
i = 1;
i < 16;
i++) {
166 unsigned int threshold1 = p->
thres2[qp][
i];
167 unsigned int threshold2 = threshold1 << 1;
169 if (((
unsigned)(
level + threshold1)) > threshold2) {
170 if (((
unsigned)(
level + 2 * threshold1)) > 2 * threshold2)
172 else {
175 else
177 }
178 }
179 }
180 return (
a + (1 << 11)) >> 12;
181 }
182
184 {
187
189 for (
i = 1;
i < 16;
i++) {
190 unsigned int threshold1 = p->
thres2[qp][
i];
191 unsigned int threshold2 = threshold1 << 1;
193 if (((
unsigned)(
level + threshold1)) > threshold2) {
196 else
198 }
199 }
200 return (
a + (1 << 11)) >> 12;
201 }
202
204 int dst_stride, int src_stride,
206 uint8_t *qp_store, int qp_stride, int is_luma)
207 {
208 int x, y;
212 int16_t *
temp = (int16_t *)(p->
src + 32);
213
214 if (!
src || !dst)
return;
215 for (y = 0; y <
height; y++) {
218 for (x = 0; x < 8; x++) {
221 }
222 }
223 for (y = 0; y < 8; y++) {
226 }
227 //FIXME (try edge emu)
228
229 for (y = 0; y <
height; y++) {
230 for (x = -8; x < 0; x += 4) {
231 const int index = x + y *
stride + (8 - 3) * (1 +
stride) + 8;
//FIXME silly offset
233 int16_t *tp =
temp + 4 * x;
234
236 }
237 for (x = 0; x <
width; ) {
238 const int qps = 3 + is_luma;
239 int qp;
241
244 else {
247 }
248 for (; x < end; x++) {
249 const int index = x + y *
stride + (8 - 3) * (1 +
stride) + 8;
//FIXME silly offset
251 int16_t *tp =
temp + 4 * x;
252 int v;
253
254 if ((x & 3) == 0)
256
258
260 v = (v +
dither[y & 7][x & 7]) >> 6;
261 if ((unsigned)v > 255)
262 v = (-v) >> 31;
263 dst[x + y * dst_stride] = v;
264 }
265 }
266 }
267 }
268
277 };
278
280 {
285
288
291
294
296
300 default:
302 }
303
305
306 #if ARCH_X86
308 #endif
309
310 return 0;
311 }
312
314 {
319
320 int qp_stride = 0;
321 int8_t *qp_table =
NULL;
322
328 }
329 }
330
331 if (!
ctx->is_disabled) {
334
335 /* get a new frame if in-place is not possible or if the dimensions
336 * are not multiple of 8 */
340
346 }
350 }
351
352 if (qp_table || pp7->
qp) {
353
357 cw, ch, qp_table, qp_stride, 0);
359 cw, ch, qp_table, qp_stride, 0);
361 }
362 }
363
370 }
373 }
374
376 {
379 }
380
382 {
387 },
388 };
389
398 .priv_class = &pp7_class,
400 };