Copy ref frame index in SVC struct after set in encoder.
Rename ext_{lst,gld,alt}_fb_idx to {lst,gld,alt}_fb_idx.
Bump up ABI version.
BUG=webm:1527
Change-Id: I06209040cb83d374030f40b79f0b36b0efe9f97d
if (cpi->refresh_alt_ref_frame)
svc->ref_frame_index[cpi->alt_fb_idx] = svc->current_superframe;
}
+ // Copy flags from encoder to SVC struct.
+ vp9_copy_flags_ref_update_idx(cpi);
}
}
svc->last_layer_dropped[sl] = 0;
svc->drop_spatial_layer[sl] = 0;
svc->ext_frame_flags[sl] = 0;
- svc->ext_lst_fb_idx[sl] = 0;
- svc->ext_gld_fb_idx[sl] = 1;
- svc->ext_alt_fb_idx[sl] = 2;
+ svc->lst_fb_idx[sl] = 0;
+ svc->gld_fb_idx[sl] = 1;
+ svc->alt_fb_idx[sl] = 2;
svc->downsample_filter_type[sl] = BILINEAR;
svc->downsample_filter_phase[sl] = 8; // Set to 8 for averaging filter.
svc->framedrop_thresh[sl] = oxcf->drop_frames_water_mark;
}
}
+void vp9_copy_flags_ref_update_idx(VP9_COMP *const cpi) {
+ SVC *const svc = &cpi->svc;
+ static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
+ VP9_ALT_FLAG };
+ int sl = svc->spatial_layer_id;
+ svc->lst_fb_idx[sl] = cpi->lst_fb_idx;
+ svc->gld_fb_idx[sl] = cpi->gld_fb_idx;
+ svc->alt_fb_idx[sl] = cpi->alt_fb_idx;
+
+ svc->update_last[sl] = (uint8_t)cpi->refresh_last_frame;
+ svc->update_golden[sl] = (uint8_t)cpi->refresh_golden_frame;
+ svc->update_altref[sl] = (uint8_t)cpi->refresh_alt_ref_frame;
+ svc->reference_last[sl] =
+ (uint8_t)(cpi->ref_frame_flags & flag_list[LAST_FRAME]);
+ svc->reference_golden[sl] =
+ (uint8_t)(cpi->ref_frame_flags & flag_list[GOLDEN_FRAME]);
+ svc->reference_altref[sl] =
+ (uint8_t)(cpi->ref_frame_flags & flag_list[ALTREF_FRAME]);
+}
+
int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) {
int width = 0, height = 0;
LAYER_CONTEXT *lc = NULL;
cpi->svc.spatial_layer_id = cpi->svc.spatial_layer_to_encode;
sl = cpi->svc.spatial_layer_id;
vp9_apply_encoding_flags(cpi, cpi->svc.ext_frame_flags[sl]);
- cpi->lst_fb_idx = cpi->svc.ext_lst_fb_idx[sl];
- cpi->gld_fb_idx = cpi->svc.ext_gld_fb_idx[sl];
- cpi->alt_fb_idx = cpi->svc.ext_alt_fb_idx[sl];
+ cpi->lst_fb_idx = cpi->svc.lst_fb_idx[sl];
+ cpi->gld_fb_idx = cpi->svc.gld_fb_idx[sl];
+ cpi->alt_fb_idx = cpi->svc.alt_fb_idx[sl];
}
}
if (cpi->svc.spatial_layer_id == 0) cpi->svc.high_source_sad_superframe = 0;
+ vp9_copy_flags_ref_update_idx(cpi);
+
if (vp9_set_size_literal(cpi, width, height) != 0)
return VPX_CODEC_INVALID_PARAM;
// Frame flags and buffer indexes for each spatial layer, set by the
// application (external settings).
int ext_frame_flags[VPX_MAX_LAYERS];
- int ext_lst_fb_idx[VPX_MAX_LAYERS];
- int ext_gld_fb_idx[VPX_MAX_LAYERS];
- int ext_alt_fb_idx[VPX_MAX_LAYERS];
+ int lst_fb_idx[VPX_MAX_LAYERS];
+ int gld_fb_idx[VPX_MAX_LAYERS];
+ int alt_fb_idx[VPX_MAX_LAYERS];
int ref_frame_index[REF_FRAMES];
int force_zero_mode_spatial_ref;
int current_superframe;
// currently checked for each superframe prior to encoding, on the full
// resolution source.
int high_source_sad_superframe;
+
+ // Flags used to get SVC pattern info.
+ uint8_t update_last[VPX_SS_MAX_LAYERS];
+ uint8_t update_golden[VPX_SS_MAX_LAYERS];
+ uint8_t update_altref[VPX_SS_MAX_LAYERS];
+ uint8_t reference_last[VPX_SS_MAX_LAYERS];
+ uint8_t reference_golden[VPX_SS_MAX_LAYERS];
+ uint8_t reference_altref[VPX_SS_MAX_LAYERS];
} SVC;
struct VP9_COMP;
// Start a frame and initialize svc parameters
int vp9_svc_start_frame(struct VP9_COMP *const cpi);
+void vp9_copy_flags_ref_update_idx(struct VP9_COMP *const cpi);
+
int vp9_one_pass_cbr_svc_start_layer(struct VP9_COMP *const cpi);
void vp9_free_svc_cyclic_refresh(struct VP9_COMP *const cpi);
return VPX_CODEC_OK;
}
+static vpx_codec_err_t ctrl_get_svc_ref_frame_config(vpx_codec_alg_priv_t *ctx,
+ va_list args) {
+ VP9_COMP *const cpi = ctx->cpi;
+ vpx_svc_ref_frame_config_t *data = va_arg(args, vpx_svc_ref_frame_config_t *);
+ int sl;
+ for (sl = 0; sl <= cpi->svc.spatial_layer_id; sl++) {
+ data->update_last[sl] = cpi->svc.update_last[sl];
+ data->update_golden[sl] = cpi->svc.update_golden[sl];
+ data->update_alt_ref[sl] = cpi->svc.update_altref[sl];
+ data->reference_last[sl] = cpi->svc.reference_last[sl];
+ data->reference_golden[sl] = cpi->svc.reference_golden[sl];
+ data->reference_alt_ref[sl] = cpi->svc.reference_altref[sl];
+ data->lst_fb_idx[sl] = cpi->svc.lst_fb_idx[sl];
+ data->gld_fb_idx[sl] = cpi->svc.gld_fb_idx[sl];
+ data->alt_fb_idx[sl] = cpi->svc.alt_fb_idx[sl];
+ }
+ return VPX_CODEC_OK;
+}
+
static vpx_codec_err_t ctrl_set_svc_ref_frame_config(vpx_codec_alg_priv_t *ctx,
va_list args) {
VP9_COMP *const cpi = ctx->cpi;
int sl;
for (sl = 0; sl < cpi->svc.number_spatial_layers; ++sl) {
cpi->svc.ext_frame_flags[sl] = data->frame_flags[sl];
- cpi->svc.ext_lst_fb_idx[sl] = data->lst_fb_idx[sl];
- cpi->svc.ext_gld_fb_idx[sl] = data->gld_fb_idx[sl];
- cpi->svc.ext_alt_fb_idx[sl] = data->alt_fb_idx[sl];
+ cpi->svc.lst_fb_idx[sl] = data->lst_fb_idx[sl];
+ cpi->svc.gld_fb_idx[sl] = data->gld_fb_idx[sl];
+ cpi->svc.alt_fb_idx[sl] = data->alt_fb_idx[sl];
}
return VPX_CODEC_OK;
}
{ VP9E_GET_SVC_LAYER_ID, ctrl_get_svc_layer_id },
{ VP9E_GET_ACTIVEMAP, ctrl_get_active_map },
{ VP9E_GET_LEVEL, ctrl_get_level },
+ { VP9E_GET_SVC_REF_FRAME_CONFIG, ctrl_get_svc_ref_frame_config },
{ -1, NULL },
};
* Supported in codecs: VP9
*/
VP9E_SET_SVC_FRAME_DROP_LAYER,
+
+ /*!\brief Codec control function to get the refresh and reference flags and
+ * the buffer indices, up to the last encoded spatial layer.
+ *
+ * Supported in codecs: VP9
+ */
+ VP9E_GET_SVC_REF_FRAME_CONFIG,
};
/*!\brief vpx 1-D scaling mode
*
*/
typedef struct vpx_svc_ref_frame_config {
- int frame_flags[VPX_TS_MAX_LAYERS]; /**< Frame flags. */
- int lst_fb_idx[VPX_TS_MAX_LAYERS]; /**< Last buffer index. */
- int gld_fb_idx[VPX_TS_MAX_LAYERS]; /**< Golden buffer index. */
- int alt_fb_idx[VPX_TS_MAX_LAYERS]; /**< Altref buffer index. */
+ // TODO(jianj/marpan): Remove the usage of frame_flags, instead use the
+ // update and reference flags.
+ int frame_flags[VPX_SS_MAX_LAYERS]; /**< Frame flags. */
+ int lst_fb_idx[VPX_SS_MAX_LAYERS]; /**< Last buffer index. */
+ int gld_fb_idx[VPX_SS_MAX_LAYERS]; /**< Golden buffer index. */
+ int alt_fb_idx[VPX_SS_MAX_LAYERS]; /**< Altref buffer index. */
+ int update_last[VPX_SS_MAX_LAYERS]; /**< Update last. */
+ int update_golden[VPX_SS_MAX_LAYERS]; /**< Update golden. */
+ int update_alt_ref[VPX_SS_MAX_LAYERS]; /**< Update altref. */
+ int reference_last[VPX_SS_MAX_LAYERS]; /**< Last as eference. */
+ int reference_golden[VPX_SS_MAX_LAYERS]; /**< Golden as reference. */
+ int reference_alt_ref[VPX_SS_MAX_LAYERS]; /**< Altref as reference. */
} vpx_svc_ref_frame_config_t;
/*!\brief VP9 svc frame dropping mode.
VPX_CTRL_USE_TYPE(VP9E_SET_SVC_FRAME_DROP_LAYER, vpx_svc_frame_drop_t *)
#define VPX_CTRL_VP9E_SET_SVC_FRAME_DROP_LAYER
+VPX_CTRL_USE_TYPE(VP9E_GET_SVC_REF_FRAME_CONFIG, vpx_svc_ref_frame_config_t *)
+#define VPX_CTRL_VP9E_GET_SVC_REF_FRAME_CONFIG
+
/*!\endcond */
/*! @} - end defgroup vp8_encoder */
#ifdef __cplusplus
* fields to structures
*/
#define VPX_ENCODER_ABI_VERSION \
- (11 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
+ (12 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Encoder capabilities bitfield
*