]> granicus.if.org Git - libvpx/commitdiff
Add getter functions for the interface data symbols
authorJohn Koleszar <jkoleszar@google.com>
Tue, 21 Sep 2010 14:35:52 +0000 (10:35 -0400)
committerJohn Koleszar <jkoleszar@google.com>
Thu, 23 Sep 2010 18:58:43 +0000 (14:58 -0400)
Having these symbols be available as functions rather than data is
occasionally more convenient. Implemented this way rather than a
get-codec-by-id style to avoid creating a link-time dependency
between the encoder and the decoder.

Fixes issue #169

Change-Id: I319f281277033a5e7e3ee3b092b9a87cce2f463d

vp8/exports_dec
vp8/exports_enc
vp8/vp8_cx_iface.c
vp8/vp8_dx_iface.c
vpx/internal/vpx_codec_internal.h
vpx/vp8cx.h
vpx/vp8dx.h

index f9b985c8646f89d27668a0b28a9f8b2a304a8f3e..100ac5c27dcd537cff77b51d00c96c29e32ad6b6 100644 (file)
@@ -1 +1,2 @@
 data vpx_codec_vp8_dx_algo
+text vpx_codec_vp8_dx
index 99670111338c16a9231eecc9f62ef415f7f568c2..29ff35ef7bd5ddac5301d8e110d3513c235bd8e6 100644 (file)
@@ -1 +1,2 @@
 data vpx_codec_vp8_cx_algo
+text vpx_codec_vp8_cx
index e3f99c08dd8879de2221eb9581d4906236c07f90..f8a4de85be01781db00bc929631fcc92543b3a8d 100644 (file)
@@ -1079,7 +1079,7 @@ static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] =
 #ifndef VERSION_STRING
 #define VERSION_STRING
 #endif
-vpx_codec_iface_t vpx_codec_vp8_cx_algo =
+CODEC_INTERFACE(vpx_codec_vp8_cx) =
 {
     "WebM Project VP8 Encoder" VERSION_STRING,
     VPX_CODEC_INTERNAL_ABI_VERSION,
index e7e535638819c837ea9d6b997ef8b9e51f1e012d..f19cb9a30d68c9a24bacdc994a9d0da879ac0714 100644 (file)
@@ -653,7 +653,7 @@ vpx_codec_ctrl_fn_map_t vp8_ctf_maps[] =
 #ifndef VERSION_STRING
 #define VERSION_STRING
 #endif
-vpx_codec_iface_t vpx_codec_vp8_dx_algo =
+CODEC_INTERFACE(vpx_codec_vp8_dx) =
 {
     "WebM Project VP8 Decoder" VERSION_STRING,
     VPX_CODEC_INTERNAL_ABI_VERSION,
index ab4cad10c7294fae6b4d7adbc24cabbb796edf0a..dcb451dca17fe055031b5ddfff620c70743f3263 100644 (file)
@@ -389,6 +389,20 @@ struct vpx_codec_priv
 #define RECAST(id, x) id##__convert(x)
 
 
+/* CODEC_INTERFACE convenience macro
+ *
+ * By convention, each codec interface is a struct with extern linkage, where
+ * the symbol is suffixed with _algo. A getter function is also defined to
+ * return a pointer to the struct, since in some cases it's easier to work
+ * with text symbols than data symbols (see issue #169). This function has
+ * the same name as the struct, less the _algo suffix. The CODEC_INTERFACE
+ * macro is provided to define this getter function automatically.
+ */
+#define CODEC_INTERFACE(id)\
+vpx_codec_iface_t* id(void) { return &id##_algo; }\
+vpx_codec_iface_t  id##_algo
+
+
 /* Internal Utility Functions
  *
  * The following functions are indended to be used inside algorithms as
index e1c82114428c4d7985c0c7e8dfda8150b7daa423..efd79459aeb152fc32d04ce77af5951c094e0ee5 100644 (file)
@@ -29,7 +29,8 @@
  * This interface provides the capability to encode raw VP8 streams, as would
  * be found in AVI files.
  */
-extern vpx_codec_iface_t vpx_codec_vp8_cx_algo;
+extern vpx_codec_iface_t  vpx_codec_vp8_cx_algo;
+extern vpx_codec_iface_t* vpx_codec_vp8_cx(void);
 
 
 /*
index 4cad838ffbe71534f1968abb2ebb4728524aa789..fccd407f33d54bca8faaf2e99a8a36679a631015 100644 (file)
@@ -29,7 +29,8 @@
  * This interface provides the capability to decode raw VP8 streams, as would
  * be found in AVI files and other non-Flash uses.
  */
-extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
+extern vpx_codec_iface_t  vpx_codec_vp8_dx_algo;
+extern vpx_codec_iface_t* vpx_codec_vp8_dx(void);
 
 /* Include controls common to both the encoder and decoder */
 #include "vp8.h"