From patchwork Mon Sep 19 13:18:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38047 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1231058pzh; Mon, 19 Sep 2022 06:22:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/lijbGx/ATdaEKwOU0O+yiu1mKlFK4LZEZ4pY5wZ5+n1ZRggEYeT2hkdZNdHubXBSOH/N X-Received: by 2002:a17:907:b09:b0:76f:99cc:81cd with SMTP id h9-20020a1709070b0900b0076f99cc81cdmr12439243ejl.530.1663593750693; Mon, 19 Sep 2022 06:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663593750; cv=none; d=google.com; s=arc-20160816; b=hMLzxmMX22qraFLORoFO4KLVgdemYzGjN47462vYskNwGOqZylAMAr6+CmKVEN4ODV ZJ68ej2HIk9yTDIsr//8siGXmUbzc/8Ay7pj4XiC6M/kzk3bBT1XXRWToo5nlXgrSpBn FJszei7b52eoia6wfMR+ujpgdMWHNZXgW9Ch9Ne14FF2FH550a3uS/z+CVsJDEYKmN1Q +crfU810sOaORCJjiF39uJ0+MsLV8KIzR4Ex29pwgQwmwE+kM5TKNCGAZcttv2Cet1vO SZYJlmNllvZE86cRp1gVOJJTEANU91bc10XI3EwJ49L+9hzD6oUooAm292flY9iwLe4M lNWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=SvKvevNjNJtpSmGEWZt5K2Cy2APOW3Pte08xRgc+QNY=; b=01OBI1u563+dZE6SNBnmquE66KE5mX6pK1Y+SoJJooDGZqySHml9MjNLydlXruWkhD tspOi9C6Ji0VpaLgq62S/7PXoUlk3qmqoZnU+gRcYV2vp8ffUsw6JuKSpODYyw62HO3O 3gXtf86iaxOxQM67FyGxb9OPLI8VSIkYdAV3MrgwKmQC126Kc59Q/czb0YhDOhZZNE2A jSKMDquE5nFN3wo0QFDQYhQBaofdH4b7gjLJCx0VN7D8dk6+91pwKCJ6fKdEzemW8woZ SSH+JGT934ecTkXyiSOLLCNmrg8/Coqhd11I+uOJL6sWflCwsmKobI2ICoSvnMgdeW1H mT5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rv14-20020a17090710ce00b00780429cae7fsi10064639ejb.409.2022.09.19.06.22.30; Mon, 19 Sep 2022 06:22:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B4D168BC6F; Mon, 19 Sep 2022 16:22:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7864168BB1F for ; Mon, 19 Sep 2022 16:22:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7BFB1240D03 for ; Mon, 19 Sep 2022 15:22:21 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 0Gc-Ag-_Gblb for ; Mon, 19 Sep 2022 15:22:17 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 208F1240175 for ; Mon, 19 Sep 2022 15:22:17 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 4C9DA3A0520; Mon, 19 Sep 2022 15:22:11 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 15:18:29 +0200 Message-Id: <20220919131829.14950-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/pthread_frame: always transfer stashed hwaccel state X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 36vQLAmIHIB8 Fixes assertion failures after avcodec_flush_buffers(), where stashed hwaccel state is present, but prev_thread is NULL. Found-by: Wang Bin --- libavcodec/pthread_frame.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 066269621d..f8fddc5e4d 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -459,14 +459,14 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx, pthread_mutex_unlock(&p->mutex); return err; } - - /* transfer hwaccel state stashed from previous thread, if any */ - av_assert0(!p->avctx->hwaccel); - FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel); - FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context); - FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv); } + /* transfer the stashed hwaccel state, if any */ + av_assert0(!p->avctx->hwaccel); + FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel); + FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context); + FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv); + av_packet_unref(p->avpkt); ret = av_packet_ref(p->avpkt, avpkt); if (ret < 0) {