Clear old cbf data before recursion in encode_transform_tree.

- Because encode_transform_tree also maintains the CBF data and assumes that
  the CBFs are initially zeroed, calling the function more than once would
  result in incorrect CBF data.
This commit is contained in:
Ari Koivula 2014-05-06 15:22:31 +03:00
parent bdc16d2612
commit 3910b7989a
2 changed files with 21 additions and 0 deletions

View file

@ -2110,6 +2110,17 @@ void encode_transform_tree(encoder_state * const encoder_state, int32_t x, int32
// asserting just depth.
assert(width == 4 || width == 8 || width == 16 || width == 32 || width == 64);
// Clear coded block flag structures for depths lower than current depth.
// This should ensure that the CBF data doesn't get corrupted if this function
// is called more than once.
{
cbf_clear(&cur_cu->cbf.y, depth + PU_INDEX(x >> 2, y >> 2));
if (PU_INDEX(x >> 2, y >> 2) == 0) {
cbf_clear(&cur_cu->cbf.u, depth);
cbf_clear(&cur_cu->cbf.v, depth);
}
}
// Split transform and increase depth
if (depth == 0 || cur_cu->tr_depth > depth) {
int offset = width_c;

View file

@ -232,6 +232,16 @@ static INLINE void cbf_set(uint8_t *cbf_flags, int depth)
*cbf_flags |= 1 << (7 - depth);
}
/**
* Set CBF in a levels <= depth to false.
*/
static INLINE void cbf_clear(uint8_t *cbf_flags, int depth)
{
static const uint8_t masks[8] = { 0xff, 0x7f, 0x3f, 0x1f, 0x8, 0x4, 0x2, 0x1 };
*cbf_flags &= ~masks[depth];
}
yuv_t * yuv_t_alloc(int luma_size);
void yuv_t_free(yuv_t * yuv);