mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-06-24 05:31:13 +00:00
Allow encoder to pick optimal ref frame count if RFI is supported by the decoder
This commit is contained in:
@@ -76,6 +76,7 @@ extern SS_PING VideoPingPayload;
|
|||||||
int serviceEnetHost(ENetHost* client, ENetEvent* event, enet_uint32 timeoutMs);
|
int serviceEnetHost(ENetHost* client, ENetEvent* event, enet_uint32 timeoutMs);
|
||||||
int gracefullyDisconnectEnetPeer(ENetHost* host, ENetPeer* peer, enet_uint32 lingerTimeoutMs);
|
int gracefullyDisconnectEnetPeer(ENetHost* host, ENetPeer* peer, enet_uint32 lingerTimeoutMs);
|
||||||
int extractVersionQuadFromString(const char* string, int* quad);
|
int extractVersionQuadFromString(const char* string, int* quad);
|
||||||
|
bool isReferenceFrameInvalidationSupportedByDecoder(void);
|
||||||
bool isReferenceFrameInvalidationEnabled(void);
|
bool isReferenceFrameInvalidationEnabled(void);
|
||||||
void* extendBuffer(void* ptr, size_t newSize);
|
void* extendBuffer(void* ptr, size_t newSize);
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -119,18 +119,18 @@ void* extendBuffer(void* ptr, size_t newSize) {
|
|||||||
return newBuf;
|
return newBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isReferenceFrameInvalidationEnabled(void) {
|
bool isReferenceFrameInvalidationSupportedByDecoder(void) {
|
||||||
LC_ASSERT(NegotiatedVideoFormat != 0);
|
LC_ASSERT(NegotiatedVideoFormat != 0);
|
||||||
|
|
||||||
// Even if the client wants it, we can't enable it without server support.
|
|
||||||
if (!ReferenceFrameInvalidationSupported) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H264) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) ||
|
return ((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H264) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) ||
|
||||||
((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H265) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC));
|
((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H265) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isReferenceFrameInvalidationEnabled(void) {
|
||||||
|
// RFI must be supported by the server and the client decoder to be used
|
||||||
|
return ReferenceFrameInvalidationSupported && isReferenceFrameInvalidationSupportedByDecoder();
|
||||||
|
}
|
||||||
|
|
||||||
void LiInitializeStreamConfiguration(PSTREAM_CONFIGURATION streamConfig) {
|
void LiInitializeStreamConfiguration(PSTREAM_CONFIGURATION streamConfig) {
|
||||||
memset(streamConfig, 0, sizeof(*streamConfig));
|
memset(streamConfig, 0, sizeof(*streamConfig));
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -386,7 +386,11 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (AppVersionQuad[0] >= 7) {
|
if (AppVersionQuad[0] >= 7) {
|
||||||
if (isReferenceFrameInvalidationEnabled()) {
|
// If the decoder supports reference frame invalidation, that indicates it also supports
|
||||||
|
// the maximum number of reference frames allowed by the codec. Even if we can't use RFI
|
||||||
|
// due to lack of host support, we can still allow the host to pick a number of reference
|
||||||
|
// frames greater than 1 to improve encoding efficiency.
|
||||||
|
if (isReferenceFrameInvalidationSupportedByDecoder()) {
|
||||||
err |= addAttributeString(&optionHead, "x-nv-video[0].maxNumReferenceFrames", "0");
|
err |= addAttributeString(&optionHead, "x-nv-video[0].maxNumReferenceFrames", "0");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user