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 #define DECLSPEC_DEPRECATED
53 #elif defined(_MSC_VER)
54 #define DEPRECATED
55 #define DECLSPEC_DEPRECATED __declspec(deprecated)
56 #else
57 #define DEPRECATED
58 #define DECLSPEC_DEPRECATED
59 #endif
60 #endif
61 
63 #ifdef UNUSED
64 #elif __GNUC__
65 #define UNUSED __attribute__ ((unused))
66 #else
67 #define UNUSED
68 #endif
69 
78 #define VPX_CODEC_ABI_VERSION (2 + VPX_IMAGE_ABI_VERSION)
81  typedef enum {
82 
84 
87 
90 
93 
96 
103 
112 
122 
127 
132 
133  }
135 
136 
145  typedef long vpx_codec_caps_t;
146 #define VPX_CODEC_CAP_DECODER 0x1
147 #define VPX_CODEC_CAP_ENCODER 0x2
148 #define VPX_CODEC_CAP_XMA 0x4
158  typedef long vpx_codec_flags_t;
159 #define VPX_CODEC_USE_XMA 0x00000001
167  typedef const struct vpx_codec_iface vpx_codec_iface_t;
168 
169 
175  typedef struct vpx_codec_priv vpx_codec_priv_t;
176 
177 
182  typedef const void *vpx_codec_iter_t;
183 
184 
193  typedef struct vpx_codec_ctx
194  {
195  const char *name;
198  const char *err_detail;
200  union
201  {
204  void *raw;
205  } config;
207  } vpx_codec_ctx_t;
208 
209 
210  /*
211  * Library Version Number Interface
212  *
213  * For example, see the following sample return values:
214  * vpx_codec_version() (1<<16 | 2<<8 | 3)
215  * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
216  * vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
217  */
218 
227  int vpx_codec_version(void);
228 #define VPX_VERSION_MAJOR(v) ((v>>16)&0xff)
229 #define VPX_VERSION_MINOR(v) ((v>>8)&0xff)
230 #define VPX_VERSION_PATCH(v) ((v>>0)&0xff)
233 #define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff)
234 
236 #define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff)
237 
239 #define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff)
240 
241 
249  const char *vpx_codec_version_str(void);
250 
251 
258  const char *vpx_codec_version_extra_str(void);
259 
260 
267  const char *vpx_codec_build_config(void);
268 
269 
277  const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
278 
279 
290  const char *vpx_codec_err_to_string(vpx_codec_err_t err);
291 
292 
303  const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
304 
305 
316  const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
317 
318 
319  /* REQUIRED FUNCTIONS
320  *
321  * The following functions are required to be implemented for all codecs.
322  * They represent the base case functionality expected of all codecs.
323  */
324 
337 
338 
347 
348 
374  int ctrl_id,
375  ...);
376 #if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
377 # define vpx_codec_control(ctx,id,data) vpx_codec_control_(ctx,id,data)
378 # define VPX_CTRL_USE_TYPE(id, typ)
379 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
380 # define VPX_CTRL_VOID(id, typ)
381 
382 #else
383 
392 # define vpx_codec_control(ctx,id,data) vpx_codec_control_##id(ctx,id,data)\
393 
407 # define VPX_CTRL_USE_TYPE(id, typ) \
408  static vpx_codec_err_t \
409  vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\
410  \
411  static vpx_codec_err_t \
412  vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
413  return vpx_codec_control_(ctx, ctrl_id, data);\
414  }
427 # define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
428  DECLSPEC_DEPRECATED static vpx_codec_err_t \
429  vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\
430  \
431  DECLSPEC_DEPRECATED static vpx_codec_err_t \
432  vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
433  return vpx_codec_control_(ctx, ctrl_id, data);\
434  }
447 # define VPX_CTRL_VOID(id) \
448  static vpx_codec_err_t \
449  vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\
450  \
451  static vpx_codec_err_t \
452  vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\
453  return vpx_codec_control_(ctx, ctrl_id);\
454  }
457 #endif
458 
459 
476  typedef struct vpx_codec_mmap
477  {
478  /*
479  * The following members are set by the codec when requesting a segment
480  */
481  unsigned int id;
482  unsigned long sz;
483  unsigned int align;
484  unsigned int flags;
485 #define VPX_CODEC_MEM_ZERO 0x1
486 #define VPX_CODEC_MEM_WRONLY 0x2
487 #define VPX_CODEC_MEM_FAST 0x4
489  /* The following members are to be filled in by the allocation function */
490  void *base;
491  void (*dtor)(struct vpx_codec_mmap *map);
492  void *priv;
493  } vpx_codec_mmap_t;
518  vpx_codec_mmap_t *mmap,
519  vpx_codec_iter_t *iter);
520 
521 
544  vpx_codec_mmap_t *mmaps,
545  unsigned int num_maps);
546 
551 #endif
552 #ifdef __cplusplus
553 }
554 #endif