|
| 1 | +/* |
| 2 | + * Copyright 2024 Signal Messenger, LLC |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-only |
| 4 | + */ |
| 5 | + |
1 | 6 | package org.thoughtcrime.securesms.video.videoconverter; |
2 | 7 |
|
3 | 8 | import android.media.MediaCodec; |
|
21 | 26 | import java.io.FileNotFoundException; |
22 | 27 | import java.io.IOException; |
23 | 28 | import java.nio.ByteBuffer; |
24 | | -import java.util.Locale; |
25 | 29 | import java.util.concurrent.atomic.AtomicReference; |
26 | 30 |
|
27 | 31 | import kotlin.Pair; |
@@ -157,6 +161,7 @@ private VideoTrackConverter( |
157 | 161 | // configure() call to throw an unhelpful exception. |
158 | 162 | outputVideoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); |
159 | 163 | outputVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, videoBitrate); |
| 164 | + outputVideoFormat.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR); |
160 | 165 | outputVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, OUTPUT_VIDEO_FRAME_RATE); |
161 | 166 | outputVideoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, OUTPUT_VIDEO_IFRAME_INTERVAL); |
162 | 167 | if (Build.VERSION.SDK_INT >= 31 && isHdr(inputVideoFormat)) { |
@@ -476,15 +481,15 @@ private static String createFragmentShader( |
476 | 481 | } |
477 | 482 | } |
478 | 483 | shader = |
479 | | - "#extension GL_OES_EGL_image_external : require\n" + |
480 | | - "precision mediump float;\n" + // highp here doesn't seem to matter |
481 | | - "varying vec2 vTextureCoord;\n" + |
482 | | - "uniform samplerExternalOES sTexture;\n" + |
483 | | - "void main() {\n" + |
484 | | - " gl_FragColor = (texture2D(sTexture, vTextureCoord)\n" + |
485 | | - colorLoop.toString() + |
486 | | - " ) / " + sum + ";\n" + |
487 | | - "}\n"; |
| 484 | + "#extension GL_OES_EGL_image_external : require\n" + |
| 485 | + "precision mediump float;\n" + // highp here doesn't seem to matter |
| 486 | + "varying vec2 vTextureCoord;\n" + |
| 487 | + "uniform samplerExternalOES sTexture;\n" + |
| 488 | + "void main() {\n" + |
| 489 | + " gl_FragColor = (texture2D(sTexture, vTextureCoord)\n" + |
| 490 | + colorLoop + |
| 491 | + " ) / " + sum + ";\n" + |
| 492 | + "}\n"; |
488 | 493 | } |
489 | 494 | Log.i(TAG, shader); |
490 | 495 | return shader; |
|
0 commit comments