Remove buffer-to-buffer copy logic
This is the first in a series of commits to add additional reference frames to the codec. Each frame will be able to update any of the available references, but copying between references is not supported. Change-Id: I5945b5ce6cc3582c495102b4e7eed4f08c44d5a1
This commit is contained in:
Родитель
9bf73f46f9
Коммит
b8e027989f
|
@ -204,9 +204,6 @@ void vp9_create_common(VP9_COMMON *oci) {
|
|||
/* Initialise reference frame sign bias structure to defaults */
|
||||
vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias));
|
||||
|
||||
/* Default disable buffer to buffer copying */
|
||||
oci->copy_buffer_to_gf = 0;
|
||||
oci->copy_buffer_to_arf = 0;
|
||||
oci->kf_ymode_probs_update = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,9 +206,6 @@ typedef struct VP9Common {
|
|||
int refresh_golden_frame; /* Two state 0 = NO, 1 = YES */
|
||||
int refresh_alt_ref_frame; /* Two state 0 = NO, 1 = YES */
|
||||
|
||||
int copy_buffer_to_gf; /* 0 none, 1 Last to GF, 2 ARF to GF */
|
||||
int copy_buffer_to_arf; /* 0 none, 1 Last to ARF, 2 GF to ARF */
|
||||
|
||||
int refresh_entropy_probs; /* Two state 0 = NO, 1 = YES */
|
||||
|
||||
int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */
|
||||
|
|
|
@ -1290,8 +1290,6 @@ static void init_frame(VP9D_COMP *pbi) {
|
|||
/* All buffers are implicitly updated on key frames. */
|
||||
pc->refresh_golden_frame = 1;
|
||||
pc->refresh_alt_ref_frame = 1;
|
||||
pc->copy_buffer_to_gf = 0;
|
||||
pc->copy_buffer_to_arf = 0;
|
||||
|
||||
/* Note that Golden and Altref modes cannot be used on a key frame so
|
||||
* ref_frame_sign_bias[] is undefined and meaningless
|
||||
|
@ -1656,17 +1654,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
|
|||
vpx_memcpy(&pc->fc, &pc->lfc, sizeof(pc->fc));
|
||||
}
|
||||
|
||||
/* Buffer to buffer copy flags. */
|
||||
pc->copy_buffer_to_gf = 0;
|
||||
|
||||
if (!pc->refresh_golden_frame)
|
||||
pc->copy_buffer_to_gf = vp9_read_literal(&header_bc, 2);
|
||||
|
||||
pc->copy_buffer_to_arf = 0;
|
||||
|
||||
if (!pc->refresh_alt_ref_frame)
|
||||
pc->copy_buffer_to_arf = vp9_read_literal(&header_bc, 2);
|
||||
|
||||
pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp9_read_bit(&header_bc);
|
||||
pc->ref_frame_sign_bias[ALTREF_FRAME] = vp9_read_bit(&header_bc);
|
||||
|
||||
|
|
|
@ -259,36 +259,8 @@ static int swap_frame_buffers(VP9_COMMON *cm) {
|
|||
int err = 0;
|
||||
|
||||
/* The alternate reference frame or golden frame can be updated
|
||||
* using the new, last, or golden/alt ref frame. If it
|
||||
* is updated using the newly decoded frame it is a refresh.
|
||||
* An update using the last or golden/alt ref frame is a copy.
|
||||
* using the new frame.
|
||||
*/
|
||||
if (cm->copy_buffer_to_arf) {
|
||||
int new_fb = 0;
|
||||
|
||||
if (cm->copy_buffer_to_arf == 1)
|
||||
new_fb = cm->lst_fb_idx;
|
||||
else if (cm->copy_buffer_to_arf == 2)
|
||||
new_fb = cm->gld_fb_idx;
|
||||
else
|
||||
err = -1;
|
||||
|
||||
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, new_fb);
|
||||
}
|
||||
|
||||
if (cm->copy_buffer_to_gf) {
|
||||
int new_fb = 0;
|
||||
|
||||
if (cm->copy_buffer_to_gf == 1)
|
||||
new_fb = cm->lst_fb_idx;
|
||||
else if (cm->copy_buffer_to_gf == 2)
|
||||
new_fb = cm->alt_fb_idx;
|
||||
else
|
||||
err = -1;
|
||||
|
||||
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, new_fb);
|
||||
}
|
||||
|
||||
if (cm->refresh_golden_frame)
|
||||
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
|
||||
|
||||
|
|
|
@ -1776,19 +1776,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
|
|||
vp9_write_bit(&header_bc, pc->refresh_golden_frame);
|
||||
vp9_write_bit(&header_bc, pc->refresh_alt_ref_frame);
|
||||
|
||||
// For inter frames the current default behavior is that when
|
||||
// cm->refresh_golden_frame is set we copy the old GF over to
|
||||
// the ARF buffer. This is purely an encoder decision at present.
|
||||
if (pc->refresh_golden_frame)
|
||||
pc->copy_buffer_to_arf = 2;
|
||||
|
||||
// If not being updated from current frame should either GF or ARF be updated from another buffer
|
||||
if (!pc->refresh_golden_frame)
|
||||
vp9_write_literal(&header_bc, pc->copy_buffer_to_gf, 2);
|
||||
|
||||
if (!pc->refresh_alt_ref_frame)
|
||||
vp9_write_literal(&header_bc, pc->copy_buffer_to_arf, 2);
|
||||
|
||||
// Indicate reference frame sign bias for Golden and ARF frames (always 0 for last frame buffer)
|
||||
vp9_write_bit(&header_bc, pc->ref_frame_sign_bias[GOLDEN_FRAME]);
|
||||
vp9_write_bit(&header_bc, pc->ref_frame_sign_bias[ALTREF_FRAME]);
|
||||
|
|
|
@ -2578,51 +2578,15 @@ static void update_reference_frames(VP9_COMMON *cm) {
|
|||
cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx;
|
||||
} else { /* For non key frames */
|
||||
if (cm->refresh_alt_ref_frame) {
|
||||
assert(!cm->copy_buffer_to_arf);
|
||||
|
||||
cm->yv12_fb[cm->new_fb_idx].flags |= VP9_ALT_FLAG;
|
||||
cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP9_ALT_FLAG;
|
||||
cm->alt_fb_idx = cm->new_fb_idx;
|
||||
} else if (cm->copy_buffer_to_arf) {
|
||||
assert(!(cm->copy_buffer_to_arf & ~0x3));
|
||||
|
||||
if (cm->copy_buffer_to_arf == 1) {
|
||||
if (cm->alt_fb_idx != cm->lst_fb_idx) {
|
||||
yv12_fb[cm->lst_fb_idx].flags |= VP9_ALT_FLAG;
|
||||
yv12_fb[cm->alt_fb_idx].flags &= ~VP9_ALT_FLAG;
|
||||
cm->alt_fb_idx = cm->lst_fb_idx;
|
||||
}
|
||||
} else { /* if (cm->copy_buffer_to_arf == 2) */
|
||||
if (cm->alt_fb_idx != cm->gld_fb_idx) {
|
||||
yv12_fb[cm->gld_fb_idx].flags |= VP9_ALT_FLAG;
|
||||
yv12_fb[cm->alt_fb_idx].flags &= ~VP9_ALT_FLAG;
|
||||
cm->alt_fb_idx = cm->gld_fb_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cm->refresh_golden_frame) {
|
||||
assert(!cm->copy_buffer_to_gf);
|
||||
|
||||
cm->yv12_fb[cm->new_fb_idx].flags |= VP9_GOLD_FLAG;
|
||||
cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP9_GOLD_FLAG;
|
||||
cm->gld_fb_idx = cm->new_fb_idx;
|
||||
} else if (cm->copy_buffer_to_gf) {
|
||||
assert(!(cm->copy_buffer_to_arf & ~0x3));
|
||||
|
||||
if (cm->copy_buffer_to_gf == 1) {
|
||||
if (cm->gld_fb_idx != cm->lst_fb_idx) {
|
||||
yv12_fb[cm->lst_fb_idx].flags |= VP9_GOLD_FLAG;
|
||||
yv12_fb[cm->gld_fb_idx].flags &= ~VP9_GOLD_FLAG;
|
||||
cm->gld_fb_idx = cm->lst_fb_idx;
|
||||
}
|
||||
} else { /* if (cm->copy_buffer_to_gf == 2) */
|
||||
if (cm->alt_fb_idx != cm->gld_fb_idx) {
|
||||
yv12_fb[cm->alt_fb_idx].flags |= VP9_GOLD_FLAG;
|
||||
yv12_fb[cm->gld_fb_idx].flags &= ~VP9_GOLD_FLAG;
|
||||
cm->gld_fb_idx = cm->alt_fb_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2786,10 +2750,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
|||
cpi->output_frame_rate);
|
||||
}
|
||||
|
||||
// Default turn off buffer to buffer copying
|
||||
cm->copy_buffer_to_gf = 0;
|
||||
cm->copy_buffer_to_arf = 0;
|
||||
|
||||
// Clear zbin over-quant value and mode boost values.
|
||||
cpi->zbin_over_quant = 0;
|
||||
cpi->zbin_mode_boost = 0;
|
||||
|
@ -3810,7 +3770,6 @@ static int frame_is_reference(const VP9_COMP *cpi) {
|
|||
|
||||
return cm->frame_type == KEY_FRAME || cm->refresh_last_frame
|
||||
|| cm->refresh_golden_frame || cm->refresh_alt_ref_frame
|
||||
|| cm->copy_buffer_to_gf || cm->copy_buffer_to_arf
|
||||
|| cm->refresh_entropy_probs
|
||||
|| xd->mode_ref_lf_delta_update
|
||||
|| xd->update_mb_segmentation_map || xd->update_mb_segmentation_data;
|
||||
|
|
Загрузка…
Ссылка в новой задаче