From 750db0c777168f4c58469a2aa53011bdcc41568f Mon Sep 17 00:00:00 2001 From: hayaksi1 <193020925+hayaksi1@users.noreply.github.com> Date: Sun, 9 Aug 2026 15:33:37 +0300 Subject: [PATCH] Drop the comments from the bitrate clamp Review feedback: the clamp expression and the test name state the rule. --- .../libraries/mediaupload/impl/VideoCompressorConfig.kt | 5 ----- .../mediaupload/impl/VideoCompressorConfigFactoryTest.kt | 2 -- 2 files changed, 7 deletions(-) diff --git a/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfig.kt b/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfig.kt index fdde89af77..40611741c9 100644 --- a/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfig.kt +++ b/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfig.kt @@ -36,11 +36,6 @@ internal object VideoCompressorConfigFactory { // If we need to resize the video, we also want to recalculate the bitrate val optimalBitrate = resizer.calculateOptimalBitrate(Size(width, height), newFrameRate).toInt() - // Never ask the encoder for more than the source already carries: re-encoding a video that is - // already efficiently encoded at a low bitrate otherwise inflates it, making the upload both - // slower and bigger than sending the original. METADATA_KEY_BITRATE is the container total, - // video plus audio, so it is a safe upper bound for the video track alone. - // See https://github.com/element-hq/element-x-android/issues/4191 val sourceBitrate = metadata?.bitrate?.takeIf { it > 0 } val newBitrate = sourceBitrate?.let { min(optimalBitrate.toLong(), it).toInt() } ?: optimalBitrate diff --git a/libraries/mediaupload/impl/src/test/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfigFactoryTest.kt b/libraries/mediaupload/impl/src/test/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfigFactoryTest.kt index 52e6b6f0c3..4309d59209 100644 --- a/libraries/mediaupload/impl/src/test/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfigFactoryTest.kt +++ b/libraries/mediaupload/impl/src/test/kotlin/io/element/android/libraries/mediaupload/impl/VideoCompressorConfigFactoryTest.kt @@ -35,8 +35,6 @@ class VideoCompressorConfigFactoryTest : RobolectricTest() { @Test fun `the bitrate is clamped to the source bitrate when the source is already low`() { - // A 720x720 clip encoded at 615 kbps: the calculated optimal is far higher, which would - // re-encode it into a much bigger file. val metadata = VideoFileMetadata(width = 720, height = 720, bitrate = 615_000, frameRate = 25, rotation = 0) val videoCompressorConfig = VideoCompressorConfigFactory.create(