mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 11:33:06 +00:00
Don't set constraints 4 & 5 when using baseline profile hack
This commit is contained in:
parent
2f219aac6f
commit
5f13b9bca4
@ -439,6 +439,23 @@ public class MediaCodecDecoderRenderer extends EnhancedDecoderRenderer {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doProfileSpecificSpsPatching(SeqParameterSet sps) {
|
||||||
|
// Some devices benefit from setting constraint flags 4 & 5 to make this Constrained
|
||||||
|
// High Profile which allows the decoder to assume there will be no B-frames and
|
||||||
|
// reduce delay and buffering accordingly. Some devices (Marvell, Exynos 4) don't
|
||||||
|
// like it so we only set them on devices that are confirmed to benefit from it.
|
||||||
|
if (sps.profile_idc == 100 && constrainedHighProfile) {
|
||||||
|
LimeLog.info("Setting constraint set flags for constrained high profile");
|
||||||
|
sps.constraint_set_4_flag = true;
|
||||||
|
sps.constraint_set_5_flag = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Force the constraints unset otherwise (some may be set by default)
|
||||||
|
sps.constraint_set_4_flag = false;
|
||||||
|
sps.constraint_set_5_flag = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void submitDecodeUnit(DecodeUnit decodeUnit, int inputBufferIndex) {
|
private void submitDecodeUnit(DecodeUnit decodeUnit, int inputBufferIndex) {
|
||||||
long timestampUs = System.nanoTime() / 1000;
|
long timestampUs = System.nanoTime() / 1000;
|
||||||
@ -541,21 +558,6 @@ public class MediaCodecDecoderRenderer extends EnhancedDecoderRenderer {
|
|||||||
sps.vuiParams.bitstreamRestriction = null;
|
sps.vuiParams.bitstreamRestriction = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some devices benefit from setting constraint flags 4 & 5 to make this Constrained
|
|
||||||
// High Profile which allows the decoder to assume there will be no B-frames and
|
|
||||||
// reduce delay and buffering accordingly. Some devices (Marvell, Exynos 4) don't
|
|
||||||
// like it so we only set them on devices that are confirmed to benefit from it.
|
|
||||||
if (constrainedHighProfile) {
|
|
||||||
LimeLog.info("Setting constraint set flags for constrained high profile");
|
|
||||||
sps.constraint_set_4_flag = true;
|
|
||||||
sps.constraint_set_5_flag = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Force the constraints unset otherwise (some may be set by default)
|
|
||||||
sps.constraint_set_4_flag = false;
|
|
||||||
sps.constraint_set_5_flag = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we need to hack this SPS to say we're baseline, do so now
|
// If we need to hack this SPS to say we're baseline, do so now
|
||||||
if (needsBaselineSpsHack) {
|
if (needsBaselineSpsHack) {
|
||||||
LimeLog.info("Hacking SPS to baseline");
|
LimeLog.info("Hacking SPS to baseline");
|
||||||
@ -563,6 +565,9 @@ public class MediaCodecDecoderRenderer extends EnhancedDecoderRenderer {
|
|||||||
savedSps = sps;
|
savedSps = sps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Patch the SPS constraint flags
|
||||||
|
doProfileSpecificSpsPatching(sps);
|
||||||
|
|
||||||
// Write the annex B header
|
// Write the annex B header
|
||||||
buf.put(header.data, header.offset, 5);
|
buf.put(header.data, header.offset, 5);
|
||||||
|
|
||||||
@ -615,6 +620,9 @@ public class MediaCodecDecoderRenderer extends EnhancedDecoderRenderer {
|
|||||||
// Switch the H264 profile back to high
|
// Switch the H264 profile back to high
|
||||||
savedSps.profile_idc = 100;
|
savedSps.profile_idc = 100;
|
||||||
|
|
||||||
|
// Patch the SPS constraint flags
|
||||||
|
doProfileSpecificSpsPatching(savedSps);
|
||||||
|
|
||||||
// Write the SPS data
|
// Write the SPS data
|
||||||
savedSps.write(inputBuffer);
|
savedSps.write(inputBuffer);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user