From 85611bcab5cf8615848a9c39f7db04a3ac230b13 Mon Sep 17 00:00:00 2001 From: Acaki Date: Tue, 2 Dec 2025 15:04:15 +0800 Subject: [PATCH] refactor: request limited range for connection --- VoidLink/Stream/Connection.m | 1 - VoidLink/Stream/VideoDecoderRenderer.m | 23 +++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/VoidLink/Stream/Connection.m b/VoidLink/Stream/Connection.m index d8fea102..f92bdccc 100644 --- a/VoidLink/Stream/Connection.m +++ b/VoidLink/Stream/Connection.m @@ -591,7 +591,6 @@ void ClSetControllerLED(uint16_t controllerNumber, uint8_t r, uint8_t g, uint8_t _callbacks = callbacks; LiInitializeStreamConfiguration(&_streamConfig); - _streamConfig.colorRange = 1; // Full range _streamConfig.width = config.width; _streamConfig.height = config.height; _streamConfig.fps = config.frameRate; diff --git a/VoidLink/Stream/VideoDecoderRenderer.m b/VoidLink/Stream/VideoDecoderRenderer.m index f51babac..1ae5e12c 100644 --- a/VoidLink/Stream/VideoDecoderRenderer.m +++ b/VoidLink/Stream/VideoDecoderRenderer.m @@ -221,19 +221,10 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, } mutableCopy]; #else NSNumber *pixelFormat = nil; - - // Uses limited range for AV1 as full range doesn't work well on all devices - if (self->_videoFormat & VIDEO_FORMAT_MASK_AV1) { - if (self->_videoFormat & VIDEO_FORMAT_MASK_YUV444) { - pixelFormat = @(kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange); - } else { - pixelFormat = @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange); - } - Log(LOG_I, @"Using VideoRange pixel format for AV1 (workaround for M3 decoder bug)"); - } else if (self->_videoFormat & VIDEO_FORMAT_MASK_YUV444) { - pixelFormat = @(kCVPixelFormatType_444YpCbCr10BiPlanarFullRange); + if (self->_videoFormat & VIDEO_FORMAT_MASK_YUV444) { + pixelFormat = @(kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange); } else { - pixelFormat = @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange); + pixelFormat = @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange); } NSMutableDictionary *destinationPixelBufferAttributes = [@{ (id)kCVPixelBufferPixelFormatTypeKey : pixelFormat @@ -636,12 +627,8 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit); break; } - Log(LOG_I, @"AV1 video range reported by stream: %@", seqHeader->color_config.color_range == 1 ? @"full" : @"limited"); - - // Forces limited range for AV1 as full range doesn't work well on all devices - SET_EXTENSION(kCMFormatDescriptionExtension_FullRangeVideo, @NO); - - Log(LOG_I, @"AV1 using limited range end-to-end"); + Log(LOG_I, @"AV1 video range: %@", seqHeader->color_config.color_range == 1 ? @"full" : @"limited"); + SET_EXTENSION(kCMFormatDescriptionExtension_FullRangeVideo, @(seqHeader->color_config.color_range == 1)); // Progressive content SET_EXTENSION(kCMFormatDescriptionExtension_FieldCount, @(1));