From patchwork Wed Oct 17 12:01:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 10695 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 6F0DA446E56 for ; Wed, 17 Oct 2018 15:01:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C7F4D68A5C0; Wed, 17 Oct 2018 15:01:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 74FF068A5B0 for ; Wed, 17 Oct 2018 15:01:00 +0300 (EEST) Received: by mail-pg1-f194.google.com with SMTP id f18-v6so12452487pgv.3 for ; Wed, 17 Oct 2018 05:01:25 -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=M7zZEVS2Km6UdWghQYn1ACzEynWpOuP7N//+iIsdp8g=; b=LnaSZxWUydxufsQsGJU2iUG+fpybORW+uDNwfuCXk/5unGJYbarbi0ybraUR5R19UO u31c1oVWAqC/gth2KlfuWJUAG0Lgoe8YNzqg7NHVeh67eeQ9gKBL5MTnhbWwwBuGwZgQ vHXrVYEl2KG0utXVf+2RN66A/BpcM9Vsi0W8OyCQpVm9sPQN5h63V0mX73cVQZFJl9jT wzt5aI/HUz0TtFOIrO0q47PxLCPrrTT0keq1mxhkyUt7XmnpeUksjYpB4t7814Aq9DBm 7o19yuxyMtPCUjIhLpMx35PqB+cM6+ZG1iyXJp4X+uvQQdLHZSaRO8I8FEJu3uRnxCar HexQ== 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=M7zZEVS2Km6UdWghQYn1ACzEynWpOuP7N//+iIsdp8g=; b=TIaBcFu1dj5yiNM/xAl5f83YXDg+BmnMeVjaq/8cSHvGGSb2OKTwOgZ6I6YgTs/PKJ U4WgeItc7ebmruUHQtNa31jJx06W4DqOouHbEO9ECtz1IAPMjDdxmeuOUuISJCxzLmDm C1UaIKl9KicU2KyLdoue5U7eqKUMlXfiZG04qkIJw87ASIBbM1YULMuUDMx3UaoE6Lb+ +ZqaeCqHWOYXKAa/JDm2Ji831jIXNEYpOFTrOXYVxS83aWSNWG0Iu5Gln3yBkqwpfR3W GgPzaaWglm4oAwur/ca1mIXy9eOAKG+4QEjrhcIPAKkoCWLHbf/uMXnJW2cpSIZCpdL4 kwZA== X-Gm-Message-State: ABuFfogwx/qpbw/lpgVSOF2zI8kwBJJFqQY2jkFRwYzrBd74CJTaA5f8 fudW9jC3xzTYTGKDdThcxDeYVJvJ+8M= X-Google-Smtp-Source: ACcGV61689qsz/vxlxbkgU102gti1fBPvxUXiHZyCNDaqf6Y4RIcHMeZuFyb12fYn/yS3il1RYLQcg== X-Received: by 2002:a62:ea03:: with SMTP id t3-v6mr27131020pfh.228.1539777683776; Wed, 17 Oct 2018 05:01:23 -0700 (PDT) Received: from localhost.localdomain ([47.90.47.25]) by smtp.gmail.com with ESMTPSA id n87-v6sm23935008pfb.62.2018.10.17.05.01.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 05:01:22 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Oct 2018 20:01:18 +0800 Message-Id: <1539777678-24518-1-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.1 Subject: [FFmpeg-devel] [PATCH V2] 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" Fix the issue: https://github.com/intel/media-driver/issues/317 the root cause is update_dimensions call get_pixel_format will trigger the hwaccel_uninit/hwaccel_init , in current context, there are 3 situations in the update_dimensions(): 1. First time calling. No matter single thread or multithread, get_pixel_format() should be called after dimensions 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_dimensions() at first time to allocate macroblocks_base and set dimensions. 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_dimensions as need. Signed-off-by: Wang, Shaofei Reviewed-by: Jun, Zhao Reviewed-by: Haihao Xiang --- libavcodec/vp8.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index a06692c..c205868 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);