diff options
-rw-r--r-- | vp8/vp8_cx_iface.c | 24 | ||||
-rw-r--r-- | vp8/vp8_dx_iface.c | 52 | ||||
-rw-r--r-- | vp9/vp9_cx_iface.c | 33 | ||||
-rw-r--r-- | vp9/vp9_dx_iface.c | 21 | ||||
-rw-r--r-- | vpx/internal/vpx_codec_internal.h | 1 | ||||
-rw-r--r-- | vpx/src/vpx_codec.c | 5 | ||||
-rw-r--r-- | vpx/src/vpx_decoder.c | 14 | ||||
-rw-r--r-- | vpx/src/vpx_encoder.c | 16 |
8 files changed, 78 insertions, 88 deletions
diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c index 1654cd821..5be645c71 100644 --- a/vp8/vp8_cx_iface.c +++ b/vp8/vp8_cx_iface.c @@ -620,7 +620,6 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, { vpx_codec_err_t res = VPX_CODEC_OK; struct vpx_codec_alg_priv *priv; - struct VP8_COMP *optr; vp8_rtcd(); @@ -633,9 +632,8 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, return VPX_CODEC_MEM_ERROR; } - ctx->priv = &priv->base; - ctx->priv->sz = sizeof(*ctx->priv); - ctx->priv->alg_priv = priv; + ctx->priv = (vpx_codec_priv_t *)priv; + ctx->priv->sz = sizeof(struct vpx_codec_alg_priv); ctx->priv->init_flags = ctx->init_flags; if (ctx->config.enc) @@ -643,11 +641,10 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, /* Update the reference to the config structure to an * internal copy. */ - ctx->priv->alg_priv->cfg = *ctx->config.enc; - ctx->config.enc = &ctx->priv->alg_priv->cfg; + priv->cfg = *ctx->config.enc; + ctx->config.enc = &priv->cfg; } - priv->vp8_cfg = default_extracfg; priv->vp8_cfg.pkt_list = &priv->pkt_list.head; @@ -671,17 +668,10 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, if (!res) { - set_vp8e_config(&ctx->priv->alg_priv->oxcf, - ctx->priv->alg_priv->cfg, - ctx->priv->alg_priv->vp8_cfg, - mr_cfg); - - optr = vp8_create_compressor(&ctx->priv->alg_priv->oxcf); - - if (!optr) + set_vp8e_config(&priv->oxcf, priv->cfg, priv->vp8_cfg, mr_cfg); + priv->cpi = vp8_create_compressor(&priv->oxcf); + if (!priv->cpi) res = VPX_CODEC_MEM_ERROR; - else - ctx->priv->alg_priv->cpi = optr; } } diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c index 05f32ba20..282032055 100644 --- a/vp8/vp8_dx_iface.c +++ b/vp8/vp8_dx_iface.c @@ -80,29 +80,32 @@ static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_ static void vp8_init_ctx(vpx_codec_ctx_t *ctx) { - ctx->priv = - (vpx_codec_priv_t *)vpx_memalign(8, sizeof(vpx_codec_alg_priv_t)); - vpx_memset(ctx->priv, 0, sizeof(vpx_codec_alg_priv_t)); + vpx_codec_alg_priv_t *priv = + (vpx_codec_alg_priv_t *)vpx_memalign(8, sizeof(*priv)); + vpx_memset(priv, 0, sizeof(*priv)); + + ctx->priv = (vpx_codec_priv_t *)priv; ctx->priv->sz = sizeof(*ctx->priv); - ctx->priv->alg_priv = (vpx_codec_alg_priv_t *)ctx->priv; - ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si); - ctx->priv->alg_priv->decrypt_cb = NULL; - ctx->priv->alg_priv->decrypt_state = NULL; - ctx->priv->alg_priv->flushed = 0; ctx->priv->init_flags = ctx->init_flags; + priv->si.sz = sizeof(priv->si); + priv->decrypt_cb = NULL; + priv->decrypt_state = NULL; + priv->flushed = 0; + if (ctx->config.dec) { /* Update the reference to the config structure to an internal copy. */ - ctx->priv->alg_priv->cfg = *ctx->config.dec; - ctx->config.dec = &ctx->priv->alg_priv->cfg; + priv->cfg = *ctx->config.dec; + ctx->config.dec = &priv->cfg; } } 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; + vpx_codec_err_t res = VPX_CODEC_OK; + vpx_codec_alg_priv_t *priv = NULL; (void) data; vp8_rtcd(); @@ -114,29 +117,30 @@ static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx, if (!ctx->priv) { vp8_init_ctx(ctx); + priv = (vpx_codec_alg_priv_t *)ctx->priv; /* initialize number of fragments to zero */ - ctx->priv->alg_priv->fragments.count = 0; + priv->fragments.count = 0; /* is input fragments enabled? */ - ctx->priv->alg_priv->fragments.enabled = - (ctx->priv->alg_priv->base.init_flags & - VPX_CODEC_USE_INPUT_FRAGMENTS); + priv->fragments.enabled = + (priv->base.init_flags & VPX_CODEC_USE_INPUT_FRAGMENTS); /*post processing level initialized to do nothing */ } + else + { + priv = (vpx_codec_alg_priv_t *)ctx->priv; + } - ctx->priv->alg_priv->yv12_frame_buffers.use_frame_threads = - (ctx->priv->alg_priv->base.init_flags & - VPX_CODEC_USE_FRAME_THREADING); + priv->yv12_frame_buffers.use_frame_threads = + (ctx->priv->init_flags & VPX_CODEC_USE_FRAME_THREADING); /* for now, disable frame threading */ - ctx->priv->alg_priv->yv12_frame_buffers.use_frame_threads = 0; + priv->yv12_frame_buffers.use_frame_threads = 0; - if(ctx->priv->alg_priv->yv12_frame_buffers.use_frame_threads && - (( ctx->priv->alg_priv->base.init_flags & - VPX_CODEC_USE_ERROR_CONCEALMENT) - || ( ctx->priv->alg_priv->base.init_flags & - VPX_CODEC_USE_INPUT_FRAGMENTS) ) ) + if (priv->yv12_frame_buffers.use_frame_threads && + ((ctx->priv->init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT) || + (ctx->priv->init_flags & VPX_CODEC_USE_INPUT_FRAGMENTS))) { /* row-based threading, error concealment, and input fragments will * not be supported when using frame-based threading */ diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 0cd1195bc..3dbf0017d 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -644,41 +644,34 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx, (void)data; if (ctx->priv == NULL) { - struct vpx_codec_alg_priv *priv = calloc(1, sizeof(*priv)); + vpx_codec_alg_priv_t *const alg_priv = calloc(1, sizeof(*alg_priv)); - if (priv == NULL) + if (alg_priv == NULL) return VPX_CODEC_MEM_ERROR; - ctx->priv = &priv->base; - ctx->priv->sz = sizeof(*ctx->priv); - ctx->priv->alg_priv = priv; + ctx->priv = (vpx_codec_priv_t *)alg_priv; + ctx->priv->sz = sizeof(vpx_codec_alg_priv_t); 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 internal copy. - ctx->priv->alg_priv->cfg = *ctx->config.enc; - ctx->config.enc = &ctx->priv->alg_priv->cfg; + alg_priv->cfg = *ctx->config.enc; + ctx->config.enc = &alg_priv->cfg; } - priv->extra_cfg = default_extra_cfg; - + alg_priv->extra_cfg = default_extra_cfg; vp9_initialize_enc(); - res = validate_config(priv, &priv->cfg, &priv->extra_cfg); + res = validate_config(alg_priv, &alg_priv->cfg, &alg_priv->extra_cfg); if (res == VPX_CODEC_OK) { - VP9_COMP *cpi; - set_encoder_config(&ctx->priv->alg_priv->oxcf, - &ctx->priv->alg_priv->cfg, - &ctx->priv->alg_priv->extra_cfg); - cpi = vp9_create_compressor(&ctx->priv->alg_priv->oxcf); - if (cpi == NULL) { + set_encoder_config(&alg_priv->oxcf, &alg_priv->cfg, &alg_priv->extra_cfg); + alg_priv->cpi = vp9_create_compressor(&alg_priv->oxcf); + if (alg_priv->cpi == NULL) res = VPX_CODEC_MEM_ERROR; - } else { - cpi->output_pkt_list = &priv->pkt_list.head; - ctx->priv->alg_priv->cpi = cpi; - } + else + alg_priv->cpi->output_pkt_list = &alg_priv->pkt_list.head; } } diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index 05d61c8a0..7909f5392 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -58,28 +58,25 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx, (void)data; if (!ctx->priv) { - vpx_codec_alg_priv_t *alg_priv = vpx_memalign(32, sizeof(*alg_priv)); + vpx_codec_alg_priv_t *const alg_priv = vpx_memalign(32, sizeof(*alg_priv)); if (alg_priv == NULL) return VPX_CODEC_MEM_ERROR; vp9_zero(*alg_priv); ctx->priv = (vpx_codec_priv_t *)alg_priv; - ctx->priv->sz = sizeof(*ctx->priv); - ctx->priv->alg_priv = alg_priv; - ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si); + ctx->priv->sz = sizeof(*alg_priv); ctx->priv->init_flags = ctx->init_flags; - ctx->priv->alg_priv->flushed = 0; - ctx->priv->alg_priv->frame_parallel_decode = - (ctx->init_flags & VPX_CODEC_USE_FRAME_THREADING); - // Disable frame parallel decoding for now. - ctx->priv->alg_priv->frame_parallel_decode = 0; + alg_priv->si.sz = sizeof(alg_priv->si); + alg_priv->flushed = 0; + alg_priv->frame_parallel_decode = + (ctx->init_flags & VPX_CODEC_USE_FRAME_THREADING); + alg_priv->frame_parallel_decode = 0; // Disable for now if (ctx->config.dec) { - // Update the reference to the config structure to an internal copy. - ctx->priv->alg_priv->cfg = *ctx->config.dec; - ctx->config.dec = &ctx->priv->alg_priv->cfg; + alg_priv->cfg = *ctx->config.dec; + ctx->config.dec = &alg_priv->cfg; } } diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h index d7c580060..02f20791a 100644 --- a/vpx/internal/vpx_codec_internal.h +++ b/vpx/internal/vpx_codec_internal.h @@ -336,7 +336,6 @@ typedef struct vpx_codec_priv_cb_pair { */ struct vpx_codec_priv { unsigned int sz; - struct vpx_codec_alg_priv *alg_priv; const char *err_detail; vpx_codec_flags_t init_flags; struct { diff --git a/vpx/src/vpx_codec.c b/vpx/src/vpx_codec.c index d175eae64..5a495ce81 100644 --- a/vpx/src/vpx_codec.c +++ b/vpx/src/vpx_codec.c @@ -88,8 +88,7 @@ vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx) { else if (!ctx->iface || !ctx->priv) res = VPX_CODEC_ERROR; else { - if (ctx->priv->alg_priv) - ctx->iface->destroy(ctx->priv->alg_priv); + ctx->iface->destroy((vpx_codec_alg_priv_t *)ctx->priv); ctx->iface = NULL; ctx->name = NULL; @@ -125,7 +124,7 @@ vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, va_list ap; va_start(ap, ctrl_id); - res = entry->fn(ctx->priv->alg_priv, ap); + res = entry->fn((vpx_codec_alg_priv_t *)ctx->priv, ap); va_end(ap); break; } diff --git a/vpx/src/vpx_decoder.c b/vpx/src/vpx_decoder.c index fdcc9c1b1..802d8edd8 100644 --- a/vpx/src/vpx_decoder.c +++ b/vpx/src/vpx_decoder.c @@ -18,6 +18,10 @@ #define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var) +static vpx_codec_alg_priv_t *get_alg_priv(vpx_codec_ctx_t *ctx) { + return (vpx_codec_alg_priv_t *)ctx->priv; +} + vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, const vpx_codec_dec_cfg_t *cfg, @@ -94,7 +98,7 @@ vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx, si->w = 0; si->h = 0; - res = ctx->iface->dec.get_si(ctx->priv->alg_priv, si); + res = ctx->iface->dec.get_si(get_alg_priv(ctx), si); } return SAVE_STATUS(ctx, res); @@ -115,8 +119,8 @@ vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, else if (!ctx->iface || !ctx->priv) res = VPX_CODEC_ERROR; else { - res = ctx->iface->dec.decode(ctx->priv->alg_priv, data, data_sz, - user_priv, deadline); + res = ctx->iface->dec.decode(get_alg_priv(ctx), data, data_sz, user_priv, + deadline); } return SAVE_STATUS(ctx, res); @@ -129,7 +133,7 @@ vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, if (!ctx || !iter || !ctx->iface || !ctx->priv) img = NULL; else - img = ctx->iface->dec.get_frame(ctx->priv->alg_priv, iter); + img = ctx->iface->dec.get_frame(get_alg_priv(ctx), iter); return img; } @@ -185,7 +189,7 @@ vpx_codec_err_t vpx_codec_set_frame_buffer_functions( !(ctx->iface->caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) { res = VPX_CODEC_ERROR; } else { - res = ctx->iface->dec.set_fb_fn(ctx->priv->alg_priv, cb_get, cb_release, + res = ctx->iface->dec.set_fb_fn(get_alg_priv(ctx), cb_get, cb_release, cb_priv); } diff --git a/vpx/src/vpx_encoder.c b/vpx/src/vpx_encoder.c index 736a8daa2..1903b5575 100644 --- a/vpx/src/vpx_encoder.c +++ b/vpx/src/vpx_encoder.c @@ -20,6 +20,10 @@ #define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var) +static vpx_codec_alg_priv_t *get_alg_priv(vpx_codec_ctx_t *ctx) { + return (vpx_codec_alg_priv_t *)ctx->priv; +} + vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, const vpx_codec_enc_cfg_t *cfg, @@ -216,7 +220,7 @@ vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, FLOATING_POINT_INIT(); if (num_enc == 1) - res = ctx->iface->enc.encode(ctx->priv->alg_priv, img, pts, + res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration, flags, deadline); else { /* Multi-resolution encoding: @@ -230,7 +234,7 @@ vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, 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, + if ((res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration, flags, deadline))) break; @@ -259,7 +263,7 @@ const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx, else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER)) ctx->err = VPX_CODEC_INCAPABLE; else - pkt = ctx->iface->enc.get_cx_data(ctx->priv->alg_priv, iter); + pkt = ctx->iface->enc.get_cx_data(get_alg_priv(ctx), iter); } if (pkt && pkt->kind == VPX_CODEC_CX_FRAME_PKT) { @@ -327,7 +331,7 @@ const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx) { else if (!ctx->iface->enc.get_preview) ctx->err = VPX_CODEC_INCAPABLE; else - img = ctx->iface->enc.get_preview(ctx->priv->alg_priv); + img = ctx->iface->enc.get_preview(get_alg_priv(ctx)); } return img; @@ -345,7 +349,7 @@ vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx) { else if (!ctx->iface->enc.get_glob_hdrs) ctx->err = VPX_CODEC_INCAPABLE; else - buf = ctx->iface->enc.get_glob_hdrs(ctx->priv->alg_priv); + buf = ctx->iface->enc.get_glob_hdrs(get_alg_priv(ctx)); } return buf; @@ -361,7 +365,7 @@ vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx, else if (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER)) res = VPX_CODEC_INCAPABLE; else - res = ctx->iface->enc.cfg_set(ctx->priv->alg_priv, cfg); + res = ctx->iface->enc.cfg_set(get_alg_priv(ctx), cfg); return SAVE_STATUS(ctx, res); } |