Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure
@ 2022-02-08 10:37 Andreas Rheinhardt
  2022-02-08 10:38 ` [FFmpeg-devel] [PATCH 2/2] avcodec/proresenc_kostya: Use av_calloc/av_malloc_array() Andreas Rheinhardt
  2022-02-11  9:28 ` [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure Andreas Rheinhardt
  0 siblings, 2 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2022-02-08 10:37 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/proresenc_kostya.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 85651fce2a..08a874dd4e 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1274,25 +1274,19 @@ static av_cold int encode_init(AVCodecContext *avctx)
         }
 
         ctx->slice_q = av_malloc(ctx->slices_per_picture * sizeof(*ctx->slice_q));
-        if (!ctx->slice_q) {
-            encode_close(avctx);
+        if (!ctx->slice_q)
             return AVERROR(ENOMEM);
-        }
 
         ctx->tdata = av_mallocz(avctx->thread_count * sizeof(*ctx->tdata));
-        if (!ctx->tdata) {
-            encode_close(avctx);
+        if (!ctx->tdata)
             return AVERROR(ENOMEM);
-        }
 
         for (j = 0; j < avctx->thread_count; j++) {
             ctx->tdata[j].nodes = av_malloc((ctx->slices_width + 1)
                                             * TRELLIS_WIDTH
                                             * sizeof(*ctx->tdata->nodes));
-            if (!ctx->tdata[j].nodes) {
-                encode_close(avctx);
+            if (!ctx->tdata[j].nodes)
                 return AVERROR(ENOMEM);
-            }
             for (i = min_quant; i < max_quant + 2; i++) {
                 ctx->tdata[j].nodes[i].prev_node = -1;
                 ctx->tdata[j].nodes[i].bits      = 0;
@@ -1415,5 +1409,5 @@ const AVCodec ff_prores_ks_encoder = {
                       },
     .priv_class     = &proresenc_class,
     .profiles       = NULL_IF_CONFIG_SMALL(ff_prores_profiles),
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.32.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] avcodec/proresenc_kostya: Use av_calloc/av_malloc_array()
  2022-02-08 10:37 [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure Andreas Rheinhardt
@ 2022-02-08 10:38 ` Andreas Rheinhardt
  2022-02-11  9:28 ` [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure Andreas Rheinhardt
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2022-02-08 10:38 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/proresenc_kostya.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 08a874dd4e..beceee621d 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1273,18 +1273,18 @@ static av_cold int encode_init(AVCodecContext *avctx)
             }
         }
 
-        ctx->slice_q = av_malloc(ctx->slices_per_picture * sizeof(*ctx->slice_q));
+        ctx->slice_q = av_malloc_array(ctx->slices_per_picture, sizeof(*ctx->slice_q));
         if (!ctx->slice_q)
             return AVERROR(ENOMEM);
 
-        ctx->tdata = av_mallocz(avctx->thread_count * sizeof(*ctx->tdata));
+        ctx->tdata = av_calloc(avctx->thread_count, sizeof(*ctx->tdata));
         if (!ctx->tdata)
             return AVERROR(ENOMEM);
 
         for (j = 0; j < avctx->thread_count; j++) {
-            ctx->tdata[j].nodes = av_malloc((ctx->slices_width + 1)
-                                            * TRELLIS_WIDTH
-                                            * sizeof(*ctx->tdata->nodes));
+            ctx->tdata[j].nodes = av_malloc_array(ctx->slices_width + 1,
+                                                  TRELLIS_WIDTH
+                                                  * sizeof(*ctx->tdata->nodes));
             if (!ctx->tdata[j].nodes)
                 return AVERROR(ENOMEM);
             for (i = min_quant; i < max_quant + 2; i++) {
-- 
2.32.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure
  2022-02-08 10:37 [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure Andreas Rheinhardt
  2022-02-08 10:38 ` [FFmpeg-devel] [PATCH 2/2] avcodec/proresenc_kostya: Use av_calloc/av_malloc_array() Andreas Rheinhardt
@ 2022-02-11  9:28 ` Andreas Rheinhardt
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2022-02-11  9:28 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/proresenc_kostya.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
> index 85651fce2a..08a874dd4e 100644
> --- a/libavcodec/proresenc_kostya.c
> +++ b/libavcodec/proresenc_kostya.c
> @@ -1274,25 +1274,19 @@ static av_cold int encode_init(AVCodecContext *avctx)
>          }
>  
>          ctx->slice_q = av_malloc(ctx->slices_per_picture * sizeof(*ctx->slice_q));
> -        if (!ctx->slice_q) {
> -            encode_close(avctx);
> +        if (!ctx->slice_q)
>              return AVERROR(ENOMEM);
> -        }
>  
>          ctx->tdata = av_mallocz(avctx->thread_count * sizeof(*ctx->tdata));
> -        if (!ctx->tdata) {
> -            encode_close(avctx);
> +        if (!ctx->tdata)
>              return AVERROR(ENOMEM);
> -        }
>  
>          for (j = 0; j < avctx->thread_count; j++) {
>              ctx->tdata[j].nodes = av_malloc((ctx->slices_width + 1)
>                                              * TRELLIS_WIDTH
>                                              * sizeof(*ctx->tdata->nodes));
> -            if (!ctx->tdata[j].nodes) {
> -                encode_close(avctx);
> +            if (!ctx->tdata[j].nodes)
>                  return AVERROR(ENOMEM);
> -            }
>              for (i = min_quant; i < max_quant + 2; i++) {
>                  ctx->tdata[j].nodes[i].prev_node = -1;
>                  ctx->tdata[j].nodes[i].bits      = 0;
> @@ -1415,5 +1409,5 @@ const AVCodec ff_prores_ks_encoder = {
>                        },
>      .priv_class     = &proresenc_class,
>      .profiles       = NULL_IF_CONFIG_SMALL(ff_prores_profiles),
> -    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
> +    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
>  };

Will apply this patchset later tonight unless there are objections.

- 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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-11  9:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 10:37 [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure Andreas Rheinhardt
2022-02-08 10:38 ` [FFmpeg-devel] [PATCH 2/2] avcodec/proresenc_kostya: Use av_calloc/av_malloc_array() Andreas Rheinhardt
2022-02-11  9:28 ` [FFmpeg-devel] [PATCH 1/2] avcodec/proresenc_kostya: Cleanup generically after init failure Andreas Rheinhardt

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