From 18613408a31bf280aab06260874ba04f9daab26d Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 19 Mar 2015 12:20:14 -0700 Subject: [PATCH] put spatial svc behind an ABI check this removes the CONFIG_* checks from public headers, but means '--enable-experimental --enable-spatial-svc' builds will fail without a local change to the ABI in vpx_encoder.h. this should be all right for testing this experiment. Change-Id: Ief55e7b9d1e8332cfce990275e04c29b30af0c4a --- examples/vpx_temporal_svc_encoder.c | 6 ++++++ test/datarate_test.cc | 4 +++- vp9/vp9_cx_iface.c | 10 +++++++++- vpx/vp8cx.h | 22 ++++++++++++++++++++++ vpx/vpx_encoder.h | 12 ++++++------ 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/examples/vpx_temporal_svc_encoder.c b/examples/vpx_temporal_svc_encoder.c index d5cd46c68..ab560932c 100644 --- a/examples/vpx_temporal_svc_encoder.c +++ b/examples/vpx_temporal_svc_encoder.c @@ -481,7 +481,11 @@ int main(int argc, char **argv) { int layering_mode = 0; int layer_flags[VPX_TS_MAX_PERIODICITY] = {0}; int flag_periodicity = 1; +#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION) vpx_svc_layer_id_t layer_id = {0, 0}; +#else + vpx_svc_layer_id_t layer_id = {0}; +#endif const VpxInterface *encoder = NULL; FILE *infile = NULL; struct RateControlMetrics rc; @@ -701,8 +705,10 @@ int main(int argc, char **argv) { struct vpx_usec_timer timer; vpx_codec_iter_t iter = NULL; const vpx_codec_cx_pkt_t *pkt; +#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION) // Update the temporal layer_id. No spatial layers in this test. layer_id.spatial_layer_id = 0; +#endif layer_id.temporal_layer_id = cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity]; if (strncmp(encoder->name, "vp9", 3) == 0) { diff --git a/test/datarate_test.cc b/test/datarate_test.cc index fc9e1f425..78b5fa406 100644 --- a/test/datarate_test.cc +++ b/test/datarate_test.cc @@ -370,8 +370,10 @@ class DatarateTestVP9Large : public ::libvpx_test::EncoderTest, if (video->frame() == 0) { encoder->Control(VP9E_SET_SVC, 1); } - vpx_svc_layer_id_t layer_id = {0, 0}; + 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); diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index eb10da7ac..630645a5a 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -12,7 +12,7 @@ #include #include "./vpx_config.h" -#include "vpx/vpx_codec.h" +#include "vpx/vpx_encoder.h" #include "vpx_ports/vpx_once.h" #include "vpx/internal/vpx_codec_internal.h" #include "./vpx_version.h" @@ -1298,7 +1298,9 @@ 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 || @@ -1318,7 +1320,9 @@ 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; @@ -1397,8 +1401,10 @@ 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}, @@ -1408,7 +1414,9 @@ 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 { -1, NULL}, }; diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h index 5f063846c..fc83ce667 100644 --- a/vpx/vp8cx.h +++ b/vpx/vp8cx.h @@ -16,6 +16,7 @@ * @{ */ #include "./vp8.h" +#include "vpx/vpx_encoder.h" /*!\file * \brief Provides definitions for using VP8 or VP9 encoder algorithm within the @@ -447,6 +448,7 @@ 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. @@ -454,6 +456,7 @@ 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 @@ -473,6 +476,7 @@ 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. @@ -488,6 +492,7 @@ 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". @@ -591,6 +596,7 @@ 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. @@ -602,6 +608,18 @@ 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 * @@ -625,8 +643,10 @@ 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) @@ -647,7 +667,9 @@ 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) diff --git a/vpx/vpx_encoder.h b/vpx/vpx_encoder.h index 2522235f2..bf75584d5 100644 --- a/vpx/vpx_encoder.h +++ b/vpx/vpx_encoder.h @@ -161,9 +161,9 @@ extern "C" { VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */ VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */ VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */ - // TODO(minghai): This is for testing purporses. The released library can't - // depend on vpx_config.h -#if defined(CONFIG_SPATIAL_SVC) && CONFIG_SPATIAL_SVC + // Spatial SVC is still experimental and may be removed before the next ABI + // bump. +#if VPX_ENCODER_ABI_VERSION > (4 + 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 @@ -203,9 +203,9 @@ extern "C" { double psnr[4]; /**< PSNR, total/y/u/v */ } psnr; /**< data for PSNR packet */ vpx_fixed_buf_t raw; /**< data for arbitrary packets */ - // TODO(minghai): This is for testing purporses. The released library - // can't depend on vpx_config.h -#if defined(CONFIG_SPATIAL_SVC) && CONFIG_SPATIAL_SVC + // Spatial SVC is still experimental and may be removed before the next + // ABI bump. +#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION) size_t layer_sizes[VPX_SS_MAX_LAYERS]; struct vpx_psnr_pkt layer_psnr[VPX_SS_MAX_LAYERS]; #endif -- 2.40.0