mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
video: Add SPA_VIDEO_FLAG_MODIFIER flag
The drm format modifier value `0` is actually `DRM_FORMAT_MOD_LINEAR`, a commonly used modifier. Unfortunately there appears to be no value that can savely used as placeholder for "no value", as e.g. `DRM_FORMAT_MOD_INVALID` is often used to indicate an implicit modifier. Thus add a new flag that clearly indicates whether the modifier value is set or not, add it to `spa_video_info_raw` and the util functions. Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2943
This commit is contained in:
parent
da26563a83
commit
c61b9a09b8
2 changed files with 17 additions and 4 deletions
|
|
@ -42,6 +42,11 @@ static inline int
|
|||
spa_format_video_raw_parse(const struct spa_pod *format,
|
||||
struct spa_video_info_raw *info)
|
||||
{
|
||||
info->flags = SPA_VIDEO_FLAG_NONE;
|
||||
if (spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) {
|
||||
info->flags |= SPA_VIDEO_FLAG_MODIFIER;
|
||||
}
|
||||
|
||||
return spa_pod_parse_object(format,
|
||||
SPA_TYPE_OBJECT_Format, NULL,
|
||||
SPA_FORMAT_VIDEO_format, SPA_POD_OPT_Id(&info->format),
|
||||
|
|
@ -65,6 +70,11 @@ static inline int
|
|||
spa_format_video_dsp_parse(const struct spa_pod *format,
|
||||
struct spa_video_info_dsp *info)
|
||||
{
|
||||
info->flags = SPA_VIDEO_FLAG_NONE;
|
||||
if (spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) {
|
||||
info->flags |= SPA_VIDEO_FLAG_MODIFIER;
|
||||
}
|
||||
|
||||
return spa_pod_parse_object(format,
|
||||
SPA_TYPE_OBJECT_Format, NULL,
|
||||
SPA_FORMAT_VIDEO_format, SPA_POD_OPT_Id(&info->format),
|
||||
|
|
@ -90,7 +100,7 @@ spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id,
|
|||
if (info->framerate.denom != 0)
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&info->framerate), 0);
|
||||
if (info->modifier != 0)
|
||||
if (info->modifier != 0 || info->flags & SPA_VIDEO_FLAG_MODIFIER)
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_VIDEO_modifier, SPA_POD_Long(info->modifier), 0);
|
||||
if (info->max_framerate.denom != 0)
|
||||
|
|
@ -142,7 +152,7 @@ spa_format_video_dsp_build(struct spa_pod_builder *builder, uint32_t id,
|
|||
if (info->format != SPA_VIDEO_FORMAT_UNKNOWN)
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_VIDEO_format, SPA_POD_Id(info->format), 0);
|
||||
if (info->modifier)
|
||||
if (info->modifier != 0 || info->flags & SPA_VIDEO_FLAG_MODIFIER)
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_VIDEO_modifier, SPA_POD_Long(info->modifier), 0);
|
||||
return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ enum spa_video_flags {
|
|||
SPA_VIDEO_FLAG_VARIABLE_FPS = (1 << 0), /**< a variable fps is selected, fps_n and fps_d
|
||||
* denote the maximum fps of the video */
|
||||
SPA_VIDEO_FLAG_PREMULTIPLIED_ALPHA = (1 << 1), /**< Each color has been scaled by the alpha value. */
|
||||
SPA_VIDEO_FLAG_MODIFIER = (1 << 2), /**< use the format modifier */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -186,7 +187,8 @@ enum spa_video_interlace_mode {
|
|||
*/
|
||||
struct spa_video_info_raw {
|
||||
enum spa_video_format format; /**< the format */
|
||||
int64_t modifier; /**< format modifier
|
||||
uint32_t flags; /**< extra video flags */
|
||||
uint64_t modifier; /**< format modifier
|
||||
* only used with DMA-BUF */
|
||||
struct spa_rectangle size; /**< the frame size of the video */
|
||||
struct spa_fraction framerate; /**< the framerate of the video, 0/1 means variable rate */
|
||||
|
|
@ -210,7 +212,8 @@ struct spa_video_info_raw {
|
|||
|
||||
struct spa_video_info_dsp {
|
||||
enum spa_video_format format;
|
||||
int64_t modifier;
|
||||
uint32_t flags;
|
||||
uint64_t modifier;
|
||||
};
|
||||
|
||||
#define SPA_VIDEO_INFO_DSP_INIT(...) ((struct spa_video_info_dsp) { __VA_ARGS__ })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue