diff mbox

[FFmpeg-devel] lavc/hevcdec: Treat clean random access nals as keyframes for -skip_frame

Message ID CAB0OVGo_UgrWFFEAiRaU=8ZJpU1QC23Yfmfo0Kq_nMjjeoQ3Bw@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos May 24, 2018, 4:57 p.m. UTC
Hi!

Attached patch fixes ticket #7227 here, -skip_frame nokey shows no
warnings on decoding with this change and still decodes less frames
than -skip_frame nointra (which shows many warnings).

Please comment, Carl Eugen

Comments

Mark Thompson May 26, 2018, 4:38 p.m. UTC | #1
On 24/05/18 17:57, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #7227 here, -skip_frame nokey shows no
> warnings on decoding with this change and still decodes less frames
> than -skip_frame nointra (which shows many warnings).
> 
> Please comment, Carl Eugen
> 
> 
> From ea5cf5aab2a9360971f5291fce19e5daae833de0 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Thu, 24 May 2018 18:53:16 +0200
> Subject: [PATCH] lavc/hevcdec: Treat clean random access nals as keyframes
>  for -skip_frame.
> 
> Fixes ticket #7227.
> ---
>  libavcodec/hevcdec.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> index c887762..dd7675a 100644
> --- a/libavcodec/hevcdec.c
> +++ b/libavcodec/hevcdec.c
> @@ -2919,7 +2919,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
>          if (
>              (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) ||
>              (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != HEVC_SLICE_I) ||
> -            (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s))) {
> +            (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT)) {

I think "!IS_IRAP(s)" would be simpler and perhaps more consistent?  (Compared to what you have here it adds BLA NAL units as well, which will be equivalent to CRA for this purpose.)

>              break;
>          }
>  
> -- 
> 1.7.10.4
> 

Should be fine with or without that change.

Thanks,

- Mark
Carl Eugen Hoyos May 27, 2018, 8:53 p.m. UTC | #2
2018-05-26 18:38 GMT+02:00, Mark Thompson <sw@jkqxz.net>:
> On 24/05/18 17:57, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes ticket #7227 here, -skip_frame nokey shows no
>> warnings on decoding with this change and still decodes less frames
>> than -skip_frame nointra (which shows many warnings).
>>
>> Please comment, Carl Eugen
>>
>>
>> From ea5cf5aab2a9360971f5291fce19e5daae833de0 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Thu, 24 May 2018 18:53:16 +0200
>> Subject: [PATCH] lavc/hevcdec: Treat clean random access nals as keyframes
>>  for -skip_frame.
>>
>> Fixes ticket #7227.
>> ---
>>  libavcodec/hevcdec.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
>> index c887762..dd7675a 100644
>> --- a/libavcodec/hevcdec.c
>> +++ b/libavcodec/hevcdec.c
>> @@ -2919,7 +2919,7 @@ static int decode_nal_unit(HEVCContext *s, const
>> H2645NAL *nal)
>>          if (
>>              (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type
>> == HEVC_SLICE_B) ||
>>              (s->avctx->skip_frame >= AVDISCARD_NONINTRA &&
>> s->sh.slice_type != HEVC_SLICE_I) ||
>> -            (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s))) {
>> +            (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s) &&
>> s->nal_unit_type != HEVC_NAL_CRA_NUT)) {
>
> I think "!IS_IRAP(s)" would be simpler and perhaps more consistent?
> (Compared to what you have here it adds BLA NAL units as well,
> which will be equivalent to CRA for this purpose.)

Patch applied with this change.

Thank you, Carl Eugen
diff mbox

Patch

From ea5cf5aab2a9360971f5291fce19e5daae833de0 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 24 May 2018 18:53:16 +0200
Subject: [PATCH] lavc/hevcdec: Treat clean random access nals as keyframes
 for -skip_frame.

Fixes ticket #7227.
---
 libavcodec/hevcdec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index c887762..dd7675a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2919,7 +2919,7 @@  static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
         if (
             (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) ||
             (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != HEVC_SLICE_I) ||
-            (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s))) {
+            (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT)) {
             break;
         }
 
-- 
1.7.10.4