From patchwork Mon Oct 21 10:20:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ManojGuptaBonda X-Patchwork-Id: 15886 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 6FFFF44757A for ; Mon, 21 Oct 2019 16:41:50 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4954468B0DF; Mon, 21 Oct 2019 16:41:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from hqemgate16.nvidia.com (hqemgate16.nvidia.com [216.228.121.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 94D8C68AFA3 for ; Mon, 21 Oct 2019 16:41:42 +0300 (EEST) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 21 Oct 2019 06:41:42 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 21 Oct 2019 06:41:39 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 21 Oct 2019 06:41:39 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 21 Oct 2019 10:20:35 +0000 Received: from bondagupta-NVWorkStation.nvidia.com (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 21 Oct 2019 10:20:32 +0000 From: ManojGuptaBonda To: Date: Mon, 21 Oct 2019 15:50:12 +0530 Message-ID: <20191021102013.30676-2-mbonda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021102013.30676-1-mbonda@nvidia.com> References: <20191021102013.30676-1-mbonda@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1571665302; bh=sgDBQzh6rkNOd5/k6PNUZrygPJSjjTvYxID8PrdMpEg=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-Originating-IP: X-ClientProxiedBy:Content-Type; b=TfQ1ZtHosYu0C9OwctpkG8DN+GuIQ0m6a94gKj5SOszIIsdIAS3eyTQK9PNaily0B X8oZBbdlmDpvVLoCZ0uRAdpXCdn7jTSVhQgmbJTtAXSDTfwpJf2v+8yB2uUd/JR3vK +KUG3TfJQn9p453tDa4YEGMbvx9vjCzGdUARU92xlw0IusG6BBraGRnaZP9BMMhBgf 4vRq+YTTsLvOd5/TG2eAZwzG55RSooEiQSf1lb7L4XIArN1+tHk08QFH8O0u2dBIA2 qu6LZef9ERu53Tn5Y1s2lQFe41qkGyOr5UMoZ+NnQZFIPcvBqbuodklJO1y2fidB7J oovNpOdTSekpQ== Subject: [FFmpeg-devel] [PATCH 1/2] Add VP9 VDPAU to list of hwaccels and supported formats 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: ManojGuptaBonda , aplattner@nvidia.com, swarren@nvidia.com, ARitger@nvidia.com, philipl@overt.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Added file vdpau_vp9.c for supporting VDPAU VP9 decoding in FFmpeg with stub functions. Modified configure to add VDPAU VP9 support. Mapped VP9 profiles to VDPAU VP9 profiles. Support for VDPAU accelerated VP9 decoding was added with libvdpau-1.3 version. Profiles related to VDPAU VP9 can be found in latest vdpau.h present in libvdpau-1.3 --- configure | 3 ++ libavcodec/Makefile | 1 + libavcodec/hwaccels.h | 1 + libavcodec/vdpau_internal.h | 3 ++ libavcodec/vdpau_vp9.c | 91 +++++++++++++++++++++++++++++++++++++ libavcodec/vp9.c | 9 +++- 6 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 libavcodec/vdpau_vp9.c diff --git a/configure b/configure index 8413826f9e..7f63eebc9d 100755 --- a/configure +++ b/configure @@ -2979,6 +2979,8 @@ vp9_nvdec_hwaccel_deps="nvdec" vp9_nvdec_hwaccel_select="vp9_decoder" vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth" vp9_vaapi_hwaccel_select="vp9_decoder" +vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9" +vp9_vdpau_hwaccel_select="vp9_decoder" wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel" wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel" wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" @@ -6093,6 +6095,7 @@ check_type "windows.h d3d11.h" "ID3D11VideoContext" check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC" +check_type "vdpau/vdpau.h" "VdpPictureInfoVP9" if [ -z "$nvccflags" ]; then nvccflags=$nvccflags_default diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 37a84a6bb4..34c3a22116 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -913,6 +913,7 @@ OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_NVDEC_HWACCEL) += nvdec_vp9.o OBJS-$(CONFIG_VP9_VAAPI_HWACCEL) += vaapi_vp9.o +OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec_other.o # libavformat dependencies diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 7d73da8676..6109c89bd6 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -68,6 +68,7 @@ extern const AVHWAccel ff_vp9_d3d11va2_hwaccel; extern const AVHWAccel ff_vp9_dxva2_hwaccel; extern const AVHWAccel ff_vp9_nvdec_hwaccel; extern const AVHWAccel ff_vp9_vaapi_hwaccel; +extern const AVHWAccel ff_vp9_vdpau_hwaccel; extern const AVHWAccel ff_wmv3_d3d11va_hwaccel; extern const AVHWAccel ff_wmv3_d3d11va2_hwaccel; extern const AVHWAccel ff_wmv3_dxva2_hwaccel; diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h index 1ee38dbc55..b6ea078cb2 100644 --- a/libavcodec/vdpau_internal.h +++ b/libavcodec/vdpau_internal.h @@ -54,6 +54,9 @@ union VDPAUPictureInfo { #ifdef VDP_YCBCR_FORMAT_Y_U_V_444 VdpPictureInfoHEVC444 hevc_444; #endif +#ifdef VDP_DECODER_PROFILE_VP9_PROFILE_0 + VdpPictureInfoVP9 vp9; +#endif }; typedef struct VDPAUHWContext { diff --git a/libavcodec/vdpau_vp9.c b/libavcodec/vdpau_vp9.c new file mode 100644 index 0000000000..d8f629d135 --- /dev/null +++ b/libavcodec/vdpau_vp9.c @@ -0,0 +1,91 @@ +/* + * VP9 HW decode acceleration through VDPAU + * + * Copyright (c) 2019 Manoj Gupta Bonda + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "avcodec.h" +#include "internal.h" +#include "vp9data.h" +#include "vp9dec.h" +#include "hwaccel.h" +#include "vdpau.h" +#include "vdpau_internal.h" + +static int vdpau_vp9_start_frame(AVCodecContext *avctx, + const uint8_t *buffer, uint32_t size) +{ + return 0; +} + +static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 }; + +static int vdpau_vp9_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, uint32_t size) +{ + return 0; +} + +static int vdpau_vp9_end_frame(AVCodecContext *avctx) +{ + return 0; +} + +static int vdpau_vp9_init(AVCodecContext *avctx) +{ + VdpDecoderProfile profile; + uint32_t level = avctx->level; + + switch (avctx->profile) { + case FF_PROFILE_VP9_0: + profile = VDP_DECODER_PROFILE_VP9_PROFILE_0; + break; + case FF_PROFILE_VP9_1: + profile = VDP_DECODER_PROFILE_VP9_PROFILE_1; + break; + case FF_PROFILE_VP9_2: + profile = VDP_DECODER_PROFILE_VP9_PROFILE_2; + break; + case FF_PROFILE_VP9_3: + profile = VDP_DECODER_PROFILE_VP9_PROFILE_3; + break; + default: + return AVERROR(ENOTSUP); + } + + return ff_vdpau_common_init(avctx, profile, level); +} + +const AVHWAccel ff_vp9_vdpau_hwaccel = { + .name = "vp9_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_VP9, + .pix_fmt = AV_PIX_FMT_VDPAU, + .start_frame = vdpau_vp9_start_frame, + .end_frame = vdpau_vp9_end_frame, + .decode_slice = vdpau_vp9_decode_slice, + .frame_priv_data_size = sizeof(struct vdpau_picture_context), + .init = vdpau_vp9_init, + .uninit = ff_vdpau_common_uninit, + .frame_params = ff_vdpau_common_frame_params, + .priv_data_size = sizeof(VDPAUContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index f16462b1e9..e6edab524e 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -173,7 +173,8 @@ static int update_size(AVCodecContext *avctx, int w, int h) #define HWACCEL_MAX (CONFIG_VP9_DXVA2_HWACCEL + \ CONFIG_VP9_D3D11VA_HWACCEL * 2 + \ CONFIG_VP9_NVDEC_HWACCEL + \ - CONFIG_VP9_VAAPI_HWACCEL) + CONFIG_VP9_VAAPI_HWACCEL + \ + CONFIG_VP9_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; VP9Context *s = avctx->priv_data; uint8_t *p; @@ -201,6 +202,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) #endif #if CONFIG_VP9_VAAPI_HWACCEL *fmtp++ = AV_PIX_FMT_VAAPI; +#endif +#if CONFIG_VP9_VDPAU_HWACCEL + *fmtp++ = AV_PIX_FMT_VDPAU; #endif break; case AV_PIX_FMT_YUV420P12: @@ -1816,6 +1820,9 @@ AVCodec ff_vp9_decoder = { #endif #if CONFIG_VP9_VAAPI_HWACCEL HWACCEL_VAAPI(vp9), +#endif +#if CONFIG_VP9_VDPAU_HWACCEL + HWACCEL_VDPAU(vp9), #endif NULL },