Commit 6cc1fd31 authored by Jingning Han's avatar Jingning Han

Refactor motion field mv buffer

Reduce the needed memory space for motion field estimation.

Change-Id: I9caa228aa804a06370a34715a1c3463564d8d86b
parent f9970a5d
...@@ -134,6 +134,10 @@ static aom_codec_err_t decoder_destroy(aom_codec_alg_priv_t *ctx) { ...@@ -134,6 +134,10 @@ static aom_codec_err_t decoder_destroy(aom_codec_alg_priv_t *ctx) {
#if CONFIG_MULTITHREAD #if CONFIG_MULTITHREAD
pthread_mutex_destroy(&frame_worker_data->stats_mutex); pthread_mutex_destroy(&frame_worker_data->stats_mutex);
pthread_cond_destroy(&frame_worker_data->stats_cond); pthread_cond_destroy(&frame_worker_data->stats_cond);
#endif
#if CONFIG_MFMV
aom_free(frame_worker_data->pbi->common.tpl_mvs);
frame_worker_data->pbi->common.tpl_mvs = NULL;
#endif #endif
aom_free(frame_worker_data); aom_free(frame_worker_data);
} }
......
...@@ -134,10 +134,6 @@ void av1_free_ref_frame_buffers(BufferPool *pool) { ...@@ -134,10 +134,6 @@ void av1_free_ref_frame_buffers(BufferPool *pool) {
} }
aom_free(pool->frame_bufs[i].mvs); aom_free(pool->frame_bufs[i].mvs);
pool->frame_bufs[i].mvs = NULL; pool->frame_bufs[i].mvs = NULL;
#if CONFIG_MFMV
aom_free(pool->frame_bufs[i].tpl_mvs);
pool->frame_bufs[i].tpl_mvs = NULL;
#endif
aom_free_frame_buffer(&pool->frame_bufs[i].buf); aom_free_frame_buffer(&pool->frame_bufs[i].buf);
#if CONFIG_HASH_ME #if CONFIG_HASH_ME
av1_hash_table_destroy(&pool->frame_bufs[i].hash_table); av1_hash_table_destroy(&pool->frame_bufs[i].hash_table);
......
...@@ -544,8 +544,7 @@ static int add_tpl_ref_mv(const AV1_COMMON *cm, ...@@ -544,8 +544,7 @@ static int add_tpl_ref_mv(const AV1_COMMON *cm,
return coll_blk_count; return coll_blk_count;
const TPL_MV_REF *prev_frame_mvs = const TPL_MV_REF *prev_frame_mvs =
cm->cur_frame->tpl_mvs + cm->tpl_mvs + ((mi_row + mi_pos.row) >> 1) * (cm->mi_stride >> 1) +
((mi_row + mi_pos.row) >> 1) * (cm->mi_stride >> 1) +
((mi_col + mi_pos.col) >> 1); ((mi_col + mi_pos.col) >> 1);
MV_REFERENCE_FRAME rf[2]; MV_REFERENCE_FRAME rf[2];
...@@ -1648,7 +1647,7 @@ void av1_setup_motion_field(AV1_COMMON *cm) { ...@@ -1648,7 +1647,7 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
int lst2_frame_index = 0, lst3_frame_index = 0; int lst2_frame_index = 0, lst3_frame_index = 0;
int bwd_frame_index = 0, alt2_frame_index = 0; int bwd_frame_index = 0, alt2_frame_index = 0;
#endif #endif
TPL_MV_REF *tpl_mvs_base = cm->cur_frame->tpl_mvs; TPL_MV_REF *tpl_mvs_base = cm->tpl_mvs;
for (int ref_frame = 0; ref_frame < INTER_REFS_PER_FRAME; ++ref_frame) { for (int ref_frame = 0; ref_frame < INTER_REFS_PER_FRAME; ++ref_frame) {
int size = ((cm->mi_rows + MAX_MIB_SIZE) >> 1) * (cm->mi_stride >> 1); int size = ((cm->mi_rows + MAX_MIB_SIZE) >> 1) * (cm->mi_stride >> 1);
......
...@@ -141,9 +141,6 @@ typedef struct { ...@@ -141,9 +141,6 @@ typedef struct {
#endif #endif
#endif // CONFIG_FRAME_MARKER #endif // CONFIG_FRAME_MARKER
#if CONFIG_MFMV
TPL_MV_REF *tpl_mvs;
#endif
MV_REF *mvs; MV_REF *mvs;
int mi_rows; int mi_rows;
int mi_cols; int mi_cols;
...@@ -547,6 +544,9 @@ typedef struct AV1Common { ...@@ -547,6 +544,9 @@ typedef struct AV1Common {
#if CONFIG_ADAPT_SCAN #if CONFIG_ADAPT_SCAN
int use_adapt_scan; int use_adapt_scan;
#endif #endif
#if CONFIG_MFMV
TPL_MV_REF *tpl_mvs;
#endif
} AV1_COMMON; } AV1_COMMON;
// TODO(hkuang): Don't need to lock the whole pool after implementing atomic // TODO(hkuang): Don't need to lock the whole pool after implementing atomic
...@@ -642,15 +642,18 @@ static INLINE void ensure_mv_buffer(RefCntBuffer *buf, AV1_COMMON *cm) { ...@@ -642,15 +642,18 @@ static INLINE void ensure_mv_buffer(RefCntBuffer *buf, AV1_COMMON *cm) {
cm, buf->mvs, cm, buf->mvs,
(MV_REF *)aom_calloc(cm->mi_rows * cm->mi_cols, sizeof(*buf->mvs))); (MV_REF *)aom_calloc(cm->mi_rows * cm->mi_cols, sizeof(*buf->mvs)));
#endif // CONFIG_TMV #endif // CONFIG_TMV
}
#if CONFIG_MFMV #if CONFIG_MFMV
aom_free(buf->tpl_mvs); if (cm->tpl_mvs == NULL || buf->mi_rows < cm->mi_rows ||
CHECK_MEM_ERROR(cm, buf->tpl_mvs, (TPL_MV_REF *)aom_calloc( buf->mi_cols < cm->mi_cols) {
((cm->mi_rows + MAX_MIB_SIZE) >> 1) * aom_free(cm->tpl_mvs);
(cm->mi_stride >> 1), CHECK_MEM_ERROR(cm, cm->tpl_mvs, (TPL_MV_REF *)aom_calloc(
sizeof(*buf->tpl_mvs))); ((cm->mi_rows + MAX_MIB_SIZE) >> 1) *
#endif (cm->mi_stride >> 1),
sizeof(*cm->tpl_mvs)));
} }
#endif
} }
#if CONFIG_VAR_REFS #if CONFIG_VAR_REFS
......
...@@ -552,6 +552,11 @@ static void dealloc_compressor_data(AV1_COMP *cpi) { ...@@ -552,6 +552,11 @@ static void dealloc_compressor_data(AV1_COMP *cpi) {
cpi->td.mb.mask_buf = NULL; cpi->td.mb.mask_buf = NULL;
#endif #endif
#if CONFIG_MFMV
aom_free(cm->tpl_mvs);
cm->tpl_mvs = NULL;
#endif
av1_free_ref_frame_buffers(cm->buffer_pool); av1_free_ref_frame_buffers(cm->buffer_pool);
#if CONFIG_LV_MAP #if CONFIG_LV_MAP
av1_free_txb_buf(cpi); av1_free_txb_buf(cpi);
......
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