30 static const float scale97[] = {1.625786, 1.230174};
32 static inline void extend53(
int *p,
int i0,
int i1)
34 p[i0 - 1] = p[i0 + 1];
36 p[i0 - 2] = p[i0 + 2];
37 p[i1 + 1] = p[i1 - 3];
40 static inline void extend97(
float *p,
int i0,
int i1)
44 for (i = 1; i <= 4; i++){
45 p[i0 -
i] = p[i0 +
i];
46 p[i1 + i - 1] = p[i1 - i - 1];
50 static void sd_1d53(
int *p,
int i0,
int i1)
59 for (i = (i0+1)/2 - 1; i < (i1+1)/2; i++)
60 p[2*i+1] -= (p[2*i] + p[2*i+2]) >> 1;
61 for (i = (i0+1)/2; i < (i1+1)/2; i++)
62 p[2*i] += (p[2*i-1] + p[2*i+1] + 2) >> 2;
82 for (lp = 0; lp < lv; lp++){
85 for (i = 0; i < lh; i++)
91 for (i = mh; i < lh; i+=2, j++)
93 for (i = 1-mh; i < lh; i+=2, j++)
99 for (lp = 0; lp < lh; lp++) {
102 for (i = 0; i < lv; i++)
108 for (i = mv; i < lv; i+=2, j++)
110 for (i = 1-mv; i < lv; i+=2, j++)
126 for (i = i0/2 - 2; i < i1/2 + 1; i++)
127 p[2*i+1] -= 1.586134 * (p[2*i] + p[2*i+2]);
128 for (i = i0/2 - 1; i < i1/2 + 1; i++)
129 p[2*i] -= 0.052980 * (p[2*i-1] + p[2*i+1]);
130 for (i = i0/2 - 1; i < i1/2; i++)
131 p[2*i+1] += 0.882911 * (p[2*i] + p[2*i+2]);
132 for (i = i0/2; i < i1/2; i++)
133 p[2*i] += 0.443506 * (p[2*i-1] + p[2*i+1]);
153 for (lp = 0; lp < lv; lp++){
156 for (i = 0; i < lh; i++)
162 for (i = mh; i < lh; i+=2, j++)
163 t[w*lp + j] =
scale97[mh] * l[i] / 2;
164 for (i = 1-mh; i < lh; i+=2, j++)
165 t[w*lp + j] =
scale97[mh] * l[i] / 2;
170 for (lp = 0; lp < lh; lp++) {
173 for (i = 0; i < lv; i++)
179 for (i = mv; i < lv; i+=2, j++)
180 t[w*j + lp] =
scale97[mv] * l[i] / 2;
181 for (i = 1-mv; i < lv; i+=2, j++)
182 t[w*j + lp] =
scale97[mv] * l[i] / 2;
196 for (i = i0/2; i < i1/2 + 1; i++)
197 p[2*i] -= (p[2*i-1] + p[2*i+1] + 2) >> 2;
198 for (i = i0/2; i < i1/2; i++)
199 p[2*i+1] += (p[2*i] + p[2*i+2]) >> 1;
219 for (lp = 0; lp < lv; lp++){
222 for (i = mh; i < lh; i+=2, j++)
224 for (i = 1-mh; i < lh; i+=2, j++)
229 for (i = 0; i < lh; i++)
235 for (lp = 0; lp < lh; lp++){
238 for (i = mv; i < lv; i+=2, j++)
240 for (i = 1-mv; i < lv; i+=2, j++)
245 for (i = 0; i < lv; i++)
260 for (i = i0/2 - 1; i < i1/2 + 2; i++)
261 p[2*i] -= 0.443506 * (p[2*i-1] + p[2*i+1]);
262 for (i = i0/2 - 1; i < i1/2 + 1; i++)
263 p[2*i+1] -= 0.882911 * (p[2*i] + p[2*i+2]);
264 for (i = i0/2; i < i1/2 + 1; i++)
265 p[2*i] += 0.052980 * (p[2*i-1] + p[2*i+1]);
266 for (i = i0/2; i < i1/2; i++)
267 p[2*i+1] += 1.586134 * (p[2*i] + p[2*i+2]);
287 for (lp = 0; lp < lv; lp++){
290 for (i = mh; i < lh; i+=2, j++)
291 l[i] =
scale97[1-mh] * t[w*lp + j];
292 for (i = 1-mh; i < lh; i+=2, j++)
293 l[i] =
scale97[1-mh] * t[w*lp + j];
297 for (i = 0; i < lh; i++)
303 for (lp = 0; lp < lh; lp++){
306 for (i = mv; i < lv; i+=2, j++)
307 l[i] =
scale97[1-mv] * t[w*j + lp];
308 for (i = 1-mv; i < lv; i+=2, j++)
309 l[i] =
scale97[1-mv] * t[w*j + lp];
313 for (i = 0; i < lv; i++)
321 int i, j, lev = decomp_levels, maxlen,
329 for (i = 0; i < 2; i++)
330 for(j = 0; j < 2; j++)
331 b[i][j] = border[i][j];
333 maxlen =
FFMAX(b[0][1] - b[0][0],
337 for (i = 0; i < 2; i++){
339 s->
mod[lev][
i] = b[
i][0] & 1;
340 for (j = 0; j < 2; j++)
341 b[i][j] = (b[i][j] + 1) >> 1;
uint16_t linelen[FF_DWT_MAX_DECLVLS][2]
line lengths {horizontal, vertical} in consecutive decomposition levels
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint8_t ndeclevels
number of decomposition levels
uint8_t type
0 for 9/7; 1 for 5/3
output residual component w
static void dwt_decode53(DWTContext *s, int *t)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static void dwt_encode97(DWTContext *s, int *t)
int ff_j2k_dwt_decode(DWTContext *s, int *t)
void ff_j2k_dwt_destroy(DWTContext *s)
static const float scale97[]
static void dwt_encode53(DWTContext *s, int *t)
static void sr_1d53(int *p, int i0, int i1)
static void extend97(float *p, int i0, int i1)
void * linebuf
buffer used by transform (int or float)
static void sd_1d53(int *p, int i0, int i1)
static void dwt_decode97(DWTContext *s, int *t)
static void sd_1d97(float *p, int i0, int i1)
static const int8_t mv[256][2]
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Discrete wavelet transform.
synthesis window for stochastic i
#define FF_DWT_MAX_DECLVLS
max number of decomposition levels
int ff_j2k_dwt_encode(DWTContext *s, int *t)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
int ff_j2k_dwt_init(DWTContext *s, uint16_t border[2][2], int decomp_levels, int type)
initialize DWT
static void sr_1d97(float *p, int i0, int i1)
static void extend53(int *p, int i0, int i1)
uint8_t mod[FF_DWT_MAX_DECLVLS][2]
coordinates (x0, y0) of decomp. levels mod 2