FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dirac_dwt.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of FFmpeg.
5  *
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.
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 GNU
14  * Lesser General Public License for more details.
15  *
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
19  */
20 
21 #ifndef AVCODEC_DIRAC_DWT_H
22 #define AVCODEC_DIRAC_DWT_H
23 
24 #include <stdint.h>
25 
26 typedef int DWTELEM;
27 typedef short IDWTELEM;
28 
29 #define MAX_DWT_SUPPORT 8
30 #define MAX_DECOMPOSITIONS 8
31 
32 typedef struct DWTCompose {
34  int y;
35 } DWTCompose;
36 
37 struct DWTContext;
38 
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);
44 
45 typedef struct DWTContext {
48  int width;
49  int height;
50  int stride;
52  int support;
53 
54  void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride);
59  void (*vertical_compose)(void); ///< one set of lowpass and highpass combined
61 
63 } DWTContext;
64 
65 enum dwt_type {
76 };
77 
78 // -1 if an error occurred, e.g. the dwt_type isn't recognized
80  int stride, enum dwt_type type, int decomposition_count,
81  IDWTELEM *temp);
82 
85 
86 void ff_spatial_idwt_slice2(DWTContext *d, int y);
87 
88 // shared stuff for simd optimiztions
89 #define COMPOSE_53iL0(b0, b1, b2)\
90  (b1 - ((b0 + b2 + 2) >> 2))
91 
92 #define COMPOSE_DIRAC53iH0(b0, b1, b2)\
93  (b1 + ((b0 + b2 + 1) >> 1))
94 
95 #define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\
96  (b2 + ((-b0 + 9*b1 + 9*b3 - b4 + 8) >> 4))
97 
98 #define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)\
99  (b2 - ((-b0 + 9*b1 + 9*b3 - b4 + 16) >> 5))
100 
101 #define COMPOSE_HAARiL0(b0, b1)\
102  (b0 - ((b1 + 1) >> 1))
103 
104 #define COMPOSE_HAARiH0(b0, b1)\
105  (b0 + b1)
106 
107 #define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
108  (b4 - ((-8*(b0+b8) + 21*(b1+b7) - 46*(b2+b6) + 161*(b3+b5) + 128) >> 8))
109 
110 #define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
111  (b4 + ((-2*(b0+b8) + 10*(b1+b7) - 25*(b2+b6) + 81*(b3+b5) + 128) >> 8))
112 
113 #define COMPOSE_DAUB97iL1(b0, b1, b2)\
114  (b1 - ((1817*(b0 + b2) + 2048) >> 12))
115 
116 #define COMPOSE_DAUB97iH1(b0, b1, b2)\
117  (b1 - (( 113*(b0 + b2) + 64) >> 7))
118 
119 #define COMPOSE_DAUB97iL0(b0, b1, b2)\
120  (b1 + (( 217*(b0 + b2) + 2048) >> 12))
121 
122 #define COMPOSE_DAUB97iH0(b0, b1, b2)\
123  (b1 + ((6497*(b0 + b2) + 2048) >> 12))
124 
125 
126 #endif /* AVCODEC_DWT_H */