2 * gstlibvpx.c - GStreamer/libvpx glue
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
13 #include <vp8/common/entropy.h>
14 #include <vp8/common/entropymv.h>
15 #include <vp8/common/default_coef_probs.h>
16 #include <vp8/decoder/dboolhuff.h>
17 #include "gstlibvpx.h"
19 #define BOOL_DECODER_CAST(bd) \
20 ((BOOL_DECODER *)(&(bd)->private[1]))
23 vp8_bool_decoder_init (vp8_bool_decoder * bd, const uint8_t * buf,
24 unsigned int buf_size)
26 assert ((sizeof (*bd) - sizeof (bd->private[0])) >= sizeof (BOOL_DECODER));
28 bd->private[0] = (uintptr_t)buf;
29 return vp8dx_start_decode (BOOL_DECODER_CAST (bd), buf, buf_size,
34 vp8_bool_decoder_read (vp8_bool_decoder * bd, uint8_t prob)
36 return vp8dx_decode_bool (BOOL_DECODER_CAST (bd), prob);
40 vp8_bool_decoder_read_literal (vp8_bool_decoder * bd, int bits)
42 return vp8_decode_value (BOOL_DECODER_CAST (bd), bits);
46 vp8_bool_decoder_get_pos (vp8_bool_decoder * bd_)
48 BOOL_DECODER *const bd = BOOL_DECODER_CAST (bd_);
50 return ((uintptr_t)bd->user_buffer - bd_->private[0]) * 8 - (8 + bd->count);
54 vp8_bool_decoder_get_state (vp8_bool_decoder * bd_,
55 vp8_bool_decoder_state * state)
57 BOOL_DECODER *const bd = BOOL_DECODER_CAST (bd_);
60 vp8dx_bool_decoder_fill (bd);
62 state->range = bd->range;
63 state->value = (uint8_t) ((bd->value) >> (VP8_BD_VALUE_SIZE - 8));
64 state->count = (8 + bd->count) % 8;
68 vp8_init_token_update_probs (uint8_t
69 probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES])
71 memcpy (probs, vp8_coef_update_probs, sizeof (vp8_coef_update_probs));
75 vp8_init_default_token_probs (uint8_t
76 probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES])
78 memcpy (probs, default_coef_probs, sizeof (default_coef_probs));
82 vp8_init_mv_update_probs (uint8_t probs[2][MVPcount])
84 memcpy (probs[0], vp8_mv_update_probs[0].prob,
85 sizeof (vp8_mv_update_probs[0].prob));
86 memcpy (probs[1], vp8_mv_update_probs[1].prob,
87 sizeof (vp8_mv_update_probs[1].prob));
91 vp8_init_default_mv_probs (uint8_t probs[2][MVPcount])
93 memcpy (probs[0], vp8_default_mv_context[0].prob,
94 sizeof (vp8_default_mv_context[0].prob));
95 memcpy (probs[1], vp8_default_mv_context[1].prob,
96 sizeof (vp8_default_mv_context[1].prob));
100 vp8_init_default_intra_mode_probs (uint8_t y_probs[VP8_YMODES-1],
101 uint8_t uv_probs[VP8_UV_MODES-1])
103 extern const uint8_t vp8_kf_ymode_prob[VP8_YMODES-1];
104 extern const uint8_t vp8_kf_uv_mode_prob[VP8_UV_MODES-1];
106 memcpy (y_probs, vp8_kf_ymode_prob, sizeof (vp8_kf_ymode_prob));
107 memcpy (uv_probs, vp8_kf_uv_mode_prob, sizeof (vp8_kf_uv_mode_prob));
111 vp8_init_default_inter_mode_probs (uint8_t y_probs[VP8_YMODES-1],
112 uint8_t uv_probs[VP8_UV_MODES-1])
114 extern const uint8_t vp8_ymode_prob[VP8_YMODES-1];
115 extern const uint8_t vp8_uv_mode_prob[VP8_UV_MODES-1];
117 memcpy (y_probs, vp8_ymode_prob, sizeof (vp8_ymode_prob));
118 memcpy (uv_probs, vp8_uv_mode_prob, sizeof (vp8_uv_mode_prob));