Compare commits

...

5 commits

Author SHA1 Message Date
Nicolas Dufresne 7a8fc93561 Merge branch 'gst-plugins-good-fix-alternate-interlacing' into 'main'
WIP: v4l2: Fix alternate interlacing caps and field values

See merge request gstreamer/gstreamer!961
2024-04-27 18:13:06 +00:00
Nirbheek Chauhan d7eeb62f38 meson: Fix Python library searching on Windows
Neither LIBDIR nor LIBPL are set with the native windows Python
(unlike MSYS2), so we need to use `prefix` which takes us to the
rootdir of the Python installation.

The name is also different: it's python312.dll, not python3.12.dll.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6734>
2024-04-27 01:30:21 +00:00
Nirbheek Chauhan 753aeccde7 meson: Fix Python library name fetching on Windows
`python.get_variable('FOO', [])` becomes `python.get_variable('FOO')`
due to how Meson treats empty arrays in arguments, which breaks the
fallback feature of get_variable().

So we need to actually check whether the variable exists before trying
to fetch it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6734>
2024-04-27 01:30:21 +00:00
Dylan Yip d7fb8ed66c v4l2object: Fix interlaced feature insertion for alternate caps
Currently the interlaced feature is being appended to the last
structure of the caps. However, there is no guarantee that the last
structure has interlace-mode=alternate. Instead, this patch first adds
the structure to the end of the list then adds the interlaced feature to
the last structure of the caps.
2021-09-29 09:48:06 -04:00
Dylan Yip ecef2e4e7d v4l2bufferpool: Set top/bottom field in v4l2 buffers for alternate mode output devices
Currently, v4l2 output buffers are being passed down to v4l2 with the
V4L2_FIELD_ALTERNATE field. This is incorrect since each buffer needs to
correspond to either a top or bottom field. This patch corrects this by
checking the GstBuffer flags and setting the correct field in the v4l2
buffer.
2021-09-29 09:48:05 -04:00
3 changed files with 41 additions and 21 deletions

View file

@ -1173,6 +1173,15 @@ gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf,
else
field = obj->format.fmt.pix.field;
/* If interlaced alternate, specify if buffer is top or bottom */
if (field == V4L2_FIELD_ALTERNATE) {
if ((GST_BUFFER_FLAGS (buf) & GST_VIDEO_BUFFER_FLAG_TOP_FIELD) ==
GST_VIDEO_BUFFER_FLAG_TOP_FIELD)
field = V4L2_FIELD_TOP;
else
field = V4L2_FIELD_BOTTOM;
}
group->buffer.field = field;
}

View file

@ -2886,6 +2886,7 @@ static void
check_alternate_and_append_struct (GstCaps * caps, GstStructure * s)
{
const GValue *mode;
GstCapsFeatures *features = NULL;
mode = gst_structure_get_value (s, "interlace-mode");
if (!mode)
@ -2894,12 +2895,9 @@ check_alternate_and_append_struct (GstCaps * caps, GstStructure * s)
if (G_VALUE_HOLDS_STRING (mode)) {
/* Add the INTERLACED feature if the mode is alternate */
if (!g_strcmp0 (gst_structure_get_string (s, "interlace-mode"),
"alternate")) {
GstCapsFeatures *feat;
feat = gst_caps_features_new (GST_CAPS_FEATURE_FORMAT_INTERLACED, NULL);
gst_caps_set_features (caps, gst_caps_get_size (caps) - 1, feat);
}
"alternate"))
features =
gst_caps_features_new (GST_CAPS_FEATURE_FORMAT_INTERLACED, NULL);
} else if (GST_VALUE_HOLDS_LIST (mode)) {
/* If the mode is a list containing alternate, remove it from the list and add a
* variant with interlace-mode=alternate and the INTERLACED feature. */
@ -2927,7 +2925,7 @@ check_alternate_and_append_struct (GstCaps * caps, GstStructure * s)
}
done:
gst_caps_append_structure (caps, s);
gst_caps_append_structure_full (caps, s, features);
}
static void

View file

@ -45,35 +45,53 @@ pylib_loc = get_option('libpython-dir')
fsmod = import('fs')
pylib_prefix = 'lib'
pylib_suffix = 'so'
pylib_ver = python_dep.version()
pylib_locs = []
if host_system == 'windows'
if cc.get_argument_syntax() == 'msvc'
pylib_prefix = ''
endif
pylib_suffix = 'dll'
pylib_ver = pylib_ver.replace('.', '')
elif host_system == 'darwin'
pylib_suffix = 'dylib'
endif
pylib_fnames = []
# Library name with soversion, non-devel package
pylib_fnames += python.get_variable('INSTSONAME', [])
if python.has_variable('INSTSONAME')
# For example, libpython3.12.so.1.0 (Linux), libpython3.11.dll.a (MSYS2), etc.
pylib_fnames += python.get_variable('INSTSONAME')
endif
# Library name without soversion, devel package, framework, etc.
pylib_fnames += python.get_variable('LDLIBRARY', [])
if python.has_variable('LDLIBRARY')
# For example, libpython3.12.so (Linux), libpython3.11.dll.a (MSYS2), etc.
pylib_fnames += python.get_variable('LDLIBRARY')
endif
# Manually construct name as a fallback
pylib_fnames += [
pylib_prefix + 'python' + python_dep.version() + python_abi_flags + '.' + pylib_suffix
pylib_prefix + 'python' + pylib_ver + python_abi_flags + '.' + pylib_suffix
]
if pylib_loc != ''
pylib_locs = [pylib_loc]
else
pylib_locs = [
python.get_variable('LIBDIR', ''),
python.get_variable('LIBPL', ''),
]
if python.has_variable('LIBDIR')
pylib_locs += python.get_variable('LIBDIR')
endif
if python.has_variable('LIBPL')
pylib_locs += python.get_variable('LIBPL')
endif
# On Windows, python312.dll is in the rootdir where Python is installed,
# which is configured as the "prefix" in sysconfig.
if host_system == 'windows'
pylib_locs += python.get_variable('prefix')
endif
endif
pylib_fname = ''
foreach loc: pylib_locs
foreach fname: pylib_fnames
if fsmod.exists(loc / fname)
fpath = loc / fname
debug(f'Looking for Python library at: @fpath@')
if fsmod.exists(fpath)
pylib_fname = fname
message(f'PY_LIB_FNAME = @fname@ (@loc@)')
break
@ -81,12 +99,7 @@ foreach loc: pylib_locs
endforeach
endforeach
if pylib_fname == ''
error_msg = 'Could not find python library to load'
if python_opt.enabled()
error(error_msg)
else
message(error_msg)
endif
message('Could not find python library to load, will try loading at runtime')
endif
pygi_override_dir = get_option('pygi-overrides-dir')