From 13feaca6744fb52ab6cf840eb5f1a9fde4ceb014 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 15 Oct 2026 01:23:34 +0200 Subject: [PATCH] Use bounded contrast and bulk YUV writes in hardware rate probe --- .../debug/java/com/utun/chat/data/CallVideoProbe.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/chatgui-android/app/src/debug/java/com/utun/chat/data/CallVideoProbe.kt b/tools/chatgui-android/app/src/debug/java/com/utun/chat/data/CallVideoProbe.kt index de6aa676..7a4a1b93 100644 --- a/tools/chatgui-android/app/src/debug/java/com/utun/chat/data/CallVideoProbe.kt +++ b/tools/chatgui-android/app/src/debug/java/com/utun/chat/data/CallVideoProbe.kt @@ -92,10 +92,15 @@ class CallVideoProbe : Instrumentation() { for ((index, plane) in image.planes.withIndex()) { val width = image.width shr (if (index == 0) 0 else 1) val height = image.height shr (if (index == 0) 0 else 1) - val buffer = plane.buffer.duplicate(); val start = buffer.position() - for (y in 0 until height) for (x in 0 until width) { - random = random * 1664525 + 1013904223 - buffer.put(start + y * plane.rowStride + x * plane.pixelStride, if (index == 0) (random ushr 24).toByte() else 128.toByte()) + val buffer = plane.buffer.duplicate(); val start = buffer.position(); val row = ByteArray(width) { 128.toByte() } + for (y in 0 until height) { + // Ограниченный контраст: полностью случайный 8-bit шум превышает возможности аппаратного CBR даже при QP=51. + if (index == 0) for (x in 0 until width) { + random = random * 1664525 + 1013904223; row[x] = (112 + (random ushr 27)).toByte() + } + val offset = start + y * plane.rowStride + if (plane.pixelStride == 1) { buffer.position(offset); buffer.put(row) } + else for (x in 0 until width) buffer.put(offset + x * plane.pixelStride, row[x]) } } return random