*/
#include <limits.h>
#include <string.h>
-#include "vpx/internal/vpx_codec_internal.h"
#include "vpx_config.h"
+#include "vpx/internal/vpx_codec_internal.h"
#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,
- vpx_codec_enc_cfg_t *cfg,
+ const vpx_codec_enc_cfg_t *cfg,
vpx_codec_flags_t flags,
int ver) {
vpx_codec_err_t res;
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;
ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL;
vpx_codec_destroy(ctx);
}
-
- if (ctx->priv)
- ctx->priv->iface = ctx->iface;
}
return SAVE_STATUS(ctx, res);
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;
}
}
- if (ctx->priv)
- ctx->priv->iface = ctx->iface;
-
if (res)
break;
unsigned int usage) {
vpx_codec_err_t res;
vpx_codec_enc_cfg_map_t *map;
+ int i;
if (!iface || !cfg || usage > INT_MAX)
res = VPX_CODEC_INVALID_PARAM;
else {
res = VPX_CODEC_INVALID_PARAM;
- for (map = iface->enc.cfg_maps; map->usage >= 0; map++) {
+ for (i = 0; i < iface->enc.cfg_map_count; ++i) {
+ map = iface->enc.cfg_maps + i;
if (map->usage == (int)usage) {
*cfg = map->cfg;
cfg->g_usage = usage;
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:
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;
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) {
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;
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;
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);
}