Bug 1430188: av1: Mark AOM_QM matricies const. r?kinetik. draft
authorRalph Giles <giles@mozilla.com>
Mon, 15 Jan 2018 09:08:18 -0800
changeset 720491 c27c20eb172d44b3fc40ea3427a9d7c5618f181d
parent 720403 a00e3a3dbad43759ee9474d6c7c908fa16deaee8
child 746084 0d09b7ff8afa5a6c9ef9b6d8ce78160d62e8a5f2
push id95565
push userbmo:giles@thaumas.net
push dateMon, 15 Jan 2018 18:11:10 +0000
reviewerskinetik
bugs1430188
milestone59.0a1
Bug 1430188: av1: Mark AOM_QM matricies const. r?kinetik. These large (200 KB) static stables are functionally read-only. Marking them const moves them to the read-only section of shared libraries, reducing memory footprint when multiple application processes are running simultaneously. This is a backport of the upstream commit 90243cf9e670. MozReview-Commit-ID: 319jjpgNlTI
third_party/aom/av1/common/onyxc_int.h
third_party/aom/av1/common/quant_common.c
third_party/aom/av1/common/quant_common.h
--- a/third_party/aom/av1/common/onyxc_int.h
+++ b/third_party/aom/av1/common/onyxc_int.h
@@ -305,25 +305,25 @@ typedef struct AV1Common {
   int y_dc_delta_q;
   int uv_dc_delta_q;
   int uv_ac_delta_q;
   int16_t y_dequant[MAX_SEGMENTS][2];
   int16_t uv_dequant[MAX_SEGMENTS][2];
 
 #if CONFIG_AOM_QM
   // Global quant matrix tables
-  qm_val_t *giqmatrix[NUM_QM_LEVELS][2][2][TX_SIZES_ALL];
-  qm_val_t *gqmatrix[NUM_QM_LEVELS][2][2][TX_SIZES_ALL];
+  const qm_val_t *giqmatrix[NUM_QM_LEVELS][2][2][TX_SIZES_ALL];
+  const qm_val_t *gqmatrix[NUM_QM_LEVELS][2][2][TX_SIZES_ALL];
 
   // Local quant matrix tables for each frame
-  qm_val_t *y_iqmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
-  qm_val_t *uv_iqmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
+  const qm_val_t *y_iqmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
+  const qm_val_t *uv_iqmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
   // Encoder
-  qm_val_t *y_qmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
-  qm_val_t *uv_qmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
+  const qm_val_t *y_qmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
+  const qm_val_t *uv_qmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
 
   int using_qmatrix;
   int min_qmlevel;
   int max_qmlevel;
 #endif
 #if CONFIG_NEW_QUANT
   dequant_val_type_nuq y_dequant_nuq[MAX_SEGMENTS][QUANT_PROFILES][COEF_BANDS];
   dequant_val_type_nuq uv_dequant_nuq[MAX_SEGMENTS][QUANT_PROFILES][COEF_BANDS];
--- a/third_party/aom/av1/common/quant_common.c
+++ b/third_party/aom/av1/common/quant_common.c
@@ -337,32 +337,32 @@ int av1_get_qindex(const struct segmenta
         seg->abs_delta == SEGMENT_ABSDATA ? data : base_qindex + data;
     return clamp(seg_qindex, 0, MAXQ);
   } else {
     return base_qindex;
   }
 }
 
 #if CONFIG_AOM_QM
-qm_val_t *aom_iqmatrix(AV1_COMMON *cm, int qmlevel, int is_chroma,
+const qm_val_t *aom_iqmatrix(AV1_COMMON *cm, int qmlevel, int is_chroma,
                        TX_SIZE tx_size, int is_intra) {
   return &cm->giqmatrix[qmlevel][!!is_chroma][!!is_intra][tx_size][0];
 }
-qm_val_t *aom_qmatrix(AV1_COMMON *cm, int qmlevel, int is_chroma,
+const qm_val_t *aom_qmatrix(AV1_COMMON *cm, int qmlevel, int is_chroma,
                       TX_SIZE tx_size, int is_intra) {
   return &cm->gqmatrix[qmlevel][!!is_chroma][!!is_intra][tx_size][0];
 }
 
 #if CONFIG_CHROMA_2X2
 #define QM_TOTAL_SIZE 3348
 #else
 #define QM_TOTAL_SIZE 3344
 #endif
-static uint16_t wt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
-static uint16_t iwt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
+static const uint16_t wt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
+static const uint16_t iwt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
 
 void aom_qm_init(AV1_COMMON *cm) {
   int q, c, f, t;
   int current;
   for (q = 0; q < NUM_QM_LEVELS; ++q) {
     for (c = 0; c < 2; ++c) {
       for (f = 0; f < 2; ++f) {
         current = 0;
@@ -394,17 +394,17 @@ void aom_qm_init(AV1_COMMON *cm) {
    defined here for convenience. Intra and inter matrix sets are the
    same but changing DEFAULT_QM_INTER_OFFSET from zero allows
    for different matrices for inter and intra blocks in the same
    frame.
    Matrices for different QM levels have been rescaled in the
    frequency domain according to different nominal viewing
    distances.
  */
-static uint16_t iwt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE] = {
+static const uint16_t iwt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE] = {
   {
       { /* Luma */
 #if CONFIG_CHROMA_2X2
         /* Size 2x2 */
         43, 86, 86, 166,
 #endif
         /* Size 4x4 */
         32, 43, 73, 97, 43, 67, 94, 110, 73, 94, 137, 150, 97, 110, 150, 200,
@@ -7290,17 +7290,17 @@ static uint16_t iwt_matrix_ref[NUM_QM_LE
         32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         32, 32, 32, 32 },
   },
 };
 
-static uint16_t wt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE] = {
+static const uint16_t wt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE] = {
   {
       { /* Luma */
 #if CONFIG_CHROMA_2X2
         /* Size 2x2 */
         24, 12, 12, 6,
 #endif
         /* Size 4x4 */
         32, 24, 14, 11, 24, 15, 11, 9, 14, 11, 7, 7, 11, 9, 7, 5,
--- a/third_party/aom/av1/common/quant_common.h
+++ b/third_party/aom/av1/common/quant_common.h
@@ -46,19 +46,19 @@ int av1_get_qindex(const struct segmenta
                    int base_qindex);
 #if CONFIG_AOM_QM
 // Reduce the large number of quantizers to a smaller number of levels for which
 // different matrices may be defined
 static INLINE int aom_get_qmlevel(int qindex, int first, int last) {
   return first + (qindex * (last + 1 - first)) / QINDEX_RANGE;
 }
 void aom_qm_init(struct AV1Common *cm);
-qm_val_t *aom_iqmatrix(struct AV1Common *cm, int qindex, int comp,
+const qm_val_t *aom_iqmatrix(struct AV1Common *cm, int qindex, int comp,
                        TX_SIZE tx_size, int is_intra);
-qm_val_t *aom_qmatrix(struct AV1Common *cm, int qindex, int comp,
+const qm_val_t *aom_qmatrix(struct AV1Common *cm, int qindex, int comp,
                       TX_SIZE tx_size, int is_intra);
 #endif
 
 #if CONFIG_NEW_QUANT
 
 #define QUANT_PROFILES 4
 #define QUANT_RANGES 2
 #define NUQ_KNOTS 3