shithub: libvpx

Download patch

ref: 1b16e74813f052c457f836795013826a3292999e
parent: 6f6856839b52c65e3b4b2c82d6b81a2b9bd92337
author: Jim Bankoski <jimbankoski@google.com>
date: Mon Jul 23 08:32:59 EDT 2012

Dll build of libvpx

Change-Id: I74e50b4dfbe73eb98e1dce1695a9973f637220c0

--- a/build/make/gen_msvs_proj.sh
+++ b/build/make/gen_msvs_proj.sh
@@ -26,6 +26,7 @@
     --help                      Print this message
     --exe                       Generate a project for building an Application
     --lib                       Generate a project for creating a static library
+    --dll                       Generate a project for creating a dll
     --static-crt                Use the static C runtime (/MT)
     --target=isa-os-cc          Target specifier (required)
     --out=filename              Write output to a file [stdout]
@@ -190,6 +191,8 @@
         ;;
         --exe) proj_kind="exe"
         ;;
+        --dll) proj_kind="dll"
+        ;;
         --lib) proj_kind="lib"
         ;;
         --src-path-bare=*) src_path_bare="$optval"
@@ -298,6 +301,8 @@
 generate_vcproj() {
     case "$proj_kind" in
         exe) vs_ConfigurationType=1
+        ;;
+        dll) vs_ConfigurationType=2
         ;;
         *)   vs_ConfigurationType=4
         ;;
--- a/configure
+++ b/configure
@@ -457,7 +457,7 @@
         # Can only build shared libs on a subset of platforms. Doing this check
         # here rather than at option parse time because the target auto-detect
         # magic happens after the command line has been parsed.
-        enabled linux || die "--enable-shared only supported on ELF for now"
+        enabled linux || enabled win32 || enabled win64 || die "--enable-shared only supported on ELF for now"
     fi
     if [ -z "$CC" ]; then
         echo "Bypassing toolchain for environment detection."
--- a/examples.mk
+++ b/examples.mk
@@ -192,7 +192,7 @@
 
 # Set up additional MSVS environment
 ifeq ($(CONFIG_MSVS),yes)
-CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
+CODEC_LIB=$(if $(CONFIG_SHARED),vpx,$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd))
 # This variable uses deferred expansion intentionally, since the results of
 # $(wildcard) may change during the course of the Make.
 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
--- a/libs.mk
+++ b/libs.mk
@@ -172,8 +172,8 @@
 vpx.vcproj: $(CODEC_SRCS) vpx.def
 	@echo "    [CREATE] $@"
 	$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
-			--lib \
-			--target=$(TOOLCHAIN) \
+            $(if $(CONFIG_SHARED),--dll,--lib) \
+            --target=$(TOOLCHAIN) \
             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
             --name=vpx \
             --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
--- a/vp8/exports_enc
+++ b/vp8/exports_enc
@@ -1,2 +1,5 @@
 data vpx_codec_vp8_cx_algo
 text vpx_codec_vp8_cx
+data vpx_codec_vp8x_cx_algo
+text vpx_codec_vp8x_cx
+
--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -1058,7 +1058,8 @@
 
 
 #if CONFIG_EXPERIMENTAL
-vpx_codec_iface_t vpx_codec_vp8x_cx_algo = {
+
+CODEC_INTERFACE(vpx_codec_vp8x_cx) = {
   "VP8 Experimental Encoder" VERSION_STRING,
   VPX_CODEC_INTERNAL_ABI_VERSION,
   VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR,
--- a/vpx/vp8cx.h
+++ b/vpx/vp8cx.h
@@ -42,6 +42,7 @@
  * VP8 variant, which is bitstream incompatible with the default VP8 encoder.
  */
 extern vpx_codec_iface_t vpx_codec_vp8x_cx_algo;
+extern vpx_codec_iface_t *vpx_codec_vp8x_cx(void);
 #endif
 
 
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -49,17 +49,19 @@
 static const char *exec_name;
 
 #define VP8_FOURCC (0x00385056)
+
 static const struct {
-  char const *name;
-  const vpx_codec_iface_t *iface;
-  unsigned int             fourcc;
-  unsigned int             fourcc_mask;
+   char const *name;
+   const vpx_codec_iface_t *(*iface)(void);
+   unsigned int             fourcc;
+   unsigned int             fourcc_mask;
 } ifaces[] = {
 #if CONFIG_VP8_DECODER
-  {"vp8",  &vpx_codec_vp8_dx_algo,   VP8_FOURCC, 0x00FFFFFF},
+  {"vp8",  vpx_codec_vp8_dx,   VP8_FOURCC, 0x00FFFFFF},
 #endif
 };
 
+
 #include "args.h"
 static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1,
                                           "Codec to use");
@@ -154,7 +156,7 @@
   for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
     fprintf(stderr, "    %-6s - %s\n",
             ifaces[i].name,
-            vpx_codec_iface_name(ifaces[i].iface));
+            vpx_codec_iface_name(ifaces[i].iface()));
 
   exit(EXIT_FAILURE);
 }
@@ -409,7 +411,7 @@
 
     if (mem_get_le32(buf) < 256 * 1024 * 1024)
       for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
-        if (!vpx_codec_peek_stream_info(ifaces[i].iface,
+        if (!vpx_codec_peek_stream_info(ifaces[i].iface(),
                                         buf + 4, 32 - 4, &si)) {
           is_raw = 1;
           *fourcc = ifaces[i].fourcc;
@@ -706,7 +708,7 @@
           k = j;
 
       if (k >= 0)
-        iface = ifaces[k].iface;
+        iface = ifaces[k].iface();
       else
         die("Error: Unrecognized argument (%s) to --codec\n",
             arg.val);
@@ -881,7 +883,7 @@
   /* Try to determine the codec from the fourcc. */
   for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
     if ((fourcc & ifaces[i].fourcc_mask) == ifaces[i].fourcc) {
-      vpx_codec_iface_t  *ivf_iface = ifaces[i].iface;
+      vpx_codec_iface_t  *ivf_iface = ifaces[i].iface();
 
       if (iface && iface != ivf_iface)
         fprintf(stderr, "Notice -- IVF header indicates codec: %s\n",
@@ -893,7 +895,7 @@
     }
 
   dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0);
-  if (vpx_codec_dec_init(&decoder, iface ? iface :  ifaces[0].iface, &cfg,
+  if (vpx_codec_dec_init(&decoder, iface ? iface :  ifaces[0].iface(), &cfg,
                          dec_flags)) {
     fprintf(stderr, "Failed to initialize decoder: %s\n", vpx_codec_error(&decoder));
     return EXIT_FAILURE;
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -72,32 +72,32 @@
 
 static const char *exec_name;
 
-static const struct codec_item {
-  char const              *name;
-  const vpx_codec_iface_t *iface;
-  unsigned int             fourcc;
-} codecs[] = {
-#if CONFIG_EXPERIMENTAL && CONFIG_VP8_ENCODER
-  {"vp8x",  &vpx_codec_vp8x_cx_algo, 0x78385056},
-#endif
-#if CONFIG_VP8_ENCODER
-  {"vp8",  &vpx_codec_vp8_cx_algo, 0x30385056},
-#endif
-};
 
-#define VP8_FOURCC (0x00385056)
+
+#define VP8_FOURCC (0x78385056)
 static const struct {
   char const *name;
-  const vpx_codec_iface_t *iface;
+  const vpx_codec_iface_t *(*iface)(void);
   unsigned int             fourcc;
   unsigned int             fourcc_mask;
 } ifaces[] = {
 #if CONFIG_VP8_DECODER
-  {"vp8",  &vpx_codec_vp8_dx_algo,   VP8_FOURCC, 0x00FFFFFF},
+  {"vp8",  &vpx_codec_vp8_dx,   VP8_FOURCC, 0x00FFFFFF},
 #endif
 };
 
+static const struct codec_item {
+  char const *name;
+  const vpx_codec_iface_t *(*iface)(void);
+  unsigned int             fourcc;
+  unsigned int             fourcc_mask;
+} codecs[] = {
+#if CONFIG_VP8_ENCODER
+  {"vp8",  vpx_codec_vp8x_cx,   VP8_FOURCC, 0x00FFFFFF},
+#endif
+};
 
+
 static void usage_exit();
 
 void die(const char *fmt, ...) {
@@ -1094,7 +1094,7 @@
   for (i = 0; i < sizeof(codecs) / sizeof(codecs[0]); i++)
     fprintf(stderr, "    %-6s - %s\n",
             codecs[i].name,
-            vpx_codec_iface_name(codecs[i].iface));
+            vpx_codec_iface_name(codecs[i].iface()));
 
   exit(EXIT_FAILURE);
 }
@@ -1407,7 +1407,7 @@
   int                    pass, one_pass_only = 0;
   stats_io_t             stats;
   vpx_image_t            raw;
-  const struct codec_item  *codec = codecs;
+  struct codec_item  *codec = codecs;
   int                    frame_avail, got_data;
 
   struct arg               arg;
@@ -1543,7 +1543,7 @@
   }
 
   /* Populate encoder configuration */
-  res = vpx_codec_enc_config_default(codec->iface, &cfg, arg_usage);
+  res = vpx_codec_enc_config_default(codec->iface(), &cfg, arg_usage);
 
   if (res) {
     fprintf(stderr, "Failed to get config: %s\n",
@@ -1660,11 +1660,7 @@
   /* Handle codec specific options */
 #if CONFIG_VP8_ENCODER
 
-  if (codec->iface == &vpx_codec_vp8_cx_algo
-#if CONFIG_EXPERIMENTAL
-      || codec->iface == &vpx_codec_vp8x_cx_algo
-#endif
-     ) {
+  if (codec->fourcc == VP8_FOURCC) {
     ctrl_args = vp8_args;
     ctrl_args_map = vp8_arg_ctrl_map;
   }
@@ -1775,7 +1771,7 @@
 #define SHOW(field) fprintf(stderr, "    %-28s = %d\n", #field, cfg.field)
 
     if (verbose && pass == 0) {
-      fprintf(stderr, "Codec: %s\n", vpx_codec_iface_name(codec->iface));
+      fprintf(stderr, "Codec: %s\n", vpx_codec_iface_name(codec->iface()));
       fprintf(stderr, "Source file: %s Format: %s\n", in_fn,
               arg_use_i420 ? "I420" : "YV12");
       fprintf(stderr, "Destination file: %s\n", out_fn);
@@ -1885,12 +1881,12 @@
 
 
     /* Construct Encoder Context */
-    vpx_codec_enc_init(&encoder, codec->iface, &cfg,
+    vpx_codec_enc_init(&encoder, codec->iface(), &cfg,
                        show_psnr ? VPX_CODEC_USE_PSNR : 0);
     ctx_exit_on_error(&encoder, "Failed to initialize encoder");
 
     if (test_decode &&
-        vpx_codec_dec_init(&decoder, ifaces[0].iface, &dec_cfg, 0)) {
+        vpx_codec_dec_init(&decoder, ifaces[0].iface(), &dec_cfg, 0)) {
       fprintf(stderr,
               "Failed to initialize decoder: %s\n",
               vpx_codec_error(&decoder));
--