From patchwork Thu Dec 29 21:02:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Miroslav_Sluge=C5=88?= X-Patchwork-Id: 1986 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2577431vsb; Thu, 29 Dec 2016 13:02:35 -0800 (PST) X-Received: by 10.194.142.243 with SMTP id rz19mr37259333wjb.132.1483045355150; Thu, 29 Dec 2016 13:02:35 -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 g10si32774780wjx.7.2016.12.29.13.02.34; Thu, 29 Dec 2016 13:02:35 -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=@email.cz; dkim=neutral (body hash did not verify) header.i=@email.cz; 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; dmarc=fail (p=NONE dis=NONE) header.from=email.cz Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 381A5689BBD; Thu, 29 Dec 2016 23:02:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mxh2.seznam.cz (mxh2.seznam.cz [77.75.76.26]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A425868981B for ; Thu, 29 Dec 2016 23:02:21 +0200 (EET) Received: from email.seznam.cz by email-smtpc7b.ng.seznam.cz (email-smtpc7b.ng.seznam.cz [10.23.13.195]) id 6a1a3bba5ecd23a66a8812b7; Thu, 29 Dec 2016 22:02:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.cz; s=beta; t=1483045344; bh=dyPtK20obg3UoS6wLOJQMUj6b5BXFVUmae9/H4rAaPI=; h=DKIM-Signature:Received:From:Subject:To:Message-ID:Date: User-Agent:MIME-Version:Content-Type; b=edmNuuxF+ItVBbHNuA/3LJmxcf0le9SAU4MVA2t8Dg83aKuR/3Tw3tgD1jwqncWPR t7+2ZHU13oUOdewNHHoctTkt+nD37mwFZV9nqRFAGUAV8qWlvtry0X9J2ib4h5YqM/ 2Db70yTfbU15K6h902Djq+xJChw/Co1RYYS6fQtk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.cz; s=beta; t=1483045344; bh=dyPtK20obg3UoS6wLOJQMUj6b5BXFVUmae9/H4rAaPI=; h=Received:From:Subject:To:Message-ID:Date:User-Agent:MIME-Version: Content-Type; b=jAEvjvJMFh7ammCdSwTj3820cIpgJJtWQdBfGroxNFh31Pgsm3hO6rK9zpIyMxUHq o5/mDxuI2D9vOkn67cxWteGxTWuXjk0v7hkQqdsil4OdrCR3Zt97sQVQnVNd7/vQsj b5nSW8EUZye0N2gH9LtwkXSgX+kAkG7jlSgwEtXg= Received: from [192.168.0.6] (ip-94-113-140-7.net.upcbroadband.cz [94.113.140.7]) by email-relay9.ng.seznam.cz (Seznam SMTPD 1.3.41) with ESMTP; Thu, 29 Dec 2016 22:02:23 +0100 (CET) From: =?UTF-8?Q?Miroslav_Sluge=c5=88?= To: ffmpeg-devel@ffmpeg.org Message-ID: <586579DE.2090909@email.cz> Date: Thu, 29 Dec 2016 22:02:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc 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" Somebody changed AUD to active in NVENC by default, which is not very clever, libx264 also has this future disabled, so we should stay in sync with libx264 behavior. Enabled AUD will work only without B-frames. There is BUG in Nvidia NVENC when you use AUD for H264 with B-frames, it will return corrupted stream, because NVIDIA is inserting AUD type 0 (I-frame) before B-frames instead of AUD type 7 (any-frame). H264 encoded with B-frames and AUD active will not play for example on Panasonic TX-AS640E, other decoders just ignore wrong AUD type. From 8205523dfa477eaaeda3e10d59a42e024dafbfdb Mon Sep 17 00:00:00 2001 From: Miroslav Slugen Date: Thu, 29 Dec 2016 21:50:13 +0100 Subject: [PATCH 1/1] NVENC: Make AUD optional --- libavcodec/nvenc.c | 4 ++-- libavcodec/nvenc.h | 1 + libavcodec/nvenc_h264.c | 1 + libavcodec/nvenc_hevc.c | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index f64fd8a..d57a90c 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -756,7 +756,7 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) h264->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; h264->repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; - h264->outputAUD = 1; + h264->outputAUD = (ctx->aud == 1) ? 1 : 0; if (avctx->refs >= 0) { /* 0 means "let the hardware decide" */ @@ -840,7 +840,7 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) hevc->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; hevc->repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; - hevc->outputAUD = 1; + hevc->outputAUD = (ctx->aud == 1) ? 1 : 0; if (avctx->refs >= 0) { /* 0 means "let the hardware decide" */ diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 5bc0cba..c435e05 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -153,6 +153,7 @@ typedef struct NvencContext int strict_gop; int aq_strength; int quality; + int aud; } NvencContext; int ff_nvenc_encode_init(AVCodecContext *avctx); diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index 71e27fd..cae27aa 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -107,6 +107,7 @@ static const AVOption options[] = { OFFSET(aq_strength), AV_OPT_TYPE_INT, { .i64 = 8 }, 1, 15, VE }, { "cq", "Set target quality level (0 to 51, 0 means automatic) for constant quality mode in VBR rate control", OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE }, + { "aud", "Use access unit delimiters", OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { NULL } }; diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index ef739b6..e44ca7e 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -104,6 +104,7 @@ static const AVOption options[] = { OFFSET(aq_strength), AV_OPT_TYPE_INT, { .i64 = 8 }, 1, 15, VE }, { "cq", "Set target quality level (0 to 51, 0 means automatic) for constant quality mode in VBR rate control", OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE }, + { "aud", "Use access unit delimiters", OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { NULL } }; -- 2.1.4