1 /* 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 * 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. 9 */ 10 11 12 /*!\defgroup codec Common Algorithm Interface 13 * This abstraction allows applications to easily support multiple video 14 * formats with minimal code duplication. This section describes the interface 15 * common to all codecs (both encoders and decoders). 16 * @{ 17 */ 18 19 /*!\file 20 * \brief Describes the codec algorithm interface to applications. 21 * 22 * This file describes the interface between an application and a 23 * video codec algorithm. 24 * 25 * An application instantiates a specific codec instance by using 26 * vpx_codec_init() and a pointer to the algorithm's interface structure: 27 * <pre> 28 * my_app.c: 29 * extern vpx_codec_iface_t my_codec; 30 * { 31 * vpx_codec_ctx_t algo; 32 * res = vpx_codec_init(&algo, &my_codec); 33 * } 34 * </pre> 35 * 36 * Once initialized, the instance is manged using other functions from 37 * the vpx_codec_* family. 38 */ 39 40 module libvpx.vpx.vpx_codec; 41 42 extern (C) { 43 44 import libvpx.vpx.vpx_integer; 45 import libvpx.vpx.vpx_image; 46 47 enum VPX_CODEC_ABI_VERSION = (2 + VPX_IMAGE_ABI_VERSION); 48 49 /*!\brief Algorithm return codes */ 50 enum vpx_codec_err_t { 51 /*!\brief Operation completed without error */ 52 VPX_CODEC_OK, 53 54 /*!\brief Unspecified error */ 55 VPX_CODEC_ERROR, 56 57 /*!\brief Memory operation failed */ 58 VPX_CODEC_MEM_ERROR, 59 60 /*!\brief ABI version mismatch */ 61 VPX_CODEC_ABI_MISMATCH, 62 63 /*!\brief Algorithm does not have required capability */ 64 VPX_CODEC_INCAPABLE, 65 66 /*!\brief The given bitstream is not supported. 67 * 68 * The bitstream was unable to be parsed at the highest level. The decoder 69 * is unable to proceed. This error \ref SHOULD be treated as fatal to the 70 * stream. */ 71 VPX_CODEC_UNSUP_BITSTREAM, 72 73 /*!\brief Encoded bitstream uses an unsupported feature 74 * 75 * The decoder does not implement a feature required by the encoder. This 76 * return code should only be used for features that prevent future 77 * pictures from being properly decoded. This error \ref MAY be treated as 78 * fatal to the stream or \ref MAY be treated as fatal to the current GOP. 79 */ 80 VPX_CODEC_UNSUP_FEATURE, 81 82 /*!\brief The coded data for this stream is corrupt or incomplete 83 * 84 * There was a problem decoding the current frame. This return code 85 * should only be used for failures that prevent future pictures from 86 * being properly decoded. This error \ref MAY be treated as fatal to the 87 * stream or \ref MAY be treated as fatal to the current GOP. If decoding 88 * is continued for the current GOP, artifacts may be present. 89 */ 90 VPX_CODEC_CORRUPT_FRAME, 91 92 /*!\brief An application-supplied parameter is not valid. 93 * 94 */ 95 VPX_CODEC_INVALID_PARAM, 96 97 /*!\brief An iterator reached the end of list. 98 * 99 */ 100 VPX_CODEC_LIST_END 101 } 102 103 /*! \brief Initialization-time Feature Enabling 104 * 105 * Certain codec features must be known at initialization time, to allow for 106 * proper memory allocation. 107 * 108 * The available flags are specified by VPX_CODEC_USE_* defines. 109 */ 110 alias vpx_codec_flags_t = long; 111 112 /*!\brief Codec interface structure. 113 * 114 * Contains function pointers and other data private to the codec 115 * implementation. This structure is opaque to the application. 116 */ 117 struct vpx_codec_iface; // TODO: is this code safe ? 118 alias vpx_codec_iface_t = vpx_codec_iface; 119 120 121 /*!\brief Codec private data structure. 122 * 123 * Contains data private to the codec implementation. This structure is opaque 124 * to the application. 125 */ 126 struct vpx_codec_priv; 127 alias vpx_codec_priv_t = vpx_codec_priv; 128 129 130 /*!\brief Iterator 131 * 132 * Opaque storage used for iterating over lists. 133 */ 134 alias vpx_codec_iter_t = const void *; 135 136 struct vpx_codec_dec_cfg; 137 struct vpx_codec_enc_cfg; 138 /*!\brief Codec context structure 139 * 140 * All codecs \ref MUST support this context structure fully. In general, 141 * this data should be considered private to the codec algorithm, and 142 * not be manipulated or examined by the calling application. Applications 143 * may reference the 'name' member to get a printable description of the 144 * algorithm. 145 */ 146 struct vpx_codec_ctx { 147 const char *name; /**< Printable interface name */ 148 vpx_codec_iface_t *iface; /**< Interface pointers */ 149 vpx_codec_err_t err; /**< Last returned error */ 150 const char *err_detail; /**< Detailed info, if available */ 151 vpx_codec_flags_t init_flags; /**< Flags passed at init time */ 152 153 private union vpx_codec_ctx_cfg { 154 vpx_codec_dec_cfg *dec; /**< Decoder Configuration Pointer */ 155 vpx_codec_enc_cfg *enc; /**< Encoder Configuration Pointer */ 156 void *raw; 157 } 158 vpx_codec_ctx_cfg config; /**< Configuration pointer aliasing union */ 159 vpx_codec_priv_t *priv; /**< Algorithm private storage */ 160 } 161 alias vpx_codec_ctx_t = vpx_codec_ctx; 162 163 164 /* 165 * Library Version Number Interface 166 * 167 * For example, see the following sample return values: 168 * vpx_codec_version() (1<<16 | 2<<8 | 3) 169 * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba" 170 * vpx_codec_version_extra_str() "rc1-16-gec6a1ba" 171 */ 172 173 /*!\brief Return the version information (as an integer) 174 * 175 * Returns a packed encoding of the library version number. This will only include 176 * the major.minor.patch component of the version number. Note that this encoded 177 * value should be accessed through the macros provided, as the encoding may change 178 * in the future. 179 * 180 */ 181 int vpx_codec_version(); 182 183 /*!\brief Return the version information (as a string) 184 * 185 * Returns a printable string containing the full library version number. This may 186 * contain additional text following the three digit version number, as to indicate 187 * release candidates, prerelease versions, etc. 188 * 189 */ 190 const char *vpx_codec_version_str(); 191 192 193 /*!\brief Return the version information (as a string) 194 * 195 * Returns a printable "extra string". This is the component of the string returned 196 * by vpx_codec_version_str() following the three digit version number. 197 * 198 */ 199 const char *vpx_codec_version_extra_str(); 200 201 202 /*!\brief Return the build configuration 203 * 204 * Returns a printable string containing an encoded version of the build 205 * configuration. This may be useful to vpx support. 206 * 207 */ 208 const char *vpx_codec_build_config(); 209 210 211 /*!\brief Return the name for a given interface 212 * 213 * Returns a human readable string for name of the given codec interface. 214 * 215 * \param[in] iface Interface pointer 216 * 217 */ 218 const char *vpx_codec_iface_name(vpx_codec_iface_t *iface); 219 220 221 /*!\brief Convert error number to printable string 222 * 223 * Returns a human readable string for the last error returned by the 224 * algorithm. The returned error will be one line and will not contain 225 * any newline characters. 226 * 227 * 228 * \param[in] err Error number. 229 * 230 */ 231 const char *vpx_codec_err_to_string(vpx_codec_err_t err); 232 233 234 /*!\brief Retrieve error synopsis for codec context 235 * 236 * Returns a human readable string for the last error returned by the 237 * algorithm. The returned error will be one line and will not contain 238 * any newline characters. 239 * 240 * 241 * \param[in] ctx Pointer to this instance's context. 242 * 243 */ 244 const char *vpx_codec_error(vpx_codec_ctx_t *ctx); 245 246 247 /*!\brief Retrieve detailed error information for codec context 248 * 249 * Returns a human readable string providing detailed information about 250 * the last error. 251 * 252 * \param[in] ctx Pointer to this instance's context. 253 * 254 * \retval NULL 255 * No detailed information is available. 256 */ 257 const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx); 258 259 260 /* REQUIRED FUNCTIONS 261 * 262 * The following functions are required to be implemented for all codecs. 263 * They represent the base case functionality expected of all codecs. 264 */ 265 266 /*!\brief Destroy a codec instance 267 * 268 * Destroys a codec context, freeing any associated memory buffers. 269 * 270 * \param[in] ctx Pointer to this instance's context 271 * 272 * \retval #VPX_CODEC_OK 273 * The codec algorithm initialized. 274 * \retval #VPX_CODEC_MEM_ERROR 275 * Memory allocation failed. 276 */ 277 vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx); 278 279 280 /*!\brief Get the capabilities of an algorithm. 281 * 282 * Retrieves the capabilities bitfield from the algorithm's interface. 283 * 284 * \param[in] iface Pointer to the algorithm interface 285 * 286 */ 287 //vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface); 288 289 }