2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 /*!\file vpx_decoder.c
13 * \brief Provides the high level interface to wrap decoder algorithms.
17 #include "vpx/vpx_integer.h"
18 #include "vpx/internal/vpx_codec_internal.h"
19 #include "vpx_version.h"
21 #define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var)
23 int vpx_codec_version(void)
25 return VERSION_PACKED;
29 const char *vpx_codec_version_str(void)
31 return VERSION_STRING_NOSP;
35 const char *vpx_codec_version_extra_str(void)
41 const char *vpx_codec_iface_name(vpx_codec_iface_t *iface)
43 return iface ? iface->name : "<invalid interface>";
46 const char *vpx_codec_err_to_string(vpx_codec_err_t err)
53 return "Unspecified internal error";
54 case VPX_CODEC_MEM_ERROR:
55 return "Memory allocation error";
56 case VPX_CODEC_ABI_MISMATCH:
57 return "ABI version mismatch";
58 case VPX_CODEC_INCAPABLE:
59 return "Codec does not implement requested capability";
60 case VPX_CODEC_UNSUP_BITSTREAM:
61 return "Bitstream not supported by this decoder";
62 case VPX_CODEC_UNSUP_FEATURE:
63 return "Bitstream required feature not supported by this decoder";
64 case VPX_CODEC_CORRUPT_FRAME:
65 return "Corrupt frame detected";
66 case VPX_CODEC_INVALID_PARAM:
67 return "Invalid parameter";
68 case VPX_CODEC_LIST_END:
69 return "End of iterated list";
72 return "Unrecognized error code";
75 const char *vpx_codec_error(vpx_codec_ctx_t *ctx)
77 return (ctx) ? vpx_codec_err_to_string(ctx->err)
78 : vpx_codec_err_to_string(VPX_CODEC_INVALID_PARAM);
81 const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx)
84 return ctx->priv ? ctx->priv->err_detail : ctx->err_detail;
90 vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
95 res = VPX_CODEC_INVALID_PARAM;
96 else if (!ctx->iface || !ctx->priv)
97 res = VPX_CODEC_ERROR;
100 if (ctx->priv->alg_priv)
101 ctx->iface->destroy(ctx->priv->alg_priv);
109 return SAVE_STATUS(ctx, res);
113 vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface)
115 return (iface) ? iface->caps : 0;
119 vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx,
125 if (!ctx || !ctrl_id)
126 res = VPX_CODEC_INVALID_PARAM;
127 else if (!ctx->iface || !ctx->priv || !ctx->iface->ctrl_maps)
128 res = VPX_CODEC_ERROR;
131 vpx_codec_ctrl_fn_map_t *entry;
133 res = VPX_CODEC_ERROR;
135 for (entry = ctx->iface->ctrl_maps; entry && entry->fn; entry++)
137 if (!entry->ctrl_id || entry->ctrl_id == ctrl_id)
141 va_start(ap, ctrl_id);
142 res = entry->fn(ctx->priv->alg_priv, ctrl_id, ap);
149 return SAVE_STATUS(ctx, res);