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 01/17] avcodec/svq3: Mark decoder as init-threadsafe
@ 2022-02-12  6:24 Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 02/17] avcodec/amrnbdec: " Andreas Rheinhardt
                   ` (16 more replies)
  0 siblings, 17 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:24 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The only interesting thing done in SVQ3's init function
is using zlib, but this is fine: https://zlib.net/zlib_faq.html#faq21

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

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index be95e222aa..da61617f4e 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1601,5 +1601,5 @@ const AVCodec ff_svq3_decoder = {
                       AV_CODEC_CAP_DELAY,
     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P,
                                                      AV_PIX_FMT_NONE},
-    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+    .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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 02/17] avcodec/amrnbdec: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  7:49   ` Paul B Mahol
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 03/17] avcodec/amrwbdec: " Andreas Rheinhardt
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It performs no initialization of static data during its init function.

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

diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
index d8e0370a3b..1e11445cd3 100644
--- a/libavcodec/amrnbdec.c
+++ b/libavcodec/amrnbdec.c
@@ -1107,4 +1107,5 @@ const AVCodec ff_amrnb_decoder = {
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
     .sample_fmts    = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
                                                      AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 03/17] avcodec/amrwbdec: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 02/17] avcodec/amrnbdec: " Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  7:49   ` Paul B Mahol
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 04/17] avcodec/rv30: " Andreas Rheinhardt
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It performs no initialization of static data in its init function.

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

diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 3ff4077f7f..7d1b820bbb 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -1303,4 +1303,5 @@ const AVCodec ff_amrwb_decoder = {
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
     .sample_fmts    = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT,
                                                      AV_SAMPLE_FMT_NONE },
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 04/17] avcodec/rv30: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 02/17] avcodec/amrnbdec: " Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 03/17] avcodec/amrwbdec: " Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 05/17] avcodec/rv40: Make decoder init-threadsafe Andreas Rheinhardt
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Init-threadsafe since f697622f687c22392194d6939914c9a6a01ce69e.

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

diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c
index 751647bebe..bd4d43aeeb 100644
--- a/libavcodec/rv30.c
+++ b/libavcodec/rv30.c
@@ -306,5 +306,6 @@ const AVCodec ff_rv30_decoder = {
         AV_PIX_FMT_NONE
     },
     .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
-    .caps_internal         = FF_CODEC_CAP_ALLOCATE_PROGRESS,
+    .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE |
+                             FF_CODEC_CAP_ALLOCATE_PROGRESS,
 };
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 05/17] avcodec/rv40: Make decoder init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 04/17] avcodec/rv30: " Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 06/17] avcodec/apedec: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index 31a7a04e51..8f7589242d 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -27,6 +27,7 @@
 #include "config.h"
 
 #include "libavutil/imgutils.h"
+#include "libavutil/thread.h"
 
 #include "avcodec.h"
 #include "mpegutils.h"
@@ -553,14 +554,13 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
  */
 static av_cold int rv40_decode_init(AVCodecContext *avctx)
 {
+    static AVOnce init_static_once = AV_ONCE_INIT;
     RV34DecContext *r = avctx->priv_data;
     int ret;
 
     r->rv30 = 0;
     if ((ret = ff_rv34_decode_init(avctx)) < 0)
         return ret;
-    if(!aic_top_vlc.bits)
-        rv40_init_tables();
     r->parse_slice_header = rv40_parse_slice_header;
     r->decode_intra_types = rv40_decode_intra_types;
     r->decode_mb_info     = rv40_decode_mb_info;
@@ -568,6 +568,7 @@ static av_cold int rv40_decode_init(AVCodecContext *avctx)
     r->luma_dc_quant_i = rv40_luma_dc_quant[0];
     r->luma_dc_quant_p = rv40_luma_dc_quant[1];
     ff_rv40dsp_init(&r->rdsp);
+    ff_thread_once(&init_static_once, rv40_init_tables);
     return 0;
 }
 
@@ -588,5 +589,6 @@ const AVCodec ff_rv40_decoder = {
         AV_PIX_FMT_NONE
     },
     .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
-    .caps_internal         = FF_CODEC_CAP_ALLOCATE_PROGRESS,
+    .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE |
+                             FF_CODEC_CAP_ALLOCATE_PROGRESS,
 };
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 06/17] avcodec/apedec: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 05/17] avcodec/rv40: Make decoder init-threadsafe Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 07/17] avcodec/alsdec: Return directly upon error Andreas Rheinhardt
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 607304fe36..923f79046b 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1666,7 +1666,7 @@ const AVCodec ff_ape_decoder = {
     .decode         = ape_decode_frame,
     .capabilities   = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DELAY |
                       AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .flush          = ape_flush,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
                                                       AV_SAMPLE_FMT_S16P,
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 07/17] avcodec/alsdec: Return directly upon error
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (4 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 06/17] avcodec/apedec: Mark decoder as init-threadsafe Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 08/17] avcodec/alsdec: Improve code locality Andreas Rheinhardt
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 9e1aaf065a..f8609e61fd 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1990,17 +1990,17 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     if ((ret = read_specific_config(ctx)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "Reading ALSSpecificConfig failed.\n");
-        goto fail;
+        return ret;
     }
 
     if ((ret = check_specific_config(ctx)) < 0) {
-        goto fail;
+        return ret;
     }
 
     if (sconf->bgmc) {
         ret = ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status);
         if (ret < 0)
-            goto fail;
+            return ret;
     }
     if (sconf->floating) {
         avctx->sample_fmt          = AV_SAMPLE_FMT_FLT;
@@ -2012,8 +2012,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         if (avctx->bits_per_raw_sample > 32) {
             av_log(avctx, AV_LOG_ERROR, "Bits per raw sample %d larger than 32.\n",
                    avctx->bits_per_raw_sample);
-            ret = AVERROR_INVALIDDATA;
-            goto fail;
+            return AVERROR_INVALIDDATA;
         }
     }
 
@@ -2044,8 +2043,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         !ctx->quant_cof_buffer       || !ctx->lpc_cof_buffer ||
         !ctx->lpc_cof_reversed_buffer) {
         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
-        ret = AVERROR(ENOMEM);
-        goto fail;
+        return AVERROR(ENOMEM);
     }
 
     // assign quantized parcor coefficient buffers
@@ -2069,8 +2067,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         !ctx->use_ltp  || !ctx->ltp_lag ||
         !ctx->ltp_gain || !ctx->ltp_gain_buffer) {
         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
-        ret = AVERROR(ENOMEM);
-        goto fail;
+        return AVERROR(ENOMEM);
     }
 
     for (c = 0; c < num_buffers; c++)
@@ -2086,8 +2083,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
         if (!ctx->chan_data_buffer || !ctx->chan_data || !ctx->reverted_channels) {
             av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
-            ret = AVERROR(ENOMEM);
-            goto fail;
+            return AVERROR(ENOMEM);
         }
 
         for (c = 0; c < num_buffers; c++)
@@ -2118,8 +2114,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         if (!ctx->mlz || !ctx->acf || !ctx->shift_value || !ctx->last_shift_value
             || !ctx->last_acf_mantissa || !ctx->raw_mantissa) {
             av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
-            ret = AVERROR(ENOMEM);
-            goto fail;
+            return AVERROR(ENOMEM);
         }
 
         ff_mlz_init_dict(avctx, ctx->mlz);
@@ -2133,8 +2128,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
     // allocate previous raw sample buffer
     if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) {
         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
-        ret = AVERROR(ENOMEM);
-        goto fail;
+        return AVERROR(ENOMEM);
     }
 
     // assign raw samples buffers
@@ -2151,17 +2145,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
                                           sizeof(*ctx->crc_buffer));
         if (!ctx->crc_buffer) {
             av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
-            ret = AVERROR(ENOMEM);
-            goto fail;
+            return AVERROR(ENOMEM);
         }
     }
 
     ff_bswapdsp_init(&ctx->bdsp);
 
     return 0;
-
-fail:
-    return ret;
 }
 
 
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 08/17] avcodec/alsdec: Improve code locality
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (5 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 07/17] avcodec/alsdec: Return directly upon error Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 09/17] avcodec/alsdec, mlz: Check allocation Andreas Rheinhardt
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index f8609e61fd..c09401d257 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -2094,12 +2094,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
         ctx->reverted_channels = NULL;
     }
 
-    channel_size      = sconf->frame_length + sconf->max_order;
-
-    ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples));
-    ctx->raw_buffer       = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
-    ctx->raw_samples      = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples));
-
     if (sconf->floating) {
         ctx->acf               = av_malloc_array(avctx->channels, sizeof(*ctx->acf));
         ctx->shift_value       = av_malloc_array(avctx->channels, sizeof(*ctx->shift_value));
@@ -2125,7 +2119,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
         }
     }
 
+    channel_size      = sconf->frame_length + sconf->max_order;
+
     // allocate previous raw sample buffer
+    ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples));
+    ctx->raw_buffer       = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
+    ctx->raw_samples      = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples));
     if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) {
         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
         return AVERROR(ENOMEM);
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 09/17] avcodec/alsdec, mlz: Check allocation
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (6 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 08/17] avcodec/alsdec: Improve code locality Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 10/17] avcodec/alsdec: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/alsdec.c | 4 +++-
 libavcodec/mlz.c    | 7 ++++++-
 libavcodec/mlz.h    | 2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index c09401d257..029c37e99c 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -2111,7 +2111,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
             return AVERROR(ENOMEM);
         }
 
-        ff_mlz_init_dict(avctx, ctx->mlz);
+        ret = ff_mlz_init_dict(avctx, ctx->mlz);
+        if (ret < 0)
+            return ret;
         ff_mlz_flush_dict(ctx->mlz);
 
         for (c = 0; c < avctx->channels; ++c) {
diff --git a/libavcodec/mlz.c b/libavcodec/mlz.c
index dbeb7dcad9..9087ffd8f0 100644
--- a/libavcodec/mlz.c
+++ b/libavcodec/mlz.c
@@ -20,8 +20,11 @@
 
 #include "mlz.h"
 
-av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) {
+av_cold int ff_mlz_init_dict(void *context, MLZ *mlz)
+{
     mlz->dict = av_mallocz(TABLE_SIZE * sizeof(*mlz->dict));
+    if (!mlz->dict)
+        return AVERROR(ENOMEM);
 
     mlz->flush_code            = FLUSH_CODE;
     mlz->current_dic_index_max = DIC_INDEX_INIT;
@@ -30,6 +33,8 @@ av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) {
     mlz->next_code             = FIRST_CODE;
     mlz->freeze_flag           = 0;
     mlz->context               = context;
+
+    return 0;
 }
 
 av_cold void ff_mlz_flush_dict(MLZ *mlz) {
diff --git a/libavcodec/mlz.h b/libavcodec/mlz.h
index c3df52c9b4..24993126ca 100644
--- a/libavcodec/mlz.h
+++ b/libavcodec/mlz.h
@@ -57,7 +57,7 @@ typedef struct MLZ {
 
 /** Initialize the dictionary
  */
-void ff_mlz_init_dict(void* context, MLZ *mlz);
+int ff_mlz_init_dict(void *context, MLZ *mlz);
 
 /** Flush the dictionary
  */
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 10/17] avcodec/alsdec: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (7 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 09/17] avcodec/alsdec, mlz: Check allocation Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 11/17] avcodec/ituh263dec: Make initializing VLCs thread-safe Andreas Rheinhardt
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It does not initialize any static data in its init function.

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

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 029c37e99c..b9629fc3d2 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -2177,5 +2177,5 @@ const AVCodec ff_als_decoder = {
     .decode         = decode_frame,
     .flush          = flush,
     .capabilities   = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
-    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+    .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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 11/17] avcodec/ituh263dec: Make initializing VLCs thread-safe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (8 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 10/17] avcodec/alsdec: Mark decoder as init-threadsafe Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 12/17] avcodec/ituh263dec: Reindent after the last commit Andreas Rheinhardt
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This automatically makes the FLV, H.263, H.263+, Intel H.263,
MPEG-4, RealVideo 1.0 and RealVideo 2.0 decoders init-threadsafe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/flvdec.c        |  3 ++-
 libavcodec/h263dec.c       |  6 ++++--
 libavcodec/intelh263dec.c  |  3 ++-
 libavcodec/ituh263dec.c    | 15 ++++++++-------
 libavcodec/mpeg4videodec.c |  3 ++-
 libavcodec/rv10.c          |  2 ++
 6 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 2bd86b5b47..587cbb3ca5 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -122,7 +122,8 @@ const AVCodec ff_flv_decoder = {
     .close          = ff_h263_decode_end,
     .decode         = ff_h263_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .max_lowres     = 3,
     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                      AV_PIX_FMT_NONE },
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 3466027286..27f9c2932c 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -772,7 +772,8 @@ const AVCodec ff_h263_decoder = {
                       AV_CODEC_CAP_TRUNCATED |
 #endif
                       AV_CODEC_CAP_DELAY,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .flush          = ff_mpeg_flush,
     .max_lowres     = 3,
     .pix_fmts       = ff_h263_hwaccel_pixfmt_list_420,
@@ -793,7 +794,8 @@ const AVCodec ff_h263p_decoder = {
                       AV_CODEC_CAP_TRUNCATED |
 #endif
                       AV_CODEC_CAP_DELAY,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .flush          = ff_mpeg_flush,
     .max_lowres     = 3,
     .pix_fmts       = ff_h263_hwaccel_pixfmt_list_420,
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index 9dde247298..b0009f00d7 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -138,7 +138,8 @@ const AVCodec ff_h263i_decoder = {
     .close          = ff_h263_decode_end,
     .decode         = ff_h263_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
         AV_PIX_FMT_NONE
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 445d5f3f36..6fa5249569 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -35,6 +35,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/mem_internal.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "mpegvideo.h"
 #include "h263.h"
@@ -104,12 +105,8 @@ static VLC cbpc_b_vlc;
 
 /* init vlcs */
 
-/* XXX: find a better solution to handle static init */
-av_cold void ff_h263_decode_init_vlc(void)
+static av_cold void h263_decode_init_vlc(void)
 {
-    static volatile int done = 0;
-
-    if (!done) {
         INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
                  ff_h263_intra_MCBPC_bits, 1, 1,
                  ff_h263_intra_MCBPC_code, 1, 1, 72);
@@ -131,8 +128,12 @@ av_cold void ff_h263_decode_init_vlc(void)
         INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
                  &ff_cbpc_b_tab[0][1], 2, 1,
                  &ff_cbpc_b_tab[0][0], 2, 1, 8);
-        done = 1;
-    }
+}
+
+av_cold void ff_h263_decode_init_vlc(void)
+{
+    static AVOnce init_static_once = AV_ONCE_INIT;
+    ff_thread_once(&init_static_once, h263_decode_init_vlc);
 }
 
 int ff_h263_decode_mba(MpegEncContext *s)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 655be5697d..432d3c418c 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3672,7 +3672,8 @@ const AVCodec ff_mpeg4_decoder = {
                              AV_CODEC_CAP_TRUNCATED |
 #endif
                              AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS,
-    .caps_internal         = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
+    .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE |
+                             FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
                              FF_CODEC_CAP_ALLOCATE_PROGRESS,
     .flush                 = ff_mpeg_flush,
     .max_lowres            = 3,
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 4dfaa3460d..34f9dbf80a 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -690,6 +690,7 @@ const AVCodec ff_rv10_decoder = {
     .close          = rv10_decode_end,
     .decode         = rv10_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
     .max_lowres     = 3,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
@@ -707,6 +708,7 @@ const AVCodec ff_rv20_decoder = {
     .close          = rv10_decode_end,
     .decode         = rv10_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
     .flush          = ff_mpeg_flush,
     .max_lowres     = 3,
     .pix_fmts       = (const enum AVPixelFormat[]) {
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 12/17] avcodec/ituh263dec: Reindent after the last commit
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (9 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 11/17] avcodec/ituh263dec: Make initializing VLCs thread-safe Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 13/17] avcodec/exr: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 6fa5249569..c141888003 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -107,27 +107,27 @@ static VLC cbpc_b_vlc;
 
 static av_cold void h263_decode_init_vlc(void)
 {
-        INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
-                 ff_h263_intra_MCBPC_bits, 1, 1,
-                 ff_h263_intra_MCBPC_code, 1, 1, 72);
-        INIT_VLC_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
-                 ff_h263_inter_MCBPC_bits, 1, 1,
-                 ff_h263_inter_MCBPC_code, 1, 1, 198);
-        INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16,
-                 &ff_h263_cbpy_tab[0][1], 2, 1,
-                 &ff_h263_cbpy_tab[0][0], 2, 1, 64);
-        INIT_VLC_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33,
-                 &ff_mvtab[0][1], 2, 1,
-                 &ff_mvtab[0][0], 2, 1, 538);
-        ff_h263_init_rl_inter();
-        INIT_VLC_RL(ff_h263_rl_inter, 554);
-        INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554);
-        INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
-                 &ff_h263_mbtype_b_tab[0][1], 2, 1,
-                 &ff_h263_mbtype_b_tab[0][0], 2, 1, 80);
-        INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
-                 &ff_cbpc_b_tab[0][1], 2, 1,
-                 &ff_cbpc_b_tab[0][0], 2, 1, 8);
+    INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
+                    ff_h263_intra_MCBPC_bits, 1, 1,
+                    ff_h263_intra_MCBPC_code, 1, 1, 72);
+    INIT_VLC_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
+                    ff_h263_inter_MCBPC_bits, 1, 1,
+                    ff_h263_inter_MCBPC_code, 1, 1, 198);
+    INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16,
+                    &ff_h263_cbpy_tab[0][1], 2, 1,
+                    &ff_h263_cbpy_tab[0][0], 2, 1, 64);
+    INIT_VLC_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33,
+                    &ff_mvtab[0][1], 2, 1,
+                    &ff_mvtab[0][0], 2, 1, 538);
+    ff_h263_init_rl_inter();
+    INIT_VLC_RL(ff_h263_rl_inter, 554);
+    INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554);
+    INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
+                    &ff_h263_mbtype_b_tab[0][1], 2, 1,
+                    &ff_h263_mbtype_b_tab[0][0], 2, 1, 80);
+    INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
+                    &ff_cbpc_b_tab[0][1], 2, 1,
+                    &ff_cbpc_b_tab[0][0], 2, 1, 8);
 }
 
 av_cold void ff_h263_decode_init_vlc(void)
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 13/17] avcodec/exr: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (10 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 12/17] avcodec/ituh263dec: Reindent after the last commit Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  7:48   ` Paul B Mahol
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 14/17] avcodec/vorbisdec: " Andreas Rheinhardt
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This decoder does not initialize any static data in its init function.

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

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 8b04fab951..fc32ef1dde 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -2351,5 +2351,6 @@ const AVCodec ff_exr_decoder = {
     .decode           = decode_frame,
     .capabilities     = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
                         AV_CODEC_CAP_SLICE_THREADS,
+    .caps_internal    = FF_CODEC_CAP_INIT_THREADSAFE,
     .priv_class       = &exr_class,
 };
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 14/17] avcodec/vorbisdec: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (11 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 13/17] avcodec/exr: Mark decoder as init-threadsafe Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 15/17] avcodec/avcodec: Decrease the amount of time while holding the lock Andreas Rheinhardt
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It does not modify any static data in its init function.

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

diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 6e07bc5a8a..be4ac055e0 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -1891,7 +1891,7 @@ const AVCodec ff_vorbis_decoder = {
     .decode          = vorbis_decode_frame,
     .flush           = vorbis_decode_flush,
     .capabilities    = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
-    .caps_internal   = FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .channel_layouts = ff_vorbis_channel_layouts,
     .sample_fmts     = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                        AV_SAMPLE_FMT_NONE },
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 15/17] avcodec/avcodec: Decrease the amount of time while holding the lock
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (12 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 14/17] avcodec/vorbisdec: " Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 16/17] avcodec/msmpeg4dec: Make initializing VLCs thread-safe Andreas Rheinhardt
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 4df834c708..92639dda6b 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -169,8 +169,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
     if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
         return AVERROR(EINVAL);
 
-    lock_avcodec(codec);
-
     avci = av_mallocz(sizeof(*avci));
     if (!avci) {
         ret = AVERROR(ENOMEM);
@@ -301,16 +299,17 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
 
     if (CONFIG_FRAME_THREAD_ENCODER && av_codec_is_encoder(avctx->codec)) {
-        unlock_avcodec(codec); //we will instantiate a few encoders thus kick the counter to prevent false detection of a problem
         ret = ff_frame_thread_encoder_init(avctx);
-        lock_avcodec(codec);
         if (ret < 0)
             goto free_and_end;
     }
 
     if (HAVE_THREADS
         && !(avci->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
+        /* Frame-threaded decoders call AVCodec.init for their child contexts. */
+        lock_avcodec(codec);
         ret = ff_thread_init(avctx);
+        unlock_avcodec(codec);
         if (ret < 0) {
             goto free_and_end;
         }
@@ -321,7 +320,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
     if (!(avctx->active_thread_type & FF_THREAD_FRAME) ||
         avci->frame_thread_encoder) {
         if (avctx->codec->init) {
+            lock_avcodec(codec);
             ret = avctx->codec->init(avctx);
+            unlock_avcodec(codec);
             if (ret < 0) {
                 avci->needs_close = avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP;
                 goto free_and_end;
@@ -369,7 +370,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
 
 end:
-    unlock_avcodec(codec);
 
     return ret;
 free_and_end:
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 16/17] avcodec/msmpeg4dec: Make initializing VLCs thread-safe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (13 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 15/17] avcodec/avcodec: Decrease the amount of time while holding the lock Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 17/17] avcodec/msmpeg4dec: Reindent after the previous commit Andreas Rheinhardt
  2022-02-17  7:46 ` [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This automatically makes the remaining mpegvideo-decoders
(namely msmpeg4v[1-3], mss2, VC-1, VC-1 Image, WMV-[1-3]
and WMV-3 Image) init-threadsafe.
These were the last native codecs that were not init-threadsafe;
only wrappers for external libraries and for hardware accelerations
are now not init-threadsafe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
The above is based around the assumption that my other patches
marking the VP56 and 8bps decoders as init-threadsafe are already
applied.
Here is an incomplete list of non-native codecs that are not
init-threadsafe yet even after all these patches have been applied
(this list is incomplete because it only contains codecs that
I include in a fairly, but not completely extensive build of mine;
the threading flags stand for frame-slice-other; if all frame-threaded
decoders were init-threadsafe, one could avoid locking around
ff_thread_init() in avcodec_open2(). This only affects libopenjpeg
and I guess that it is init-threadsafe (as are probably most of the
following entries):

Encoder libaom-av1 is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Encoder libcodec2 is not init-threadsafe yet.
Encoder libfdk_aac is not init-threadsafe yet.
Encoder libgsm is not init-threadsafe yet.
Encoder libgsm_ms is not init-threadsafe yet.
Encoder libilbc is not init-threadsafe yet.
Encoder libmp3lame is not init-threadsafe yet.
Encoder libopencore_amrnb is not init-threadsafe yet.
Encoder libopenjpeg is not init-threadsafe yet.
Codec supports threading: 1, 0, 0
Encoder libopus is not init-threadsafe yet.
Encoder libshine is not init-threadsafe yet.
Encoder libspeex is not init-threadsafe yet.
Encoder libtheora is not init-threadsafe yet.
Encoder libtwolame is not init-threadsafe yet.
Encoder libvorbis is not init-threadsafe yet.
Encoder libvpx is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Encoder libvpx-vp9 is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Encoder libwebp_anim is not init-threadsafe yet.
Encoder libwebp is not init-threadsafe yet.
Encoder libx265 is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Encoder libxavs is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Encoder libxavs2 is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Encoder h263_v4l2m2m is not init-threadsafe yet.
Encoder h264_nvenc is not init-threadsafe yet.
Encoder h264_qsv is not init-threadsafe yet.
Encoder h264_v4l2m2m is not init-threadsafe yet.
Encoder h264_vaapi is not init-threadsafe yet.
Encoder hevc_nvenc is not init-threadsafe yet.
Encoder hevc_qsv is not init-threadsafe yet.
Encoder hevc_v4l2m2m is not init-threadsafe yet.
Encoder hevc_vaapi is not init-threadsafe yet.
Encoder mjpeg_qsv is not init-threadsafe yet.
Encoder mjpeg_vaapi is not init-threadsafe yet.
Encoder mpeg2_qsv is not init-threadsafe yet.
Encoder mpeg2_vaapi is not init-threadsafe yet.
Encoder mpeg4_v4l2m2m is not init-threadsafe yet.
Encoder vp8_v4l2m2m is not init-threadsafe yet.
Encoder vp8_vaapi is not init-threadsafe yet.
Encoder vp9_vaapi is not init-threadsafe yet.
Encoder vp9_qsv is not init-threadsafe yet.
Decoder h263_v4l2m2m is not init-threadsafe yet.
Decoder h264_crystalhd is not init-threadsafe yet.
Decoder h264_v4l2m2m is not init-threadsafe yet.
Decoder h264_qsv is not init-threadsafe yet.
Decoder h264_rkmpp is not init-threadsafe yet.
Decoder hevc_qsv is not init-threadsafe yet.
Decoder hevc_rkmpp is not init-threadsafe yet.
Decoder hevc_v4l2m2m is not init-threadsafe yet.
Decoder mpeg4_crystalhd is not init-threadsafe yet.
Decoder mpeg4_v4l2m2m is not init-threadsafe yet.
Decoder mpeg1_v4l2m2m is not init-threadsafe yet.
Decoder mpeg2_crystalhd is not init-threadsafe yet.
Decoder mpeg2_v4l2m2m is not init-threadsafe yet.
Decoder mpeg2_qsv is not init-threadsafe yet.
Decoder msmpeg4_crystalhd is not init-threadsafe yet.
Decoder vc1_crystalhd is not init-threadsafe yet.
Decoder vc1_qsv is not init-threadsafe yet.
Decoder vc1_v4l2m2m is not init-threadsafe yet.
Decoder vp8_rkmpp is not init-threadsafe yet.
Decoder vp8_v4l2m2m is not init-threadsafe yet.
Decoder vp9_rkmpp is not init-threadsafe yet.
Decoder vp9_v4l2m2m is not init-threadsafe yet.
Decoder wmv3_crystalhd is not init-threadsafe yet.
Decoder libaribb24 is not init-threadsafe yet.
Decoder libcelt is not init-threadsafe yet.
Decoder libcodec2 is not init-threadsafe yet.
Decoder libdavs2 is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Decoder libgsm is not init-threadsafe yet.
Decoder libgsm_ms is not init-threadsafe yet.
Decoder libilbc is not init-threadsafe yet.
Decoder libopencore_amrnb is not init-threadsafe yet.
Decoder libopencore_amrwb is not init-threadsafe yet.
Decoder libopenjpeg is not init-threadsafe yet.
Codec supports threading: 1, 0, 0
Decoder libopus is not init-threadsafe yet.
Decoder libspeex is not init-threadsafe yet.
Decoder libuavs3d is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Decoder libvorbis is not init-threadsafe yet.
Decoder libvpx is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Decoder libvpx-vp9 is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Decoder libzvbi_teletextdec is not init-threadsafe yet.
Decoder libaom-av1 is not init-threadsafe yet.
Codec supports threading: 0, 0, 1
Decoder av1_cuvid is not init-threadsafe yet.
Decoder av1_qsv is not init-threadsafe yet.
Decoder h264_cuvid is not init-threadsafe yet.
Decoder hevc_cuvid is not init-threadsafe yet.
Decoder mjpeg_cuvid is not init-threadsafe yet.
Decoder mjpeg_qsv is not init-threadsafe yet.
Decoder mpeg1_cuvid is not init-threadsafe yet.
Decoder mpeg2_cuvid is not init-threadsafe yet.
Decoder mpeg4_cuvid is not init-threadsafe yet.
Decoder vc1_cuvid is not init-threadsafe yet.
Decoder vp8_cuvid is not init-threadsafe yet.
Decoder vp8_qsv is not init-threadsafe yet.
Decoder vp9_cuvid is not init-threadsafe yet.
Decoder vp9_qsv is not init-threadsafe yet.

 libavcodec/msmpeg4dec.c | 47 ++++++++++++++++++++++++-----------------
 libavcodec/mss2.c       |  1 +
 libavcodec/vc1dec.c     |  4 ++++
 libavcodec/wmv2dec.c    |  2 +-
 4 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 3d2dcb9429..ba72c7ee50 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -22,6 +22,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/thread.h"
+
 #include "avcodec.h"
 #include "internal.h"
 #include "mpegutils.h"
@@ -292,22 +294,10 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
 }
 
 /* init all vlc decoding tables */
-av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
+static av_cold void msmpeg4_decode_init_static(void)
 {
-    MpegEncContext *s = avctx->priv_data;
-    static volatile int done = 0;
-    int ret;
     MVTable *mv;
 
-    if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
-        return ret;
-
-    if (ff_h263_decode_init(avctx) < 0)
-        return -1;
-
-    ff_msmpeg4_common_init(s);
-
-    if (!done) {
         INIT_FIRST_VLC_RL(ff_rl_table[0], 642);
         INIT_FIRST_VLC_RL(ff_rl_table[1], 1104);
         INIT_FIRST_VLC_RL(ff_rl_table[2], 554);
@@ -372,8 +362,21 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
         INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
                  &ff_table_inter_intra[0][1], 2, 1,
                  &ff_table_inter_intra[0][0], 2, 1, 8);
-        done = 1;
-    }
+}
+
+av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
+{
+    static AVOnce init_static_once = AV_ONCE_INIT;
+    MpegEncContext *s = avctx->priv_data;
+    int ret;
+
+    if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
+        return ret;
+
+    if (ff_h263_decode_init(avctx) < 0)
+        return -1;
+
+    ff_msmpeg4_common_init(s);
 
     switch(s->msmpeg4_version){
     case 1:
@@ -394,6 +397,8 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
 
     s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
 
+    ff_thread_once(&init_static_once, msmpeg4_decode_init_static);
+
     return 0;
 }
 
@@ -866,7 +871,8 @@ const AVCodec ff_msmpeg4v1_decoder = {
     .close          = ff_h263_decode_end,
     .decode         = ff_h263_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .max_lowres     = 3,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
@@ -884,7 +890,8 @@ const AVCodec ff_msmpeg4v2_decoder = {
     .close          = ff_h263_decode_end,
     .decode         = ff_h263_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .max_lowres     = 3,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
@@ -902,7 +909,8 @@ const AVCodec ff_msmpeg4v3_decoder = {
     .close          = ff_h263_decode_end,
     .decode         = ff_h263_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .max_lowres     = 3,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
@@ -920,7 +928,8 @@ const AVCodec ff_wmv1_decoder = {
     .close          = ff_h263_decode_end,
     .decode         = ff_h263_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     .max_lowres     = 3,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index d7a19f6ad2..3b756c9399 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -855,4 +855,5 @@ const AVCodec ff_mss2_decoder = {
     .close          = mss2_decode_end,
     .decode         = mss2_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 7ed5133cfa..7568dfc332 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1209,6 +1209,7 @@ const AVCodec ff_vc1_decoder = {
     .decode         = vc1_decode_frame,
     .flush          = ff_mpeg_flush,
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
     .pix_fmts       = vc1_hwaccel_pixfmt_list_420,
     .hw_configs     = (const AVCodecHWConfigInternal *const []) {
 #if CONFIG_VC1_DXVA2_HWACCEL
@@ -1246,6 +1247,7 @@ const AVCodec ff_wmv3_decoder = {
     .decode         = vc1_decode_frame,
     .flush          = ff_mpeg_flush,
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
     .pix_fmts       = vc1_hwaccel_pixfmt_list_420,
     .hw_configs     = (const AVCodecHWConfigInternal *const []) {
 #if CONFIG_WMV3_DXVA2_HWACCEL
@@ -1283,6 +1285,7 @@ const AVCodec ff_wmv3image_decoder = {
     .close          = ff_vc1_decode_end,
     .decode         = vc1_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
     .flush          = vc1_sprite_flush,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
@@ -1302,6 +1305,7 @@ const AVCodec ff_vc1image_decoder = {
     .close          = ff_vc1_decode_end,
     .decode         = vc1_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
     .flush          = vc1_sprite_flush,
     .pix_fmts       = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_YUV420P,
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 7518088b6a..71c948df23 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -567,7 +567,7 @@ const AVCodec ff_wmv2_decoder = {
     .close          = wmv2_decode_end,
     .decode         = ff_h263_decode_frame,
     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
-    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                      AV_PIX_FMT_NONE },
 };
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 17/17] avcodec/msmpeg4dec: Reindent after the previous commit
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (14 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 16/17] avcodec/msmpeg4dec: Make initializing VLCs thread-safe Andreas Rheinhardt
@ 2022-02-12  6:41 ` Andreas Rheinhardt
  2022-02-17  7:46 ` [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-12  6:41 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index ba72c7ee50..ac7c7d75e2 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -298,70 +298,70 @@ static av_cold void msmpeg4_decode_init_static(void)
 {
     MVTable *mv;
 
-        INIT_FIRST_VLC_RL(ff_rl_table[0], 642);
-        INIT_FIRST_VLC_RL(ff_rl_table[1], 1104);
-        INIT_FIRST_VLC_RL(ff_rl_table[2], 554);
-        INIT_VLC_RL(ff_rl_table[3], 940);
-        INIT_VLC_RL(ff_rl_table[4], 962);
-        /* ff_rl_table[5] coincides with ff_h263_rl_inter which has just been
-         * initialized in ff_h263_decode_init() above. So just copy the VLCs. */
-        av_assert1(ff_h263_rl_inter.rl_vlc[0]);
-        memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
-
-        mv = &ff_mv_tables[0];
-        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
+    INIT_FIRST_VLC_RL(ff_rl_table[0], 642);
+    INIT_FIRST_VLC_RL(ff_rl_table[1], 1104);
+    INIT_FIRST_VLC_RL(ff_rl_table[2], 554);
+    INIT_VLC_RL(ff_rl_table[3], 940);
+    INIT_VLC_RL(ff_rl_table[4], 962);
+    /* ff_rl_table[5] coincides with ff_h263_rl_inter which has just been
+        * initialized in ff_h263_decode_init() above. So just copy the VLCs. */
+    av_assert1(ff_h263_rl_inter.rl_vlc[0]);
+    memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
+
+    mv = &ff_mv_tables[0];
+    INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
                     mv->table_mv_bits, 1, 1,
                     mv->table_mv_code, 2, 2, 3714);
-        mv = &ff_mv_tables[1];
-        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
+    mv = &ff_mv_tables[1];
+    INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1,
                     mv->table_mv_bits, 1, 1,
                     mv->table_mv_code, 2, 2, 2694);
 
-        INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
-                 &ff_table0_dc_lum[0][1], 8, 4,
-                 &ff_table0_dc_lum[0][0], 8, 4, 1158);
-        INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
-                 &ff_table0_dc_chroma[0][1], 8, 4,
-                 &ff_table0_dc_chroma[0][0], 8, 4, 1118);
-        INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
-                 &ff_table1_dc_lum[0][1], 8, 4,
-                 &ff_table1_dc_lum[0][0], 8, 4, 1476);
-        INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
-                 &ff_table1_dc_chroma[0][1], 8, 4,
-                 &ff_table1_dc_chroma[0][0], 8, 4, 1216);
-
-        INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
-                 &ff_v2_dc_lum_table[0][1], 8, 4,
-                 &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
-        INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
-                 &ff_v2_dc_chroma_table[0][1], 8, 4,
-                 &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
-
-        INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
-                 &ff_v2_intra_cbpc[0][1], 2, 1,
-                 &ff_v2_intra_cbpc[0][0], 2, 1, 8);
-        INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
-                 &ff_v2_mb_type[0][1], 2, 1,
-                 &ff_v2_mb_type[0][0], 2, 1, 128);
-
-        for (unsigned i = 0, offset = 0; i < 4; i++) {
-            static VLC_TYPE vlc_buf[1636 + 2648 + 1532 + 2488][2];
-            ff_mb_non_intra_vlc[i].table           = &vlc_buf[offset];
-            ff_mb_non_intra_vlc[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset;
-            init_vlc(&ff_mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128,
-                     &ff_wmv2_inter_table[i][0][1], 8, 4,
-                     &ff_wmv2_inter_table[i][0][0], 8, 4,
-                     INIT_VLC_STATIC_OVERLONG);
-            offset += ff_mb_non_intra_vlc[i].table_size;
-        }
+    INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
+                    &ff_table0_dc_lum[0][1], 8, 4,
+                    &ff_table0_dc_lum[0][0], 8, 4, 1158);
+    INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
+                    &ff_table0_dc_chroma[0][1], 8, 4,
+                    &ff_table0_dc_chroma[0][0], 8, 4, 1118);
+    INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
+                    &ff_table1_dc_lum[0][1], 8, 4,
+                    &ff_table1_dc_lum[0][0], 8, 4, 1476);
+    INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
+                    &ff_table1_dc_chroma[0][1], 8, 4,
+                    &ff_table1_dc_chroma[0][0], 8, 4, 1216);
+
+    INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
+                    &ff_v2_dc_lum_table[0][1], 8, 4,
+                    &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
+    INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
+                    &ff_v2_dc_chroma_table[0][1], 8, 4,
+                    &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
+
+    INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
+                    &ff_v2_intra_cbpc[0][1], 2, 1,
+                    &ff_v2_intra_cbpc[0][0], 2, 1, 8);
+    INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
+                    &ff_v2_mb_type[0][1], 2, 1,
+                    &ff_v2_mb_type[0][0], 2, 1, 128);
+
+    for (unsigned i = 0, offset = 0; i < 4; i++) {
+        static VLC_TYPE vlc_buf[1636 + 2648 + 1532 + 2488][2];
+        ff_mb_non_intra_vlc[i].table           = &vlc_buf[offset];
+        ff_mb_non_intra_vlc[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset;
+        init_vlc(&ff_mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128,
+                 &ff_wmv2_inter_table[i][0][1], 8, 4,
+                 &ff_wmv2_inter_table[i][0][0], 8, 4,
+                 INIT_VLC_STATIC_OVERLONG);
+        offset += ff_mb_non_intra_vlc[i].table_size;
+    }
 
-        INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
-                 &ff_msmp4_mb_i_table[0][1], 4, 2,
-                 &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
+    INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
+                    &ff_msmp4_mb_i_table[0][1], 4, 2,
+                    &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
 
-        INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
-                 &ff_table_inter_intra[0][1], 2, 1,
-                 &ff_table_inter_intra[0][0], 2, 1, 8);
+    INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
+                    &ff_table_inter_intra[0][1], 2, 1,
+                    &ff_table_inter_intra[0][0], 2, 1, 8);
 }
 
 av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
-- 
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 13/17] avcodec/exr: Mark decoder as init-threadsafe
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 13/17] avcodec/exr: Mark decoder as init-threadsafe Andreas Rheinhardt
@ 2022-02-12  7:48   ` Paul B Mahol
  0 siblings, 0 replies; 21+ messages in thread
From: Paul B Mahol @ 2022-02-12  7:48 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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 03/17] avcodec/amrwbdec: Mark decoder as init-threadsafe
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 03/17] avcodec/amrwbdec: " Andreas Rheinhardt
@ 2022-02-12  7:49   ` Paul B Mahol
  0 siblings, 0 replies; 21+ messages in thread
From: Paul B Mahol @ 2022-02-12  7:49 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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 02/17] avcodec/amrnbdec: Mark decoder as init-threadsafe
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 02/17] avcodec/amrnbdec: " Andreas Rheinhardt
@ 2022-02-12  7:49   ` Paul B Mahol
  0 siblings, 0 replies; 21+ messages in thread
From: Paul B Mahol @ 2022-02-12  7:49 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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe
  2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
                   ` (15 preceding siblings ...)
  2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 17/17] avcodec/msmpeg4dec: Reindent after the previous commit Andreas Rheinhardt
@ 2022-02-17  7:46 ` Andreas Rheinhardt
  16 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-02-17  7:46 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> The only interesting thing done in SVQ3's init function
> is using zlib, but this is fine: https://zlib.net/zlib_faq.html#faq21
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/svq3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
> index be95e222aa..da61617f4e 100644
> --- a/libavcodec/svq3.c
> +++ b/libavcodec/svq3.c
> @@ -1601,5 +1601,5 @@ const AVCodec ff_svq3_decoder = {
>                        AV_CODEC_CAP_DELAY,
>      .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P,
>                                                       AV_PIX_FMT_NONE},
> -    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
> +    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
>  };

Will apply the rest of this patchset 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] 21+ messages in thread

end of thread, other threads:[~2022-02-17  7:46 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-12  6:24 [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 02/17] avcodec/amrnbdec: " Andreas Rheinhardt
2022-02-12  7:49   ` Paul B Mahol
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 03/17] avcodec/amrwbdec: " Andreas Rheinhardt
2022-02-12  7:49   ` Paul B Mahol
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 04/17] avcodec/rv30: " Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 05/17] avcodec/rv40: Make decoder init-threadsafe Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 06/17] avcodec/apedec: Mark decoder as init-threadsafe Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 07/17] avcodec/alsdec: Return directly upon error Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 08/17] avcodec/alsdec: Improve code locality Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 09/17] avcodec/alsdec, mlz: Check allocation Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 10/17] avcodec/alsdec: Mark decoder as init-threadsafe Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 11/17] avcodec/ituh263dec: Make initializing VLCs thread-safe Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 12/17] avcodec/ituh263dec: Reindent after the last commit Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 13/17] avcodec/exr: Mark decoder as init-threadsafe Andreas Rheinhardt
2022-02-12  7:48   ` Paul B Mahol
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 14/17] avcodec/vorbisdec: " Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 15/17] avcodec/avcodec: Decrease the amount of time while holding the lock Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 16/17] avcodec/msmpeg4dec: Make initializing VLCs thread-safe Andreas Rheinhardt
2022-02-12  6:41 ` [FFmpeg-devel] [PATCH 17/17] avcodec/msmpeg4dec: Reindent after the previous commit Andreas Rheinhardt
2022-02-17  7:46 ` [FFmpeg-devel] [PATCH 01/17] avcodec/svq3: Mark decoder as init-threadsafe 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