From patchwork Sat Jun 27 13:34:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ManojGuptaBonda X-Patchwork-Id: 20644 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 9C61044ABCF for ; Sat, 27 Jun 2020 16:34:55 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82E0268B607; Sat, 27 Jun 2020 16:34:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB75C68B606 for ; Sat, 27 Jun 2020 16:34:49 +0300 (EEST) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sat, 27 Jun 2020 06:34:00 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Sat, 27 Jun 2020 06:34:48 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Sat, 27 Jun 2020 06:34:48 -0700 Received: from bondagupta-NVWorkStation.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 27 Jun 2020 13:34:45 +0000 From: ManojGuptaBonda To: , Date: Sat, 27 Jun 2020 19:04:22 +0530 Message-ID: <20200627133422.8321-3-mbonda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200627133422.8321-1-mbonda@nvidia.com> References: <20200627133422.8321-1-mbonda@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1593264840; bh=0nMvnlBGN0eDvJYkTYBvpCzCHJu784otbpP4t4bVC20=; 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=bGBrPJ/e2xguMZDWU2XEPJ+hsMDPKOTuHFK8S94+hWYrmBtNPrfnhHrc0A3iTjoL4 dWk2onvN6ALMknSL1IShG/AIURqO2wu2gkgsI4ifEfP+zAtYUjtVW/Lb+PHuYJYrx+ hC2g2N+RHB12egCHi0N+ToZHSUqPssqqKiL3Y4Cf5llj8zxwfjl/yTgJ4u4mnyBDRo JL4H+uicSza3fBPc+Wsj8Svh/5uJvuqRPWlz6joR+SznaUGBzj8Q5C3/rq12AImRqf y+R0GpwQTGMY73JS7x/3dT3lbN2ebHZ+C711PJ5vTOgohxeqkVpUIm803c5x9doWlL R29+JI5jpXe6w== Subject: [FFmpeg-devel] [PATCH 2/2] Add VDPAU to list of 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: aplattner@nvidia.com, ManojGuptaBonda , philipl@overt.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Added VDPAU to list of supported formats for HEVC10 and 12 bit formats also added 42010 bit to surface_parameters and new VDP chroma formats to VDPAUPixFmtMaps Add HEVC 420 10/12 Bit and 444 10/12 Bit support for VDPAU YUV444P10 is defined as the 444 surface with 10bit valid data in LSBs but H/w returns Data in MSBs Hence if we map output as YUV444p16 it is filtering out the LSB to convert to p10 format. --- libavcodec/hevcdec.c | 6 ++++++ libavcodec/vdpau.c | 4 ++++ libavutil/hwcontext_vdpau.c | 21 +++++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index b63cba6c25..b4375ccec2 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -423,6 +423,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif +#if CONFIG_HEVC_VDPAU_HWACCEL + *fmt++ = AV_PIX_FMT_VDPAU; +#endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; #endif @@ -444,6 +447,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV444P10: case AV_PIX_FMT_YUV444P12: +#if CONFIG_HEVC_VDPAU_HWACCEL + *fmt++ = AV_PIX_FMT_VDPAU; +#endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; #endif diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 167f06d7ae..fa10905c75 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -83,6 +83,8 @@ int av_vdpau_get_surface_parameters(AVCodecContext *avctx, switch (avctx->sw_pix_fmt) { case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUVJ420P: + case AV_PIX_FMT_YUV420P10: + case AV_PIX_FMT_YUV420P12: t = VDP_CHROMA_TYPE_420; w = (w + 1) & ~1; h = (h + 3) & ~3; @@ -95,6 +97,8 @@ int av_vdpau_get_surface_parameters(AVCodecContext *avctx, break; case AV_PIX_FMT_YUV444P: case AV_PIX_FMT_YUVJ444P: + case AV_PIX_FMT_YUV444P10: + case AV_PIX_FMT_YUV444P12: t = VDP_CHROMA_TYPE_444; h = (h + 1) & ~1; break; diff --git a/libavutil/hwcontext_vdpau.c b/libavutil/hwcontext_vdpau.c index 6b8c1d5f76..dbef5495af 100644 --- a/libavutil/hwcontext_vdpau.c +++ b/libavutil/hwcontext_vdpau.c @@ -39,8 +39,8 @@ typedef struct VDPAUDeviceContext { VdpVideoSurfaceCreate *surf_create; VdpVideoSurfaceDestroy *surf_destroy; - enum AVPixelFormat *pix_fmts[3]; - int nb_pix_fmts[3]; + enum AVPixelFormat *pix_fmts[8]; + int nb_pix_fmts[8]; } VDPAUDeviceContext; typedef struct VDPAUFramesContext { @@ -61,6 +61,10 @@ typedef struct VDPAUPixFmtMap { static const VDPAUPixFmtMap pix_fmts_420[] = { { VDP_YCBCR_FORMAT_NV12, AV_PIX_FMT_NV12 }, { VDP_YCBCR_FORMAT_YV12, AV_PIX_FMT_YUV420P }, +#ifdef VDP_YCBCR_FORMAT_P016 + { VDP_YCBCR_FORMAT_P016, AV_PIX_FMT_P016 }, + { VDP_YCBCR_FORMAT_P010, AV_PIX_FMT_P010 }, +#endif { 0, AV_PIX_FMT_NONE, }, }; @@ -75,6 +79,9 @@ static const VDPAUPixFmtMap pix_fmts_422[] = { static const VDPAUPixFmtMap pix_fmts_444[] = { #ifdef VDP_YCBCR_FORMAT_Y_U_V_444 { VDP_YCBCR_FORMAT_Y_U_V_444, AV_PIX_FMT_YUV444P }, +#endif +#ifdef VDP_YCBCR_FORMAT_P016 + {VDP_YCBCR_FORMAT_Y_U_V_444_16, AV_PIX_FMT_YUV444P16}, #endif { 0, AV_PIX_FMT_NONE, }, }; @@ -87,6 +94,13 @@ static const struct { { VDP_CHROMA_TYPE_420, AV_PIX_FMT_YUV420P, pix_fmts_420 }, { VDP_CHROMA_TYPE_422, AV_PIX_FMT_YUV422P, pix_fmts_422 }, { VDP_CHROMA_TYPE_444, AV_PIX_FMT_YUV444P, pix_fmts_444 }, +#ifdef VDP_YCBCR_FORMAT_P016 + { VDP_CHROMA_TYPE_420_16, AV_PIX_FMT_YUV420P10, pix_fmts_420 }, + { VDP_CHROMA_TYPE_420_16, AV_PIX_FMT_YUV420P12, pix_fmts_420 }, + { VDP_CHROMA_TYPE_422_16, AV_PIX_FMT_YUV422P10, pix_fmts_422 }, + { VDP_CHROMA_TYPE_444_16, AV_PIX_FMT_YUV444P10, pix_fmts_444 }, + { VDP_CHROMA_TYPE_444_16, AV_PIX_FMT_YUV444P12, pix_fmts_444 }, +#endif }; static int count_pixfmts(const VDPAUPixFmtMap *map) @@ -354,6 +368,9 @@ static int vdpau_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, if ((vdpau_format == VDP_YCBCR_FORMAT_YV12) #ifdef VDP_YCBCR_FORMAT_Y_U_V_444 || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444) +#endif +#ifdef VDP_YCBCR_FORMAT_P016 + || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444_16) #endif ) FFSWAP(void*, data[1], data[2]);