-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linux-pipewire: Factor out formats list into a file
This will help share these formats with the upcoming Camera portal code.
- Loading branch information
1 parent
7f765cd
commit 364323e
Showing
4 changed files
with
206 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* formats.c | ||
* | ||
* Copyright 2023 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
#include "formats.h" | ||
|
||
#include <libdrm/drm_fourcc.h> | ||
#include <pipewire/pipewire.h> | ||
|
||
static const struct obs_pw_video_format supported_formats[] = { | ||
{ | ||
SPA_VIDEO_FORMAT_BGRA, | ||
DRM_FORMAT_ARGB8888, | ||
GS_BGRA, | ||
VIDEO_FORMAT_BGRA, | ||
false, | ||
4, | ||
"ARGB8888", | ||
}, | ||
{ | ||
SPA_VIDEO_FORMAT_RGBA, | ||
DRM_FORMAT_ABGR8888, | ||
GS_RGBA, | ||
VIDEO_FORMAT_RGBA, | ||
false, | ||
4, | ||
"ABGR8888", | ||
}, | ||
{ | ||
SPA_VIDEO_FORMAT_BGRx, | ||
DRM_FORMAT_XRGB8888, | ||
GS_BGRX, | ||
VIDEO_FORMAT_BGRX, | ||
false, | ||
4, | ||
"XRGB8888", | ||
}, | ||
{ | ||
SPA_VIDEO_FORMAT_RGBx, | ||
DRM_FORMAT_XBGR8888, | ||
GS_BGRX, | ||
VIDEO_FORMAT_NONE, | ||
true, | ||
4, | ||
"XBGR8888", | ||
}, | ||
{ | ||
SPA_VIDEO_FORMAT_YUY2, | ||
DRM_FORMAT_YUYV, | ||
GS_UNKNOWN, | ||
VIDEO_FORMAT_YUY2, | ||
false, | ||
2, | ||
"YUYV422", | ||
}, | ||
{ | ||
SPA_VIDEO_FORMAT_NV12, | ||
DRM_FORMAT_NV12, | ||
GS_UNKNOWN, | ||
VIDEO_FORMAT_NV12, | ||
false, | ||
2, | ||
"NV12", | ||
}, | ||
#if PW_CHECK_VERSION(0, 3, 41) | ||
{ | ||
SPA_VIDEO_FORMAT_ABGR_210LE, | ||
DRM_FORMAT_ABGR2101010, | ||
GS_R10G10B10A2, | ||
VIDEO_FORMAT_NONE, | ||
false, | ||
10, | ||
"ABGR2101010", | ||
|
||
}, | ||
{ | ||
SPA_VIDEO_FORMAT_xBGR_210LE, | ||
DRM_FORMAT_XBGR2101010, | ||
GS_R10G10B10A2, | ||
VIDEO_FORMAT_NONE, | ||
false, | ||
10, | ||
"XBGR2101010", | ||
|
||
}, | ||
#endif | ||
}; | ||
|
||
#define N_SUPPORTED_FORMATS \ | ||
(sizeof(supported_formats) / sizeof(supported_formats[0])) | ||
|
||
bool obs_pw_video_format_from_spa_format( | ||
uint32_t spa_format, struct obs_pw_video_format *out_video_format) | ||
{ | ||
for (size_t i = 0; i < N_SUPPORTED_FORMATS; i++) { | ||
if (supported_formats[i].spa_format != spa_format) | ||
continue; | ||
|
||
if (out_video_format) | ||
*out_video_format = supported_formats[i]; | ||
|
||
return true; | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* formats.h | ||
* | ||
* Copyright 2023 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <obs-module.h> | ||
|
||
#include <spa/param/video/format-utils.h> | ||
|
||
struct obs_pw_video_format { | ||
uint32_t spa_format; | ||
uint32_t drm_format; | ||
enum gs_color_format gs_format; | ||
enum video_format video_format; | ||
bool swap_red_blue; | ||
uint32_t bpp; | ||
const char *pretty_name; | ||
}; | ||
|
||
bool obs_pw_video_format_from_spa_format( | ||
uint32_t spa_format, struct obs_pw_video_format *out_format_info); |
Oops, something went wrong.