00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVCODEC_DWT_H
00022 #define AVCODEC_DWT_H
00023
00024 #include <stdint.h>
00025
00026 typedef int DWTELEM;
00027 typedef short IDWTELEM;
00028
00029 #define MAX_DWT_SUPPORT 8
00030 #define MAX_DECOMPOSITIONS 8
00031
00032 typedef struct {
00033 IDWTELEM *b[MAX_DWT_SUPPORT];
00034
00035 IDWTELEM *b0;
00036 IDWTELEM *b1;
00037 IDWTELEM *b2;
00038 IDWTELEM *b3;
00039 int y;
00040 } DWTCompose;
00041
00044 typedef struct slice_buffer_s {
00045 IDWTELEM **line;
00046 IDWTELEM **data_stack;
00047 int data_stack_top;
00048 int line_count;
00049 int line_width;
00050 int data_count;
00051 IDWTELEM *base_buffer;
00052 } slice_buffer;
00053
00054 struct DWTContext;
00055
00056
00057 typedef void (*vertical_compose_2tap)(IDWTELEM *b0, IDWTELEM *b1, int width);
00058 typedef void (*vertical_compose_3tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width);
00059 typedef void (*vertical_compose_5tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, int width);
00060 typedef void (*vertical_compose_9tap)(IDWTELEM *dst, IDWTELEM *b[8], int width);
00061
00062 typedef struct DWTContext {
00063 IDWTELEM *buffer;
00064 IDWTELEM *temp;
00065 int width;
00066 int height;
00067 int stride;
00068 int decomposition_count;
00069 int support;
00070
00071 void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride);
00072 void (*vertical_compose_l0)(void);
00073 void (*vertical_compose_h0)(void);
00074 void (*vertical_compose_l1)(void);
00075 void (*vertical_compose_h1)(void);
00076 void (*vertical_compose)(void);
00077 void (*horizontal_compose)(IDWTELEM *b, IDWTELEM *tmp, int width);
00078
00079 void (*vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
00080 IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5,
00081 int width);
00082 void (*horizontal_compose97i)(IDWTELEM *b, IDWTELEM *temp, int width);
00083 void (*inner_add_yblock)(const uint8_t *obmc, const int obmc_stride,
00084 uint8_t **block, int b_w, int b_h, int src_x,
00085 int src_y, int src_stride, slice_buffer *sb,
00086 int add, uint8_t *dst8);
00087
00088 DWTCompose cs[MAX_DECOMPOSITIONS];
00089 } DWTContext;
00090
00091 enum dwt_type {
00092 DWT_SNOW_DAUB9_7,
00093 DWT_SNOW_LEGALL5_3,
00094 DWT_DIRAC_DD9_7,
00095 DWT_DIRAC_LEGALL5_3,
00096 DWT_DIRAC_DD13_7,
00097 DWT_DIRAC_HAAR0,
00098 DWT_DIRAC_HAAR1,
00099 DWT_DIRAC_FIDELITY,
00100 DWT_DIRAC_DAUB9_7,
00101 DWT_NUM_TYPES
00102 };
00103
00104
00105 int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height,
00106 int stride, enum dwt_type type, int decomposition_count,
00107 IDWTELEM *temp);
00108
00109 int ff_spatial_idwt2(IDWTELEM *buffer, int width, int height, int stride,
00110 enum dwt_type type, int decomposition_count, IDWTELEM *temp);
00111
00112 void ff_spatial_idwt_slice2(DWTContext *d, int y);
00113
00114
00115 #define COMPOSE_53iL0(b0, b1, b2)\
00116 (b1 - ((b0 + b2 + 2) >> 2))
00117
00118 #define COMPOSE_DIRAC53iH0(b0, b1, b2)\
00119 (b1 + ((b0 + b2 + 1) >> 1))
00120
00121 #define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\
00122 (b2 + ((-b0 + 9*b1 + 9*b3 - b4 + 8) >> 4))
00123
00124 #define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)\
00125 (b2 - ((-b0 + 9*b1 + 9*b3 - b4 + 16) >> 5))
00126
00127 #define COMPOSE_HAARiL0(b0, b1)\
00128 (b0 - ((b1 + 1) >> 1))
00129
00130 #define COMPOSE_HAARiH0(b0, b1)\
00131 (b0 + b1)
00132
00133 #define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
00134 (b4 - ((-8*(b0+b8) + 21*(b1+b7) - 46*(b2+b6) + 161*(b3+b5) + 128) >> 8))
00135
00136 #define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
00137 (b4 + ((-2*(b0+b8) + 10*(b1+b7) - 25*(b2+b6) + 81*(b3+b5) + 128) >> 8))
00138
00139 #define COMPOSE_DAUB97iL1(b0, b1, b2)\
00140 (b1 - ((1817*(b0 + b2) + 2048) >> 12))
00141
00142 #define COMPOSE_DAUB97iH1(b0, b1, b2)\
00143 (b1 - (( 113*(b0 + b2) + 64) >> 7))
00144
00145 #define COMPOSE_DAUB97iL0(b0, b1, b2)\
00146 (b1 + (( 217*(b0 + b2) + 2048) >> 12))
00147
00148 #define COMPOSE_DAUB97iH0(b0, b1, b2)\
00149 (b1 + ((6497*(b0 + b2) + 2048) >> 12))
00150
00151
00152
00153 #define DWT_97 0
00154 #define DWT_53 1
00155
00156 #define liftS lift
00157 #define W_AM 3
00158 #define W_AO 0
00159 #define W_AS 1
00160
00161 #undef liftS
00162 #define W_BM 1
00163 #define W_BO 8
00164 #define W_BS 4
00165
00166 #define W_CM 1
00167 #define W_CO 0
00168 #define W_CS 0
00169
00170 #define W_DM 3
00171 #define W_DO 4
00172 #define W_DS 3
00173
00174 #define slice_buffer_get_line(slice_buf, line_num) \
00175 ((slice_buf)->line[line_num] ? (slice_buf)->line[line_num] \
00176 : ff_slice_buffer_load_line((slice_buf), \
00177 (line_num)))
00178
00179 int ff_slice_buffer_init(slice_buffer *buf, int line_count,
00180 int max_allocated_lines, int line_width,
00181 IDWTELEM *base_buffer);
00182 void ff_slice_buffer_release(slice_buffer *buf, int line);
00183 void ff_slice_buffer_flush(slice_buffer *buf);
00184 void ff_slice_buffer_destroy(slice_buffer *buf);
00185 IDWTELEM *ff_slice_buffer_load_line(slice_buffer *buf, int line);
00186
00187 void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
00188 IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5,
00189 int width);
00190 void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width);
00191 void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride,
00192 uint8_t **block, int b_w, int b_h, int src_x,
00193 int src_y, int src_stride, slice_buffer *sb,
00194 int add, uint8_t *dst8);
00195
00196 int ff_w53_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
00197 int ff_w97_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
00198
00199 void ff_spatial_dwt(int *buffer, int *temp, int width, int height, int stride,
00200 int type, int decomposition_count);
00201
00202 void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer *sb, int width,
00203 int height, int stride_line, int type,
00204 int decomposition_count);
00205 void ff_spatial_idwt_buffered_slice(DWTContext *dsp, DWTCompose *cs,
00206 slice_buffer *slice_buf, IDWTELEM *temp,
00207 int width, int height, int stride_line,
00208 int type, int decomposition_count, int y);
00209 void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height,
00210 int stride, int type, int decomposition_count);
00211
00212 void ff_dwt_init(DWTContext *c);
00213 void ff_dwt_init_x86(DWTContext *c);
00214
00215 #endif