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
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/libaribb24: Use FF_CODEC_CAP_INIT_CLEANUP
Date: Mon, 11 Sep 2023 17:31:44 +0200
Message-ID: <AS8P250MB07448E62CF71B734377A28218FF2A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB0744B225ACBAE17540C9E6A28FF2A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

libaribb24_close() does the same as the fail path in
libaribb24_init().

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

diff --git a/libavcodec/libaribb24.c b/libavcodec/libaribb24.c
index 551be89ffd..29479e375d 100644
--- a/libavcodec/libaribb24.c
+++ b/libavcodec/libaribb24.c
@@ -147,12 +147,12 @@ static int libaribb24_init(AVCodecContext *avctx)
 {
     Libaribb24Context *b24 = avctx->priv_data;
     void(* arib_dec_init)(arib_decoder_t* decoder) = NULL;
-    int ret_code = AVERROR_EXTERNAL;
+    int ret;
     int profile = avctx->profile;
 
     if (!(b24->lib_instance = arib_instance_new(avctx))) {
         av_log(avctx, AV_LOG_ERROR, "Failed to initialize libaribb24!\n");
-        goto init_fail;
+        return AVERROR_EXTERNAL;
     }
 
     if (b24->aribb24_base_path) {
@@ -165,11 +165,11 @@ static int libaribb24_init(AVCodecContext *avctx)
 
     if (!(b24->parser = arib_get_parser(b24->lib_instance))) {
         av_log(avctx, AV_LOG_ERROR, "Failed to initialize libaribb24 PES parser!\n");
-        goto init_fail;
+        return AVERROR_EXTERNAL;
     }
     if (!(b24->decoder = arib_get_decoder(b24->lib_instance))) {
         av_log(avctx, AV_LOG_ERROR, "Failed to initialize libaribb24 decoder!\n");
-        goto init_fail;
+        return AVERROR_EXTERNAL;
     }
 
     if (profile == AV_PROFILE_UNKNOWN)
@@ -184,27 +184,16 @@ static int libaribb24_init(AVCodecContext *avctx)
         break;
     default:
         av_log(avctx, AV_LOG_ERROR, "Unknown or unsupported profile set!\n");
-        ret_code = AVERROR(EINVAL);
-        goto init_fail;
+        return AVERROR(EINVAL);
     }
 
     arib_dec_init(b24->decoder);
 
-    if (libaribb24_generate_ass_header(avctx) < 0) {
-        ret_code = AVERROR(ENOMEM);
-        goto init_fail;
-    }
+    ret = libaribb24_generate_ass_header(avctx);
+    if (ret < 0)
+        return ret;
 
     return 0;
-
-init_fail:
-    if (b24->decoder)
-        arib_finalize_decoder(b24->decoder);
-
-    if (b24->lib_instance)
-        arib_instance_destroy(b24->lib_instance);
-
-    return ret_code;
 }
 
 static int libaribb24_close(AVCodecContext *avctx)
@@ -410,7 +399,7 @@ const FFCodec ff_libaribb24_decoder = {
     .p.id           = AV_CODEC_ID_ARIB_CAPTION,
     .p.priv_class   = &aribb24_class,
     .p.wrapper_name = "libaribb24",
-    .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_NOT_INIT_THREADSAFE,
     .priv_data_size = sizeof(Libaribb24Context),
     .init      = libaribb24_init,
     .close     = libaribb24_close,
-- 
2.34.1

_______________________________________________
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:[~2023-09-11 15:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 15:30 [FFmpeg-devel] [PATCH 1/4] avcodec/libaribb24, ttmlenc, avutil/tx: Remove redundant init of AVBPrint Andreas Rheinhardt
2023-09-11 15:31 ` Andreas Rheinhardt [this message]
2023-09-11 15:31 ` [FFmpeg-devel] [PATCH 3/4] avcodec/imc: Fix leak on init error Andreas Rheinhardt
2023-09-11 17:10   ` Paul B Mahol
2023-09-11 15:31 ` [FFmpeg-devel] [PATCH 4/4] avcodec/flicvideo: Remove unnecessary cast Andreas Rheinhardt
2023-09-11 17:10   ` Paul B Mahol
2023-09-13 19:44 ` [FFmpeg-devel] [PATCH 1/4] avcodec/libaribb24, ttmlenc, avutil/tx: Remove redundant init of AVBPrint Andreas Rheinhardt

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=AS8P250MB07448E62CF71B734377A28218FF2A@AS8P250MB0744.EURP250.PROD.OUTLOOK.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