Drop the comments from the bitrate clamp

Review feedback: the clamp expression and the test name state the rule.
This commit is contained in:
hayaksi1
2026-08-09 15:33:37 +03:00
parent 1be87994b1
commit 750db0c777
2 changed files with 0 additions and 7 deletions
@@ -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
@@ -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(