77cadd860300f7eed3f575733abfea3826313cb7
[libav.git] / libavcodec / jpeg2000.c
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
28 #include "libavutil/attributes.h"
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 */
39 static 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
52 static 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
85 uint8_t ff_jpeg2000_sigctxno_lut[256][4];
86
87 static 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;
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;
138 }
139 return 0;
140 }
141
142 uint8_t ff_jpeg2000_sgnctxno_lut[16][16], ff_jpeg2000_xorbit_lut[16][16];
143
144 static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
145 static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
146 static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
147
148 static 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
161 void av_cold ff_jpeg2000_init_tier1_luts(void)
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
173 void 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
196 static const uint8_t lut_gain[2][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 2 } };
197
198 static void init_band_stepsize(AVCodecContext *avctx,
199 Jpeg2000Band *band,
200 Jpeg2000CodingStyle *codsty,
201 Jpeg2000QuantStyle *qntsty,
202 int bandno, int gbandno, int reslevelno,
203 int cbps)
204 {
205 /* TODO: Implementation of quantization step not finished,
206 * see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
207 switch (qntsty->quantsty) {
208 uint8_t gain;
209 int numbps;
210 case JPEG2000_QSTY_NONE:
211 /* TODO: to verify. No quantization in this case */
212 band->f_stepsize = 1;
213 break;
214 case JPEG2000_QSTY_SI:
215 /*TODO: Compute formula to implement. */
216 numbps = cbps +
217 lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)];
218 band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
219 2 + numbps - qntsty->expn[gbandno]);
220 break;
221 case JPEG2000_QSTY_SE:
222 /* Exponent quantization step.
223 * Formula:
224 * delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11))
225 * R_b = R_I + log2 (gain_b )
226 * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
227 /* TODO/WARN: value of log2 (gain_b ) not taken into account
228 * but it works (compared to OpenJPEG). Why?
229 * Further investigation needed. */
230 gain = cbps;
231 band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
232 band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
233 break;
234 default:
235 band->f_stepsize = 0;
236 av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
237 break;
238 }
239 /* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
240 * If not set output of entropic decoder is not correct. */
241 if (!av_codec_is_encoder(avctx->codec))
242 band->f_stepsize *= 0.5;
243
244 band->i_stepsize = band->f_stepsize * (1 << 16);
245 }
246
247 static int init_band(AVCodecContext *avctx,
248 Jpeg2000ResLevel *reslevel,
249 Jpeg2000Component *comp,
250 Jpeg2000CodingStyle *codsty,
251 Jpeg2000QuantStyle *qntsty,
252 int bandno, int gbandno, int reslevelno,
253 int cbps, int dx, int dy)
254 {
255 Jpeg2000Band *band = reslevel->band + bandno;
256 uint8_t log2_band_prec_width, log2_band_prec_height;
257 int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
258 int cblkno, precno;
259 int nb_precincts;
260 int i, j;
261
262 init_band_stepsize(avctx, band, codsty, qntsty, bandno, gbandno, reslevelno, cbps);
263
264
265 /* computation of tbx_0, tbx_1, tby_0, tby_1
266 * see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1
267 * codeblock width and height is computed for
268 * DCI JPEG 2000 codeblock_width = codeblock_width = 32 = 2 ^ 5 */
269 if (reslevelno == 0) {
270 /* for reslevelno = 0, only one band, x0_b = y0_b = 0 */
271 for (i = 0; i < 2; i++)
272 for (j = 0; j < 2; j++)
273 band->coord[i][j] =
274 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0],
275 declvl - 1);
276 log2_band_prec_width = reslevel->log2_prec_width;
277 log2_band_prec_height = reslevel->log2_prec_height;
278 /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
279 band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
280 reslevel->log2_prec_width);
281 band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
282 reslevel->log2_prec_height);
283 } else {
284 /* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
285 /* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */
286 for (i = 0; i < 2; i++)
287 for (j = 0; j < 2; j++)
288 /* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
289 band->coord[i][j] =
290 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] -
291 (((bandno + 1 >> i) & 1) << declvl - 1),
292 declvl);
293 /* TODO: Manage case of 3 band offsets here or
294 * in coding/decoding function? */
295
296 /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
297 band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
298 reslevel->log2_prec_width - 1);
299 band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
300 reslevel->log2_prec_height - 1);
301
302 log2_band_prec_width = reslevel->log2_prec_width - 1;
303 log2_band_prec_height = reslevel->log2_prec_height - 1;
304 }
305
306 for (j = 0; j < 2; j++)
307 band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
308 for (j = 0; j < 2; j++)
309 band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
310
311 nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
312 band->prec = av_mallocz_array(nb_precincts, sizeof(*band->prec));
313 if (!band->prec)
314 return AVERROR(ENOMEM);
315
316 for (precno = 0; precno < nb_precincts; precno++) {
317 Jpeg2000Prec *prec = band->prec + precno;
318 int nb_codeblocks;
319
320 /* TODO: Explain formula for JPEG200 DCINEMA. */
321 /* TODO: Verify with previous count of codeblocks per band */
322
323 /* Compute P_x0 */
324 prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
325 (1 << log2_band_prec_width);
326 prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
327
328 /* Compute P_y0 */
329 prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
330 (1 << log2_band_prec_height);
331 prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
332
333 /* Compute P_x1 */
334 prec->coord[0][1] = prec->coord[0][0] +
335 (1 << log2_band_prec_width);
336 prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
337
338 /* Compute P_y1 */
339 prec->coord[1][1] = prec->coord[1][0] +
340 (1 << log2_band_prec_height);
341 prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
342
343 prec->nb_codeblocks_width =
344 ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
345 prec->coord[0][0],
346 band->log2_cblk_width);
347 prec->nb_codeblocks_height =
348 ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
349 prec->coord[1][0],
350 band->log2_cblk_height);
351
352 /* Tag trees initialization */
353 prec->cblkincl =
354 ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
355 prec->nb_codeblocks_height);
356 if (!prec->cblkincl)
357 return AVERROR(ENOMEM);
358
359 prec->zerobits =
360 ff_jpeg2000_tag_tree_init(prec->nb_codeblocks_width,
361 prec->nb_codeblocks_height);
362 if (!prec->zerobits)
363 return AVERROR(ENOMEM);
364
365 nb_codeblocks = prec->nb_codeblocks_width * prec->nb_codeblocks_height;
366 prec->cblk = av_mallocz_array(nb_codeblocks, sizeof(*prec->cblk));
367 if (!prec->cblk)
368 return AVERROR(ENOMEM);
369 for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
370 Jpeg2000Cblk *cblk = prec->cblk + cblkno;
371 uint16_t Cx0, Cy0;
372
373 /* Compute coordinates of codeblocks */
374 /* Compute Cx0*/
375 Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
376 Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
377 cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
378
379 /* Compute Cy0*/
380 Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
381 Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
382 cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
383
384 /* Compute Cx1 */
385 cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
386 prec->coord[0][1]);
387
388 /* Compute Cy1 */
389 cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
390 prec->coord[1][1]);
391 /* Update code-blocks coordinates according sub-band position */
392 if ((bandno + !!reslevelno) & 1) {
393 cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] -
394 comp->reslevel[reslevelno-1].coord[0][0];
395 cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] -
396 comp->reslevel[reslevelno-1].coord[0][0];
397 }
398 if ((bandno + !!reslevelno) & 2) {
399 cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] -
400 comp->reslevel[reslevelno-1].coord[1][0];
401 cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] -
402 comp->reslevel[reslevelno-1].coord[1][0];
403 }
404
405 cblk->zero = 0;
406 cblk->lblock = 3;
407 cblk->length = 0;
408 cblk->lengthinc = 0;
409 cblk->npasses = 0;
410 }
411 }
412
413 return 0;
414 }
415
416 int ff_jpeg2000_init_component(Jpeg2000Component *comp,
417 Jpeg2000CodingStyle *codsty,
418 Jpeg2000QuantStyle *qntsty,
419 int cbps, int dx, int dy,
420 AVCodecContext *avctx)
421 {
422 int reslevelno, bandno, gbandno = 0, ret, i, j;
423 uint32_t csize;
424
425 if (!codsty->nreslevels2decode) {
426 av_log(avctx, AV_LOG_ERROR, "nreslevels2decode uninitialized\n");
427 return AVERROR_INVALIDDATA;
428 }
429
430 if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord,
431 codsty->nreslevels2decode - 1,
432 codsty->transform))
433 return ret;
434 // component size comp->coord is uint16_t so ir cannot overflow
435 csize = (comp->coord[0][1] - comp->coord[0][0]) *
436 (comp->coord[1][1] - comp->coord[1][0]);
437
438 if (codsty->transform == FF_DWT97) {
439 comp->i_data = NULL;
440 comp->f_data = av_malloc_array(csize, sizeof(*comp->f_data));
441 if (!comp->f_data)
442 return AVERROR(ENOMEM);
443 } else {
444 comp->f_data = NULL;
445 comp->i_data = av_malloc_array(csize, sizeof(*comp->i_data));
446 if (!comp->i_data)
447 return AVERROR(ENOMEM);
448 }
449 comp->reslevel = av_mallocz_array(codsty->nreslevels, sizeof(*comp->reslevel));
450 if (!comp->reslevel)
451 return AVERROR(ENOMEM);
452 /* LOOP on resolution levels */
453 for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
454 int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
455 Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
456
457 /* Compute borders for each resolution level.
458 * Computation of trx_0, trx_1, try_0 and try_1.
459 * see ISO/IEC 15444-1:2002 eq. B.5 and B-14 */
460 for (i = 0; i < 2; i++)
461 for (j = 0; j < 2; j++)
462 reslevel->coord[i][j] =
463 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
464 // update precincts size: 2^n value
465 reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
466 reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
467
468 /* Number of bands for each resolution level */
469 if (reslevelno == 0)
470 reslevel->nbands = 1;
471 else
472 reslevel->nbands = 3;
473
474 /* Number of precincts wich span the tile for resolution level reslevelno
475 * see B.6 in ISO/IEC 15444-1:2002 eq. B-16
476 * num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -| - (trx_0 / 2 ^ log2_prec_width)
477 * num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| - (try_0 / 2 ^ log2_prec_width)
478 * for Dcinema profiles in JPEG 2000
479 * num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -|
480 * num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| */
481 if (reslevel->coord[0][1] == reslevel->coord[0][0])
482 reslevel->num_precincts_x = 0;
483 else
484 reslevel->num_precincts_x =
485 ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
486 reslevel->log2_prec_width) -
487 (reslevel->coord[0][0] >> reslevel->log2_prec_width);
488
489 if (reslevel->coord[1][1] == reslevel->coord[1][0])
490 reslevel->num_precincts_y = 0;
491 else
492 reslevel->num_precincts_y =
493 ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
494 reslevel->log2_prec_height) -
495 (reslevel->coord[1][0] >> reslevel->log2_prec_height);
496
497 reslevel->band = av_mallocz_array(reslevel->nbands, sizeof(*reslevel->band));
498 if (!reslevel->band)
499 return AVERROR(ENOMEM);
500
501 for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
502 ret = init_band(avctx, reslevel,
503 comp, codsty, qntsty,
504 bandno, gbandno, reslevelno,
505 cbps, dx, dy);
506 if (ret < 0)
507 return ret;
508 }
509 }
510 return 0;
511 }
512
513 void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
514 {
515 int reslevelno, bandno, precno;
516 for (reslevelno = 0;
517 comp->reslevel && reslevelno < codsty->nreslevels;
518 reslevelno++) {
519 Jpeg2000ResLevel *reslevel;
520
521 if (!comp->reslevel)
522 continue;
523
524 reslevel = comp->reslevel + reslevelno;
525 for (bandno = 0; bandno < reslevel->nbands; bandno++) {
526 Jpeg2000Band *band;
527
528 if (!reslevel->band)
529 continue;
530
531 band = reslevel->band + bandno;
532 for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++) {
533 Jpeg2000Prec *prec;
534
535 if (!band->prec)
536 continue;
537
538 prec = band->prec + precno;
539 av_freep(&prec->zerobits);
540 av_freep(&prec->cblkincl);
541 av_freep(&prec->cblk);
542
543 }
544
545 av_freep(&band->prec);
546 }
547 av_freep(&reslevel->band);
548 }
549
550 ff_dwt_destroy(&comp->dwt);
551 av_freep(&comp->reslevel);
552 av_freep(&comp->i_data);
553 av_freep(&comp->f_data);
554 }