vp8: Modify to use closest reference in zero_mv bias.
Modify zero_mv bias condition to include check that "closest" reference is last_frame. This is needed for temporal layers, where the last_frame is not always the closest reference. Also, constain zeromv_count to be for last_frame reference. Change-Id: I7af54a809ebf01ef43b9933c9d4095b6cb189390
This commit is contained in:
Родитель
940db8fc4e
Коммит
21a0dade42
|
@ -3150,10 +3150,8 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
|
|
||||||
cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx;
|
cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[GOLDEN_FRAME] = cm->current_video_frame;
|
cpi->current_ref_frames[GOLDEN_FRAME] = cm->current_video_frame;
|
||||||
cpi->current_ref_frames[ALTREF_FRAME] = cm->current_video_frame;
|
cpi->current_ref_frames[ALTREF_FRAME] = cm->current_video_frame;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else /* For non key frames */
|
else /* For non key frames */
|
||||||
{
|
{
|
||||||
|
@ -3165,9 +3163,7 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
|
cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
|
||||||
cm->alt_fb_idx = cm->new_fb_idx;
|
cm->alt_fb_idx = cm->new_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[ALTREF_FRAME] = cm->current_video_frame;
|
cpi->current_ref_frames[ALTREF_FRAME] = cm->current_video_frame;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (cm->copy_buffer_to_arf)
|
else if (cm->copy_buffer_to_arf)
|
||||||
{
|
{
|
||||||
|
@ -3181,10 +3177,8 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
|
yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
|
||||||
cm->alt_fb_idx = cm->lst_fb_idx;
|
cm->alt_fb_idx = cm->lst_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[ALTREF_FRAME] =
|
cpi->current_ref_frames[ALTREF_FRAME] =
|
||||||
cpi->current_ref_frames[LAST_FRAME];
|
cpi->current_ref_frames[LAST_FRAME];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* if (cm->copy_buffer_to_arf == 2) */
|
else /* if (cm->copy_buffer_to_arf == 2) */
|
||||||
|
@ -3195,10 +3189,8 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
|
yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
|
||||||
cm->alt_fb_idx = cm->gld_fb_idx;
|
cm->alt_fb_idx = cm->gld_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[ALTREF_FRAME] =
|
cpi->current_ref_frames[ALTREF_FRAME] =
|
||||||
cpi->current_ref_frames[GOLDEN_FRAME];
|
cpi->current_ref_frames[GOLDEN_FRAME];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3211,9 +3203,7 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
|
cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
|
||||||
cm->gld_fb_idx = cm->new_fb_idx;
|
cm->gld_fb_idx = cm->new_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[GOLDEN_FRAME] = cm->current_video_frame;
|
cpi->current_ref_frames[GOLDEN_FRAME] = cm->current_video_frame;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (cm->copy_buffer_to_gf)
|
else if (cm->copy_buffer_to_gf)
|
||||||
{
|
{
|
||||||
|
@ -3227,10 +3217,8 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
|
yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
|
||||||
cm->gld_fb_idx = cm->lst_fb_idx;
|
cm->gld_fb_idx = cm->lst_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[GOLDEN_FRAME] =
|
cpi->current_ref_frames[GOLDEN_FRAME] =
|
||||||
cpi->current_ref_frames[LAST_FRAME];
|
cpi->current_ref_frames[LAST_FRAME];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* if (cm->copy_buffer_to_gf == 2) */
|
else /* if (cm->copy_buffer_to_gf == 2) */
|
||||||
|
@ -3241,10 +3229,8 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
|
yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
|
||||||
cm->gld_fb_idx = cm->alt_fb_idx;
|
cm->gld_fb_idx = cm->alt_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[GOLDEN_FRAME] =
|
cpi->current_ref_frames[GOLDEN_FRAME] =
|
||||||
cpi->current_ref_frames[ALTREF_FRAME];
|
cpi->current_ref_frames[ALTREF_FRAME];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3256,9 +3242,7 @@ static void update_reference_frames(VP8_COMP *cpi)
|
||||||
cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP8_LAST_FRAME;
|
cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP8_LAST_FRAME;
|
||||||
cm->lst_fb_idx = cm->new_fb_idx;
|
cm->lst_fb_idx = cm->new_fb_idx;
|
||||||
|
|
||||||
#if CONFIG_MULTI_RES_ENCODING
|
|
||||||
cpi->current_ref_frames[LAST_FRAME] = cm->current_video_frame;
|
cpi->current_ref_frames[LAST_FRAME] = cm->current_video_frame;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_TEMPORAL_DENOISING
|
#if CONFIG_TEMPORAL_DENOISING
|
||||||
|
@ -3494,6 +3478,31 @@ static void encode_frame_to_data_rate
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Find the reference frame closest to the current frame.
|
||||||
|
cpi->closest_reference_frame = LAST_FRAME;
|
||||||
|
if (cm->frame_type != KEY_FRAME) {
|
||||||
|
int i;
|
||||||
|
MV_REFERENCE_FRAME closest_ref = INTRA_FRAME;
|
||||||
|
if (cpi->ref_frame_flags & VP8_LAST_FRAME) {
|
||||||
|
closest_ref = LAST_FRAME;
|
||||||
|
} else if (cpi->ref_frame_flags & VP8_GOLD_FRAME) {
|
||||||
|
closest_ref = GOLDEN_FRAME;
|
||||||
|
} else if (cpi->ref_frame_flags & VP8_ALTR_FRAME) {
|
||||||
|
closest_ref = ALTREF_FRAME;
|
||||||
|
}
|
||||||
|
for (i = 1; i <= 3; i++) {
|
||||||
|
vpx_ref_frame_type_t ref_frame_type = (vpx_ref_frame_type_t)
|
||||||
|
((i == 3) ? 4 : i);
|
||||||
|
if (cpi->ref_frame_flags & ref_frame_type) {
|
||||||
|
if ((cm->current_video_frame - cpi->current_ref_frames[i]) <
|
||||||
|
(cm->current_video_frame - cpi->current_ref_frames[closest_ref])) {
|
||||||
|
closest_ref = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cpi->closest_reference_frame = closest_ref;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set various flags etc to special state if it is a key frame */
|
/* Set various flags etc to special state if it is a key frame */
|
||||||
if (cm->frame_type == KEY_FRAME)
|
if (cm->frame_type == KEY_FRAME)
|
||||||
{
|
{
|
||||||
|
@ -4420,7 +4429,8 @@ static void encode_frame_to_data_rate
|
||||||
{
|
{
|
||||||
for (mb_col = 0; mb_col < cm->mb_cols; mb_col ++)
|
for (mb_col = 0; mb_col < cm->mb_cols; mb_col ++)
|
||||||
{
|
{
|
||||||
if(tmp->mbmi.mode == ZEROMV)
|
if (tmp->mbmi.mode == ZEROMV &&
|
||||||
|
tmp->mbmi.ref_frame == LAST_FRAME)
|
||||||
cpi->zeromv_count++;
|
cpi->zeromv_count++;
|
||||||
tmp++;
|
tmp++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,9 +684,10 @@ typedef struct VP8_COMP
|
||||||
int mr_low_res_mb_cols;
|
int mr_low_res_mb_cols;
|
||||||
/* Indicate if lower-res mv info is available */
|
/* Indicate if lower-res mv info is available */
|
||||||
unsigned char mr_low_res_mv_avail;
|
unsigned char mr_low_res_mv_avail;
|
||||||
|
#endif
|
||||||
/* The frame number of each reference frames */
|
/* The frame number of each reference frames */
|
||||||
unsigned int current_ref_frames[MAX_REF_FRAMES];
|
unsigned int current_ref_frames[MAX_REF_FRAMES];
|
||||||
#endif
|
MV_REFERENCE_FRAME closest_reference_frame;
|
||||||
|
|
||||||
struct rd_costs_struct
|
struct rd_costs_struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -505,16 +505,11 @@ static int evaluate_inter_mode(unsigned int* sse, int rate2, int* distortion2,
|
||||||
|
|
||||||
this_rd = RDCOST(x->rdmult, x->rddiv, rate2, *distortion2);
|
this_rd = RDCOST(x->rdmult, x->rddiv, rate2, *distortion2);
|
||||||
|
|
||||||
/* Adjust rd to bias to ZEROMV */
|
// Adjust rd for ZEROMV and LAST, if LAST is the closest reference frame.
|
||||||
if(this_mode == ZEROMV)
|
if (this_mode == ZEROMV &&
|
||||||
|
x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME &&
|
||||||
|
cpi->closest_reference_frame == LAST_FRAME)
|
||||||
{
|
{
|
||||||
/* Bias to ZEROMV on LAST_FRAME reference when it is available. */
|
|
||||||
if ((cpi->ref_frame_flags & VP8_LAST_FRAME &
|
|
||||||
cpi->common.refresh_last_frame)
|
|
||||||
&& x->e_mbd.mode_info_context->mbmi.ref_frame != LAST_FRAME)
|
|
||||||
rd_adj = 100;
|
|
||||||
|
|
||||||
// rd_adj <= 100
|
|
||||||
this_rd = ((int64_t)this_rd) * rd_adj / 100;
|
this_rd = ((int64_t)this_rd) * rd_adj / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче