amfcodec: Fix for MinGW build

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>
This commit is contained in:
Seungha Yang 2022-04-12 01:49:17 +09:00 committed by GStreamer Marge Bot
parent 5a6aff05ec
commit ad9c435647
4 changed files with 24 additions and 27 deletions

View file

@ -28,7 +28,7 @@
#include <gst/d3d11/gstd3d11.h> #include <gst/d3d11/gstd3d11.h>
#include <wrl.h> #include <wrl.h>
#include <string.h> #include <string.h>
#include <timeapi.h> #include <mmsystem.h>
/* *INDENT-OFF* */ /* *INDENT-OFF* */
using namespace Microsoft::WRL; using namespace Microsoft::WRL;
@ -1006,7 +1006,6 @@ gst_amf_encoder_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
guint size; guint size;
GstStructure *config; GstStructure *config;
GstCapsFeatures *features; GstCapsFeatures *features;
gboolean is_d3d11 = FALSE;
gst_query_parse_allocation (query, &caps, nullptr); gst_query_parse_allocation (query, &caps, nullptr);
if (!caps) { if (!caps) {
@ -1024,7 +1023,6 @@ gst_amf_encoder_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY)) { GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY)) {
GST_DEBUG_OBJECT (self, "upstream support d3d11 memory"); GST_DEBUG_OBJECT (self, "upstream support d3d11 memory");
pool = gst_d3d11_buffer_pool_new (device); pool = gst_d3d11_buffer_pool_new (device);
is_d3d11 = TRUE;
} else { } else {
pool = gst_d3d11_staging_buffer_pool_new (device); pool = gst_d3d11_staging_buffer_pool_new (device);
} }

View file

@ -1331,7 +1331,7 @@ gst_amf_h264_enc_create_class_data (GstD3D11Device * device,
num_val = in_iocaps->GetNumOfFormats (); num_val = in_iocaps->GetNumOfFormats ();
GST_LOG_OBJECT (device, "Input format count: %d", num_val); 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_SURFACE_FORMAT format;
amf_bool native; amf_bool native;
@ -1351,7 +1351,7 @@ gst_amf_h264_enc_create_class_data (GstD3D11Device * device,
num_val = in_iocaps->GetNumOfMemoryTypes (); num_val = in_iocaps->GetNumOfMemoryTypes ();
GST_LOG_OBJECT (device, "Input memory type count: %d", num_val); 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_MEMORY_TYPE type;
amf_bool native; 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); in_min_width, in_max_width, in_min_height, in_max_height);
#define QUERY_CAPS_PROP(prop,val) G_STMT_START { \ #define QUERY_CAPS_PROP(prop,val) G_STMT_START { \
amf_int64 _val; \ amf_int64 _val = 0; \
result = amf_caps->GetProperty (prop, &_val); \ result = amf_caps->GetProperty (prop, &_val); \
if (result == AMF_OK) { \ if (result == AMF_OK) { \
GST_INFO_OBJECT (device, G_STRINGIFY (val) ": %" G_GINT64_FORMAT, _val); \ GST_INFO_OBJECT (device, G_STRINGIFY (val) ": %" G_GINT64_FORMAT, _val); \

View file

@ -522,18 +522,6 @@ update_enum (GstAmfH265Enc * self, gint * old_val, const GValue * new_val)
self->property_updated = TRUE; self->property_updated = TRUE;
} }
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 static void
gst_amf_h265_enc_set_property (GObject * object, guint prop_id, gst_amf_h265_enc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
@ -979,7 +967,7 @@ gst_amf_h265_enc_create_class_data (GstD3D11Device * device,
num_val = in_iocaps->GetNumOfFormats (); num_val = in_iocaps->GetNumOfFormats ();
GST_LOG_OBJECT (device, "Input format count: %d", num_val); 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_SURFACE_FORMAT format;
amf_bool native; amf_bool native;
@ -999,7 +987,7 @@ gst_amf_h265_enc_create_class_data (GstD3D11Device * device,
num_val = in_iocaps->GetNumOfMemoryTypes (); num_val = in_iocaps->GetNumOfMemoryTypes ();
GST_LOG_OBJECT (device, "Input memory type count: %d", num_val); 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_MEMORY_TYPE type;
amf_bool native; 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); in_min_width, in_max_width, in_min_height, in_max_height);
#define QUERY_CAPS_PROP(prop,val) G_STMT_START { \ #define QUERY_CAPS_PROP(prop,val) G_STMT_START { \
amf_int64 _val; \ amf_int64 _val = 0; \
result = amf_caps->GetProperty (prop, &_val); \ result = amf_caps->GetProperty (prop, &_val); \
if (result == AMF_OK) { \ if (result == AMF_OK) { \
GST_INFO_OBJECT (device, G_STRINGIFY (val) ": %" G_GINT64_FORMAT, _val); \ GST_INFO_OBJECT (device, G_STRINGIFY (val) ": %" G_GINT64_FORMAT, _val); \

View file

@ -13,6 +13,7 @@ endif
platform_deps = [] platform_deps = []
extra_args = ['-DGST_USE_UNSTABLE_API'] extra_args = ['-DGST_USE_UNSTABLE_API']
extra_cpp_args = []
if host_system == 'windows' if host_system == 'windows'
if not gstd3d11_dep.found() if not gstd3d11_dep.found()
if amf_option.enabled() if amf_option.enabled()
@ -37,8 +38,12 @@ if host_system == 'windows'
# Encoder needs to do sleep() by API design # Encoder needs to do sleep() by API design
winmm_lib = cc.find_library('winmm', required: amf_option) winmm_lib = cc.find_library('winmm', required: amf_option)
if not winmm_lib.found() or not cc.has_header('timeapi.h') if not winmm_lib.found() or not cc.has_header('mmsystem.h')
subdir_done() if amf_option.enabled()
error('Required winmm dependency is not available')
else
subdir_done()
endif
endif endif
platform_deps += [gstd3d11_dep, winmm_lib] platform_deps += [gstd3d11_dep, winmm_lib]
@ -50,17 +55,23 @@ else
endif endif
endif endif
# and MinGW 32bits compiler seems to be complaining about redundant-decls if cxx.get_id() != 'msvc'
if cc.get_id() != 'msvc' extra_cpp_args = cxx.get_supported_arguments([
extra_args += cc.get_supported_arguments([ # and MinGW 32bits compiler seems to be complaining about redundant-decls
'-Wno-redundant-decls', '-Wno-redundant-decls',
# Various SDK header issue
'-Wno-class-memaccess',
'-Wno-attributes',
'-Wno-format',
'-Wno-format-nonliteral',
'-Wno-format-security',
]) ])
endif endif
gstamfcodec = library('gstamfcodec', gstamfcodec = library('gstamfcodec',
amf_sources, amf_sources,
c_args : gst_plugins_bad_args + extra_args, 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')], include_directories : [configinc, include_directories('include')],
dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstcodecparsers_dep, gmodule_dep] + platform_deps, dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstcodecparsers_dep, gmodule_dep] + platform_deps,
install : true, install : true,