Merge "Deleting vp9_treereader.h file."
This commit is contained in:
commit
4622cd14c2
@ -18,32 +18,28 @@
|
|||||||
// Even relatively modest values like 100 would work fine.
|
// Even relatively modest values like 100 would work fine.
|
||||||
#define LOTS_OF_BITS 0x40000000
|
#define LOTS_OF_BITS 0x40000000
|
||||||
|
|
||||||
|
|
||||||
int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size) {
|
int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size) {
|
||||||
int marker_bit;
|
if (size && !buffer) {
|
||||||
|
|
||||||
r->buffer_end = buffer + size;
|
|
||||||
r->buffer = buffer;
|
|
||||||
r->value = 0;
|
|
||||||
r->count = -8;
|
|
||||||
r->range = 255;
|
|
||||||
|
|
||||||
if (size && !buffer)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
} else {
|
||||||
vp9_reader_fill(r);
|
r->buffer_end = buffer + size;
|
||||||
marker_bit = vp9_read_bit(r);
|
r->buffer = buffer;
|
||||||
return marker_bit != 0;
|
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) {
|
void vp9_reader_fill(vp9_reader *r) {
|
||||||
const uint8_t *const buffer_end = r->buffer_end;
|
const uint8_t *const buffer_end = r->buffer_end;
|
||||||
const uint8_t *buffer = r->buffer;
|
const uint8_t *buffer = r->buffer;
|
||||||
VP9_BD_VALUE value = r->value;
|
BD_VALUE value = r->value;
|
||||||
int count = r->count;
|
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;
|
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;
|
const int x = shift + CHAR_BIT - bits_left;
|
||||||
|
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
@ -54,7 +50,7 @@ void vp9_reader_fill(vp9_reader *r) {
|
|||||||
if (x < 0 || bits_left) {
|
if (x < 0 || bits_left) {
|
||||||
while (shift >= loop_end) {
|
while (shift >= loop_end) {
|
||||||
count += CHAR_BIT;
|
count += CHAR_BIT;
|
||||||
value |= (VP9_BD_VALUE)*buffer++ << shift;
|
value |= (BD_VALUE)*buffer++ << shift;
|
||||||
shift -= CHAR_BIT;
|
shift -= CHAR_BIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,46 +18,50 @@
|
|||||||
#include "vpx_ports/mem.h"
|
#include "vpx_ports/mem.h"
|
||||||
#include "vpx/vpx_integer.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 {
|
typedef struct {
|
||||||
const uint8_t *buffer_end;
|
const uint8_t *buffer_end;
|
||||||
const uint8_t *buffer;
|
const uint8_t *buffer;
|
||||||
VP9_BD_VALUE value;
|
BD_VALUE value;
|
||||||
int count;
|
int count;
|
||||||
unsigned int range;
|
unsigned int range;
|
||||||
} vp9_reader;
|
} 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);
|
int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size);
|
||||||
|
|
||||||
void vp9_reader_fill(vp9_reader *r);
|
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);
|
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;
|
unsigned int bit = 0;
|
||||||
VP9_BD_VALUE value;
|
BD_VALUE value;
|
||||||
VP9_BD_VALUE bigsplit;
|
BD_VALUE bigsplit;
|
||||||
int count;
|
int count;
|
||||||
unsigned int range;
|
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)
|
if (r->count < 0)
|
||||||
vp9_reader_fill(br);
|
vp9_reader_fill(r);
|
||||||
|
|
||||||
value = br->value;
|
value = r->value;
|
||||||
count = br->count;
|
count = r->count;
|
||||||
|
|
||||||
bigsplit = (VP9_BD_VALUE)split << (BD_VALUE_SIZE - 8);
|
bigsplit = (BD_VALUE)split << (BD_VALUE_SIZE - CHAR_BIT);
|
||||||
|
|
||||||
range = split;
|
range = split;
|
||||||
|
|
||||||
if (value >= bigsplit) {
|
if (value >= bigsplit) {
|
||||||
range = br->range - split;
|
range = r->range - split;
|
||||||
value = value - bigsplit;
|
value = value - bigsplit;
|
||||||
bit = 1;
|
bit = 1;
|
||||||
}
|
}
|
||||||
@ -68,9 +72,9 @@ static int vp9_read(vp9_reader *br, int probability) {
|
|||||||
value <<= shift;
|
value <<= shift;
|
||||||
count -= shift;
|
count -= shift;
|
||||||
}
|
}
|
||||||
br->value = value;
|
r->value = value;
|
||||||
br->count = count;
|
r->count = count;
|
||||||
br->range = range;
|
r->range = range;
|
||||||
|
|
||||||
return bit;
|
return bit;
|
||||||
}
|
}
|
||||||
@ -79,15 +83,23 @@ static int vp9_read_bit(vp9_reader *r) {
|
|||||||
return vp9_read(r, 128); // vp9_prob_half
|
return vp9_read(r, 128); // vp9_prob_half
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vp9_read_literal(vp9_reader *br, int bits) {
|
static int vp9_read_literal(vp9_reader *r, int bits) {
|
||||||
int z = 0, bit;
|
int literal = 0, bit;
|
||||||
|
|
||||||
for (bit = bits - 1; bit >= 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_
|
#endif // VP9_DECODER_VP9_DBOOLHUFF_H_
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "vp9/decoder/vp9_onyxd_int.h"
|
#include "vp9/decoder/vp9_onyxd_int.h"
|
||||||
#include "vp9/decoder/vp9_read_bit_buffer.h"
|
#include "vp9/decoder/vp9_read_bit_buffer.h"
|
||||||
#include "vp9/decoder/vp9_thread.h"
|
#include "vp9/decoder/vp9_thread.h"
|
||||||
#include "vp9/decoder/vp9_treereader.h"
|
|
||||||
|
|
||||||
typedef struct TileWorkerData {
|
typedef struct TileWorkerData {
|
||||||
VP9_COMMON *cm;
|
VP9_COMMON *cm;
|
||||||
@ -473,7 +472,7 @@ static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd, int hbs,
|
|||||||
PARTITION_TYPE p;
|
PARTITION_TYPE p;
|
||||||
|
|
||||||
if (has_rows && has_cols)
|
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)
|
else if (!has_rows && has_cols)
|
||||||
p = vp9_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ;
|
p = vp9_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ;
|
||||||
else if (has_rows && !has_cols)
|
else if (has_rows && !has_cols)
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
#include "vp9/common/vp9_reconinter.h"
|
#include "vp9/common/vp9_reconinter.h"
|
||||||
#include "vp9/common/vp9_seg_common.h"
|
#include "vp9/common/vp9_seg_common.h"
|
||||||
|
|
||||||
|
#include "vp9/decoder/vp9_dboolhuff.h"
|
||||||
#include "vp9/decoder/vp9_decodemv.h"
|
#include "vp9/decoder/vp9_decodemv.h"
|
||||||
#include "vp9/decoder/vp9_decodeframe.h"
|
#include "vp9/decoder/vp9_decodeframe.h"
|
||||||
#include "vp9/decoder/vp9_onyxd_int.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) {
|
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,
|
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,
|
static MB_PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r,
|
||||||
int ctx) {
|
int ctx) {
|
||||||
const int mode = treed_read(r, vp9_inter_mode_tree,
|
const int mode = vp9_read_tree(r, vp9_inter_mode_tree,
|
||||||
cm->fc.inter_mode_probs[ctx]);
|
cm->fc.inter_mode_probs[ctx]);
|
||||||
if (!cm->frame_parallel_decoding_mode)
|
if (!cm->frame_parallel_decoding_mode)
|
||||||
++cm->counts.inter_mode[ctx][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) {
|
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,
|
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) {
|
const nmv_component *mvcomp, int usehp) {
|
||||||
int mag, d, fr, hp;
|
int mag, d, fr, hp;
|
||||||
const int sign = vp9_read(r, mvcomp->sign);
|
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;
|
const int class0 = mv_class == MV_CLASS_0;
|
||||||
|
|
||||||
// Integer part
|
// Integer part
|
||||||
if (class0) {
|
if (class0) {
|
||||||
d = treed_read(r, vp9_mv_class0_tree, mvcomp->class0);
|
d = vp9_read_tree(r, vp9_mv_class0_tree, mvcomp->class0);
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
const int n = mv_class + CLASS0_BITS - 1; // number of bits
|
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
|
// Fractional part
|
||||||
fr = treed_read(r, vp9_mv_fp_tree,
|
fr = vp9_read_tree(r, vp9_mv_fp_tree, class0 ? mvcomp->class0_fp[d]
|
||||||
class0 ? mvcomp->class0_fp[d] : mvcomp->fp);
|
: mvcomp->fp);
|
||||||
|
|
||||||
|
|
||||||
// High precision part (if hp is not used, the default value of the hp is 1)
|
// 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,
|
static INLINE void read_mv(vp9_reader *r, MV *mv, const MV *ref,
|
||||||
const nmv_context *ctx,
|
const nmv_context *ctx,
|
||||||
nmv_context_counts *counts, int allow_hp) {
|
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);
|
const int use_hp = allow_hp && vp9_use_mv_hp(ref);
|
||||||
MV diff = {0, 0};
|
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(
|
static INLINE INTERPOLATION_TYPE read_switchable_filter_type(
|
||||||
VP9_COMMON *const cm, MACROBLOCKD *const xd, vp9_reader *r) {
|
VP9_COMMON *const cm, MACROBLOCKD *const xd, vp9_reader *r) {
|
||||||
const int ctx = vp9_get_pred_context_switchable_interp(xd);
|
const int ctx = vp9_get_pred_context_switchable_interp(xd);
|
||||||
const int type = treed_read(r, vp9_switchable_interp_tree,
|
const int type = vp9_read_tree(r, vp9_switchable_interp_tree,
|
||||||
cm->fc.switchable_interp_prob[ctx]);
|
cm->fc.switchable_interp_prob[ctx]);
|
||||||
if (!cm->frame_parallel_decoding_mode)
|
if (!cm->frame_parallel_decoding_mode)
|
||||||
++cm->counts.switchable_interp[ctx][type];
|
++cm->counts.switchable_interp[ctx][type];
|
||||||
return type;
|
return type;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "vp9/decoder/vp9_dboolhuff.h"
|
#include "vp9/decoder/vp9_dboolhuff.h"
|
||||||
#include "vp9/decoder/vp9_detokenize.h"
|
#include "vp9/decoder/vp9_detokenize.h"
|
||||||
#include "vp9/decoder/vp9_onyxd_int.h"
|
#include "vp9/decoder/vp9_onyxd_int.h"
|
||||||
#include "vp9/decoder/vp9_treereader.h"
|
|
||||||
|
|
||||||
#define EOB_CONTEXT_NODE 0
|
#define EOB_CONTEXT_NODE 0
|
||||||
#define ZERO_CONTEXT_NODE 1
|
#define ZERO_CONTEXT_NODE 1
|
||||||
|
@ -1,30 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#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_onyxd_int.h
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_thread.c
|
VP9_DX_SRCS-yes += decoder/vp9_thread.c
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_thread.h
|
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_onyxd_if.c
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_dsubexp.c
|
VP9_DX_SRCS-yes += decoder/vp9_dsubexp.c
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_dsubexp.h
|
VP9_DX_SRCS-yes += decoder/vp9_dsubexp.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user