Remove functions for CNN-restoration

Change-Id: I5d8343a4485c5a0056e930fee9c8030de21ef515
diff --git a/av1/encoder/cnn.c b/av1/encoder/cnn.c
index 217d238..3cfe63e 100644
--- a/av1/encoder/cnn.c
+++ b/av1/encoder/cnn.c
@@ -1048,188 +1048,3 @@
                   thread_data, output, out_stride);
   aom_free(input_);
 }
-
-void av1_restore_cnn_img(uint8_t *dgd, int width, int height, int stride,
-                         const CNN_CONFIG *cnn_config,
-                         const CNN_THREAD_DATA *thread_data) {
-  const float max_val = 255;
-  int out_width = 0;
-  int out_height = 0;
-  int out_channels = 0;
-  av1_find_cnn_output_size(width, height, cnn_config, &out_width, &out_height,
-                           &out_channels);
-  assert(out_width == width);
-  assert(out_height == height);
-  // For restoration, we only want one channel outputted.
-  assert(out_channels == 1);
-
-  const int out_stride = width;
-  float *output = (float *)aom_malloc(width * height * sizeof(*output));
-  av1_cnn_predict_img(&dgd, width, height, stride, cnn_config, thread_data,
-                      &output, out_stride);
-
-  if (cnn_config->is_residue) {
-    for (int i = 0; i < height; ++i)
-      for (int j = 0; j < width; ++j) {
-        const int residue = (int)(output[i * out_stride + j] * max_val + 0.5);
-        dgd[i * stride + j] = clip_pixel(dgd[i * stride + j] + residue);
-      }
-  } else {
-    for (int i = 0; i < height; ++i)
-      for (int j = 0; j < width; ++j)
-        dgd[i * stride + j] =
-            clip_pixel((int)(output[i * out_stride + j] * max_val + 0.5));
-  }
-  aom_free(output);
-}
-
-void av1_restore_cnn_img_highbd(uint16_t *dgd, int width, int height,
-                                int stride, const CNN_CONFIG *cnn_config,
-                                const CNN_THREAD_DATA *thread_data,
-                                int bit_depth) {
-  const float max_val = (float)((1 << bit_depth) - 1);
-  int out_width = 0;
-  int out_height = 0;
-  int out_channels = 0;
-  av1_find_cnn_output_size(width, height, cnn_config, &out_width, &out_height,
-                           &out_channels);
-  assert(out_width == width);
-  assert(out_height == height);
-  // For restoration, we only want one channel outputted.
-  assert(out_channels == 1);
-
-  float *output = (float *)aom_malloc(width * height * sizeof(*output));
-  const int out_stride = width;
-  av1_cnn_predict_img_highbd(&dgd, width, height, stride, cnn_config,
-                             thread_data, bit_depth, &output, out_stride);
-
-  if (cnn_config->is_residue) {
-    for (int i = 0; i < height; ++i)
-      for (int j = 0; j < width; ++j) {
-        const int residue = (int)(output[i * out_stride + j] * max_val + 0.5);
-        dgd[i * stride + j] +=
-            clip_pixel_highbd(dgd[i * stride + j] + residue, bit_depth);
-      }
-  } else {
-    for (int i = 0; i < height; ++i)
-      for (int j = 0; j < width; ++j)
-        dgd[i * stride + j] = clip_pixel_highbd(
-            (int)(output[i * out_stride + j] * max_val + 0.5), bit_depth);
-  }
-  aom_free(output);
-}
-
-void av1_restore_cnn_plane_part(AV1_COMMON *cm, const CNN_CONFIG *cnn_config,
-                                const CNN_THREAD_DATA *thread_data, int plane,
-                                int start_x, int start_y, int width,
-                                int height) {
-  YV12_BUFFER_CONFIG *buf = &cm->cur_frame->buf;
-
-  assert(start_x >= 0 && start_x + width <= buf->y_crop_width);
-  assert(start_y >= 0 && start_y + height <= buf->y_crop_height);
-
-  int offset = 0, part_width = 0, part_height = 0;
-  switch (plane) {
-    case AOM_PLANE_Y:
-      part_width = width;
-      part_height = height;
-      offset = start_y * buf->y_stride + start_x;
-      break;
-    case AOM_PLANE_U:
-    case AOM_PLANE_V:
-      part_width = width >> buf->subsampling_x;
-      part_height = height >> buf->subsampling_y;
-      offset = (start_y >> buf->subsampling_y) * buf->uv_stride +
-               (start_x >> buf->subsampling_x);
-      break;
-    default: assert(0 && "Invalid plane index");
-  }
-  if (cm->seq_params.use_highbitdepth) {
-    switch (plane) {
-      case AOM_PLANE_Y:
-        av1_restore_cnn_img_highbd(CONVERT_TO_SHORTPTR(buf->y_buffer + offset),
-                                   part_width, part_height, buf->y_stride,
-                                   cnn_config, thread_data,
-                                   cm->seq_params.bit_depth);
-        break;
-      case AOM_PLANE_U:
-        av1_restore_cnn_img_highbd(CONVERT_TO_SHORTPTR(buf->u_buffer + offset),
-                                   part_width, part_height, buf->uv_stride,
-                                   cnn_config, thread_data,
-                                   cm->seq_params.bit_depth);
-        break;
-      case AOM_PLANE_V:
-        av1_restore_cnn_img_highbd(CONVERT_TO_SHORTPTR(buf->v_buffer + offset),
-                                   part_width, part_height, buf->uv_stride,
-                                   cnn_config, thread_data,
-                                   cm->seq_params.bit_depth);
-        break;
-      default: assert(0 && "Invalid plane index");
-    }
-  } else {
-    assert(cm->seq_params.bit_depth == 8);
-    switch (plane) {
-      case AOM_PLANE_Y:
-        av1_restore_cnn_img(buf->y_buffer + offset, part_width, part_height,
-                            buf->y_stride, cnn_config, thread_data);
-        break;
-      case AOM_PLANE_U:
-        av1_restore_cnn_img(buf->u_buffer + offset, part_width, part_height,
-                            buf->uv_stride, cnn_config, thread_data);
-        break;
-      case AOM_PLANE_V:
-        av1_restore_cnn_img(buf->v_buffer + offset, part_width, part_height,
-                            buf->uv_stride, cnn_config, thread_data);
-        break;
-      default: assert(0 && "Invalid plane index");
-    }
-  }
-}
-
-void av1_restore_cnn_plane(AV1_COMMON *cm, const CNN_CONFIG *cnn_config,
-                           int plane, const CNN_THREAD_DATA *thread_data) {
-  YV12_BUFFER_CONFIG *buf = &cm->cur_frame->buf;
-  if (cm->seq_params.use_highbitdepth) {
-    switch (plane) {
-      case AOM_PLANE_Y:
-        av1_restore_cnn_img_highbd(CONVERT_TO_SHORTPTR(buf->y_buffer),
-                                   buf->y_crop_width, buf->y_crop_height,
-                                   buf->y_stride, cnn_config, thread_data,
-                                   cm->seq_params.bit_depth);
-        break;
-      case AOM_PLANE_U:
-        av1_restore_cnn_img_highbd(CONVERT_TO_SHORTPTR(buf->u_buffer),
-                                   buf->uv_crop_width, buf->uv_crop_height,
-                                   buf->uv_stride, cnn_config, thread_data,
-                                   cm->seq_params.bit_depth);
-        break;
-      case AOM_PLANE_V:
-        av1_restore_cnn_img_highbd(CONVERT_TO_SHORTPTR(buf->v_buffer),
-                                   buf->uv_crop_width, buf->uv_crop_height,
-                                   buf->uv_stride, cnn_config, thread_data,
-                                   cm->seq_params.bit_depth);
-        break;
-      default: assert(0 && "Invalid plane index");
-    }
-  } else {
-    assert(cm->seq_params.bit_depth == 8);
-    switch (plane) {
-      case AOM_PLANE_Y:
-        av1_restore_cnn_img(buf->y_buffer, buf->y_crop_width,
-                            buf->y_crop_height, buf->y_stride, cnn_config,
-                            thread_data);
-        break;
-      case AOM_PLANE_U:
-        av1_restore_cnn_img(buf->u_buffer, buf->uv_crop_width,
-                            buf->uv_crop_height, buf->uv_stride, cnn_config,
-                            thread_data);
-        break;
-      case AOM_PLANE_V:
-        av1_restore_cnn_img(buf->v_buffer, buf->uv_crop_width,
-                            buf->uv_crop_height, buf->uv_stride, cnn_config,
-                            thread_data);
-        break;
-      default: assert(0 && "Invalid plane index");
-    }
-  }
-}
diff --git a/av1/encoder/cnn.h b/av1/encoder/cnn.h
index 58e0d03..dc800a0 100644
--- a/av1/encoder/cnn.h
+++ b/av1/encoder/cnn.h
@@ -159,26 +159,6 @@
                                 const CNN_THREAD_DATA *thread_data,
                                 int bit_depth, float **output, int out_stride);
 
-// Restoration functions from input image buffer
-// These internally call av1_cnn_predict_img() / av1_cnn_predict_img_highbd().
-void av1_restore_cnn_img(uint8_t *dgd, int width, int height, int stride,
-                         const CNN_CONFIG *cnn_config,
-                         const CNN_THREAD_DATA *thread_data);
-void av1_restore_cnn_img_highbd(uint16_t *dgd, int width, int height,
-                                int stride, const CNN_CONFIG *cnn_config,
-                                const CNN_THREAD_DATA *thread_data,
-                                int bit_depth);
-
-// Restoration functions that work on current frame buffer in AV1_COMMON
-// directly for convenience.
-void av1_restore_cnn_plane(struct AV1Common *cm, const CNN_CONFIG *cnn_config,
-                           int plane, const CNN_THREAD_DATA *thread_data);
-void av1_restore_cnn_plane_part(struct AV1Common *cm,
-                                const CNN_CONFIG *cnn_config,
-                                const CNN_THREAD_DATA *thread_data, int plane,
-                                int start_x, int start_y, int width,
-                                int height);
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif