[FFmpeg-devel,v2] libavcodec/hevc_filter: support for all skip_loop_filter levels

Submitted by Stefan _ on Dec. 3, 2017, 7:58 p.m.

Details

Message ID DB3PR0202MB34520A86048E760A95D268B1EC3F0@DB3PR0202MB3452.eurprd02.prod.outlook.com
State New
Headers show

Commit Message

Stefan _ Dec. 3, 2017, 7:58 p.m.
On 01.12.2017 at 17:45 Michael Niedermayer wrote:
> AVDISCARD_NONREF is about frames which are not referenced by any other

> doesnt ff_hevc_frame_nb_refs() produce the number of references curently

> aka the other end of the reference arrows ?


Yes, that sounds right.

I've revised the patch to check for *_N NAL unit types instead (which 
should be equivalent to H.264's nal_idc == 0) and to skip not only 
deblock, but also SAO.

Comments

Michael Niedermayer Dec. 4, 2017, 5:49 p.m.
On Sun, Dec 03, 2017 at 07:58:18PM +0000, Stefan _ wrote:
> On 01.12.2017 at 17:45 Michael Niedermayer wrote:
> > AVDISCARD_NONREF is about frames which are not referenced by any other
> > doesnt ff_hevc_frame_nb_refs() produce the number of references curently
> > aka the other end of the reference arrows ?
> 
> Yes, that sounds right.
> 
> I've revised the patch to check for *_N NAL unit types instead (which 
> should be equivalent to H.264's nal_idc == 0) and to skip not only 
> deblock, but also SAO.
> 

>  doc/decoders.texi        |    7 -------
>  libavcodec/hevc_filter.c |   29 +++++++++++++++++++++++++++--
>  2 files changed, 27 insertions(+), 9 deletions(-)
> d0c4c6a91d7222fd9f370bd213e1075d7551463b  0001-libavcodec-hevc_filter-support-for-all-skip_loop_fil.patch
> From a3ebeb4ca0849cfc3846de79b38ae5ca6c001718 Mon Sep 17 00:00:00 2001
> From: sfan5 <sfan5@live.de>
> Date: Thu, 30 Nov 2017 23:58:02 +0100
> Subject: [PATCH] libavcodec/hevc_filter: support for all skip_loop_filter
>  levels.
> 
> Continues where commit 52c75d486ed5f75cbb79e5dbd07b7aef24f3071f left off.
> ---
>  doc/decoders.texi        |  7 -------
>  libavcodec/hevc_filter.c | 29 +++++++++++++++++++++++++++--
>  2 files changed, 27 insertions(+), 9 deletions(-)

will apply

can you add a fate test for this ?

thanks

[...]

Patch hide | download patch | download mbox

From a3ebeb4ca0849cfc3846de79b38ae5ca6c001718 Mon Sep 17 00:00:00 2001
From: sfan5 <sfan5@live.de>
Date: Thu, 30 Nov 2017 23:58:02 +0100
Subject: [PATCH] libavcodec/hevc_filter: support for all skip_loop_filter
 levels.

Continues where commit 52c75d486ed5f75cbb79e5dbd07b7aef24f3071f left off.
---
 doc/decoders.texi        |  7 -------
 libavcodec/hevc_filter.c | 29 +++++++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/doc/decoders.texi b/doc/decoders.texi
index d149d2bea5..a9510bdf02 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -25,13 +25,6 @@  enabled decoders.
 A description of some of the currently available video decoders
 follows.
 
-@section hevc
-
-HEVC / H.265 decoder.
-
-Note: the @option{skip_loop_filter} option has effect only at level
-@code{all}.
-
 @section rawvideo
 
 Raw video decoder.
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index b53f4cc721..94fb7cd3d1 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -842,9 +842,34 @@  void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
 void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
 {
     int x_end = x >= s->ps.sps->width  - ctb_size;
-    if (s->avctx->skip_loop_filter < AVDISCARD_ALL)
+    int skip = 0, is_n = 0;
+    switch (s->nal_unit_type) {
+    case HEVC_NAL_TRAIL_N:
+    case HEVC_NAL_TSA_N:
+    case HEVC_NAL_STSA_N:
+    case HEVC_NAL_RADL_N:
+    case HEVC_NAL_RASL_N:
+    case HEVC_NAL_VCL_N10:
+    case HEVC_NAL_VCL_N12:
+    case HEVC_NAL_VCL_N14:
+    case HEVC_NAL_BLA_N_LP:
+    case HEVC_NAL_IDR_N_LP:
+        is_n = 1;
+        break;
+    default: break;
+    }
+    if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
+        (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) ||
+        (s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
+         s->sh.slice_type != HEVC_SLICE_I) ||
+        (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
+         s->sh.slice_type == HEVC_SLICE_B) ||
+        (s->avctx->skip_loop_filter >= AVDISCARD_NONREF && is_n))
+        skip = 1;
+
+    if (!skip)
         deblocking_filter_CTB(s, x, y);
-    if (s->ps.sps->sao_enabled) {
+    if (s->ps.sps->sao_enabled && !skip) {
         int y_end = y >= s->ps.sps->height - ctb_size;
         if (y && x)
             sao_filter_CTB(s, x - ctb_size, y - ctb_size);
-- 
2.15.1