Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
987451d8
Commit
987451d8
authored
Jul 21, 2015
by
Yaowu Xu
Committed by
Gerrit Code Review
Jul 21, 2015
Browse files
Merge "vpx_dsp/bitwriter.h: vp9_->vpx_"
parents
41c13ddb
817be1d2
Changes
9
Hide whitespace changes
Inline
Side-by-side
test/vp9_boolcoder_test.cc
View file @
987451d8
...
...
@@ -50,9 +50,9 @@ TEST(VP9, TestBitIO) {
const
int
random_seed
=
6432
;
const
int
kBufferSize
=
10000
;
ACMRandom
bit_rnd
(
random_seed
);
vp
9
_writer
bw
;
vp
x
_writer
bw
;
uint8_t
bw_buffer
[
kBufferSize
];
vp
9
_start_encode
(
&
bw
,
bw_buffer
);
vp
x
_start_encode
(
&
bw
,
bw_buffer
);
int
bit
=
(
bit_method
==
0
)
?
0
:
(
bit_method
==
1
)
?
1
:
0
;
for
(
int
i
=
0
;
i
<
kBitsToTest
;
++
i
)
{
...
...
@@ -61,10 +61,10 @@ TEST(VP9, TestBitIO) {
}
else
if
(
bit_method
==
3
)
{
bit
=
bit_rnd
(
2
);
}
vp
9
_write
(
&
bw
,
bit
,
static_cast
<
int
>
(
probas
[
i
]));
vp
x
_write
(
&
bw
,
bit
,
static_cast
<
int
>
(
probas
[
i
]));
}
vp
9
_stop_encode
(
&
bw
);
vp
x
_stop_encode
(
&
bw
);
// First bit should be zero
GTEST_ASSERT_EQ
(
bw_buffer
[
0
]
&
0x80
,
0
);
...
...
vp9/encoder/vp9_bitstream.c
View file @
987451d8
...
...
@@ -44,12 +44,12 @@ static const struct vp9_token partition_encodings[PARTITION_TYPES] =
static
const
struct
vp9_token
inter_mode_encodings
[
INTER_MODES
]
=
{{
2
,
2
},
{
6
,
3
},
{
0
,
1
},
{
7
,
3
}};
static
void
write_intra_mode
(
vp
9
_writer
*
w
,
PREDICTION_MODE
mode
,
static
void
write_intra_mode
(
vp
x
_writer
*
w
,
PREDICTION_MODE
mode
,
const
vpx_prob
*
probs
)
{
vp9_write_token
(
w
,
vp9_intra_mode_tree
,
probs
,
&
intra_mode_encodings
[
mode
]);
}
static
void
write_inter_mode
(
vp
9
_writer
*
w
,
PREDICTION_MODE
mode
,
static
void
write_inter_mode
(
vp
x
_writer
*
w
,
PREDICTION_MODE
mode
,
const
vpx_prob
*
probs
)
{
assert
(
is_inter_mode
(
mode
));
vp9_write_token
(
w
,
vp9_inter_mode_tree
,
probs
,
...
...
@@ -64,7 +64,7 @@ static void encode_unsigned_max(struct vp9_write_bit_buffer *wb,
static
void
prob_diff_update
(
const
vpx_tree_index
*
tree
,
vpx_prob
probs
[
/*n - 1*/
],
const
unsigned
int
counts
[
/*n - 1*/
],
int
n
,
vp
9
_writer
*
w
)
{
int
n
,
vp
x
_writer
*
w
)
{
int
i
;
unsigned
int
branch_ct
[
32
][
2
];
...
...
@@ -77,32 +77,32 @@ static void prob_diff_update(const vpx_tree_index *tree,
}
static
void
write_selected_tx_size
(
const
VP9_COMMON
*
cm
,
const
MACROBLOCKD
*
xd
,
vp
9
_writer
*
w
)
{
const
MACROBLOCKD
*
xd
,
vp
x
_writer
*
w
)
{
TX_SIZE
tx_size
=
xd
->
mi
[
0
]
->
mbmi
.
tx_size
;
BLOCK_SIZE
bsize
=
xd
->
mi
[
0
]
->
mbmi
.
sb_type
;
const
TX_SIZE
max_tx_size
=
max_txsize_lookup
[
bsize
];
const
vpx_prob
*
const
tx_probs
=
get_tx_probs2
(
max_tx_size
,
xd
,
&
cm
->
fc
->
tx_probs
);
vp
9
_write
(
w
,
tx_size
!=
TX_4X4
,
tx_probs
[
0
]);
vp
x
_write
(
w
,
tx_size
!=
TX_4X4
,
tx_probs
[
0
]);
if
(
tx_size
!=
TX_4X4
&&
max_tx_size
>=
TX_16X16
)
{
vp
9
_write
(
w
,
tx_size
!=
TX_8X8
,
tx_probs
[
1
]);
vp
x
_write
(
w
,
tx_size
!=
TX_8X8
,
tx_probs
[
1
]);
if
(
tx_size
!=
TX_8X8
&&
max_tx_size
>=
TX_32X32
)
vp
9
_write
(
w
,
tx_size
!=
TX_16X16
,
tx_probs
[
2
]);
vp
x
_write
(
w
,
tx_size
!=
TX_16X16
,
tx_probs
[
2
]);
}
}
static
int
write_skip
(
const
VP9_COMMON
*
cm
,
const
MACROBLOCKD
*
xd
,
int
segment_id
,
const
MODE_INFO
*
mi
,
vp
9
_writer
*
w
)
{
int
segment_id
,
const
MODE_INFO
*
mi
,
vp
x
_writer
*
w
)
{
if
(
segfeature_active
(
&
cm
->
seg
,
segment_id
,
SEG_LVL_SKIP
))
{
return
1
;
}
else
{
const
int
skip
=
mi
->
mbmi
.
skip
;
vp
9
_write
(
w
,
skip
,
vp9_get_skip_prob
(
cm
,
xd
));
vp
x
_write
(
w
,
skip
,
vp9_get_skip_prob
(
cm
,
xd
));
return
skip
;
}
}
static
void
update_skip_probs
(
VP9_COMMON
*
cm
,
vp
9
_writer
*
w
,
static
void
update_skip_probs
(
VP9_COMMON
*
cm
,
vp
x
_writer
*
w
,
FRAME_COUNTS
*
counts
)
{
int
k
;
...
...
@@ -110,7 +110,7 @@ static void update_skip_probs(VP9_COMMON *cm, vp9_writer *w,
vp9_cond_prob_diff_update
(
w
,
&
cm
->
fc
->
skip_probs
[
k
],
counts
->
skip
[
k
]);
}
static
void
update_switchable_interp_probs
(
VP9_COMMON
*
cm
,
vp
9
_writer
*
w
,
static
void
update_switchable_interp_probs
(
VP9_COMMON
*
cm
,
vp
x
_writer
*
w
,
FRAME_COUNTS
*
counts
)
{
int
j
;
for
(
j
=
0
;
j
<
SWITCHABLE_FILTER_CONTEXTS
;
++
j
)
...
...
@@ -119,7 +119,7 @@ static void update_switchable_interp_probs(VP9_COMMON *cm, vp9_writer *w,
counts
->
switchable_interp
[
j
],
SWITCHABLE_FILTERS
,
w
);
}
static
void
pack_mb_tokens
(
vp
9
_writer
*
w
,
static
void
pack_mb_tokens
(
vp
x
_writer
*
w
,
TOKENEXTRA
**
tp
,
const
TOKENEXTRA
*
const
stop
,
vpx_bit_depth_t
bit_depth
)
{
TOKENEXTRA
*
p
=
*
tp
;
...
...
@@ -179,12 +179,12 @@ static void pack_mb_tokens(vp9_writer *w,
do
{
const
int
bb
=
(
v
>>
--
n
)
&
1
;
vp
9
_write
(
w
,
bb
,
pb
[
i
>>
1
]);
vp
x
_write
(
w
,
bb
,
pb
[
i
>>
1
]);
i
=
b
->
tree
[
i
+
bb
];
}
while
(
n
);
}
vp
9
_write_bit
(
w
,
e
&
1
);
vp
x
_write_bit
(
w
,
e
&
1
);
}
++
p
;
}
...
...
@@ -192,7 +192,7 @@ static void pack_mb_tokens(vp9_writer *w,
*
tp
=
p
+
(
p
->
token
==
EOSB_TOKEN
);
}
static
void
write_segment_id
(
vp
9
_writer
*
w
,
const
struct
segmentation
*
seg
,
static
void
write_segment_id
(
vp
x
_writer
*
w
,
const
struct
segmentation
*
seg
,
int
segment_id
)
{
if
(
seg
->
enabled
&&
seg
->
update_map
)
vp9_write_tree
(
w
,
vp9_segment_tree
,
seg
->
tree_probs
,
segment_id
,
3
,
0
);
...
...
@@ -200,7 +200,7 @@ static void write_segment_id(vp9_writer *w, const struct segmentation *seg,
// This function encodes the reference frame
static
void
write_ref_frames
(
const
VP9_COMMON
*
cm
,
const
MACROBLOCKD
*
xd
,
vp
9
_writer
*
w
)
{
vp
x
_writer
*
w
)
{
const
MB_MODE_INFO
*
const
mbmi
=
&
xd
->
mi
[
0
]
->
mbmi
;
const
int
is_compound
=
has_second_ref
(
mbmi
);
const
int
segment_id
=
mbmi
->
segment_id
;
...
...
@@ -215,27 +215,27 @@ static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd,
// does the feature use compound prediction or not
// (if not specified at the frame/segment level)
if
(
cm
->
reference_mode
==
REFERENCE_MODE_SELECT
)
{
vp
9
_write
(
w
,
is_compound
,
vp9_get_reference_mode_prob
(
cm
,
xd
));
vp
x
_write
(
w
,
is_compound
,
vp9_get_reference_mode_prob
(
cm
,
xd
));
}
else
{
assert
(
!
is_compound
==
(
cm
->
reference_mode
==
SINGLE_REFERENCE
));
}
if
(
is_compound
)
{
vp
9
_write
(
w
,
mbmi
->
ref_frame
[
0
]
==
GOLDEN_FRAME
,
vp
x
_write
(
w
,
mbmi
->
ref_frame
[
0
]
==
GOLDEN_FRAME
,
vp9_get_pred_prob_comp_ref_p
(
cm
,
xd
));
}
else
{
const
int
bit0
=
mbmi
->
ref_frame
[
0
]
!=
LAST_FRAME
;
vp
9
_write
(
w
,
bit0
,
vp9_get_pred_prob_single_ref_p1
(
cm
,
xd
));
vp
x
_write
(
w
,
bit0
,
vp9_get_pred_prob_single_ref_p1
(
cm
,
xd
));
if
(
bit0
)
{
const
int
bit1
=
mbmi
->
ref_frame
[
0
]
!=
GOLDEN_FRAME
;
vp
9
_write
(
w
,
bit1
,
vp9_get_pred_prob_single_ref_p2
(
cm
,
xd
));
vp
x
_write
(
w
,
bit1
,
vp9_get_pred_prob_single_ref_p2
(
cm
,
xd
));
}
}
}
}
static
void
pack_inter_mode_mvs
(
VP9_COMP
*
cpi
,
const
MODE_INFO
*
mi
,
vp
9
_writer
*
w
)
{
vp
x
_writer
*
w
)
{
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
const
nmv_context
*
nmvc
=
&
cm
->
fc
->
nmvc
;
const
MACROBLOCK
*
const
x
=
&
cpi
->
td
.
mb
;
...
...
@@ -255,7 +255,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
if
(
seg
->
temporal_update
)
{
const
int
pred_flag
=
mbmi
->
seg_id_predicted
;
vpx_prob
pred_prob
=
vp9_get_pred_prob_seg_id
(
seg
,
xd
);
vp
9
_write
(
w
,
pred_flag
,
pred_prob
);
vp
x
_write
(
w
,
pred_flag
,
pred_prob
);
if
(
!
pred_flag
)
write_segment_id
(
w
,
seg
,
segment_id
);
}
else
{
...
...
@@ -266,7 +266,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
skip
=
write_skip
(
cm
,
xd
,
segment_id
,
mi
,
w
);
if
(
!
segfeature_active
(
seg
,
segment_id
,
SEG_LVL_REF_FRAME
))
vp
9
_write
(
w
,
is_inter
,
vp9_get_intra_inter_prob
(
cm
,
xd
));
vp
x
_write
(
w
,
is_inter
,
vp9_get_intra_inter_prob
(
cm
,
xd
));
if
(
bsize
>=
BLOCK_8X8
&&
cm
->
tx_mode
==
TX_MODE_SELECT
&&
!
(
is_inter
&&
skip
))
{
...
...
@@ -339,7 +339,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
}
static
void
write_mb_modes_kf
(
const
VP9_COMMON
*
cm
,
const
MACROBLOCKD
*
xd
,
MODE_INFO
**
mi_8x8
,
vp
9
_writer
*
w
)
{
MODE_INFO
**
mi_8x8
,
vp
x
_writer
*
w
)
{
const
struct
segmentation
*
const
seg
=
&
cm
->
seg
;
const
MODE_INFO
*
const
mi
=
mi_8x8
[
0
];
const
MODE_INFO
*
const
above_mi
=
xd
->
above_mi
;
...
...
@@ -375,7 +375,7 @@ static void write_mb_modes_kf(const VP9_COMMON *cm, const MACROBLOCKD *xd,
}
static
void
write_modes_b
(
VP9_COMP
*
cpi
,
const
TileInfo
*
const
tile
,
vp
9
_writer
*
w
,
TOKENEXTRA
**
tok
,
vp
x
_writer
*
w
,
TOKENEXTRA
**
tok
,
const
TOKENEXTRA
*
const
tok_end
,
int
mi_row
,
int
mi_col
)
{
const
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
...
...
@@ -405,7 +405,7 @@ static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile,
static
void
write_partition
(
const
VP9_COMMON
*
const
cm
,
const
MACROBLOCKD
*
const
xd
,
int
hbs
,
int
mi_row
,
int
mi_col
,
PARTITION_TYPE
p
,
BLOCK_SIZE
bsize
,
vp
9
_writer
*
w
)
{
PARTITION_TYPE
p
,
BLOCK_SIZE
bsize
,
vp
x
_writer
*
w
)
{
const
int
ctx
=
partition_plane_context
(
xd
,
mi_row
,
mi_col
,
bsize
);
const
vpx_prob
*
const
probs
=
xd
->
partition_probs
[
ctx
];
const
int
has_rows
=
(
mi_row
+
hbs
)
<
cm
->
mi_rows
;
...
...
@@ -415,17 +415,17 @@ static void write_partition(const VP9_COMMON *const cm,
vp9_write_token
(
w
,
vp9_partition_tree
,
probs
,
&
partition_encodings
[
p
]);
}
else
if
(
!
has_rows
&&
has_cols
)
{
assert
(
p
==
PARTITION_SPLIT
||
p
==
PARTITION_HORZ
);
vp
9
_write
(
w
,
p
==
PARTITION_SPLIT
,
probs
[
1
]);
vp
x
_write
(
w
,
p
==
PARTITION_SPLIT
,
probs
[
1
]);
}
else
if
(
has_rows
&&
!
has_cols
)
{
assert
(
p
==
PARTITION_SPLIT
||
p
==
PARTITION_VERT
);
vp
9
_write
(
w
,
p
==
PARTITION_SPLIT
,
probs
[
2
]);
vp
x
_write
(
w
,
p
==
PARTITION_SPLIT
,
probs
[
2
]);
}
else
{
assert
(
p
==
PARTITION_SPLIT
);
}
}
static
void
write_modes_sb
(
VP9_COMP
*
cpi
,
const
TileInfo
*
const
tile
,
vp
9
_writer
*
w
,
const
TileInfo
*
const
tile
,
vp
x
_writer
*
w
,
TOKENEXTRA
**
tok
,
const
TOKENEXTRA
*
const
tok_end
,
int
mi_row
,
int
mi_col
,
BLOCK_SIZE
bsize
)
{
const
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
...
...
@@ -483,7 +483,7 @@ static void write_modes_sb(VP9_COMP *cpi,
}
static
void
write_modes
(
VP9_COMP
*
cpi
,
const
TileInfo
*
const
tile
,
vp
9
_writer
*
w
,
const
TileInfo
*
const
tile
,
vp
x
_writer
*
w
,
TOKENEXTRA
**
tok
,
const
TOKENEXTRA
*
const
tok_end
)
{
const
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
MACROBLOCKD
*
const
xd
=
&
cpi
->
td
.
mb
.
e_mbd
;
...
...
@@ -528,7 +528,7 @@ static void build_tree_distribution(VP9_COMP *cpi, TX_SIZE tx_size,
}
}
static
void
update_coef_probs_common
(
vp
9
_writer
*
const
bc
,
VP9_COMP
*
cpi
,
static
void
update_coef_probs_common
(
vp
x
_writer
*
const
bc
,
VP9_COMP
*
cpi
,
TX_SIZE
tx_size
,
vp9_coeff_stats
*
frame_branch_ct
,
vp9_coeff_probs_model
*
new_coef_probs
)
{
...
...
@@ -575,10 +575,10 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
// printf("Update %d %d, savings %d\n", update[0], update[1], savings);
/* Is coef updated at all */
if
(
update
[
1
]
==
0
||
savings
<
0
)
{
vp
9
_write_bit
(
bc
,
0
);
vp
x
_write_bit
(
bc
,
0
);
return
;
}
vp
9
_write_bit
(
bc
,
1
);
vp
x
_write_bit
(
bc
,
1
);
for
(
i
=
0
;
i
<
PLANE_TYPES
;
++
i
)
{
for
(
j
=
0
;
j
<
REF_TYPES
;
++
j
)
{
for
(
k
=
0
;
k
<
COEF_BANDS
;
++
k
)
{
...
...
@@ -600,7 +600,7 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
*
oldp
,
&
newp
,
upd
);
if
(
s
>
0
&&
newp
!=
*
oldp
)
u
=
1
;
vp
9
_write
(
bc
,
u
,
upd
);
vp
x
_write
(
bc
,
u
,
upd
);
if
(
u
)
{
/* send/use new probability */
vp9_write_prob_diff_update
(
bc
,
newp
,
*
oldp
);
...
...
@@ -648,11 +648,11 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
if
(
u
==
1
&&
updates
==
1
)
{
int
v
;
// first update
vp
9
_write_bit
(
bc
,
1
);
vp
x
_write_bit
(
bc
,
1
);
for
(
v
=
0
;
v
<
noupdates_before_first
;
++
v
)
vp
9
_write
(
bc
,
0
,
upd
);
vp
x
_write
(
bc
,
0
,
upd
);
}
vp
9
_write
(
bc
,
u
,
upd
);
vp
x
_write
(
bc
,
u
,
upd
);
if
(
u
)
{
/* send/use new probability */
vp9_write_prob_diff_update
(
bc
,
newp
,
*
oldp
);
...
...
@@ -664,7 +664,7 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
}
}
if
(
updates
==
0
)
{
vp
9
_write_bit
(
bc
,
0
);
// no updates
vp
x
_write_bit
(
bc
,
0
);
// no updates
}
return
;
}
...
...
@@ -673,7 +673,7 @@ static void update_coef_probs_common(vp9_writer* const bc, VP9_COMP *cpi,
}
}
static
void
update_coef_probs
(
VP9_COMP
*
cpi
,
vp
9
_writer
*
w
)
{
static
void
update_coef_probs
(
VP9_COMP
*
cpi
,
vp
x
_writer
*
w
)
{
const
TX_MODE
tx_mode
=
cpi
->
common
.
tx_mode
;
const
TX_SIZE
max_tx_size
=
tx_mode_to_biggest_tx_size
[
tx_mode
];
TX_SIZE
tx_size
;
...
...
@@ -682,7 +682,7 @@ static void update_coef_probs(VP9_COMP *cpi, vp9_writer* w) {
vp9_coeff_probs_model
frame_coef_probs
[
PLANE_TYPES
];
if
(
cpi
->
td
.
counts
->
tx
.
tx_totals
[
tx_size
]
<=
20
||
(
tx_size
>=
TX_16X16
&&
cpi
->
sf
.
tx_size_search_method
==
USE_TX_8X8
))
{
vp
9
_write_bit
(
w
,
0
);
vp
x
_write_bit
(
w
,
0
);
}
else
{
build_tree_distribution
(
cpi
,
tx_size
,
frame_branch_ct
,
frame_coef_probs
);
...
...
@@ -812,12 +812,12 @@ static void encode_segmentation(VP9_COMMON *cm, MACROBLOCKD *xd,
}
}
static
void
encode_txfm_probs
(
VP9_COMMON
*
cm
,
vp
9
_writer
*
w
,
static
void
encode_txfm_probs
(
VP9_COMMON
*
cm
,
vp
x
_writer
*
w
,
FRAME_COUNTS
*
counts
)
{
// Mode
vp
9
_write_literal
(
w
,
MIN
(
cm
->
tx_mode
,
ALLOW_32X32
),
2
);
vp
x
_write_literal
(
w
,
MIN
(
cm
->
tx_mode
,
ALLOW_32X32
),
2
);
if
(
cm
->
tx_mode
>=
ALLOW_32X32
)
vp
9
_write_bit
(
w
,
cm
->
tx_mode
==
TX_MODE_SELECT
);
vp
x
_write_bit
(
w
,
cm
->
tx_mode
==
TX_MODE_SELECT
);
// Probabilities
if
(
cm
->
tx_mode
==
TX_MODE_SELECT
)
{
...
...
@@ -928,7 +928,7 @@ static int get_refresh_mask(VP9_COMP *cpi) {
static
size_t
encode_tiles
(
VP9_COMP
*
cpi
,
uint8_t
*
data_ptr
)
{
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
vp
9
_writer
residual_bc
;
vp
x
_writer
residual_bc
;
int
tile_row
,
tile_col
;
TOKENEXTRA
*
tok_end
;
size_t
total_size
=
0
;
...
...
@@ -947,14 +947,14 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
cpi
->
tok_count
[
tile_row
][
tile_col
];
if
(
tile_col
<
tile_cols
-
1
||
tile_row
<
tile_rows
-
1
)
vp
9
_start_encode
(
&
residual_bc
,
data_ptr
+
total_size
+
4
);
vp
x
_start_encode
(
&
residual_bc
,
data_ptr
+
total_size
+
4
);
else
vp
9
_start_encode
(
&
residual_bc
,
data_ptr
+
total_size
);
vp
x
_start_encode
(
&
residual_bc
,
data_ptr
+
total_size
);
write_modes
(
cpi
,
&
cpi
->
tile_data
[
tile_idx
].
tile_info
,
&
residual_bc
,
&
tok
,
tok_end
);
assert
(
tok
==
tok_end
);
vp
9
_stop_encode
(
&
residual_bc
);
vp
x
_stop_encode
(
&
residual_bc
);
if
(
tile_col
<
tile_cols
-
1
||
tile_row
<
tile_rows
-
1
)
{
// size of this tile
mem_put_be32
(
data_ptr
+
total_size
,
residual_bc
.
pos
);
...
...
@@ -1155,9 +1155,9 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
MACROBLOCKD
*
const
xd
=
&
cpi
->
td
.
mb
.
e_mbd
;
FRAME_CONTEXT
*
const
fc
=
cm
->
fc
;
FRAME_COUNTS
*
counts
=
cpi
->
td
.
counts
;
vp
9
_writer
header_bc
;
vp
x
_writer
header_bc
;
vp
9
_start_encode
(
&
header_bc
,
data
);
vp
x
_start_encode
(
&
header_bc
,
data
);
if
(
xd
->
lossless
)
cm
->
tx_mode
=
ONLY_4X4
;
...
...
@@ -1185,9 +1185,9 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
const
int
use_compound_pred
=
cm
->
reference_mode
!=
SINGLE_REFERENCE
;
const
int
use_hybrid_pred
=
cm
->
reference_mode
==
REFERENCE_MODE_SELECT
;
vp
9
_write_bit
(
&
header_bc
,
use_compound_pred
);
vp
x
_write_bit
(
&
header_bc
,
use_compound_pred
);
if
(
use_compound_pred
)
{
vp
9
_write_bit
(
&
header_bc
,
use_hybrid_pred
);
vp
x
_write_bit
(
&
header_bc
,
use_hybrid_pred
);
if
(
use_hybrid_pred
)
for
(
i
=
0
;
i
<
COMP_INTER_CONTEXTS
;
i
++
)
vp9_cond_prob_diff_update
(
&
header_bc
,
&
fc
->
comp_inter_prob
[
i
],
...
...
@@ -1221,7 +1221,7 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
&
counts
->
mv
);
}
vp
9
_stop_encode
(
&
header_bc
);
vp
x
_stop_encode
(
&
header_bc
);
assert
(
header_bc
.
pos
<=
0xffff
);
return
header_bc
.
pos
;
...
...
vp9/encoder/vp9_encodemv.c
View file @
987451d8
...
...
@@ -29,7 +29,7 @@ void vp9_entropy_mv_init(void) {
vp9_tokens_from_tree
(
mv_fp_encodings
,
vp9_mv_fp_tree
);
}
static
void
encode_mv_component
(
vp
9
_writer
*
w
,
int
comp
,
static
void
encode_mv_component
(
vp
x
_writer
*
w
,
int
comp
,
const
nmv_component
*
mvcomp
,
int
usehp
)
{
int
offset
;
const
int
sign
=
comp
<
0
;
...
...
@@ -42,7 +42,7 @@ static void encode_mv_component(vp9_writer* w, int comp,
assert
(
comp
!=
0
);
// Sign
vp
9
_write
(
w
,
sign
,
mvcomp
->
sign
);
vp
x
_write
(
w
,
sign
,
mvcomp
->
sign
);
// Class
vp9_write_token
(
w
,
vp9_mv_class_tree
,
mvcomp
->
classes
,
...
...
@@ -56,7 +56,7 @@ static void encode_mv_component(vp9_writer* w, int comp,
int
i
;
const
int
n
=
mv_class
+
CLASS0_BITS
-
1
;
// number of bits
for
(
i
=
0
;
i
<
n
;
++
i
)
vp
9
_write
(
w
,
(
d
>>
i
)
&
1
,
mvcomp
->
bits
[
i
]);
vp
x
_write
(
w
,
(
d
>>
i
)
&
1
,
mvcomp
->
bits
[
i
]);
}
// Fractional bits
...
...
@@ -66,7 +66,7 @@ static void encode_mv_component(vp9_writer* w, int comp,
// High precision bit
if
(
usehp
)
vp
9
_write
(
w
,
hp
,
vp
x
_write
(
w
,
hp
,
mv_class
==
MV_CLASS_0
?
mvcomp
->
class0_hp
:
mvcomp
->
hp
);
}
...
...
@@ -133,15 +133,15 @@ static void build_nmv_component_cost_table(int *mvcost,
}
}
static
int
update_mv
(
vp
9
_writer
*
w
,
const
unsigned
int
ct
[
2
],
vpx_prob
*
cur_p
,
static
int
update_mv
(
vp
x
_writer
*
w
,
const
unsigned
int
ct
[
2
],
vpx_prob
*
cur_p
,
vpx_prob
upd_p
)
{
const
vpx_prob
new_p
=
get_binary_prob
(
ct
[
0
],
ct
[
1
])
|
1
;
const
int
update
=
cost_branch256
(
ct
,
*
cur_p
)
+
vp9_cost_zero
(
upd_p
)
>
cost_branch256
(
ct
,
new_p
)
+
vp9_cost_one
(
upd_p
)
+
7
*
256
;
vp
9
_write
(
w
,
update
,
upd_p
);
vp
x
_write
(
w
,
update
,
upd_p
);
if
(
update
)
{
*
cur_p
=
new_p
;
vp
9
_write_literal
(
w
,
new_p
>>
1
,
7
);
vp
x
_write_literal
(
w
,
new_p
>>
1
,
7
);
}
return
update
;
}
...
...
@@ -149,7 +149,7 @@ static int update_mv(vp9_writer *w, const unsigned int ct[2], vpx_prob *cur_p,
static
void
write_mv_update
(
const
vpx_tree_index
*
tree
,
vpx_prob
probs
[
/*n - 1*/
],
const
unsigned
int
counts
[
/*n - 1*/
],
int
n
,
vp
9
_writer
*
w
)
{
int
n
,
vp
x
_writer
*
w
)
{
int
i
;
unsigned
int
branch_ct
[
32
][
2
];
...
...
@@ -161,7 +161,7 @@ static void write_mv_update(const vpx_tree_index *tree,
update_mv
(
w
,
branch_ct
[
i
],
&
probs
[
i
],
MV_UPDATE_PROB
);
}
void
vp9_write_nmv_probs
(
VP9_COMMON
*
cm
,
int
usehp
,
vp
9
_writer
*
w
,
void
vp9_write_nmv_probs
(
VP9_COMMON
*
cm
,
int
usehp
,
vp
x
_writer
*
w
,
nmv_context_counts
*
const
counts
)
{
int
i
,
j
;
nmv_context
*
const
mvc
=
&
cm
->
fc
->
nmvc
;
...
...
@@ -199,7 +199,7 @@ void vp9_write_nmv_probs(VP9_COMMON *cm, int usehp, vp9_writer *w,
}
}
void
vp9_encode_mv
(
VP9_COMP
*
cpi
,
vp
9
_writer
*
w
,
void
vp9_encode_mv
(
VP9_COMP
*
cpi
,
vp
x
_writer
*
w
,
const
MV
*
mv
,
const
MV
*
ref
,
const
nmv_context
*
mvctx
,
int
usehp
)
{
const
MV
diff
=
{
mv
->
row
-
ref
->
row
,
...
...
vp9/encoder/vp9_encodemv.h
View file @
987451d8
...
...
@@ -20,10 +20,10 @@ extern "C" {
void
vp9_entropy_mv_init
(
void
);
void
vp9_write_nmv_probs
(
VP9_COMMON
*
cm
,
int
usehp
,
vp
9
_writer
*
w
,
void
vp9_write_nmv_probs
(
VP9_COMMON
*
cm
,
int
usehp
,
vp
x
_writer
*
w
,
nmv_context_counts
*
const
counts
);
void
vp9_encode_mv
(
VP9_COMP
*
cpi
,
vp
9
_writer
*
w
,
const
MV
*
mv
,
const
MV
*
ref
,
void
vp9_encode_mv
(
VP9_COMP
*
cpi
,
vp
x
_writer
*
w
,
const
MV
*
mv
,
const
MV
*
ref
,
const
nmv_context
*
mvctx
,
int
usehp
);
void
vp9_build_nmv_cost_table
(
int
*
mvjoint
,
int
*
mvcost
[
2
],
...
...
vp9/encoder/vp9_subexp.c
View file @
987451d8
...
...
@@ -83,35 +83,35 @@ static int prob_diff_update_cost(vpx_prob newp, vpx_prob oldp) {
return
update_bits
[
delp
]
*
256
;
}
static
void
encode_uniform
(
vp
9
_writer
*
w
,
int
v
)
{
static
void
encode_uniform
(
vp
x
_writer
*
w
,
int
v
)
{
const
int
l
=
8
;
const
int
m
=
(
1
<<
l
)
-
191
;
if
(
v
<
m
)
{
vp
9
_write_literal
(
w
,
v
,
l
-
1
);
vp
x
_write_literal
(
w
,
v
,
l
-
1
);
}
else
{
vp
9
_write_literal
(
w
,
m
+
((
v
-
m
)
>>
1
),
l
-
1
);
vp
9
_write_literal
(
w
,
(
v
-
m
)
&
1
,
1
);
vp
x
_write_literal
(
w
,
m
+
((
v
-
m
)
>>
1
),
l
-
1
);
vp
x
_write_literal
(
w
,
(
v
-
m
)
&
1
,
1
);
}
}
static
INLINE
int
write_bit_gte
(
vp
9
_writer
*
w
,
int
word
,
int
test
)
{
vp
9
_write_literal
(
w
,
word
>=
test
,
1
);
static
INLINE
int
write_bit_gte
(
vp
x
_writer
*
w
,
int
word
,
int
test
)
{
vp
x
_write_literal
(
w
,
word
>=
test
,
1
);
return
word
>=
test
;
}
static
void
encode_term_subexp
(
vp
9
_writer
*
w
,
int
word
)
{
static
void
encode_term_subexp
(
vp
x
_writer
*
w
,
int
word
)
{
if
(
!
write_bit_gte
(
w
,
word
,
16
))
{
vp
9
_write_literal
(
w
,
word
,
4
);
vp
x
_write_literal
(
w
,
word
,
4
);
}
else
if
(
!
write_bit_gte
(
w
,
word
,
32
))
{
vp
9
_write_literal
(
w
,
word
-
16
,
4
);
vp
x
_write_literal
(
w
,
word
-
16
,
4
);
}
else
if
(
!
write_bit_gte
(
w
,
word
,
64
))
{
vp
9
_write_literal
(
w
,
word
-
32
,
5
);
vp
x
_write_literal
(
w
,
word
-
32
,
5
);
}
else
{
encode_uniform
(
w
,
word
-
64
);
}
}
void
vp9_write_prob_diff_update
(
vp
9
_writer
*
w
,
vpx_prob
newp
,
vpx_prob
oldp
)
{
void
vp9_write_prob_diff_update
(
vp
x
_writer
*
w
,
vpx_prob
newp
,
vpx_prob
oldp
)
{
const
int
delp
=
remap_prob
(
newp
,
oldp
);
encode_term_subexp
(
w
,
delp
);
}
...
...
@@ -196,7 +196,7 @@ int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
return
bestsavings
;
}
void
vp9_cond_prob_diff_update
(
vp
9
_writer
*
w
,
vpx_prob
*
oldp
,
void
vp9_cond_prob_diff_update
(
vp
x
_writer
*
w
,
vpx_prob
*
oldp
,
const
unsigned
int
ct
[
2
])
{
const
vpx_prob
upd
=
DIFF_UPDATE_PROB
;
vpx_prob
newp
=
get_binary_prob
(
ct
[
0
],
ct
[
1
]);
...
...
@@ -204,10 +204,10 @@ void vp9_cond_prob_diff_update(vp9_writer *w, vpx_prob *oldp,
upd
);
assert
(
newp
>=
1
);
if
(
savings
>
0
)
{
vp
9
_write
(
w
,
1
,
upd
);
vp
x
_write
(
w
,
1
,
upd
);
vp9_write_prob_diff_update
(
w
,
newp
,
*
oldp
);
*
oldp
=
newp
;
}
else
{
vp
9
_write
(
w
,
0
,
upd
);
vp
x
_write
(
w
,
0
,
upd
);
}
}
vp9/encoder/vp9_subexp.h
View file @
987451d8
...
...
@@ -18,12 +18,12 @@ extern "C" {
#include "vpx_dsp/prob.h"
struct
vp
9
_writer
;
struct
vp
x
_writer
;
void
vp9_write_prob_diff_update
(
struct
vp
9
_writer
*
w
,
void
vp9_write_prob_diff_update
(
struct
vp
x
_writer
*
w
,
vpx_prob
newp
,
vpx_prob
oldp
);
void
vp9_cond_prob_diff_update
(
struct
vp
9
_writer
*
w
,
vpx_prob
*
oldp
,
void
vp9_cond_prob_diff_update
(
struct
vp
x
_writer
*
w
,
vpx_prob
*
oldp
,
const
unsigned
int
ct
[
2
]);
int
vp9_prob_diff_update_savings_search
(
const
unsigned
int
*
ct
,
...
...
vp9/encoder/vp9_treewriter.h
View file @
987451d8
...
...
@@ -28,17 +28,17 @@ struct vp9_token {
void
vp9_tokens_from_tree
(
struct
vp9_token
*
,
const
vpx_tree_index
*
);
static
INLINE
void
vp9_write_tree
(
vp
9
_writer
*
w
,
const
vpx_tree_index
*
tree
,
static
INLINE
void
vp9_write_tree
(
vp
x
_writer
*
w
,
const
vpx_tree_index
*
tree
,
const
vpx_prob
*
probs
,
int
bits
,
int
len
,
vpx_tree_index
i
)
{
do
{
const
int
bit
=
(
bits
>>
--
len
)
&
1
;
vp
9
_write
(
w
,
bit
,
probs
[
i
>>
1
]);
vp
x
_write
(
w
,
bit
,
probs
[
i
>>
1
]);
i
=
tree
[
i
+
bit
];
}
while
(
len
);
}
static
INLINE
void
vp9_write_token
(
vp
9
_writer
*
w
,
const
vpx_tree_index
*
tree
,
static
INLINE
void
vp9_write_token
(
vp
x
_writer
*
w
,
const
vpx_tree_index
*
tree
,
const
vpx_prob
*
probs
,
const
struct
vp9_token
*
token
)
{
vp9_write_tree
(
w
,
tree
,
probs
,
token
->
value
,
token
->
len
,
0
);
...
...
vpx_dsp/bitwriter.c
View file @
987451d8
...
...
@@ -12,20 +12,20 @@
#include "./bitwriter.h"
void
vp
9
_start_encode
(
vp
9
_writer
*
br
,
uint8_t
*
source
)
{
void
vp
x
_start_encode
(
vp
x
_writer
*
br
,
uint8_t
*
source
)
{
br
->
lowvalue
=
0
;
br
->
range
=
255
;
br
->
count
=
-
24
;
br
->
buffer
=
source
;
br
->
pos
=
0
;
vp
9
_write_bit
(
br
,
0
);
vp
x
_write_bit
(
br
,
0
);
}