1 /*
2 * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
3 * Copyright (C) 2008 David Conrad
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
27
28
31 {
32 int i;
33
34 for (i = 0; i <
width; i++)
35 b1[i] -= (b0[i] + b2[i] + 2) >> 2;
36 }
37
38
41 {
42 int i;
43 for (i = 0; i < w2; i++) {
44 dst[2*i ] = (src0[i] + add) >> shift;
45 dst[2*i+1] = (src1[i] + add) >> shift;
46 }
47 }
48
50 {
51 const int w2 = w >> 1;
52 int x;
53
55 for (x = 1; x < w2; x++) {
58 }
60
62 }
63
65 {
66 const int w2 = w >> 1;
67 int x;
68
70 for (x = 1; x < w2; x++)
72
73 // extend the edges
74 tmp[-1] = tmp[0];
75 tmp[w2+1] = tmp[w2] = tmp[w2-1];
76
77 for (x = 0; x < w2; x++) {
78 b[2*x ] = (tmp[x] + 1)>>1;
79 b[2*x+1] = (
COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1;
80 }
81 }
82
84 {
85 const int w2 = w >> 1;
86 int x;
87
90 for (x = 2; x < w2-1; x++)
93
94 // extend the edges
95 tmp[-1] = tmp[0];
96 tmp[w2+1] = tmp[w2] = tmp[w2-1];
97
98 for (x = 0; x < w2; x++) {
99 b[2*x ] = (tmp[x] + 1)>>1;
100 b[2*x+1] = (
COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1;
101 }
102 }
103
106 {
107 const int w2 = w >> 1;
108 int x;
109
110 for (x = 0; x < w2; x++) {
113 }
114
115 interleave(b, temp, temp+w2, w2, shift, shift);
116 }
117
119 {
121 }
122
124 {
126 }
127
129 {
130 const int w2 = w >> 1;
131 int i, x;
133
134 for (x = 0; x < w2; x++) {
135 for (i = 0; i < 8; i++)
136 v[i] = b[av_clip(x-3+i, 0, w2-1)];
138 }
139
140 for (x = 0; x < w2; x++) {
141 for (i = 0; i < 8; i++)
142 v[i] = tmp[av_clip(x-4+i, 0, w2-1)];
144 }
145
147 }
148
150 {
151 const int w2 = w >> 1;
152 int x, b0, b1, b2;
153
155 for (x = 1; x < w2; x++) {
158 }
160
161 // second stage combined with interleave and shift
163 b[0] = (b0 + 1) >> 1;
164 for (x = 1; x < w2; x++) {
167 b[2*x-1] = (b1 + 1) >> 1;
168 b[2*x ] = (b2 + 1) >> 1;
169 b0 = b2;
170 }
172 }
173
175 {
176 int i;
177
178 for(i=0; i<
width; i++){
180 }
181 }
182
185 {
186 int i;
187
188 for(i=0; i<
width; i++){
190 }
191 }
192
195 {
196 int i;
197
198 for(i=0; i<
width; i++){
200 }
201 }
202
204 {
205 int i;
206
207 for (i = 0; i <
width; i++) {
210 }
211 }
212
214 {
215 int i;
216
217 for(i=0; i<
width; i++){
218 dst[i] =
COMPOSE_FIDELITYiH0(b[0][i], b[1][i], b[2][i], b[3][i], dst[i], b[4][i], b[5][i], b[6][i], b[7][i]);
219 }
220 }
221
223 {
224 int i;
225
226 for(i=0; i<
width; i++){
227 dst[i] =
COMPOSE_FIDELITYiL0(b[0][i], b[1][i], b[2][i], b[3][i], dst[i], b[4][i], b[5][i], b[6][i], b[7][i]);
228 }
229 }
230
232 {
233 int i;
234
235 for(i=0; i<
width; i++){
237 }
238 }
239
241 {
242 int i;
243
244 for(i=0; i<
width; i++){
246 }
247 }
248
250 {
251 int i;
252
253 for(i=0; i<
width; i++){
255 }
256 }
257
259 {
260 int i;
261
262 for(i=0; i<
width; i++){
264 }
265 }
266
267
269 {
273
276 for (i = 0; i < 6; i++)
278 b[6] = d->
buffer + av_clip(y+5, 0, height-2)*stride;
279 b[7] = d->
buffer + av_clip(y+6, 1, height-1)*stride;
280
281 if(y+5<(unsigned)height) vertical_compose_l0( b[5], b[6], b[7], width);
282 if(y+1<(unsigned)height) vertical_compose_h0(b[0], b[2], b[3], b[4], b[6], width);
283
286
287 for (i = 0; i < 6; i++)
290 }
291
293 {
297
302
303 if(y+1<(unsigned)height) vertical_compose_l0(b[1], b[2], b[3], width);
304 if(y+0<(unsigned)height) vertical_compose_h0(b[0], b[1], b[2], width);
305
308
312 }
313
314
316 {
320
323 for (i = 0; i < 8; i++)
325 b[8] = d->
buffer + av_clip(y+7, 0, height-2)*stride;
326 b[9] = d->
buffer + av_clip(y+8, 1, height-1)*stride;
327
328 if(y+5<(unsigned)height) vertical_compose_l0(b[3], b[5], b[6], b[7], b[9], width);
329 if(y+1<(unsigned)height) vertical_compose_h0(b[0], b[2], b[3], b[4], b[6], width);
330
333
334 for (i = 0; i < 8; i++)
337 }
338
339 // haar makes the assumption that height is even (always true for dirac)
341 {
343 int y = d->
cs[level].
y;
346
347 vertical_compose(b0, b1, width);
350
352 }
353
354 // Don't do sliced idwt for fidelity; the 9 tap filter makes it a bit annoying
355 // Fortunately, this filter isn't used in practice.
357 {
362
363 for (y = 1; y <
height; y += 2) {
364 for (i = 0; i < 8; i++)
365 b[i] = d->
buffer + av_clip((y-7 + 2*i), 0, height-2)*stride;
366 vertical_compose_h0(d->
buffer + y*stride, b, width);
367 }
368
369 for (y = 0; y <
height; y += 2) {
370 for (i = 0; i < 8; i++)
371 b[i] = d->
buffer + av_clip((y-7 + 2*i), 1, height-1)*stride;
372 vertical_compose_l0(d->
buffer + y*stride, b, width);
373 }
374
375 for (y = 0; y <
height; y++)
377
379 }
380
382 {
388
391 for (i = 0; i < 4; i++)
395
396 if(y+3<(unsigned)height) vertical_compose_l1(b[3], b[4], b[5], width);
397 if(y+2<(unsigned)height) vertical_compose_h1(b[2], b[3], b[4], width);
398 if(y+1<(unsigned)height) vertical_compose_l0(b[1], b[2], b[3], width);
399 if(y+0<(unsigned)height) vertical_compose_h0(b[0], b[1], b[2], width);
400
403
404 for (i = 0; i < 4; i++)
407 }
408
409
411 {
417 }
418
420 {
424 }
425
427 {
428 cs->
b[0] = buffer + av_clip(-5-1, 0, height-2)*stride;
429 cs->
b[1] = buffer + av_clip(-5 , 1, height-1)*stride;
430 cs->
b[2] = buffer + av_clip(-5+1, 0, height-2)*stride;
431 cs->
b[3] = buffer + av_clip(-5+2, 1, height-1)*stride;
432 cs->
b[4] = buffer + av_clip(-5+3, 0, height-2)*stride;
433 cs->
b[5] = buffer + av_clip(-5+4, 1, height-1)*stride;
435 }
436
438 {
439 cs->
b[0] = buffer + av_clip(-5-1, 0, height-2)*stride;
440 cs->
b[1] = buffer + av_clip(-5 , 1, height-1)*stride;
441 cs->
b[2] = buffer + av_clip(-5+1, 0, height-2)*stride;
442 cs->
b[3] = buffer + av_clip(-5+2, 1, height-1)*stride;
443 cs->
b[4] = buffer + av_clip(-5+3, 0, height-2)*stride;
444 cs->
b[5] = buffer + av_clip(-5+4, 1, height-1)*stride;
445 cs->
b[6] = buffer + av_clip(-5+5, 0, height-2)*stride;
446 cs->
b[7] = buffer + av_clip(-5+6, 1, height-1)*stride;
448 }
449
453 {
455
462
463 for(level=decomposition_count-1; level>=0; level--){
464 int hl = height >>
level;
465 int stride_l = stride <<
level;
466
467 switch(type){
470 break;
473 break;
476 break;
480 break;
483 break;
484 default:
486 break;
487 }
488 }
489
490 switch (type) {
497 break;
504 break;
511 break;
518 else
521 break;
527 d->
support = 0;
// not really used
528 break;
537 break;
538 default:
540 return -1;
541 }
542
544
545 return 0;
546 }
547
549 {
551
556
557 while (d->
cs[level].
y <=
FFMIN((y>>level)+support, hl))
559 }
560 }
561