]> granicus.if.org Git - libvpx/commitdiff
Compute count_ls in vp9_kmeans
authorAngie Chiang <angiebird@google.com>
Sat, 16 Mar 2019 01:30:38 +0000 (18:30 -0700)
committerAngie Chiang <angiebird@google.com>
Mon, 18 Mar 2019 22:19:15 +0000 (15:19 -0700)
Change-Id: Id5a83554f2037b03a3a7d86f83e47cac311fbe1d

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_encodeframe.h
vp9/encoder/vp9_encoder.h

index d0ebbae8d297fe5b5baafe1f7da004aebcf1197a..9bf2fd189f1e44d7616a9b0b22e2363df7256925 100644 (file)
@@ -5714,8 +5714,8 @@ int vp9_get_group_idx(double value, double *boundary_ls, int k) {
   return group_idx;
 }
 
-void vp9_kmeans(double *ctr_ls, double *boundary_ls, int k, KMEANS_DATA *arr,
-                int size) {
+void vp9_kmeans(double *ctr_ls, double *boundary_ls, int *count_ls, int k,
+                KMEANS_DATA *arr, int size) {
   double min, max;
   double step;
   int i, j;
@@ -5765,7 +5765,10 @@ void vp9_kmeans(double *ctr_ls, double *boundary_ls, int k, KMEANS_DATA *arr,
     }
   }
 
-  // compute group_idx
+  // compute group_idx, boundary_ls and count_ls
+  for (j = 0; j < k; ++j) {
+    count_ls[j] = 0;
+  }
   compute_boundary_ls(ctr_ls, k, boundary_ls);
   group_idx = 0;
   for (i = 0; i < size; ++i) {
@@ -5776,6 +5779,7 @@ void vp9_kmeans(double *ctr_ls, double *boundary_ls, int k, KMEANS_DATA *arr,
       }
     }
     arr[i].group_idx = group_idx;
+    ++count_ls[group_idx];
   }
 }
 
@@ -5890,8 +5894,8 @@ static void encode_frame_internal(VP9_COMP *cpi) {
           wiener_var_rdmult(cpi, BLOCK_64X64, mi_row, mi_col, cpi->rd.RDMULT);
 
       vp9_kmeans(cpi->kmeans_ctr_ls, cpi->kmeans_boundary_ls,
-                 cpi->kmeans_ctr_num, cpi->kmeans_data_arr,
-                 cpi->kmeans_data_size);
+                 cpi->kmeans_count_ls, cpi->kmeans_ctr_num,
+                 cpi->kmeans_data_arr, cpi->kmeans_data_size);
 
       vp9_perceptual_aq_mode_setup(cpi, &cm->seg);
     }
index 29a56b923cf496fab1555473c5328c44be03bd56..fd0a9c517ef0a639e3deffd1b091c27ba6f1ba9a 100644 (file)
@@ -46,7 +46,7 @@ void vp9_set_variance_partition_thresholds(struct VP9_COMP *cpi, int q,
                                            int content_state);
 
 struct KMEANS_DATA;
-void vp9_kmeans(double *ctr_ls, double *boundary_ls, int k,
+void vp9_kmeans(double *ctr_ls, double *boundary_ls, int *count_ls, int k,
                 struct KMEANS_DATA *arr, int size);
 int vp9_get_group_idx(double value, double *boundary_ls, int k);
 
index 567f05934c388695979f98a368e571acc9c4c9ca..67d764f80991d78dd318f343ec605d333b62d206 100644 (file)
@@ -611,6 +611,7 @@ typedef struct VP9_COMP {
   int kmeans_data_stride;
   double kmeans_ctr_ls[MAX_KMEANS_GROUPS];
   double kmeans_boundary_ls[MAX_KMEANS_GROUPS];
+  int kmeans_count_ls[MAX_KMEANS_GROUPS];
   int kmeans_ctr_num;
 #if CONFIG_NON_GREEDY_MV
   int tpl_ready;