2022-02-19 01:15:03 +00:00
|
|
|
// Copyright 2019-2022, Collabora, Ltd.
|
2019-07-23 12:38:58 +00:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
2019-08-20 11:17:24 +00:00
|
|
|
* @brief @ref xrt_frame_sink converters and other helpers.
|
2019-07-23 12:38:58 +00:00
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
2022-02-19 01:15:03 +00:00
|
|
|
* @author Moses Turner <moses@collabora.com>
|
2019-07-23 12:38:58 +00:00
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-09-15 21:15:44 +00:00
|
|
|
#include "os/os_threading.h"
|
2019-08-20 11:17:24 +00:00
|
|
|
#include "xrt/xrt_frame.h"
|
2022-09-20 20:31:57 +00:00
|
|
|
#include "xrt/xrt_tracking.h"
|
2019-07-23 12:38:58 +00:00
|
|
|
|
2021-09-15 21:15:44 +00:00
|
|
|
|
2019-07-23 12:38:58 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
|
|
|
* @see u_sink_quirk_create
|
|
|
|
*/
|
2020-01-17 21:50:43 +00:00
|
|
|
struct u_sink_quirk_params
|
|
|
|
{
|
|
|
|
bool stereo_sbs;
|
|
|
|
bool ps4_cam;
|
2020-01-18 21:03:36 +00:00
|
|
|
bool leap_motion;
|
2020-01-17 21:50:43 +00:00
|
|
|
};
|
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2019-07-23 12:38:58 +00:00
|
|
|
void
|
2019-08-22 13:15:41 +00:00
|
|
|
u_sink_create_format_converter(struct xrt_frame_context *xfctx,
|
|
|
|
enum xrt_format f,
|
2019-08-20 11:17:24 +00:00
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
2019-07-23 12:38:58 +00:00
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2019-10-19 22:14:19 +00:00
|
|
|
void
|
|
|
|
u_sink_create_to_r8g8b8_or_l8(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2020-09-15 15:21:44 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-09-15 15:21:44 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_sink_create_to_r8g8b8_bayer_or_l8(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2021-06-23 14:34:40 +00:00
|
|
|
/*!
|
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_sink_create_to_rgb_yuv_yuyv_uyvy_or_l8(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2020-01-17 22:24:54 +00:00
|
|
|
void
|
2020-04-24 19:00:23 +00:00
|
|
|
u_sink_create_to_yuv_yuyv_uyvy_or_l8(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
2020-01-17 22:24:54 +00:00
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2019-08-05 18:20:53 +00:00
|
|
|
void
|
2019-08-22 13:15:41 +00:00
|
|
|
u_sink_create_to_yuv_or_yuyv(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
2019-08-05 18:20:53 +00:00
|
|
|
struct xrt_frame_sink **out_xfs);
|
2022-02-19 01:15:03 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_sink_create_to_r8g8b8_r8g8b8a8_r8g8b8x8_or_l8(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2020-01-18 20:59:38 +00:00
|
|
|
void
|
|
|
|
u_sink_deinterleaver_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2019-08-22 13:15:41 +00:00
|
|
|
bool
|
|
|
|
u_sink_queue_create(struct xrt_frame_context *xfctx,
|
2021-11-29 19:15:57 +00:00
|
|
|
uint64_t max_size,
|
2019-08-22 13:15:41 +00:00
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2022-03-19 00:18:32 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_sink_simple_queue_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2020-01-17 14:17:54 +00:00
|
|
|
void
|
|
|
|
u_sink_quirk_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
2020-01-17 21:50:43 +00:00
|
|
|
struct u_sink_quirk_params *params,
|
2020-01-17 14:17:54 +00:00
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
2021-03-26 16:21:00 +00:00
|
|
|
* @public @memberof xrt_frame_sink
|
|
|
|
* @see xrt_frame_context
|
2022-03-04 11:39:03 +00:00
|
|
|
* Takes a frame and pushes it to two sinks
|
2020-06-03 16:43:30 +00:00
|
|
|
*/
|
2019-09-03 09:07:20 +00:00
|
|
|
void
|
|
|
|
u_sink_split_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *left,
|
|
|
|
struct xrt_frame_sink *right,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2022-03-04 11:39:03 +00:00
|
|
|
/*!
|
|
|
|
* Splits Stereo SBS frames into two independent frames
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_sink_stereo_sbs_to_slam_sbs_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream_left,
|
|
|
|
struct xrt_frame_sink *downstream_right,
|
|
|
|
struct xrt_frame_sink **out_xfs);
|
|
|
|
|
2021-10-09 20:52:31 +00:00
|
|
|
/*!
|
|
|
|
* Combines stereo frames.
|
2022-03-04 11:39:03 +00:00
|
|
|
* Opposite of u_sink_stereo_sbs_to_slam_sbs_create
|
2021-10-09 20:52:31 +00:00
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_sink_combiner_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream,
|
|
|
|
struct xrt_frame_sink **out_left_xfs,
|
|
|
|
struct xrt_frame_sink **out_right_xfs);
|
|
|
|
|
2022-02-08 17:29:23 +00:00
|
|
|
/*!
|
|
|
|
* Enforces left-right push order on frames and forces them to be within a reasonable amount of time from each other
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_sink_force_genlock_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_frame_sink *downstream_left,
|
|
|
|
struct xrt_frame_sink *downstream_right,
|
|
|
|
struct xrt_frame_sink **out_left_xfs,
|
|
|
|
struct xrt_frame_sink **out_right_xfs);
|
2021-09-15 21:15:44 +00:00
|
|
|
|
2022-03-22 13:33:41 +00:00
|
|
|
|
2021-09-15 21:15:44 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Debugging sink,
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Allows more safely to debug sink inputs and outputs.
|
|
|
|
*/
|
|
|
|
struct u_sink_debug
|
|
|
|
{
|
|
|
|
//! Is initialised/destroyed when added or root is removed.
|
|
|
|
struct os_mutex mutex;
|
|
|
|
|
|
|
|
// Protected by mutex, mutex must be held when frame is being pushed.
|
|
|
|
struct xrt_frame_sink *sink;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
u_sink_debug_init(struct u_sink_debug *usd)
|
|
|
|
{
|
|
|
|
os_mutex_init(&usd->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
u_sink_debug_is_active(struct u_sink_debug *usd)
|
|
|
|
{
|
|
|
|
os_mutex_lock(&usd->mutex);
|
|
|
|
bool active = usd->sink != NULL;
|
|
|
|
os_mutex_unlock(&usd->mutex);
|
|
|
|
|
|
|
|
return active;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
u_sink_debug_push_frame(struct u_sink_debug *usd, struct xrt_frame *xf)
|
|
|
|
{
|
|
|
|
os_mutex_lock(&usd->mutex);
|
|
|
|
if (usd->sink != NULL) {
|
|
|
|
xrt_sink_push_frame(usd->sink, xf);
|
|
|
|
}
|
|
|
|
os_mutex_unlock(&usd->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
u_sink_debug_set_sink(struct u_sink_debug *usd, struct xrt_frame_sink *xfs)
|
|
|
|
{
|
|
|
|
os_mutex_lock(&usd->mutex);
|
|
|
|
usd->sink = xfs;
|
|
|
|
os_mutex_unlock(&usd->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
u_sink_debug_destroy(struct u_sink_debug *usd)
|
|
|
|
{
|
|
|
|
os_mutex_destroy(&usd->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-20 20:31:57 +00:00
|
|
|
/*!
|
|
|
|
* @public @memberof xrt_imu_sink
|
|
|
|
* @see xrt_frame_context
|
|
|
|
* Takes an IMU sample and pushes it to two sinks
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_imu_sink_split_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_imu_sink *downstream_one,
|
|
|
|
struct xrt_imu_sink *downstream_two,
|
|
|
|
struct xrt_imu_sink **out_imu_sink);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @public @memberof xrt_imu_sink
|
|
|
|
* @see xrt_frame_context
|
|
|
|
* Takes an IMU sample and only pushes it if its timestamp has monotonically increased.
|
|
|
|
* Useful for handling hardware inconsistencies.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_imu_sink_force_monotonic_create(struct xrt_frame_context *xfctx,
|
|
|
|
struct xrt_imu_sink *downstream,
|
|
|
|
struct xrt_imu_sink **out_imu_sink);
|
|
|
|
|
|
|
|
|
2019-07-23 12:38:58 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|