mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-15 14:38:10 +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 gracefullyDisconnectEnetPeer(ENetHost* host, ENetPeer* peer, enet_uint32 lingerTimeoutMs);
|
||||
int extractVersionQuadFromString(const char* string, int* quad);
|
||||
bool isReferenceFrameInvalidationSupportedByDecoder(void);
|
||||
bool isReferenceFrameInvalidationEnabled(void);
|
||||
void* extendBuffer(void* ptr, size_t newSize);
|
||||
|
||||
|
||||
12
src/Misc.c
12
src/Misc.c
@@ -119,18 +119,18 @@ void* extendBuffer(void* ptr, size_t newSize) {
|
||||
return newBuf;
|
||||
}
|
||||
|
||||
bool isReferenceFrameInvalidationEnabled(void) {
|
||||
bool isReferenceFrameInvalidationSupportedByDecoder(void) {
|
||||
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)) ||
|
||||
((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) {
|
||||
memset(streamConfig, 0, sizeof(*streamConfig));
|
||||
}
|
||||
|
||||
@@ -386,7 +386,11 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user