Move aom_dsp/grain_synthesis.{h,c} to av1/decoder/

The top portion of aom_dsp/grain_synthesis.h, which defines the
aom_film_grain_t struct and the aom_check_grain_params_equiv() inline
function, becomes aom_dsp/grain_params.h. Since aom_film_grain_t is used
by both the decoder and the encoder, aom_dsp/grain_params.h is added to
AOM_DSP_COMMON_SOURCES instead of AOM_DSP_DECODER_SOURCES.

The reason aom_dsp/grain_params.h must stay in aom_dsp/ is that
aom_dsp/grain_table.h and aom_dsp/noise_model.h use the aom_film_grain_t
type.

BUG=aomedia:2734

Change-Id: I92d4ec60efaefcf0cefe986b405a5a8e1bba5802
diff --git a/aom_dsp/aom_dsp.cmake b/aom_dsp/aom_dsp.cmake
index 15a7615..e201832 100644
--- a/aom_dsp/aom_dsp.cmake
+++ b/aom_dsp/aom_dsp.cmake
@@ -31,6 +31,7 @@
             "${AOM_ROOT}/aom_dsp/entcode.h"
             "${AOM_ROOT}/aom_dsp/fft.c"
             "${AOM_ROOT}/aom_dsp/fft_common.h"
+            "${AOM_ROOT}/aom_dsp/grain_params.h"
             "${AOM_ROOT}/aom_dsp/intrapred.c"
             "${AOM_ROOT}/aom_dsp/intrapred_common.h"
             "${AOM_ROOT}/aom_dsp/loopfilter.c"
@@ -163,9 +164,7 @@
               "${AOM_ROOT}/aom_dsp/binary_codes_reader.h"
               "${AOM_ROOT}/aom_dsp/bitreader.c"
               "${AOM_ROOT}/aom_dsp/bitreader.h" "${AOM_ROOT}/aom_dsp/entdec.c"
-              "${AOM_ROOT}/aom_dsp/entdec.h"
-              "${AOM_ROOT}/aom_dsp/grain_synthesis.c"
-              "${AOM_ROOT}/aom_dsp/grain_synthesis.h")
+              "${AOM_ROOT}/aom_dsp/entdec.h")
 endif()
 
 if(CONFIG_AV1_ENCODER)
diff --git a/aom_dsp/grain_synthesis.h b/aom_dsp/grain_params.h
similarity index 75%
rename from aom_dsp/grain_synthesis.h
rename to aom_dsp/grain_params.h
index 7945767..5a28afc 100644
--- a/aom_dsp/grain_synthesis.h
+++ b/aom_dsp/grain_params.h
@@ -10,20 +10,20 @@
  */
 
 /*!\file
- * \brief Describes film grain parameters and film grain synthesis
+ * \brief Describes film grain parameters
  *
  */
-#ifndef AOM_AOM_DSP_GRAIN_SYNTHESIS_H_
-#define AOM_AOM_DSP_GRAIN_SYNTHESIS_H_
+#ifndef AOM_AOM_DSP_GRAIN_PARAMS_H_
+#define AOM_AOM_DSP_GRAIN_PARAMS_H_
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#include <stdint.h>
 #include <string.h>
 
-#include "aom_dsp/aom_dsp_common.h"
-#include "aom/aom_image.h"
+#include "config/aom_config.h"
 
 /*!\brief Structure containing film grain synthesis parameters for a frame
  *
@@ -151,42 +151,8 @@
   return 1;
 }
 
-/*!\brief Add film grain
- *
- * Add film grain to an image
- *
- * Returns 0 for success, -1 for failure
- *
- * \param[in]    grain_params     Grain parameters
- * \param[in]    luma             luma plane
- * \param[in]    cb               cb plane
- * \param[in]    cr               cr plane
- * \param[in]    height           luma plane height
- * \param[in]    width            luma plane width
- * \param[in]    luma_stride      luma plane stride
- * \param[in]    chroma_stride    chroma plane stride
- */
-int av1_add_film_grain_run(const aom_film_grain_t *grain_params, uint8_t *luma,
-                           uint8_t *cb, uint8_t *cr, int height, int width,
-                           int luma_stride, int chroma_stride,
-                           int use_high_bit_depth, int chroma_subsamp_y,
-                           int chroma_subsamp_x, int mc_identity);
-
-/*!\brief Add film grain
- *
- * Add film grain to an image
- *
- * Returns 0 for success, -1 for failure
- *
- * \param[in]    grain_params     Grain parameters
- * \param[in]    src              Source image
- * \param[out]   dst              Resulting image with grain
- */
-int av1_add_film_grain(const aom_film_grain_t *grain_params,
-                       const aom_image_t *src, aom_image_t *dst);
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
-#endif  // AOM_AOM_DSP_GRAIN_SYNTHESIS_H_
+#endif  // AOM_AOM_DSP_GRAIN_PARAMS_H_
diff --git a/aom_dsp/grain_table.h b/aom_dsp/grain_table.h
index a8ac507..3f75101 100644
--- a/aom_dsp/grain_table.h
+++ b/aom_dsp/grain_table.h
@@ -34,7 +34,7 @@
 extern "C" {
 #endif
 
-#include "aom_dsp/grain_synthesis.h"
+#include "aom_dsp/grain_params.h"
 #include "aom/internal/aom_codec_internal.h"
 
 typedef struct aom_film_grain_table_entry_t {
diff --git a/aom_dsp/noise_model.h b/aom_dsp/noise_model.h
index bb2b419..f385251 100644
--- a/aom_dsp/noise_model.h
+++ b/aom_dsp/noise_model.h
@@ -17,7 +17,8 @@
 #endif  // __cplusplus
 
 #include <stdint.h>
-#include "aom_dsp/grain_synthesis.h"
+#include "aom_dsp/grain_params.h"
+#include "aom_ports/mem.h"
 #include "aom_scale/yv12config.h"
 
 /*!\brief Wrapper of data required to represent linear system of eqns and soln.
diff --git a/av1/av1.cmake b/av1/av1.cmake
index bcffa76..440cb9a 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -110,6 +110,8 @@
             "${AOM_ROOT}/av1/decoder/detokenize.c"
             "${AOM_ROOT}/av1/decoder/detokenize.h"
             "${AOM_ROOT}/av1/decoder/dthread.h"
+            "${AOM_ROOT}/av1/decoder/grain_synthesis.c"
+            "${AOM_ROOT}/av1/decoder/grain_synthesis.h"
             "${AOM_ROOT}/av1/decoder/obu.h"
             "${AOM_ROOT}/av1/decoder/obu.c")
 
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index 686db8d..8e69a01 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -31,6 +31,7 @@
 
 #include "av1/decoder/decoder.h"
 #include "av1/decoder/decodeframe.h"
+#include "av1/decoder/grain_synthesis.h"
 #include "av1/decoder/obu.h"
 
 #include "av1/av1_iface_common.h"
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h
index 980f31c..5454a00 100644
--- a/av1/common/av1_common_int.h
+++ b/av1/common/av1_common_int.h
@@ -29,7 +29,7 @@
 #include "av1/common/restoration.h"
 #include "av1/common/tile_common.h"
 #include "av1/common/timing.h"
-#include "aom_dsp/grain_synthesis.h"
+#include "aom_dsp/grain_params.h"
 #include "aom_dsp/grain_table.h"
 #include "aom_dsp/odintrin.h"
 #ifdef __cplusplus
diff --git a/aom_dsp/grain_synthesis.c b/av1/decoder/grain_synthesis.c
similarity index 99%
rename from aom_dsp/grain_synthesis.c
rename to av1/decoder/grain_synthesis.c
index 626eb76..60b458b 100644
--- a/aom_dsp/grain_synthesis.c
+++ b/av1/decoder/grain_synthesis.c
@@ -18,8 +18,9 @@
 #include <string.h>
 #include <stdlib.h>
 #include <assert.h>
-#include "aom_dsp/grain_synthesis.h"
+#include "aom_dsp/aom_dsp_common.h"
 #include "aom_mem/aom_mem.h"
+#include "av1/decoder/grain_synthesis.h"
 
 // Samples with Gaussian distribution in the range of [-2048, 2047] (12 bits)
 // with zero mean and standard deviation of about 512.
diff --git a/av1/decoder/grain_synthesis.h b/av1/decoder/grain_synthesis.h
new file mode 100644
index 0000000..9858ce0
--- /dev/null
+++ b/av1/decoder/grain_synthesis.h
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+/*!\file
+ * \brief Describes film grain synthesis
+ *
+ */
+#ifndef AOM_AV1_DECODER_GRAIN_SYNTHESIS_H_
+#define AOM_AV1_DECODER_GRAIN_SYNTHESIS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#include "aom_dsp/grain_params.h"
+#include "aom/aom_image.h"
+
+/*!\brief Add film grain
+ *
+ * Add film grain to an image
+ *
+ * Returns 0 for success, -1 for failure
+ *
+ * \param[in]    grain_params     Grain parameters
+ * \param[in]    luma             luma plane
+ * \param[in]    cb               cb plane
+ * \param[in]    cr               cr plane
+ * \param[in]    height           luma plane height
+ * \param[in]    width            luma plane width
+ * \param[in]    luma_stride      luma plane stride
+ * \param[in]    chroma_stride    chroma plane stride
+ */
+int av1_add_film_grain_run(const aom_film_grain_t *grain_params, uint8_t *luma,
+                           uint8_t *cb, uint8_t *cr, int height, int width,
+                           int luma_stride, int chroma_stride,
+                           int use_high_bit_depth, int chroma_subsamp_y,
+                           int chroma_subsamp_x, int mc_identity);
+
+/*!\brief Add film grain
+ *
+ * Add film grain to an image
+ *
+ * Returns 0 for success, -1 for failure
+ *
+ * \param[in]    grain_params     Grain parameters
+ * \param[in]    src              Source image
+ * \param[out]   dst              Resulting image with grain
+ */
+int av1_add_film_grain(const aom_film_grain_t *grain_params,
+                       const aom_image_t *src, aom_image_t *dst);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // AOM_AV1_DECODER_GRAIN_SYNTHESIS_H_
diff --git a/examples/noise_model.c b/examples/noise_model.c
index d07443f..2a40c12 100644
--- a/examples/noise_model.c
+++ b/examples/noise_model.c
@@ -47,7 +47,7 @@
 #include "aom_dsp/aom_dsp_common.h"
 
 #if CONFIG_AV1_DECODER
-#include "aom_dsp/grain_synthesis.h"
+#include "av1/decoder/grain_synthesis.h"
 #endif
 
 #include "aom_dsp/grain_table.h"