]> granicus.if.org Git - libvpx/commitdiff
Add codec control to disable loopfilter for vp9
authorJerome Jiang <jianj@google.com>
Fri, 2 Oct 2020 17:47:47 +0000 (10:47 -0700)
committerJerome Jiang <jianj@google.com>
Fri, 2 Oct 2020 19:09:01 +0000 (12:09 -0700)
Change-Id: I6d693e84570c353d20ec314acea43363956c0590

examples/vp9_spatial_svc_encoder.c
examples/vpx_temporal_svc_encoder.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_encoder.h
vp9/vp9_cx_iface.c
vpx/vp8cx.h

index 5bb5a3183f39dd48e63e87b072e4e3b4100a8fee..63055729795ebc93407effb1a56c71d1857f0a11 100644 (file)
@@ -1054,6 +1054,7 @@ int main(int argc, const char **argv) {
   vpx_codec_control(&encoder, VP9E_SET_TUNE_CONTENT, app_input.tune_content);
 
   vpx_codec_control(&encoder, VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, 0);
+  vpx_codec_control(&encoder, VP9E_SET_DISABLE_LOOPFILTER, 0);
 
   svc_drop_frame.framedrop_mode = FULL_SUPERFRAME_DROP;
   for (sl = 0; sl < (unsigned int)svc_ctx.spatial_layers; ++sl)
index c5a3228b112b89d51eb621291ab4e298b7fd4a13..ffeae2abc4f68c939f9847f57675ba438ba58a70 100644 (file)
@@ -841,6 +841,7 @@ int main(int argc, char **argv) {
     vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1);
     vpx_codec_control(&codec, VP9E_SET_TUNE_CONTENT, 0);
     vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, get_msb(cfg.g_threads));
+    vpx_codec_control(&codec, VP9E_SET_DISABLE_LOOPFILTER, 0);
 #if ROI_MAP
     set_roi_map(encoder->name, &cfg, &roi);
     if (vpx_codec_control(&codec, VP9E_SET_ROI_MAP, &roi))
index 0485590615109e2a3b85b52287863e69651404a8..e513cef84c28fc9d1c465727a45347dcb590b95f 100644 (file)
@@ -3316,6 +3316,12 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
     return;
   }
 
+  if (cpi->loopfilter_ctrl == NO_LOOPFILTER ||
+      (!is_reference_frame && cpi->loopfilter_ctrl == LOOPFILTER_REFERENCE)) {
+    lf->filter_level = 0;
+    return;
+  }
+
   if (xd->lossless) {
     lf->filter_level = 0;
     lf->last_filt_level = 0;
index b201e25c16434b417d648bb00c8fabf74d68d901..263b10cdbbeef98f3c0cd814ca5cfefb14672d1c 100644 (file)
@@ -147,6 +147,12 @@ typedef enum {
   kVeryHighSad = 6,
 } CONTENT_STATE_SB;
 
+typedef enum {
+  LOOPFILTER_ALL = 0,
+  LOOPFILTER_REFERENCE = 1,  // Disable loopfilter on non reference frames.
+  NO_LOOPFILTER = 2,         // Disable loopfilter on all frames.
+} LOOPFILTER_CONTROL;
+
 typedef struct VP9EncoderConfig {
   BITSTREAM_PROFILE profile;
   vpx_bit_depth_t bit_depth;     // Codec bit-depth.
@@ -958,6 +964,8 @@ typedef struct VP9_COMP {
 
   int multi_layer_arf;
   vpx_roi_map_t roi;
+
+  LOOPFILTER_CONTROL loopfilter_ctrl;
 #if CONFIG_RATE_CTRL
   ENCODE_COMMAND encode_command;
   PARTITION_INFO *partition_info;
index 172a248230d47519544a8bde849e60cc6dad6bf9..9586937927b7bf16ab0164f7a0ee51aabdcf2f14 100644 (file)
@@ -1724,6 +1724,14 @@ static vpx_codec_err_t ctrl_set_disable_overshoot_maxq_cbr(
   return VPX_CODEC_OK;
 }
 
+static vpx_codec_err_t ctrl_set_disable_loopfilter(vpx_codec_alg_priv_t *ctx,
+                                                   va_list args) {
+  VP9_COMP *const cpi = ctx->cpi;
+  const unsigned int data = va_arg(args, unsigned int);
+  cpi->loopfilter_ctrl = data;
+  return VPX_CODEC_OK;
+}
+
 static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { VP8_COPY_REFERENCE, ctrl_copy_reference },
 
@@ -1775,6 +1783,7 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { VP9E_SET_SVC_GF_TEMPORAL_REF, ctrl_set_svc_gf_temporal_ref },
   { VP9E_SET_SVC_SPATIAL_LAYER_SYNC, ctrl_set_svc_spatial_layer_sync },
   { VP9E_SET_DELTA_Q_UV, ctrl_set_delta_q_uv },
+  { VP9E_SET_DISABLE_LOOPFILTER, ctrl_set_disable_loopfilter },
 
   // Getters
   { VP8E_GET_LAST_QUANTIZER, ctrl_get_quantizer },
index ed3e2516af6cf883d8ce5b1154ef591cc982f378..59753cdfde5205f0c18b55108c16f3f87172c21a 100644 (file)
@@ -692,6 +692,15 @@ enum vp8e_enc_control_id {
    * Supported in codecs: VP9
    */
   VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR,
+
+  /*!\brief Codec control function to disable loopfilter.
+   *
+   * 0: Loopfilter on all frames, 1: Disable on non reference frames.
+   * 2: Disable on all frames.
+   *
+   * Supported in codecs: VP9
+   */
+  VP9E_SET_DISABLE_LOOPFILTER,
 };
 
 /*!\brief vpx 1-D scaling mode
@@ -1044,6 +1053,9 @@ VPX_CTRL_USE_TYPE(VP9E_SET_DELTA_Q_UV, int)
 
 VPX_CTRL_USE_TYPE(VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, int)
 #define VPX_CTRL_VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR
+
+VPX_CTRL_USE_TYPE(VP9E_SET_DISABLE_LOOPFILTER, int)
+#define VPX_CTRL_VP9E_SET_DISABLE_LOOPFILTER
 /*!\endcond */
 /*! @} - end defgroup vp8_encoder */
 #ifdef __cplusplus