| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 */ | 38 */ |
| 39 #ifdef __cplusplus | 39 #ifdef __cplusplus |
| 40 extern "C" { | 40 extern "C" { |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 #ifndef VPX_CODEC_H | 43 #ifndef VPX_CODEC_H |
| 44 #define VPX_CODEC_H | 44 #define VPX_CODEC_H |
| 45 #include "vpx_integer.h" | 45 #include "vpx_integer.h" |
| 46 #include "vpx_image.h" | 46 #include "vpx_image.h" |
| 47 | 47 |
| 48 /*!\brief Decorator indicating a function is deprecated */ | 48 /*!\brief Decorator indicating a function is deprecated */ |
| 49 #ifndef DEPRECATED | 49 #ifndef DEPRECATED |
| 50 #if defined(__GNUC__) && __GNUC__ | 50 #if defined(__GNUC__) && __GNUC__ |
| 51 #define DEPRECATED __attribute__ ((deprecated)) | 51 #define DEPRECATED __attribute__ ((deprecated)) |
| 52 #define DECLSPEC_DEPRECATED /**< \copydoc #DEPRECATED */ | 52 #define DECLSPEC_DEPRECATED /**< \copydoc #DEPRECATED */ |
| 53 #elif defined(_MSC_VER) | 53 #elif defined(_MSC_VER) |
| 54 #define DEPRECATED | 54 #define DEPRECATED |
| 55 #define DECLSPEC_DEPRECATED __declspec(deprecated) /**< \copydoc #DEPRECATED */ | 55 #define DECLSPEC_DEPRECATED __declspec(deprecated) /**< \copydoc #DEPRECATED */ |
| 56 #else | 56 #else |
| 57 #define DEPRECATED | 57 #define DEPRECATED |
| 58 #define DECLSPEC_DEPRECATED /**< \copydoc #DEPRECATED */ | 58 #define DECLSPEC_DEPRECATED /**< \copydoc #DEPRECATED */ |
| 59 #endif | 59 #endif |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 /*!\brief Decorator indicating a function is potentially unused */ | 62 /*!\brief Decorator indicating a function is potentially unused */ |
| 63 #ifdef UNUSED | 63 #ifdef UNUSED |
| 64 #elif __GNUC__ | 64 #elif __GNUC__ |
| 65 #define UNUSED __attribute__ ((unused)) | 65 #define UNUSED __attribute__ ((unused)) |
| 66 #else | 66 #else |
| 67 #define UNUSED | 67 #define UNUSED |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 /*!\brief Current ABI version number | 70 /*!\brief Current ABI version number |
| 71 * | 71 * |
| 72 * \internal | 72 * \internal |
| 73 * If this file is altered in any way that changes the ABI, this value | 73 * If this file is altered in any way that changes the ABI, this value |
| 74 * must be bumped. Examples include, but are not limited to, changing | 74 * must be bumped. Examples include, but are not limited to, changing |
| 75 * types, removing or reassigning enums, adding/removing/rearranging | 75 * types, removing or reassigning enums, adding/removing/rearranging |
| 76 * fields to structures | 76 * fields to structures |
| 77 */ |
| 78 #define VPX_CODEC_ABI_VERSION (2 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/ |
| 79 |
| 80 /*!\brief Algorithm return codes */ |
| 81 typedef enum { |
| 82 /*!\brief Operation completed without error */ |
| 83 VPX_CODEC_OK, |
| 84 |
| 85 /*!\brief Unspecified error */ |
| 86 VPX_CODEC_ERROR, |
| 87 |
| 88 /*!\brief Memory operation failed */ |
| 89 VPX_CODEC_MEM_ERROR, |
| 90 |
| 91 /*!\brief ABI version mismatch */ |
| 92 VPX_CODEC_ABI_MISMATCH, |
| 93 |
| 94 /*!\brief Algorithm does not have required capability */ |
| 95 VPX_CODEC_INCAPABLE, |
| 96 |
| 97 /*!\brief The given bitstream is not supported. |
| 98 * |
| 99 * The bitstream was unable to be parsed at the highest level. The decoder |
| 100 * is unable to proceed. This error \ref SHOULD be treated as fatal to the |
| 101 * stream. */ |
| 102 VPX_CODEC_UNSUP_BITSTREAM, |
| 103 |
| 104 /*!\brief Encoded bitstream uses an unsupported feature |
| 105 * |
| 106 * The decoder does not implement a feature required by the encoder. This |
| 107 * return code should only be used for features that prevent future |
| 108 * pictures from being properly decoded. This error \ref MAY be treated as |
| 109 * fatal to the stream or \ref MAY be treated as fatal to the current GOP. |
| 77 */ | 110 */ |
| 78 #define VPX_CODEC_ABI_VERSION (2 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/ | 111 VPX_CODEC_UNSUP_FEATURE, |
| 79 | 112 |
| 80 /*!\brief Algorithm return codes */ | 113 /*!\brief The coded data for this stream is corrupt or incomplete |
| 81 typedef enum { | 114 * |
| 82 /*!\brief Operation completed without error */ | 115 * There was a problem decoding the current frame. This return code |
| 83 VPX_CODEC_OK, | 116 * should only be used for failures that prevent future pictures from |
| 84 | 117 * being properly decoded. This error \ref MAY be treated as fatal to the |
| 85 /*!\brief Unspecified error */ | 118 * stream or \ref MAY be treated as fatal to the current GOP. If decoding |
| 86 VPX_CODEC_ERROR, | 119 * is continued for the current GOP, artifacts may be present. |
| 87 | |
| 88 /*!\brief Memory operation failed */ | |
| 89 VPX_CODEC_MEM_ERROR, | |
| 90 | |
| 91 /*!\brief ABI version mismatch */ | |
| 92 VPX_CODEC_ABI_MISMATCH, | |
| 93 | |
| 94 /*!\brief Algorithm does not have required capability */ | |
| 95 VPX_CODEC_INCAPABLE, | |
| 96 | |
| 97 /*!\brief The given bitstream is not supported. | |
| 98 * | |
| 99 * The bitstream was unable to be parsed at the highest level. The decod
er | |
| 100 * is unable to proceed. This error \ref SHOULD be treated as fatal to t
he | |
| 101 * stream. */ | |
| 102 VPX_CODEC_UNSUP_BITSTREAM, | |
| 103 | |
| 104 /*!\brief Encoded bitstream uses an unsupported feature | |
| 105 * | |
| 106 * The decoder does not implement a feature required by the encoder. Thi
s | |
| 107 * return code should only be used for features that prevent future | |
| 108 * pictures from being properly decoded. This error \ref MAY be treated
as | |
| 109 * fatal to the stream or \ref MAY be treated as fatal to the current GO
P. | |
| 110 */ | |
| 111 VPX_CODEC_UNSUP_FEATURE, | |
| 112 | |
| 113 /*!\brief The coded data for this stream is corrupt or incomplete | |
| 114 * | |
| 115 * There was a problem decoding the current frame. This return code | |
| 116 * should only be used for failures that prevent future pictures from | |
| 117 * being properly decoded. This error \ref MAY be treated as fatal to th
e | |
| 118 * stream or \ref MAY be treated as fatal to the current GOP. If decodin
g | |
| 119 * is continued for the current GOP, artifacts may be present. | |
| 120 */ | |
| 121 VPX_CODEC_CORRUPT_FRAME, | |
| 122 | |
| 123 /*!\brief An application-supplied parameter is not valid. | |
| 124 * | |
| 125 */ | |
| 126 VPX_CODEC_INVALID_PARAM, | |
| 127 | |
| 128 /*!\brief An iterator reached the end of list. | |
| 129 * | |
| 130 */ | |
| 131 VPX_CODEC_LIST_END | |
| 132 | |
| 133 } | |
| 134 vpx_codec_err_t; | |
| 135 | |
| 136 | |
| 137 /*! \brief Codec capabilities bitfield | |
| 138 * | |
| 139 * Each codec advertises the capabilities it supports as part of its | |
| 140 * ::vpx_codec_iface_t interface structure. Capabilities are extra interfac
es | |
| 141 * or functionality, and are not required to be supported. | |
| 142 * | |
| 143 * The available flags are specified by VPX_CODEC_CAP_* defines. | |
| 144 */ | 120 */ |
| 145 typedef long vpx_codec_caps_t; | 121 VPX_CODEC_CORRUPT_FRAME, |
| 122 |
| 123 /*!\brief An application-supplied parameter is not valid. |
| 124 * |
| 125 */ |
| 126 VPX_CODEC_INVALID_PARAM, |
| 127 |
| 128 /*!\brief An iterator reached the end of list. |
| 129 * |
| 130 */ |
| 131 VPX_CODEC_LIST_END |
| 132 |
| 133 } |
| 134 vpx_codec_err_t; |
| 135 |
| 136 |
| 137 /*! \brief Codec capabilities bitfield |
| 138 * |
| 139 * Each codec advertises the capabilities it supports as part of its |
| 140 * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces |
| 141 * or functionality, and are not required to be supported. |
| 142 * |
| 143 * The available flags are specified by VPX_CODEC_CAP_* defines. |
| 144 */ |
| 145 typedef long vpx_codec_caps_t; |
| 146 #define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */ | 146 #define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */ |
| 147 #define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */ | 147 #define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */ |
| 148 #define VPX_CODEC_CAP_XMA 0x4 /**< Supports eXternal Memory Allocation */ | 148 #define VPX_CODEC_CAP_XMA 0x4 /**< Supports eXternal Memory Allocation */ |
| 149 | 149 |
| 150 | 150 |
| 151 /*! \brief Initialization-time Feature Enabling | 151 /*! \brief Initialization-time Feature Enabling |
| 152 * | 152 * |
| 153 * Certain codec features must be known at initialization time, to allow fo
r | 153 * Certain codec features must be known at initialization time, to allow for |
| 154 * proper memory allocation. | 154 * proper memory allocation. |
| 155 * | 155 * |
| 156 * The available flags are specified by VPX_CODEC_USE_* defines. | 156 * The available flags are specified by VPX_CODEC_USE_* defines. |
| 157 */ | 157 */ |
| 158 typedef long vpx_codec_flags_t; | 158 typedef long vpx_codec_flags_t; |
| 159 #define VPX_CODEC_USE_XMA 0x00000001 /**< Use eXternal Memory Allocation mode
*/ | 159 #define VPX_CODEC_USE_XMA 0x00000001 /**< Use eXternal Memory Allocation mode
*/ |
| 160 | 160 |
| 161 | 161 |
| 162 /*!\brief Codec interface structure. | 162 /*!\brief Codec interface structure. |
| 163 * | 163 * |
| 164 * Contains function pointers and other data private to the codec | 164 * Contains function pointers and other data private to the codec |
| 165 * implementation. This structure is opaque to the application. | 165 * implementation. This structure is opaque to the application. |
| 166 */ | 166 */ |
| 167 typedef const struct vpx_codec_iface vpx_codec_iface_t; | 167 typedef const struct vpx_codec_iface vpx_codec_iface_t; |
| 168 | 168 |
| 169 | 169 |
| 170 /*!\brief Codec private data structure. | 170 /*!\brief Codec private data structure. |
| 171 * | 171 * |
| 172 * Contains data private to the codec implementation. This structure is opaq
ue | 172 * Contains data private to the codec implementation. This structure is opaque |
| 173 * to the application. | 173 * to the application. |
| 174 */ | 174 */ |
| 175 typedef struct vpx_codec_priv vpx_codec_priv_t; | 175 typedef struct vpx_codec_priv vpx_codec_priv_t; |
| 176 | 176 |
| 177 | 177 |
| 178 /*!\brief Iterator | 178 /*!\brief Iterator |
| 179 * | 179 * |
| 180 * Opaque storage used for iterating over lists. | 180 * Opaque storage used for iterating over lists. |
| 181 */ | 181 */ |
| 182 typedef const void *vpx_codec_iter_t; | 182 typedef const void *vpx_codec_iter_t; |
| 183 | 183 |
| 184 | 184 |
| 185 /*!\brief Codec context structure | 185 /*!\brief Codec context structure |
| 186 * | 186 * |
| 187 * All codecs \ref MUST support this context structure fully. In general, | 187 * All codecs \ref MUST support this context structure fully. In general, |
| 188 * this data should be considered private to the codec algorithm, and | 188 * this data should be considered private to the codec algorithm, and |
| 189 * not be manipulated or examined by the calling application. Applications | 189 * not be manipulated or examined by the calling application. Applications |
| 190 * may reference the 'name' member to get a printable description of the | 190 * may reference the 'name' member to get a printable description of the |
| 191 * algorithm. | 191 * algorithm. |
| 192 */ | 192 */ |
| 193 typedef struct vpx_codec_ctx | 193 typedef struct vpx_codec_ctx { |
| 194 { | 194 const char *name; /**< Printable interface name */ |
| 195 const char *name; /**< Printable interface name */ | 195 vpx_codec_iface_t *iface; /**< Interface pointers */ |
| 196 vpx_codec_iface_t *iface; /**< Interface pointers */ | 196 vpx_codec_err_t err; /**< Last returned error */ |
| 197 vpx_codec_err_t err; /**< Last returned error */ | 197 const char *err_detail; /**< Detailed info, if available */ |
| 198 const char *err_detail; /**< Detailed info, if available *
/ | 198 vpx_codec_flags_t init_flags; /**< Flags passed at init time */ |
| 199 vpx_codec_flags_t init_flags; /**< Flags passed at init time */ | 199 union { |
| 200 union | 200 struct vpx_codec_dec_cfg *dec; /**< Decoder Configuration Pointer */ |
| 201 { | 201 struct vpx_codec_enc_cfg *enc; /**< Encoder Configuration Pointer */ |
| 202 struct vpx_codec_dec_cfg *dec; /**< Decoder Configuration Pointer
*/ | 202 void *raw; |
| 203 struct vpx_codec_enc_cfg *enc; /**< Encoder Configuration Pointer
*/ | 203 } config; /**< Configuration pointer aliasing un
ion */ |
| 204 void *raw; | 204 vpx_codec_priv_t *priv; /**< Algorithm private storage */ |
| 205 } config; /**< Configuration pointer aliasin
g union */ | 205 } vpx_codec_ctx_t; |
| 206 vpx_codec_priv_t *priv; /**< Algorithm private storage */ | 206 |
| 207 } vpx_codec_ctx_t; | 207 |
| 208 | 208 /* |
| 209 | 209 * Library Version Number Interface |
| 210 /* | 210 * |
| 211 * Library Version Number Interface | 211 * For example, see the following sample return values: |
| 212 * | 212 * vpx_codec_version() (1<<16 | 2<<8 | 3) |
| 213 * For example, see the following sample return values: | 213 * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba" |
| 214 * vpx_codec_version() (1<<16 | 2<<8 | 3) | 214 * vpx_codec_version_extra_str() "rc1-16-gec6a1ba" |
| 215 * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba" | 215 */ |
| 216 * vpx_codec_version_extra_str() "rc1-16-gec6a1ba" | 216 |
| 217 */ | 217 /*!\brief Return the version information (as an integer) |
| 218 | 218 * |
| 219 /*!\brief Return the version information (as an integer) | 219 * Returns a packed encoding of the library version number. This will only inc
lude |
| 220 * | 220 * the major.minor.patch component of the version number. Note that this encod
ed |
| 221 * Returns a packed encoding of the library version number. This will only i
nclude | 221 * value should be accessed through the macros provided, as the encoding may c
hange |
| 222 * the major.minor.patch component of the version number. Note that this enc
oded | 222 * in the future. |
| 223 * value should be accessed through the macros provided, as the encoding may
change | 223 * |
| 224 * in the future. | 224 */ |
| 225 * | 225 int vpx_codec_version(void); |
| 226 */ | |
| 227 int vpx_codec_version(void); | |
| 228 #define VPX_VERSION_MAJOR(v) ((v>>16)&0xff) /**< extract major from packed versi
on */ | 226 #define VPX_VERSION_MAJOR(v) ((v>>16)&0xff) /**< extract major from packed versi
on */ |
| 229 #define VPX_VERSION_MINOR(v) ((v>>8)&0xff) /**< extract minor from packed versi
on */ | 227 #define VPX_VERSION_MINOR(v) ((v>>8)&0xff) /**< extract minor from packed versi
on */ |
| 230 #define VPX_VERSION_PATCH(v) ((v>>0)&0xff) /**< extract patch from packed versi
on */ | 228 #define VPX_VERSION_PATCH(v) ((v>>0)&0xff) /**< extract patch from packed versi
on */ |
| 231 | 229 |
| 232 /*!\brief Return the version major number */ | 230 /*!\brief Return the version major number */ |
| 233 #define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff) | 231 #define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff) |
| 234 | 232 |
| 235 /*!\brief Return the version minor number */ | 233 /*!\brief Return the version minor number */ |
| 236 #define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff) | 234 #define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff) |
| 237 | 235 |
| 238 /*!\brief Return the version patch number */ | 236 /*!\brief Return the version patch number */ |
| 239 #define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff) | 237 #define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff) |
| 240 | 238 |
| 241 | 239 |
| 242 /*!\brief Return the version information (as a string) | 240 /*!\brief Return the version information (as a string) |
| 243 * | 241 * |
| 244 * Returns a printable string containing the full library version number. Th
is may | 242 * Returns a printable string containing the full library version number. This
may |
| 245 * contain additional text following the three digit version number, as to i
ndicate | 243 * contain additional text following the three digit version number, as to ind
icate |
| 246 * release candidates, prerelease versions, etc. | 244 * release candidates, prerelease versions, etc. |
| 247 * | 245 * |
| 248 */ | 246 */ |
| 249 const char *vpx_codec_version_str(void); | 247 const char *vpx_codec_version_str(void); |
| 250 | 248 |
| 251 | 249 |
| 252 /*!\brief Return the version information (as a string) | 250 /*!\brief Return the version information (as a string) |
| 253 * | 251 * |
| 254 * Returns a printable "extra string". This is the component of the string r
eturned | 252 * Returns a printable "extra string". This is the component of the string ret
urned |
| 255 * by vpx_codec_version_str() following the three digit version number. | 253 * by vpx_codec_version_str() following the three digit version number. |
| 256 * | 254 * |
| 257 */ | 255 */ |
| 258 const char *vpx_codec_version_extra_str(void); | 256 const char *vpx_codec_version_extra_str(void); |
| 259 | 257 |
| 260 | 258 |
| 261 /*!\brief Return the build configuration | 259 /*!\brief Return the build configuration |
| 262 * | 260 * |
| 263 * Returns a printable string containing an encoded version of the build | 261 * Returns a printable string containing an encoded version of the build |
| 264 * configuration. This may be useful to vpx support. | 262 * configuration. This may be useful to vpx support. |
| 265 * | 263 * |
| 266 */ | 264 */ |
| 267 const char *vpx_codec_build_config(void); | 265 const char *vpx_codec_build_config(void); |
| 268 | 266 |
| 269 | 267 |
| 270 /*!\brief Return the name for a given interface | 268 /*!\brief Return the name for a given interface |
| 271 * | 269 * |
| 272 * Returns a human readable string for name of the given codec interface. | 270 * Returns a human readable string for name of the given codec interface. |
| 273 * | 271 * |
| 274 * \param[in] iface Interface pointer | 272 * \param[in] iface Interface pointer |
| 275 * | 273 * |
| 276 */ | 274 */ |
| 277 const char *vpx_codec_iface_name(vpx_codec_iface_t *iface); | 275 const char *vpx_codec_iface_name(vpx_codec_iface_t *iface); |
| 278 | 276 |
| 279 | 277 |
| 280 /*!\brief Convert error number to printable string | 278 /*!\brief Convert error number to printable string |
| 281 * | 279 * |
| 282 * Returns a human readable string for the last error returned by the | 280 * Returns a human readable string for the last error returned by the |
| 283 * algorithm. The returned error will be one line and will not contain | 281 * algorithm. The returned error will be one line and will not contain |
| 284 * any newline characters. | 282 * any newline characters. |
| 285 * | 283 * |
| 286 * | 284 * |
| 287 * \param[in] err Error number. | 285 * \param[in] err Error number. |
| 288 * | 286 * |
| 289 */ | 287 */ |
| 290 const char *vpx_codec_err_to_string(vpx_codec_err_t err); | 288 const char *vpx_codec_err_to_string(vpx_codec_err_t err); |
| 291 | 289 |
| 292 | 290 |
| 293 /*!\brief Retrieve error synopsis for codec context | 291 /*!\brief Retrieve error synopsis for codec context |
| 294 * | 292 * |
| 295 * Returns a human readable string for the last error returned by the | 293 * Returns a human readable string for the last error returned by the |
| 296 * algorithm. The returned error will be one line and will not contain | 294 * algorithm. The returned error will be one line and will not contain |
| 297 * any newline characters. | 295 * any newline characters. |
| 298 * | 296 * |
| 299 * | 297 * |
| 300 * \param[in] ctx Pointer to this instance's context. | 298 * \param[in] ctx Pointer to this instance's context. |
| 301 * | 299 * |
| 302 */ | 300 */ |
| 303 const char *vpx_codec_error(vpx_codec_ctx_t *ctx); | 301 const char *vpx_codec_error(vpx_codec_ctx_t *ctx); |
| 304 | 302 |
| 305 | 303 |
| 306 /*!\brief Retrieve detailed error information for codec context | 304 /*!\brief Retrieve detailed error information for codec context |
| 307 * | 305 * |
| 308 * Returns a human readable string providing detailed information about | 306 * Returns a human readable string providing detailed information about |
| 309 * the last error. | 307 * the last error. |
| 310 * | 308 * |
| 311 * \param[in] ctx Pointer to this instance's context. | 309 * \param[in] ctx Pointer to this instance's context. |
| 312 * | 310 * |
| 313 * \retval NULL | 311 * \retval NULL |
| 314 * No detailed information is available. | 312 * No detailed information is available. |
| 315 */ | 313 */ |
| 316 const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx); | 314 const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx); |
| 317 | 315 |
| 318 | 316 |
| 319 /* REQUIRED FUNCTIONS | 317 /* REQUIRED FUNCTIONS |
| 320 * | 318 * |
| 321 * The following functions are required to be implemented for all codecs. | 319 * The following functions are required to be implemented for all codecs. |
| 322 * They represent the base case functionality expected of all codecs. | 320 * They represent the base case functionality expected of all codecs. |
| 323 */ | 321 */ |
| 324 | 322 |
| 325 /*!\brief Destroy a codec instance | 323 /*!\brief Destroy a codec instance |
| 326 * | 324 * |
| 327 * Destroys a codec context, freeing any associated memory buffers. | 325 * Destroys a codec context, freeing any associated memory buffers. |
| 328 * | 326 * |
| 329 * \param[in] ctx Pointer to this instance's context | 327 * \param[in] ctx Pointer to this instance's context |
| 330 * | 328 * |
| 331 * \retval #VPX_CODEC_OK | 329 * \retval #VPX_CODEC_OK |
| 332 * The codec algorithm initialized. | 330 * The codec algorithm initialized. |
| 333 * \retval #VPX_CODEC_MEM_ERROR | 331 * \retval #VPX_CODEC_MEM_ERROR |
| 334 * Memory allocation failed. | 332 * Memory allocation failed. |
| 335 */ | 333 */ |
| 336 vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx); | 334 vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx); |
| 337 | 335 |
| 338 | 336 |
| 339 /*!\brief Get the capabilities of an algorithm. | 337 /*!\brief Get the capabilities of an algorithm. |
| 340 * | 338 * |
| 341 * Retrieves the capabilities bitfield from the algorithm's interface. | 339 * Retrieves the capabilities bitfield from the algorithm's interface. |
| 342 * | 340 * |
| 343 * \param[in] iface Pointer to the algorithm interface | 341 * \param[in] iface Pointer to the algorithm interface |
| 344 * | 342 * |
| 345 */ | 343 */ |
| 346 vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface); | 344 vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface); |
| 347 | 345 |
| 348 | 346 |
| 349 /*!\brief Control algorithm | 347 /*!\brief Control algorithm |
| 350 * | 348 * |
| 351 * This function is used to exchange algorithm specific data with the codec | 349 * This function is used to exchange algorithm specific data with the codec |
| 352 * instance. This can be used to implement features specific to a particular | 350 * instance. This can be used to implement features specific to a particular |
| 353 * algorithm. | 351 * algorithm. |
| 354 * | 352 * |
| 355 * This wrapper function dispatches the request to the helper function | 353 * This wrapper function dispatches the request to the helper function |
| 356 * associated with the given ctrl_id. It tries to call this function | 354 * associated with the given ctrl_id. It tries to call this function |
| 357 * transparently, but will return #VPX_CODEC_ERROR if the request could not | 355 * transparently, but will return #VPX_CODEC_ERROR if the request could not |
| 358 * be dispatched. | 356 * be dispatched. |
| 359 * | 357 * |
| 360 * Note that this function should not be used directly. Call the | 358 * Note that this function should not be used directly. Call the |
| 361 * #vpx_codec_control wrapper macro instead. | 359 * #vpx_codec_control wrapper macro instead. |
| 362 * | 360 * |
| 363 * \param[in] ctx Pointer to this instance's context | 361 * \param[in] ctx Pointer to this instance's context |
| 364 * \param[in] ctrl_id Algorithm specific control identifier | 362 * \param[in] ctrl_id Algorithm specific control identifier |
| 365 * | 363 * |
| 366 * \retval #VPX_CODEC_OK | 364 * \retval #VPX_CODEC_OK |
| 367 * The control request was processed. | 365 * The control request was processed. |
| 368 * \retval #VPX_CODEC_ERROR | 366 * \retval #VPX_CODEC_ERROR |
| 369 * The control request was not processed. | 367 * The control request was not processed. |
| 370 * \retval #VPX_CODEC_INVALID_PARAM | 368 * \retval #VPX_CODEC_INVALID_PARAM |
| 371 * The data was not valid. | 369 * The data was not valid. |
| 372 */ | 370 */ |
| 373 vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, | 371 vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, |
| 374 int ctrl_id, | 372 int ctrl_id, |
| 375 ...); | 373 ...); |
| 376 #if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS | 374 #if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS |
| 377 # define vpx_codec_control(ctx,id,data) vpx_codec_control_(ctx,id,data) | 375 # define vpx_codec_control(ctx,id,data) vpx_codec_control_(ctx,id,data) |
| 378 # define VPX_CTRL_USE_TYPE(id, typ) | 376 # define VPX_CTRL_USE_TYPE(id, typ) |
| 379 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) | 377 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) |
| 380 # define VPX_CTRL_VOID(id, typ) | 378 # define VPX_CTRL_VOID(id, typ) |
| 381 | 379 |
| 382 #else | 380 #else |
| 383 /*!\brief vpx_codec_control wrapper macro | 381 /*!\brief vpx_codec_control wrapper macro |
| 384 * | 382 * |
| 385 * This macro allows for type safe conversions across the variadic parameter | 383 * This macro allows for type safe conversions across the variadic parameter |
| 386 * to vpx_codec_control_(). | 384 * to vpx_codec_control_(). |
| 387 * | 385 * |
| 388 * \internal | 386 * \internal |
| 389 * It works by dispatching the call to the control function through a wrappe
r | 387 * It works by dispatching the call to the control function through a wrapper |
| 390 * function named with the id parameter. | 388 * function named with the id parameter. |
| 391 */ | 389 */ |
| 392 # define vpx_codec_control(ctx,id,data) vpx_codec_control_##id(ctx,id,data)\ | 390 # define vpx_codec_control(ctx,id,data) vpx_codec_control_##id(ctx,id,data)\ |
| 393 /**<\hideinitializer*/ | 391 /**<\hideinitializer*/ |
| 394 | 392 |
| 395 | 393 |
| 396 /*!\brief vpx_codec_control type definition macro | 394 /*!\brief vpx_codec_control type definition macro |
| 397 * | 395 * |
| 398 * This macro allows for type safe conversions across the variadic parameter | 396 * This macro allows for type safe conversions across the variadic parameter |
| 399 * to vpx_codec_control_(). It defines the type of the argument for a given | 397 * to vpx_codec_control_(). It defines the type of the argument for a given |
| 400 * control identifier. | 398 * control identifier. |
| 401 * | 399 * |
| 402 * \internal | 400 * \internal |
| 403 * It defines a static function with | 401 * It defines a static function with |
| 404 * the correctly typed arguments as a wrapper to the type-unsafe internal | 402 * the correctly typed arguments as a wrapper to the type-unsafe internal |
| 405 * function. | 403 * function. |
| 406 */ | 404 */ |
| 407 # define VPX_CTRL_USE_TYPE(id, typ) \ | 405 # define VPX_CTRL_USE_TYPE(id, typ) \ |
| 408 static vpx_codec_err_t \ | 406 static vpx_codec_err_t \ |
| 409 vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\ | 407 vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\ |
| 410 \ | 408 \ |
| 411 static vpx_codec_err_t \ | 409 static vpx_codec_err_t \ |
| 412 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\ | 410 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\ |
| 413 return vpx_codec_control_(ctx, ctrl_id, data);\ | 411 return vpx_codec_control_(ctx, ctrl_id, data);\ |
| 414 } /**<\hideinitializer*/ | 412 } /**<\hideinitializer*/ |
| 415 | 413 |
| 416 | 414 |
| 417 /*!\brief vpx_codec_control deprecated type definition macro | 415 /*!\brief vpx_codec_control deprecated type definition macro |
| 418 * | 416 * |
| 419 * Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is | 417 * Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is |
| 420 * deprecated and should not be used. Consult the documentation for your | 418 * deprecated and should not be used. Consult the documentation for your |
| 421 * codec for more information. | 419 * codec for more information. |
| 422 * | 420 * |
| 423 * \internal | 421 * \internal |
| 424 * It defines a static function with the correctly typed arguments as a | 422 * It defines a static function with the correctly typed arguments as a |
| 425 * wrapper to the type-unsafe internal function. | 423 * wrapper to the type-unsafe internal function. |
| 426 */ | 424 */ |
| 427 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \ | 425 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \ |
| 428 DECLSPEC_DEPRECATED static vpx_codec_err_t \ | 426 DECLSPEC_DEPRECATED static vpx_codec_err_t \ |
| 429 vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\ | 427 vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\ |
| 430 \ | 428 \ |
| 431 DECLSPEC_DEPRECATED static vpx_codec_err_t \ | 429 DECLSPEC_DEPRECATED static vpx_codec_err_t \ |
| 432 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\ | 430 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\ |
| 433 return vpx_codec_control_(ctx, ctrl_id, data);\ | 431 return vpx_codec_control_(ctx, ctrl_id, data);\ |
| 434 } /**<\hideinitializer*/ | 432 } /**<\hideinitializer*/ |
| 435 | 433 |
| 436 | 434 |
| 437 /*!\brief vpx_codec_control void type definition macro | 435 /*!\brief vpx_codec_control void type definition macro |
| 438 * | 436 * |
| 439 * This macro allows for type safe conversions across the variadic parameter | 437 * This macro allows for type safe conversions across the variadic parameter |
| 440 * to vpx_codec_control_(). It indicates that a given control identifier tak
es | 438 * to vpx_codec_control_(). It indicates that a given control identifier takes |
| 441 * no argument. | 439 * no argument. |
| 442 * | 440 * |
| 443 * \internal | 441 * \internal |
| 444 * It defines a static function without a data argument as a wrapper to the | 442 * It defines a static function without a data argument as a wrapper to the |
| 445 * type-unsafe internal function. | 443 * type-unsafe internal function. |
| 446 */ | 444 */ |
| 447 # define VPX_CTRL_VOID(id) \ | 445 # define VPX_CTRL_VOID(id) \ |
| 448 static vpx_codec_err_t \ | 446 static vpx_codec_err_t \ |
| 449 vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\ | 447 vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\ |
| 450 \ | 448 \ |
| 451 static vpx_codec_err_t \ | 449 static vpx_codec_err_t \ |
| 452 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\ | 450 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\ |
| 453 return vpx_codec_control_(ctx, ctrl_id);\ | 451 return vpx_codec_control_(ctx, ctrl_id);\ |
| 454 } /**<\hideinitializer*/ | 452 } /**<\hideinitializer*/ |
| 455 | 453 |
| 456 | 454 |
| 457 #endif | 455 #endif |
| 458 | 456 |
| 459 | 457 |
| 460 /*!\defgroup cap_xma External Memory Allocation Functions | 458 /*!\defgroup cap_xma External Memory Allocation Functions |
| 461 * | 459 * |
| 462 * The following functions are required to be implemented for all codecs | 460 * The following functions are required to be implemented for all codecs |
| 463 * that advertise the VPX_CODEC_CAP_XMA capability. Calling these functions | 461 * that advertise the VPX_CODEC_CAP_XMA capability. Calling these functions |
| 464 * for codecs that don't advertise this capability will result in an error | 462 * for codecs that don't advertise this capability will result in an error |
| 465 * code being returned, usually VPX_CODEC_INCAPABLE | 463 * code being returned, usually VPX_CODEC_INCAPABLE |
| 466 * @{ | 464 * @{ |
| 467 */ | 465 */ |
| 468 | 466 |
| 469 | 467 |
| 470 /*!\brief Memory Map Entry | 468 /*!\brief Memory Map Entry |
| 471 * | 469 * |
| 472 * This structure is used to contain the properties of a memory segment. It | 470 * This structure is used to contain the properties of a memory segment. It |
| 473 * is populated by the codec in the request phase, and by the calling | 471 * is populated by the codec in the request phase, and by the calling |
| 474 * application once the requested allocation has been performed. | 472 * application once the requested allocation has been performed. |
| 473 */ |
| 474 typedef struct vpx_codec_mmap { |
| 475 /* |
| 476 * The following members are set by the codec when requesting a segment |
| 475 */ | 477 */ |
| 476 typedef struct vpx_codec_mmap | 478 unsigned int id; /**< identifier for the segment's contents */ |
| 477 { | 479 unsigned long sz; /**< size of the segment, in bytes */ |
| 478 /* | 480 unsigned int align; /**< required alignment of the segment, in bytes */ |
| 479 * The following members are set by the codec when requesting a segment | 481 unsigned int flags; /**< bitfield containing segment properties */ |
| 480 */ | |
| 481 unsigned int id; /**< identifier for the segment's contents */ | |
| 482 unsigned long sz; /**< size of the segment, in bytes */ | |
| 483 unsigned int align; /**< required alignment of the segment, in bytes
*/ | |
| 484 unsigned int flags; /**< bitfield containing segment properties */ | |
| 485 #define VPX_CODEC_MEM_ZERO 0x1 /**< Segment must be zeroed by allocation */ | 482 #define VPX_CODEC_MEM_ZERO 0x1 /**< Segment must be zeroed by allocation */ |
| 486 #define VPX_CODEC_MEM_WRONLY 0x2 /**< Segment need not be readable */ | 483 #define VPX_CODEC_MEM_WRONLY 0x2 /**< Segment need not be readable */ |
| 487 #define VPX_CODEC_MEM_FAST 0x4 /**< Place in fast memory, if available */ | 484 #define VPX_CODEC_MEM_FAST 0x4 /**< Place in fast memory, if available */ |
| 488 | 485 |
| 489 /* The following members are to be filled in by the allocation function
*/ | 486 /* The following members are to be filled in by the allocation function */ |
| 490 void *base; /**< pointer to the allocated segment */ | 487 void *base; /**< pointer to the allocated segment */ |
| 491 void (*dtor)(struct vpx_codec_mmap *map); /**< destructor to cal
l */ | 488 void (*dtor)(struct vpx_codec_mmap *map); /**< destructor to call */ |
| 492 void *priv; /**< allocator private storage */ | 489 void *priv; /**< allocator private storage */ |
| 493 } vpx_codec_mmap_t; /**< alias for struct vpx_codec_mmap */ | 490 } vpx_codec_mmap_t; /**< alias for struct vpx_codec_mmap */ |
| 494 | 491 |
| 495 | 492 |
| 496 /*!\brief Iterate over the list of segments to allocate. | 493 /*!\brief Iterate over the list of segments to allocate. |
| 497 * | 494 * |
| 498 * Iterates over a list of the segments to allocate. The iterator storage | 495 * Iterates over a list of the segments to allocate. The iterator storage |
| 499 * should be initialized to NULL to start the iteration. Iteration is comple
te | 496 * should be initialized to NULL to start the iteration. Iteration is complete |
| 500 * when this function returns VPX_CODEC_LIST_END. The amount of memory neede
d to | 497 * when this function returns VPX_CODEC_LIST_END. The amount of memory needed
to |
| 501 * allocate is dependent upon the size of the encoded stream. In cases where
the | 498 * allocate is dependent upon the size of the encoded stream. In cases where t
he |
| 502 * stream is not available at allocation time, a fixed size must be requeste
d. | 499 * stream is not available at allocation time, a fixed size must be requested. |
| 503 * The codec will not be able to operate on streams larger than the size use
d at | 500 * The codec will not be able to operate on streams larger than the size used
at |
| 504 * allocation time. | 501 * allocation time. |
| 505 * | 502 * |
| 506 * \param[in] ctx Pointer to this instance's context. | 503 * \param[in] ctx Pointer to this instance's context. |
| 507 * \param[out] mmap Pointer to the memory map entry to populate. | 504 * \param[out] mmap Pointer to the memory map entry to populate. |
| 508 * \param[in,out] iter Iterator storage, initialized to NULL | 505 * \param[in,out] iter Iterator storage, initialized to NULL |
| 509 * | 506 * |
| 510 * \retval #VPX_CODEC_OK | 507 * \retval #VPX_CODEC_OK |
| 511 * The memory map entry was populated. | 508 * The memory map entry was populated. |
| 512 * \retval #VPX_CODEC_ERROR | 509 * \retval #VPX_CODEC_ERROR |
| 513 * Codec does not support XMA mode. | 510 * Codec does not support XMA mode. |
| 514 * \retval #VPX_CODEC_MEM_ERROR | 511 * \retval #VPX_CODEC_MEM_ERROR |
| 515 * Unable to determine segment size from stream info. | 512 * Unable to determine segment size from stream info. |
| 516 */ | 513 */ |
| 517 vpx_codec_err_t vpx_codec_get_mem_map(vpx_codec_ctx_t *ctx, | 514 vpx_codec_err_t vpx_codec_get_mem_map(vpx_codec_ctx_t *ctx, |
| 518 vpx_codec_mmap_t *mmap, | 515 vpx_codec_mmap_t *mmap, |
| 519 vpx_codec_iter_t *iter); | 516 vpx_codec_iter_t *iter); |
| 520 | 517 |
| 521 | 518 |
| 522 /*!\brief Identify allocated segments to codec instance | 519 /*!\brief Identify allocated segments to codec instance |
| 523 * | 520 * |
| 524 * Stores a list of allocated segments in the codec. Segments \ref MUST be | 521 * Stores a list of allocated segments in the codec. Segments \ref MUST be |
| 525 * passed in the order they are read from vpx_codec_get_mem_map(), but may b
e | 522 * passed in the order they are read from vpx_codec_get_mem_map(), but may be |
| 526 * passed in groups of any size. Segments \ref MUST be set only once. The | 523 * passed in groups of any size. Segments \ref MUST be set only once. The |
| 527 * allocation function \ref MUST ensure that the vpx_codec_mmap_t::base memb
er | 524 * allocation function \ref MUST ensure that the vpx_codec_mmap_t::base member |
| 528 * is non-NULL. If the segment requires cleanup handling (e.g., calling free
() | 525 * is non-NULL. If the segment requires cleanup handling (e.g., calling free() |
| 529 * or close()) then the vpx_codec_mmap_t::dtor member \ref MUST be populated
. | 526 * or close()) then the vpx_codec_mmap_t::dtor member \ref MUST be populated. |
| 530 * | 527 * |
| 531 * \param[in] ctx Pointer to this instance's context. | 528 * \param[in] ctx Pointer to this instance's context. |
| 532 * \param[in] mmaps Pointer to the first memory map entry in the list
. | 529 * \param[in] mmaps Pointer to the first memory map entry in the list. |
| 533 * \param[in] num_maps Number of entries being set at this time | 530 * \param[in] num_maps Number of entries being set at this time |
| 534 * | 531 * |
| 535 * \retval #VPX_CODEC_OK | 532 * \retval #VPX_CODEC_OK |
| 536 * The segment was stored in the codec context. | 533 * The segment was stored in the codec context. |
| 537 * \retval #VPX_CODEC_INCAPABLE | 534 * \retval #VPX_CODEC_INCAPABLE |
| 538 * Codec does not support XMA mode. | 535 * Codec does not support XMA mode. |
| 539 * \retval #VPX_CODEC_MEM_ERROR | 536 * \retval #VPX_CODEC_MEM_ERROR |
| 540 * Segment base address was not set, or segment was already stored. | 537 * Segment base address was not set, or segment was already stored. |
| 541 | 538 |
| 542 */ | 539 */ |
| 543 vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx, | 540 vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx, |
| 544 vpx_codec_mmap_t *mmaps, | 541 vpx_codec_mmap_t *mmaps, |
| 545 unsigned int num_maps); | 542 unsigned int num_maps); |
| 546 | 543 |
| 547 /*!@} - end defgroup cap_xma*/ | 544 /*!@} - end defgroup cap_xma*/ |
| 548 /*!@} - end defgroup codec*/ | 545 /*!@} - end defgroup codec*/ |
| 549 | 546 |
| 550 | 547 |
| 551 #endif | 548 #endif |
| 552 #ifdef __cplusplus | 549 #ifdef __cplusplus |
| 553 } | 550 } |
| 554 #endif | 551 #endif |
| OLD | NEW |