2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
13 * \brief Describes film grain parameters
16 #ifndef AOM_AOM_DSP_GRAIN_PARAMS_H_
17 #define AOM_AOM_DSP_GRAIN_PARAMS_H_
26 #include "config/aom_config.h"
28 /*!\brief Structure containing film grain synthesis parameters for a frame
30 * This structure contains input parameters for film grain synthesis
33 // This structure is compared element-by-element in the function
34 // aom_check_grain_params_equiv: this function must be updated if any changes
35 // are made to this structure.
38 int update_parameters
;
41 int scaling_points_y
[14][2];
42 int num_y_points
; // value: 0..14
45 int scaling_points_cb
[10][2];
46 int num_cb_points
; // value: 0..10
49 int scaling_points_cr
[10][2];
50 int num_cr_points
; // value: 0..10
52 int scaling_shift
; // values : 8..11
54 int ar_coeff_lag
; // values: 0..3
61 // Shift value: AR coeffs range
66 int ar_coeff_shift
; // values : 6..9
68 int cb_mult
; // 8 bits
69 int cb_luma_mult
; // 8 bits
70 int cb_offset
; // 9 bits
72 int cr_mult
; // 8 bits
73 int cr_luma_mult
; // 8 bits
74 int cr_offset
; // 9 bits
78 int clip_to_restricted_range
;
80 unsigned int bit_depth
; // video bit depth
82 int chroma_scaling_from_luma
;
84 int grain_scale_shift
;
87 // This structure is compared element-by-element in the function
88 // aom_check_grain_params_equiv: this function must be updated if any changes
89 // are made to this structure.
92 /*!\brief Check if two film grain parameters structs are equivalent
94 * Check if two film grain parameters are equal, except for the
95 * update_parameters and random_seed elements which are ignored.
97 * \param[in] pa The first set of parameters to compare
98 * \param[in] pb The second set of parameters to compare
99 * \return Returns 1 if the params are equivalent, 0 otherwise
101 static INLINE
int aom_check_grain_params_equiv(
102 const aom_film_grain_t
*const pa
, const aom_film_grain_t
*const pb
) {
103 if (pa
->apply_grain
!= pb
->apply_grain
) return 0;
104 // Don't compare update_parameters
106 if (pa
->num_y_points
!= pb
->num_y_points
) return 0;
107 if (memcmp(pa
->scaling_points_y
, pb
->scaling_points_y
,
108 pa
->num_y_points
* 2 * sizeof(*pa
->scaling_points_y
)) != 0)
111 if (pa
->num_cb_points
!= pb
->num_cb_points
) return 0;
112 if (memcmp(pa
->scaling_points_cb
, pb
->scaling_points_cb
,
113 pa
->num_cb_points
* 2 * sizeof(*pa
->scaling_points_cb
)) != 0)
116 if (pa
->num_cr_points
!= pb
->num_cr_points
) return 0;
117 if (memcmp(pa
->scaling_points_cr
, pb
->scaling_points_cr
,
118 pa
->num_cr_points
* 2 * sizeof(*pa
->scaling_points_cr
)) != 0)
121 if (pa
->scaling_shift
!= pb
->scaling_shift
) return 0;
122 if (pa
->ar_coeff_lag
!= pb
->ar_coeff_lag
) return 0;
124 const int num_pos
= 2 * pa
->ar_coeff_lag
* (pa
->ar_coeff_lag
+ 1);
125 if (memcmp(pa
->ar_coeffs_y
, pb
->ar_coeffs_y
,
126 num_pos
* sizeof(*pa
->ar_coeffs_y
)) != 0)
128 if (memcmp(pa
->ar_coeffs_cb
, pb
->ar_coeffs_cb
,
129 num_pos
* sizeof(*pa
->ar_coeffs_cb
)) != 0)
131 if (memcmp(pa
->ar_coeffs_cr
, pb
->ar_coeffs_cr
,
132 num_pos
* sizeof(*pa
->ar_coeffs_cr
)) != 0)
135 if (pa
->ar_coeff_shift
!= pb
->ar_coeff_shift
) return 0;
137 if (pa
->cb_mult
!= pb
->cb_mult
) return 0;
138 if (pa
->cb_luma_mult
!= pb
->cb_luma_mult
) return 0;
139 if (pa
->cb_offset
!= pb
->cb_offset
) return 0;
141 if (pa
->cr_mult
!= pb
->cr_mult
) return 0;
142 if (pa
->cr_luma_mult
!= pb
->cr_luma_mult
) return 0;
143 if (pa
->cr_offset
!= pb
->cr_offset
) return 0;
145 if (pa
->overlap_flag
!= pb
->overlap_flag
) return 0;
146 if (pa
->clip_to_restricted_range
!= pb
->clip_to_restricted_range
) return 0;
147 if (pa
->bit_depth
!= pb
->bit_depth
) return 0;
148 if (pa
->chroma_scaling_from_luma
!= pb
->chroma_scaling_from_luma
) return 0;
149 if (pa
->grain_scale_shift
!= pb
->grain_scale_shift
) return 0;
158 #endif // AOM_AOM_DSP_GRAIN_PARAMS_H_