From patchwork Thu Aug 9 07:09:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 9943 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp1821458jad; Thu, 9 Aug 2018 00:09:21 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzfckjVq9FumxAOoWnrdMntoMeHVviYagdCGA+Fca60vvSLGzpzXMYhWeVc/PiAhkHafa73 X-Received: by 2002:a1c:ea9c:: with SMTP id g28-v6mr767574wmi.65.1533798561218; Thu, 09 Aug 2018 00:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533798561; cv=none; d=google.com; s=arc-20160816; b=S6KGeuLAxRwnuqLLHPmMGV/kgties8C8oV1d1lG4lGajgI3BS6EdNGWFqunmTATXZ9 6+DAOkHdrbxr24KGJyYFpRY+eEFGNrVDcm0wasB6rXyrWl1QyTrGEctyb+4IuaFlBSUI NuaHaAGE8u5O8g58PNah3bDAt97rLomGlcM92xFLLpWyyXpcO9Yw6W7LsmlI5SopdW8j 0x5dUzlVs3rKdu8oCuw6RqaPlOWo9SU6Gh/C/Uoq0UhgFDB/xP72kGzOajEG8BHczciy 68hA5ysyFrawDZnrYupTCNphZflizyTnVP12F1sNCPGz36PAZHFHbnToEy1YRmKLlfu1 dpnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=1tZ7ORJQ023Ab9JTpSP/UzImf3im/f3PZM7nqP7K4QQ=; b=KrgXdG1zg3QOZJIGDr9QSXAB+HqrmT+HzLKwK790Ei3MaEkvGniN4g/yKrSkrH5U3e 3VfuTdyiHzni12UpA/sDpUuqWOBMJTW097rsX8mi3tr2odS7qs5z8S5CaM86Jxy8wXk/ P9KUJECQokOgZnNWj708UYVNOm9TTfznj/BMaCl3HA9C8pjXnqAH1XpQ47XZ9iVgtu6V 9MG7k67cVFoFOaTpcej/0rDgOWxhQUEV0xOE+s32S+HPrzi0R4Besf9mECeJhhxRJ5VS xKjs01dDPJQWUMXvOo7IyhiktlfNSPBG7K8T1d1COqGlOP59uPnrMpcDLykfxk0gxCia k/0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=bCLvIwYe; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y7-v6si5114898wmg.96.2018.08.09.00.09.20; Thu, 09 Aug 2018 00:09:21 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=bCLvIwYe; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E8CCD68A4C6; Thu, 9 Aug 2018 10:08:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6A612689C54 for ; Thu, 9 Aug 2018 10:08:50 +0300 (EEST) Received: by mail-pg1-f195.google.com with SMTP id r5-v6so2318511pgv.0 for ; Thu, 09 Aug 2018 00:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=bWalJk8RY/dCYf95PDjb6d7Al/MZAVApr/CDsKIQZ5o=; b=bCLvIwYeE1TexMNGnjZE4HEsyWnmJOfshSTdL6txpVFRO/KARVPKsJoSiHXszKQmMJ 7+ZL9q7+iGtq4nJDdfBKINczkQB8cnxOIQw5DtvZ/FNYaa0ixZjJeAGEpZKu0SGoupeY WXfQWsFkxWIzIz94sGwfebWdomk4rPUN8qkTfgBAfPaNqHMtWr0Mfmz1SIbupqL2O+/1 Mz6DVd5QM/XAYXQsnt7D5fTTbyccFN+0w1qEPfiYFZjDcqftxcYmSZuvC+6Bhr53A9BW lXcb8O20Jl+OWz1Cuf91TjMcXi/nc0+9cGcHd6lnKp/OSoE63SUVemvvtvb6vqYgcw2X OSUg== 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; bh=bWalJk8RY/dCYf95PDjb6d7Al/MZAVApr/CDsKIQZ5o=; b=rGUWu9JXsj5D8ASZjtVZmR9smX1evueTqzFq6VeSgIg3WT5GMCU7FS1UV/owYM1XhP ajZNbB2nc3RHNVWUkIPE1fhBmfwMPiVPPiXuBVrbkHwnqqZbzvprRlL8wJVdbNX9Xxlt ICqPyhm/XfUb3sNV9AA+MsWgukztKX364DgctZcMjmVxhPUGQrcI1iTneAlKYxipAK6a MPx9ZqhFPfq4t06fqiOxEsj+0Mt+nCzeuTVryhDs7z/s5fLHXU4g0ETmbZz3sFZlzqux BBJibmDVSgm+8EODxJsF5imB5o656Mhc0QsIctOy6wmbFF5XNdc9cveiJpy4P9M9EO4G vhOQ== X-Gm-Message-State: AOUpUlF4OxJcIK1Qu3g/yYvohoCWcoKmrJEm5cocjQ48Pz4wvX1H6Kwg r/r1FfUqGLxoxBewrxFjxxZDsf7t5h0= X-Received: by 2002:a62:6cc7:: with SMTP id h190-v6mr1065094pfc.113.1533798549936; Thu, 09 Aug 2018 00:09:09 -0700 (PDT) Received: from localhost.localdomain ([47.90.47.25]) by smtp.gmail.com with ESMTPSA id j15-v6sm7557739pfn.52.2018.08.09.00.09.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 00:09:09 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Aug 2018 15:09:02 +0800 Message-Id: <1533798542-2494-1-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.1 Subject: [FFmpeg-devel] [PATCH] libavcodec/vp8dec: fix the multi-thread HWAccel decode error 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: Jun Zhao , "Wang, Shaofei" MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" the root cause is update_dimentions call get_pixel_format will trigger the hwaccel_uninit/hwaccel_init , in current context, there are 3 situations in the update_dimentions(): 1. First time calling. No matter single thread or multithread, get_pixel_format() should be called after dimentions were set; 2. Dimention changed at the runtime. Dimention need to be updated when macroblocks_base is already allocated, get_pixel_format() should be called to recreate new frames according to updated dimention; 3. Multithread first time calling. After decoder init, the other threads will call update_dimentions() at first time to allocate macroblocks_base and set dimentions. But get_pixel_format() is shouldn't be called due to low level frames and context are already created. In this fix, we only call update_dimentions as need. Signed-off-by: Wang, Shaofei Reviewed-by: Jun, Zhao --- libavcodec/vp8.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 3adfeac..18d1ada 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -187,7 +187,7 @@ static av_always_inline int update_dimensions(VP8Context *s, int width, int height, int is_vp7) { AVCodecContext *avctx = s->avctx; - int i, ret; + int i, ret, dim_reset = 0; if (width != s->avctx->width || ((width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height) && s->macroblocks_base || height != s->avctx->height) { @@ -196,9 +196,12 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7) ret = ff_set_dimensions(s->avctx, width, height); if (ret < 0) return ret; + + dim_reset = (s->macroblocks_base != NULL); } - if (!s->actually_webp && !is_vp7) { + if ((s->pix_fmt == AV_PIX_FMT_NONE || dim_reset) && + !s->actually_webp && !is_vp7) { s->pix_fmt = get_pixel_format(s); if (s->pix_fmt < 0) return AVERROR(EINVAL);