mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Drop the comments from the bitrate clamp
Review feedback: the clamp expression and the test name state the rule.
This commit is contained in:
-5
@@ -36,11 +36,6 @@ internal object VideoCompressorConfigFactory {
|
|||||||
// If we need to resize the video, we also want to recalculate the bitrate
|
// If we need to resize the video, we also want to recalculate the bitrate
|
||||||
val optimalBitrate = resizer.calculateOptimalBitrate(Size(width, height), newFrameRate).toInt()
|
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 sourceBitrate = metadata?.bitrate?.takeIf { it > 0 }
|
||||||
val newBitrate = sourceBitrate?.let { min(optimalBitrate.toLong(), it).toInt() } ?: optimalBitrate
|
val newBitrate = sourceBitrate?.let { min(optimalBitrate.toLong(), it).toInt() } ?: optimalBitrate
|
||||||
|
|
||||||
|
|||||||
-2
@@ -35,8 +35,6 @@ class VideoCompressorConfigFactoryTest : RobolectricTest() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `the bitrate is clamped to the source bitrate when the source is already low`() {
|
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 metadata = VideoFileMetadata(width = 720, height = 720, bitrate = 615_000, frameRate = 25, rotation = 0)
|
||||||
|
|
||||||
val videoCompressorConfig = VideoCompressorConfigFactory.create(
|
val videoCompressorConfig = VideoCompressorConfigFactory.create(
|
||||||
|
|||||||
Reference in New Issue
Block a user