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/4] avcodec/libaribb24, ttmlenc, avutil/tx: Remove redundant init of AVBPrint
@ 2023-09-11 15:30 Andreas Rheinhardt
  2023-09-11 15:31 ` [FFmpeg-devel] [PATCH 2/4] avcodec/libaribb24: Use FF_CODEC_CAP_INIT_CLEANUP Andreas Rheinhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-09-11 15:30 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

An AVBPrint is initialized via av_bprint_init() (or
av_bprint_init_for_buffer()) which expects uninitialized
AVBPrints; it is therefore not necessary to zero them before
the actual initialization.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/libaribb24.c | 2 +-
 libavcodec/ttmlenc.c    | 2 +-
 libavutil/tx.c          | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libaribb24.c b/libavcodec/libaribb24.c
index 8032536b22..551be89ffd 100644
--- a/libavcodec/libaribb24.c
+++ b/libavcodec/libaribb24.c
@@ -227,7 +227,7 @@ static int libaribb24_handle_regions(AVCodecContext *avctx, AVSubtitle *sub)
     Libaribb24Context *b24 = avctx->priv_data;
     const arib_buf_region_t *region = arib_decoder_get_regions(b24->decoder);
     unsigned int profile_font_size = get_profile_font_size(avctx);
-    AVBPrint buf = { 0 };
+    AVBPrint buf;
     int ret = 0;
 
     av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c
index fb05c38968..6a2ab23cab 100644
--- a/libavcodec/ttmlenc.c
+++ b/libavcodec/ttmlenc.c
@@ -45,7 +45,7 @@ typedef struct {
 static void ttml_text_cb(void *priv, const char *text, int len)
 {
     TTMLContext *s = priv;
-    AVBPrint cur_line = { 0 };
+    AVBPrint cur_line;
     AVBPrint *buffer = &s->buffer;
 
     av_bprint_init(&cur_line, len, AV_BPRINT_SIZE_UNLIMITED);
diff --git a/libavutil/tx.c b/libavutil/tx.c
index 24b2015b44..d6740071b9 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -595,7 +595,7 @@ static void print_type(AVBPrint *bp, enum AVTXType type)
 
 static void print_cd_info(const FFTXCodelet *cd, int prio, int len, int print_prio)
 {
-    AVBPrint bp = { 0 };
+    AVBPrint bp;
     av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
 
     av_bprintf(&bp, "%s - type: ", cd->name);
@@ -718,7 +718,7 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type,
     int codelet_list_idx = codelet_list_num;
     int nb_cd_matches = 0;
 #if !CONFIG_SMALL
-    AVBPrint bp = { 0 };
+    AVBPrint bp;
 #endif
 
     /* We still accept functions marked with SLOW, even if the CPU is
-- 
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".

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

* [FFmpeg-devel] [PATCH 2/4] avcodec/libaribb24: Use FF_CODEC_CAP_INIT_CLEANUP
  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
  2023-09-11 15:31 ` [FFmpeg-devel] [PATCH 3/4] avcodec/imc: Fix leak on init error Andreas Rheinhardt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-09-11 15:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

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

* [FFmpeg-devel] [PATCH 3/4] avcodec/imc: Fix leak on init error
  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 ` [FFmpeg-devel] [PATCH 2/4] avcodec/libaribb24: Use FF_CODEC_CAP_INIT_CLEANUP Andreas Rheinhardt
@ 2023-09-11 15:31 ` 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-13 19:44 ` [FFmpeg-devel] [PATCH 1/4] avcodec/libaribb24, ttmlenc, avutil/tx: Remove redundant init of AVBPrint Andreas Rheinhardt
  3 siblings, 1 reply; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-09-11 15:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Since e6afa61be97674312e36c9b6f8bb5fba009232e7 an AVFloatDSPContext
would leak on av_tx_init() failure.

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

diff --git a/libavcodec/imc.c b/libavcodec/imc.c
index 83572c4f2c..754ceff958 100644
--- a/libavcodec/imc.c
+++ b/libavcodec/imc.c
@@ -1038,6 +1038,7 @@ const FFCodec ff_imc_decoder = {
     .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
     .p.sample_fmts  = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
 #if CONFIG_IAC_DECODER
@@ -1054,5 +1055,6 @@ const FFCodec ff_iac_decoder = {
     .p.capabilities = AV_CODEC_CAP_DR1,
     .p.sample_fmts  = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif
-- 
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".

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

* [FFmpeg-devel] [PATCH 4/4] avcodec/flicvideo: Remove unnecessary cast
  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 ` [FFmpeg-devel] [PATCH 2/4] avcodec/libaribb24: Use FF_CODEC_CAP_INIT_CLEANUP Andreas Rheinhardt
  2023-09-11 15:31 ` [FFmpeg-devel] [PATCH 3/4] avcodec/imc: Fix leak on init error Andreas Rheinhardt
@ 2023-09-11 15:31 ` 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
  3 siblings, 1 reply; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-09-11 15:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/flicvideo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
index e4b334e10f..8531eb715c 100644
--- a/libavcodec/flicvideo.c
+++ b/libavcodec/flicvideo.c
@@ -79,7 +79,7 @@ typedef struct FlicDecodeContext {
 static av_cold int flic_decode_init(AVCodecContext *avctx)
 {
     FlicDecodeContext *s = avctx->priv_data;
-    unsigned char *fli_header = (unsigned char *)avctx->extradata;
+    uint8_t *fli_header = avctx->extradata;
     int depth;
 
     if (avctx->extradata_size != 0 &&
-- 
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".

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

* Re: [FFmpeg-devel] [PATCH 3/4] avcodec/imc: Fix leak on init error
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Paul B Mahol @ 2023-09-11 17:10 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt

LGTM
_______________________________________________
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] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/flicvideo: Remove unnecessary cast
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Paul B Mahol @ 2023-09-11 17:10 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt

LGTM
_______________________________________________
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] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/libaribb24, ttmlenc, avutil/tx: Remove redundant init of AVBPrint
  2023-09-11 15:30 [FFmpeg-devel] [PATCH 1/4] avcodec/libaribb24, ttmlenc, avutil/tx: Remove redundant init of AVBPrint Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2023-09-11 15:31 ` [FFmpeg-devel] [PATCH 4/4] avcodec/flicvideo: Remove unnecessary cast Andreas Rheinhardt
@ 2023-09-13 19:44 ` Andreas Rheinhardt
  3 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-09-13 19:44 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> An AVBPrint is initialized via av_bprint_init() (or
> av_bprint_init_for_buffer()) which expects uninitialized
> AVBPrints; it is therefore not necessary to zero them before
> the actual initialization.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/libaribb24.c | 2 +-
>  libavcodec/ttmlenc.c    | 2 +-
>  libavutil/tx.c          | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/libaribb24.c b/libavcodec/libaribb24.c
> index 8032536b22..551be89ffd 100644
> --- a/libavcodec/libaribb24.c
> +++ b/libavcodec/libaribb24.c
> @@ -227,7 +227,7 @@ static int libaribb24_handle_regions(AVCodecContext *avctx, AVSubtitle *sub)
>      Libaribb24Context *b24 = avctx->priv_data;
>      const arib_buf_region_t *region = arib_decoder_get_regions(b24->decoder);
>      unsigned int profile_font_size = get_profile_font_size(avctx);
> -    AVBPrint buf = { 0 };
> +    AVBPrint buf;
>      int ret = 0;
>  
>      av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
> diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c
> index fb05c38968..6a2ab23cab 100644
> --- a/libavcodec/ttmlenc.c
> +++ b/libavcodec/ttmlenc.c
> @@ -45,7 +45,7 @@ typedef struct {
>  static void ttml_text_cb(void *priv, const char *text, int len)
>  {
>      TTMLContext *s = priv;
> -    AVBPrint cur_line = { 0 };
> +    AVBPrint cur_line;
>      AVBPrint *buffer = &s->buffer;
>  
>      av_bprint_init(&cur_line, len, AV_BPRINT_SIZE_UNLIMITED);
> diff --git a/libavutil/tx.c b/libavutil/tx.c
> index 24b2015b44..d6740071b9 100644
> --- a/libavutil/tx.c
> +++ b/libavutil/tx.c
> @@ -595,7 +595,7 @@ static void print_type(AVBPrint *bp, enum AVTXType type)
>  
>  static void print_cd_info(const FFTXCodelet *cd, int prio, int len, int print_prio)
>  {
> -    AVBPrint bp = { 0 };
> +    AVBPrint bp;
>      av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
>  
>      av_bprintf(&bp, "%s - type: ", cd->name);
> @@ -718,7 +718,7 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type,
>      int codelet_list_idx = codelet_list_num;
>      int nb_cd_matches = 0;
>  #if !CONFIG_SMALL
> -    AVBPrint bp = { 0 };
> +    AVBPrint bp;
>  #endif
>  
>      /* We still accept functions marked with SLOW, even if the CPU is

Will apply this patchset tomorrow 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] 7+ messages in thread

end of thread, other threads:[~2023-09-13 19:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [FFmpeg-devel] [PATCH 2/4] avcodec/libaribb24: Use FF_CODEC_CAP_INIT_CLEANUP Andreas Rheinhardt
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

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