Disable periodic keyframes
Bug: none Change-Id: I8bd049cb8e8c958e59bf90a61198b7933eb5d40f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251692 Reviewed-by: Stefan Holmer <stefan@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36019}
This commit is contained in:
parent
035e97a447
commit
419344264c
@ -27,6 +27,11 @@ import java.util.List;
|
||||
public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
|
||||
private static final String TAG = "HardwareVideoEncoderFactory";
|
||||
|
||||
// We don't need periodic keyframes. But some HW encoders, Exynos in particular, fails to
|
||||
// initialize with value -1 which should disable periodic keyframes according to the spec. Set it
|
||||
// to 1 hour.
|
||||
private static final int PERIODIC_KEY_FRAME_INTERVAL_S = 3600;
|
||||
|
||||
// Forced key frame interval - used to reduce color distortions on Qualcomm platforms.
|
||||
private static final int QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_L_MS = 15000;
|
||||
private static final int QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_M_MS = 20000;
|
||||
@ -123,7 +128,7 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
|
||||
}
|
||||
|
||||
return new HardwareVideoEncoder(new MediaCodecWrapperFactoryImpl(), codecName, type,
|
||||
surfaceColorFormat, yuvColorFormat, input.params, getKeyFrameIntervalSec(type),
|
||||
surfaceColorFormat, yuvColorFormat, input.params, PERIODIC_KEY_FRAME_INTERVAL_S,
|
||||
getForcedKeyFrameIntervalMs(type, codecName), createBitrateAdjuster(type, codecName),
|
||||
sharedContext);
|
||||
}
|
||||
@ -250,18 +255,6 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
|
||||
return codecAllowedPredicate.test(info);
|
||||
}
|
||||
|
||||
private int getKeyFrameIntervalSec(VideoCodecMimeType type) {
|
||||
switch (type) {
|
||||
case VP8: // Fallthrough intended.
|
||||
case VP9:
|
||||
case AV1:
|
||||
return 100;
|
||||
case H264:
|
||||
return 20;
|
||||
}
|
||||
throw new IllegalArgumentException("Unsupported VideoCodecMimeType " + type);
|
||||
}
|
||||
|
||||
private int getForcedKeyFrameIntervalMs(VideoCodecMimeType type, String codecName) {
|
||||
if (type == VideoCodecMimeType.VP8 && codecName.startsWith(QCOM_PREFIX)) {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user