summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/vp9_spatial_svc_encoder.c3
-rw-r--r--vp9/encoder/vp9_encoder.c6
-rw-r--r--vp9/encoder/vp9_svc_layercontext.c6
-rw-r--r--vp9/encoder/vp9_svc_layercontext.h6
-rw-r--r--vp9/vp9_cx_iface.c3
-rw-r--r--vpx/vp8cx.h1
6 files changed, 24 insertions, 1 deletions
diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c
index 17beea15c..50d9106ac 100644
--- a/examples/vp9_spatial_svc_encoder.c
+++ b/examples/vp9_spatial_svc_encoder.c
@@ -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
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 714c8a241..f0e4901d5 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -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)) {
diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c
index 3713ff368..78a771a41 100644
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -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);
+}
diff --git a/vp9/encoder/vp9_svc_layercontext.h b/vp9/encoder/vp9_svc_layercontext.h
index 60fb7da75..fdd62d7de 100644
--- a/vp9/encoder/vp9_svc_layercontext.h
+++ b/vp9/encoder/vp9_svc_layercontext.h
@@ -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
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 251acf3c5..6cf4134ea 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -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;
}
diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h
index 6aa5dcb98..4c11a25cd 100644
--- a/vpx/vp8cx.h
+++ b/vpx/vp8cx.h
@@ -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.