amfcodec: Fix for MinGW build
authorSeungha Yang <seungha@centricular.com>
Mon, 11 Apr 2022 16:49:17 +0000 (01:49 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 11 Apr 2022 18:44:40 +0000 (18:44 +0000)
timeapi.h header might not be missing depending on toolchain.
Also do hard meson error if winmm dep is not available but
amfcodec is explicitly enabled.
And fixing various GCC build warning errors.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2155>

subprojects/gst-plugins-bad/sys/amfcodec/gstamfencoder.cpp
subprojects/gst-plugins-bad/sys/amfcodec/gstamfh264enc.cpp
subprojects/gst-plugins-bad/sys/amfcodec/gstamfh265enc.cpp
subprojects/gst-plugins-bad/sys/amfcodec/meson.build

index 63c8b3d..fd14849 100644 (file)
@@ -28,7 +28,7 @@
 #include <gst/d3d11/gstd3d11.h>
 #include <wrl.h>
 #include <string.h>
-#include <timeapi.h>
+#include <mmsystem.h>
 
 /* *INDENT-OFF* */
 using namespace Microsoft::WRL;
@@ -1006,7 +1006,6 @@ gst_amf_encoder_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
   guint size;
   GstStructure *config;
   GstCapsFeatures *features;
-  gboolean is_d3d11 = FALSE;
 
   gst_query_parse_allocation (query, &caps, nullptr);
   if (!caps) {
@@ -1024,7 +1023,6 @@ gst_amf_encoder_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
           GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY)) {
     GST_DEBUG_OBJECT (self, "upstream support d3d11 memory");
     pool = gst_d3d11_buffer_pool_new (device);
-    is_d3d11 = TRUE;
   } else {
     pool = gst_d3d11_staging_buffer_pool_new (device);
   }
index d043daa..fbc64af 100644 (file)
@@ -1331,7 +1331,7 @@ gst_amf_h264_enc_create_class_data (GstD3D11Device * device,
 
   num_val = in_iocaps->GetNumOfFormats ();
   GST_LOG_OBJECT (device, "Input format count: %d", num_val);
-  for (guint i = 0; i < num_val; i++) {
+  for (amf_int32 i = 0; i < num_val; i++) {
     AMF_SURFACE_FORMAT format;
     amf_bool native;
 
@@ -1351,7 +1351,7 @@ gst_amf_h264_enc_create_class_data (GstD3D11Device * device,
 
   num_val = in_iocaps->GetNumOfMemoryTypes ();
   GST_LOG_OBJECT (device, "Input memory type count: %d", num_val);
-  for (guint i = 0; i < num_val; i++) {
+  for (amf_int32 i = 0; i < num_val; i++) {
     AMF_MEMORY_TYPE type;
     amf_bool native;
 
@@ -1383,7 +1383,7 @@ gst_amf_h264_enc_create_class_data (GstD3D11Device * device,
       in_min_width, in_max_width, in_min_height, in_max_height);
 
 #define QUERY_CAPS_PROP(prop,val) G_STMT_START { \
-  amf_int64 _val; \
+  amf_int64 _val = 0; \
   result = amf_caps->GetProperty (prop, &_val); \
   if (result == AMF_OK) { \
     GST_INFO_OBJECT (device, G_STRINGIFY (val) ": %" G_GINT64_FORMAT, _val); \
index 17224ec..e231e98 100644 (file)
@@ -523,18 +523,6 @@ update_enum (GstAmfH265Enc * self, gint * old_val, const GValue * new_val)
 }
 
 static void
-update_bool (GstAmfH265Enc * self, gboolean * old_val, const GValue * new_val)
-{
-  gboolean val = g_value_get_boolean (new_val);
-
-  if (*old_val == val)
-    return;
-
-  *old_val = val;
-  self->property_updated = TRUE;
-}
-
-static void
 gst_amf_h265_enc_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec)
 {
@@ -979,7 +967,7 @@ gst_amf_h265_enc_create_class_data (GstD3D11Device * device,
 
   num_val = in_iocaps->GetNumOfFormats ();
   GST_LOG_OBJECT (device, "Input format count: %d", num_val);
-  for (guint i = 0; i < num_val; i++) {
+  for (amf_int32 i = 0; i < num_val; i++) {
     AMF_SURFACE_FORMAT format;
     amf_bool native;
 
@@ -999,7 +987,7 @@ gst_amf_h265_enc_create_class_data (GstD3D11Device * device,
 
   num_val = in_iocaps->GetNumOfMemoryTypes ();
   GST_LOG_OBJECT (device, "Input memory type count: %d", num_val);
-  for (guint i = 0; i < num_val; i++) {
+  for (amf_int32 i = 0; i < num_val; i++) {
     AMF_MEMORY_TYPE type;
     amf_bool native;
 
@@ -1031,7 +1019,7 @@ gst_amf_h265_enc_create_class_data (GstD3D11Device * device,
       in_min_width, in_max_width, in_min_height, in_max_height);
 
 #define QUERY_CAPS_PROP(prop,val) G_STMT_START { \
-  amf_int64 _val; \
+  amf_int64 _val = 0; \
   result = amf_caps->GetProperty (prop, &_val); \
   if (result == AMF_OK) { \
     GST_INFO_OBJECT (device, G_STRINGIFY (val) ": %" G_GINT64_FORMAT, _val); \
index 6f3da43..66c59db 100644 (file)
@@ -13,6 +13,7 @@ endif
 
 platform_deps = []
 extra_args = ['-DGST_USE_UNSTABLE_API']
+extra_cpp_args = []
 if host_system == 'windows'
   if not gstd3d11_dep.found()
     if amf_option.enabled()
@@ -37,8 +38,12 @@ if host_system == 'windows'
 
   # Encoder needs to do sleep() by API design
   winmm_lib = cc.find_library('winmm', required: amf_option)
-  if not winmm_lib.found() or not cc.has_header('timeapi.h')
-    subdir_done()
+  if not winmm_lib.found() or not cc.has_header('mmsystem.h')
+    if amf_option.enabled()
+      error('Required winmm dependency is not available')
+    else
+      subdir_done()
+    endif
   endif
 
   platform_deps += [gstd3d11_dep, winmm_lib]
@@ -50,17 +55,23 @@ else
   endif
 endif
 
-# and MinGW 32bits compiler seems to be complaining about redundant-decls
-if cc.get_id() != 'msvc'
-  extra_args += cc.get_supported_arguments([
+if cxx.get_id() != 'msvc'
+  extra_cpp_args = cxx.get_supported_arguments([
+    # and MinGW 32bits compiler seems to be complaining about redundant-decls
     '-Wno-redundant-decls',
+    # Various SDK header issue
+    '-Wno-class-memaccess',
+    '-Wno-attributes',
+    '-Wno-format',
+    '-Wno-format-nonliteral',
+    '-Wno-format-security',
   ])
 endif
 
 gstamfcodec = library('gstamfcodec',
   amf_sources,
   c_args : gst_plugins_bad_args + extra_args,
-  cpp_args : gst_plugins_bad_args + extra_args,
+  cpp_args : gst_plugins_bad_args + extra_args + extra_cpp_args,
   include_directories : [configinc, include_directories('include')],
   dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstcodecparsers_dep, gmodule_dep] + platform_deps,
   install : true,