]> granicus.if.org Git - libvpx/commitdiff
Moving vp9_tree_probs_from_distribution() to encoder.
authorDmitry Kovalev <dkovalev@google.com>
Fri, 6 Dec 2013 02:13:26 +0000 (18:13 -0800)
committerDmitry Kovalev <dkovalev@google.com>
Fri, 6 Dec 2013 02:13:26 +0000 (18:13 -0800)
Writing custom coeff branch count calculation (which is much clearer) in
adapt_coef_probs() function. Removing vp9_treecoder.c file.

Change-Id: I8880fb7a39996c8bcf6cd0acf9898a8c712ba91f

vp9/common/vp9_entropy.c
vp9/common/vp9_treecoder.c [deleted file]
vp9/common/vp9_treecoder.h
vp9/encoder/vp9_treewriter.c
vp9/encoder/vp9_treewriter.h
vp9/vp9_common.mk

index cce05d0e5ee2324909e8f38a94f319bb54180655..d89f70d648015e4ca355c2cf49360a689975a6f1 100644 (file)
@@ -756,27 +756,30 @@ static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE tx_size,
                              unsigned int count_sat,
                              unsigned int update_factor) {
   const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
-
-  vp9_coeff_probs_model *dst_coef_probs = cm->fc.coef_probs[tx_size];
-  const vp9_coeff_probs_model *pre_coef_probs = pre_fc->coef_probs[tx_size];
-  vp9_coeff_count_model *coef_counts = cm->counts.coef[tx_size];
-  unsigned int (*eob_branch_count)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
+  vp9_coeff_probs_model *const probs = cm->fc.coef_probs[tx_size];
+  const vp9_coeff_probs_model *const pre_probs = pre_fc->coef_probs[tx_size];
+  vp9_coeff_count_model *counts = cm->counts.coef[tx_size];
+  unsigned int (*eob_counts)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
       cm->counts.eob_branch[tx_size];
   int i, j, k, l, m;
-  unsigned int branch_ct[UNCONSTRAINED_NODES][2];
 
   for (i = 0; i < BLOCK_TYPES; ++i)
     for (j = 0; j < REF_TYPES; ++j)
       for (k = 0; k < COEF_BANDS; ++k)
         for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
-          vp9_tree_probs_from_distribution(vp9_coefmodel_tree, branch_ct,
-                                           coef_counts[i][j][k][l]);
-          branch_ct[0][1] = eob_branch_count[i][j][k][l] - branch_ct[0][0];
+          const int n0 = counts[i][j][k][l][ZERO_TOKEN];
+          const int n1 = counts[i][j][k][l][ONE_TOKEN];
+          const int n2 = counts[i][j][k][l][TWO_TOKEN];
+          const int neob = counts[i][j][k][l][EOB_MODEL_TOKEN];
+          const unsigned int branch_ct[UNCONSTRAINED_NODES][2] = {
+            { neob, eob_counts[i][j][k][l] - neob },
+            { n0, n1 + n2 },
+            { n1, n2 }
+          };
           for (m = 0; m < UNCONSTRAINED_NODES; ++m)
-            dst_coef_probs[i][j][k][l][m] = merge_probs(
-                                                pre_coef_probs[i][j][k][l][m],
-                                                branch_ct[m],
-                                                count_sat, update_factor);
+            probs[i][j][k][l][m] = merge_probs(pre_probs[i][j][k][l][m],
+                                               branch_ct[m],
+                                               count_sat, update_factor);
         }
 }
 
diff --git a/vp9/common/vp9_treecoder.c b/vp9/common/vp9_treecoder.c
deleted file mode 100644 (file)
index dca3076..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-
-#include <assert.h>
-
-#include "./vpx_config.h"
-#include "vp9/common/vp9_treecoder.h"
-
-static unsigned int convert_distribution(unsigned int i, vp9_tree tree,
-                                         unsigned int branch_ct[][2],
-                                         const unsigned int num_events[]) {
-  unsigned int left, right;
-
-  if (tree[i] <= 0)
-    left = num_events[-tree[i]];
-  else
-    left = convert_distribution(tree[i], tree, branch_ct, num_events);
-
-  if (tree[i + 1] <= 0)
-    right = num_events[-tree[i + 1]];
-  else
-    right = convert_distribution(tree[i + 1], tree, branch_ct, num_events);
-
-  branch_ct[i >> 1][0] = left;
-  branch_ct[i >> 1][1] = right;
-  return left + right;
-}
-
-void vp9_tree_probs_from_distribution(vp9_tree tree,
-                                      unsigned int branch_ct[/* n-1 */][2],
-                                      const unsigned int num_events[/* n */]) {
-  convert_distribution(0, tree, branch_ct, num_events);
-}
-
-
index bbe4e8f6adb7dfd0142b959c11bb0008c0fa38bf..ed8c74ae017ca3aaa4d8b78bfcd405d5ce482d5a 100644 (file)
@@ -39,11 +39,6 @@ typedef const vp9_tree_index vp9_tree[];
    taken for each node on the tree; this facilitiates decisions as to
    probability updates. */
 
-void vp9_tree_probs_from_distribution(vp9_tree tree,
-                                      unsigned int branch_ct[ /* n - 1 */ ][2],
-                                      const unsigned int num_events[ /* n */ ]);
-
-
 static INLINE vp9_prob clip_prob(int p) {
   return (p > 255) ? 255u : (p < 1) ? 1u : p;
 }
index 5b0c17fe7a217b370c23ac36798b740d4a8ad650..35e5a8fd07982093b418ac48e1214a8bf4d7ad6a 100644 (file)
@@ -57,3 +57,29 @@ void vp9_tokens_from_tree(struct vp9_token *tokens,
                           const vp9_tree_index *tree) {
   tree2tok(tokens, tree, 0, 0, 0);
 }
+
+static unsigned int convert_distribution(unsigned int i, vp9_tree tree,
+                                         unsigned int branch_ct[][2],
+                                         const unsigned int num_events[]) {
+  unsigned int left, right;
+
+  if (tree[i] <= 0)
+    left = num_events[-tree[i]];
+  else
+    left = convert_distribution(tree[i], tree, branch_ct, num_events);
+
+  if (tree[i + 1] <= 0)
+    right = num_events[-tree[i + 1]];
+  else
+    right = convert_distribution(tree[i + 1], tree, branch_ct, num_events);
+
+  branch_ct[i >> 1][0] = left;
+  branch_ct[i >> 1][1] = right;
+  return left + right;
+}
+
+void vp9_tree_probs_from_distribution(vp9_tree tree,
+                                      unsigned int branch_ct[/* n-1 */][2],
+                                      const unsigned int num_events[/* n */]) {
+  convert_distribution(0, tree, branch_ct, num_events);
+}
index 94f3eb987ceb1dd5b08eb9f10cf94fe1d6b9ab93..a2f9df139fc8d94501975aabffaa9d0c5513bbf4 100644 (file)
@@ -75,4 +75,8 @@ static INLINE int treed_cost(vp9_tree tree, const vp9_prob *probs,
 void vp9_cost_tokens(int *costs, const vp9_prob *probs, vp9_tree tree);
 void vp9_cost_tokens_skip(int *costs, const vp9_prob *probs, vp9_tree tree);
 
+void vp9_tree_probs_from_distribution(vp9_tree tree,
+                                      unsigned int branch_ct[ /* n - 1 */ ][2],
+                                      const unsigned int num_events[ /* n */ ]);
+
 #endif  // VP9_ENCODER_VP9_TREEWRITER_H_
index f6aebff0c3eb45daddf5840f38e3709f0f7cda7b..01c55a4ada68b065a780fc4a536c619305186483 100644 (file)
@@ -61,7 +61,6 @@ VP9_COMMON_SRCS-yes += common/vp9_quant_common.c
 VP9_COMMON_SRCS-yes += common/vp9_reconinter.c
 VP9_COMMON_SRCS-yes += common/vp9_reconintra.c
 VP9_COMMON_SRCS-$(CONFIG_POSTPROC_VISUALIZER) += common/vp9_textblit.c
-VP9_COMMON_SRCS-yes += common/vp9_treecoder.c
 VP9_COMMON_SRCS-yes += common/vp9_common_data.c
 VP9_COMMON_SRCS-yes += common/vp9_common_data.h
 VP9_COMMON_SRCS-yes += common/vp9_scan.c