From patchwork Wed Sep 16 20:57:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 22454 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 A5B6744AD96 for ; Thu, 17 Sep 2020 11:37:55 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 702DF68BAB9; Thu, 17 Sep 2020 11:37:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C1BC68B976 for ; Thu, 17 Sep 2020 11:37:48 +0300 (EEST) IronPort-SDR: 7/pfuLDjol42ghaJnvr7CZ40mWL9yt8NyR4QwiSIKA/rP2r1W5O72To1BbZSf+qDNq1dmJRFO3 c22f71SQbSaw== X-IronPort-AV: E=McAfee;i="6000,8403,9746"; a="157059414" X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="scan'208";a="157059414" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 01:37:46 -0700 IronPort-SDR: 134UEyfBvVW0P0rVDrKbflczciMmAbi49tdXCPU6qwvkdXFpf4mM6HLUDYcj+9Ngpm/P+9aSGy Cn9IXbDzhKdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="scan'208";a="508324633" Received: from yami-tgl.sh.intel.com ([10.239.35.1]) by fmsmga005.fm.intel.com with ESMTP; 17 Sep 2020 01:37:45 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Sep 2020 16:57:15 -0400 Message-Id: <20200916205715.3624-1-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec/av1dec: check avctx->hwaccel when hwaccel pix_fmt selected 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: Fei Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Pix fmt with hwaccel flag may not be chosen in format probing, in this case avctx->hwaccel will not be inited. Signed-off-by: Fei Wang --- libavcodec/av1dec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 0bb04a3e44..cdcc618013 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -251,6 +251,7 @@ static int get_pixel_format(AVCodecContext *avctx) { AV1DecContext *s = avctx->priv_data; const AV1RawSequenceHeader *seq = s->raw_seq; + const AVPixFmtDescriptor *desc; uint8_t bit_depth; int ret; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; @@ -327,10 +328,13 @@ static int get_pixel_format(AVCodecContext *avctx) * Since now the av1 decoder doesn't support native decode, if it will be * implemented in the future, need remove this check. */ - if (!avctx->hwaccel) { - av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport" - " hardware accelerated AV1 decoding.\n"); - return AVERROR(ENOSYS); + desc = av_pix_fmt_desc_get(ret); + if (desc && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { + if (!avctx->hwaccel) { + av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport" + " hardware accelerated AV1 decoding.\n"); + return AVERROR(ENOSYS); + } } avctx->pix_fmt = ret;