Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: source/libvpx/vp9/common/vp9_treecoder.h

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/common/vp9_textblit.h ('k') | source/libvpx/vp9/common/vp9_treecoder.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/common/vp9_treecoder.h
===================================================================
--- source/libvpx/vp9/common/vp9_treecoder.h (revision 177019)
+++ source/libvpx/vp9/common/vp9_treecoder.h (working copy)
@@ -8,30 +8,19 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#ifndef VP9_COMMON_VP9_TREECODER_H_
#define VP9_COMMON_VP9_TREECODER_H_
-typedef unsigned char vp9_prob;
+#include "vpx/vpx_integer.h"
-#define vp9_prob_half ( (vp9_prob) 128)
+typedef uint8_t vp9_prob;
-typedef signed char vp9_tree_index;
-struct bool_coder_spec;
+#define vp9_prob_half ((vp9_prob) 128)
-typedef struct bool_coder_spec bool_coder_spec;
-typedef struct bool_writer bool_writer;
-typedef struct bool_reader bool_reader;
+typedef int8_t vp9_tree_index;
-typedef const bool_coder_spec c_bool_coder_spec;
-typedef const bool_writer c_bool_writer;
-typedef const bool_reader c_bool_reader;
+#define vp9_complement(x) (255 - x)
-
-
-# define vp9_complement( x) (255 - x)
-
-
/* We build coding trees compactly in arrays.
Each node of the tree is a pair of vp9_tree_indices.
Array index often references a corresponding probability table.
@@ -41,7 +30,6 @@
typedef const vp9_tree_index vp9_tree[], *vp9_tree_p;
-
typedef const struct vp9_token_struct {
int value;
int Len;
@@ -53,31 +41,33 @@
void vp9_tokens_from_tree_offset(struct vp9_token_struct *, vp9_tree,
int offset);
-
/* Convert array of token occurrence counts into a table of probabilities
for the associated binary encoding tree. Also writes count of branches
taken for each node on the tree; this facilitiates decisions as to
probability updates. */
-void vp9_tree_probs_from_distribution(
- int n, /* n = size of alphabet */
- vp9_token tok [ /* n */ ],
- vp9_tree tree,
- vp9_prob probs [ /* n-1 */ ],
- unsigned int branch_ct [ /* n-1 */ ] [2],
- const unsigned int num_events[ /* n */ ],
- unsigned int Pfactor,
- int Round
-);
+void vp9_tree_probs_from_distribution(int n, /* n = size of alphabet */
+ vp9_token tok[ /* n */ ],
+ vp9_tree tree,
+ vp9_prob probs[ /* n - 1 */ ],
+ unsigned int branch_ct[ /* n - 1 */ ][2],
+ const unsigned int num_events[ /* n */ ]);
-static __inline int clip_prob(int p) {
- if (p > 255)
- return 255;
- else if (p < 1)
- return 1;
- return p;
+static __inline vp9_prob clip_prob(int p) {
+ return (p > 255) ? 255u : (p < 1) ? 1u : p;
}
-vp9_prob vp9_bin_prob_from_distribution(const unsigned int counts[2]);
+static __inline vp9_prob get_prob(int num, int den) {
+ return (den == 0) ? 128u : clip_prob((num * 256 + (den >> 1)) / den);
+}
-#endif
+static __inline vp9_prob get_binary_prob(int n0, int n1) {
+ return get_prob(n0, n0 + n1);
+}
+
+/* this function assumes prob1 and prob2 are already within [1,255] range */
+static __inline vp9_prob weighted_prob(int prob1, int prob2, int factor) {
+ return (prob1 * (256 - factor) + prob2 * factor + 128) >> 8;
+}
+
+#endif // VP9_COMMON_VP9_TREECODER_H_
« no previous file with comments | « source/libvpx/vp9/common/vp9_textblit.h ('k') | source/libvpx/vp9/common/vp9_treecoder.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698