Commit graph

39 commits

Author SHA1 Message Date
Demi Marie Obenour
5853e1150b *: rely on checks now done by spa_pod_get_values()
Rely on spa_pod_get_values() to return no values if the size is too
small for the type.  This means that if there is a check that at least
one value is returned, checking that the size is large enough is
unnecessary.
2025-09-08 15:49:31 -04:00
Demi Marie Obenour
b04da87e38 pod: check that choices are not empty
Before using the contents of a choice, check that it is not empty to
avoid reading out of bounds.
2025-07-15 10:13:18 +02:00
Demi Marie Obenour
fb315b9050 *: Missing bounds checks in POD handling
There were missing bounds checks for ill-formed POD all over the place.
2025-07-15 10:13:17 +02:00
Demi Marie Obenour
b3bf5be1f6 *: Avoid macros that use casts where possible
Use direct field access when the type is known, instead of a macro that
includes a cast.

These were missed in e4fcbef89a.
2025-07-10 14:02:55 +00:00
Wim Taymans
8047a37b02 spa: remove control type from formats
We just want to negotiate the control stream, we don't really care
about what is in the control stream.
2025-06-18 15:23:16 +02:00
Wim Taymans
c45d667934 loop: spa_loop_invoke -> spa_loop_locked where possible
When we simply need to change some state for the code executed in the
loop, we can use locked() instead of invoke(). This is more efficient
and avoids some context switches in the normal case.
2025-05-30 11:59:35 +02:00
Wim Taymans
564c9b1ba5 Use "8 bit raw midi" for control ports again
There is no need to encode the potential format in the format.dsp of
control ports, this is just for legacy compatibility with JACK apps. The
actual format can be negotiated with the types field.

Fixes midi port visibility with apps compiled against 1.2, such as JACK
apps in flatpaks.
2025-05-23 16:46:13 +02:00
Wim Taymans
218f25088c convert: place the right id in the portconfig format 2025-05-14 18:21:39 +02:00
Wim Taymans
2420c3a8c8 convert: refactor node_set_param functions
Move them to their own function to make the main function shorter.

Also make sure we emit the new ports first and then the node info.
2025-05-12 11:39:02 +02:00
Wim Taymans
0ebf664515 videoconvert: refactor add_video_formats
Rework the function a little so that it can take a list of formats and
only add the supported formats from that list and only once. It can
optionally select only the DSP formats.
2025-05-06 10:07:09 +02:00
Wim Taymans
df2369f6e1 videoconvert: fix enum format for control and dsp ports
They just have 1 format object.
2025-05-06 09:28:13 +02:00
Wim Taymans
1904521a4d videoconvert: add PeerFormats support
Make a new PeerFormats param that can be set on ports to let it know
about the possible peer formats. This can be used by converters to calculate
an optimum conversion.

make the videoadpter query the follower formats, simplify them and then
set them as PeerFormats on the converter.

Implement peerformats in videoconvert. This makes EnumFormat on the port
depend on the negotiated format of the peer. It will suggest a Format
that most closely matches the current negotiated format with the available
PeerFormats. This then makes it possible to negotiate to the format that
would require the least amount of conversions.
2025-05-05 12:59:06 +02:00
Wim Taymans
46d376cb78 videoconvert: pass the param id to enum functions 2025-05-05 12:54:41 +02:00
Wim Taymans
80f700876d videoconvert: refactor enum_params
Move the enum_param implementation out of the main enum_param loop.

This makes it easier to read the individual functions.
2025-05-05 12:45:41 +02:00
Wim Taymans
aedbe51043 videoconvert: move get_format around 2025-05-05 12:12:09 +02:00
Wim Taymans
6373827a40 videoconvert: use a table for format conversion
Use a table with format conversion values so that we can also use
flags for the formats.
2025-05-05 12:10:02 +02:00
Wim Taymans
86dd937857 videoconvert: move event emission at end of functions
Make a function to emit all pending events and trigger it at the end of
operations that can change params.
2025-05-05 11:54:18 +02:00
Wim Taymans
77e6471a04 videoconvert: free codec resources
Free encoder and decoder resource properly when we renegotiate.
2025-05-05 11:20:15 +02:00
Wim Taymans
4dd98b4ff8 videoconvert: Use converter direction from properties 2025-05-05 11:19:15 +02:00
Wim Taymans
df52086c47 videoconvert: always restore old change_mask 2025-05-05 11:17:23 +02:00
Wim Taymans
1cca24c585 videoconvert: consume input buffer in all cases
Return the input buffer when we get some error so that the other side
can send new data.
2025-04-24 10:58:04 +02:00
Wim Taymans
774f9cbb80 videconvert: fix compilation on 32 bits 2025-04-02 10:15:37 +02:00
Wim Taymans
bf952a6e4b videoconvert: improve setup of DSP mode
Parse and use DSP formats.

Redo the conversion setup when the formats changed. We usually do this
when starting the node but the formats can change while running as well.
2025-04-01 16:35:32 +02:00
Wim Taymans
5c5075f4d6 videoconvert-ffmpeg: copy complete passthrough buffer data
We also need to copy the data type, flags and sizes.
2025-03-28 16:10:42 +01:00
Wim Taymans
b23161d772 videoconvert: always put frame size on Format param
We can now set the 0x0 frame size as the default as a wildcard.
2025-03-28 16:09:36 +01:00
Wim Taymans
5f4c0cdd1e improve debug and error reporting a little 2025-03-28 16:08:57 +01:00
Wim Taymans
ae1bbc93d8 videoconvert: return error on invalid formats 2025-03-28 16:08:19 +01:00
Wim Taymans
328718f958 audioconvert: add support for buffer data mmap
When there is no data and the buffer is mmapable, try to mmap it. Unmap
again when clearing the buffers.

Use the mmaped data pointer of the buffer when processing.
2025-03-27 15:37:19 +01:00
Wim Taymans
9ceb4310f8 videoconvert: unmap buffer memory as well
Set a flag when we mmaped the buffer memory so that we can unmap it
again when clearing the buffers.
2025-03-27 15:21:12 +01:00
Wim Taymans
479ba33685 videoconvert-ffmpeg: support transcoding
When the input and output is an encoded format but the dimensions are
different, do a decode, scale and encode.
2025-03-26 17:52:26 +01:00
Wim Taymans
f8dcf32c8d videoconvert-ffmpeg: fix passthrough mode
Keep the passthrough flag up to date when we unset a port format or when
it changes.

We should only fill in the buffer data/fd when the ALLOC flag is set.

We should only take the passthrough input buffer as output when we are
in passthrough mode.

Copy the header metadata.
2025-03-26 17:52:26 +01:00
Wim Taymans
241ec04d88 videoconvert: support planar formats
Keep track of the per-place strides and sizes and use that to fill the
output buffer.
2025-03-26 12:29:26 +01:00
Wim Taymans
636e123fdd videoconvert-ffmpeg: set better size suggestion
Use a better suggestion for the buffer size.
2025-03-26 09:54:12 +01:00
Wim Taymans
1515e46d50 ffmeg: fix default number of buffers
Make the MAX buffers different from the min and make sure the default
value is between min and max.
2025-03-25 16:19:50 +01:00
Wim Taymans
367e756ebe videoconvert-ffmpeg: remove debug 2025-03-24 11:45:29 +01:00
Wim Taymans
4e0545aa04 videoconvert: get the correct strides
Use ffmpeg to get the right stride for the negotiated format instead of
using a wrong hardcoded value.
2025-03-20 10:57:26 +01:00
Wim Taymans
84bd4b7ea9 spa: use static inline for interfaces instead of macro
It gives better typechecking and a path to make a library of functions.
2024-11-26 11:35:49 +01:00
Wim Taymans
c0fcc9b83f videoconvert: add more ffmpeg format mappings 2024-11-05 10:40:14 +01:00
Wim Taymans
2cbcdbc579 videoconvert: add an ffmpeg based video converter
To activate:

PIPEWIRE_PROPS='{ video.adapt.converter = video.convert.ffmpeg }' build/src/examples/video-play

This makes it possible to start firefox with mjpg capture and then
video-play and it will decode the mjpeg transparently. Works for other
incompatible video formats as well, as long as they can be mmapped.

Ideally this should use something GPU accelerated and this is what the
vulkan converter will do.
2024-09-06 12:27:02 +02:00