x264: Initialize function vtable in plugin_init()
authorNirbheek Chauhan <nirbheek@centricular.com>
Tue, 31 Jan 2017 21:38:10 +0000 (03:08 +0530)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 1 Feb 2017 10:38:01 +0000 (12:38 +0200)
These values are defined in the x264.h header and are not const on
Windows due to the way DLLs work. See:
https://msdn.microsoft.com/en-us/library/619w14ds.aspx
https://msdn.microsoft.com/en-us/library/zw3za17w.aspx

https://bugzilla.gnome.org/show_bug.cgi?id=777903

ext/x264/gstx264enc.c

index f5d8f9f64573190713b13cf0c4dd19917b2c30f9..49d99f15b4a7a4dadfcaddfd87bf11349d0b3f2a 100644 (file)
@@ -137,16 +137,7 @@ struct _GstX264EncVTable
   int (*x264_param_parse) (x264_param_t *, const char *name, const char *value);
 };
 
-static GstX264EncVTable default_vtable = {
-  NULL,
-  &x264_bit_depth,
-  &x264_chroma_format, x264_encoder_close, x264_encoder_delayed_frames,
-  x264_encoder_encode, x264_encoder_headers, x264_encoder_intra_refresh,
-  x264_encoder_maximum_delayed_frames, x264_encoder_open,
-  x264_encoder_reconfig, &x264_levels, x264_param_apply_fastfirstpass,
-  x264_param_apply_profile, x264_param_default, x264_param_default_preset,
-  x264_param_parse
-};
+static GstX264EncVTable default_vtable;
 
 static GstX264EncVTable *vtable_8bit = NULL, *vtable_10bit = NULL;
 static GstCaps *supported_sinkcaps = NULL;
@@ -2900,6 +2891,27 @@ plugin_init (GstPlugin * plugin)
 
   GST_INFO ("linked against x264 build: %u", X264_BUILD);
 
+  /* Initialize the static GstX264EncVTable which is overriden in load_x264()
+   * if needed. We can't initialize statically because these values are not
+   * constant on Windows. */
+  default_vtable.module = NULL;
+  default_vtable.x264_bit_depth = &x264_bit_depth;
+  default_vtable.x264_chroma_format = &x264_chroma_format;
+  default_vtable.x264_encoder_close = x264_encoder_close;
+  default_vtable.x264_encoder_delayed_frames = x264_encoder_delayed_frames;
+  default_vtable.x264_encoder_encode = x264_encoder_encode;
+  default_vtable.x264_encoder_headers = x264_encoder_headers;
+  default_vtable.x264_encoder_intra_refresh = x264_encoder_intra_refresh;
+  default_vtable.x264_encoder_maximum_delayed_frames = x264_encoder_maximum_delayed_frames;
+  default_vtable.x264_encoder_open = x264_encoder_open;
+  default_vtable.x264_encoder_reconfig = x264_encoder_reconfig;
+  default_vtable.x264_levels = &x264_levels;
+  default_vtable.x264_param_apply_fastfirstpass = x264_param_apply_fastfirstpass;
+  default_vtable.x264_param_apply_profile = x264_param_apply_profile;
+  default_vtable.x264_param_default = x264_param_default;
+  default_vtable.x264_param_default_preset = x264_param_default_preset;
+  default_vtable.x264_param_parse = x264_param_parse;
+
   if (!load_x264_libraries ())
     return FALSE;