From patchwork Fri Nov 20 07:19:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23823 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DE1A244B51D for ; Fri, 20 Nov 2020 09:37:02 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB3D668BBB2; Fri, 20 Nov 2020 09:25:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C60F768BA9A for ; Fri, 20 Nov 2020 09:25:19 +0200 (EET) Received: by mail-ed1-f68.google.com with SMTP id q3so8444876edr.12 for ; Thu, 19 Nov 2020 23:25:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=jh1YmNpcxjkwTgXr3Q0br5qSJT8IGboNZPUqWwDi8Y4=; b=hzTsSiUQ1e+3PpN7NoYooPCee6aj9u/6AMPJazxyNeSjyt5aLP0Ps5kyK/0D7mp8mo 5KeV3TBv6ioL6/Ndsh6X3nr1xze1kgk997Njo/raSRk0QU/pj8rtFZ9S1+XiC7V1c6Pk OcTKIBUHYcEG/bx7QVcG31GojRLCIEWp9j1Brlyc8cO+2RWN7FME6NZ5K72laICIPpxR 1eyJ/F0P01rpx7wKWV5cuw4umCFRvB14oEI4fQCY+hpNMzJpcDt+03T6NCfjaA8SCeZk A3rnAjmW/NQYBb5Weoumn2x5uk2odge9emr7dRenHHITEcgop/qDCsUTYs/bK8XqKbN/ lKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=jh1YmNpcxjkwTgXr3Q0br5qSJT8IGboNZPUqWwDi8Y4=; b=nW6oll85lM4SgRCtsvzbSvavDO8xB+v9EJUZ4SlGGvYpLxgD2ajXsvX+OEWhxSZJV/ kJ7SqqidwfJmv6XWqFLxD08emaMwbcUmEihjLHOXxizA/G70+4kUJE6Bd/CA3ZBi4C3B ozBA1g6+spvghKaNuHvZUU5gTQ42FZV+qxvFAAMWbM68OmvtWf7NmNZIR+KzGCmPZijD E1uQFfv0n+OUj3zvHHlfwf/Sk7ts/u4mtMl+jWM68FahxkZY7ltKw2yzeZ0VDMWIonPB 5ngPxDzu8LSwDRrPzl/JszCEXfPvA5o7ShuFGEZEAqCDfNowbNUbJL5+/5V9Mu9cKDtI wzLw== X-Gm-Message-State: AOAM533AgVGxeCI7vdnj4QVg0hTBJObpLP8ER08kQR3N3vtVbt70vsAd v0C79npHFoFaE4JXqnexo3YB0sJxcgZBdA== X-Google-Smtp-Source: ABdhPJxHxEez/M7FlPts0KDTZiF84fHNthC4VaFeID08BNj6YTzL4zAq6fq3DCp0fj5YV7EFRCdPmQ== X-Received: by 2002:aa7:d34e:: with SMTP id m14mr33180486edr.42.1605857119046; Thu, 19 Nov 2020 23:25:19 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id lz27sm779419ejb.39.2020.11.19.23.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:25:18 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:19:42 +0100 Message-Id: <20201120072116.818090-70-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> References: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 069/162] avcodec/qdm2: Make decoder init-threadsafe X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index f2e78c3fa2..b1465750c2 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -36,6 +36,7 @@ #include #include "libavutil/channel_layout.h" +#include "libavutil/thread.h" #define BITSTREAM_READER_LE #include "avcodec.h" @@ -1598,19 +1599,12 @@ static void qdm2_synthesis_filter(QDM2Context *q, int index) * @param q context */ static av_cold void qdm2_init_static_data(void) { - static int done; - - if(done) - return; - qdm2_init_vlc(); softclip_table_init(); rnd_table_init(); init_noise_samples(); ff_mpa_synth_init_float(); - - done = 1; } /** @@ -1618,12 +1612,11 @@ static av_cold void qdm2_init_static_data(void) { */ static av_cold int qdm2_decode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; QDM2Context *s = avctx->priv_data; int tmp_val, tmp, size; GetByteContext gb; - qdm2_init_static_data(); - /* extradata parsing Structure: @@ -1769,6 +1762,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) avctx->sample_fmt = AV_SAMPLE_FMT_S16; + ff_thread_once(&init_static_once, qdm2_init_static_data); + return 0; } @@ -1885,4 +1880,5 @@ AVCodec ff_qdm2_decoder = { .close = qdm2_decode_close, .decode = qdm2_decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, };