FFmpeg
Loading...
Searching...
No Matches
snow_dwt.c
Go to the documentation of this file.
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
23#include "libavutil/avassert.h"
24#include "libavutil/common.h"
25#include "libavutil/mem.h"
26#include "me_cmp.h"
27#include "snow_dwt.h"
28
29int ff_slice_buffer_init(slice_buffer *buf, int line_count,
30 int max_allocated_lines, int line_width,
31 IDWTELEM *base_buffer)
32{
33 int i;
34
35 buf->base_buffer = base_buffer;
36 buf->line_count = line_count;
37 buf->line_width = line_width;
38 buf->data_count = max_allocated_lines;
39 buf->line = av_calloc(line_count, sizeof(*buf->line));
40 if (!buf->line)
41 return AVERROR(ENOMEM);
42 buf->data_stack = av_malloc_array(max_allocated_lines, sizeof(IDWTELEM *));
43 if (!buf->data_stack) {
44 av_freep(&buf->line);
45 return AVERROR(ENOMEM);
46 }
47
48 for (i = 0; i < max_allocated_lines; i++) {
49 buf->data_stack[i] = av_malloc_array(line_width, sizeof(IDWTELEM));
50 if (!buf->data_stack[i]) {
51 for (i--; i >=0; i--)
52 av_freep(&buf->data_stack[i]);
53 av_freep(&buf->data_stack);
54 av_freep(&buf->line);
55 return AVERROR(ENOMEM);
56 }
57 }
58
59 buf->data_stack_top = max_allocated_lines - 1;
60 return 0;
61}
62
64{
66
67 av_assert0(buf->data_stack_top >= 0);
68// av_assert1(!buf->line[line]);
69 if (buf->line[line])
70 return buf->line[line];
71
72 buffer = buf->data_stack[buf->data_stack_top];
73 buf->data_stack_top--;
74 buf->line[line] = buffer;
75
76 return buffer;
77}
78
80{
82
83 av_assert1(line >= 0 && line < buf->line_count);
84 av_assert1(buf->line[line]);
85
86 buffer = buf->line[line];
87 buf->data_stack_top++;
88 buf->data_stack[buf->data_stack_top] = buffer;
89 buf->line[line] = NULL;
90}
91
93{
94 int i;
95
96 if (!buf->line)
97 return;
98
99 for (i = 0; i < buf->line_count; i++)
100 if (buf->line[i])
102}
103
105{
106 int i;
108
109 if (buf->data_stack)
110 for (i = buf->data_count - 1; i >= 0; i--)
111 av_freep(&buf->data_stack[i]);
112 av_freep(&buf->data_stack);
113 av_freep(&buf->line);
114}
115
117 int dst_step, int src_step, int ref_step,
118 int width, int mul, int add, int shift,
119 int highpass, int inverse)
120{
121 const int mirror_left = !highpass;
122 const int mirror_right = (width & 1) ^ highpass;
123 const int w = (width >> 1) - 1 + (highpass & width);
124 int i;
125
126#define LIFT(src, ref, inv) ((src) + ((inv) ? -(ref) : +(ref)))
127 if (mirror_left) {
128 dst[0] = LIFT(src[0], ((mul * 2 * ref[0] + add) >> shift), inverse);
129 dst += dst_step;
130 src += src_step;
131 }
132
133 for (i = 0; i < w; i++)
134 dst[i * dst_step] = LIFT(src[i * src_step],
135 ((mul * (ref[i * ref_step] +
136 ref[(i + 1) * ref_step]) +
137 add) >> shift),
138 inverse);
139
140 if (mirror_right)
141 dst[w * dst_step] = LIFT(src[w * src_step],
142 ((mul * 2 * ref[w * ref_step] + add) >> shift),
143 inverse);
144}
145
147 int dst_step, int src_step, int ref_step,
148 int width, int mul, int add, int shift,
149 int highpass, int inverse)
150{
151 const int mirror_left = !highpass;
152 const int mirror_right = (width & 1) ^ highpass;
153 const int w = (width >> 1) - 1 + (highpass & width);
154 int i;
155
156 av_assert1(shift == 4);
157#define LIFTS(src, ref, inv) \
158 ((inv) ? (src) + (((ref) + 4 * (src)) >> shift) \
159 : -((-16 * (src) + (ref) + add / \
160 4 + 1 + (5 << 25)) / (5 * 4) - (1 << 23)))
161 if (mirror_left) {
162 dst[0] = LIFTS(src[0], mul * 2 * ref[0] + add, inverse);
163 dst += dst_step;
164 src += src_step;
165 }
166
167 for (i = 0; i < w; i++)
168 dst[i * dst_step] = LIFTS(src[i * src_step],
169 mul * (ref[i * ref_step] +
170 ref[(i + 1) * ref_step]) + add,
171 inverse);
172
173 if (mirror_right)
174 dst[w * dst_step] = LIFTS(src[w * src_step],
175 mul * 2 * ref[w * ref_step] + add,
176 inverse);
177}
178
180{
181 const int width2 = width >> 1;
182 int x;
183 const int w2 = (width + 1) >> 1;
184
185 for (x = 0; x < width2; x++) {
186 temp[x] = b[2 * x];
187 temp[x + w2] = b[2 * x + 1];
188 }
189 if (width & 1)
190 temp[x] = b[2 * x];
191 lift(b + w2, temp + w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0);
192 lift(b, temp, b + w2, 1, 1, 1, width, 1, 2, 2, 0, 0);
193}
194
196 int width)
197{
198 int i;
199
200 for (i = 0; i < width; i++)
201 b1[i] -= (b0[i] + b2[i]) >> 1;
202}
203
205 int width)
206{
207 int i;
208
209 for (i = 0; i < width; i++)
210 b1[i] += (b0[i] + b2[i] + 2) >> 2;
211}
212
214 int width, int height, int stride)
215{
216 int y;
217 DWTELEM *b0 = buffer + avpriv_mirror(-2 - 1, height - 1) * stride;
218 DWTELEM *b1 = buffer + avpriv_mirror(-2, height - 1) * stride;
219
220 for (y = -2; y < height; y += 2) {
221 DWTELEM *b2 = buffer + avpriv_mirror(y + 1, height - 1) * stride;
222 DWTELEM *b3 = buffer + avpriv_mirror(y + 2, height - 1) * stride;
223
224 if (y + 1 < (unsigned)height)
226 if (y + 2 < (unsigned)height)
228
229 if (y + 1 < (unsigned)height)
231 if (y + 0 < (unsigned)height)
233
234 b0 = b2;
235 b1 = b3;
236 }
237}
238
240{
241 const int w2 = (width + 1) >> 1;
242
243 lift(temp + w2, b + 1, b, 1, 2, 2, width, W_AM, W_AO, W_AS, 1, 1);
244 liftS(temp, b, temp + w2, 1, 2, 1, width, W_BM, W_BO, W_BS, 0, 0);
245 lift(b + w2, temp + w2, temp, 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 0);
246 lift(b, temp, b + w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 0);
247}
248
250 int width)
251{
252 int i;
253
254 for (i = 0; i < width; i++)
255 b1[i] -= (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS;
256}
257
259 int width)
260{
261 int i;
262
263 for (i = 0; i < width; i++)
264 b1[i] += (W_CM * (b0[i] + b2[i]) + W_CO) >> W_CS;
265}
266
268 int width)
269{
270 int i;
271
272 for (i = 0; i < width; i++)
273 b1[i] = (16 * 4 * b1[i] - 4 * (b0[i] + b2[i]) + W_BO * 5 + (5 << 27)) /
274 (5 * 16) - (1 << 23);
275}
276
278 int width)
279{
280 int i;
281
282 for (i = 0; i < width; i++)
283 b1[i] += (W_DM * (b0[i] + b2[i]) + W_DO) >> W_DS;
284}
285
287 int width, int height, int stride)
288{
289 int y;
290 DWTELEM *b0 = buffer + avpriv_mirror(-4 - 1, height - 1) * stride;
291 DWTELEM *b1 = buffer + avpriv_mirror(-4, height - 1) * stride;
292 DWTELEM *b2 = buffer + avpriv_mirror(-4 + 1, height - 1) * stride;
293 DWTELEM *b3 = buffer + avpriv_mirror(-4 + 2, height - 1) * stride;
294
295 for (y = -4; y < height; y += 2) {
296 DWTELEM *b4 = buffer + avpriv_mirror(y + 3, height - 1) * stride;
297 DWTELEM *b5 = buffer + avpriv_mirror(y + 4, height - 1) * stride;
298
299 if (y + 3 < (unsigned)height)
301 if (y + 4 < (unsigned)height)
303
304 if (y + 3 < (unsigned)height)
306 if (y + 2 < (unsigned)height)
308 if (y + 1 < (unsigned)height)
310 if (y + 0 < (unsigned)height)
312
313 b0 = b2;
314 b1 = b3;
315 b2 = b4;
316 b3 = b5;
317 }
318}
319
321 int stride, int type, int decomposition_count)
322{
323 int level;
324
325 for (level = 0; level < decomposition_count; level++) {
326 switch (type) {
327 case DWT_97:
329 width >> level, height >> level,
330 stride << level);
331 break;
332 case DWT_53:
334 width >> level, height >> level,
335 stride << level);
336 break;
337 }
338 }
339}
340
342{
343 const int width2 = width >> 1;
344 const int w2 = (width + 1) >> 1;
345 int x;
346
347 for (x = 0; x < width2; x++) {
348 temp[2 * x] = b[x];
349 temp[2 * x + 1] = b[x + w2];
350 }
351 if (width & 1)
352 temp[2 * x] = b[x];
353
354 b[0] = temp[0] - ((temp[1] + 1) >> 1);
355 for (x = 2; x < width - 1; x += 2) {
356 b[x] = temp[x] - ((temp[x - 1] + temp[x + 1] + 2) >> 2);
357 b[x - 1] = temp[x - 1] + ((b[x - 2] + b[x] + 1) >> 1);
358 }
359 if (width & 1) {
360 b[x] = temp[x] - ((temp[x - 1] + 1) >> 1);
361 b[x - 1] = temp[x - 1] + ((b[x - 2] + b[x] + 1) >> 1);
362 } else
363 b[x - 1] = temp[x - 1] + b[x - 2];
364}
365
367 int width)
368{
369 int i;
370
371 for (i = 0; i < width; i++)
372 b1[i] += (b0[i] + b2[i]) >> 1;
373}
374
376 int width)
377{
378 int i;
379
380 for (i = 0; i < width; i++)
381 b1[i] -= (b0[i] + b2[i] + 2) >> 2;
382}
383
385 int height, int stride_line)
386{
387 cs->b0 = slice_buffer_get_line(sb,
388 avpriv_mirror(-1 - 1, height - 1) * stride_line);
389 cs->b1 = slice_buffer_get_line(sb, avpriv_mirror(-1, height - 1) * stride_line);
390 cs->y = -1;
391}
392
394 int height, int stride)
395{
396 cs->b0 = buffer + avpriv_mirror(-1 - 1, height - 1) * stride;
397 cs->b1 = buffer + avpriv_mirror(-1, height - 1) * stride;
398 cs->y = -1;
399}
400
402 IDWTELEM *temp,
403 int width, int height,
404 int stride_line)
405{
406 int y = cs->y;
407
408 IDWTELEM *b0 = cs->b0;
409 IDWTELEM *b1 = cs->b1;
411 avpriv_mirror(y + 1, height - 1) *
412 stride_line);
414 avpriv_mirror(y + 2, height - 1) *
415 stride_line);
416
417 if (y + 1 < (unsigned)height && y < (unsigned)height) {
418 int x;
419
420 for (x = 0; x < width; x++) {
421 b2[x] -= (b1[x] + b3[x] + 2) >> 2;
422 b1[x] += (b0[x] + b2[x]) >> 1;
423 }
424 } else {
425 if (y + 1 < (unsigned)height)
427 if (y + 0 < (unsigned)height)
429 }
430
431 if (y - 1 < (unsigned)height)
433 if (y + 0 < (unsigned)height)
435
436 cs->b0 = b2;
437 cs->b1 = b3;
438 cs->y += 2;
439}
440
442 IDWTELEM *temp, int width, int height,
443 int stride)
444{
445 int y = cs->y;
446 IDWTELEM *b0 = cs->b0;
447 IDWTELEM *b1 = cs->b1;
448 IDWTELEM *b2 = buffer + avpriv_mirror(y + 1, height - 1) * stride;
449 IDWTELEM *b3 = buffer + avpriv_mirror(y + 2, height - 1) * stride;
450
451 if (y + 1 < (unsigned)height)
453 if (y + 0 < (unsigned)height)
455
456 if (y - 1 < (unsigned)height)
458 if (y + 0 < (unsigned)height)
460
461 cs->b0 = b2;
462 cs->b1 = b3;
463 cs->y += 2;
464}
465
467{
468 const int w2 = (width + 1) >> 1;
469 int x;
470
471 temp[0] = b[0] - ((3 * b[w2] + 2) >> 2);
472 for (x = 1; x < (width >> 1); x++) {
473 temp[2 * x] = b[x] - ((3 * (b[x + w2 - 1] + b[x + w2]) + 4) >> 3);
474 temp[2 * x - 1] = b[x + w2 - 1] - temp[2 * x - 2] - temp[2 * x];
475 }
476 if (width & 1) {
477 temp[2 * x] = b[x] - ((3 * b[x + w2 - 1] + 2) >> 2);
478 temp[2 * x - 1] = b[x + w2 - 1] - temp[2 * x - 2] - temp[2 * x];
479 } else
480 temp[2 * x - 1] = b[x + w2 - 1] - 2 * temp[2 * x - 2];
481
482 b[0] = temp[0] + ((2 * temp[0] + temp[1] + 4) >> 3);
483 for (x = 2; x < width - 1; x += 2) {
484 b[x] = temp[x] + ((4 * temp[x] + temp[x - 1] + temp[x + 1] + 8) >> 4);
485 b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1);
486 }
487 if (width & 1) {
488 b[x] = temp[x] + ((2 * temp[x] + temp[x - 1] + 4) >> 3);
489 b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1);
490 } else
491 b[x - 1] = temp[x - 1] + 3 * b[x - 2];
492}
493
495 int width)
496{
497 int i;
498
499 for (i = 0; i < width; i++)
500 b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS;
501}
502
504 int width)
505{
506 int i;
507
508 for (i = 0; i < width; i++)
509 b1[i] -= (W_CM * (b0[i] + b2[i]) + W_CO) >> W_CS;
510}
511
513 int width)
514{
515 int i;
516
517 for (i = 0; i < width; i++)
518 b1[i] += (W_BM * (b0[i] + b2[i]) + 4 * b1[i] + W_BO) >> W_BS;
519}
520
522 int width)
523{
524 int i;
525
526 for (i = 0; i < width; i++)
527 b1[i] -= (W_DM * (b0[i] + b2[i]) + W_DO) >> W_DS;
528}
529
531 IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5,
532 int width)
533{
534 int i;
535
536 for (i = 0; i < width; i++) {
537 b4[i] -= (W_DM * (b3[i] + b5[i]) + W_DO) >> W_DS;
538 b3[i] -= (W_CM * (b2[i] + b4[i]) + W_CO) >> W_CS;
539 b2[i] += (W_BM * (b1[i] + b3[i]) + 4 * b2[i] + W_BO) >> W_BS;
540 b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS;
541 }
542}
543
545 int height, int stride_line)
546{
547 cs->b0 = slice_buffer_get_line(sb, avpriv_mirror(-3 - 1, height - 1) * stride_line);
548 cs->b1 = slice_buffer_get_line(sb, avpriv_mirror(-3, height - 1) * stride_line);
549 cs->b2 = slice_buffer_get_line(sb, avpriv_mirror(-3 + 1, height - 1) * stride_line);
550 cs->b3 = slice_buffer_get_line(sb, avpriv_mirror(-3 + 2, height - 1) * stride_line);
551 cs->y = -3;
552}
553
555 int stride)
556{
557 cs->b0 = buffer + avpriv_mirror(-3 - 1, height - 1) * stride;
558 cs->b1 = buffer + avpriv_mirror(-3, height - 1) * stride;
559 cs->b2 = buffer + avpriv_mirror(-3 + 1, height - 1) * stride;
560 cs->b3 = buffer + avpriv_mirror(-3 + 2, height - 1) * stride;
561 cs->y = -3;
562}
563
566 int width, int height,
567 int stride_line)
568{
569 int y = cs->y;
570
571 IDWTELEM *b0 = cs->b0;
572 IDWTELEM *b1 = cs->b1;
573 IDWTELEM *b2 = cs->b2;
574 IDWTELEM *b3 = cs->b3;
576 avpriv_mirror(y + 3, height - 1) *
577 stride_line);
579 avpriv_mirror(y + 4, height - 1) *
580 stride_line);
581
582 if (y > 0 && y + 4 < height) {
583 dsp->vertical_compose97i(b0, b1, b2, b3, b4, b5, width);
584 } else {
585 if (y + 3 < (unsigned)height)
587 if (y + 2 < (unsigned)height)
589 if (y + 1 < (unsigned)height)
591 if (y + 0 < (unsigned)height)
593 }
594
595 if (y - 1 < (unsigned)height)
597 if (y + 0 < (unsigned)height)
599
600 cs->b0 = b2;
601 cs->b1 = b3;
602 cs->b2 = b4;
603 cs->b3 = b5;
604 cs->y += 2;
605}
606
608 IDWTELEM *temp, int width, int height,
609 int stride)
610{
611 int y = cs->y;
612 IDWTELEM *b0 = cs->b0;
613 IDWTELEM *b1 = cs->b1;
614 IDWTELEM *b2 = cs->b2;
615 IDWTELEM *b3 = cs->b3;
616 IDWTELEM *b4 = buffer + avpriv_mirror(y + 3, height - 1) * stride;
617 IDWTELEM *b5 = buffer + avpriv_mirror(y + 4, height - 1) * stride;
618
619 if (y + 3 < (unsigned)height)
621 if (y + 2 < (unsigned)height)
623 if (y + 1 < (unsigned)height)
625 if (y + 0 < (unsigned)height)
627
628 if (y - 1 < (unsigned)height)
630 if (y + 0 < (unsigned)height)
632
633 cs->b0 = b2;
634 cs->b1 = b3;
635 cs->b2 = b4;
636 cs->b3 = b5;
637 cs->y += 2;
638}
639
641 int height, int stride_line, int type,
642 int decomposition_count)
643{
644 int level;
645 for (level = decomposition_count - 1; level >= 0; level--) {
646 switch (type) {
647 case DWT_97:
649 stride_line << level);
650 break;
651 case DWT_53:
653 stride_line << level);
654 break;
655 }
656 }
657}
658
660 slice_buffer *slice_buf, IDWTELEM *temp,
661 int width, int height, int stride_line,
662 int type, int decomposition_count, int y)
663{
664 const int support = type == 1 ? 3 : 5;
665 int level;
666 if (type == 2)
667 return;
668
669 for (level = decomposition_count - 1; level >= 0; level--)
670 while (cs[level].y <= FFMIN((y >> level) + support, height >> level)) {
671 switch (type) {
672 case DWT_97:
673 spatial_compose97i_dy_buffered(dsp, cs + level, slice_buf, temp,
674 width >> level,
675 height >> level,
676 stride_line << level);
677 break;
678 case DWT_53:
680 width >> level,
681 height >> level,
682 stride_line << level);
683 break;
684 }
685 }
686}
687
689 int height, int stride, int type,
690 int decomposition_count)
691{
692 int level;
693 for (level = decomposition_count - 1; level >= 0; level--) {
694 switch (type) {
695 case DWT_97:
697 stride << level);
698 break;
699 case DWT_53:
701 stride << level);
702 break;
703 }
704 }
705}
706
708 IDWTELEM *temp, int width, int height,
709 int stride, int type,
710 int decomposition_count, int y)
711{
712 const int support = type == 1 ? 3 : 5;
713 int level;
714 if (type == 2)
715 return;
716
717 for (level = decomposition_count - 1; level >= 0; level--)
718 while (cs[level].y <= FFMIN((y >> level) + support, height >> level)) {
719 switch (type) {
720 case DWT_97:
722 height >> level, stride << level);
723 break;
724 case DWT_53:
726 height >> level, stride << level);
727 break;
728 }
729 }
730}
731
733 int stride, int type, int decomposition_count)
734{
736 int y;
738 decomposition_count);
739 for (y = 0; y < height; y += 4)
741 decomposition_count, y);
742}
743
744static inline int w_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size,
745 int w, int h, int type)
746{
747 int s, i, j;
748 const int dec_count = w == 8 ? 3 : 4;
749 int tmp[32 * 32], tmp2[32];
750 int level, ori;
751 static const int scale[2][2][4][4] = {
752 {
753 { // 9/7 8x8 dec=3
754 { 268, 239, 239, 213 },
755 { 0, 224, 224, 152 },
756 { 0, 135, 135, 110 },
757 },
758 { // 9/7 16x16 or 32x32 dec=4
759 { 344, 310, 310, 280 },
760 { 0, 320, 320, 228 },
761 { 0, 175, 175, 136 },
762 { 0, 129, 129, 102 },
763 }
764 },
765 {
766 { // 5/3 8x8 dec=3
767 { 275, 245, 245, 218 },
768 { 0, 230, 230, 156 },
769 { 0, 138, 138, 113 },
770 },
771 { // 5/3 16x16 or 32x32 dec=4
772 { 352, 317, 317, 286 },
773 { 0, 328, 328, 233 },
774 { 0, 180, 180, 140 },
775 { 0, 132, 132, 105 },
776 }
777 }
778 };
779
780 for (i = 0; i < h; i++) {
781 for (j = 0; j < w; j += 4) {
782 tmp[32 * i + j + 0] = (pix1[j + 0] - pix2[j + 0]) * (1 << 4);
783 tmp[32 * i + j + 1] = (pix1[j + 1] - pix2[j + 1]) * (1 << 4);
784 tmp[32 * i + j + 2] = (pix1[j + 2] - pix2[j + 2]) * (1 << 4);
785 tmp[32 * i + j + 3] = (pix1[j + 3] - pix2[j + 3]) * (1 << 4);
786 }
787 pix1 += line_size;
788 pix2 += line_size;
789 }
790
791 ff_spatial_dwt(tmp, tmp2, w, h, 32, type, dec_count);
792
793 s = 0;
794 av_assert1(w == h);
795 for (level = 0; level < dec_count; level++)
796 for (ori = level ? 1 : 0; ori < 4; ori++) {
797 int size = w >> (dec_count - level);
798 int sx = (ori & 1) ? size : 0;
799 int stride = 32 << (dec_count - level);
800 int sy = (ori & 2) ? stride >> 1 : 0;
801
802 for (i = 0; i < size; i++)
803 for (j = 0; j < size; j++) {
804 int v = tmp[sx + sy + i * stride + j] *
805 scale[type][dec_count - 3][level][ori];
806 s += FFABS(v);
807 }
808 }
809 av_assert1(s >= 0);
810 return s >> 9;
811}
812
813static int w53_8_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
814{
815 return w_c(v, pix1, pix2, line_size, 8, h, 1);
816}
817
818static int w97_8_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
819{
820 return w_c(v, pix1, pix2, line_size, 8, h, 0);
821}
822
823static int w53_16_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
824{
825 return w_c(v, pix1, pix2, line_size, 16, h, 1);
826}
827
828static int w97_16_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
829{
830 return w_c(v, pix1, pix2, line_size, 16, h, 0);
831}
832
833int ff_w53_32_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
834{
835 return w_c(v, pix1, pix2, line_size, 32, h, 1);
836}
837
838int ff_w97_32_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
839{
840 return w_c(v, pix1, pix2, line_size, 32, h, 0);
841}
842
844{
845 c->w53[0] = w53_16_c;
846 c->w53[1] = w53_8_c;
847 c->w97[0] = w97_16_c;
848 c->w97[1] = w97_8_c;
849}
850
852{
853 c->vertical_compose97i = snow_vertical_compose97i;
854 c->horizontal_compose97i = snow_horizontal_compose97i;
855 c->inner_add_yblock = ff_snow_inner_add_yblock_c;
856
857#if ARCH_X86 && HAVE_MMX
859#endif
860}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
@ highpass
Definition af_biquads.c:86
inverse
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition avassert.h:58
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition common.h:74
#define NULL
Definition coverity.c:32
int DWTELEM
Definition dirac_dwt.h:27
#define MAX_DECOMPOSITIONS
Definition dirac_dwt.h:31
short IDWTELEM
Definition dirac_dwt.h:28
#define AVERROR(e)
Definition error.h:45
cl_device_type type
#define b
Definition input.c:43
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
static int shift(int a, int b)
Definition bonk.c:261
Macro definitions for various function/variable attributes.
#define av_always_inline
Definition attributes.h:72
#define av_cold
Definition attributes.h:117
static av_always_inline av_const int avpriv_mirror(int x, int w)
Definition internal.h:134
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
void ff_snow_inner_add_yblock_c(const uint8_t *obmc, const int obmc_stride, uint8_t **block, int b_w, int b_h, int src_x, int src_stride, IDWTELEM *const *lines, int add, uint8_t *dst8)
Definition snow.c:118
static av_always_inline void lift(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse)
Definition snow_dwt.c:116
static void vertical_decompose97iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
Definition snow_dwt.c:249
static void spatial_compose53i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
Definition snow_dwt.c:393
static void vertical_compose53iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
Definition snow_dwt.c:366
static void spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride, int type, int decomposition_count, int y)
Definition snow_dwt.c:707
static void horizontal_decompose97i(DWTELEM *b, DWTELEM *temp, int width)
Definition snow_dwt.c:239
static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width)
Definition snow_dwt.c:179
void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride, int type, int decomposition_count)
Definition snow_dwt.c:732
static void spatial_compose97i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
Definition snow_dwt.c:554
static int w53_16_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
Definition snow_dwt.c:823
int ff_w53_32_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
Definition snow_dwt.c:833
void ff_slice_buffer_release(slice_buffer *buf, int line)
Definition snow_dwt.c:79
static void spatial_compose53i_dy_buffered(DWTCompose *cs, slice_buffer *sb, IDWTELEM *temp, int width, int height, int stride_line)
Definition snow_dwt.c:401
int ff_w97_32_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
Definition snow_dwt.c:838
static int w97_16_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
Definition snow_dwt.c:828
av_cold void ff_dsputil_init_dwt(MECmpContext *c)
Definition snow_dwt.c:843
static void spatial_decompose97i(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride)
Definition snow_dwt.c:286
void ff_spatial_idwt_buffered_slice(SnowDWTContext *dsp, DWTCompose *cs, slice_buffer *slice_buf, IDWTELEM *temp, int width, int height, int stride_line, int type, int decomposition_count, int y)
Definition snow_dwt.c:659
static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
Definition snow_dwt.c:521
void ff_slice_buffer_flush(slice_buffer *buf)
Definition snow_dwt.c:92
void ff_spatial_dwt(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride, int type, int decomposition_count)
Definition snow_dwt.c:320
int ff_slice_buffer_init(slice_buffer *buf, int line_count, int max_allocated_lines, int line_width, IDWTELEM *base_buffer)
Definition snow_dwt.c:29
static void spatial_compose53i_dy(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride)
Definition snow_dwt.c:441
av_cold void ff_dwt_init(SnowDWTContext *c)
Definition snow_dwt.c:851
static void spatial_compose97i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line)
Definition snow_dwt.c:544
static int w53_8_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
Definition snow_dwt.c:813
static void spatial_compose53i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line)
Definition snow_dwt.c:384
static void spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count)
Definition snow_dwt.c:688
static void horizontal_compose53i(IDWTELEM *b, IDWTELEM *temp, int width)
Definition snow_dwt.c:341
#define LIFTS(src, ref, inv)
static int w_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int w, int h, int type)
Definition snow_dwt.c:744
static void vertical_decompose97iH1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
Definition snow_dwt.c:258
static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
Definition snow_dwt.c:195
static void snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width)
Definition snow_dwt.c:466
void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer *sb, int width, int height, int stride_line, int type, int decomposition_count)
Definition snow_dwt.c:640
static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
Definition snow_dwt.c:267
static void spatial_compose97i_dy_buffered(SnowDWTContext *dsp, DWTCompose *cs, slice_buffer *sb, IDWTELEM *temp, int width, int height, int stride_line)
Definition snow_dwt.c:564
static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
Definition snow_dwt.c:494
IDWTELEM * ff_slice_buffer_load_line(slice_buffer *buf, int line)
Definition snow_dwt.c:63
static void vertical_decompose53iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
Definition snow_dwt.c:204
void ff_slice_buffer_destroy(slice_buffer *buf)
Definition snow_dwt.c:104
static int w97_8_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
Definition snow_dwt.c:818
static void spatial_decompose53i(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride)
Definition snow_dwt.c:213
static void snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width)
Definition snow_dwt.c:530
static void vertical_compose97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
Definition snow_dwt.c:512
static void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
Definition snow_dwt.c:375
static void vertical_compose97iH1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
Definition snow_dwt.c:503
#define LIFT(src, ref, inv)
static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
Definition snow_dwt.c:277
static void spatial_compose97i_dy(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride)
Definition snow_dwt.c:607
#define W_CS
Definition snow_dwt.h:83
#define W_BO
Definition snow_dwt.h:78
#define W_BM
Definition snow_dwt.h:77
#define W_AM
Definition snow_dwt.h:72
#define DWT_97
Definition snow_dwt.h:68
#define DWT_53
Definition snow_dwt.h:69
#define W_DM
Definition snow_dwt.h:85
#define liftS
Definition snow_dwt.h:71
#define W_BS
Definition snow_dwt.h:79
#define W_CO
Definition snow_dwt.h:82
void ff_dwt_init_x86(SnowDWTContext *c)
#define W_CM
Definition snow_dwt.h:81
#define slice_buffer_get_line(slice_buf, line_num)
Definition snow_dwt.h:89
#define W_AO
Definition snow_dwt.h:73
#define W_DO
Definition snow_dwt.h:86
#define W_AS
Definition snow_dwt.h:74
#define W_DS
Definition snow_dwt.h:87
IDWTELEM * b1
Definition snow_dwt.h:38
IDWTELEM * b0
Definition snow_dwt.h:37
IDWTELEM * b3
Definition snow_dwt.h:40
IDWTELEM * b2
Definition snow_dwt.h:39
void(* horizontal_compose97i)(IDWTELEM *b, IDWTELEM *temp, int width)
Definition snow_dwt.h:60
void(* vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width)
Definition snow_dwt.h:57
Used to minimize the amount of memory used in order to optimize cache performance.
Definition snow_dwt.h:46
IDWTELEM ** data_stack
Used for internal purposes.
Definition snow_dwt.h:48
int line_count
Definition snow_dwt.h:50
int data_stack_top
Definition snow_dwt.h:49
int line_width
Definition snow_dwt.h:51
IDWTELEM ** line
For use by idwt and predict_slices.
Definition snow_dwt.h:47
int data_count
Definition snow_dwt.h:52
IDWTELEM * base_buffer
Buffer that this structure is caching.
Definition snow_dwt.h:53
uint8_t level
Definition svq3.c:208
#define stride
#define av_malloc_array(a, b)
#define av_freep(p)
static uint8_t tmp[40]
Definition aes_ctr.c:52
#define src
Definition vp8dsp.c:248
static int ref[MAX_W *MAX_W]
static char buffer[20]
Definition seek.c:32
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
int size
else temp
Definition vf_mcdeint.c:275
static double b1(void *priv, double x, double y)
Definition vf_xfade.c:2034
static double b2(void *priv, double x, double y)
Definition vf_xfade.c:2035
static double b3(void *priv, double x, double y)
Definition vf_xfade.c:2036
static double b0(void *priv, double x, double y)
Definition vf_xfade.c:2033
static double c[64]