Commit d7efe068 authored by Dmitry Kovalev's avatar Dmitry Kovalev

Deleting vp9_treereader.h file.

Renaming treed_read() to consistent vp9_read_tree() and moving it from
deleted vp9_treereader.h to vp9_dboolhuff.h file.

Change-Id: Iedd8655acbe25e4fcf62b79e5a13bdea69b6b004
parent 5488da28
......@@ -18,32 +18,28 @@
// Even relatively modest values like 100 would work fine.
#define LOTS_OF_BITS 0x40000000
int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size) {
int marker_bit;
r->buffer_end = buffer + size;
r->buffer = buffer;
r->value = 0;
r->count = -8;
r->range = 255;
if (size && !buffer)
if (size && !buffer) {
return 1;
vp9_reader_fill(r);
marker_bit = vp9_read_bit(r);
return marker_bit != 0;
} else {
r->buffer_end = buffer + size;
r->buffer = buffer;
r->value = 0;
r->count = -8;
r->range = 255;
vp9_reader_fill(r);
return vp9_read_bit(r) != 0; // marker bit
}
}
void vp9_reader_fill(vp9_reader *r) {
const uint8_t *const buffer_end = r->buffer_end;
const uint8_t *buffer = r->buffer;
VP9_BD_VALUE value = r->value;
BD_VALUE value = r->value;
int count = r->count;
int shift = BD_VALUE_SIZE - 8 - (count + 8);
int shift = BD_VALUE_SIZE - CHAR_BIT - (count + CHAR_BIT);
int loop_end = 0;
const int bits_left = (int)((buffer_end - buffer)*CHAR_BIT);
const int bits_left = (int)((buffer_end - buffer) * CHAR_BIT);
const int x = shift + CHAR_BIT - bits_left;
if (x >= 0) {
......@@ -54,7 +50,7 @@ void vp9_reader_fill(vp9_reader *r) {
if (x < 0 || bits_left) {
while (shift >= loop_end) {
count += CHAR_BIT;
value |= (VP9_BD_VALUE)*buffer++ << shift;
value |= (BD_VALUE)*buffer++ << shift;
shift -= CHAR_BIT;
}
}
......
......@@ -18,46 +18,50 @@
#include "vpx_ports/mem.h"
#include "vpx/vpx_integer.h"
typedef size_t VP9_BD_VALUE;
#include "vp9/common/vp9_treecoder.h"
#define BD_VALUE_SIZE ((int)sizeof(VP9_BD_VALUE)*CHAR_BIT)
typedef size_t BD_VALUE;
#define BD_VALUE_SIZE ((int)sizeof(BD_VALUE) * CHAR_BIT)
DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
typedef struct {
const uint8_t *buffer_end;
const uint8_t *buffer;
VP9_BD_VALUE value;
BD_VALUE value;
int count;
unsigned int range;
} vp9_reader;
DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size);
void vp9_reader_fill(vp9_reader *r);
int vp9_reader_has_error(vp9_reader *r);
const uint8_t *vp9_reader_find_end(vp9_reader *r);
static int vp9_read(vp9_reader *br, int probability) {
static int vp9_read(vp9_reader *r, int prob) {
unsigned int bit = 0;
VP9_BD_VALUE value;
VP9_BD_VALUE bigsplit;
BD_VALUE value;
BD_VALUE bigsplit;
int count;
unsigned int range;
unsigned int split = ((br->range * probability) + (256 - probability)) >> 8;
unsigned int split = (r->range * prob + (256 - prob)) >> CHAR_BIT;
if (br->count < 0)
vp9_reader_fill(br);
if (r->count < 0)
vp9_reader_fill(r);
value = br->value;
count = br->count;
value = r->value;
count = r->count;
bigsplit = (VP9_BD_VALUE)split << (BD_VALUE_SIZE - 8);
bigsplit = (BD_VALUE)split << (BD_VALUE_SIZE - CHAR_BIT);
range = split;
if (value >= bigsplit) {
range = br->range - split;
range = r->range - split;
value = value - bigsplit;
bit = 1;
}
......@@ -68,9 +72,9 @@ static int vp9_read(vp9_reader *br, int probability) {
value <<= shift;
count -= shift;
}
br->value = value;
br->count = count;
br->range = range;
r->value = value;
r->count = count;
r->range = range;
return bit;
}
......@@ -79,15 +83,23 @@ static int vp9_read_bit(vp9_reader *r) {
return vp9_read(r, 128); // vp9_prob_half
}
static int vp9_read_literal(vp9_reader *br, int bits) {
int z = 0, bit;
static int vp9_read_literal(vp9_reader *r, int bits) {
int literal = 0, bit;
for (bit = bits - 1; bit >= 0; bit--)
z |= vp9_read_bit(br) << bit;
literal |= vp9_read_bit(r) << bit;
return z;
return literal;
}
int vp9_reader_has_error(vp9_reader *r);
static int vp9_read_tree(vp9_reader *r, const vp9_tree_index *tree,
const vp9_prob *probs) {
vp9_tree_index i = 0;
while ((i = tree[i + vp9_read(r, probs[i >> 1])]) > 0)
continue;
return -i;
}
#endif // VP9_DECODER_VP9_DBOOLHUFF_H_
......@@ -36,7 +36,6 @@
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_read_bit_buffer.h"
#include "vp9/decoder/vp9_thread.h"
#include "vp9/decoder/vp9_treereader.h"
typedef struct TileWorkerData {
VP9_COMMON *cm;
......@@ -473,7 +472,7 @@ static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd, int hbs,
PARTITION_TYPE p;
if (has_rows && has_cols)
p = treed_read(r, vp9_partition_tree, probs);
p = vp9_read_tree(r, vp9_partition_tree, probs);
else if (!has_rows && has_cols)
p = vp9_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ;
else if (has_rows && !has_cols)
......
......@@ -20,13 +20,13 @@
#include "vp9/common/vp9_reconinter.h"
#include "vp9/common/vp9_seg_common.h"
#include "vp9/decoder/vp9_dboolhuff.h"
#include "vp9/decoder/vp9_decodemv.h"
#include "vp9/decoder/vp9_decodeframe.h"
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_treereader.h"
static MB_PREDICTION_MODE read_intra_mode(vp9_reader *r, const vp9_prob *p) {
return (MB_PREDICTION_MODE)treed_read(r, vp9_intra_mode_tree, p);
return (MB_PREDICTION_MODE)vp9_read_tree(r, vp9_intra_mode_tree, p);
}
static MB_PREDICTION_MODE read_intra_mode_y(VP9_COMMON *cm, vp9_reader *r,
......@@ -49,8 +49,8 @@ static MB_PREDICTION_MODE read_intra_mode_uv(VP9_COMMON *cm, vp9_reader *r,
static MB_PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r,
int ctx) {
const int mode = treed_read(r, vp9_inter_mode_tree,
cm->fc.inter_mode_probs[ctx]);
const int mode = vp9_read_tree(r, vp9_inter_mode_tree,
cm->fc.inter_mode_probs[ctx]);
if (!cm->frame_parallel_decoding_mode)
++cm->counts.inter_mode[ctx][mode];
......@@ -58,7 +58,7 @@ static MB_PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r,
}
static int read_segment_id(vp9_reader *r, const struct segmentation *seg) {
return treed_read(r, vp9_segment_tree, seg->tree_probs);
return vp9_read_tree(r, vp9_segment_tree, seg->tree_probs);
}
static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
......@@ -210,12 +210,12 @@ static int read_mv_component(vp9_reader *r,
const nmv_component *mvcomp, int usehp) {
int mag, d, fr, hp;
const int sign = vp9_read(r, mvcomp->sign);
const int mv_class = treed_read(r, vp9_mv_class_tree, mvcomp->classes);
const int mv_class = vp9_read_tree(r, vp9_mv_class_tree, mvcomp->classes);
const int class0 = mv_class == MV_CLASS_0;
// Integer part
if (class0) {
d = treed_read(r, vp9_mv_class0_tree, mvcomp->class0);
d = vp9_read_tree(r, vp9_mv_class0_tree, mvcomp->class0);
} else {
int i;
const int n = mv_class + CLASS0_BITS - 1; // number of bits
......@@ -226,8 +226,8 @@ static int read_mv_component(vp9_reader *r,
}
// Fractional part
fr = treed_read(r, vp9_mv_fp_tree,
class0 ? mvcomp->class0_fp[d] : mvcomp->fp);
fr = vp9_read_tree(r, vp9_mv_fp_tree, class0 ? mvcomp->class0_fp[d]
: mvcomp->fp);
// High precision part (if hp is not used, the default value of the hp is 1)
......@@ -242,7 +242,7 @@ static int read_mv_component(vp9_reader *r,
static INLINE void read_mv(vp9_reader *r, MV *mv, const MV *ref,
const nmv_context *ctx,
nmv_context_counts *counts, int allow_hp) {
const MV_JOINT_TYPE j = treed_read(r, vp9_mv_joint_tree, ctx->joints);
const MV_JOINT_TYPE j = vp9_read_tree(r, vp9_mv_joint_tree, ctx->joints);
const int use_hp = allow_hp && vp9_use_mv_hp(ref);
MV diff = {0, 0};
......@@ -318,8 +318,8 @@ static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd,
static INLINE INTERPOLATION_TYPE read_switchable_filter_type(
VP9_COMMON *const cm, MACROBLOCKD *const xd, vp9_reader *r) {
const int ctx = vp9_get_pred_context_switchable_interp(xd);
const int type = treed_read(r, vp9_switchable_interp_tree,
cm->fc.switchable_interp_prob[ctx]);
const int type = vp9_read_tree(r, vp9_switchable_interp_tree,
cm->fc.switchable_interp_prob[ctx]);
if (!cm->frame_parallel_decoding_mode)
++cm->counts.switchable_interp[ctx][type];
return type;
......
......@@ -18,7 +18,6 @@
#include "vp9/decoder/vp9_dboolhuff.h"
#include "vp9/decoder/vp9_detokenize.h"
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_treereader.h"
#define EOB_CONTEXT_NODE 0
#define ZERO_CONTEXT_NODE 1
......
/*
* 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.
*/
#ifndef VP9_DECODER_VP9_TREEREADER_H_
#define VP9_DECODER_VP9_TREEREADER_H_
#include "vp9/common/vp9_treecoder.h"
#include "vp9/decoder/vp9_dboolhuff.h"
// Intent of tree data structure is to make decoding trivial.
static int treed_read(vp9_reader *const r, /* !!! must return a 0 or 1 !!! */
vp9_tree t,
const vp9_prob *const p) {
register vp9_tree_index i = 0;
while ((i = t[ i + vp9_read(r, p[i >> 1])]) > 0)
continue;
return -i;
}
#endif // VP9_DECODER_VP9_TREEREADER_H_
......@@ -30,7 +30,6 @@ VP9_DX_SRCS-yes += decoder/vp9_onyxd.h
VP9_DX_SRCS-yes += decoder/vp9_onyxd_int.h
VP9_DX_SRCS-yes += decoder/vp9_thread.c
VP9_DX_SRCS-yes += decoder/vp9_thread.h
VP9_DX_SRCS-yes += decoder/vp9_treereader.h
VP9_DX_SRCS-yes += decoder/vp9_onyxd_if.c
VP9_DX_SRCS-yes += decoder/vp9_dsubexp.c
VP9_DX_SRCS-yes += decoder/vp9_dsubexp.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment