From fa7a55bb043a6abfc661a8d06a2611b54372fe1c Mon Sep 17 00:00:00 2001 From: John Koleszar Date: Tue, 21 Sep 2010 10:35:52 -0400 Subject: [PATCH] Add getter functions for the interface data symbols 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 | 1 + vp8/exports_enc | 1 + vp8/vp8_cx_iface.c | 2 +- vp8/vp8_dx_iface.c | 2 +- vpx/internal/vpx_codec_internal.h | 14 ++++++++++++++ vpx/vp8cx.h | 3 ++- vpx/vp8dx.h | 3 ++- 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/vp8/exports_dec b/vp8/exports_dec index f9b985c86..100ac5c27 100644 --- a/vp8/exports_dec +++ b/vp8/exports_dec @@ -1 +1,2 @@ data vpx_codec_vp8_dx_algo +text vpx_codec_vp8_dx diff --git a/vp8/exports_enc b/vp8/exports_enc index 996701113..29ff35ef7 100644 --- a/vp8/exports_enc +++ b/vp8/exports_enc @@ -1 +1,2 @@ data vpx_codec_vp8_cx_algo +text vpx_codec_vp8_cx diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c index e3f99c08d..f8a4de85b 100644 --- a/vp8/vp8_cx_iface.c +++ b/vp8/vp8_cx_iface.c @@ -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, diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c index e7e535638..f19cb9a30 100644 --- a/vp8/vp8_dx_iface.c +++ b/vp8/vp8_dx_iface.c @@ -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, diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h index ab4cad10c..dcb451dca 100644 --- a/vpx/internal/vpx_codec_internal.h +++ b/vpx/internal/vpx_codec_internal.h @@ -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 diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h index e1c821144..efd79459a 100644 --- a/vpx/vp8cx.h +++ b/vpx/vp8cx.h @@ -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); /* diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h index 4cad838ff..fccd407f3 100644 --- a/vpx/vp8dx.h +++ b/vpx/vp8dx.h @@ -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" -- 2.40.0