2 * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVCODEC_DIRAC_DWT_H
22 #define AVCODEC_DIRAC_DWT_H
27 typedef short IDWTELEM;
29 #define MAX_DWT_SUPPORT 8
30 #define MAX_DECOMPOSITIONS 8
32 typedef struct DWTCompose {
33 IDWTELEM *b[MAX_DWT_SUPPORT];
39 // Possible prototypes for vertical_compose functions
40 typedef void (*vertical_compose_2tap)(IDWTELEM *b0, IDWTELEM *b1, int width);
41 typedef void (*vertical_compose_3tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width);
42 typedef void (*vertical_compose_5tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, int width);
43 typedef void (*vertical_compose_9tap)(IDWTELEM *dst, IDWTELEM *b[8], int width);
45 typedef struct DWTContext {
51 int decomposition_count;
54 void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride);
55 void (*vertical_compose_l0)(void);
56 void (*vertical_compose_h0)(void);
57 void (*vertical_compose_l1)(void);
58 void (*vertical_compose_h1)(void);
59 void (*vertical_compose)(void); ///< one set of lowpass and highpass combined
60 void (*horizontal_compose)(IDWTELEM *b, IDWTELEM *tmp, int width);
62 DWTCompose cs[MAX_DECOMPOSITIONS];
78 // -1 if an error occurred, e.g. the dwt_type isn't recognized
79 int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height,
80 int stride, enum dwt_type type, int decomposition_count,
83 void ff_spatial_idwt_slice2(DWTContext *d, int y);
85 // shared stuff for simd optimiztions
86 #define COMPOSE_53iL0(b0, b1, b2)\
87 (b1 - ((b0 + b2 + 2) >> 2))
89 #define COMPOSE_DIRAC53iH0(b0, b1, b2)\
90 (b1 + ((b0 + b2 + 1) >> 1))
92 #define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\
93 (b2 + ((-b0 + 9*b1 + 9*b3 - b4 + 8) >> 4))
95 #define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)\
96 (b2 - ((-b0 + 9*b1 + 9*b3 - b4 + 16) >> 5))
98 #define COMPOSE_HAARiL0(b0, b1)\
99 (b0 - ((b1 + 1) >> 1))
101 #define COMPOSE_HAARiH0(b0, b1)\
104 #define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
105 (b4 - ((-8*(b0+b8) + 21*(b1+b7) - 46*(b2+b6) + 161*(b3+b5) + 128) >> 8))
107 #define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
108 (b4 + ((-2*(b0+b8) + 10*(b1+b7) - 25*(b2+b6) + 81*(b3+b5) + 128) >> 8))
110 #define COMPOSE_DAUB97iL1(b0, b1, b2)\
111 (b1 - ((1817*(b0 + b2) + 2048) >> 12))
113 #define COMPOSE_DAUB97iH1(b0, b1, b2)\
114 (b1 - (( 113*(b0 + b2) + 64) >> 7))
116 #define COMPOSE_DAUB97iL0(b0, b1, b2)\
117 (b1 + (( 217*(b0 + b2) + 2048) >> 12))
119 #define COMPOSE_DAUB97iH0(b0, b1, b2)\
120 (b1 + ((6497*(b0 + b2) + 2048) >> 12))
123 #endif /* AVCODEC_DWT_H */