|
|
|
|
@ -59,7 +59,7 @@ class CallVideoProbe : Instrumentation() {
|
|
|
|
|
check(encoder.setBitrate(rate)) { "In-place bitrate unsupported: $name" } |
|
|
|
|
var input = 0; var output = 0; var bytes = 0L; var prepared = false; var key = false |
|
|
|
|
val base = 10_000_000L + phase * 4_000_000L |
|
|
|
|
val deadline = System.nanoTime() + 15_000_000_000L |
|
|
|
|
val started = System.nanoTime(); val deadline = started + 30_000_000_000L |
|
|
|
|
while (output < 120 && System.nanoTime() < deadline) { |
|
|
|
|
if (input < 120) { |
|
|
|
|
if (!prepared) { random = fillNoise(image, random); prepared = true } |
|
|
|
|
@ -76,7 +76,8 @@ class CallVideoProbe : Instrumentation() {
|
|
|
|
|
Thread.sleep(2) |
|
|
|
|
} |
|
|
|
|
val measured = bytes * 8 / 2 |
|
|
|
|
val result = "name=$name phase=$phase target=$rate measured=$measured input=$input output=$output key=$key" |
|
|
|
|
val result = "name=$name phase=$phase target=$rate measured=$measured input=$input output=$output key=$key " + |
|
|
|
|
"elapsed_ms=${(System.nanoTime() - started) / 1_000_000}" |
|
|
|
|
android.util.Log.i("CallVideoProbe", "rate check $result") |
|
|
|
|
check(input == 120 && output == 120 && key) { "Incomplete rate check: $result" } |
|
|
|
|
check(measured > rate / 2 && measured < rate.toLong() * 3 / 2) { "Bitrate change ineffective: $result" } |
|
|
|
|
@ -92,15 +93,16 @@ 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(); val row = ByteArray(width) { 128.toByte() } |
|
|
|
|
val buffer = plane.buffer.duplicate(); val start = buffer.position() |
|
|
|
|
val row = ByteArray((width - 1) * plane.pixelStride + 1) { 128.toByte() } |
|
|
|
|
for (y in 0 until height) { |
|
|
|
|
// Ограниченный контраст: полностью случайный 8-bit шум превышает возможности аппаратного CBR даже при QP=51. |
|
|
|
|
// Ограниченный контраст сохраняет сжимаемость тестового сигнала при низком bitrate. |
|
|
|
|
if (index == 0) for (x in 0 until width) { |
|
|
|
|
random = random * 1664525 + 1013904223; row[x] = (112 + (random ushr 27)).toByte() |
|
|
|
|
random = random * 1664525 + 1013904223; row[x * plane.pixelStride] = (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]) |
|
|
|
|
// Обе chroma-плоскости нейтральны: interleaved U/V тоже заполняем одним bulk put. |
|
|
|
|
buffer.position(offset); buffer.put(row) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return random |
|
|
|
|
|