]> granicus.if.org Git - libvpx/commitdiff
Remove ABI check for 1 pass CBR SVC.
authorMarco <marpan@chromium.org>
Tue, 2 Jun 2015 17:23:03 +0000 (10:23 -0700)
committerMarco <marpan@chromium.org>
Thu, 4 Jun 2015 00:43:22 +0000 (17:43 -0700)
Remove the ABI check for the controls needed for SVC 1 pass CBR mode.
Bump up the ABI version.

Change-Id: I35b79ee010e14af83c6d1e801d574deaaa2fc7eb

CHANGELOG
examples/vpx_temporal_svc_encoder.c
test/datarate_test.cc
vp9/encoder/vp9_encodeframe.c
vp9/vp9_cx_iface.c
vpx/src/svc_encodeframe.c
vpx/vp8cx.h
vpx/vpx_encoder.h

index a318784150a4ce410a43dbb191186a9d87bc7f47..4ada43af35087fcaeb30542e3cb42bfb2ff8e171 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+xxxx-yy-zz v1.4.0 "Changes for next release"
+  Encoder controls added for 1 pass SVC.
+
 2015-04-03 v1.4.0 "Indian Runner Duck"
   This release includes significant improvements to the VP9 codec.
 
index a7616f3def52150c6e8ca9595a1074f5d048d67b..da2a7cfcfac0cb2dcc8e007553fcea96f59d2e5f 100644 (file)
@@ -684,27 +684,22 @@ int main(int argc, char **argv) {
     vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOff);
     vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);
   } else if (strncmp(encoder->name, "vp9", 3) == 0) {
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
     vpx_svc_extra_cfg_t svc_params;
-#endif
-      vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
-      vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
-      vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0);
-      vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0);
-      vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);
-      vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, (cfg.g_threads >> 1));
-      if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1: 0)) {
-        die_codec(&codec, "Failed to set SVC");
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
-      for (i = 0; i < cfg.ts_number_layers; ++i) {
-        svc_params.max_quantizers[i] = cfg.rc_max_quantizer;
-        svc_params.min_quantizers[i] = cfg.rc_min_quantizer;
-      }
-      svc_params.scaling_factor_num[0] = cfg.g_h;
-      svc_params.scaling_factor_den[0] = cfg.g_h;
-      vpx_codec_control(&codec, VP9E_SET_SVC_PARAMETERS, &svc_params);
-#endif
+    vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
+    vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
+    vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0);
+    vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0);
+    vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);
+    vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, (cfg.g_threads >> 1));
+    if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1: 0))
+      die_codec(&codec, "Failed to set SVC");
+    for (i = 0; i < cfg.ts_number_layers; ++i) {
+      svc_params.max_quantizers[i] = cfg.rc_max_quantizer;
+      svc_params.min_quantizers[i] = cfg.rc_min_quantizer;
     }
+    svc_params.scaling_factor_num[0] = cfg.g_h;
+    svc_params.scaling_factor_den[0] = cfg.g_h;
+    vpx_codec_control(&codec, VP9E_SET_SVC_PARAMETERS, &svc_params);
   }
   if (strncmp(encoder->name, "vp8", 3) == 0) {
     vpx_codec_control(&codec, VP8E_SET_SCREEN_CONTENT_MODE, 0);
index c182a242709fcd8c1c0ca5a5a9733a87b6e732ff..9a8f014b8b4a081b0912fe917abe2c7616b46fe7 100644 (file)
@@ -372,9 +372,7 @@ class DatarateTestVP9Large : public ::libvpx_test::EncoderTest,
         encoder->Control(VP9E_SET_SVC, 1);
       }
       vpx_svc_layer_id_t layer_id;
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
       layer_id.spatial_layer_id = 0;
-#endif
       frame_flags_ = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
       layer_id.temporal_layer_id = SetLayerId(video->frame(),
                                               cfg_.ts_number_layers);
@@ -779,9 +777,7 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
       svc_params_.scaling_factor_num[1] = 288;
       svc_params_.scaling_factor_den[1] = 288;
       encoder->Control(VP9E_SET_SVC, 1);
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
       encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_);
-#endif
       encoder->Control(VP8E_SET_CPUUSED, speed_setting_);
       encoder->Control(VP9E_SET_TILE_COLUMNS, 0);
       encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 300);
@@ -869,7 +865,7 @@ static void assign_layer_bitrates(vpx_codec_enc_cfg_t *const enc_cfg,
     }
   }
 }
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
+
 // Check basic rate targeting for 1 pass CBR SVC: 2 spatial layers and
 // 3 temporal layers.
 TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
@@ -911,7 +907,7 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
         << " The datarate for the file is lower than the target by too much!";
   }
 }
-#endif
+
 VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES);
 VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large,
                           ::testing::Values(::libvpx_test::kOnePassGood,
index 4355ec60e1adad7bc153a679d73e2e644c115895..49e8887687de34b4ab66403b2ebad58195ba45fb 100644 (file)
@@ -843,7 +843,9 @@ static int choose_partitioning(VP9_COMP *cpi,
           }
         }
       }
-      if (is_key_frame || (low_res &&
+      // TODO(marpan): There is an issue with variance based on 4x4 average in
+      // svc mode, don't allow it for now.
+      if (is_key_frame || (low_res && !cpi->use_svc &&
           vt.split[i].split[j].part_variances.none.variance >
           (thresholds[1] << 1))) {
         force_split[split_index] = 0;
index 01b97bd60daf77e3741274f63d5eec330cb0d432..9462be9faf17ceb6904a155201af9203f079bb8e 100644 (file)
@@ -1103,6 +1103,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t  *ctx,
 
         cx_data += size;
         cx_data_sz -= size;
+#if VPX_ENCODER_ABI_VERSION > (5 + VPX_CODEC_ABI_VERSION)
 #if CONFIG_SPATIAL_SVC
         if (cpi->use_svc && !ctx->output_cx_pkt_cb.output_cx_pkt) {
           vpx_codec_cx_pkt_t pkt_sizes, pkt_psnr;
@@ -1123,6 +1124,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t  *ctx,
 
           vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt_psnr);
         }
+#endif
 #endif
         if (is_one_pass_cbr_svc(cpi) &&
             (cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1)) {
@@ -1331,9 +1333,7 @@ static vpx_codec_err_t ctrl_set_svc_layer_id(vpx_codec_alg_priv_t *ctx,
   VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi;
   SVC *const svc = &cpi->svc;
 
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
   svc->spatial_layer_id = data->spatial_layer_id;
-#endif
   svc->temporal_layer_id = data->temporal_layer_id;
   // Checks on valid layer_id input.
   if (svc->temporal_layer_id < 0 ||
@@ -1353,9 +1353,7 @@ static vpx_codec_err_t ctrl_get_svc_layer_id(vpx_codec_alg_priv_t *ctx,
   VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi;
   SVC *const svc = &cpi->svc;
 
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
   data->spatial_layer_id = svc->spatial_layer_id;
-#endif
   data->temporal_layer_id = svc->temporal_layer_id;
 
   return VPX_CODEC_OK;
@@ -1440,10 +1438,8 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   {VP9E_SET_AQ_MODE,                  ctrl_set_aq_mode},
   {VP9E_SET_FRAME_PERIODIC_BOOST,     ctrl_set_frame_periodic_boost},
   {VP9E_SET_SVC,                      ctrl_set_svc},
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
   {VP9E_SET_SVC_PARAMETERS,           ctrl_set_svc_parameters},
   {VP9E_REGISTER_CX_CALLBACK,         ctrl_register_cx_callback},
-#endif
   {VP9E_SET_SVC_LAYER_ID,             ctrl_set_svc_layer_id},
   {VP9E_SET_TUNE_CONTENT,             ctrl_set_tune_content},
   {VP9E_SET_COLOR_SPACE,              ctrl_set_color_space},
@@ -1453,9 +1449,7 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   {VP8E_GET_LAST_QUANTIZER,           ctrl_get_quantizer},
   {VP8E_GET_LAST_QUANTIZER_64,        ctrl_get_quantizer64},
   {VP9_GET_REFERENCE,                 ctrl_get_reference},
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
   {VP9E_GET_SVC_LAYER_ID,             ctrl_get_svc_layer_id},
-#endif
   {VP9E_GET_ACTIVEMAP,                ctrl_get_active_map},
 
   { -1, NULL},
index 9a3cd8f336e03054ab55ac1086c8aec051b3dde0..9844ace54dcbeb28ec27d8fb5d17e99c45f35bfa 100644 (file)
@@ -529,6 +529,7 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx,
   iter = NULL;
   while ((cx_pkt = vpx_codec_get_cx_data(codec_ctx, &iter))) {
     switch (cx_pkt->kind) {
+#if VPX_ENCODER_ABI_VERSION > (5 + VPX_CODEC_ABI_VERSION)
 #if CONFIG_SPATIAL_SVC
       case VPX_CODEC_SPATIAL_SVC_LAYER_PSNR: {
         int i;
@@ -566,6 +567,7 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx,
           si->bytes_sum[i] += cx_pkt->data.layer_sizes[i];
         break;
       }
+#endif
 #endif
       default: {
         break;
index 90edc03fa39f7d9f3edb82b9a4cdfc70b6f7c1f9..19bc4bdcce110cbd1fc31f93b28c8d01468cbabc 100644 (file)
@@ -450,7 +450,6 @@ enum vp8e_enc_control_id {
    */
   VP9E_SET_SVC,
 
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
   /*!\brief Codec control function to set parameters for SVC.
    * \note Parameters contain min_q, max_q, scaling factor for each of the
    *       SVC layers.
@@ -458,7 +457,6 @@ enum vp8e_enc_control_id {
    * Supported in codecs: VP9
    */
   VP9E_SET_SVC_PARAMETERS,
-#endif
 
   /*!\brief Codec control function to set svc layer for spatial and temporal.
    * \note Valid ranges: 0..#vpx_codec_enc_cfg::ss_number_layers for spatial
@@ -478,7 +476,6 @@ enum vp8e_enc_control_id {
    */
   VP9E_SET_TUNE_CONTENT,
 
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
   /*!\brief Codec control function to get svc layer ID.
    * \note The layer ID returned is for the data packet from the registered
    *       callback function.
@@ -494,7 +491,6 @@ enum vp8e_enc_control_id {
    * Supported in codecs: VP9
    */
   VP9E_REGISTER_CX_CALLBACK,
-#endif
 
   /*!\brief Codec control function to set color space info.
    * \note Valid ranges: 0..7, default is "UNKNOWN".
@@ -641,7 +637,6 @@ typedef enum {
   VP8_TUNE_SSIM
 } vp8e_tuning;
 
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
 /*!\brief  vp9 svc layer parameters
  *
  * This defines the spatial and temporal layer id numbers for svc encoding.
@@ -653,18 +648,6 @@ typedef struct vpx_svc_layer_id {
   int spatial_layer_id;       /**< Spatial layer id number. */
   int temporal_layer_id;      /**< Temporal layer id number. */
 } vpx_svc_layer_id_t;
-#else
-/*!\brief  vp9 svc layer parameters
- *
- * This defines the temporal layer id numbers for svc encoding.
- * This is used with the #VP9E_SET_SVC_LAYER_ID control to set the
- * temporal layer id for the current frame.
- *
- */
-typedef struct vpx_svc_layer_id {
-  int temporal_layer_id;      /**< Temporal layer id number. */
-} vpx_svc_layer_id_t;
-#endif
 
 /*!\brief VP8 encoder control function parameter type
  *
@@ -688,10 +671,8 @@ VPX_CTRL_USE_TYPE(VP8E_SET_ACTIVEMAP,          vpx_active_map_t *)
 VPX_CTRL_USE_TYPE(VP8E_SET_SCALEMODE,          vpx_scaling_mode_t *)
 
 VPX_CTRL_USE_TYPE(VP9E_SET_SVC,                int)
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_PARAMETERS,     void *)
 VPX_CTRL_USE_TYPE(VP9E_REGISTER_CX_CALLBACK,   void *)
-#endif
 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_LAYER_ID,       vpx_svc_layer_id_t *)
 
 VPX_CTRL_USE_TYPE(VP8E_SET_CPUUSED,            int)
@@ -712,9 +693,7 @@ VPX_CTRL_USE_TYPE(VP9E_SET_TILE_ROWS,  int)
 
 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER,     int *)
 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64,  int *)
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
 VPX_CTRL_USE_TYPE(VP9E_GET_SVC_LAYER_ID,  vpx_svc_layer_id_t *)
-#endif
 
 VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTRA_BITRATE_PCT, unsigned int)
 VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTER_BITRATE_PCT, unsigned int)
index 5892a63ce510a18f0f27941b6315d4575d6ad844..2b17f98a2313f4aec55a4cb55fb98f389d90f384 100644 (file)
@@ -62,7 +62,7 @@ extern "C" {
    * types, removing or reassigning enums, adding/removing/rearranging
    * fields to structures
    */
-#define VPX_ENCODER_ABI_VERSION (4 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
+#define VPX_ENCODER_ABI_VERSION (5 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
 
 
   /*! \brief Encoder capabilities bitfield
@@ -166,7 +166,7 @@ extern "C" {
     VPX_CODEC_PSNR_PKT,        /**< PSNR statistics for this frame */
     // Spatial SVC is still experimental and may be removed before the next ABI
     // bump.
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
+#if VPX_ENCODER_ABI_VERSION > (5 + VPX_CODEC_ABI_VERSION)
     VPX_CODEC_SPATIAL_SVC_LAYER_SIZES, /**< Sizes for each layer in this frame*/
     VPX_CODEC_SPATIAL_SVC_LAYER_PSNR, /**< PSNR for each layer in this frame*/
 #endif
@@ -208,7 +208,7 @@ extern "C" {
       vpx_fixed_buf_t raw;     /**< data for arbitrary packets */
       // Spatial SVC is still experimental and may be removed before the next
       // ABI bump.
-#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
+#if VPX_ENCODER_ABI_VERSION > (5 + VPX_CODEC_ABI_VERSION)
       size_t layer_sizes[VPX_SS_MAX_LAYERS];
       struct vpx_psnr_pkt layer_psnr[VPX_SS_MAX_LAYERS];
 #endif