Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 07/13] lavc/jpeg2000*: Use ff_fast_recalloc() to eliminate lots of allocations
Date: Tue, 14 Jun 2022 17:23:41 +0200
Message-ID: <DB6PR0101MB2214B18CB8BE02C7FFE49A7D8FAA9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <f3c27ac8051c11b12726a2791eeae13887973c2e.camel@acc.umu.se>

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-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2022-06-14 15:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 14:39 [FFmpeg-devel] [PATCH 01/13] lavc/jpeg2000dec: Finer granularity threading Tomas Härdin
2022-06-14 14:39 ` [FFmpeg-devel] [PATCH 02/13] lavc/jpeg2000dec: Reindent Tomas Härdin
2022-06-14 14:40 ` [FFmpeg-devel] [PATCH 03/13] lavc/jpeg2000dwt: Implement sliced transforms Tomas Härdin
2022-06-14 14:40 ` [FFmpeg-devel] [PATCH 04/13] lavc/jpeg2000dec: Implement IDWT slicing Tomas Härdin
2022-06-14 14:41 ` [FFmpeg-devel] [PATCH 05/13] lavc/jpeg2000dec: Thread init_tile() Tomas Härdin
2022-06-14 21:11   ` Michael Niedermayer
2022-06-15 13:11     ` Tomas Härdin
2022-06-15 21:05       ` Michael Niedermayer
2022-06-16  9:28         ` Tomas Härdin
2022-06-14 14:42 ` [FFmpeg-devel] [PATCH 06/13] lavu/mem: Add ff_fast_recalloc() Tomas Härdin
2022-06-14 20:26   ` Michael Niedermayer
2022-06-15  9:59     ` Tomas Härdin
2022-06-15 12:15       ` James Almer
2022-06-16 12:44         ` Tomas Härdin
2022-06-18 14:57           ` Anton Khirnov
2022-06-21  8:04             ` Tomas Härdin
2022-06-14 14:42 ` [FFmpeg-devel] [PATCH 07/13] lavc/jpeg2000*: Use ff_fast_recalloc() to eliminate lots of allocations Tomas Härdin
2022-06-14 15:23   ` Andreas Rheinhardt [this message]
2022-06-15 10:03     ` Tomas Härdin
2022-06-14 14:43 ` [FFmpeg-devel] [PATCH 08/13] lavc/jpeg2000: Switch Jpeg2000TgtNode to int32_t parent Tomas Härdin
2022-06-14 14:43 ` [FFmpeg-devel] [PATCH 09/13] lavc/jpeg2000: Speed up ff_jpeg2000_tag_tree_init() using stereotypes for sizes <= 4x4 Tomas Härdin
2022-06-18 15:00   ` Anton Khirnov
2022-06-21  7:57     ` Tomas Härdin
2022-06-14 14:43 ` [FFmpeg-devel] [PATCH 10/13] lavc/jpeg2000: Reindent Tomas Härdin
2022-06-14 14:44 ` [FFmpeg-devel] [PATCH 11/13] lavc/jpeg2000: Minimize calls to av_codec_is_encoder() Tomas Härdin
2022-06-14 15:04   ` Andreas Rheinhardt
2022-06-15 10:20     ` Tomas Härdin
2022-06-14 14:44 ` [FFmpeg-devel] [PATCH 12/13] lavc/jpeg2000dec: Use coarser slicing for initial reslevels Tomas Härdin
2022-06-14 14:47 ` [FFmpeg-devel] [PATCH 13/13] lavc/jpeg2000dec: Component-level threading of write_frame() Tomas Härdin
2022-06-18 14:50 ` [FFmpeg-devel] [PATCH 01/13] lavc/jpeg2000dec: Finer granularity threading Anton Khirnov
2022-06-24  8:19   ` Tomas Härdin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB6PR0101MB2214B18CB8BE02C7FFE49A7D8FAA9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git