media/libvpx/vp8/common/treecoder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp8/common/treecoder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,90 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +
    1.15 +#ifndef __INC_TREECODER_H
    1.16 +#define __INC_TREECODER_H
    1.17 +
    1.18 +typedef unsigned char vp8bc_index_t; /* probability index */
    1.19 +
    1.20 +
    1.21 +typedef unsigned char vp8_prob;
    1.22 +
    1.23 +#define vp8_prob_half ( (vp8_prob) 128)
    1.24 +
    1.25 +typedef signed char vp8_tree_index;
    1.26 +struct bool_coder_spec;
    1.27 +
    1.28 +typedef struct bool_coder_spec bool_coder_spec;
    1.29 +typedef struct bool_writer bool_writer;
    1.30 +typedef struct bool_reader bool_reader;
    1.31 +
    1.32 +typedef const bool_coder_spec c_bool_coder_spec;
    1.33 +typedef const bool_writer c_bool_writer;
    1.34 +typedef const bool_reader c_bool_reader;
    1.35 +
    1.36 +
    1.37 +
    1.38 +# define vp8_complement( x) (255 - x)
    1.39 +
    1.40 +
    1.41 +/* We build coding trees compactly in arrays.
    1.42 +   Each node of the tree is a pair of vp8_tree_indices.
    1.43 +   Array index often references a corresponding probability table.
    1.44 +   Index <= 0 means done encoding/decoding and value = -Index,
    1.45 +   Index > 0 means need another bit, specification at index.
    1.46 +   Nonnegative indices are always even;  processing begins at node 0. */
    1.47 +
    1.48 +typedef const vp8_tree_index vp8_tree[], *vp8_tree_p;
    1.49 +
    1.50 +
    1.51 +typedef const struct vp8_token_struct
    1.52 +{
    1.53 +    int value;
    1.54 +    int Len;
    1.55 +} vp8_token;
    1.56 +
    1.57 +/* Construct encoding array from tree. */
    1.58 +
    1.59 +void vp8_tokens_from_tree(struct vp8_token_struct *, vp8_tree);
    1.60 +void vp8_tokens_from_tree_offset(struct vp8_token_struct *, vp8_tree,
    1.61 +                                 int offset);
    1.62 +
    1.63 +
    1.64 +/* Convert array of token occurrence counts into a table of probabilities
    1.65 +   for the associated binary encoding tree.  Also writes count of branches
    1.66 +   taken for each node on the tree; this facilitiates decisions as to
    1.67 +   probability updates. */
    1.68 +
    1.69 +void vp8_tree_probs_from_distribution(
    1.70 +    int n,                      /* n = size of alphabet */
    1.71 +    vp8_token tok               [ /* n */ ],
    1.72 +    vp8_tree tree,
    1.73 +    vp8_prob probs          [ /* n-1 */ ],
    1.74 +    unsigned int branch_ct       [ /* n-1 */ ] [2],
    1.75 +    const unsigned int num_events[ /* n */ ],
    1.76 +    unsigned int Pfactor,
    1.77 +    int Round
    1.78 +);
    1.79 +
    1.80 +/* Variant of above using coder spec rather than hardwired 8-bit probs. */
    1.81 +
    1.82 +void vp8bc_tree_probs_from_distribution(
    1.83 +    int n,                      /* n = size of alphabet */
    1.84 +    vp8_token tok               [ /* n */ ],
    1.85 +    vp8_tree tree,
    1.86 +    vp8_prob probs          [ /* n-1 */ ],
    1.87 +    unsigned int branch_ct       [ /* n-1 */ ] [2],
    1.88 +    const unsigned int num_events[ /* n */ ],
    1.89 +    c_bool_coder_spec *s
    1.90 +);
    1.91 +
    1.92 +
    1.93 +#endif

mercurial