From patchwork Fri Nov 27 01:02:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24070 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 5463B44B413 for ; Fri, 27 Nov 2020 03:07:40 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3851268BB8F; Fri, 27 Nov 2020 03:07:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0DCE668BBB7 for ; Fri, 27 Nov 2020 03:07:26 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id w24so4488707wmi.0 for ; Thu, 26 Nov 2020 17:07:25 -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 :mime-version:content-transfer-encoding; bh=9r194S52a1YUibtFq8fLkFkrpY1xoMnal5bBPUVuh8o=; b=ri2g5sm773yUrtBtHko8h8KAslHIHJu/jE5qY+dVX17Q0aJ/YoX9piZn2yuScMbSkk kAP4z3nhjFQmsjNK2kiz/EiwTQiWgO1flin/jI9aJ53TFJQdPZBfOWmSC2/HR2RD8SZO eRPTXNAPYJBLxrWRP4pkG0N3v0Tz3qqRcYVXQfJdHiqSqYDwzJabIO1enoi2KP8NO5Jq 0/yS29nKpsvq7/uWyKnW7HaP7aOlytIST3fIREwqVLNSM/B+qxnJ+X3I5O+chprv2bFh TI5YBunplCLZOTmL6T1mBAHmTrT2cVq7bDAPnI4mGti4lfM/dj0qKrhuPKHnTnD2zjG2 6IZg== 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:mime-version:content-transfer-encoding; bh=9r194S52a1YUibtFq8fLkFkrpY1xoMnal5bBPUVuh8o=; b=WKJO0T5NXv0SNFN+ToK8l7tNsKYx3GqM+BDf46dyj6upGB0K21eJcVmUdsP9qiJJtA pquoTcVaWeYnVxC9dyyPHBb60PsPxHNDh1oihqWY/ECoaIEye/TH4lyU2cVTPXOpiBHZ gYZ+CqKt7Fl32CSmKMa+wa57dLPK1pYd9mCVvAyql0Dnmjn7kmafm18B/Xbd9lKS1xAm +ZQSzXC4dUy4/pWTxSeZHYt2fBHHLDpIsG7ykkb+P09s85bnrj/u7993wltmXqoXnych U3siBpikwOLAdLxo0Xgoa+2biavrooj9axeaJ70/VyFnwTAX3b0prX2wDjLTOcjtLFVc bIFQ== X-Gm-Message-State: AOAM530C2BZW7LwqRIiCLXxDyvbHqzsJtY7diQX6f5iywn46U3605pMO Yb+GbufYWMDmgJrTPS+ttEztB4c5yl4AXg== X-Google-Smtp-Source: ABdhPJwqDhv41psfxVyS/QMFfQQDMrFTBlSf5GW+M68QWYOMngDUVELeixZ8bnqHe9W3otFVoC7QPg== X-Received: by 2002:a05:600c:229a:: with SMTP id 26mr6203948wmf.100.1606439245315; Thu, 26 Nov 2020 17:07:25 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id l8sm10504450wro.46.2020.11.26.17.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 17:07:24 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 27 Nov 2020 02:02:48 +0100 Message-Id: <20201127010249.2724610-44-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201127010249.2724610-1-andreas.rheinhardt@gmail.com> References: <20201127010249.2724610-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 44/45] avcodec/tiff: 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" The only thing that stands in the way of adding the FF_CODEC_CAP_INIT_THREADSAFE flag to the TIFF decoder is its usage of ff_codec_open2_recursive(): This function requires its caller to hold the lock for the mutex that guards initialization of AVCodecContexts whose codecs have a non-threadsafe init function and only callers whose codec does not have the FF_CODEC_CAP_INIT_THREADSAFE flag set hold said lock (the others don't need to care about said lock). But one can set the flag if one switches to avcodec_open2() at the same time. Signed-off-by: Andreas Rheinhardt --- libavcodec/tiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 2e45464218..fa1f44ce1d 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -2168,7 +2168,7 @@ static av_cold int tiff_init(AVCodecContext *avctx) s->avctx_mjpeg->flags2 = avctx->flags2; s->avctx_mjpeg->dct_algo = avctx->dct_algo; s->avctx_mjpeg->idct_algo = avctx->idct_algo; - ret = ff_codec_open2_recursive(s->avctx_mjpeg, codec, NULL); + ret = avcodec_open2(s->avctx_mjpeg, codec, NULL); if (ret < 0) { return ret; } @@ -2219,6 +2219,6 @@ AVCodec ff_tiff_decoder = { .close = tiff_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .priv_class = &tiff_decoder_class, };