From patchwork Thu Jun 25 11:23:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ManojGuptaBonda X-Patchwork-Id: 20602 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 6518E4484D6 for ; Thu, 25 Jun 2020 14:23:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 47691687F44; Thu, 25 Jun 2020 14:23:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8312768015C for ; Thu, 25 Jun 2020 14:23:26 +0300 (EEST) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 25 Jun 2020 04:23:11 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Thu, 25 Jun 2020 04:23:23 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Thu, 25 Jun 2020 04:23:23 -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; Thu, 25 Jun 2020 11:23:21 +0000 From: ManojGuptaBonda To: , Date: Thu, 25 Jun 2020 16:53:01 +0530 Message-ID: <20200625112302.21994-2-mbonda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200625112302.21994-1-mbonda@nvidia.com> References: <20200625112302.21994-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=1593084191; bh=xmq/We9inXrCSJApeZku3uFmY3BiCYnWnOWQWp7UhTY=; 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=qk/Uf+oiINoaKXAEAPT9XgUC8YQQp5YoU9dFv+hrfGZ65XYOZMzQiL188k3Tjd17b s5DX7OJj84AKHOLoUiLpajO+in9SnfDqHMnlfMVXDhQvZ0Elyt5RnwkMjech8/YsEZ kiUTzJ4JDjN/FfnldNQgd41S9NTNcHSxCmY+1XUCodUyR9r6i7L9PYRMBWEOlrz345 ugDpXNfmyfBUvFp5nfLN3IyBrurCOlA0ScsYUMKrbP1KJvLI7scD5iGbIxNlFi3o7C NPce49RIhiaMF3bGdd3hOO2Y6RPtGa8q+/i3+/SVOPkNUZ1DfTa3LDx6gNt1vtDBcV 1O/Bfi+BgoAlg== Subject: [FFmpeg-devel] [PATCH 1/2] lavc/vdpau_hevc: add function to find exact vdp_profile for REXT 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" Add vdpau_parse_rext_profile and use profile constraint flags to determine the exact vdp_profile for HEVC_REXT. If profile mismatch is allowed, select Main profile by default. Add build object in Makefile for h265_profile_level dependency. --- libavcodec/Makefile | 2 +- libavcodec/vdpau_hevc.c | 83 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 5a6ea59715..4f28cb0f2a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -910,7 +910,7 @@ OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o -OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o +OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o h265_profile_level.o OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL) += vaapi_mjpeg.o OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL) += nvdec_mpeg12.o diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c index 29cb2da078..1ee781c685 100644 --- a/libavcodec/vdpau_hevc.c +++ b/libavcodec/vdpau_hevc.c @@ -29,6 +29,8 @@ #include "hwconfig.h" #include "vdpau.h" #include "vdpau_internal.h" +#include "h265_profile_level.h" + static int vdpau_hevc_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) @@ -429,10 +431,87 @@ static int vdpau_hevc_end_frame(AVCodecContext *avctx) return 0; } + + +static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel *h265_raw_ptl) +{ + h265_raw_ptl->general_profile_space = general_ptl->profile_space; + h265_raw_ptl->general_tier_flag = general_ptl->tier_flag; + h265_raw_ptl->general_profile_idc = general_ptl->profile_idc; + + memcpy(h265_raw_ptl->general_profile_compatibility_flag, + general_ptl->profile_compatibility_flag, 32 * sizeof(uint8_t)); + +#define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name + copy_field(progressive_source_flag); + copy_field(interlaced_source_flag); + copy_field(non_packed_constraint_flag); + copy_field(frame_only_constraint_flag); + copy_field(max_12bit_constraint_flag); + copy_field(max_10bit_constraint_flag); + copy_field(max_8bit_constraint_flag); + copy_field(max_422chroma_constraint_flag); + copy_field(max_420chroma_constraint_flag); + copy_field(max_monochrome_constraint_flag); + copy_field(intra_constraint_flag); + copy_field(one_picture_only_constraint_flag); + copy_field(lower_bit_rate_constraint_flag); + copy_field(max_14bit_constraint_flag); + copy_field(inbld_flag); + copy_field(level_idc); +#undef copy_field + + return 0; +} + +/* + * Find exact vdpau_profile for HEVC Range Extension + */ +static int vdpau_hevc_parse_rext_profile(AVCodecContext *avctx, VdpDecoderProfile *vdp_profile) +{ + const HEVCContext *h = avctx->priv_data; + const HEVCSPS *sps = h->ps.sps; + const PTL *ptl = &sps->ptl; + const PTLCommon *general_ptl = &ptl->general_ptl; + const H265ProfileDescriptor *profile; + H265RawProfileTierLevel h265_raw_ptl = {0}; + + /* convert PTLCommon to H265RawProfileTierLevel */ + ptl_convert(general_ptl, &h265_raw_ptl); + + profile = ff_h265_get_profile(&h265_raw_ptl); + if (!profile) { + av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n"); + if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) { + // Default to selecting Main profile if profile mismatch is allowed + *vdp_profile = VDP_DECODER_PROFILE_HEVC_MAIN; + return 0; + } else + return AVERROR(ENOTSUP); + } + + if (!strcmp(profile->name, "Main 12") || + !strcmp(profile->name, "Main 12 Intra")) + *vdp_profile = VDP_DECODER_PROFILE_HEVC_MAIN_12; + else if (!strcmp(profile->name, "Main 4:4:4") || + !strcmp(profile->name, "Main 4:4:4 Intra")) + *vdp_profile = VDP_DECODER_PROFILE_HEVC_MAIN_444; + else if (!strcmp(profile->name, "Main 4:4:4 10") || + !strcmp(profile->name, "Main 4:4:4 10 Intra")) + *vdp_profile = VDP_DECODER_PROFILE_HEVC_MAIN_444_10; + else if (!strcmp(profile->name, "Main 4:4:4 12") || + !strcmp(profile->name, "Main 4:4:4 12 Intra")) + *vdp_profile = VDP_DECODER_PROFILE_HEVC_MAIN_444_12; + + return 0; +} + + static int vdpau_hevc_init(AVCodecContext *avctx) { VdpDecoderProfile profile; uint32_t level = avctx->level; + int ret; switch (avctx->profile) { case FF_PROFILE_HEVC_MAIN: @@ -445,7 +524,9 @@ static int vdpau_hevc_init(AVCodecContext *avctx) profile = VDP_DECODER_PROFILE_HEVC_MAIN_STILL; break; case FF_PROFILE_HEVC_REXT: - profile = VDP_DECODER_PROFILE_HEVC_MAIN_444; + ret = vdpau_hevc_parse_rext_profile(avctx, &profile); + if (ret) + return AVERROR(ENOTSUP); break; default: return AVERROR(ENOTSUP); From patchwork Thu Jun 25 11:23:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ManojGuptaBonda X-Patchwork-Id: 20603 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 56A074484D6 for ; Thu, 25 Jun 2020 14:23:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38DE568804B; Thu, 25 Jun 2020 14:23:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1ADDD68015C for ; Thu, 25 Jun 2020 14:23:29 +0300 (EEST) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 25 Jun 2020 04:23:15 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 25 Jun 2020 04:23:28 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 25 Jun 2020 04:23:28 -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; Thu, 25 Jun 2020 11:23:26 +0000 From: ManojGuptaBonda To: , Date: Thu, 25 Jun 2020 16:53:02 +0530 Message-ID: <20200625112302.21994-3-mbonda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200625112302.21994-1-mbonda@nvidia.com> References: <20200625112302.21994-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=1593084195; bh=wj4q6KfILzSDyDoMwa3Pg5GyAlE2dcPYLDXxOpYXyjA=; 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=RG+LN3Kj7H7e5sE6Vj+TvOfKJqPNchJUgujVbgPlLI99HO/V3WoupHdBbdXcS5yjF sgvTI1ukg5hSHTJB4EuGzOHHNR9Iwg4U/fVdzsnRFmv3KTL8ROUiUC6a1sJnT/DeJ4 7gQO8sOEGuXvOl7dQWPmeNg60RVqx02k41a3/6UI1a8At46cfVckkpwrHB3MYIELfY zU1M9qbO43DxQsyEhCdkDH427xthm8cSQEPbKWOiMISC3NXa5mr7+VEbPsqfYT9b+1 rQmbZ6vFgL/dVQgT6xluNt7KGRiMUzbG3SJ7NBnTBoJkyYT6OXol/AfhccJlLgC4ea Z8/utbIkENXqg== 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 | 13 +++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index c9e28f5826..e576cce5de 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -414,6 +414,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 @@ -435,6 +438,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..6061476094 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,8 @@ 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 }, + { VDP_YCBCR_FORMAT_P016, AV_PIX_FMT_P016 }, + { VDP_YCBCR_FORMAT_P010, AV_PIX_FMT_P010 }, { 0, AV_PIX_FMT_NONE, }, }; @@ -75,6 +77,7 @@ 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 }, + {VDP_YCBCR_FORMAT_Y_U_V_444_16, AV_PIX_FMT_YUV444P16}, #endif { 0, AV_PIX_FMT_NONE, }, }; @@ -87,6 +90,11 @@ 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 }, + { 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_YUV422P, 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 }, }; static int count_pixfmts(const VDPAUPixFmtMap *map) @@ -354,6 +362,7 @@ 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) + || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444_16) #endif ) FFSWAP(void*, data[1], data[2]);