From patchwork Wed Feb 1 22:54:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 2406 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2662840vsb; Wed, 1 Feb 2017 14:54:38 -0800 (PST) X-Received: by 10.28.148.76 with SMTP id w73mr5079322wmd.43.1485989678085; Wed, 01 Feb 2017 14:54:38 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m84si22705776wmf.133.2017.02.01.14.54.37; Wed, 01 Feb 2017 14:54:38 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@overt.org; 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 F134A68920E; Thu, 2 Feb 2017 00:54:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-s67.mailgun.info (mail-s67.mailgun.info [184.173.153.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1C1B3680CFB for ; Thu, 2 Feb 2017 00:54:27 +0200 (EET) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1485989666; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=zogXCVBSuWDheLIlPwl8tXG1vM5z9AjpXYA5HHcvy6s=; b=nIZTZOqhSGfxCDjsw2Y2nhVfG5uT3yrU8PY7SOLhstcjqskYpT6Gg1WRzfMsPi4oXC1pwEq5 4oWVYjyxJofkYmxuW78SQbpKbIGMD7wZp1sZMbJAlX0TuPIc2s4IwgZ/f/c0W/TTMUNPQrha XsmHjJoVGazB2FIdP0tw8oYt6dU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=overt.org; s=k1; q=dns; h=Sender: From: To: Cc: Subject: Date: Message-Id: In-Reply-To: References; b=f+zZBKqlzSn5Jwo1zs3QZ6LWQ+OGh0DLiOfdPqptIZZop3YN0CMyqyiclDQd300vkp9Cio tcrRLffDKIHHOVLNk6mCHY/80gJr8wLSip09tnBWTpuHdrIufqTelHXDsaCeEE8EY/m/wacO DXp1NwThuz0keOhvjCpccSDNZ9c68= X-Mailgun-Sending-Ip: 184.173.153.195 X-Mailgun-Sid: WyIyM2Q3MCIsICJmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZyIsICI0YTg5NjEiXQ== Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com [107.178.208.155]) by mxa.mailgun.org with ESMTP id 58926721.7fd5b45a1dc0-smtp-out-n01; Wed, 01 Feb 2017 22:54:25 -0000 (UTC) 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 2947663BDC; Wed, 1 Feb 2017 22:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1485989665; bh=5fXSbY97TCOzd008Gq/E+8wiWkgyzBUs1sdfai33/8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t7jTaz9ZyAPcfZKt9QJnWCj2BnvATDQU5cSinWIghxPUlZwehynKv3slL/Onwv5lQ 6QnZnRjcO/d8LoQc8Z6FjgGsTBDPzln5KC+0rU9xJTcL4bw+HOCiA7k4ve5qF43yZq ZkbcGR2WNy34VAFe0hfqPl8x3EPy8yi2ptGNvr9q1d/boZ3Q7EbFSMoQPtYJOlaCld St9XFKoVl/gCeATz3QIcImReTHN2nNxXkzoQbJNDi9GxM/17C0VhxBQWQWjDpC0eLd Z9YFvfPfviZpbbBdDYJDPan1o2upFoytrbEyYI1Ct1FkfGTEKdWtI/yqxv46APPY2c sVQr//FKmp7RQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Feb 2017 14:54:18 -0800 Message-Id: <20170201225419.32405-2-philipl@overt.org> In-Reply-To: <20170201225419.32405-1-philipl@overt.org> References: <20170201225419.32405-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 1/2] avutil: Add MSB packed YUV444P10 format 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" nvenc supports a YUV444P10 format with the same bit layout as P010, with the data bits at the MSB end. Unfortunately, the current YUV444P10 format we have defined puts the data bits at the LSB end. This mismatch led to us introducing a fudge in nvenc where we mapped their 444P10 format to the ffmpeg 444P16 format. This ensured that the data ends up in the right place if you are starting with 10bit content, but it leads to other problems. Specifically: * >10bit content will be preferrentially converted to 444P16 to pass to nvenc to 'preserve' the additional bits. However, they aren't actually preserved, but are discarded, so we're worse off because no dithering took place in swscale. * On top of that, the input data is almost certainly 4:2:0 and so the conversion to 4:4:4 is pointless, while also leading to an output file that's incompatible with many playback scenarios (no hardware decoder supports 4:4:4 content). So, for the sake of accuracy, introduce an explicit pixfmt for this situation. There's no conversion support because you'll basically never have a use for it. If someone ever finds one, they can write the swscale code. In the mean time, common 12 bit content (YUV420P12 or P016) will be correctly converted to P010 for nvenc. Signed-off-by: Philip Langdale --- libavutil/pixdesc.c | 24 ++++++++++++++++++++++++ libavutil/pixfmt.h | 5 +++++ libavutil/version.h | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 3b9c45d..fe9b59d 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -1565,6 +1565,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, + [AV_PIX_FMT_YUV444P10MSBLE] = { + .name = "yuv444p10msble", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10, 1, 9, 1 }, /* Y */ + { 1, 2, 0, 6, 10, 1, 9, 1 }, /* U */ + { 2, 2, 0, 6, 10, 1, 9, 1 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_YUV444P10MSBBE] = { + .name = "yuv444p10msbbe", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10, 1, 9, 1 }, /* Y */ + { 1, 2, 0, 6, 10, 1, 9, 1 }, /* U */ + { 2, 2, 0, 6, 10, 1, 9, 1 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, + }, [AV_PIX_FMT_YUV444P9LE] = { .name = "yuv444p9le", .nb_components = 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index dfb1b11..46bf9c0 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -314,6 +314,9 @@ enum AVPixelFormat { AV_PIX_FMT_P016LE, ///< like NV12, with 16bpp per component, little-endian AV_PIX_FMT_P016BE, ///< like NV12, with 16bpp per component, big-endian + AV_PIX_FMT_YUV444P10MSBLE, /// like YUV444P10 but with data in the high bits, zeros in the low bits, little-endian + AV_PIX_FMT_YUV444P10MSBBE, /// like YUV444P10 but with data in the high bits, zeros in the low bits, big-endian + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -394,6 +397,8 @@ enum AVPixelFormat { #define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE) #define AV_PIX_FMT_P016 AV_PIX_FMT_NE(P016BE, P016LE) +#define AV_PIX_FMT_YUV444P10MSB AV_PIX_FMT_NE(YUV444P10MSBBE, YUV444P10MSBLE) + /** * Chromaticity coordinates of the source primaries. */ diff --git a/libavutil/version.h b/libavutil/version.h index 8866064..a8b00bf 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 46 +#define LIBAVUTIL_VERSION_MINOR 47 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \