From 83b1d907daef1db08834093806f125e56fba3370 Mon Sep 17 00:00:00 2001 From: John Koleszar Date: Mon, 5 Nov 2012 12:37:14 -0800 Subject: [PATCH] vpx: merge with master Change-Id: I44b3ad780cef6f448fa17ff8e28fea87ef9cd518 --- vp9/vp9_cx_iface.c | 126 ++----- vp9/vp9_dx_iface.c | 36 +- vpx/internal/vpx_codec_internal.h | 32 +- vpx/src/vpx_decoder.c | 9 +- vpx/src/vpx_decoder_compat.c | 180 --------- vpx/src/vpx_encoder.c | 125 ++++++- vpx/src/vpx_image.c | 49 ++- vpx/vp8.h | 15 +- vpx/vp8cx.h | 45 +-- vpx/vp8dx.h | 11 +- vpx/vp8e.h | 62 ---- vpx/vpx_codec.mk | 10 +- vpx/vpx_decoder.h | 32 +- vpx/vpx_decoder_compat.h | 584 ------------------------------ vpx/vpx_encoder.h | 102 +++++- vpx/vpx_image.h | 3 +- vpx/vpx_integer.h | 10 +- vpxenc.c | 30 +- 18 files changed, 389 insertions(+), 1072 deletions(-) delete mode 100644 vpx/src/vpx_decoder_compat.c delete mode 100644 vpx/vp8e.h delete mode 100644 vpx/vpx_decoder_compat.h diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 1572920f1..bbd9317fe 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -13,20 +13,14 @@ #include "vpx/internal/vpx_codec_internal.h" #include "vpx_version.h" #include "vp9/encoder/onyx_int.h" -#include "vpx/vp8e.h" +#include "vpx/vp8cx.h" #include "vp9/encoder/firstpass.h" #include "vp9/common/onyx.h" #include #include -/* This value is a sentinel for determining whether the user has set a mode - * directly through the deprecated VP8E_SET_ENCODING_MODE control. - */ -#define NO_MODE_SET 255 - struct vp8_extracfg { struct vpx_codec_pkt_list *pkt_list; - vp8e_encoding_mode encoding_mode; /** best, good, realtime */ int cpu_used; /** available cpu percentage in 1/16*/ unsigned int enable_auto_alt_ref; /** if encoder decides to uses alternate reference frame */ unsigned int noise_sensitivity; @@ -40,7 +34,9 @@ struct vp8_extracfg { vp8e_tuning tuning; unsigned int cq_level; /* constrained quality level */ unsigned int rc_max_intra_bitrate_pct; - +#if CONFIG_LOSSLESS + unsigned int lossless; +#endif }; struct extraconfig_map { @@ -53,7 +49,6 @@ static const struct extraconfig_map extracfg_map[] = { 0, { NULL, - VP8_BEST_QUALITY_ENCODING, /* Encoding Mode */ 0, /* cpu_used */ 0, /* enable_auto_alt_ref */ 0, /* noise_sensitivity */ @@ -67,6 +62,9 @@ static const struct extraconfig_map extracfg_map[] = { 0, /* tuning*/ 10, /* cq_level */ 0, /* rc_max_intra_bitrate_pct */ +#if CONFIG_LOSSLESS + 0, /* lossless */ +#endif } } }; @@ -83,7 +81,6 @@ struct vpx_codec_alg_priv { unsigned int next_frame_flag; vp8_postproc_cfg_t preview_ppcfg; vpx_codec_pkt_list_decl(64) pkt_list; // changed to accomendate the maximum number of lagged frames allowed - int deprecated_mode; unsigned int fixed_kf_cntr; }; @@ -135,8 +132,17 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000); RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den); RANGE_CHECK_HI(cfg, g_profile, 3); + RANGE_CHECK_HI(cfg, rc_max_quantizer, 63); RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer); +#if CONFIG_LOSSLESS + RANGE_CHECK_BOOL(vp8_cfg, lossless); + if (vp8_cfg->lossless) { + RANGE_CHECK_HI(cfg, rc_max_quantizer, 0); + RANGE_CHECK_HI(cfg, rc_min_quantizer, 0); + } +#endif + RANGE_CHECK_HI(cfg, g_threads, 64); RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS); RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_CQ); @@ -162,7 +168,6 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref); RANGE_CHECK(vp8_cfg, cpu_used, -16, 16); - RANGE_CHECK(vp8_cfg, encoding_mode, VP8_BEST_QUALITY_ENCODING, VP8_REAL_TIME_ENCODING); RANGE_CHECK_HI(vp8_cfg, noise_sensitivity, 6); RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_TOKENPARTITION); @@ -303,7 +308,7 @@ static vpx_codec_err_t set_vp8e_config(VP9_CONFIG *oxcf, oxcf->tuning = vp8_cfg.tuning; #if CONFIG_LOSSLESS - oxcf->lossless = cfg.lossless; + oxcf->lossless = vp8_cfg.lossless; #endif /* @@ -397,7 +402,6 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, #define MAP(id, var) case id: var = CAST(id, args); break; switch (ctrl_id) { - MAP(VP8E_SET_ENCODING_MODE, ctx->deprecated_mode); MAP(VP8E_SET_CPUUSED, xcfg.cpu_used); MAP(VP8E_SET_ENABLEAUTOALTREF, xcfg.enable_auto_alt_ref); MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity); @@ -411,7 +415,9 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, MAP(VP8E_SET_TUNING, xcfg.tuning); MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level); MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); - +#if CONFIG_LOSSLESS + MAP(VP9E_SET_LOSSLESS, xcfg.lossless); +#endif } res = validate_config(ctx, &ctx->cfg, &xcfg); @@ -429,7 +435,7 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, int experimental) { - vpx_codec_err_t res = VPX_DEC_OK; + vpx_codec_err_t res = VPX_CODEC_OK; struct vpx_codec_alg_priv *priv; vpx_codec_enc_cfg_t *cfg; unsigned int i; @@ -448,6 +454,7 @@ static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, ctx->priv->iface = ctx->iface; ctx->priv->alg_priv = priv; ctx->priv->init_flags = ctx->init_flags; + ctx->priv->enc.total_encoders = 1; if (ctx->config.enc) { /* Update the reference to the config structure to an @@ -481,8 +488,6 @@ static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, return VPX_CODEC_MEM_ERROR; } - priv->deprecated_mode = NO_MODE_SET; - vp9_initialize_enc(); res = validate_config(priv, &priv->cfg, &priv->vp8_cfg); @@ -504,13 +509,15 @@ static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx, } -static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx) { +static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, + vpx_codec_priv_enc_mr_cfg_t *data) { return vp8e_common_init(ctx, 0); } #if CONFIG_EXPERIMENTAL -static vpx_codec_err_t vp8e_exp_init(vpx_codec_ctx_t *ctx) { +static vpx_codec_err_t vp8e_exp_init(vpx_codec_ctx_t *ctx, + vpx_codec_priv_enc_mr_cfg_t *data) { return vp8e_common_init(ctx, 1); } #endif @@ -957,7 +964,6 @@ static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = { {VP8E_SET_ROI_MAP, vp8e_set_roi_map}, {VP8E_SET_ACTIVEMAP, vp8e_set_activemap}, {VP8E_SET_SCALEMODE, vp8e_set_scalemode}, - {VP8E_SET_ENCODING_MODE, set_param}, {VP8E_SET_CPUUSED, set_param}, {VP8E_SET_NOISE_SENSITIVITY, set_param}, {VP8E_SET_ENABLEAUTOALTREF, set_param}, @@ -972,6 +978,9 @@ static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = { {VP8E_SET_TUNING, set_param}, {VP8E_SET_CQ_LEVEL, set_param}, {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param}, +#if CONFIG_LOSSLESS + {VP9E_SET_LOSSLESS, set_param}, +#endif { -1, NULL}, }; @@ -1090,80 +1099,3 @@ CODEC_INTERFACE(vpx_codec_vp8x_cx) = { } /* encoder functions */ }; #endif - - -/* - * BEGIN BACKWARDS COMPATIBILITY SHIM. - */ -#define FORCE_KEY 2 -static vpx_codec_err_t api1_control(vpx_codec_alg_priv_t *ctx, - int ctrl_id, - va_list args) { - vpx_codec_ctrl_fn_map_t *entry; - - switch (ctrl_id) { - case VP8E_SET_FLUSHFLAG: - /* VP8 sample code did VP8E_SET_FLUSHFLAG followed by - * vpx_codec_get_cx_data() rather than vpx_codec_encode(). - */ - return vp8e_encode(ctx, NULL, 0, 0, 0, 0); - case VP8E_SET_FRAMETYPE: - ctx->base.enc.tbd |= FORCE_KEY; - return VPX_CODEC_OK; - } - - for (entry = vp8e_ctf_maps; entry && entry->fn; entry++) { - if (!entry->ctrl_id || entry->ctrl_id == ctrl_id) { - return entry->fn(ctx, ctrl_id, args); - } - } - - return VPX_CODEC_ERROR; -} - - -static vpx_codec_ctrl_fn_map_t api1_ctrl_maps[] = { - {0, api1_control}, - { -1, NULL} -}; - - -static vpx_codec_err_t api1_encode(vpx_codec_alg_priv_t *ctx, - const vpx_image_t *img, - vpx_codec_pts_t pts, - unsigned long duration, - vpx_enc_frame_flags_t flags, - unsigned long deadline) { - int force = ctx->base.enc.tbd; - - ctx->base.enc.tbd = 0; - return vp8e_encode - (ctx, - img, - pts, - duration, - flags | ((force & FORCE_KEY) ? VPX_EFLAG_FORCE_KF : 0), - deadline); -} - - -vpx_codec_iface_t vpx_enc_vp8_algo = { - "WebM Project VP8 Encoder (Deprecated API)" VERSION_STRING, - VPX_CODEC_INTERNAL_ABI_VERSION, - VPX_CODEC_CAP_ENCODER, - /* vpx_codec_caps_t caps; */ - vp8e_init, /* vpx_codec_init_fn_t init; */ - vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */ - api1_ctrl_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ - NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ - NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ - {NOT_IMPLEMENTED}, /* decoder functions */ - { - vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ - api1_encode, /* vpx_codec_encode_fn_t encode; */ - vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ - vp8e_set_config, - NOT_IMPLEMENTED, - vp8e_get_preview, - } /* encoder functions */ -}; diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index 7116d5f9e..71d140c9d 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -163,7 +163,8 @@ static void vp8_finalize_mmaps(vpx_codec_alg_priv_t *ctx) { /* nothing to clean up */ } -static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx) { +static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx, + vpx_codec_priv_enc_mr_cfg_t *data) { vpx_codec_err_t res = VPX_CODEC_OK; /* This function only allocates space for the vpx_codec_alg_priv_t @@ -504,7 +505,7 @@ static vpx_codec_err_t vp8_xma_set_mmap(vpx_codec_ctx_t *ctx, if (done && !res) { vp8_finalize_mmaps(ctx->priv->alg_priv); - res = ctx->iface->init(ctx); + res = ctx->iface->init(ctx, NULL); } return res; @@ -661,37 +662,6 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = { CODEC_INTERFACE(vpx_codec_vp8_dx) = { "WebM Project VP8 Decoder" VERSION_STRING, VPX_CODEC_INTERNAL_ABI_VERSION, - VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC | - VPX_CODEC_CAP_INPUT_PARTITION, - /* vpx_codec_caps_t caps; */ - vp8_init, /* vpx_codec_init_fn_t init; */ - vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */ - ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ - vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */ - vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */ - { - vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */ - vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */ - vp8_decode, /* vpx_codec_decode_fn_t decode; */ - vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */ - }, - { - /* encoder functions */ - NOT_IMPLEMENTED, - NOT_IMPLEMENTED, - NOT_IMPLEMENTED, - NOT_IMPLEMENTED, - NOT_IMPLEMENTED, - NOT_IMPLEMENTED - } -}; - -/* - * BEGIN BACKWARDS COMPATIBILITY SHIM. - */ -vpx_codec_iface_t vpx_codec_vp8_algo = { - "WebM Project VP8 Decoder (Deprecated API)" VERSION_STRING, - VPX_CODEC_INTERNAL_ABI_VERSION, VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC, /* vpx_codec_caps_t caps; */ vp8_init, /* vpx_codec_init_fn_t init; */ diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h index 811fe3462..4b7b03067 100644 --- a/vpx/internal/vpx_codec_internal.h +++ b/vpx/internal/vpx_codec_internal.h @@ -56,9 +56,10 @@ * types, removing or reassigning enums, adding/removing/rearranging * fields to structures */ -#define VPX_CODEC_INTERNAL_ABI_VERSION (3) /**<\hideinitializer*/ +#define VPX_CODEC_INTERNAL_ABI_VERSION (4) /**<\hideinitializer*/ typedef struct vpx_codec_alg_priv vpx_codec_alg_priv_t; +typedef struct vpx_codec_priv_enc_mr_cfg vpx_codec_priv_enc_mr_cfg_t; /*!\brief init function pointer prototype * @@ -73,7 +74,8 @@ typedef struct vpx_codec_alg_priv vpx_codec_alg_priv_t; * \retval #VPX_CODEC_MEM_ERROR * Memory operation failed. */ -typedef vpx_codec_err_t (*vpx_codec_init_fn_t)(vpx_codec_ctx_t *ctx); +typedef vpx_codec_err_t (*vpx_codec_init_fn_t)(vpx_codec_ctx_t *ctx, + vpx_codec_priv_enc_mr_cfg_t *data); /*!\brief destroy function pointer prototype * @@ -163,7 +165,7 @@ typedef vpx_codec_err_t (*vpx_codec_control_fn_t)(vpx_codec_alg_priv_t *ctx, * mapping. This implies that ctrl_id values chosen by the algorithm * \ref MUST be non-zero. */ -typedef const struct { +typedef const struct vpx_codec_ctrl_fn_map { int ctrl_id; vpx_codec_control_fn_t fn; } vpx_codec_ctrl_fn_map_t; @@ -263,6 +265,10 @@ typedef vpx_fixed_buf_t * typedef vpx_image_t * (*vpx_codec_get_preview_frame_fn_t)(vpx_codec_alg_priv_t *ctx); +typedef vpx_codec_err_t +(*vpx_codec_enc_mr_get_mem_loc_fn_t)(const vpx_codec_enc_cfg_t *cfg, + void **mem_loc); + /*!\brief usage configuration mapping * * This structure stores the mapping between usage identifiers and @@ -273,7 +279,7 @@ typedef vpx_image_t * * one mapping must be present, in addition to the end-of-list. * */ -typedef const struct { +typedef const struct vpx_codec_enc_cfg_map { int usage; vpx_codec_enc_cfg_t cfg; } vpx_codec_enc_cfg_map_t; @@ -293,19 +299,20 @@ struct vpx_codec_iface { vpx_codec_ctrl_fn_map_t *ctrl_maps; /**< \copydoc ::vpx_codec_ctrl_fn_map_t */ vpx_codec_get_mmap_fn_t get_mmap; /**< \copydoc ::vpx_codec_get_mmap_fn_t */ vpx_codec_set_mmap_fn_t set_mmap; /**< \copydoc ::vpx_codec_set_mmap_fn_t */ - struct { + struct vpx_codec_dec_iface { vpx_codec_peek_si_fn_t peek_si; /**< \copydoc ::vpx_codec_peek_si_fn_t */ vpx_codec_get_si_fn_t get_si; /**< \copydoc ::vpx_codec_peek_si_fn_t */ vpx_codec_decode_fn_t decode; /**< \copydoc ::vpx_codec_decode_fn_t */ vpx_codec_get_frame_fn_t get_frame; /**< \copydoc ::vpx_codec_get_frame_fn_t */ } dec; - struct { + struct vpx_codec_enc_iface { vpx_codec_enc_cfg_map_t *cfg_maps; /**< \copydoc ::vpx_codec_enc_cfg_map_t */ vpx_codec_encode_fn_t encode; /**< \copydoc ::vpx_codec_encode_fn_t */ vpx_codec_get_cx_data_fn_t get_cx_data; /**< \copydoc ::vpx_codec_get_cx_data_fn_t */ vpx_codec_enc_config_set_fn_t cfg_set; /**< \copydoc ::vpx_codec_enc_config_set_fn_t */ - vpx_codec_get_global_headers_fn_t get_glob_hdrs; /**< \copydoc ::vpx_codec_enc_config_set_fn_t */ + vpx_codec_get_global_headers_fn_t get_glob_hdrs; /**< \copydoc ::vpx_codec_get_global_headers_fn_t */ vpx_codec_get_preview_frame_fn_t get_preview; /**< \copydoc ::vpx_codec_get_preview_frame_fn_t */ + vpx_codec_enc_mr_get_mem_loc_fn_t mr_get_mem_loc; /**< \copydoc ::vpx_codec_enc_mr_get_mem_loc_fn_t */ } enc; }; @@ -343,9 +350,20 @@ struct vpx_codec_priv { unsigned int cx_data_pad_before; unsigned int cx_data_pad_after; vpx_codec_cx_pkt_t cx_data_pkt; + unsigned int total_encoders; } enc; }; +/* + * Multi-resolution encoding internal configuration + */ +struct vpx_codec_priv_enc_mr_cfg { + unsigned int mr_total_resolutions; + unsigned int mr_encoder_id; + struct vpx_rational mr_down_sampling_factor; + void *mr_low_res_mode_info; +}; + #undef VPX_CTRL_USE_TYPE #define VPX_CTRL_USE_TYPE(id, typ) \ static typ id##__value(va_list args) {return va_arg(args, typ);} \ diff --git a/vpx/src/vpx_decoder.c b/vpx/src/vpx_decoder.c index 9fa1bf6c2..1f575e0a0 100644 --- a/vpx/src/vpx_decoder.c +++ b/vpx/src/vpx_decoder.c @@ -35,8 +35,11 @@ vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx, res = VPX_CODEC_INCAPABLE; else if ((flags & VPX_CODEC_USE_POSTPROC) && !(iface->caps & VPX_CODEC_CAP_POSTPROC)) res = VPX_CODEC_INCAPABLE; - else if ((flags & VPX_CODEC_USE_INPUT_PARTITION) && - !(iface->caps & VPX_CODEC_CAP_INPUT_PARTITION)) + else if ((flags & VPX_CODEC_USE_ERROR_CONCEALMENT) && + !(iface->caps & VPX_CODEC_CAP_ERROR_CONCEALMENT)) + res = VPX_CODEC_INCAPABLE; + else if ((flags & VPX_CODEC_USE_INPUT_FRAGMENTS) && + !(iface->caps & VPX_CODEC_CAP_INPUT_FRAGMENTS)) res = VPX_CODEC_INCAPABLE; else if (!(iface->caps & VPX_CODEC_CAP_DECODER)) res = VPX_CODEC_INCAPABLE; @@ -50,7 +53,7 @@ vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx, res = VPX_CODEC_OK; if (!(flags & VPX_CODEC_USE_XMA)) { - res = ctx->iface->init(ctx); + res = ctx->iface->init(ctx, NULL); if (res) { ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL; diff --git a/vpx/src/vpx_decoder_compat.c b/vpx/src/vpx_decoder_compat.c deleted file mode 100644 index 59bd261a6..000000000 --- a/vpx/src/vpx_decoder_compat.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/*!\file - * \brief Provides the high level interface to wrap decoder algorithms. - * - */ -#include -#include -#include "vpx/vpx_decoder.h" -#include "vpx/internal/vpx_codec_internal.h" - -#define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var) - -const char *vpx_dec_iface_name(vpx_dec_iface_t *iface) { - return vpx_codec_iface_name((vpx_codec_iface_t *)iface); -} - -const char *vpx_dec_err_to_string(vpx_dec_err_t err) { - return vpx_codec_err_to_string(err); -} - -const char *vpx_dec_error(vpx_dec_ctx_t *ctx) { - return vpx_codec_error((vpx_codec_ctx_t *)ctx); -} - -const char *vpx_dec_error_detail(vpx_dec_ctx_t *ctx) { - return vpx_codec_error_detail((vpx_codec_ctx_t *)ctx); -} - - -vpx_dec_err_t vpx_dec_init_ver(vpx_dec_ctx_t *ctx, - vpx_dec_iface_t *iface, - int ver) { - return vpx_codec_dec_init_ver((vpx_codec_ctx_t *)ctx, - (vpx_codec_iface_t *)iface, - NULL, - 0, - ver); -} - - -vpx_dec_err_t vpx_dec_destroy(vpx_dec_ctx_t *ctx) { - return vpx_codec_destroy((vpx_codec_ctx_t *)ctx); -} - - -vpx_dec_caps_t vpx_dec_get_caps(vpx_dec_iface_t *iface) { - return vpx_codec_get_caps((vpx_codec_iface_t *)iface); -} - - -vpx_dec_err_t vpx_dec_peek_stream_info(vpx_dec_iface_t *iface, - const uint8_t *data, - unsigned int data_sz, - vpx_dec_stream_info_t *si) { - return vpx_codec_peek_stream_info((vpx_codec_iface_t *)iface, data, data_sz, - (vpx_codec_stream_info_t *)si); -} - - -vpx_dec_err_t vpx_dec_get_stream_info(vpx_dec_ctx_t *ctx, - vpx_dec_stream_info_t *si) { - return vpx_codec_get_stream_info((vpx_codec_ctx_t *)ctx, - (vpx_codec_stream_info_t *)si); -} - - -vpx_dec_err_t vpx_dec_control(vpx_dec_ctx_t *ctx, - int ctrl_id, - void *data) { - return vpx_codec_control_((vpx_codec_ctx_t *)ctx, ctrl_id, data); -} - - -vpx_dec_err_t vpx_dec_decode(vpx_dec_ctx_t *ctx, - uint8_t *data, - unsigned int data_sz, - void *user_priv, - int rel_pts) { - (void)rel_pts; - return vpx_codec_decode((vpx_codec_ctx_t *)ctx, data, data_sz, user_priv, - 0); -} - -vpx_image_t *vpx_dec_get_frame(vpx_dec_ctx_t *ctx, - vpx_dec_iter_t *iter) { - return vpx_codec_get_frame((vpx_codec_ctx_t *)ctx, iter); -} - - -vpx_dec_err_t vpx_dec_register_put_frame_cb(vpx_dec_ctx_t *ctx, - vpx_dec_put_frame_cb_fn_t cb, - void *user_priv) { - return vpx_codec_register_put_frame_cb((vpx_codec_ctx_t *)ctx, cb, - user_priv); -} - - -vpx_dec_err_t vpx_dec_register_put_slice_cb(vpx_dec_ctx_t *ctx, - vpx_dec_put_slice_cb_fn_t cb, - void *user_priv) { - return vpx_codec_register_put_slice_cb((vpx_codec_ctx_t *)ctx, cb, - user_priv); -} - - -vpx_dec_err_t vpx_dec_xma_init_ver(vpx_dec_ctx_t *ctx, - vpx_dec_iface_t *iface, - int ver) { - return vpx_codec_dec_init_ver((vpx_codec_ctx_t *)ctx, - (vpx_codec_iface_t *)iface, - NULL, - VPX_CODEC_USE_XMA, - ver); -} - -vpx_dec_err_t vpx_dec_get_mem_map(vpx_dec_ctx_t *ctx_, - vpx_dec_mmap_t *mmap, - const vpx_dec_stream_info_t *si, - vpx_dec_iter_t *iter) { - vpx_codec_ctx_t *ctx = (vpx_codec_ctx_t *)ctx_; - vpx_dec_err_t res = VPX_DEC_OK; - - if (!ctx || !mmap || !si || !iter || !ctx->iface) - res = VPX_DEC_INVALID_PARAM; - else if (!(ctx->iface->caps & VPX_DEC_CAP_XMA)) - res = VPX_DEC_ERROR; - else { - if (!ctx->config.dec) { - ctx->config.dec = malloc(sizeof(vpx_codec_dec_cfg_t)); - ctx->config.dec->w = si->w; - ctx->config.dec->h = si->h; - } - - res = ctx->iface->get_mmap(ctx, mmap, iter); - } - - return SAVE_STATUS(ctx, res); -} - - -vpx_dec_err_t vpx_dec_set_mem_map(vpx_dec_ctx_t *ctx_, - vpx_dec_mmap_t *mmap, - unsigned int num_maps) { - vpx_codec_ctx_t *ctx = (vpx_codec_ctx_t *)ctx_; - vpx_dec_err_t res = VPX_DEC_MEM_ERROR; - - if (!ctx || !mmap || !ctx->iface) - res = VPX_DEC_INVALID_PARAM; - else if (!(ctx->iface->caps & VPX_DEC_CAP_XMA)) - res = VPX_DEC_ERROR; - else { - void *save = (ctx->priv) ? NULL : ctx->config.dec; - unsigned int i; - - for (i = 0; i < num_maps; i++, mmap++) { - if (!mmap->base) - break; - - /* Everything look ok, set the mmap in the decoder */ - res = ctx->iface->set_mmap(ctx, mmap); - - if (res) - break; - } - - if (save) free(save); - } - - return SAVE_STATUS(ctx, res); -} diff --git a/vpx/src/vpx_encoder.c b/vpx/src/vpx_encoder.c index 1d3b646d3..3cec895c9 100644 --- a/vpx/src/vpx_encoder.c +++ b/vpx/src/vpx_encoder.c @@ -49,7 +49,7 @@ vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx, ctx->priv = NULL; ctx->init_flags = flags; ctx->config.enc = cfg; - res = ctx->iface->init(ctx); + res = ctx->iface->init(ctx, NULL); if (res) { ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL; @@ -63,6 +63,97 @@ vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx, return SAVE_STATUS(ctx, res); } +vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx, + vpx_codec_iface_t *iface, + vpx_codec_enc_cfg_t *cfg, + int num_enc, + vpx_codec_flags_t flags, + vpx_rational_t *dsf, + int ver) { + vpx_codec_err_t res = 0; + + if (ver != VPX_ENCODER_ABI_VERSION) + res = VPX_CODEC_ABI_MISMATCH; + else if (!ctx || !iface || !cfg || (num_enc > 16 || num_enc < 1)) + res = VPX_CODEC_INVALID_PARAM; + else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION) + res = VPX_CODEC_ABI_MISMATCH; + else if (!(iface->caps & VPX_CODEC_CAP_ENCODER)) + res = VPX_CODEC_INCAPABLE; + else if ((flags & VPX_CODEC_USE_XMA) && !(iface->caps & VPX_CODEC_CAP_XMA)) + res = VPX_CODEC_INCAPABLE; + else if ((flags & VPX_CODEC_USE_PSNR) + && !(iface->caps & VPX_CODEC_CAP_PSNR)) + res = VPX_CODEC_INCAPABLE; + else if ((flags & VPX_CODEC_USE_OUTPUT_PARTITION) + && !(iface->caps & VPX_CODEC_CAP_OUTPUT_PARTITION)) + res = VPX_CODEC_INCAPABLE; + else { + int i; + void *mem_loc = NULL; + + if (!(res = iface->enc.mr_get_mem_loc(cfg, &mem_loc))) { + for (i = 0; i < num_enc; i++) { + vpx_codec_priv_enc_mr_cfg_t mr_cfg; + + /* Validate down-sampling factor. */ + if (dsf->num < 1 || dsf->num > 4096 || dsf->den < 1 || + dsf->den > dsf->num) { + res = VPX_CODEC_INVALID_PARAM; + break; + } + + mr_cfg.mr_low_res_mode_info = mem_loc; + mr_cfg.mr_total_resolutions = num_enc; + mr_cfg.mr_encoder_id = num_enc - 1 - i; + mr_cfg.mr_down_sampling_factor.num = dsf->num; + mr_cfg.mr_down_sampling_factor.den = dsf->den; + + /* Force Key-frame synchronization. Namely, encoder at higher + * resolution always use the same frame_type chosen by the + * lowest-resolution encoder. + */ + if (mr_cfg.mr_encoder_id) + cfg->kf_mode = VPX_KF_DISABLED; + + ctx->iface = iface; + ctx->name = iface->name; + ctx->priv = NULL; + ctx->init_flags = flags; + ctx->config.enc = cfg; + res = ctx->iface->init(ctx, &mr_cfg); + + if (res) { + const char *error_detail = + ctx->priv ? ctx->priv->err_detail : NULL; + /* Destroy current ctx */ + ctx->err_detail = error_detail; + vpx_codec_destroy(ctx); + + /* Destroy already allocated high-level ctx */ + while (i) { + ctx--; + ctx->err_detail = error_detail; + vpx_codec_destroy(ctx); + i--; + } + } + + if (ctx->priv) + ctx->priv->iface = ctx->iface; + + if (res) + break; + + ctx++; + cfg++; + dsf++; + } + } + } + + return SAVE_STATUS(ctx, res); +} vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface, @@ -115,7 +206,7 @@ vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, unsigned long duration, vpx_enc_frame_flags_t flags, unsigned long deadline) { - vpx_codec_err_t res; + vpx_codec_err_t res = 0; if (!ctx || (img && !duration)) res = VPX_CODEC_INVALID_PARAM; @@ -127,9 +218,35 @@ vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, /* Execute in a normalized floating point environment, if the platform * requires it. */ + unsigned int num_enc = ctx->priv->enc.total_encoders; + FLOATING_POINT_INIT(); - res = ctx->iface->enc.encode(ctx->priv->alg_priv, img, pts, - duration, flags, deadline); + + if (num_enc == 1) + res = ctx->iface->enc.encode(ctx->priv->alg_priv, img, pts, + duration, flags, deadline); + else { + /* Multi-resolution encoding: + * Encode multi-levels in reverse order. For example, + * if mr_total_resolutions = 3, first encode level 2, + * then encode level 1, and finally encode level 0. + */ + int i; + + ctx += num_enc - 1; + if (img) img += num_enc - 1; + + for (i = num_enc - 1; i >= 0; i--) { + if ((res = ctx->iface->enc.encode(ctx->priv->alg_priv, img, pts, + duration, flags, deadline))) + break; + + ctx--; + if (img) img--; + } + ctx++; + } + FLOATING_POINT_RESTORE(); } diff --git a/vpx/src/vpx_image.c b/vpx/src/vpx_image.c index 4903789f2..36eda958e 100644 --- a/vpx/src/vpx_image.c +++ b/vpx/src/vpx_image.c @@ -13,16 +13,52 @@ #include #include "vpx/vpx_image.h" +#define ADDRESS_STORAGE_SIZE sizeof(size_t) +/*returns an addr aligned to the byte boundary specified by align*/ +#define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align)) + +/* Memalign code is copied from vpx_mem.c */ +static void *img_buf_memalign(size_t align, size_t size) { + void *addr, + * x = NULL; + + addr = malloc(size + align - 1 + ADDRESS_STORAGE_SIZE); + + if (addr) { + x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align); + /* save the actual malloc address */ + ((size_t *)x)[-1] = (size_t)addr; + } + + return x; +} + +static void img_buf_free(void *memblk) { + if (memblk) { + void *addr = (void *)(((size_t *)memblk)[-1]); + free(addr); + } +} + static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, + unsigned int buf_align, unsigned int stride_align, unsigned char *img_data) { unsigned int h, w, s, xcs, ycs, bps; int align; + /* Treat align==0 like align==1 */ + if (!buf_align) + buf_align = 1; + + /* Validate alignment (must be power of 2) */ + if (buf_align & (buf_align - 1)) + goto fail; + /* Treat align==0 like align==1 */ if (!stride_align) stride_align = 1; @@ -111,7 +147,8 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, img->img_data = img_data; if (!img_data) { - img->img_data = malloc((fmt & VPX_IMG_FMT_PLANAR) ? h * w * bps / 8 : h * s); + img->img_data = img_buf_memalign(buf_align, ((fmt & VPX_IMG_FMT_PLANAR) ? + h * s * bps / 8 : h * s)); img->img_data_owner = 1; } @@ -142,8 +179,8 @@ vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, - unsigned int stride_align) { - return img_alloc_helper(img, fmt, d_w, d_h, stride_align, NULL); + unsigned int align) { + return img_alloc_helper(img, fmt, d_w, d_h, align, align, NULL); } vpx_image_t *vpx_img_wrap(vpx_image_t *img, @@ -152,7 +189,9 @@ vpx_image_t *vpx_img_wrap(vpx_image_t *img, unsigned int d_h, unsigned int stride_align, unsigned char *img_data) { - return img_alloc_helper(img, fmt, d_w, d_h, stride_align, img_data); + /* By setting buf_align = 1, we don't change buffer alignment in this + * function. */ + return img_alloc_helper(img, fmt, d_w, d_h, 1, stride_align, img_data); } int vpx_img_set_rect(vpx_image_t *img, @@ -232,7 +271,7 @@ void vpx_img_flip(vpx_image_t *img) { void vpx_img_free(vpx_image_t *img) { if (img) { if (img->img_data && img->img_data_owner) - free(img->img_data); + img_buf_free(img->img_data); if (img->self_allocd) free(img); diff --git a/vpx/vp8.h b/vpx/vp8.h index 1450efb67..3c313632b 100644 --- a/vpx/vp8.h +++ b/vpx/vp8.h @@ -28,8 +28,8 @@ /*!\file * \brief Provides controls common to both the VP8 encoder and decoder. */ -#ifndef VP9_H -#define VP9_H +#ifndef VP8_H +#define VP8_H #include "vpx_codec_impl_top.h" /*!\brief Control functions @@ -45,7 +45,7 @@ enum vp8_com_control_id { VP8_SET_DBG_COLOR_B_MODES = 6, /**< set which blocks modes to color */ VP8_SET_DBG_DISPLAY_MV = 7, /**< set which motion vector modes to draw */ VP8_COMMON_CTRL_ID_MAX, - VP8_DECODER_CTRL_ID_START = 256, + VP8_DECODER_CTRL_ID_START = 256 }; /*!\brief post process flags @@ -61,6 +61,7 @@ enum vp8_postproc_level { VP8_DEBUG_TXT_MBLK_MODES = 1 << 4, /**< print macro block modes over each macro block */ VP8_DEBUG_TXT_DC_DIFF = 1 << 5, /**< print dc diff for each macro block */ VP8_DEBUG_TXT_RATE_INFO = 1 << 6, /**< print video rate info (encoder only) */ + VP8_MFQE = 1 << 10 }; /*!\brief post process flags @@ -113,13 +114,5 @@ VPX_CTRL_USE_TYPE(VP8_SET_DBG_DISPLAY_MV, int) /*! @} - end defgroup vp8 */ -#if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT -/* The following definitions are provided for backward compatibility with - * the VP8 1.0.x SDK. USE IN PRODUCTION CODE IS NOT RECOMMENDED. - */ - -DECLSPEC_DEPRECATED extern vpx_codec_iface_t vpx_codec_vp8_algo DEPRECATED; -#endif - #include "vpx_codec_impl_bottom.h" #endif diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h index 193ae8049..50fc7f031 100644 --- a/vpx/vp8cx.h +++ b/vpx/vp8cx.h @@ -20,9 +20,8 @@ * \brief Provides definitions for using the VP8 encoder algorithm within the * vpx Codec Interface. */ -#ifndef VP9CX_H -#define VP9CX_H -#include "vpx_config.h" +#ifndef VP8CX_H +#define VP8CX_H #include "vpx_codec_impl_top.h" /*!\name Algorithm interface for VP8 @@ -33,18 +32,12 @@ */ extern vpx_codec_iface_t vpx_codec_vp8_cx_algo; extern vpx_codec_iface_t *vpx_codec_vp8_cx(void); -/*!@} - end algorithm interface member group*/ - -#if CONFIG_EXPERIMENTAL -/*!\brief Algorithm interface for VP8 experimental branch - * - * This interface provides the ability to encode using the "experimental" - * VP8 variant, which is bitstream incompatible with the default VP8 encoder. - */ -extern vpx_codec_iface_t vpx_codec_vp8x_cx_algo; +/* TODO(jkoleszar): These move to VP9 in a later patch set. */ +extern vpx_codec_iface_t vpx_codec_vp8x_cx_algo; extern vpx_codec_iface_t *vpx_codec_vp8x_cx(void); -#endif + +/*!@} - end algorithm interface member group*/ /* @@ -189,6 +182,10 @@ enum vp8e_enc_control_id { * */ VP8E_SET_MAX_INTRA_BITRATE_PCT, + + + /* TODO(jkoleszar): Move to vp9cx.h */ + VP9E_SET_LOSSLESS }; /*!\brief vpx 1-D scaling mode @@ -213,8 +210,8 @@ typedef struct vpx_roi_map { unsigned char *roi_map; /**< specify an id between 0 and 3 for each 16x16 region within a frame */ unsigned int rows; /**< number of rows */ unsigned int cols; /**< number of cols */ - int delta_q[4]; /**< quantizer delta [-64, 64] off baseline for regions with id between 0 and 3*/ - int delta_lf[4]; /**< loop filter strength delta [-32, 32] for regions with id between 0 and 3 */ + int delta_q[4]; /**< quantizer delta [-63, 63] off baseline for regions with id between 0 and 3*/ + int delta_lf[4]; /**< loop filter strength delta [-63, 63] for regions with id between 0 and 3 */ unsigned int static_threshold[4];/**< threshold for region to be treated as static */ } vpx_roi_map_t; @@ -241,17 +238,6 @@ typedef struct vpx_scaling_mode { VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode */ } vpx_scaling_mode_t; -/*!\brief VP8 encoding mode - * - * This defines VP8 encoding mode - * - */ -typedef enum { - VP8_BEST_QUALITY_ENCODING, - VP8_GOOD_QUALITY_ENCODING, - VP8_REAL_TIME_ENCODING -} vp8e_encoding_mode; - /*!\brief VP8 token partition mode * * This defines VP8 partitioning mode for compressed data, i.e., the number of @@ -263,7 +249,7 @@ typedef enum { VP8_ONE_TOKENPARTITION = 0, VP8_TWO_TOKENPARTITION = 1, VP8_FOUR_TOKENPARTITION = 2, - VP8_EIGHT_TOKENPARTITION = 3, + VP8_EIGHT_TOKENPARTITION = 3 } vp8e_token_partitions; @@ -302,12 +288,12 @@ VPX_CTRL_USE_TYPE(VP8E_SET_ENABLEAUTOALTREF, unsigned int) VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY, unsigned int) VPX_CTRL_USE_TYPE(VP8E_SET_SHARPNESS, unsigned int) VPX_CTRL_USE_TYPE(VP8E_SET_STATIC_THRESHOLD, unsigned int) -VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, vp8e_token_partitions) +VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, int) /* vp8e_token_partitions */ VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_MAXFRAMES, unsigned int) VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH, unsigned int) VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_TYPE, unsigned int) -VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, vp8e_tuning) +VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, int) /* vp8e_tuning */ VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL, unsigned int) VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *) @@ -315,6 +301,7 @@ VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *) VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTRA_BITRATE_PCT, unsigned int) +VPX_CTRL_USE_TYPE(VP9E_SET_LOSSLESS, unsigned int) /*! @} - end defgroup vp8_encoder */ #include "vpx_codec_impl_bottom.h" diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h index b076f51ea..a2c3a3928 100644 --- a/vpx/vp8dx.h +++ b/vpx/vp8dx.h @@ -20,8 +20,8 @@ * \brief Provides definitions for using the VP8 algorithm within the vpx Decoder * interface. */ -#ifndef VP9DX_H -#define VP9DX_H +#ifndef VP8DX_H +#define VP8DX_H #include "vpx_codec_impl_top.h" /*!\name Algorithm interface for VP8 @@ -54,6 +54,11 @@ enum vp8_dec_control_id { /** check if the indicated frame is corrupted */ VP8D_GET_FRAME_CORRUPTED, + /** control function to get info on which reference frames were used + * by the last decode + */ + VP8D_GET_LAST_REF_USED, + VP8_DECODER_CTRL_ID_MAX }; @@ -68,7 +73,7 @@ enum vp8_dec_control_id { VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *) VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *) - +VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *) /*! @} - end defgroup vp8_decoder */ diff --git a/vpx/vp8e.h b/vpx/vp8e.h deleted file mode 100644 index 00ff090a6..000000000 --- a/vpx/vp8e.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* This file contains backwards compatibility stubs for applications using - * the VP8 version 1.0 API. - */ -#ifndef VP9E_H -#define VP9E_H -#include "vpx_codec_impl_top.h" - -#if defined(VPX_CODEC_DISABLE_COMPAT) && VPX_CODEC_DISABLE_COMPAT -#error "Backwards compatibility disabled: don't include vp8e.h" -#endif - -#include "vp8cx.h" -DECLSPEC_DEPRECATED extern vpx_codec_iface_t vpx_enc_vp8_algo DEPRECATED; - - -enum { - VP8E_SET_REFERENCE = VP8_SET_REFERENCE, - VP8E_COPY_REFERENCE = VP8_COPY_REFERENCE, - VP8E_SET_PREVIEWPP = VP8_SET_POSTPROC, - VP8E_SET_FLUSHFLAG = 4, - VP8E_SET_FRAMETYPE = 10, - VP8E_SET_ENCODING_MODE = 12 -}; - -#define NORMAL_FRAME (0) -#define KEY_FRAME (1) - -/* Change VP8E to VP8 to get the undeprecated version of these (defined in - * vp8.h) - */ -VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_REFERENCE, vpx_ref_frame_t *) -VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_COPY_REFERENCE, vpx_ref_frame_t *) -VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_PREVIEWPP, vp8_postproc_cfg_t *) - - -/* Flush is done by calling vpx_codec_encode with a NULL input image. */ -VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_FLUSHFLAG, int) - - -/* Frame type is set with a flag to vpx_codec_control. See VPX_EFLAG_FORCE_KF - */ -VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_FRAMETYPE, int) - - -/* This control has been deprecated in favor of the duration parameter to - * vpx_codec_encode(). Use the #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY, - * #VPX_DL_BEST_QUALITY constants to that parameter instead. - */ -VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_ENCODING_MODE, vp8e_encoding_mode) -#include "vpx_codec_impl_bottom.h" -#endif diff --git a/vpx/vpx_codec.mk b/vpx/vpx_codec.mk index 4f1d74bd4..427fd0f52 100644 --- a/vpx/vpx_codec.mk +++ b/vpx/vpx_codec.mk @@ -11,12 +11,10 @@ API_EXPORTS += exports -API_SRCS-$(CONFIG_DECODERS) += src/vpx_decoder.c -API_SRCS-$(CONFIG_DECODERS) += src/vpx_decoder_compat.c -API_SRCS-$(CONFIG_DECODERS) += vpx_decoder.h -API_SRCS-$(CONFIG_DECODERS) += vpx_decoder_compat.h -API_SRCS-$(CONFIG_ENCODERS) += src/vpx_encoder.c -API_SRCS-$(CONFIG_ENCODERS) += vpx_encoder.h +API_SRCS-yes += src/vpx_decoder.c +API_SRCS-yes += vpx_decoder.h +API_SRCS-yes += src/vpx_encoder.c +API_SRCS-yes += vpx_encoder.h API_SRCS-yes += internal/vpx_codec_internal.h API_SRCS-yes += src/vpx_codec.c API_SRCS-yes += src/vpx_image.c diff --git a/vpx/vpx_decoder.h b/vpx/vpx_decoder.h index 3b919e508..dbe6aaaaa 100644 --- a/vpx/vpx_decoder.h +++ b/vpx/vpx_decoder.h @@ -53,8 +53,10 @@ extern "C" { #define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */ #define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */ #define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */ -#define VPX_CODEC_CAP_INPUT_PARTITION 0x100000 /**< Can receive encoded frames - one partition at a time */ +#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000 /**< Can conceal errors due to + packet loss */ +#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000 /**< Can receive encoded frames + one fragment at a time */ /*! \brief Initialization-time Feature Enabling * @@ -64,9 +66,11 @@ extern "C" { * The available flags are specified by VPX_CODEC_USE_* defines. */ #define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */ -#define VPX_CODEC_USE_INPUT_PARTITION 0x40000 /**< The input frame should be +#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000 /**< Conceal errors in decoded + frames */ +#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000 /**< The input frame should be passed to the decoder one - partition at a time */ + fragment at a time */ /*!\brief Stream properties * @@ -107,6 +111,10 @@ extern "C" { * function directly, to ensure that the ABI version number parameter * is properly initialized. * + * If the library was configured with --disable-multithread, this call + * is not thread safe and should be guarded with a lock if being used + * in a multithreaded context. + * * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags * parameter), the storage pointed to by the cfg parameter must be * kept readable and stable until all memory maps have been set. @@ -183,11 +191,13 @@ extern "C" { * generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode * time stamp) order. Frames produced will always be in PTS (presentation * time stamp) order. - * If the decoder is configured with VPX_CODEC_USE_INPUT_PARTITION enabled, - * data and data_sz must contain at most one encoded partition. When no more - * data is available, this function should be called with NULL as data and 0 - * as data_sz. The memory passed to this function must be available until - * the frame has been decoded. + * If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled, + * data and data_sz can contain a fragment of the encoded frame. Fragment + * \#n must contain at least partition \#n, but can also contain subsequent + * partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must + * be empty. When no more data is available, this function should be called + * with NULL as data and 0 as data_sz. The memory passed to this function + * must be available until the frame has been decoded. * * \param[in] ctx Pointer to this instance's context * \param[in] data Pointer to this block of new coded data. If @@ -319,7 +329,3 @@ extern "C" { #ifdef __cplusplus } #endif - -#if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT -#include "vpx_decoder_compat.h" -#endif diff --git a/vpx/vpx_decoder_compat.h b/vpx/vpx_decoder_compat.h deleted file mode 100644 index c657ef9d9..000000000 --- a/vpx/vpx_decoder_compat.h +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/*!\defgroup decoder Common Decoder Algorithm Interface - * This abstraction allows applications using this decoder to easily support - * multiple video formats with minimal code duplication. This section describes - * the interface common to all codecs. - * @{ - */ - -/*!\file - * \brief Provides a compatibility layer between version 1 and 2 of this API. - * - * This interface has been deprecated. Only existing code should make use - * of this interface, and therefore, it is only thinly documented. Existing - * code should be ported to the vpx_codec_* API. - */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef VPX_DECODER_COMPAT_H -#define VPX_DECODER_COMPAT_H - - /*!\brief Decoder algorithm return codes */ - typedef enum { - /*!\brief Operation completed without error */ - VPX_DEC_OK = VPX_CODEC_OK, - - /*!\brief Unspecified error */ - VPX_DEC_ERROR = VPX_CODEC_ERROR, - - /*!\brief Memory operation failed */ - VPX_DEC_MEM_ERROR = VPX_CODEC_MEM_ERROR, - - /*!\brief ABI version mismatch */ - VPX_DEC_ABI_MISMATCH = VPX_CODEC_ABI_MISMATCH, - - /*!\brief The given bitstream is not supported. - * - * The bitstream was unable to be parsed at the highest level. The decoder - * is unable to proceed. This error \ref SHOULD be treated as fatal to the - * stream. */ - VPX_DEC_UNSUP_BITSTREAM = VPX_CODEC_UNSUP_BITSTREAM, - - /*!\brief Encoded bitstream uses an unsupported feature - * - * The decoder does not implement a feature required by the encoder. This - * return code should only be used for features that prevent future - * pictures from being properly decoded. This error \ref MAY be treated as - * fatal to the stream or \ref MAY be treated as fatal to the current GOP. - */ - VPX_DEC_UNSUP_FEATURE = VPX_CODEC_UNSUP_FEATURE, - - /*!\brief The coded data for this stream is corrupt or incomplete - * - * There was a problem decoding the current frame. This return code - * should only be used for failures that prevent future pictures from - * being properly decoded. This error \ref MAY be treated as fatal to the - * stream or \ref MAY be treated as fatal to the current GOP. If decoding - * is continued for the current GOP, artifacts may be present. - */ - VPX_DEC_CORRUPT_FRAME = VPX_CODEC_CORRUPT_FRAME, - - /*!\brief An application-supplied parameter is not valid. - * - */ - VPX_DEC_INVALID_PARAM = VPX_CODEC_INVALID_PARAM, - - /*!\brief An iterator reached the end of list. - * - */ - VPX_DEC_LIST_END = VPX_CODEC_LIST_END - - } - vpx_dec_err_t; - - /*! \brief Decoder capabilities bitfield - * - * Each decoder advertises the capabilities it supports as part of its - * ::vpx_dec_iface_t interface structure. Capabilities are extra interfaces - * or functionality, and are not required to be supported by a decoder. - * - * The available flags are specified by VPX_DEC_CAP_* defines. - */ - typedef int vpx_dec_caps_t; -#define VPX_DEC_CAP_PUT_SLICE 0x0001 /**< Will issue put_slice callbacks */ -#define VPX_DEC_CAP_PUT_FRAME 0x0002 /**< Will issue put_frame callbacks */ -#define VPX_DEC_CAP_XMA 0x0004 /**< Supports eXternal Memory Allocation */ - - /*!\brief Stream properties - * - * This structure is used to query or set properties of the decoded - * stream. Algorithms may extend this structure with data specific - * to their bitstream by setting the sz member appropriately. - */ -#if 1 - typedef vpx_codec_stream_info_t vpx_dec_stream_info_t; -#else - typedef struct { - unsigned int sz; /**< Size of this structure */ - unsigned int w; /**< Width (or 0 for unknown/default) */ - unsigned int h; /**< Height (or 0 for unknown/default) */ - unsigned int is_kf; /**< Current frame is a keyframe */ - } vpx_dec_stream_info_t; -#endif - - - /*!\brief Decoder interface structure. - * - * Contains function pointers and other data private to the decoder - * implementation. This structure is opaque to the application. - */ - typedef const struct vpx_codec_iface vpx_dec_iface_t; - typedef struct vpx_codec_priv vpx_dec_priv_t; - - /*!\brief Iterator - * - * Opaque storage used for iterating over lists. - */ - typedef vpx_codec_iter_t vpx_dec_iter_t; - - /*!\brief Decoder context structure - * - * All decoders \ref MUST support this context structure fully. In general, - * this data should be considered private to the decoder algorithm, and - * not be manipulated or examined by the calling application. Applications - * may reference the 'name' member to get a printable description of the - * algorithm. - */ -#if 1 - typedef vpx_codec_ctx_t vpx_dec_ctx_t; -#else - typedef struct { - const char *name; /**< Printable interface name */ - vpx_dec_iface_t *iface; /**< Interface pointers */ - vpx_dec_err_t err; /**< Last returned error */ - vpx_dec_priv_t *priv; /**< Algorithm private storage */ - } vpx_dec_ctx_t; -#endif - - - /*!\brief Return the build configuration - * - * Returns a printable string containing an encoded version of the build - * configuration. This may be useful to vpx support. - * - */ - const char *vpx_dec_build_config(void) DEPRECATED; - - /*!\brief Return the name for a given interface - * - * Returns a human readable string for name of the given decoder interface. - * - * \param[in] iface Interface pointer - * - */ - const char *vpx_dec_iface_name(vpx_dec_iface_t *iface) DEPRECATED; - - - /*!\brief Convert error number to printable string - * - * Returns a human readable string for the last error returned by the - * algorithm. The returned error will be one line and will not contain - * any newline characters. - * - * - * \param[in] err Error number. - * - */ - const char *vpx_dec_err_to_string(vpx_dec_err_t err) DEPRECATED; - - - /*!\brief Retrieve error synopsis for decoder context - * - * Returns a human readable string for the last error returned by the - * algorithm. The returned error will be one line and will not contain - * any newline characters. - * - * - * \param[in] ctx Pointer to this instance's context. - * - */ - const char *vpx_dec_error(vpx_dec_ctx_t *ctx) DEPRECATED; - - - /*!\brief Retrieve detailed error information for decoder context - * - * Returns a human readable string providing detailed information about - * the last error. - * - * \param[in] ctx Pointer to this instance's context. - * - * \retval NULL - * No detailed information is available. - */ - const char *vpx_dec_error_detail(vpx_dec_ctx_t *ctx) DEPRECATED; - - - /* REQUIRED FUNCTIONS - * - * The following functions are required to be implemented for all decoders. - * They represent the base case functionality expected of all decoders. - */ - - - /*!\brief Initialize a decoder instance - * - * Initializes a decoder context using the given interface. Applications - * should call the vpx_dec_init convenience macro instead of this - * function directly, to ensure that the ABI version number parameter - * is properly initialized. - * - * \param[in] ctx Pointer to this instance's context. - * \param[in] iface Pointer to the algorithm interface to use. - * \param[in] ver ABI version number. Must be set to - * VPX_DECODER_ABI_VERSION - * \retval #VPX_DEC_OK - * The decoder algorithm initialized. - * \retval #VPX_DEC_MEM_ERROR - * Memory allocation failed. - */ - vpx_dec_err_t vpx_dec_init_ver(vpx_dec_ctx_t *ctx, - vpx_dec_iface_t *iface, - int ver) DEPRECATED; -#define vpx_dec_init(ctx, iface) \ - vpx_dec_init_ver(ctx, iface, VPX_DECODER_ABI_VERSION) - - - /*!\brief Destroy a decoder instance - * - * Destroys a decoder context, freeing any associated memory buffers. - * - * \param[in] ctx Pointer to this instance's context - * - * \retval #VPX_DEC_OK - * The decoder algorithm initialized. - * \retval #VPX_DEC_MEM_ERROR - * Memory allocation failed. - */ - vpx_dec_err_t vpx_dec_destroy(vpx_dec_ctx_t *ctx) DEPRECATED; - - - /*!\brief Get the capabilities of an algorithm. - * - * Retrieves the capabilities bitfield from the algorithm's interface. - * - * \param[in] iface Pointer to the algorithm interface - * - */ - vpx_dec_caps_t vpx_dec_get_caps(vpx_dec_iface_t *iface) DEPRECATED; - - - /*!\brief Parse stream info from a buffer - * - * Performs high level parsing of the bitstream. Construction of a decoder - * context is not necessary. Can be used to determine if the bitstream is - * of the proper format, and to extract information from the stream. - * - * \param[in] iface Pointer to the algorithm interface - * \param[in] data Pointer to a block of data to parse - * \param[in] data_sz Size of the data buffer - * \param[in,out] si Pointer to stream info to update. The size member - * \ref MUST be properly initialized, but \ref MAY be - * clobbered by the algorithm. This parameter \ref MAY - * be NULL. - * - * \retval #VPX_DEC_OK - * Bitstream is parsable and stream information updated - */ - vpx_dec_err_t vpx_dec_peek_stream_info(vpx_dec_iface_t *iface, - const uint8_t *data, - unsigned int data_sz, - vpx_dec_stream_info_t *si) DEPRECATED; - - - /*!\brief Return information about the current stream. - * - * Returns information about the stream that has been parsed during decoding. - * - * \param[in] ctx Pointer to this instance's context - * \param[in,out] si Pointer to stream info to update. The size member - * \ref MUST be properly initialized, but \ref MAY be - * clobbered by the algorithm. This parameter \ref MAY - * be NULL. - * - * \retval #VPX_DEC_OK - * Bitstream is parsable and stream information updated - */ - vpx_dec_err_t vpx_dec_get_stream_info(vpx_dec_ctx_t *ctx, - vpx_dec_stream_info_t *si) DEPRECATED; - - - /*!\brief Control algorithm - * - * This function is used to exchange algorithm specific data with the decoder - * instance. This can be used to implement features specific to a particular - * algorithm. - * - * This wrapper function dispatches the request to the helper function - * associated with the given ctrl_id. It tries to call this function - * transparently, but will return #VPX_DEC_ERROR if the request could not - * be dispatched. - * - * \param[in] ctx Pointer to this instance's context - * \param[in] ctrl_id Algorithm specific control identifier - * \param[in,out] data Data to exchange with algorithm instance. - * - * \retval #VPX_DEC_OK - * The control request was processed. - * \retval #VPX_DEC_ERROR - * The control request was not processed. - * \retval #VPX_DEC_INVALID_PARAM - * The data was not valid. - */ - vpx_dec_err_t vpx_dec_control(vpx_dec_ctx_t *ctx, - int ctrl_id, - void *data) DEPRECATED; - - /*!\brief Decode data - * - * Processes a buffer of coded data. If the processing results in a new - * decoded frame becoming available, #VPX_DEC_CB_PUT_SLICE and - * #VPX_DEC_CB_PUT_FRAME events may be generated, as appropriate. Encoded data - * \ref MUST be passed in DTS (decode time stamp) order. Frames produced will - * always be in PTS (presentation time stamp) order. - * - * \param[in] ctx Pointer to this instance's context - * \param[in] data Pointer to this block of new coded data. If - * NULL, a VPX_DEC_CB_PUT_FRAME event is posted - * for the previously decoded frame. - * \param[in] data_sz Size of the coded data, in bytes. - * \param[in] user_priv Application specific data to associate with - * this frame. - * \param[in] rel_pts PTS relative to the previous frame, in us. If - * unknown or unavailable, set to zero. - * - * \return Returns #VPX_DEC_OK if the coded data was processed completely - * and future pictures can be decoded without error. Otherwise, - * see the descriptions of the other error codes in ::vpx_dec_err_t - * for recoverability capabilities. - */ - vpx_dec_err_t vpx_dec_decode(vpx_dec_ctx_t *ctx, - uint8_t *data, - unsigned int data_sz, - void *user_priv, - int rel_pts) DEPRECATED; - - - /*!\brief Decoded frames iterator - * - * Iterates over a list of the frames available for display. The iterator - * storage should be initialized to NULL to start the iteration. Iteration is - * complete when this function returns NULL. - * - * The list of available frames becomes valid upon completion of the - * vpx_dec_decode call, and remains valid until the next call to vpx_dec_decode. - * - * \param[in] ctx Pointer to this instance's context - * \param[in out] iter Iterator storage, initialized to NULL - * - * \return Returns a pointer to an image, if one is ready for display. Frames - * produced will always be in PTS (presentation time stamp) order. - */ - vpx_image_t *vpx_dec_get_frame(vpx_dec_ctx_t *ctx, - vpx_dec_iter_t *iter) DEPRECATED; - - - /*!\defgroup cap_put_frame Frame-Based Decoding Functions - * - * The following functions are required to be implemented for all decoders - * that advertise the VPX_DEC_CAP_PUT_FRAME capability. Calling these functions - * for codecs that don't advertise this capability will result in an error - * code being returned, usually VPX_DEC_ERROR - * @{ - */ - - /*!\brief put frame callback prototype - * - * This callback is invoked by the decoder to notify the application of - * the availability of decoded image data. - */ - typedef void (*vpx_dec_put_frame_cb_fn_t)(void *user_priv, - const vpx_image_t *img); - - - /*!\brief Register for notification of frame completion. - * - * Registers a given function to be called when a decoded frame is - * available. - * - * \param[in] ctx Pointer to this instance's context - * \param[in] cb Pointer to the callback function - * \param[in] user_priv User's private data - * - * \retval #VPX_DEC_OK - * Callback successfully registered. - * \retval #VPX_DEC_ERROR - * Decoder context not initialized, or algorithm not capable of - * posting slice completion. - */ - vpx_dec_err_t vpx_dec_register_put_frame_cb(vpx_dec_ctx_t *ctx, - vpx_dec_put_frame_cb_fn_t cb, - void *user_priv) DEPRECATED; - - - /*!@} - end defgroup cap_put_frame */ - - /*!\defgroup cap_put_slice Slice-Based Decoding Functions - * - * The following functions are required to be implemented for all decoders - * that advertise the VPX_DEC_CAP_PUT_SLICE capability. Calling these functions - * for codecs that don't advertise this capability will result in an error - * code being returned, usually VPX_DEC_ERROR - * @{ - */ - - /*!\brief put slice callback prototype - * - * This callback is invoked by the decoder to notify the application of - * the availability of partially decoded image data. The - */ - typedef void (*vpx_dec_put_slice_cb_fn_t)(void *user_priv, - const vpx_image_t *img, - const vpx_image_rect_t *valid, - const vpx_image_rect_t *update); - - - /*!\brief Register for notification of slice completion. - * - * Registers a given function to be called when a decoded slice is - * available. - * - * \param[in] ctx Pointer to this instance's context - * \param[in] cb Pointer to the callback function - * \param[in] user_priv User's private data - * - * \retval #VPX_DEC_OK - * Callback successfully registered. - * \retval #VPX_DEC_ERROR - * Decoder context not initialized, or algorithm not capable of - * posting slice completion. - */ - vpx_dec_err_t vpx_dec_register_put_slice_cb(vpx_dec_ctx_t *ctx, - vpx_dec_put_slice_cb_fn_t cb, - void *user_priv) DEPRECATED; - - - /*!@} - end defgroup cap_put_slice*/ - - /*!\defgroup cap_xma External Memory Allocation Functions - * - * The following functions are required to be implemented for all decoders - * that advertise the VPX_DEC_CAP_XMA capability. Calling these functions - * for codecs that don't advertise this capability will result in an error - * code being returned, usually VPX_DEC_ERROR - * @{ - */ - - /*!\brief Memory Map Entry - * - * This structure is used to contain the properties of a memory segment. It - * is populated by the decoder in the request phase, and by the calling - * application once the requested allocation has been performed. - */ -#if 1 -#define VPX_DEC_MEM_ZERO 0x1 /**< Segment must be zeroed by allocation */ -#define VPX_DEC_MEM_WRONLY 0x2 /**< Segment need not be readable */ -#define VPX_DEC_MEM_FAST 0x4 /**< Place in fast memory, if available */ - typedef struct vpx_codec_mmap vpx_dec_mmap_t; -#else - typedef struct vpx_dec_mmap { - /* - * The following members are set by the codec when requesting a segment - */ - unsigned int id; /**< identifier for the segment's contents */ - unsigned long sz; /**< size of the segment, in bytes */ - unsigned int align; /**< required alignment of the segment, in bytes */ - unsigned int flags; /**< bitfield containing segment properties */ -#define VPX_DEC_MEM_ZERO 0x1 /**< Segment must be zeroed by allocation */ -#define VPX_DEC_MEM_WRONLY 0x2 /**< Segment need not be readable */ -#define VPX_DEC_MEM_FAST 0x4 /**< Place in fast memory, if available */ - - /* The following members are to be filled in by the allocation function */ - void *base; /**< pointer to the allocated segment */ - void (*dtor)(struct vpx_dec_mmap *map); /**< destructor to call */ - void *priv; /**< allocator private storage */ - } vpx_dec_mmap_t; -#endif - - /*!\brief Initialize a decoder instance in external allocation mode - * - * Initializes a decoder context using the given interface. Applications - * should call the vpx_dec_xma_init convenience macro instead of this - * function directly, to ensure that the ABI version number parameter - * is properly initialized. - * - * \param[in] ctx Pointer to this instance's context. - * \param[in] iface Pointer to the algorithm interface to use. - * \param[in] ver ABI version number. Must be set to - * VPX_DECODER_ABI_VERSION - * \retval #VPX_DEC_OK - * The decoder algorithm initialized. - * \retval #VPX_DEC_ERROR - * Decoder does not support XMA mode. - */ - vpx_dec_err_t vpx_dec_xma_init_ver(vpx_dec_ctx_t *ctx, - vpx_dec_iface_t *iface, - int ver) DEPRECATED; -#define vpx_dec_xma_init(ctx, iface) \ - vpx_dec_xma_init_ver(ctx, iface, VPX_DECODER_ABI_VERSION) - - - /*!\brief Iterate over the list of segments to allocate. - * - * Iterates over a list of the segments to allocate. The iterator storage - * should be initialized to NULL to start the iteration. Iteration is complete - * when this function returns VPX_DEC_LIST_END. The amount of memory needed to - * allocate is dependent upon the size of the encoded stream. This means that - * the stream info structure must be known at allocation time. It can be - * populated with the vpx_dec_peek_stream_info() function. In cases where the - * stream to be decoded is not available at allocation time, a fixed size must - * be requested. The decoder will not be able to decode streams larger than - * the size used at allocation time. - * - * \param[in] ctx Pointer to this instance's context. - * \param[out] mmap Pointer to the memory map entry to populate. - * \param[in] si Pointer to the stream info. - * \param[in out] iter Iterator storage, initialized to NULL - * - * \retval #VPX_DEC_OK - * The memory map entry was populated. - * \retval #VPX_DEC_ERROR - * Decoder does not support XMA mode. - * \retval #VPX_DEC_MEM_ERROR - * Unable to determine segment size from stream info. - */ - vpx_dec_err_t vpx_dec_get_mem_map(vpx_dec_ctx_t *ctx, - vpx_dec_mmap_t *mmap, - const vpx_dec_stream_info_t *si, - vpx_dec_iter_t *iter) DEPRECATED; - - - /*!\brief Identify allocated segments to decoder instance - * - * Stores a list of allocated segments in the decoder. Segments \ref MUST be - * passed in the order they are read from vpx_dec_get_mem_map(), but may be - * passed in groups of any size. Segments \ref MUST be set only once. The - * allocation function \ref MUST ensure that the vpx_dec_mmap_t::base member - * is non-NULL. If the segment requires cleanup handling (e.g., calling free() - * or close()) then the vpx_dec_mmap_t::dtor member \ref MUST be populated. - * - * \param[in] ctx Pointer to this instance's context. - * \param[in] mmaps Pointer to the first memory map entry in the list. - * \param[in] num_maps Number of entries being set at this time - * - * \retval #VPX_DEC_OK - * The segment was stored in the decoder context. - * \retval #VPX_DEC_ERROR - * Decoder does not support XMA mode. - * \retval #VPX_DEC_MEM_ERROR - * Segment base address was not set, or segment was already stored. - - */ - vpx_dec_err_t vpx_dec_set_mem_map(vpx_dec_ctx_t *ctx, - vpx_dec_mmap_t *mmaps, - unsigned int num_maps) DEPRECATED; - - /*!@} - end defgroup cap_xma*/ - /*!@} - end defgroup decoder*/ - - -#endif -#ifdef __cplusplus -} -#endif diff --git a/vpx/vpx_encoder.h b/vpx/vpx_encoder.h index ec7ce4898..ffdbc0644 100644 --- a/vpx/vpx_encoder.h +++ b/vpx/vpx_encoder.h @@ -32,6 +32,19 @@ extern "C" { #define VPX_ENCODER_H #include "vpx_codec.h" + /*! Temporal Scalability: Maximum length of the sequence defining frame + * layer membership + */ +#define VPX_TS_MAX_PERIODICITY 16 + + /*! Temporal Scalability: Maximum number of coding layers */ +#define VPX_TS_MAX_LAYERS 5 + + /*!\deprecated Use #VPX_TS_MAX_PERIODICITY instead. */ +#define MAX_PERIODICITY VPX_TS_MAX_PERIODICITY + + /*!\deprecated Use #VPX_TS_MAX_LAYERS instead. */ +#define MAX_LAYERS VPX_TS_MAX_LAYERS /*!\brief Current ABI version number * @@ -41,7 +54,7 @@ extern "C" { * types, removing or reassigning enums, adding/removing/rearranging * fields to structures */ -#define VPX_ENCODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ +#define VPX_ENCODER_ABI_VERSION (3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ /*! \brief Encoder capabilities bitfield @@ -581,12 +594,46 @@ extern "C" { */ unsigned int kf_max_dist; + /* + * Temporal scalability settings (ts) + */ + + /*!\brief Number of coding layers + * + * This value specifies the number of coding layers to be used. + */ + unsigned int ts_number_layers; + + /*!\brief Target bitrate for each layer + * + * These values specify the target coding bitrate for each coding layer. + */ + unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS]; + + /*!\brief Frame rate decimation factor for each layer + * + * These values specify the frame rate decimation factors to apply + * to each layer. + */ + unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS]; - /*!\brief Enable lossless compression mode + /*!\brief Length of the sequence defining frame layer membership * - * If this flag is set, the decoder will be in lossless compression mode. + * This value specifies the length of the sequence that defines the + * membership of frames to layers. For example, if ts_periodicity=8 then + * frames are assigned to coding layers with a repeated sequence of + * length 8. */ - unsigned int lossless; + unsigned int ts_periodicity; + + /*!\brief Template defining the membership of frames to coding layers + * + * This array defines the membership of frames to coding layers. For a + * 2-layer encoding that assigns even numbered frames to one layer (0) + * and odd numbered frames to a second layer (1) with ts_periodicity=8, + * then ts_layer_id = (0,1,0,1,0,1,0,1). + */ + unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY]; } vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */ @@ -597,6 +644,10 @@ extern "C" { * function directly, to ensure that the ABI version number parameter * is properly initialized. * + * If the library was configured with --disable-multithread, this call + * is not thread safe and should be guarded with a lock if being used + * in a multithreaded context. + * * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags * parameter), the storage pointed to by the cfg parameter must be * kept readable and stable until all memory maps have been set. @@ -627,6 +678,48 @@ extern "C" { vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION) + /*!\brief Initialize multi-encoder instance + * + * Initializes multi-encoder context using the given interface. + * Applications should call the vpx_codec_enc_init_multi convenience macro + * instead of this function directly, to ensure that the ABI version number + * parameter is properly initialized. + * + * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags + * parameter), the storage pointed to by the cfg parameter must be + * kept readable and stable until all memory maps have been set. + * + * \param[in] ctx Pointer to this instance's context. + * \param[in] iface Pointer to the algorithm interface to use. + * \param[in] cfg Configuration to use, if known. May be NULL. + * \param[in] num_enc Total number of encoders. + * \param[in] flags Bitfield of VPX_CODEC_USE_* flags + * \param[in] dsf Pointer to down-sampling factors. + * \param[in] ver ABI version number. Must be set to + * VPX_ENCODER_ABI_VERSION + * \retval #VPX_CODEC_OK + * The decoder algorithm initialized. + * \retval #VPX_CODEC_MEM_ERROR + * Memory allocation failed. + */ + vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx, + vpx_codec_iface_t *iface, + vpx_codec_enc_cfg_t *cfg, + int num_enc, + vpx_codec_flags_t flags, + vpx_rational_t *dsf, + int ver); + + + /*!\brief Convenience macro for vpx_codec_enc_init_multi_ver() + * + * Ensures the ABI version parameter is properly set. + */ +#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \ + vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \ + VPX_ENCODER_ABI_VERSION) + + /*!\brief Get a default configuration * * Initializes a encoder configuration structure with default values. Supports @@ -732,7 +825,6 @@ extern "C" { vpx_enc_frame_flags_t flags, unsigned long deadline); - /*!\brief Set compressed data output buffer * * Sets the buffer that the codec should output the compressed data diff --git a/vpx/vpx_image.h b/vpx/vpx_image.h index c94028bb4..809fa38d0 100644 --- a/vpx/vpx_image.h +++ b/vpx/vpx_image.h @@ -158,7 +158,8 @@ extern "C" { * \param[in] fmt Format for the image * \param[in] d_w Width of the image * \param[in] d_h Height of the image - * \param[in] align Alignment, in bytes, of each row in the image. + * \param[in] align Alignment, in bytes, of the image buffer and + * each row in the image(stride). * * \return Returns a pointer to the initialized image descriptor. If the img * parameter is non-null, the value of the img parameter will be diff --git a/vpx/vpx_integer.h b/vpx/vpx_integer.h index 608760f8b..218bca773 100644 --- a/vpx/vpx_integer.h +++ b/vpx/vpx_integer.h @@ -29,16 +29,8 @@ typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; #endif -#ifdef HAVE_ARMV6 -typedef unsigned int int_fast16_t; -#else -typedef signed short int_fast16_t; -#endif -typedef signed char int_fast8_t; -typedef unsigned char uint_fast8_t; - #ifndef _UINTPTR_T_DEFINED -typedef unsigned int uintptr_t; +typedef size_t uintptr_t; #endif #else diff --git a/vpxenc.c b/vpxenc.c index c52800661..cf7727440 100644 --- a/vpxenc.c +++ b/vpxenc.c @@ -1052,14 +1052,22 @@ static const arg_def_t max_intra_rate_pct = ARG_DEF(NULL, "max-intra-rate", 1, static const arg_def_t *vp8_args[] = { &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type, - &tune_ssim, &cq_level, &max_intra_rate_pct, NULL + &tune_ssim, &cq_level, &max_intra_rate_pct, +#if CONFIG_LOSSLESS + &lossless_enabled, +#endif + NULL }; static const int vp8_arg_ctrl_map[] = { VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, VP8E_SET_TOKEN_PARTITIONS, VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, - VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, 0 + VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, +#if CONFIG_LOSSLESS + VP9E_SET_LOSSLESS, +#endif + 0 }; #endif @@ -1563,10 +1571,6 @@ int main(int argc, const char **argv_) { cfg.g_w = 0; cfg.g_h = 0; -#if CONFIG_LOSSLESS - cfg.lossless = 0; -#endif - /* Now parse the remainder of the parameters. */ for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) { arg.argv_step = 1; @@ -1643,21 +1647,10 @@ int main(int argc, const char **argv_) { cfg.kf_max_dist = arg_parse_uint(&arg); else if (arg_match(&arg, &kf_disabled, argi)) cfg.kf_mode = VPX_KF_DISABLED; -#if CONFIG_LOSSLESS - else if (arg_match(&arg, &lossless_enabled, argi)) - cfg.lossless = 1; -#endif else argj++; } -#if CONFIG_LOSSLESS - if (cfg.lossless) { - cfg.rc_min_quantizer = 0; - cfg.rc_max_quantizer = 0; - } -#endif - /* Handle codec specific options */ #if CONFIG_VP9_ENCODER @@ -1807,9 +1800,6 @@ int main(int argc, const char **argv_) { SHOW(kf_mode); SHOW(kf_min_dist); SHOW(kf_max_dist); -#if CONFIG_LOSSLESS - SHOW(lossless); -#endif } if (pass == (one_pass_only ? one_pass_only - 1 : 0)) { -- 2.40.0