Tomas Härdin: > > > @@ -2166,12 +2163,13 @@ static int jpeg2000_mct_write_frame(AVCodecContext > *avctx, void *td, > return 0; > } > > -static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s) > +static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s, int close) > { > int tileno, compno; > - for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) { > + if (close) { > + for (tileno = 0; tileno < s->tile_size/sizeof(*s->tile); tileno++) { > if (s->tile[tileno].comp) { > - for (compno = 0; compno < s->ncomponents; compno++) { > + for (compno = 0; compno < > s->tile[tileno].comp_size/sizeof(*s->tile[tileno].comp); compno++) { > Jpeg2000Component *comp = s->tile[tileno].comp + > compno; > Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + > compno; > > @@ -2182,10 +2180,11 @@ static void > jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s) > s->tile[tileno].packed_headers_size = 0; > } > } > + av_freep(&s->tile); > + } > av_freep(&s->packed_headers); > s->packed_headers_size = 0; > memset(&s->packed_headers_stream, 0, sizeof(s->packed_headers_stream)); > - av_freep(&s->tile); > memset(s->codsty, 0, sizeof(s->codsty)); > memset(s->qntsty, 0, sizeof(s->qntsty)); > memset(s->properties, 0, sizeof(s->properties)); > @@ -2689,7 +2688,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, > AVFrame *picture, > > avctx->execute2(avctx, jpeg2000_mct_write_frame, picture, NULL, > s->numXtiles * s->numYtiles); > > - jpeg2000_dec_cleanup(s); > + jpeg2000_dec_cleanup(s, 0); > > *got_frame = 1; > > @@ -2702,7 +2701,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, > AVFrame *picture, > return bytestream2_tell(&s->g); > > end: > - jpeg2000_dec_cleanup(s); > + jpeg2000_dec_cleanup(s, 0); > return ret; > } > > @@ -2712,6 +2711,7 @@ static av_cold int jpeg2000_decode_close(AVCodecContext > *avctx) > > av_freep(&s->idwt); > av_freep(&s->cb); > + jpeg2000_dec_cleanup(s, 1); > > return 0; > }
Why don't you just move the part of jpeg2000_dec_cleanup() that you intend to be only executed in jpeg2000_decode_close() to jpeg2000_decode_close()? - Andreas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".