From patchwork Sun Oct 7 17:50:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 10598 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:ab0:73d2:0:0:0:0:0 with SMTP id m18csp2761849uaq; Sun, 7 Oct 2018 10:52:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UuhzcmEnQvPFOmtA51paEWC4ydnuvCVsg1JCoXdUrDT08baYiO7nKSNTnrbNav2tF5CZ9 X-Received: by 2002:adf:93e6:: with SMTP id 93-v6mr14040408wrp.81.1538934723542; Sun, 07 Oct 2018 10:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538934723; cv=none; d=google.com; s=arc-20160816; b=JWJXi4V9OBEPXDcacCqlRu1DeW+xLzHxcChiilLmPCIJw4YvrxAlzLy49rje1WXYPU qT6hYWEpc6ELB7Tk8oKaXZZhJ3HDjCAI/O/iVy4h/X7ii5DbFFsvZvB1fohn3INn7weP 9L1ix3rY2JvyYs+EImp2/4JQ0DBfccSJsz4W7Qsi1KTYhrs74/9k9P3Q/K6hu8KV/ofm Xw08QmJjzQmOwe33KFW1rFDpFJ335K5Vp2Sc7clsCjh5N8e1kOQJumPVgvAQVn6BmEDJ db8kaq1r7KS6OnfhSDhWbzCGNOMOISqellMIP3M4/cKQ0NHG2Xp8+JdTKtGtACQn/Eev PfgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=HTzF8anyC3JDNZ0cmB0Mpjmy9YSHwu+s7W5AtiNj5Og=; b=O83PQr29xie6ljzCQaN9ug/AZcKFU+tHSQyMyoUiND/ea8m1BTeA7jtawgTT7VyYgG QVC4tCcGFxQto+q+wXfK8/9Ky2gO6UtjioTRhT2ChtRfalf5tjRgy3CWuKvOFXX1BnGP SlO3J7Psxq/r83DBno1y1XPvJFk0InUJNi2ENUCslxoiRISwASzougltu10WWUsf251o fZS68e0iZx2ZlTMlcHFVMzZ41844mAsC6wjQdHtYaiE2djWGeo+neFUx3drdHsTg6Fg3 lQVfAT6Tsbeznz7c1ogbdGDVfd1Vj/hNYZ5YZ3MXzaJwxoh4gMvH45nIbDStJfmLHnaj LHjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=rCuzhJSe; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h64-v6si6164772wmf.40.2018.10.07.10.52.03; Sun, 07 Oct 2018 10:52:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=rCuzhJSe; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C01968A129; Sun, 7 Oct 2018 20:51:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vk1-f226.google.com (mail-vk1-f226.google.com [209.85.221.226]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4C31D689E21 for ; Sun, 7 Oct 2018 20:51:07 +0300 (EEST) Received: by mail-vk1-f226.google.com with SMTP id n71-v6so3108204vke.2 for ; Sun, 07 Oct 2018 10:51:28 -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; bh=zfJNKdrnhj+cbaqfjXiWvk2WJpybS+kbNp4Dzzw2fTQ=; b=gfVhtiy5C4sMW3QK4VZeAQA84wzRF+4mMAJLu21FT/N1VB0197jF888Nw4b7ouH4xi zy//ffLPP3CeE+7+P/lKSAtCueZBQjAGK8j/5WKXZf6stEwRqV50Dmd6SXy0mCOJFN0/ luYxP5OwNxua3ljjVhRL8z35w5gXDYgBGeqnTJDF1S/DsGVrFEqMOpZb9YvFzniMcKi7 8X3C+UOP4iLHgLLiA3obgZ7TCOBc8p6xNAHd4J8OVJtaBpBpEdrQzZPdq44xnMqJGoze AuuFitV8c5i7wiVGupZcGZTuz3k7hiwrcBwZO540sYwVF0NzCA7CgTcDpsiCjH8TnBVl JumQ== X-Gm-Message-State: ABuFfoh4GyKq2CElciYYr7c+FX0UMx+0/WFltHH5n1FS1mhkgKRs3k8F wpt8ln+yAKNXNXUOIhV2LKzY+yJxaceR2jv2fa2gJkdvvzsndg== X-Received: by 2002:a1f:588:: with SMTP id 130-v6mr7515049vkf.49.1538934687466; Sun, 07 Oct 2018 10:51:27 -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 x136-v6sm1395543vkx.11.2018.10.07.10.51.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Oct 2018 10:51: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 73FB960189; Sun, 7 Oct 2018 17:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1538934686; bh=k/z1oC+Kn33TjYZ9RBQKiw7hjlXF8W69fz3yMyfBu6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCuzhJSeFnsapQxcY55P45uZMM8BvE3/6jhCZFp9nvx/1C8bxM2tl1ud4iM3k1lsU +JbxLiMdGP/yXz9OHtHckbPSt45oyjdTYZchtyz0loZ4z5wld8UcpuJdMAiTRZ+jwf jGNESVLvgCRvNgyMJ7cDb5+5QrMNzyJIKeEECmshBFIW2cdSvHzkFhhJ6DAQi0+IWu ppjhtwVt2saAMbUCOwWEyS1p4hzNAD9SPbMamoAEIXFauyppPjQn8JnSNazBqITGd9 I26DXGYRsrOjNjJoHHMSL09zZskhmgeuV4lYn/pHgE9gLD0aJWE9Gva38Bf+oV6jLe 4bcC92vwNEiEQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org, Timo Rothenpieler Date: Sun, 7 Oct 2018 10:50:55 -0700 Message-Id: <20181007175057.31070-4-philipl@overt.org> In-Reply-To: <20181007175057.31070-1-philipl@overt.org> References: <20181007175057.31070-1-philipl@overt.org> 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 MIME-Version: 1.0 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 e1ac06f852..4d1f55b49a 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 = {