From patchwork Sat Oct 20 20:46:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 10728 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 F32CE4486D9 for ; Sat, 20 Oct 2018 23:47:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 675CC68A7F7; Sat, 20 Oct 2018 23:47:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ua1-f98.google.com (mail-ua1-f98.google.com [209.85.222.98]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E1F2968A774 for ; Sat, 20 Oct 2018 23:47:02 +0300 (EEST) Received: by mail-ua1-f98.google.com with SMTP id f12so8656907uan.6 for ; Sat, 20 Oct 2018 13:47:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RZpkTNreyc94JU2qZByuHUhqGli2C5ReU54tfSQccDQ=; b=cR0F6pVxHWQ62WBQvk4ntP7p8g5nnVwEH+Xz/AGEBkOGvEVRPxb1N+OoeVYgXgjR9W jKHxnLzzgVDN0oHBQY570xqXWx8L7E6skO/VEx5vMF2BH0X/lpKwGCX0icAtzfukLVno zptcpE1vwGB1nlHG3OL0I/y5uzlOR4hfcmPOdgEhzOQ+zTNCv65hQmWhuzH08xr4YCEr fObVW+ArBcl33fVCIWOoP/rHIo+COoTN6KtcygYs4cj+zB88VA5TkCWyQVMWqjeg1Fgn MBHsV/AE+9xbkM+F7kU/PsPgoCNCy7oDc5dSrVLjpnc3O0aYYH5Mtjbpbu8AchrfQs41 Pj0g== X-Gm-Message-State: ABuFfohhC/u7CriiMyf+kcBmGEV5CvaHxgfmi4JcUjA78IVrob6VtBjh 6oLNpPM3kdJUBRyGc8PbsaR5XhvVit5PoEoJNmUIsSlo4pATFw== X-Google-Smtp-Source: ACcGV63o04W1YySaa+/FRh6knewF68ZhbEdSTl2H8DCxPNkevxt7tSQnYKobrxzsv/Cg2Sl47OHNTODbE1v/ X-Received: by 2002:ab0:4714:: with SMTP id h20mr6456063uac.122.1540068448001; Sat, 20 Oct 2018 13:47:28 -0700 (PDT) Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com. [107.178.208.155]) by smtp-relay.gmail.com with ESMTPS id y21sm2662327vso.1.2018.10.20.13.47.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Oct 2018 13:47:27 -0700 (PDT) X-Relaying-Domain: gapps.overt.org Received: from authenticated-user (mail.overt.org [107.178.208.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id A41676195B; Sat, 20 Oct 2018 20:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1540068446; bh=2ZLa9ZEMC2YfedDluXlvQE5pFS9FTdXP9sHbvs1kVew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ig8zeRPjAR4J2C5SLU02X5x5KfOQ1tBNbGYuRzoZyBOj6ID8pl3KO2qSfMGlbyupD MOKH7R0KkqtXKGCYm7IQopxUnUu2jVTquDGyl7GtZm/OW2/tS+MUXTpEIaXteCWfg/ mhLTTNHacFMKPLAWs552NaYKbQ8HN76OKqbi4mE6L3WjCDHzewkSIdc40L1RN6qrwL vnfqXLzLKqJ8Ckq8Gw0PWw1JvcHIE3IvU/cQPXe5ef7QB+Hat314YLgDK+PXOaFWBx 4UZ0qx7FXKq74Kw488S3EC9Ee4l/bbJ20BR558NXdlc6gblm0hMHIsGuWHHoaE/g17 PtYYyFE0Hc5Kg== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Sat, 20 Oct 2018 13:46:59 -0700 Message-Id: <20181020204701.6865-4-philipl@overt.org> In-Reply-To: <20181020204701.6865-1-philipl@overt.org> References: <20181020204701.6865-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/nvdec: Explicitly mark codecs that support 444 output 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: Philip Langdale Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" With the introduction of HEVC 444 support, we technically have two codecs that can handle 444 - HEVC and MJPEG. In the case of MJPEG, it can decode, but can only output one of the semi-planar formats. That means we need additional logic to decide whether to use a 444 output format or not. Signed-off-by: Philip Langdale --- libavcodec/nvdec.c | 7 ++++--- libavcodec/nvdec.h | 5 ++++- libavcodec/nvdec_h264.c | 2 +- libavcodec/nvdec_hevc.c | 10 ++++++++-- libavcodec/nvdec_mjpeg.c | 2 +- libavcodec/nvdec_mpeg12.c | 2 +- libavcodec/nvdec_mpeg4.c | 2 +- libavcodec/nvdec_vc1.c | 2 +- libavcodec/nvdec_vp8.c | 2 +- libavcodec/nvdec_vp9.c | 2 +- 10 files changed, 23 insertions(+), 13 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index 43cc38485a..76e8b7c7bc 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -295,7 +295,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n"); return AVERROR(ENOSYS); } - chroma_444 = cuvid_chroma_format == cudaVideoChromaFormat_444; + chroma_444 = ctx->supports_444 && cuvid_chroma_format == cudaVideoChromaFormat_444; if (!avctx->hw_frames_ctx) { ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA); @@ -595,7 +595,8 @@ static AVBufferRef *nvdec_alloc_dummy(int size) int ff_nvdec_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx, - int dpb_size) + int dpb_size, + int supports_444) { AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data; const AVPixFmtDescriptor *sw_desc; @@ -616,7 +617,7 @@ int ff_nvdec_frame_params(AVCodecContext *avctx, av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n"); return AVERROR(EINVAL); } - chroma_444 = cuvid_chroma_format == cudaVideoChromaFormat_444; + chroma_444 = supports_444 && cuvid_chroma_format == cudaVideoChromaFormat_444; frames_ctx->format = AV_PIX_FMT_CUDA; frames_ctx->width = (avctx->coded_width + 1) & ~1; diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h index 85a0fcf725..09ae8c37e6 100644 --- a/libavcodec/nvdec.h +++ b/libavcodec/nvdec.h @@ -61,6 +61,8 @@ typedef struct NVDECContext { unsigned *slice_offsets; int nb_slices; unsigned int slice_offsets_allocated; + + int supports_444; } NVDECContext; int ff_nvdec_decode_init(AVCodecContext *avctx); @@ -72,7 +74,8 @@ int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size); int ff_nvdec_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx, - int dpb_size); + int dpb_size, + int supports_444); int ff_nvdec_get_ref_idx(AVFrame *frame); #endif /* AVCODEC_NVDEC_H */ diff --git a/libavcodec/nvdec_h264.c b/libavcodec/nvdec_h264.c index 25b30329d0..116bd4fb5d 100644 --- a/libavcodec/nvdec_h264.c +++ b/libavcodec/nvdec_h264.c @@ -166,7 +166,7 @@ static int nvdec_h264_frame_params(AVCodecContext *avctx, { const H264Context *h = avctx->priv_data; const SPS *sps = h->ps.sps; - return ff_nvdec_frame_params(avctx, hw_frames_ctx, sps->ref_frame_count + sps->num_reorder_frames); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, sps->ref_frame_count + sps->num_reorder_frames, 0); } const AVHWAccel ff_h264_nvdec_hwaccel = { diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c index e04a701f3a..9e726f708e 100644 --- a/libavcodec/nvdec_hevc.c +++ b/libavcodec/nvdec_hevc.c @@ -269,7 +269,13 @@ static int nvdec_hevc_frame_params(AVCodecContext *avctx, { const HEVCContext *s = avctx->priv_data; const HEVCSPS *sps = s->ps.sps; - return ff_nvdec_frame_params(avctx, hw_frames_ctx, sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering + 1); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering + 1, 1); +} + +static int nvdec_hevc_decode_init(AVCodecContext *avctx) { + NVDECContext *ctx = avctx->internal->hwaccel_priv_data; + ctx->supports_444 = 1; + return ff_nvdec_decode_init(avctx); } const AVHWAccel ff_hevc_nvdec_hwaccel = { @@ -281,7 +287,7 @@ const AVHWAccel ff_hevc_nvdec_hwaccel = { .end_frame = ff_nvdec_end_frame, .decode_slice = nvdec_hevc_decode_slice, .frame_params = nvdec_hevc_frame_params, - .init = ff_nvdec_decode_init, + .init = nvdec_hevc_decode_init, .uninit = ff_nvdec_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; diff --git a/libavcodec/nvdec_mjpeg.c b/libavcodec/nvdec_mjpeg.c index 7e404246ce..be39d23bae 100644 --- a/libavcodec/nvdec_mjpeg.c +++ b/libavcodec/nvdec_mjpeg.c @@ -66,7 +66,7 @@ static int nvdec_mjpeg_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { // Only need storage for the current frame - return ff_nvdec_frame_params(avctx, hw_frames_ctx, 1); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, 1, 0); } #if CONFIG_MJPEG_NVDEC_HWACCEL diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c index 7293d50555..300e1d3d88 100644 --- a/libavcodec/nvdec_mpeg12.c +++ b/libavcodec/nvdec_mpeg12.c @@ -87,7 +87,7 @@ static int nvdec_mpeg12_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { // Each frame can at most have one P and one B reference - return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2, 0); } #if CONFIG_MPEG2_NVDEC_HWACCEL diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index 907af1391a..739b049933 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -103,7 +103,7 @@ static int nvdec_mpeg4_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { // Each frame can at most have one P and one B reference - return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2, 0); } const AVHWAccel ff_mpeg4_nvdec_hwaccel = { diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c index 7257692d66..10e7b5ab0d 100644 --- a/libavcodec/nvdec_vc1.c +++ b/libavcodec/nvdec_vc1.c @@ -107,7 +107,7 @@ static int nvdec_vc1_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { // Each frame can at most have one P and one B reference - return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, 2, 0); } const AVHWAccel ff_vc1_nvdec_hwaccel = { diff --git a/libavcodec/nvdec_vp8.c b/libavcodec/nvdec_vp8.c index 7b37445613..9c4608d8cf 100644 --- a/libavcodec/nvdec_vp8.c +++ b/libavcodec/nvdec_vp8.c @@ -87,7 +87,7 @@ static int nvdec_vp8_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { // VP8 uses a fixed size pool of 3 possible reference frames - return ff_nvdec_frame_params(avctx, hw_frames_ctx, 3); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, 3, 0); } AVHWAccel ff_vp8_nvdec_hwaccel = { diff --git a/libavcodec/nvdec_vp9.c b/libavcodec/nvdec_vp9.c index 3b665a9bc7..a76bcf9943 100644 --- a/libavcodec/nvdec_vp9.c +++ b/libavcodec/nvdec_vp9.c @@ -166,7 +166,7 @@ static int nvdec_vp9_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { // VP9 uses a fixed size pool of 8 possible reference frames - return ff_nvdec_frame_params(avctx, hw_frames_ctx, 8); + return ff_nvdec_frame_params(avctx, hw_frames_ctx, 8, 0); } const AVHWAccel ff_vp9_nvdec_hwaccel = {