WebM VP8 Codec SDK
vpx_codec.h
Go to the documentation of this file.
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 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #ifndef VPX_CODEC_H
44 #define VPX_CODEC_H
45 #include "vpx_integer.h"
46 #include "vpx_image.h"
47 
49 #ifndef DEPRECATED
50 #if defined(__GNUC__) && __GNUC__
51 #define DEPRECATED __attribute__ ((deprecated))
52 #elif defined(_MSC_VER)
53 #define DEPRECATED
54 #else
55 #define DEPRECATED
56 #endif
57 #endif /* DEPRECATED */
58 
59 #ifndef DECLSPEC_DEPRECATED
60 #if defined(__GNUC__) && __GNUC__
61 #define DECLSPEC_DEPRECATED
62 #elif defined(_MSC_VER)
63 #define DECLSPEC_DEPRECATED __declspec(deprecated)
64 #else
65 #define DECLSPEC_DEPRECATED
66 #endif
67 #endif /* DECLSPEC_DEPRECATED */
68 
70 #ifdef UNUSED
71 #elif __GNUC__
72 #define UNUSED __attribute__ ((unused))
73 #else
74 #define UNUSED
75 #endif
76 
85 #define VPX_CODEC_ABI_VERSION (2 + VPX_IMAGE_ABI_VERSION)
88  typedef enum {
89 
91 
94 
97 
100 
103 
110 
119 
129 
134 
139 
140  }
142 
143 
152  typedef long vpx_codec_caps_t;
153 #define VPX_CODEC_CAP_DECODER 0x1
154 #define VPX_CODEC_CAP_ENCODER 0x2
155 #define VPX_CODEC_CAP_XMA 0x4
165  typedef long vpx_codec_flags_t;
166 #define VPX_CODEC_USE_XMA 0x00000001
174  typedef const struct vpx_codec_iface vpx_codec_iface_t;
175 
176 
182  typedef struct vpx_codec_priv vpx_codec_priv_t;
183 
184 
189  typedef const void *vpx_codec_iter_t;
190 
191 
200  typedef struct vpx_codec_ctx
201  {
202  const char *name;
205  const char *err_detail;
207  union
208  {
211  void *raw;
212  } config;
214  } vpx_codec_ctx_t;
215 
216 
217  /*
218  * Library Version Number Interface
219  *
220  * For example, see the following sample return values:
221  * vpx_codec_version() (1<<16 | 2<<8 | 3)
222  * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
223  * vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
224  */
225 
234  int vpx_codec_version(void);
235 #define VPX_VERSION_MAJOR(v) ((v>>16)&0xff)
236 #define VPX_VERSION_MINOR(v) ((v>>8)&0xff)
237 #define VPX_VERSION_PATCH(v) ((v>>0)&0xff)
240 #define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff)
241 
243 #define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff)
244 
246 #define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff)
247 
248 
256  const char *vpx_codec_version_str(void);
257 
258 
265  const char *vpx_codec_version_extra_str(void);
266 
267 
274  const char *vpx_codec_build_config(void);
275 
276 
284  const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
285 
286 
297  const char *vpx_codec_err_to_string(vpx_codec_err_t err);
298 
299 
310  const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
311 
312 
323  const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
324 
325 
326  /* REQUIRED FUNCTIONS
327  *
328  * The following functions are required to be implemented for all codecs.
329  * They represent the base case functionality expected of all codecs.
330  */
331 
344 
345 
354 
355 
381  int ctrl_id,
382  ...);
383 #if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
384 # define vpx_codec_control(ctx,id,data) vpx_codec_control_(ctx,id,data)
385 # define VPX_CTRL_USE_TYPE(id, typ)
386 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
387 # define VPX_CTRL_VOID(id, typ)
388 
389 #else
390 
399 # define vpx_codec_control(ctx,id,data) vpx_codec_control_##id(ctx,id,data)\
400 
414 # define VPX_CTRL_USE_TYPE(id, typ) \
415  static vpx_codec_err_t \
416  vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\
417  \
418  static vpx_codec_err_t \
419  vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
420  return vpx_codec_control_(ctx, ctrl_id, data);\
421  }
434 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
435  DECLSPEC_DEPRECATED static vpx_codec_err_t \
436  vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\
437  \
438  DECLSPEC_DEPRECATED static vpx_codec_err_t \
439  vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
440  return vpx_codec_control_(ctx, ctrl_id, data);\
441  }
454 # define VPX_CTRL_VOID(id) \
455  static vpx_codec_err_t \
456  vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\
457  \
458  static vpx_codec_err_t \
459  vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\
460  return vpx_codec_control_(ctx, ctrl_id);\
461  }
464 #endif
465 
466 
483  typedef struct vpx_codec_mmap
484  {
485  /*
486  * The following members are set by the codec when requesting a segment
487  */
488  unsigned int id;
489  unsigned long sz;
490  unsigned int align;
491  unsigned int flags;
492 #define VPX_CODEC_MEM_ZERO 0x1
493 #define VPX_CODEC_MEM_WRONLY 0x2
494 #define VPX_CODEC_MEM_FAST 0x4
496  /* The following members are to be filled in by the allocation function */
497  void *base;
498  void (*dtor)(struct vpx_codec_mmap *map);
499  void *priv;
500  } vpx_codec_mmap_t;
525  vpx_codec_mmap_t *mmap,
526  vpx_codec_iter_t *iter);
527 
528 
551  vpx_codec_mmap_t *mmaps,
552  unsigned int num_maps);
553 
558 #endif
559 #ifdef __cplusplus
560 }
561 #endif