Merge "Consistent allocation of vpx_codec_alg_priv_t."

This commit is contained in:
Dmitry Kovalev 2014-09-03 19:41:28 -07:00 коммит произвёл Gerrit Code Review
Родитель ab73dba65f b08fab8808
Коммит 3820f568da
4 изменённых файлов: 31 добавлений и 33 удалений

Просмотреть файл

@ -14,6 +14,7 @@
#include "vpx/vpx_codec.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "vpx_version.h"
#include "vpx_mem/vpx_mem.h"
#include "vp8/encoder/onyx_int.h"
#include "vpx/vp8cx.h"
#include "vp8/encoder/firstpass.h"
@ -619,13 +620,14 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx,
vpx_codec_priv_enc_mr_cfg_t *mr_cfg)
{
vpx_codec_err_t res = VPX_CODEC_OK;
struct vpx_codec_alg_priv *priv;
vp8_rtcd();
if (!ctx->priv)
{
priv = calloc(1, sizeof(struct vpx_codec_alg_priv));
struct vpx_codec_alg_priv *priv =
(struct vpx_codec_alg_priv *)vpx_calloc(1, sizeof(*priv));
if (!priv)
{
@ -633,7 +635,7 @@ static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx,
}
ctx->priv = (vpx_codec_priv_t *)priv;
ctx->priv->sz = sizeof(struct vpx_codec_alg_priv);
ctx->priv->sz = sizeof(*priv);
ctx->priv->init_flags = ctx->init_flags;
if (ctx->config.enc)
@ -692,7 +694,7 @@ static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx)
free(ctx->cx_data);
vp8_remove_compressor(&ctx->cpi);
free(ctx);
vpx_free(ctx);
return VPX_CODEC_OK;
}

Просмотреть файл

@ -81,11 +81,10 @@ 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)
{
vpx_codec_alg_priv_t *priv =
(vpx_codec_alg_priv_t *)vpx_memalign(8, sizeof(*priv));
vpx_memset(priv, 0, sizeof(*priv));
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
ctx->priv = (vpx_codec_priv_t *)priv;
ctx->priv->sz = sizeof(*ctx->priv);
ctx->priv->sz = sizeof(*priv);
ctx->priv->init_flags = ctx->init_flags;
priv->si.sz = sizeof(priv->si);

Просмотреть файл

@ -665,34 +665,33 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx,
(void)data;
if (ctx->priv == NULL) {
vpx_codec_alg_priv_t *const alg_priv = calloc(1, sizeof(*alg_priv));
if (alg_priv == NULL)
vpx_codec_alg_priv_t *const priv = vpx_calloc(1, sizeof(*priv));
if (priv == NULL)
return VPX_CODEC_MEM_ERROR;
ctx->priv = (vpx_codec_priv_t *)alg_priv;
ctx->priv->sz = sizeof(vpx_codec_alg_priv_t);
ctx->priv = (vpx_codec_priv_t *)priv;
ctx->priv->sz = sizeof(*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 internal copy.
alg_priv->cfg = *ctx->config.enc;
ctx->config.enc = &alg_priv->cfg;
priv->cfg = *ctx->config.enc;
ctx->config.enc = &priv->cfg;
}
alg_priv->extra_cfg = default_extra_cfg;
priv->extra_cfg = default_extra_cfg;
vp9_initialize_enc();
res = validate_config(alg_priv, &alg_priv->cfg, &alg_priv->extra_cfg);
res = validate_config(priv, &priv->cfg, &priv->extra_cfg);
if (res == VPX_CODEC_OK) {
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)
set_encoder_config(&priv->oxcf, &priv->cfg, &priv->extra_cfg);
priv->cpi = vp9_create_compressor(&priv->oxcf);
if (priv->cpi == NULL)
res = VPX_CODEC_MEM_ERROR;
else
alg_priv->cpi->output_pkt_list = &alg_priv->pkt_list.head;
priv->cpi->output_pkt_list = &priv->pkt_list.head;
}
}
@ -702,7 +701,7 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx,
static vpx_codec_err_t encoder_destroy(vpx_codec_alg_priv_t *ctx) {
free(ctx->cx_data);
vp9_remove_compressor(ctx->cpi);
free(ctx);
vpx_free(ctx);
return VPX_CODEC_OK;
}

Просмотреть файл

@ -58,25 +58,23 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx,
(void)data;
if (!ctx->priv) {
vpx_codec_alg_priv_t *const alg_priv = vpx_memalign(32, sizeof(*alg_priv));
if (alg_priv == NULL)
vpx_codec_alg_priv_t *const priv = vpx_calloc(1, sizeof(*priv));
if (priv == NULL)
return VPX_CODEC_MEM_ERROR;
vp9_zero(*alg_priv);
ctx->priv = (vpx_codec_priv_t *)alg_priv;
ctx->priv->sz = sizeof(*alg_priv);
ctx->priv = (vpx_codec_priv_t *)priv;
ctx->priv->sz = sizeof(*priv);
ctx->priv->init_flags = ctx->init_flags;
alg_priv->si.sz = sizeof(alg_priv->si);
alg_priv->flushed = 0;
alg_priv->frame_parallel_decode =
priv->si.sz = sizeof(priv->si);
priv->flushed = 0;
priv->frame_parallel_decode =
(ctx->init_flags & VPX_CODEC_USE_FRAME_THREADING);
alg_priv->frame_parallel_decode = 0; // Disable for now
priv->frame_parallel_decode = 0; // Disable for now
if (ctx->config.dec) {
alg_priv->cfg = *ctx->config.dec;
ctx->config.dec = &alg_priv->cfg;
priv->cfg = *ctx->config.dec;
ctx->config.dec = &priv->cfg;
}
}