Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2017-06-15 Thread Yogender Kumar Gupta
Yes, please try the latest driver version.

Thanks
Yogender

> On 13-Jun-2017, at 6:47 PM, Ali KIZIL  wrote:
> 
> 2017-01-05 13:29 GMT+03:00 Yogender Gupta :
> 
 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).
>> 
>> Thanks for bringing this to notice. We have added a fix in the Nvidia
>> driver and the newer driver releases will insert the correct AUD type.
>> 
>> Thanks,
>> Yogender
>> 
>> 
>> ---
>> This email message is for the sole use of the intended recipient(s) and
>> may contain
>> confidential information.  Any unauthorized review, use, disclosure or
>> distribution
>> is prohibited.  If you are not the intended recipient, please contact the
>> sender by
>> reply email and destroy all copies of the original message.
>> 
>> ---
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
> 
> Yogender, is new driver released for correct AUD type insertion ?
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2017-06-13 Thread Ali KIZIL
2017-01-05 13:29 GMT+03:00 Yogender Gupta :

> >> 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).
>
> Thanks for bringing this to notice. We have added a fix in the Nvidia
> driver and the newer driver releases will insert the correct AUD type.
>
> Thanks,
> Yogender
>
> 
> ---
> This email message is for the sole use of the intended recipient(s) and
> may contain
> confidential information.  Any unauthorized review, use, disclosure or
> distribution
> is prohibited.  If you are not the intended recipient, please contact the
> sender by
> reply email and destroy all copies of the original message.
> 
> ---
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Yogender, is new driver released for correct AUD type insertion ?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2017-01-05 Thread Yogender Gupta
>> 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).

Thanks for bringing this to notice. We have added a fix in the Nvidia driver 
and the newer driver releases will insert the correct AUD type.

Thanks,
Yogender

---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2017-01-01 Thread Miroslav Slugeň

Dne 1.1.2017 v 14:57 Kieran Kunhya napsal(a):

Resending with requested modifications and basic implementation of
bluray_compat function which enables AUD.



-


This is a misleading option name because Blu-ray compatibility is a lot
more than what you implement. There are lots of rules I implemented in x264
years ago.

Kieran
Yes, it is not yet fully completed, it will require much more changes 
and tests of encoded samples. But i think it is good start... Maybe we 
could print some warnings about using this function for now.




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



--
Miroslav Slugeň
+420 724 825 885

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2017-01-01 Thread Kieran Kunhya
>
> Resending with requested modifications and basic implementation of
> bluray_compat function which enables AUD.
>
>
>
> -
>

This is a misleading option name because Blu-ray compatibility is a lot
more than what you implement. There are lots of rules I implemented in x264
years ago.

Kieran

>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2017-01-01 Thread Timo Rothenpieler
Sounds and looks fine to me.
I agree that having AUD enabled by default wasn't the best solution, as
it's useless overhead for most cases.

both applied
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Miroslav Slugeň

Dne 30.12.2016 v 17:38 Mark Thompson napsal(a):

On 30/12/16 16:12, Miroslav Slugeň wrote:

Dne 30.12.2016 v 15:32 Mark Thompson napsal(a):

On 29/12/16 21:02, Miroslav Slugeň wrote:

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;

Just write ctx->aud, no need for the conditional.

I understand, but in our implementation we reserved -1 for autodetection which could 
be done later based on other parameters of encoder. Should i then rewrite it to: 
h264->outputAUD = ctx->aud; now, until autodetection is complete?

I don't mind; if it makes a following patch look simpler then sure, leave it.

I'm curious how this autodetection can work, though.  In general you prefer never to have 
AUD enabled unless required (to avoid issues like your own problem this is fixing, and 
because it is just redundant padding which increases the size of the stream to no gain), 
so the cases where you want it enabled are going to be where it is an absolute 
requirement anyway (such as bluray), hence I see no meaningful "auto" case.


 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;

Similarly here.


 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


LGTM otherwise.

Thanks,

- Mark

Thanks :)


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Resending with 

Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Mark Thompson
On 30/12/16 16:12, Miroslav Slugeň wrote:
> Dne 30.12.2016 v 15:32 Mark Thompson napsal(a):
>> On 29/12/16 21:02, Miroslav Slugeň wrote:
>>> 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;
>> Just write ctx->aud, no need for the conditional.
> 
> I understand, but in our implementation we reserved -1 for autodetection 
> which could be done later based on other parameters of encoder. Should i then 
> rewrite it to: h264->outputAUD = ctx->aud; now, until autodetection is 
> complete?

I don't mind; if it makes a following patch look simpler then sure, leave it.

I'm curious how this autodetection can work, though.  In general you prefer 
never to have AUD enabled unless required (to avoid issues like your own 
problem this is fixing, and because it is just redundant padding which 
increases the size of the stream to no gain), so the cases where you want it 
enabled are going to be where it is an absolute requirement anyway (such as 
bluray), hence I see no meaningful "auto" case.

>>> 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;
>> Similarly here.
>>
>>> 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),   
>>>

Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Miroslav Slugeň

Dne 30.12.2016 v 15:32 Mark Thompson napsal(a):

On 29/12/16 21:02, Miroslav Slugeň wrote:

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;

Just write ctx->aud, no need for the conditional.


I understand, but in our implementation we reserved -1 for autodetection 
which could be done later based on other parameters of encoder. Should i 
then rewrite it to: h264->outputAUD = ctx->aud; now, until autodetection 
is complete?


  
  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;

Similarly here.

  
  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


LGTM otherwise.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Thanks :)

--
Miroslav Slugeň
+420 724 825 885

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Mark Thompson
On 29/12/16 21:02, Miroslav Slugeň wrote:
> 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;

Just write ctx->aud, no need for the conditional.

>  
>  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;

Similarly here.

>  
>  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
> 

LGTM otherwise.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Mark Thompson
On 30/12/16 11:00, Ali KIZIL wrote:
> 2016-12-30 12:07 GMT+03:00 Miroslav Slugeň :
> 
>> Dne 30.12.2016 v 05:48 Ali KIZIL napsal(a):
>>
>>> 2016-12-30 0:02 GMT+03:00 Miroslav Slugeň :
>>>
>>>
>>> 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.


 --
 Miroslav Slugeň


 AUD set to active by default was for LG and Sony like UHD TVs which could
>>> not decode NVENC encoded HEVC MPEGTS properly.
>>> If patch sets AUD active by default if there is no B-Frames (as so in
>>> NVENC
>>> HEVC encoding), patch will be ok in common.
>>>
>>> I checked how libx264 and libx265 works
>>
>> For libx265 default is off:
>>
>> void x265_param_default(x265_param* param) {
>> param->bEnableAccessUnitDelimiters = 0;
>> }
>>
>> Only for UHD BLURAY is on:
>>
>> if (p->uhdBluray) {
>> p->bEnableAccessUnitDelimiters = 1;
>> }
>>
>> For libx264 default is off:
>>
>> void x264_param_default( x264_param_t *param ) {
>> param->b_aud = 0;
>> }
>>
>> Only for BLURAY and AVC-Intra compat
>>
>> if( h->param.b_bluray_compat ) {
>> h->param.b_aud = 1;
>> }
>>
>> /* 200,100,50 */
>> if( h->param.i_avcintra_class ) {
>> h->param.b_aud = 1;
>> }
>>
>> So how we should implement this to NVENC? :)
>>
>> I still think we should default AUD to off and set in on only in special
>> cases like BLURAY and AVC-Intra.
>>
> 
> From my opinion, we can set AUD on by default for HEVC as there is no
> B-Frames. When AUD is on at HEVC, I checked many TVs (Samsung, LG, Sony,
> Philips etc.) all look OK.
> It will be better to hear comments from others as well.

Wouldn't that then revisit the same problem with some future implementation 
which adds support for B frames in H.265?  (I assume that's an implementation 
omission, not an API one.)

To my mind AUDs are a niche feature which should not be enabled by default 
unless specifically requested (hence the code in x26[45] enabling it only for 
bluray encodes, which do require them).  If some broken decoders are unable to 
function without them that is unfortunate, but not really ffmpeg's problem (and 
the workaround is known for anyone encountering it).

Therefore, I agree with the original patch.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Ali KIZIL
2016-12-30 12:07 GMT+03:00 Miroslav Slugeň :

> Dne 30.12.2016 v 05:48 Ali KIZIL napsal(a):
>
>> 2016-12-30 0:02 GMT+03:00 Miroslav Slugeň :
>>
>>
>> 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.
>>>
>>>
>>> --
>>> Miroslav Slugeň
>>>
>>>
>>> AUD set to active by default was for LG and Sony like UHD TVs which could
>> not decode NVENC encoded HEVC MPEGTS properly.
>> If patch sets AUD active by default if there is no B-Frames (as so in
>> NVENC
>> HEVC encoding), patch will be ok in common.
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> I checked how libx264 and libx265 works
>
> For libx265 default is off:
>
> void x265_param_default(x265_param* param) {
> param->bEnableAccessUnitDelimiters = 0;
> }
>
> Only for UHD BLURAY is on:
>
> if (p->uhdBluray) {
> p->bEnableAccessUnitDelimiters = 1;
> }
>
> For libx264 default is off:
>
> void x264_param_default( x264_param_t *param ) {
> param->b_aud = 0;
> }
>
> Only for BLURAY and AVC-Intra compat
>
> if( h->param.b_bluray_compat ) {
> h->param.b_aud = 1;
> }
>
> /* 200,100,50 */
> if( h->param.i_avcintra_class ) {
> h->param.b_aud = 1;
> }
>
> So how we should implement this to NVENC? :)
>
> I still think we should default AUD to off and set in on only in special
> cases like BLURAY and AVC-Intra.
>
>
> --
> Miroslav Slugeň
> +420 724 825 885
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

From my opinion, we can set AUD on by default for HEVC as there is no
B-Frames. When AUD is on at HEVC, I checked many TVs (Samsung, LG, Sony,
Philips etc.) all look OK.
It will be better to hear comments from others as well.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Miroslav Slugeň

Dne 30.12.2016 v 05:48 Ali KIZIL napsal(a):

2016-12-30 0:02 GMT+03:00 Miroslav Slugeň :


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.


--
Miroslav Slugeň



AUD set to active by default was for LG and Sony like UHD TVs which could
not decode NVENC encoded HEVC MPEGTS properly.
If patch sets AUD active by default if there is no B-Frames (as so in NVENC
HEVC encoding), patch will be ok in common.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


I checked how libx264 and libx265 works

For libx265 default is off:

void x265_param_default(x265_param* param) {
param->bEnableAccessUnitDelimiters = 0;
}

Only for UHD BLURAY is on:

if (p->uhdBluray) {
p->bEnableAccessUnitDelimiters = 1;
}

For libx264 default is off:

void x264_param_default( x264_param_t *param ) {
param->b_aud = 0;
}

Only for BLURAY and AVC-Intra compat

if( h->param.b_bluray_compat ) {
h->param.b_aud = 1;
}

/* 200,100,50 */
if( h->param.i_avcintra_class ) {
h->param.b_aud = 1;
}

So how we should implement this to NVENC? :)

I still think we should default AUD to off and set in on only in special 
cases like BLURAY and AVC-Intra.


--
Miroslav Slugeň
+420 724 825 885

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-30 Thread Miroslav Slugeň

Dne 30.12.2016 v 05:48 Ali KIZIL napsal(a):

2016-12-30 0:02 GMT+03:00 Miroslav Slugeň :


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.


--
Miroslav Slugeň



AUD set to active by default was for LG and Sony like UHD TVs which could
not decode NVENC encoded HEVC MPEGTS properly.
If patch sets AUD active by default if there is no B-Frames (as so in NVENC
HEVC encoding), patch will be ok in common.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


I know that it was for LG tvs (i hav seen original enabling patch), and 
what about to enable AUD only for HEVC which doesn't have any B-frames 
in NVENC?


Because I think that we should always stay in sync between h264_nvenc 
and libx264 parameters.


--
Miroslav Slugeň
+420 724 825 885

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2016-12-29 Thread Ali KIZIL
2016-12-30 0:02 GMT+03:00 Miroslav Slugeň :

> 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.
>
>
> --
> Miroslav Slugeň
>
>
AUD set to active by default was for LG and Sony like UHD TVs which could
not decode NVENC encoded HEVC MPEGTS properly.
If patch sets AUD active by default if there is no B-Frames (as so in NVENC
HEVC encoding), patch will be ok in common.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel