From patchwork Fri Dec 27 08:48:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 16994 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 48DAF44A196 for ; Fri, 27 Dec 2019 10:59:24 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2F2806899BB; Fri, 27 Dec 2019 10:59:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0E9EB688108 for ; Fri, 27 Dec 2019 10:59:16 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Dec 2019 00:59:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,362,1571727600"; d="scan'208";a="215147892" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by fmsmga008.fm.intel.com with ESMTP; 27 Dec 2019 00:59:14 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 27 Dec 2019 16:48:33 +0800 Message-Id: <1577436513-25309-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH 2/2] lavc/vp9: support hardware decode with resolution changing on inter frame 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" VP9 decoder should be able to handle resolution changing on inter frame without re-initialization. For hardware decoder, re-allocate hardware frame surface. Fix #8068 for VA-API. Signed-off-by: Linjie Fu --- Request for comments. This works for VA-API, however for dxva2 it didn't cover all cases. Another idea is to register a call-back function in AVHWAccel (such as ff_vp9_dxva2_hwaccel) to handle surface re-allocation according to the hardware decoder. libavcodec/vp9.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 0fd15ef..a7b4c6a 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -34,6 +34,7 @@ #include "vp9dec.h" #include "libavutil/avassert.h" #include "libavutil/pixdesc.h" +#include "decode.h" #define VP9_SYNCCODE 0x498342 @@ -220,11 +221,20 @@ static int update_size(AVCodecContext *avctx, int w, int h) *fmtp++ = s->pix_fmt; *fmtp = AV_PIX_FMT_NONE; - ret = ff_thread_get_format(avctx, pix_fmts); - if (ret < 0) - return ret; + if (avctx->internal->hwaccel_priv_data && s->pix_fmt == s->gf_fmt && (s->w != w || s->h != h)) { + const AVHWDeviceContext *device_ctx = + (AVHWDeviceContext*)avctx->hw_device_ctx->data; + ret = ff_decode_get_hw_frames_ctx(avctx, device_ctx->type); + if (ret < 0) + return ret; + } else { + ret = ff_thread_get_format(avctx, pix_fmts); + if (ret < 0) + return ret; + + avctx->pix_fmt = ret; + } - avctx->pix_fmt = ret; s->gf_fmt = s->pix_fmt; s->w = w; s->h = h;