]> granicus.if.org Git - libvpx/commitdiff
vp9-svc: Allow for setting framerate per spatial layer.
authorMarco Paniconi <marpan@google.com>
Wed, 29 Aug 2018 22:05:46 +0000 (15:05 -0700)
committerMarco Paniconi <marpan@google.com>
Wed, 5 Sep 2018 15:55:57 +0000 (08:55 -0700)
Add duration to set_svc_ref_frame_config.

BUG=b/113346831

Change-Id: I63613aed6b1183f98d04831600a6bdd645c740df

examples/vp9_spatial_svc_encoder.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_svc_layercontext.c
vp9/encoder/vp9_svc_layercontext.h
vp9/vp9_cx_iface.c
vpx/vp8cx.h

index 17beea15cab9113ef80c9c9339fde609ae1ed972..50d9106ac5958050dcb38b0f2146787a20db08dc 100644 (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
index 714c8a2411e8cfa2a7ca57cc1b4140ea7f61ae3c..f0e4901d50b867d69e27b35d21ed8a750413358e 100644 (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)) {
index 3713ff3689a71f8e3df72bb628239d012e799c90..78a771a41d640c74a388b7263059d734c1c57240 100644 (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);
+}
index 60fb7da752e92a00f0a3b306db3126ff4b2e4d45..fdd62d7de611d1be6e334522187b51d9d40fa2cb 100644 (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
index 251acf3c5fa637f5e8fedd46c56cbfb085f424a8..6cf4134ea5b46f543dd23560b6a89875819195c8 100644 (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;
 }
index 6aa5dcb98cf8bf22f8e5135f45e6d589bb98e6c3..4c11a25cdc38516f7b69643112771d1e8a1deed6 100644 (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.