From patchwork Wed Sep 7 11:43:04 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: 461 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp257524vsd; Wed, 7 Sep 2016 04:43:17 -0700 (PDT) X-Received: by 10.28.170.197 with SMTP id t188mr3370406wme.42.1473248597029; Wed, 07 Sep 2016 04:43:17 -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 s9si35518877wjl.127.2016.09.07.04.43.13; Wed, 07 Sep 2016 04:43:17 -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 D63D868A0E4; Wed, 7 Sep 2016 14:43:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nm1.bullet.mail.ir2.yahoo.com (nm1.bullet.mail.ir2.yahoo.com [212.82.96.32]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B2B2D68A077 for ; Wed, 7 Sep 2016 14:42:55 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sky.com; s=s1024; t=1473248585; bh=zCtsG1T1pHWv6OWWgJYPn+qNZyYMtxy+wOmZ3R/Ayj8=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=StVojo0k96pQVs2zMwzh8j4pXl90PnkKk/OgoKxDeKllVmIl/MfYSyO0U68ijjrAyWR6TXxAw92Q7mD0r7h4Bp1htnirbapRqHvDzplUMP8ZQnuywcc6WJTVH8qIfLuPuus216qFPlS5yisskglgUA+8AwmW7YPnncJjuBB8DHk= Received: from [212.82.98.126] by nm1.bullet.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 11:43:05 -0000 Received: from [46.228.39.66] by tm19.bullet.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 11:43:04 -0000 Received: from [127.0.0.1] by smtp103.mail.ir2.yahoo.com with NNFMP; 07 Sep 2016 11:43:04 -0000 X-Yahoo-Newman-Id: 986595.493.bm@smtp103.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Sw4MCX0VM1lj5ZEi5Pl3Fx2WikGKyCYkqL31K5BHrRHjT6w Fp5OkwbJBT8uU4sPtPivrPKRTmlYjRqES2UI0EqL73TgtQhApntoSkePipIn q6NgPbFNQqLyCkN_XzD3Q11TTM.HzwtfWxeX3aDMFUeAF4xQrHmS7_6Trkjj HyIdK3rR86sg96AeUGU9r9hwk.D9a_1eUFUr6NwPZYSK_qJ0IwC9pz8KB5gd rMyH3HyJ1E0SzkuxM9JyG3oVwbU3UPkFj0oWairZDf0XW6T4L9NoBgwFm6wr vVyLoeoyu4Vjkp7rF2BAFpUXT_EzByo2vdWeTqG1UPLfEdM92j83VCXM7Qrq J1AQvX6vR8t8vrIMLl8npYNr4hIRS1oM7.HI_e0ZltyV2msHf88sponuRRzi 3twhFYOvoanQv.b5_gND93ktHY3lBW_Huup2v2PE7GF3LboEIAUZ1lpvQppC gK6XhO5H_aOfmCYYHpWZE_.dYfIqvECQfQFIIfUpEhQi3EmTCvSZxdv8te9t pVdYg3TLyDQsRkcW7F99Hguu.pVq9v3Lo57ZC82g- 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> From: "Sven C. Dack" Message-ID: Date: Wed, 7 Sep 2016 12:43:04 +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: X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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 12:27, Carl Eugen Hoyos wrote: > If your patch adds "RGBA" as supported colour space, > the encoder (by definition) announces that it supports > transparency. > nvenc does not support transparency (if it would, it would > be a - grave - bug to use "RGB0" in the patch). So please > do not add it. Done and tested. Now please explain to me what RGB0/BGR0 exactly means in FFmpeg terms. It says in the headers "0" stands for undefined. Does this mean anything can be present in the "0"-field or can one rely on the "0"-field to always contain 0x00? 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_RGB0 || 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,8 @@ 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, #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_RGB0: + ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_ABGR; + break; + + case AV_PIX_FMT_BGR0: + ctx->surfaces[idx].format = NV_ENC_BUFFER_FORMAT_ARGB; + break; + default: av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n");