libobs: Add better default source color range handling
Fixes handling of the `obs_source_frame::full_range` member variable, which is often set to false by default by many plugins even when using RGB, which would cause RGB to be marked as "partial range". This change is crucial for when partial range RBG support is implemented. Adds `obs_source_frame2` structure that replaces the `full_range` member variable with a `range` variable, which uses the `video_range_type` enum to allow handling default range values. This member variable treats VIDEO_RANGE_DEFAULT as full range if the format is RGB, and partial range if the format is YUV. Also adds `obs_source_output_video2` and `obs_source_preload_video2` functions which use the `obs_source_frame2` structure instead of the `obs_source_frame` structure. When using the original `obs_source_frame`, `obs_source_output_video`, and `obs_source_preload_video` functions, RGB will always be full range by default for backward compatibility purposes.
This commit is contained in:
@@ -135,15 +135,23 @@ static inline const char *get_video_colorspace_name(enum video_colorspace cs)
|
||||
return "601";
|
||||
}
|
||||
|
||||
static inline const char *get_video_range_name(enum video_range_type range)
|
||||
static inline enum video_range_type resolve_video_range(
|
||||
enum video_format format, enum video_range_type range)
|
||||
{
|
||||
switch (range) {
|
||||
case VIDEO_RANGE_FULL: return "Full";
|
||||
case VIDEO_RANGE_PARTIAL:
|
||||
case VIDEO_RANGE_DEFAULT:;
|
||||
if (range == VIDEO_RANGE_DEFAULT) {
|
||||
range = format_is_yuv(format)
|
||||
? VIDEO_RANGE_PARTIAL
|
||||
: VIDEO_RANGE_FULL;
|
||||
}
|
||||
|
||||
return "Partial";
|
||||
return range;
|
||||
}
|
||||
|
||||
static inline const char *get_video_range_name(enum video_format format,
|
||||
enum video_range_type range)
|
||||
{
|
||||
range = resolve_video_range(format, range);
|
||||
return range == VIDEO_RANGE_FULL ? "Full" : "Partial";
|
||||
}
|
||||
|
||||
enum video_scale_type {
|
||||
|
Reference in New Issue
Block a user