Remove post processing related code

Remove all code related to the codec control id AOM_SET_POSTPROC, the
decoder capability AOM_CODEC_CAP_POSTPROC, and decoder initialization
flag AOM_CODEC_USE_POSTPROC.

Post processing is not implemented in libaom. In libvpx, post processing
is implemented by VP8 but not by VP9. On the decoder side, it is used to
post-process decoded frames. On the encoder side, it is used to
post-process preview frames.

Notes on _ABI_VERSION changes in this CL:

1. AOM_SET_POSTPROC was defined in aom/aom.h. Although aom/aom.h does
not have its own _ABI_VERSION macro, I assume that aom/aom.h is covered
by AOM_CODEC_ABI_VERSION. Therefore I bumped AOM_CODEC_ABI_VERSION for
the removal of AOM_SET_POSTPROC.

2. A bump to AOM_CODEC_ABI_VERSION automatically bumps the numeric value
of AOM_DECODER_ABI_VERSION (and AOM_ENCODER_ABI_VERSION), so one can
argue that it is not necessary to bump AOM_DECODER_ABI_VERSION for the
removal of AOM_CODEC_CAP_POSTPROC and AOM_CODEC_USE_POSTPROC. I bumped
the symbolic expression of AOM_DECODER_ABI_VERSION anyway because I saw
this kind of libaom ABI version test in WebRTC code:

  #if AOM_DECODER_ABI_VERSION < (4 + AOM_CODEC_ABI_VERSION)
    ...
  #else
    ...
  #endif

BUG=aomedia:2631

Change-Id: I6eefd7026475bfbf5157bdc7854d79b01c538be4
(cherry picked from commit 6522a0a3064319252a714f66a2a0107cf1e9c75d)
diff --git a/aom/aom.h b/aom/aom.h
index b1cc1ec..4a4cf46 100644
--- a/aom/aom.h
+++ b/aom/aom.h
@@ -45,7 +45,6 @@
 enum aom_com_control_id {
   /*!\brief pass in an external frame into decoder to be used as reference frame
    */
-  AOM_SET_POSTPROC = 3, /**< set the decoder's post processing settings  */
   AOM_SET_DBG_COLOR_REF_FRAME =
       4, /**< set the reference frames to color for each macroblock */
   AOM_SET_DBG_COLOR_MB_MODES = 5, /**< set which macro block modes to color */
@@ -69,38 +68,6 @@
   AOM_DECODER_CTRL_ID_START = 256
 };
 
-/*!\brief post process flags
- *
- * The set of macros define AOM decoder post processing flags
- */
-enum aom_postproc_level {
-  AOM_NOFILTERING = 0,
-  AOM_DEBLOCK = 1 << 0,
-  AOM_DEMACROBLOCK = 1 << 1,
-  AOM_ADDNOISE = 1 << 2,
-  AOM_DEBUG_TXT_FRAME_INFO = 1 << 3, /**< print frame information */
-  AOM_DEBUG_TXT_MBLK_MODES =
-      1 << 4, /**< print macro block modes over each macro block */
-  AOM_DEBUG_TXT_DC_DIFF = 1 << 5,   /**< print dc diff for each macro block */
-  AOM_DEBUG_TXT_RATE_INFO = 1 << 6, /**< print video rate info (encoder only) */
-  AOM_MFQE = 1 << 10
-};
-
-/*!\brief post process flags
- *
- * This define a structure that describe the post processing settings. For
- * the best objective measure (using the PSNR metric) set post_proc_flag
- * to AOM_DEBLOCK and deblocking_level to 1.
- */
-
-typedef struct aom_postproc_cfg {
-  /*!\brief the types of post processing to be done, should be combination of
-   * "aom_postproc_level" */
-  int post_proc_flag;
-  int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
-  int noise_level; /**< the strength of additive noise, valid range [0, 16] */
-} aom_postproc_cfg_t;
-
 /*!\brief AV1 specific reference frame data struct
  *
  * Define the data struct to access av1 reference frames.
@@ -116,8 +83,6 @@
  *
  * defines the data type for each of AOM decoder control function requires
  */
-AOM_CTRL_USE_TYPE(AOM_SET_POSTPROC, aom_postproc_cfg_t *)
-#define AOM_CTRL_AOM_SET_POSTPROC
 AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_REF_FRAME, int)
 #define AOM_CTRL_AOM_SET_DBG_COLOR_REF_FRAME
 AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_MB_MODES, int)
diff --git a/aom/aom_codec.h b/aom/aom_codec.h
index 2a5ef7e..9ac5619 100644
--- a/aom/aom_codec.h
+++ b/aom/aom_codec.h
@@ -95,7 +95,7 @@
  * types, removing or reassigning enums, adding/removing/rearranging
  * fields to structures
  */
-#define AOM_CODEC_ABI_VERSION (3 + AOM_IMAGE_ABI_VERSION) /**<\hideinitializer*/
+#define AOM_CODEC_ABI_VERSION (4 + AOM_IMAGE_ABI_VERSION) /**<\hideinitializer*/
 
 /*!\brief Algorithm return codes */
 typedef enum {
diff --git a/aom/aom_decoder.h b/aom/aom_decoder.h
index d4ad059..5ce7c7b 100644
--- a/aom/aom_decoder.h
+++ b/aom/aom_decoder.h
@@ -42,7 +42,7 @@
  * fields to structures
  */
 #define AOM_DECODER_ABI_VERSION \
-  (5 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
+  (6 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
 
 /*! \brief Decoder capabilities bitfield
  *
@@ -52,7 +52,6 @@
  *
  *  The available flags are specified by AOM_CODEC_CAP_* defines.
  */
-#define AOM_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
 /*!brief Can support external frame buffers */
 #define AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x200000
 
@@ -63,7 +62,6 @@
  *
  *  The available flags are specified by AOM_CODEC_USE_* defines.
  */
-#define AOM_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
 
 /*!\brief Stream properties
  *
diff --git a/aom/src/aom_decoder.c b/aom/src/aom_decoder.c
index 58df482..49fff26 100644
--- a/aom/src/aom_decoder.c
+++ b/aom/src/aom_decoder.c
@@ -34,9 +34,6 @@
     res = AOM_CODEC_INVALID_PARAM;
   else if (iface->abi_version != AOM_CODEC_INTERNAL_ABI_VERSION)
     res = AOM_CODEC_ABI_MISMATCH;
-  else if ((flags & AOM_CODEC_USE_POSTPROC) &&
-           !(iface->caps & AOM_CODEC_CAP_POSTPROC))
-    res = AOM_CODEC_INCAPABLE;
   else if (!(iface->caps & AOM_CODEC_CAP_DECODER))
     res = AOM_CODEC_INCAPABLE;
   else {
diff --git a/aom_dsp/add_noise.c b/aom_dsp/add_noise.c
deleted file mode 100644
index 43587ca..0000000
--- a/aom_dsp/add_noise.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-#include <math.h>
-#include <stdlib.h>
-
-#include "config/aom_config.h"
-#include "config/aom_dsp_rtcd.h"
-
-#include "aom/aom_integer.h"
-#include "aom_ports/mem.h"
-
-void aom_plane_add_noise_c(uint8_t *start, char *noise, char blackclamp[16],
-                           char whiteclamp[16], char bothclamp[16],
-                           unsigned int width, unsigned int height, int pitch) {
-  unsigned int i, j;
-
-  for (i = 0; i < height; ++i) {
-    uint8_t *pos = start + i * pitch;
-    char *ref = (char *)(noise + (rand() & 0xff));  // NOLINT
-
-    for (j = 0; j < width; ++j) {
-      int v = pos[j];
-
-      v = clamp(v - blackclamp[0], 0, 255);
-      v = clamp(v + bothclamp[0], 0, 255);
-      v = clamp(v - whiteclamp[0], 0, 255);
-
-      pos[j] = v + ref[j];
-    }
-  }
-}
-
-static double gaussian(double sigma, double mu, double x) {
-  return 1 / (sigma * sqrt(2.0 * PI)) *
-         (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
-}
-
-int aom_setup_noise(double sigma, int size, char *noise) {
-  char char_dist[256];
-  int next = 0, i, j;
-
-  // set up a 256 entry lookup that matches gaussian distribution
-  for (i = -32; i < 32; ++i) {
-    const int a_i = (int)(0.5 + 256 * gaussian(sigma, 0, i));
-    if (a_i) {
-      for (j = 0; j < a_i; ++j) {
-        char_dist[next + j] = (char)i;
-      }
-      next = next + j;
-    }
-  }
-
-  // Rounding error - might mean we have less than 256.
-  for (; next < 256; ++next) {
-    char_dist[next] = 0;
-  }
-
-  for (i = 0; i < size; ++i) {
-    noise[i] = char_dist[rand() & 0xff];  // NOLINT
-  }
-
-  // Returns the highest non 0 value used in distribution.
-  return -char_dist[0];
-}
diff --git a/aom_dsp/mips/add_noise_msa.c b/aom_dsp/mips/add_noise_msa.c
deleted file mode 100644
index 96d04cf..0000000
--- a/aom_dsp/mips/add_noise_msa.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-#include <stdlib.h>
-
-#include "aom_dsp/mips/macros_msa.h"
-
-void aom_plane_add_noise_msa(uint8_t *start_ptr, char *noise,
-                             char blackclamp[16], char whiteclamp[16],
-                             char bothclamp[16], uint32_t width,
-                             uint32_t height, int32_t pitch) {
-  uint32_t i, j;
-
-  for (i = 0; i < height / 2; ++i) {
-    uint8_t *pos0_ptr = start_ptr + (2 * i) * pitch;
-    int8_t *ref0_ptr = (int8_t *)(noise + (rand() & 0xff));
-    uint8_t *pos1_ptr = start_ptr + (2 * i + 1) * pitch;
-    int8_t *ref1_ptr = (int8_t *)(noise + (rand() & 0xff));
-    for (j = width / 16; j--;) {
-      v16i8 temp00_s, temp01_s;
-      v16u8 temp00, temp01, black_clamp, white_clamp;
-      v16u8 pos0, ref0, pos1, ref1;
-      v16i8 const127 = __msa_ldi_b(127);
-
-      pos0 = LD_UB(pos0_ptr);
-      ref0 = LD_UB(ref0_ptr);
-      pos1 = LD_UB(pos1_ptr);
-      ref1 = LD_UB(ref1_ptr);
-      black_clamp = (v16u8)__msa_fill_b(blackclamp[0]);
-      white_clamp = (v16u8)__msa_fill_b(whiteclamp[0]);
-      temp00 = (pos0 < black_clamp);
-      pos0 = __msa_bmnz_v(pos0, black_clamp, temp00);
-      temp01 = (pos1 < black_clamp);
-      pos1 = __msa_bmnz_v(pos1, black_clamp, temp01);
-      XORI_B2_128_UB(pos0, pos1);
-      temp00_s = __msa_adds_s_b((v16i8)white_clamp, const127);
-      temp00 = (v16u8)(temp00_s < pos0);
-      pos0 = (v16u8)__msa_bmnz_v((v16u8)pos0, (v16u8)temp00_s, temp00);
-      temp01_s = __msa_adds_s_b((v16i8)white_clamp, const127);
-      temp01 = (temp01_s < pos1);
-      pos1 = (v16u8)__msa_bmnz_v((v16u8)pos1, (v16u8)temp01_s, temp01);
-      XORI_B2_128_UB(pos0, pos1);
-      pos0 += ref0;
-      ST_UB(pos0, pos0_ptr);
-      pos1 += ref1;
-      ST_UB(pos1, pos1_ptr);
-      pos0_ptr += 16;
-      pos1_ptr += 16;
-      ref0_ptr += 16;
-      ref1_ptr += 16;
-    }
-  }
-}
diff --git a/aom_dsp/postproc.h b/aom_dsp/postproc.h
deleted file mode 100644
index f3d87f2..0000000
--- a/aom_dsp/postproc.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-#ifndef AOM_AOM_DSP_POSTPROC_H_
-#define AOM_AOM_DSP_POSTPROC_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Fills a noise buffer with gaussian noise strength determined by sigma.
-int aom_setup_noise(double sigma, int size, char *noise);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  // AOM_AOM_DSP_POSTPROC_H_
diff --git a/apps/aomdec.c b/apps/aomdec.c
index 8b149a0..86b0e00 100644
--- a/apps/aomdec.c
+++ b/apps/aomdec.c
@@ -76,8 +76,6 @@
     ARG_DEF(NULL, "limit", 1, "Stop decoding after n frames");
 static const arg_def_t skiparg =
     ARG_DEF(NULL, "skip", 1, "Skip the first n input frames");
-static const arg_def_t postprocarg =
-    ARG_DEF(NULL, "postproc", 0, "Postprocess decoded frames");
 static const arg_def_t summaryarg =
     ARG_DEF(NULL, "summary", 0, "Show timing summary");
 static const arg_def_t outputfile =
@@ -108,13 +106,11 @@
     ARG_DEF(NULL, "skip-film-grain", 0, "Skip film grain application");
 
 static const arg_def_t *all_args[] = {
-  &help,           &codecarg,   &use_yv12,      &use_i420,
-  &flipuvarg,      &rawvideo,   &noblitarg,     &progressarg,
-  &limitarg,       &skiparg,    &postprocarg,   &summaryarg,
-  &outputfile,     &threadsarg, &verbosearg,    &scalearg,
-  &fb_arg,         &md5arg,     &framestatsarg, &continuearg,
-  &outbitdeptharg, &isannexb,   &oppointarg,    &outallarg,
-  &skipfilmgrain,  NULL
+  &help,       &codecarg,   &use_yv12,      &use_i420,      &flipuvarg,
+  &rawvideo,   &noblitarg,  &progressarg,   &limitarg,      &skiparg,
+  &summaryarg, &outputfile, &threadsarg,    &verbosearg,    &scalearg,
+  &fb_arg,     &md5arg,     &framestatsarg, &continuearg,   &outbitdeptharg,
+  &isannexb,   &oppointarg, &outallarg,     &skipfilmgrain, NULL
 };
 
 #if CONFIG_LIBYUV
@@ -437,7 +433,7 @@
   FILE *infile;
   int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0;
   int do_md5 = 0, progress = 0;
-  int stop_after = 0, postproc = 0, summary = 0, quiet = 1;
+  int stop_after = 0, summary = 0, quiet = 1;
   int arg_skip = 0;
   int keep_going = 0;
   const AvxInterface *interface = NULL;
@@ -536,8 +532,6 @@
       stop_after = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &skiparg, argi)) {
       arg_skip = arg_parse_uint(&arg);
-    } else if (arg_match(&arg, &postprocarg, argi)) {
-      postproc = 1;
     } else if (arg_match(&arg, &md5arg, argi)) {
       do_md5 = 1;
     } else if (arg_match(&arg, &framestatsarg, argi)) {
@@ -676,7 +670,7 @@
 
   if (!interface) interface = get_aom_decoder_by_index(0);
 
-  dec_flags = (postproc ? AOM_CODEC_USE_POSTPROC : 0);
+  dec_flags = 0;
   if (aom_codec_dec_init(&decoder, interface->codec_interface(), &cfg,
                          dec_flags)) {
     fprintf(stderr, "Failed to initialize decoder: %s\n",
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 37189f1..676eaa0 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -293,7 +293,6 @@
   size_t pending_frame_sizes[8];
   aom_image_t preview_img;
   aom_enc_frame_flags_t next_frame_flags;
-  aom_postproc_cfg_t preview_ppcfg;
   aom_codec_pkt_list_decl(256) pkt_list;
   unsigned int fixed_kf_cntr;
   // BufferPool that holds all reference frames.
@@ -2388,13 +2387,6 @@
   }
 }
 
-static aom_codec_err_t ctrl_set_previewpp(aom_codec_alg_priv_t *ctx,
-                                          va_list args) {
-  (void)ctx;
-  (void)args;
-  return AOM_CODEC_INCAPABLE;
-}
-
 static aom_image_t *encoder_get_preview(aom_codec_alg_priv_t *ctx) {
   YV12_BUFFER_CONFIG sd;
 
@@ -2639,7 +2631,6 @@
 
   // Setters
   { AV1_SET_REFERENCE, ctrl_set_reference },
-  { AOM_SET_POSTPROC, ctrl_set_previewpp },
   { AOME_SET_ROI_MAP, ctrl_set_roi_map },
   { AOME_SET_ACTIVEMAP, ctrl_set_active_map },
   { AOME_SET_SCALEMODE, ctrl_set_scale_mode },
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index 40aec58..129ef8a 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -39,8 +39,6 @@
   aom_codec_priv_t base;
   aom_codec_dec_cfg_t cfg;
   aom_codec_stream_info_t si;
-  int postproc_cfg_set;
-  aom_postproc_cfg_t postproc_cfg;
   aom_image_t img;
   int img_avail;
   int flushed;
@@ -399,12 +397,6 @@
   }
 }
 
-static void set_default_ppflags(aom_postproc_cfg_t *cfg) {
-  cfg->post_proc_flag = AOM_DEBLOCK | AOM_DEMACROBLOCK;
-  cfg->deblocking_level = 4;
-  cfg->noise_level = 0;
-}
-
 static int frame_worker_hook(void *arg1, void *arg2) {
   FrameWorkerData *const frame_worker_data = (FrameWorkerData *)arg1;
   const uint8_t *data = frame_worker_data->data;
@@ -478,11 +470,6 @@
 
   worker->hook = frame_worker_hook;
 
-  // If postprocessing was enabled by the application and a
-  // configuration has not been provided, default it.
-  if (!ctx->postproc_cfg_set && (ctx->base.init_flags & AOM_CODEC_USE_POSTPROC))
-    set_default_ppflags(&ctx->postproc_cfg);
-
   init_buffer_callbacks(ctx);
 
   return AOM_CODEC_OK;
@@ -953,13 +940,6 @@
   }
 }
 
-static aom_codec_err_t ctrl_set_postproc(aom_codec_alg_priv_t *ctx,
-                                         va_list args) {
-  (void)ctx;
-  (void)args;
-  return AOM_CODEC_INCAPABLE;
-}
-
 static aom_codec_err_t ctrl_set_dbg_options(aom_codec_alg_priv_t *ctx,
                                             va_list args) {
   (void)ctx;
@@ -1357,7 +1337,6 @@
 
   // Setters
   { AV1_SET_REFERENCE, ctrl_set_reference },
-  { AOM_SET_POSTPROC, ctrl_set_postproc },
   { AOM_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options },
   { AOM_SET_DBG_COLOR_MB_MODES, ctrl_set_dbg_options },
   { AOM_SET_DBG_COLOR_B_MODES, ctrl_set_dbg_options },
diff --git a/usage_dx.dox b/usage_dx.dox
index 41d3f77..76dc213 100644
--- a/usage_dx.dox
+++ b/usage_dx.dox
@@ -19,16 +19,4 @@
     frames that are ready for display, depending on the codec.
 
 
-    \section usage_postproc Postprocessing
-    Postprocessing is a process that is applied after a frame is decoded to
-    enhance the image's appearance by removing artifacts introduced in the
-    compression process. It is not required to properly decode the frame, and
-    is generally done only when there is enough spare CPU time to execute
-    the required filters. Codecs may support a number of different
-    postprocessing filters, and the available filters may differ from platform
-    to platform. Embedded devices often do not have enough CPU to implement
-    postprocessing in software. The filter selection is generally handled
-    automatically by the codec.
-
-
 */