Commit 70f61b22 authored by Jingning Han's avatar Jingning Han

Re-allocate the mfmv buffer when frame size changes

Fix a bug that prevents the mfmv buffer re-allocation when the
frame size changes.

BUG=aomedia:1194

Change-Id: Ied349ead9703069c87fbf9e46668ae1dd0b6141a
parent 2e302f94
......@@ -122,6 +122,7 @@ typedef enum {
typedef struct {
int_mv mfmv[INTER_REFS_PER_FRAME][MFMV_STACK_SIZE];
int mem_size;
} TPL_MV_REF;
#endif
......@@ -667,8 +668,10 @@ static INLINE int frame_can_use_prev_frame_mvs(const AV1_COMMON *cm) {
#endif
static INLINE void ensure_mv_buffer(RefCntBuffer *buf, AV1_COMMON *cm) {
if (buf->mvs == NULL || buf->mi_rows < cm->mi_rows ||
buf->mi_cols < cm->mi_cols) {
const int buf_rows = buf->mi_rows;
const int buf_cols = buf->mi_cols;
if (buf->mvs == NULL || buf_rows < cm->mi_rows || buf_cols < cm->mi_cols) {
aom_free(buf->mvs);
buf->mi_rows = cm->mi_rows;
buf->mi_cols = cm->mi_cols;
......@@ -691,13 +694,16 @@ static INLINE void ensure_mv_buffer(RefCntBuffer *buf, AV1_COMMON *cm) {
}
#if CONFIG_MFMV
if (cm->tpl_mvs == NULL || buf->mi_rows < cm->mi_rows ||
buf->mi_cols < cm->mi_cols) {
const int mem_size =
((cm->mi_rows + MAX_MIB_SIZE) >> 1) * (cm->mi_stride >> 1);
int realloc = cm->tpl_mvs == NULL;
if (cm->tpl_mvs) realloc |= cm->tpl_mvs->mem_size < mem_size;
if (realloc) {
aom_free(cm->tpl_mvs);
CHECK_MEM_ERROR(cm, cm->tpl_mvs, (TPL_MV_REF *)aom_calloc(
((cm->mi_rows + MAX_MIB_SIZE) >> 1) *
(cm->mi_stride >> 1),
sizeof(*cm->tpl_mvs)));
CHECK_MEM_ERROR(cm, cm->tpl_mvs,
(TPL_MV_REF *)aom_calloc(mem_size, sizeof(*cm->tpl_mvs)));
cm->tpl_mvs->mem_size = mem_size;
}
#endif
}
......
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