diff options
Diffstat (limited to 'vp9/encoder/vp9_encoder.c')
-rw-r--r-- | vp9/encoder/vp9_encoder.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 6ba4ac69f..8296cd943 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -131,7 +131,7 @@ static void setup_frame(VP9_COMP *cpi) { } if (cm->frame_type == KEY_FRAME) { - if (!(cpi->use_svc && cpi->svc.number_temporal_layers == 1)) + if (!is_spatial_svc(cpi)) cpi->refresh_golden_frame = 1; cpi->refresh_alt_ref_frame = 1; } else { @@ -477,7 +477,7 @@ static void update_frame_size(VP9_COMP *cpi) { vp9_init_context_buffers(cm); init_macroblockd(cm, xd); - if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) { + if (is_spatial_svc(cpi)) { if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, @@ -1565,22 +1565,15 @@ void vp9_update_reference_frames(VP9_COMP *cpi) { &cm->ref_frame_map[cpi->gld_fb_idx], cm->new_fb_idx); ref_cnt_fb(cm->frame_bufs, &cm->ref_frame_map[cpi->alt_fb_idx], cm->new_fb_idx); - } else if (!cpi->multi_arf_allowed && cpi->refresh_golden_frame && - cpi->rc.is_src_frame_alt_ref && - (!cpi->use_svc || // Add spatial svc base layer case here - (cpi->svc.number_temporal_layers == 1 && - cpi->svc.spatial_layer_id == 0 && - cpi->svc.layer_context[0].gold_ref_idx >=0 && - cpi->oxcf.ss_play_alternate[0]))) { - /* Preserve the previously existing golden frame and update the frame in - * the alt ref slot instead. This is highly specific to the current use of - * alt-ref as a forward reference, and this needs to be generalized as - * other uses are implemented (like RTC/temporal scaling) - * - * The update to the buffer in the alt ref slot was signaled in - * vp9_pack_bitstream(), now swap the buffer pointers so that it's treated - * as the golden frame next time. - */ + } else if (vp9_preserve_existing_gf(cpi)) { + // We have decided to preserve the previously existing golden frame as our + // new ARF frame. However, in the short term in function + // vp9_bitstream.c::get_refresh_mask() we left it in the GF slot and, if + // we're updating the GF with the current decoded frame, we save it to the + // ARF slot instead. + // We now have to update the ARF with the current frame and swap gld_fb_idx + // and alt_fb_idx so that, overall, we've stored the old GF in the new ARF + // slot and, if we're updating the GF, the current frame becomes the new GF. int tmp; ref_cnt_fb(cm->frame_bufs, @@ -1590,7 +1583,7 @@ void vp9_update_reference_frames(VP9_COMP *cpi) { cpi->alt_fb_idx = cpi->gld_fb_idx; cpi->gld_fb_idx = tmp; - if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) { + if (is_spatial_svc(cpi)) { cpi->svc.layer_context[0].gold_ref_idx = cpi->gld_fb_idx; cpi->svc.layer_context[0].alt_ref_idx = cpi->alt_fb_idx; } @@ -2014,7 +2007,7 @@ static void get_ref_frame_flags(VP9_COMP *cpi) { cpi->ref_frame_flags &= ~VP9_GOLD_FLAG; if (cpi->rc.frames_till_gf_update_due == INT_MAX && - !(cpi->use_svc && cpi->svc.number_temporal_layers == 1)) + !is_spatial_svc(cpi)) cpi->ref_frame_flags &= ~VP9_GOLD_FLAG; if (cpi->alt_is_last) @@ -2060,9 +2053,7 @@ static void configure_skippable_frame(VP9_COMP *cpi) { // according to the variance SVC *const svc = &cpi->svc; - const int is_spatial_svc = (svc->number_spatial_layers > 1) && - (svc->number_temporal_layers == 1); - TWO_PASS *const twopass = is_spatial_svc ? + TWO_PASS *const twopass = is_spatial_svc(cpi) ? &svc->layer_context[svc->spatial_layer_id].twopass : &cpi->twopass; @@ -2190,7 +2181,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, // Check if the current frame is skippable for the partition search in the // second pass according to the first pass stats if (cpi->pass == 2 && - (!cpi->use_svc || cpi->svc.number_temporal_layers == 1)) { + (!cpi->use_svc || is_spatial_svc(cpi))) { configure_skippable_frame(cpi); } @@ -2442,7 +2433,7 @@ int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags, vpx_usec_timer_start(&timer); #if CONFIG_SPATIAL_SVC - if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) + if (is_spatial_svc(cpi)) res = vp9_svc_lookahead_push(cpi, cpi->lookahead, sd, time_stamp, end_time, frame_flags); else @@ -2572,14 +2563,11 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, YV12_BUFFER_CONFIG *force_src_buffer = NULL; MV_REFERENCE_FRAME ref_frame; int arf_src_index; - const int is_spatial_svc = cpi->use_svc && - (cpi->svc.number_temporal_layers == 1) && - (cpi->svc.number_spatial_layers > 1); if (!cpi) return -1; - if (is_spatial_svc && cpi->pass == 2) { + if (is_spatial_svc(cpi) && cpi->pass == 2) { #if CONFIG_SPATIAL_SVC vp9_svc_lookahead_peek(cpi, cpi->lookahead, 0, 1); #endif @@ -2606,7 +2594,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, assert(arf_src_index <= rc->frames_to_key); #if CONFIG_SPATIAL_SVC - if (is_spatial_svc) + if (is_spatial_svc(cpi)) cpi->source = vp9_svc_lookahead_peek(cpi, cpi->lookahead, arf_src_index, 0); else @@ -2616,7 +2604,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, cpi->alt_ref_source = cpi->source; #if CONFIG_SPATIAL_SVC - if (is_spatial_svc && cpi->svc.spatial_layer_id > 0) { + if (is_spatial_svc(cpi) && cpi->svc.spatial_layer_id > 0) { int i; // Reference a hidden frame from a lower layer for (i = cpi->svc.spatial_layer_id - 1; i >= 0; --i) { @@ -2651,7 +2639,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, // Get last frame source. if (cm->current_video_frame > 0) { #if CONFIG_SPATIAL_SVC - if (is_spatial_svc) + if (is_spatial_svc(cpi)) cpi->last_source = vp9_svc_lookahead_peek(cpi, cpi->lookahead, -1, 0); else #endif @@ -2662,7 +2650,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, // Read in the source frame. #if CONFIG_SPATIAL_SVC - if (is_spatial_svc) + if (is_spatial_svc(cpi)) cpi->source = vp9_svc_lookahead_pop(cpi, cpi->lookahead, flush); else #endif @@ -2778,13 +2766,13 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, } if (cpi->pass == 1 && - (!cpi->use_svc || cpi->svc.number_temporal_layers == 1)) { + (!cpi->use_svc || is_spatial_svc(cpi))) { const int lossless = is_lossless_requested(&cpi->oxcf); cpi->mb.fwd_txm4x4 = lossless ? vp9_fwht4x4 : vp9_fdct4x4; cpi->mb.itxm_add = lossless ? vp9_iwht4x4_add : vp9_idct4x4_add; vp9_first_pass(cpi); } else if (cpi->pass == 2 && - (!cpi->use_svc || cpi->svc.number_temporal_layers == 1)) { + (!cpi->use_svc || is_spatial_svc(cpi))) { Pass2Encode(cpi, size, dest, frame_flags); } else if (cpi->use_svc) { SvcEncode(cpi, size, dest, frame_flags); |