Commit bb46b311 authored by Jingning Han's avatar Jingning Han

Prevent potential token buffer overflow in format 444

For a 16x16 pixel block, one needs to allocate 16x16 coefficient
tokens, plus up to 16 eob tokens, per plane. This commit increases
the token allocation size to cover the case where all the transform
blocks are of size 4x4 in format 444.

Change-Id: I5755e6a53771053d51163d01ec1d62e670c5009e
parent 2dff042a
......@@ -657,12 +657,10 @@ static INLINE int enc_is_ref_frame_buf(AV1_COMP *cpi, RefCntBuffer *frame_buf) {
#endif // CONFIG_EXT_REFS
static INLINE int get_token_alloc(int mb_rows, int mb_cols) {
// TODO(JBB): double check we can't exceed this token count if we have a
// 32x32 transform crossing a boundary at a multiple of 16.
// mb_rows, cols are in units of 16 pixels. We assume 3 planes all at full
// resolution. We assume up to 1 token per pixel, and then allow
// a head room of 1 EOSB token per 8x8 block per plane.
return mb_rows * mb_cols * (16 * 16 + 4) * 3;
// We assume 3 planes all at full resolution. We assume up to 1 token per
// pixel, and then allow a head room of 1 EOSB token per 4x4 block per plane,
// plus EOSB_TOKEN per plane.
return mb_rows * mb_cols * (16 * 16 + 17) * 3;
}
// Get the allocated token size for a tile. It does the same calculation as in
......
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