mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-02 05:12:02 +00:00
[common] lgmp: separate transport configuration
Move LGMP queue tunables into LGMPConfig.h and keep compatibility aliases in KVMFR.h. Promote color-transform, SDR white-level, and damage-limit definitions to transport-neutral common types so non-LGMP transports do not depend on the KVMFR wire format.
This commit is contained in:
@@ -26,22 +26,16 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "types.h"
|
||||
#include "LGMPConfig.h"
|
||||
|
||||
#define KVMFR_MAGIC "KVMFR---"
|
||||
#define KVMFR_VERSION 23
|
||||
|
||||
// Fallback used by producers that cannot report the source display's SDR
|
||||
// white level. IDD frames override this with IDDCX_METADATA2::SdrWhiteLevel.
|
||||
#define KVMFR_SDR_WHITE_LEVEL_DEFAULT 203
|
||||
|
||||
#define KVMFR_MAX_DAMAGE_RECTS 64
|
||||
|
||||
#define LGMP_Q_POINTER 1
|
||||
#define LGMP_Q_FRAME 2
|
||||
|
||||
#define LGMP_Q_FRAME_LEN 2
|
||||
#define LGMP_Q_POINTER_LEN 32
|
||||
#define KVMFR_SDR_WHITE_LEVEL_DEFAULT LG_SDR_WHITE_LEVEL_DEFAULT
|
||||
|
||||
#define KVMFR_MAX_DAMAGE_RECTS LG_MAX_FRAME_DAMAGE_RECTS
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// don't warn on zero length arrays
|
||||
@@ -144,25 +138,18 @@ KVMFRCursor;
|
||||
|
||||
enum
|
||||
{
|
||||
KVMFR_COLOR_TRANSFORM_MATRIX = 0x1,
|
||||
KVMFR_COLOR_TRANSFORM_LUT = 0x2,
|
||||
KVMFR_COLOR_TRANSFORM_MATRIX = LG_COLOR_TRANSFORM_MATRIX,
|
||||
KVMFR_COLOR_TRANSFORM_LUT = LG_COLOR_TRANSFORM_LUT,
|
||||
};
|
||||
|
||||
typedef uint32_t KVMFRColorTransformFlags;
|
||||
typedef LGColorTransformFlags KVMFRColorTransformFlags;
|
||||
|
||||
// Optional payload appended to KVMFRCursor when
|
||||
// CURSOR_FLAG_COLOR_TRANSFORM is present. The matrix is an XYZ-to-XYZ
|
||||
// adjustment; the LUT is applied after encoding to the active wire transfer
|
||||
// function. Four LUT components keep the payload directly uploadable as an
|
||||
// RGBA32F texture, with alpha reserved and set to 1.0.
|
||||
typedef struct KVMFRColorTransform
|
||||
{
|
||||
KVMFRColorTransformFlags flags;
|
||||
float matrix[3][4];
|
||||
float scalar;
|
||||
float lut[4096][4];
|
||||
}
|
||||
KVMFRColorTransform;
|
||||
typedef LGColorTransform KVMFRColorTransform;
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
30
common/include/common/LGMPConfig.h
Normal file
30
common/include/common/LGMPConfig.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* 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, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_LGMP_CONFIG_
|
||||
#define _H_LG_COMMON_LGMP_CONFIG_
|
||||
|
||||
#define LGMP_Q_POINTER 1
|
||||
#define LGMP_Q_FRAME 2
|
||||
|
||||
#define LGMP_Q_FRAME_LEN 2
|
||||
#define LGMP_Q_POINTER_LEN 32
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _H_LG_COMMON_STRINGUTILS
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// vsprintf but with buffer allocation
|
||||
int valloc_sprintf(char ** str, const char * format, va_list ap)
|
||||
@@ -37,6 +38,9 @@ bool str_containsValue(const char * list, char delimiter, const char * value);
|
||||
// Local implementation of strdup
|
||||
char * lg_strdup(const char *s);
|
||||
|
||||
// copy a potentially unterminated string into a null-terminated buffer
|
||||
void str_copy(char * dst, size_t dstSize, const char * src, size_t srcSize);
|
||||
|
||||
// search a non null terminated buffer for a value
|
||||
const char * memsearch(
|
||||
const char * haystack, size_t haystackSize,
|
||||
|
||||
@@ -89,6 +89,26 @@ typedef enum CursorType
|
||||
}
|
||||
CursorType;
|
||||
|
||||
enum
|
||||
{
|
||||
LG_COLOR_TRANSFORM_MATRIX = 0x1,
|
||||
LG_COLOR_TRANSFORM_LUT = 0x2,
|
||||
};
|
||||
|
||||
typedef uint32_t LGColorTransformFlags;
|
||||
|
||||
#define LG_SDR_WHITE_LEVEL_DEFAULT 203
|
||||
#define LG_MAX_FRAME_DAMAGE_RECTS 64
|
||||
|
||||
typedef struct LGColorTransform
|
||||
{
|
||||
LGColorTransformFlags flags;
|
||||
float matrix[3][4];
|
||||
float scalar;
|
||||
float lut[4096][4];
|
||||
}
|
||||
LGColorTransform;
|
||||
|
||||
typedef struct StringPair
|
||||
{
|
||||
const char * name;
|
||||
|
||||
@@ -112,6 +112,20 @@ char * lg_strdup(const char *s)
|
||||
return out;
|
||||
}
|
||||
|
||||
void str_copy(char * dst, size_t dstSize, const char * src, size_t srcSize)
|
||||
{
|
||||
if (!dstSize)
|
||||
return;
|
||||
|
||||
const char * end = memchr(src, 0, srcSize);
|
||||
const size_t srcLength = end ? (size_t)(end - src) : srcSize;
|
||||
const size_t copySize = srcLength < dstSize - 1 ?
|
||||
srcLength : dstSize - 1;
|
||||
|
||||
memcpy(dst, src, copySize);
|
||||
dst[copySize] = 0;
|
||||
}
|
||||
|
||||
const char * memsearch(
|
||||
const char * haystack, size_t haystackSize,
|
||||
const char * needle , size_t needleSize ,
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "common/rects.h"
|
||||
#include "common/runningavg.h"
|
||||
#include "common/KVMFR.h"
|
||||
#include "common/LGMPConfig.h"
|
||||
#include "common/vector.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "common/rects.h"
|
||||
#include "common/thread.h"
|
||||
#include "common/KVMFR.h"
|
||||
#include "common/LGMPConfig.h"
|
||||
#include "common/vector.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "common/option.h"
|
||||
#include "common/locking.h"
|
||||
#include "common/KVMFR.h"
|
||||
#include "common/LGMPConfig.h"
|
||||
#include "common/crash.h"
|
||||
#include "common/thread.h"
|
||||
#include "common/ivshmem.h"
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
struct CD3D12Device;
|
||||
|
||||
extern "C" {
|
||||
#include "common/KVMFR.h"
|
||||
#include "common/types.h"
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ struct D12FrameFormat
|
||||
bool hdr = false;
|
||||
bool hdrPQ = false;
|
||||
bool hdrMetadata = false;
|
||||
uint32_t sdrWhiteLevel = KVMFR_SDR_WHITE_LEVEL_DEFAULT;
|
||||
uint32_t sdrWhiteLevel = LG_SDR_WHITE_LEVEL_DEFAULT;
|
||||
std::shared_ptr<const D12ColorTransform> colorTransform;
|
||||
|
||||
// HDR static metadata (SMPTE ST 2086)
|
||||
|
||||
1
obs/lg.c
1
obs/lg.c
@@ -29,6 +29,7 @@
|
||||
#include <common/array.h>
|
||||
#include <common/ivshmem.h>
|
||||
#include <common/KVMFR.h>
|
||||
#include <common/LGMPConfig.h>
|
||||
#include <common/framebuffer.h>
|
||||
#include <lgmp/client.h>
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "common/option.h"
|
||||
#include "common/crash.h"
|
||||
#include "common/KVMFR.h"
|
||||
#include "common/LGMPConfig.h"
|
||||
#include "common/locking.h"
|
||||
#include "common/stringutils.h"
|
||||
#include "common/ivshmem.h"
|
||||
|
||||
Reference in New Issue
Block a user