mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
spa: libcamera: source: simplify format lookup
Use range based for loops instead of indices.
(cherry picked from commit 489cc49937)
This commit is contained in:
parent
d1eb5f6d20
commit
bdf904ebad
1 changed files with 16 additions and 18 deletions
|
|
@ -415,28 +415,26 @@ static const struct format_info format_info[] = {
|
||||||
#undef MAKE_FMT
|
#undef MAKE_FMT
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct format_info *video_format_to_info(const PixelFormat &pix) {
|
static const struct format_info *video_format_to_info(const PixelFormat &pix)
|
||||||
size_t i;
|
{
|
||||||
|
for (const auto& f : format_info) {
|
||||||
for (i = 0; i < SPA_N_ELEMENTS(format_info); i++) {
|
if (f.pix == pix)
|
||||||
if (format_info[i].pix == pix)
|
return &f;
|
||||||
return &format_info[i];
|
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct format_info *find_format_info_by_media_type(uint32_t type,
|
static const struct format_info *find_format_info_by_media_type(
|
||||||
uint32_t subtype, uint32_t format, int startidx)
|
uint32_t type, uint32_t subtype, uint32_t format)
|
||||||
{
|
{
|
||||||
size_t i;
|
for (const auto& f : format_info) {
|
||||||
|
if (f.media_type == type && f.media_subtype == subtype
|
||||||
for (i = startidx; i < SPA_N_ELEMENTS(format_info); i++) {
|
&& (f.format == SPA_VIDEO_FORMAT_UNKNOWN || f.format == format))
|
||||||
if ((format_info[i].media_type == type) &&
|
return &f;
|
||||||
(format_info[i].media_subtype == subtype) &&
|
|
||||||
(format == SPA_VIDEO_FORMAT_UNKNOWN || format_info[i].format == format))
|
|
||||||
return &format_info[i];
|
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int score_size(Size &a, Size &b)
|
static int score_size(Size &a, Size &b)
|
||||||
|
|
@ -682,7 +680,7 @@ static int spa_libcamera_set_format(struct impl *impl, struct port *port,
|
||||||
}
|
}
|
||||||
|
|
||||||
info = find_format_info_by_media_type(format->media_type,
|
info = find_format_info_by_media_type(format->media_type,
|
||||||
format->media_subtype, video_format, 0);
|
format->media_subtype, video_format);
|
||||||
if (info == NULL || size == NULL || framerate == NULL) {
|
if (info == NULL || size == NULL || framerate == NULL) {
|
||||||
spa_log_error(impl->log, "unknown media type %d %d %d", format->media_type,
|
spa_log_error(impl->log, "unknown media type %d %d %d", format->media_type,
|
||||||
format->media_subtype, video_format);
|
format->media_subtype, video_format);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue