From patchwork Wed Sep 7 00:23:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sven C. Dack" X-Patchwork-Id: 457 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp47331vsd; Tue, 6 Sep 2016 17:24:13 -0700 (PDT) X-Received: by 10.194.178.102 with SMTP id cx6mr38032243wjc.58.1473207853535; Tue, 06 Sep 2016 17:24:13 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 80si1417850wmy.26.2016.09.06.17.24.07; Tue, 06 Sep 2016 17:24:13 -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=@sky.com; 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 19F1468A057; Wed, 7 Sep 2016 03:23:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nm4-vm4.bullet.mail.ir2.yahoo.com (nm4-vm4.bullet.mail.ir2.yahoo.com [212.82.96.102]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CB5FC68A051 for ; Wed, 7 Sep 2016 03:23:49 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sky.com; s=s1024; t=1473207838; bh=90gQgHPN0P4V/vAYSGFOhLo9FvAlYBzvE953sfjeHcQ=; h=Subject:Reply-To:References:To:From:Date:In-Reply-To:From:Subject; b=OC1Vb3+H7NrqGkyEOjWeroUbl87y6yZhUArENA1s1zSsSAJLTk3s+0nJZ2wYGDarL6RDTiJV3RaI15aQHkm7XRC9nrPIJl2FT5ggvltAJbzEc1WoRVReK6XQwW4dMCzBkkNLqHi4QWZQ2N3mcsosvp+AxyljVoi2AtYxefW4cpg= Received: from [212.82.98.50] by nm4.bullet.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 00:23:58 -0000 Received: from [46.228.39.70] by tm3.bullet.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 00:23:58 -0000 Received: from [127.0.0.1] by smtp107.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 00:23:58 -0000 X-Yahoo-Newman-Id: 817105.69062.bm@smtp107.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: mV10nw4VM1nL_w0ePFo07lg_PC.b6eHFmpEFb94OO1OiYPG aFFn7NXrFX5b4zJGkAPSEmKITMTmrfXG6NHULHSPK6GhYnsmuxYYaExTf3rs WfQLv9Vr74RXjgMun2N7Q.yLclLayrSIkh67c7fqKjgwE10fVUt4OUVr8NCV e6nZqb7HFq_NRP1KClDp3I1Fst2bHEEI7v.JRQ8oy670FyAUK4GJYO28stD1 ctuWNfQ527TyHsbEe2iI96cjSPAWIQn9HYmelr4mTD.Om9CSnmkZrgxgeY1P fA.9lZ4S3WolRG5Y9Mef_8YqKrlx3XQX2GiAoTFqAfTGwidp7fMlmrEYt4qg dwQt49E24Ac4PjYi9jo2pSP5R1N_IKdtNY8Nonf0mP0v54lFhbtA_5.tm6K7 U7dUnxp_rm50y24wiRv.Zt2vEodJgh1AJ3sPm2.971Zw9J7PVQabPG0YNG.S Lx21qIi3X8h9c6Aa9emfSx0EgtypneTyQbZTpl_RAmMgt5O02PcBnlvhqQmq 2I2mpu7ht4PI9Ds0HMpZn03KYWw8AUB8nlUCSwkg- X-Yahoo-SMTP: vPZU.OKswBC.RMkOW9onWi6Zk8BriyC1yj0kMdBuqpLuLjitZVXhzK.Ofd5b References: <67a158c2-8043-50ab-c3f4-3bbf805deedb@sky.com> To: FFmpeg development discussions and patches From: "Sven C. Dack" Message-ID: <06309fa1-a0e9-9a79-5e87-c82a03bd16b5@sky.com> Date: Wed, 7 Sep 2016 01:23:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] adding RGBA and BGRA to nvenc.c 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 07/09/16 01:08, Sven C. Dack wrote: > On 07/09/16 00:43, Carl Eugen Hoyos wrote: >> >> Should be AV_PIX_FMT_RGB0... >> >> >> ... and AV_PIX_FMT_BGR0 > > I was wondering about that. The 0 means undefined/unused and I didn't want to > open a can of worms with it. Should I add BGR0 and RGB0, too? Does the 0 mean > it is reliably 0? Just tested it with BGR0 and RGB0 and it does encode at ~100 fp/s from the screen with it. $ ffmpeg -f x11grab -framerate 333 -s 1920x1080 -i :0.0 -c:v hevc_nvenc -b:v 4096k -y test.mkv Sven return AVERROR(EINVAL); @@ -1350,6 +1364,14 @@ static int nvenc_copy_frame(AVCodecContext *avctx, NvencSurface *inSurf, av_image_copy_plane(buf, lockBufferParams->pitch, frame->data[2], frame->linesize[2], avctx->width << 1, avctx->height); + } else if (frame->format == AV_PIX_FMT_RGBA || frame->format == AV_PIX_FMT_RGB0) { + av_image_copy_plane(buf, lockBufferParams->pitch, + frame->data[0], frame->linesize[0], + avctx->width << 2, avctx->height); + } else if (frame->format == AV_PIX_FMT_BGRA || frame->format == AV_PIX_FMT_BGR0) { + av_image_copy_plane(buf, lockBufferParams->pitch, + frame->data[0], frame->linesize[0], + avctx->width << 2, avctx->height); } else { av_log(avctx, AV_LOG_FATAL, "Invalid pixel format!\n"); return AVERROR(EINVAL); --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -81,6 +81,10 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = { AV_PIX_FMT_P010, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P16, + AV_PIX_FMT_RGB0, + AV_PIX_FMT_BGR0, + AV_PIX_FMT_RGBA, + AV_PIX_FMT_BGRA, #if CONFIG_CUDA AV_PIX_FMT_CUDA, #endif @@ -1032,6 +1036,16 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx) ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_YUV444_10BIT; break; + case AV_PIX_FMT_RGB0: + case AV_PIX_FMT_RGBA: + ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_ABGR; + break; + + case AV_PIX_FMT_BGR0: + case AV_PIX_FMT_BGRA: + ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_ARGB; + break; + default: av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n");