From patchwork Fri Nov 20 07:19:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23837 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 1F8D0448ACD for ; Fri, 20 Nov 2020 09:39:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5FCB768BBCF; Fri, 20 Nov 2020 09:25:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3BD968BBD8 for ; Fri, 20 Nov 2020 09:25:35 +0200 (EET) Received: by mail-ej1-f67.google.com with SMTP id s25so11498270ejy.6 for ; Thu, 19 Nov 2020 23:25:35 -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=IKcDdMaR2wVaI45OZZVHtgSYkB73LhN3Bzn31yZfyo4=; b=YstvDUs0grIDpnwESyulu6F+dtKJZyIbnaEnGRwmXxK2YX2EM2bxeKAlTkkq3SvdNr Lp7XVJ9pwucF/OS2OasInQMUczfVTztBevSJT8IPkA+khNF/98qnxp4VNKC35m9WAu+m Ym0+n4v2C5kLYU1HWHWIdsms4SIQWK/njf88Q1OV/FMDFqLabrmBkGhB6SD6PylCkDkX io83VNxl4b3g9FJxD7cFpxv/9BXHQaJujaEOLZtS0nIyFoTqJ059UUipj/4WWI5jkx/r I+RkwiVvgbzdJZqN8BU5FlTOx2/5LH5VVn7kWYB3O4nWb+VesSpvbo95mT9f9GubjxDW tH3w== 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=IKcDdMaR2wVaI45OZZVHtgSYkB73LhN3Bzn31yZfyo4=; b=njxGDnzNahMF4ElNvvRyrmDCEW16C54nBwoo9kAc5lBq0ylhihPoav8TN+j0s7ixO2 LmHI/+1gwD2m8xsGfKCRUl8dt28LSiGTBXcnGGPccfewEl0suKGI+nGw2qzlRKfT8fxq 0vfleeY88cTOB4WIW/TU0Mnl5qZVWTlqxCqCjMo/NnUt1UCwK543AKqBpe8QWxKhRmP7 8iVhRf5lq+nyIlSlhzeqVnZu/6u3z3oUQ/4/Yrj5vl05gu2XEZzyvh169ZVTh+KBOORc uJmZy0Y+Wvilpj84e8RJ8yeJbdDtdRZ4AdlUFTb2u4/tGxh3BTiSXfhtY2wiAPPQL+Iw BeTg== X-Gm-Message-State: AOAM531+0S8qiyz0yNJtNwKpzbopkxaCpdZo55mW3CPd5SIan41vlFvm peLC/5IA0yr5vXhUD2hGlJlgLMhYfzwovQ== X-Google-Smtp-Source: ABdhPJxdkRsCwCYtA4b3+lOb4IqF0JSFHl+N2SanR5JVj2HSrsL/Fli9WCErvLDTYQWVhKRlyl9dEA== X-Received: by 2002:a17:907:11d9:: with SMTP id va25mr13256668ejb.431.1605857135224; Thu, 19 Nov 2020 23:25:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:25:34 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:19:58 +0100 Message-Id: <20201120072116.818090-86-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 085/162] avcodec/indeo2: Make decoder thread-safe 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/indeo2.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 5a9c0e77be..5721308267 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -25,6 +25,7 @@ */ #include "libavutil/attributes.h" +#include "libavutil/thread.h" #define BITSTREAM_READER_LE #include "avcodec.h" @@ -225,8 +226,16 @@ static int ir2_decode_frame(AVCodecContext *avctx, return buf_size; } +static av_cold void ir2_init_static(void) +{ + INIT_VLC_STATIC_FROM_LENGTHS(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, + &ir2_tab[0][1], 2, &ir2_tab[0][0], 2, 1, + 0, INIT_VLC_OUTPUT_LE, 1 << CODE_VLC_BITS); +} + static av_cold int ir2_decode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; Ir2Context * const ic = avctx->priv_data; ic->avctx = avctx; @@ -237,9 +246,7 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx) if (!ic->picture) return AVERROR(ENOMEM); - INIT_VLC_STATIC_FROM_LENGTHS(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, - &ir2_tab[0][1], 2, &ir2_tab[0][0], 2, 1, - 0, INIT_VLC_OUTPUT_LE, 1 << CODE_VLC_BITS); + ff_thread_once(&init_static_once, ir2_init_static); return 0; } @@ -263,4 +270,5 @@ AVCodec ff_indeo2_decoder = { .close = ir2_decode_end, .decode = ir2_decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, };