jpeg2000: Factor out band initialization
[libav.git] / libavcodec / jpeg2000.c
CommitLineData
c81a7063
NB
1/*
2 * JPEG 2000 encoder and decoder common functions
3 * Copyright (c) 2007 Kamil Nowosad
4 * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
5 *
6 * This file is part of Libav.
7 *
8 * Libav is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * Libav is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * JPEG 2000 image encoder and decoder common functions
26 */
27
fe4d5fe9 28#include "libavutil/attributes.h"
c81a7063
NB
29#include "libavutil/common.h"
30#include "libavutil/mem.h"
31#include "avcodec.h"
32#include "jpeg2000.h"
33
34#define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
35
36/* tag tree routines */
37
38/* allocate the memory for tag tree */
39static int32_t tag_tree_size(uint16_t w, uint16_t h)
40{
41 uint32_t res = 0;
42 while (w > 1 || h > 1) {
43 res += w * h;
44 if (res + 1 >= INT32_MAX)
45 return -1;
46 w = (w + 1) >> 1;
47 h = (h + 1) >> 1;
48 }
49 return (int32_t)(res + 1);
50}
51
52static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h)
53{
54 int pw = w, ph = h;
55 Jpeg2000TgtNode *res, *t, *t2;
56 int32_t tt_size;
57
58 tt_size = tag_tree_size(w, h);
59 if (tt_size == -1)
60 return NULL;
61
62 t = res = av_mallocz_array(tt_size, sizeof(*t));
63 if (!res)
64 return NULL;
65
66 while (w > 1 || h > 1) {
67 int i, j;
68 pw = w;
69 ph = h;
70
71 w = (w + 1) >> 1;
72 h = (h + 1) >> 1;
73 t2 = t + pw * ph;
74
75 for (i = 0; i < ph; i++)
76 for (j = 0; j < pw; j++)
77 t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)];
78
79 t = t2;
80 }
81 t[0].parent = NULL;
82 return res;
83}
84
85uint8_t ff_jpeg2000_sigctxno_lut[256][4];
86
87static int getsigctxno(int flag, int bandno)
88{
89 int h, v, d;
90
91 h = ((flag & JPEG2000_T1_SIG_E) ? 1 : 0) +
92 ((flag & JPEG2000_T1_SIG_W) ? 1 : 0);
93 v = ((flag & JPEG2000_T1_SIG_N) ? 1 : 0) +
94 ((flag & JPEG2000_T1_SIG_S) ? 1 : 0);
95 d = ((flag & JPEG2000_T1_SIG_NE) ? 1 : 0) +
96 ((flag & JPEG2000_T1_SIG_NW) ? 1 : 0) +
97 ((flag & JPEG2000_T1_SIG_SE) ? 1 : 0) +
98 ((flag & JPEG2000_T1_SIG_SW) ? 1 : 0);
99 if (bandno < 3) {
100 if (bandno == 1)
101 FFSWAP(int, h, v);
102 if (h == 2)
103 return 8;
104 if (h == 1) {
105 if (v >= 1)
106 return 7;
107 if (d >= 1)
108 return 6;
109 return 5;
110 }
111 if (v == 2)
112 return 4;
113 if (v == 1)
114 return 3;
115 if (d >= 2)
116 return 2;
117 if (d == 1)
118 return 1;
c81a7063
NB
119 } else {
120 if (d >= 3)
121 return 8;
122 if (d == 2) {
123 if (h + v >= 1)
124 return 7;
125 return 6;
126 }
127 if (d == 1) {
128 if (h + v >= 2)
129 return 5;
130 if (h + v == 1)
131 return 4;
132 return 3;
133 }
134 if (h + v >= 2)
135 return 2;
136 if (h + v == 1)
137 return 1;
c81a7063
NB
138 }
139 return 0;
140}
141
142uint8_t ff_jpeg2000_sgnctxno_lut[16][16], ff_jpeg2000_xorbit_lut[16][16];
143
144static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
145static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
146static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
147
148static int getsgnctxno(int flag, uint8_t *xorbit)
149{
150 int vcontrib, hcontrib;
151
152 hcontrib = contribtab[flag & JPEG2000_T1_SIG_E ? flag & JPEG2000_T1_SGN_E ? 1 : 2 : 0]
153 [flag & JPEG2000_T1_SIG_W ? flag & JPEG2000_T1_SGN_W ? 1 : 2 : 0] + 1;
154 vcontrib = contribtab[flag & JPEG2000_T1_SIG_S ? flag & JPEG2000_T1_SGN_S ? 1 : 2 : 0]
155 [flag & JPEG2000_T1_SIG_N ? flag & JPEG2000_T1_SGN_N ? 1 : 2 : 0] + 1;
156 *xorbit = xorbittab[hcontrib][vcontrib];
157
158 return ctxlbltab[hcontrib][vcontrib];
159}
160
fe4d5fe9 161void av_cold ff_jpeg2000_init_tier1_luts(void)
c81a7063
NB
162{
163 int i, j;
164 for (i = 0; i < 256; i++)
165 for (j = 0; j < 4; j++)
166 ff_jpeg2000_sigctxno_lut[i][j] = getsigctxno(i, j);
167 for (i = 0; i < 16; i++)
168 for (j = 0; j < 16; j++)
169 ff_jpeg2000_sgnctxno_lut[i][j] =
170 getsgnctxno(i + (j << 8), &ff_jpeg2000_xorbit_lut[i][j]);
171}
172
173void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y,
174 int negative)
175{
176 x++;
177 y++;
178 t1->flags[y][x] |= JPEG2000_T1_SIG;
179 if (negative) {
180 t1->flags[y][x + 1] |= JPEG2000_T1_SIG_W | JPEG2000_T1_SGN_W;
181 t1->flags[y][x - 1] |= JPEG2000_T1_SIG_E | JPEG2000_T1_SGN_E;
182 t1->flags[y + 1][x] |= JPEG2000_T1_SIG_N | JPEG2000_T1_SGN_N;
183 t1->flags[y - 1][x] |= JPEG2000_T1_SIG_S | JPEG2000_T1_SGN_S;
184 } else {
185 t1->flags[y][x + 1] |= JPEG2000_T1_SIG_W;
186 t1->flags[y][x - 1] |= JPEG2000_T1_SIG_E;
187 t1->flags[y + 1][x] |= JPEG2000_T1_SIG_N;
188 t1->flags[y - 1][x] |= JPEG2000_T1_SIG_S;
189 }
190 t1->flags[y + 1][x + 1] |= JPEG2000_T1_SIG_NW;
191 t1->flags[y + 1][x - 1] |= JPEG2000_T1_SIG_NE;
192 t1->flags[y - 1][x + 1] |= JPEG2000_T1_SIG_SW;
193 t1->flags[y - 1][x - 1] |= JPEG2000_T1_SIG_SE;
194}
195
196static const uint8_t lut_gain[2][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 2 } };
197
7fb93eae
LB
198static int init_band(AVCodecContext *avctx,
199 Jpeg2000ResLevel *reslevel,
200 Jpeg2000Component *comp,
201 Jpeg2000CodingStyle *codsty,
202 Jpeg2000QuantStyle *qntsty,
203 int bandno, int gbandno, int reslevelno,
204 int cbps, int dx, int dy)
205{
206 Jpeg2000Band *band = reslevel->band + bandno;
207 uint8_t log2_band_prec_width, log2_band_prec_height;
208 int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
209 int cblkno, precno;
210 int nb_precincts;
211 int i, j;
212
213 /* TODO: Implementation of quantization step not finished,
214 * see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
215 switch (qntsty->quantsty) {
216 uint8_t gain;
217 int numbps;
218 case JPEG2000_QSTY_NONE:
219 /* TODO: to verify. No quantization in this case */
220 band->f_stepsize = 1;
221 break;
222 case JPEG2000_QSTY_SI:
223 /*TODO: Compute formula to implement. */
224 numbps = cbps +
225 lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)];
226 band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
227 2 + numbps - qntsty->expn[gbandno]);
228 break;
229 case JPEG2000_QSTY_SE:
230 /* Exponent quantization step.
231 * Formula:
232 * delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11))
233 * R_b = R_I + log2 (gain_b )
234 * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
235 /* TODO/WARN: value of log2 (gain_b ) not taken into account
236 * but it works (compared to OpenJPEG). Why?
237 * Further investigation needed. */
238 gain = cbps;
239 band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
240 band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
241 break;
242 default:
243 band->f_stepsize = 0;
244 av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
245 break;
246 }
247 /* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
248 * If not set output of entropic decoder is not correct. */
249 if (!av_codec_is_encoder(avctx->codec))
250 band->f_stepsize *= 0.5;
251
252 band->i_stepsize = band->f_stepsize * (1 << 16);
253
254 /* computation of tbx_0, tbx_1, tby_0, tby_1
255 * see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1
256 * codeblock width and height is computed for
257 * DCI JPEG 2000 codeblock_width = codeblock_width = 32 = 2 ^ 5 */
258 if (reslevelno == 0) {
259 /* for reslevelno = 0, only one band, x0_b = y0_b = 0 */
260 for (i = 0; i < 2; i++)
261 for (j = 0; j < 2; j++)
262 band->coord[i][j] =
263 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0],
264 declvl - 1);
265 log2_band_prec_width = reslevel->log2_prec_width;
266 log2_band_prec_height = reslevel->log2_prec_height;
267 /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
268 band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
269 reslevel->log2_prec_width);
270 band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
271 reslevel->log2_prec_height);
272 } else {
273 /* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
274 /* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */
275 for (i = 0; i < 2; i++)
276 for (j = 0; j < 2; j++)
277 /* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
278 band->coord[i][j] =
279 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] -
280 (((bandno + 1 >> i) & 1) << declvl - 1),
281 declvl);
282 /* TODO: Manage case of 3 band offsets here or
283 * in coding/decoding function? */
284
285 /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
286 band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
287 reslevel->log2_prec_width - 1);
288 band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
289 reslevel->log2_prec_height - 1);
290
291 log2_band_prec_width = reslevel->log2_prec_width - 1;
292 log2_band_prec_height = reslevel->log2_prec_height - 1;
293 }
294
295 for (j = 0; j < 2; j++)
296 band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
297 for (j = 0; j < 2; j++)
298 band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
299
300 nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
301 band->prec = av_mallocz_array(nb_precincts, sizeof(*band->prec));
302 if (!band->prec)
303 return AVERROR(ENOMEM);
304
305 for (precno = 0; precno < nb_precincts; precno++) {
306 Jpeg2000Prec *prec = band->prec + precno;
307 int nb_codeblocks;
308
309 /* TODO: Explain formula for JPEG200 DCINEMA. */
310 /* TODO: Verify with previous count of codeblocks per band */
311
312 /* Compute P_x0 */
313 prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
314 (1 << log2_band_prec_width);
315 prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
316
317 /* Compute P_y0 */
318 prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
319 (1 << log2_band_prec_height);
320 prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
321
322 /* Compute P_x1 */
323 prec->coord[0][1] = prec->coord[0][0] +
324 (1 << log2_band_prec_width);
325 prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
326
327 /* Compute P_y1 */
328 prec->coord[1][1] = prec->coord[1][0] +
329 (1 << log2_band_prec_height);
330 prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
331
332 prec->nb_codeblocks_width =
333 ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
334 prec->coord[0][0],
335 band->log2_cblk_width);
336 prec->nb_codeblocks_height =
337 ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
338 prec->coord[1][0],
339 band->log2_cblk_height);
340
341 /* Tag trees initialization */
342 prec->cblkincl =
343 ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
344 prec->nb_codeblocks_height);
345 if (!prec->cblkincl)
346 return AVERROR(ENOMEM);
347
348 prec->zerobits =
349 ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
350 prec->nb_codeblocks_height);
351 if (!prec->zerobits)
352 return AVERROR(ENOMEM);
353
354 nb_codeblocks = prec->nb_codeblocks_width * prec->nb_codeblocks_height;
355 prec->cblk = av_mallocz_array(nb_codeblocks, sizeof(*prec->cblk));
356 if (!prec->cblk)
357 return AVERROR(ENOMEM);
358 for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
359 Jpeg2000Cblk *cblk = prec->cblk + cblkno;
360 uint16_t Cx0, Cy0;
361
362 /* Compute coordinates of codeblocks */
363 /* Compute Cx0*/
364 Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
365 Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
366 cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
367
368 /* Compute Cy0*/
369 Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
370 Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
371 cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
372
373 /* Compute Cx1 */
374 cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
375 prec->coord[0][1]);
376
377 /* Compute Cy1 */
378 cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
379 prec->coord[1][1]);
380 /* Update code-blocks coordinates according sub-band position */
381 if ((bandno + !!reslevelno) & 1) {
382 cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] -
383 comp->reslevel[reslevelno-1].coord[0][0];
384 cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] -
385 comp->reslevel[reslevelno-1].coord[0][0];
386 }
387 if ((bandno + !!reslevelno) & 2) {
388 cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] -
389 comp->reslevel[reslevelno-1].coord[1][0];
390 cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] -
391 comp->reslevel[reslevelno-1].coord[1][0];
392 }
393
394 cblk->zero = 0;
395 cblk->lblock = 3;
396 cblk->length = 0;
397 cblk->lengthinc = 0;
398 cblk->npasses = 0;
399 }
400 }
401
402 return 0;
403}
404
c81a7063
NB
405int ff_jpeg2000_init_component(Jpeg2000Component *comp,
406 Jpeg2000CodingStyle *codsty,
407 Jpeg2000QuantStyle *qntsty,
408 int cbps, int dx, int dy,
409 AVCodecContext *avctx)
410{
c81a7063 411 int reslevelno, bandno, gbandno = 0, ret, i, j;
690c8af9 412 uint32_t csize;
c81a7063 413
78962d3d
MN
414 if (!codsty->nreslevels2decode) {
415 av_log(avctx, AV_LOG_ERROR, "nreslevels2decode uninitialized\n");
416 return AVERROR_INVALIDDATA;
417 }
418
c81a7063
NB
419 if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord,
420 codsty->nreslevels2decode - 1,
421 codsty->transform))
422 return ret;
423 // component size comp->coord is uint16_t so ir cannot overflow
424 csize = (comp->coord[0][1] - comp->coord[0][0]) *
425 (comp->coord[1][1] - comp->coord[1][0]);
426
5bf208f6
MN
427 if (codsty->transform == FF_DWT97) {
428 comp->i_data = NULL;
429 comp->f_data = av_malloc_array(csize, sizeof(*comp->f_data));
430 if (!comp->f_data)
431 return AVERROR(ENOMEM);
432 } else {
433 comp->f_data = NULL;
434 comp->i_data = av_malloc_array(csize, sizeof(*comp->i_data));
435 if (!comp->i_data)
436 return AVERROR(ENOMEM);
437 }
10306e9c 438 comp->reslevel = av_mallocz_array(codsty->nreslevels, sizeof(*comp->reslevel));
c81a7063
NB
439 if (!comp->reslevel)
440 return AVERROR(ENOMEM);
441 /* LOOP on resolution levels */
442 for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
443 int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
444 Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
445
446 /* Compute borders for each resolution level.
447 * Computation of trx_0, trx_1, try_0 and try_1.
448 * see ISO/IEC 15444-1:2002 eq. B.5 and B-14 */
449 for (i = 0; i < 2; i++)
450 for (j = 0; j < 2; j++)
451 reslevel->coord[i][j] =
452 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
453 // update precincts size: 2^n value
454 reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
455 reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
456
457 /* Number of bands for each resolution level */
458 if (reslevelno == 0)
459 reslevel->nbands = 1;
460 else
461 reslevel->nbands = 3;
462
463 /* Number of precincts wich span the tile for resolution level reslevelno
464 * see B.6 in ISO/IEC 15444-1:2002 eq. B-16
465 * num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -| - (trx_0 / 2 ^ log2_prec_width)
466 * num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| - (try_0 / 2 ^ log2_prec_width)
467 * for Dcinema profiles in JPEG 2000
468 * num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -|
469 * num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| */
470 if (reslevel->coord[0][1] == reslevel->coord[0][0])
471 reslevel->num_precincts_x = 0;
472 else
473 reslevel->num_precincts_x =
474 ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
475 reslevel->log2_prec_width) -
476 (reslevel->coord[0][0] >> reslevel->log2_prec_width);
477
478 if (reslevel->coord[1][1] == reslevel->coord[1][0])
479 reslevel->num_precincts_y = 0;
480 else
481 reslevel->num_precincts_y =
482 ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
483 reslevel->log2_prec_height) -
484 (reslevel->coord[1][0] >> reslevel->log2_prec_height);
485
10306e9c 486 reslevel->band = av_mallocz_array(reslevel->nbands, sizeof(*reslevel->band));
c81a7063
NB
487 if (!reslevel->band)
488 return AVERROR(ENOMEM);
489
490 for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
7fb93eae
LB
491 ret = init_band(avctx, reslevel,
492 comp, codsty, qntsty,
493 bandno, gbandno, reslevelno,
494 cbps, dx, dy);
495 if (ret < 0)
496 return ret;
c81a7063
NB
497 }
498 }
499 return 0;
500}
501
502void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
503{
504 int reslevelno, bandno, precno;
daeb4e30
LB
505 for (reslevelno = 0;
506 comp->reslevel && reslevelno < codsty->nreslevels;
507 reslevelno++) {
10306e9c
VG
508 Jpeg2000ResLevel *reslevel;
509
510 if (!comp->reslevel)
511 continue;
c81a7063 512
10306e9c 513 reslevel = comp->reslevel + reslevelno;
c81a7063 514 for (bandno = 0; bandno < reslevel->nbands; bandno++) {
10306e9c
VG
515 Jpeg2000Band *band;
516
517 if (!reslevel->band)
518 continue;
519
520 band = reslevel->band + bandno;
c81a7063 521 for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++) {
10306e9c
VG
522 Jpeg2000Prec *prec;
523
524 if (!band->prec)
525 continue;
526
527 prec = band->prec + precno;
c81a7063
NB
528 av_freep(&prec->zerobits);
529 av_freep(&prec->cblkincl);
530 av_freep(&prec->cblk);
10306e9c 531
c81a7063
NB
532 }
533
534 av_freep(&band->prec);
535 }
536 av_freep(&reslevel->band);
537 }
538
539 ff_dwt_destroy(&comp->dwt);
540 av_freep(&comp->reslevel);
5bf208f6
MN
541 av_freep(&comp->i_data);
542 av_freep(&comp->f_data);
c81a7063 543}