WebM VP8 Codec SDK
|
00001 /* 00002 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 00003 * 00004 * Use of this source code is governed by a BSD-style license 00005 * that can be found in the LICENSE file in the root of the source 00006 * tree. An additional intellectual property rights grant can be found 00007 * in the file PATENTS. All contributing project authors may 00008 * be found in the AUTHORS file in the root of the source tree. 00009 */ 00010 00011 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 #ifndef VPX_CODEC_H 00044 #define VPX_CODEC_H 00045 #include "vpx_integer.h" 00046 #include "vpx_image.h" 00047 00049 #ifndef DEPRECATED 00050 #if defined(__GNUC__) && __GNUC__ 00051 #define DEPRECATED __attribute__ ((deprecated)) 00052 #elif defined(_MSC_VER) 00053 #define DEPRECATED 00054 #else 00055 #define DEPRECATED 00056 #endif 00057 #endif /* DEPRECATED */ 00058 00059 #ifndef DECLSPEC_DEPRECATED 00060 #if defined(__GNUC__) && __GNUC__ 00061 #define DECLSPEC_DEPRECATED 00062 #elif defined(_MSC_VER) 00063 #define DECLSPEC_DEPRECATED __declspec(deprecated) 00064 #else 00065 #define DECLSPEC_DEPRECATED 00066 #endif 00067 #endif /* DECLSPEC_DEPRECATED */ 00068 00070 #ifdef UNUSED 00071 #elif __GNUC__ 00072 #define UNUSED __attribute__ ((unused)) 00073 #else 00074 #define UNUSED 00075 #endif 00076 00085 #define VPX_CODEC_ABI_VERSION (2 + VPX_IMAGE_ABI_VERSION) 00088 typedef enum { 00089 00090 VPX_CODEC_OK, 00091 00093 VPX_CODEC_ERROR, 00094 00096 VPX_CODEC_MEM_ERROR, 00097 00099 VPX_CODEC_ABI_MISMATCH, 00100 00102 VPX_CODEC_INCAPABLE, 00103 00109 VPX_CODEC_UNSUP_BITSTREAM, 00110 00118 VPX_CODEC_UNSUP_FEATURE, 00119 00128 VPX_CODEC_CORRUPT_FRAME, 00129 00133 VPX_CODEC_INVALID_PARAM, 00134 00138 VPX_CODEC_LIST_END 00139 00140 } 00141 vpx_codec_err_t; 00142 00143 00152 typedef long vpx_codec_caps_t; 00153 #define VPX_CODEC_CAP_DECODER 0x1 00154 #define VPX_CODEC_CAP_ENCODER 0x2 00155 #define VPX_CODEC_CAP_XMA 0x4 00165 typedef long vpx_codec_flags_t; 00166 #define VPX_CODEC_USE_XMA 0x00000001 00174 typedef const struct vpx_codec_iface vpx_codec_iface_t; 00175 00176 00182 typedef struct vpx_codec_priv vpx_codec_priv_t; 00183 00184 00189 typedef const void *vpx_codec_iter_t; 00190 00191 00200 typedef struct vpx_codec_ctx { 00201 const char *name; 00202 vpx_codec_iface_t *iface; 00203 vpx_codec_err_t err; 00204 const char *err_detail; 00205 vpx_codec_flags_t init_flags; 00206 union { 00207 struct vpx_codec_dec_cfg *dec; 00208 struct vpx_codec_enc_cfg *enc; 00209 void *raw; 00210 } config; 00211 vpx_codec_priv_t *priv; 00212 } vpx_codec_ctx_t; 00213 00214 00215 /* 00216 * Library Version Number Interface 00217 * 00218 * For example, see the following sample return values: 00219 * vpx_codec_version() (1<<16 | 2<<8 | 3) 00220 * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba" 00221 * vpx_codec_version_extra_str() "rc1-16-gec6a1ba" 00222 */ 00223 00232 int vpx_codec_version(void); 00233 #define VPX_VERSION_MAJOR(v) ((v>>16)&0xff) 00234 #define VPX_VERSION_MINOR(v) ((v>>8)&0xff) 00235 #define VPX_VERSION_PATCH(v) ((v>>0)&0xff) 00238 #define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff) 00239 00241 #define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff) 00242 00244 #define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff) 00245 00246 00254 const char *vpx_codec_version_str(void); 00255 00256 00263 const char *vpx_codec_version_extra_str(void); 00264 00265 00272 const char *vpx_codec_build_config(void); 00273 00274 00282 const char *vpx_codec_iface_name(vpx_codec_iface_t *iface); 00283 00284 00295 const char *vpx_codec_err_to_string(vpx_codec_err_t err); 00296 00297 00308 const char *vpx_codec_error(vpx_codec_ctx_t *ctx); 00309 00310 00321 const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx); 00322 00323 00324 /* REQUIRED FUNCTIONS 00325 * 00326 * The following functions are required to be implemented for all codecs. 00327 * They represent the base case functionality expected of all codecs. 00328 */ 00329 00341 vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx); 00342 00343 00351 vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface); 00352 00353 00378 vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, 00379 int ctrl_id, 00380 ...); 00381 #if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS 00382 # define vpx_codec_control(ctx,id,data) vpx_codec_control_(ctx,id,data) 00383 # define VPX_CTRL_USE_TYPE(id, typ) 00384 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) 00385 # define VPX_CTRL_VOID(id, typ) 00386 00387 #else 00388 00397 # define vpx_codec_control(ctx,id,data) vpx_codec_control_##id(ctx,id,data)\ 00398 00412 # define VPX_CTRL_USE_TYPE(id, typ) \ 00413 static vpx_codec_err_t \ 00414 vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\ 00415 \ 00416 static vpx_codec_err_t \ 00417 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\ 00418 return vpx_codec_control_(ctx, ctrl_id, data);\ 00419 } 00432 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \ 00433 DECLSPEC_DEPRECATED static vpx_codec_err_t \ 00434 vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\ 00435 \ 00436 DECLSPEC_DEPRECATED static vpx_codec_err_t \ 00437 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\ 00438 return vpx_codec_control_(ctx, ctrl_id, data);\ 00439 } 00452 # define VPX_CTRL_VOID(id) \ 00453 static vpx_codec_err_t \ 00454 vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\ 00455 \ 00456 static vpx_codec_err_t \ 00457 vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\ 00458 return vpx_codec_control_(ctx, ctrl_id);\ 00459 } 00462 #endif 00463 00464 00481 typedef struct vpx_codec_mmap { 00482 /* 00483 * The following members are set by the codec when requesting a segment 00484 */ 00485 unsigned int id; 00486 unsigned long sz; 00487 unsigned int align; 00488 unsigned int flags; 00489 #define VPX_CODEC_MEM_ZERO 0x1 00490 #define VPX_CODEC_MEM_WRONLY 0x2 00491 #define VPX_CODEC_MEM_FAST 0x4 00493 /* The following members are to be filled in by the allocation function */ 00494 void *base; 00495 void (*dtor)(struct vpx_codec_mmap *map); 00496 void *priv; 00497 } vpx_codec_mmap_t; 00521 vpx_codec_err_t vpx_codec_get_mem_map(vpx_codec_ctx_t *ctx, 00522 vpx_codec_mmap_t *mmap, 00523 vpx_codec_iter_t *iter); 00524 00525 00547 vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx, 00548 vpx_codec_mmap_t *mmaps, 00549 unsigned int num_maps); 00550 00555 #endif 00556 #ifdef __cplusplus 00557 } 00558 #endif