vp9-svc: Allow for setting framerate per spatial layer.

Add duration to set_svc_ref_frame_config.

BUG=b/113346831

Change-Id: I63613aed6b1183f98d04831600a6bdd645c740df
This commit is contained in:
Marco Paniconi
2018-08-29 15:05:46 -07:00
parent 00207bc812
commit 04b3d49bac
6 changed files with 24 additions and 1 deletions

View File

@@ -925,6 +925,9 @@ int main(int argc, const char **argv) {
svc_ctx.spatial_layers, frame_cnt == 0,
&ref_frame_config);
}
ref_frame_config.duration[0] = frame_duration * 1;
ref_frame_config.duration[1] = frame_duration * 1;
vpx_codec_control(&codec, VP9E_SET_SVC_REF_FRAME_CONFIG,
&ref_frame_config);
// Keep track of input frames, to account for frame drops in rate control

View File

@@ -6237,7 +6237,11 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
// adjust frame rates based on timestamps given
if (cm->show_frame) {
adjust_frame_rate(cpi, source);
if (cpi->use_svc && cpi->svc.use_set_ref_frame_config &&
cpi->svc.duration[cpi->svc.spatial_layer_id] > 0)
vp9_svc_adjust_frame_rate(cpi);
else
adjust_frame_rate(cpi, source);
}
if (is_one_pass_cbr_svc(cpi)) {

View File

@@ -1200,3 +1200,9 @@ void vp9_svc_update_ref_frame(VP9_COMP *const cpi) {
vp9_copy_flags_ref_update_idx(cpi);
vp9_svc_update_ref_frame_buffer_idx(cpi);
}
void vp9_svc_adjust_frame_rate(VP9_COMP *cpi) {
int64_t this_duration =
cpi->svc.timebase_fac * cpi->svc.duration[cpi->svc.spatial_layer_id];
vp9_new_framerate(cpi, 10000000.0 / this_duration);
}

View File

@@ -177,6 +177,10 @@ typedef struct SVC {
int temporal_layer_id_per_spatial[VPX_SS_MAX_LAYERS];
int first_spatial_layer_to_encode;
int64_t duration[VPX_SS_MAX_LAYERS];
int64_t timebase_fac;
} SVC;
struct VP9_COMP;
@@ -244,6 +248,8 @@ void vp9_svc_update_ref_frame_buffer_idx(struct VP9_COMP *const cpi);
void vp9_svc_update_ref_frame(struct VP9_COMP *const cpi);
void vp9_svc_adjust_frame_rate(struct VP9_COMP *const cpi);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -1150,6 +1150,8 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
size_t size, cx_data_sz;
unsigned char *cx_data;
cpi->svc.timebase_fac = timebase_units_to_ticks(timebase, 1);
// Set up internal flags
if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) cpi->b_calculate_psnr = 1;
@@ -1537,6 +1539,7 @@ static vpx_codec_err_t ctrl_set_svc_ref_frame_config(vpx_codec_alg_priv_t *ctx,
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];
cpi->svc.duration[sl] = data->duration[sl];
}
return VPX_CODEC_OK;
}

View File

@@ -810,6 +810,7 @@ typedef struct vpx_svc_ref_frame_config {
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. */
int64_t duration[VPX_SS_MAX_LAYERS]; /**< Duration per spatial layer. */
} vpx_svc_ref_frame_config_t;
/*!\brief VP9 svc frame dropping mode.