mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-02 13:22: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 <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "LGMPConfig.h"
|
||||||
|
|
||||||
#define KVMFR_MAGIC "KVMFR---"
|
#define KVMFR_MAGIC "KVMFR---"
|
||||||
#define KVMFR_VERSION 23
|
#define KVMFR_VERSION 23
|
||||||
|
|
||||||
// Fallback used by producers that cannot report the source display's SDR
|
// Fallback used by producers that cannot report the source display's SDR
|
||||||
// white level. IDD frames override this with IDDCX_METADATA2::SdrWhiteLevel.
|
// white level. IDD frames override this with IDDCX_METADATA2::SdrWhiteLevel.
|
||||||
#define KVMFR_SDR_WHITE_LEVEL_DEFAULT 203
|
#define KVMFR_SDR_WHITE_LEVEL_DEFAULT LG_SDR_WHITE_LEVEL_DEFAULT
|
||||||
|
|
||||||
#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_MAX_DAMAGE_RECTS LG_MAX_FRAME_DAMAGE_RECTS
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// don't warn on zero length arrays
|
// don't warn on zero length arrays
|
||||||
@@ -144,25 +138,18 @@ KVMFRCursor;
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
KVMFR_COLOR_TRANSFORM_MATRIX = 0x1,
|
KVMFR_COLOR_TRANSFORM_MATRIX = LG_COLOR_TRANSFORM_MATRIX,
|
||||||
KVMFR_COLOR_TRANSFORM_LUT = 0x2,
|
KVMFR_COLOR_TRANSFORM_LUT = LG_COLOR_TRANSFORM_LUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint32_t KVMFRColorTransformFlags;
|
typedef LGColorTransformFlags KVMFRColorTransformFlags;
|
||||||
|
|
||||||
// Optional payload appended to KVMFRCursor when
|
// Optional payload appended to KVMFRCursor when
|
||||||
// CURSOR_FLAG_COLOR_TRANSFORM is present. The matrix is an XYZ-to-XYZ
|
// 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
|
// adjustment; the LUT is applied after encoding to the active wire transfer
|
||||||
// function. Four LUT components keep the payload directly uploadable as an
|
// function. Four LUT components keep the payload directly uploadable as an
|
||||||
// RGBA32F texture, with alpha reserved and set to 1.0.
|
// RGBA32F texture, with alpha reserved and set to 1.0.
|
||||||
typedef struct KVMFRColorTransform
|
typedef LGColorTransform KVMFRColorTransform;
|
||||||
{
|
|
||||||
KVMFRColorTransformFlags flags;
|
|
||||||
float matrix[3][4];
|
|
||||||
float scalar;
|
|
||||||
float lut[4096][4];
|
|
||||||
}
|
|
||||||
KVMFRColorTransform;
|
|
||||||
|
|
||||||
enum
|
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
|
#define _H_LG_COMMON_STRINGUTILS
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
// vsprintf but with buffer allocation
|
// vsprintf but with buffer allocation
|
||||||
int valloc_sprintf(char ** str, const char * format, va_list ap)
|
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
|
// Local implementation of strdup
|
||||||
char * lg_strdup(const char *s);
|
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
|
// search a non null terminated buffer for a value
|
||||||
const char * memsearch(
|
const char * memsearch(
|
||||||
const char * haystack, size_t haystackSize,
|
const char * haystack, size_t haystackSize,
|
||||||
|
|||||||
@@ -89,6 +89,26 @@ typedef enum CursorType
|
|||||||
}
|
}
|
||||||
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
|
typedef struct StringPair
|
||||||
{
|
{
|
||||||
const char * name;
|
const char * name;
|
||||||
|
|||||||
@@ -112,6 +112,20 @@ char * lg_strdup(const char *s)
|
|||||||
return out;
|
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 * memsearch(
|
||||||
const char * haystack, size_t haystackSize,
|
const char * haystack, size_t haystackSize,
|
||||||
const char * needle , size_t needleSize ,
|
const char * needle , size_t needleSize ,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "common/rects.h"
|
#include "common/rects.h"
|
||||||
#include "common/runningavg.h"
|
#include "common/runningavg.h"
|
||||||
#include "common/KVMFR.h"
|
#include "common/KVMFR.h"
|
||||||
|
#include "common/LGMPConfig.h"
|
||||||
#include "common/vector.h"
|
#include "common/vector.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "common/rects.h"
|
#include "common/rects.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#include "common/KVMFR.h"
|
#include "common/KVMFR.h"
|
||||||
|
#include "common/LGMPConfig.h"
|
||||||
#include "common/vector.h"
|
#include "common/vector.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "common/option.h"
|
#include "common/option.h"
|
||||||
#include "common/locking.h"
|
#include "common/locking.h"
|
||||||
#include "common/KVMFR.h"
|
#include "common/KVMFR.h"
|
||||||
|
#include "common/LGMPConfig.h"
|
||||||
#include "common/crash.h"
|
#include "common/crash.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#include "common/ivshmem.h"
|
#include "common/ivshmem.h"
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
struct CD3D12Device;
|
struct CD3D12Device;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "common/KVMFR.h"
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ struct D12FrameFormat
|
|||||||
bool hdr = false;
|
bool hdr = false;
|
||||||
bool hdrPQ = false;
|
bool hdrPQ = false;
|
||||||
bool hdrMetadata = 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;
|
std::shared_ptr<const D12ColorTransform> colorTransform;
|
||||||
|
|
||||||
// HDR static metadata (SMPTE ST 2086)
|
// HDR static metadata (SMPTE ST 2086)
|
||||||
|
|||||||
1
obs/lg.c
1
obs/lg.c
@@ -29,6 +29,7 @@
|
|||||||
#include <common/array.h>
|
#include <common/array.h>
|
||||||
#include <common/ivshmem.h>
|
#include <common/ivshmem.h>
|
||||||
#include <common/KVMFR.h>
|
#include <common/KVMFR.h>
|
||||||
|
#include <common/LGMPConfig.h>
|
||||||
#include <common/framebuffer.h>
|
#include <common/framebuffer.h>
|
||||||
#include <lgmp/client.h>
|
#include <lgmp/client.h>
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "common/option.h"
|
#include "common/option.h"
|
||||||
#include "common/crash.h"
|
#include "common/crash.h"
|
||||||
#include "common/KVMFR.h"
|
#include "common/KVMFR.h"
|
||||||
|
#include "common/LGMPConfig.h"
|
||||||
#include "common/locking.h"
|
#include "common/locking.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
#include "common/ivshmem.h"
|
#include "common/ivshmem.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user