From patchwork Wed Sep 7 14:01:24 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: 463 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp319241vsd; Wed, 7 Sep 2016 07:01:42 -0700 (PDT) X-Received: by 10.194.95.36 with SMTP id dh4mr15642411wjb.156.1473256902692; Wed, 07 Sep 2016 07:01:42 -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 k9si6458248wjx.225.2016.09.07.07.01.34; Wed, 07 Sep 2016 07:01:42 -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 DB91A68A127; Wed, 7 Sep 2016 17:01:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nm13-vm4.bullet.mail.ir2.yahoo.com (nm13-vm4.bullet.mail.ir2.yahoo.com [212.82.96.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F80868A114 for ; Wed, 7 Sep 2016 17:01:16 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sky.com; s=s1024; t=1473256885; bh=PCGUNVFVl0u6HhzEu9Vi07YxUGuOtq3gu0vpO46dZJA=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=BRlyvs9JcJ1qoy7aB3CN9wi1gIR9qP2a7Ht8aKVkevDZ4ioqDHV5W4oKkxPhYqCywfnQnb25QNOI259HMPt3psRRuTOjeiJTA+JTAAQJrdrKcIhJruMyXW81pSCuIsWOYSkLjVSxYJd6XGJ0z+ioEd9PByWVQys7ttC/O+mqbtE= Received: from [212.82.98.126] by nm13.bullet.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 14:01:25 -0000 Received: from [46.228.39.90] by tm19.bullet.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 14:01:25 -0000 Received: from [127.0.0.1] by smtp127.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 14:01:25 -0000 X-Yahoo-Newman-Id: 427574.42985.bm@smtp127.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: tJspAcMVM1nQAFlvZiYVvTicKpV87o58bxb6b1S7qkkHmm7 V.p6kYnTsEyxwVUcv4LNNRwQS2bjVdLTyhTTBY.vXxy_H.WilS1R1pQYzAIE Szq8P3aNhcq0h_aS7bRyXQX9.IGpebto7xFtvgfdUjlXxnKxNyR20eUNX1O7 aZ0Oew6tltl5Sxk4_RZFxkpvWH0zBhcGJhIHg.Vfcx2.bBmonqrrZBHgf1n8 xeDNNB_xPSagoC2Q_0zZYEgIM69TRMjwVc9971cCQPa8p7v7UFdY7g._anUk bwzWTPf_jwvQw72RFw7DZ2X3C5190PyFjjaNnXyjLSCG5PiKhn1qXyxEIN.b fd2lRKvdpc6mOefbEOmB7_NuGwX40B.vgfpP6IBi18dv1DzLkZCwRxoscXvp wUMgijyjQPEt0OwoMzPzIFRJSpU8fvfrVW3904Jkme52n180dACdqXliFLHQ 8IJyYdUTMLr2NNFhijMOL_RVm02QPXO8SQOGCHzsnqeMwXxdHPQ17a0doh5U bmPCz3.z.1Y3qj_yN5mK2lkYGIrEWUO2mYxv0q9U- X-Yahoo-SMTP: vPZU.OKswBC.RMkOW9onWi6Zk8BriyC1yj0kMdBuqpLuLjitZVXhzK.Ofd5b To: FFmpeg development discussions and patches References: <67a158c2-8043-50ab-c3f4-3bbf805deedb@sky.com> <06309fa1-a0e9-9a79-5e87-c82a03bd16b5@sky.com> <89d3ee6c-8a30-ade8-4b16-efd06178f6ca@rothenpieler.org> <294eb876-6b24-718e-be41-10e43d03e475@sky.com> <8962542C-7A12-464B-90E8-88DCC845EBC1@gmail.com> <09abd4f5-7259-0901-6c64-e5fb9a8db2cf@sky.com> <2c366865-734c-298c-5af2-0745c68c6973@rothenpieler.org> <1c24bc26-cc94-4a39-187f-830583ea721e@sky.com> From: "Sven C. Dack" Message-ID: Date: Wed, 7 Sep 2016 15:01:24 +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 14:33, Timo Rothenpieler wrote: > 0RGB/0BGR does not mean the alpha bits are zeroed. > It means they are undefined, so you convert from ARGB to 0RGB by doing > nothing. There is no performance to gain by supporting a format that > falsely advertises support for an alpha channel. > > Also, the correct formats to use are AV_PIX_FMT_0RGB32, which > corresponds to NV_ENC_BUFFER_FORMAT_ARGB, and AV_PIX_FMT_0BGR32 for ABGR. Thanks for finally explaining it. I also tested it with 0RGB32 and it does work with those, too. Sven return AVERROR(EINVAL); @@ -1350,6 +1360,10 @@ 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_0RGB32 || frame->format == AV_PIX_FMT_0BGR32) { + 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,8 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = { AV_PIX_FMT_P010, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P16, + AV_PIX_FMT_0RGB32, + AV_PIX_FMT_0BGR32, #if CONFIG_CUDA AV_PIX_FMT_CUDA, #endif @@ -1032,6 +1034,14 @@ 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_0RGB32: + ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_ABGR; + break; + + case AV_PIX_FMT_0BGR32: + ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_ARGB; + break; + default: av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n");