mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Add timekeeping stats to CPU decoder
This commit is contained in:
parent
91e68c0580
commit
d2f8ee8b81
@ -31,6 +31,10 @@ public class AndroidCpuDecoderRenderer implements VideoDecoderRenderer {
|
|||||||
private static final int MED_PERF = 2;
|
private static final int MED_PERF = 2;
|
||||||
private static final int HIGH_PERF = 3;
|
private static final int HIGH_PERF = 3;
|
||||||
|
|
||||||
|
private int totalFrames;
|
||||||
|
private long decoderTimeMs;
|
||||||
|
private long totalTimeMs;
|
||||||
|
|
||||||
private int cpuCount = Runtime.getRuntime().availableProcessors();
|
private int cpuCount = Runtime.getRuntime().availableProcessors();
|
||||||
|
|
||||||
private int findOptimalPerformanceLevel() {
|
private int findOptimalPerformanceLevel() {
|
||||||
@ -195,6 +199,8 @@ public class AndroidCpuDecoderRenderer implements VideoDecoderRenderer {
|
|||||||
private boolean submitDecodeUnit(DecodeUnit decodeUnit) {
|
private boolean submitDecodeUnit(DecodeUnit decodeUnit) {
|
||||||
byte[] data;
|
byte[] data;
|
||||||
|
|
||||||
|
long timeBeforeDecode = System.currentTimeMillis();
|
||||||
|
|
||||||
// Use the reserved decoder buffer if this decode unit will fit
|
// Use the reserved decoder buffer if this decode unit will fit
|
||||||
if (decodeUnit.getDataLength() <= DECODER_BUFFER_SIZE) {
|
if (decodeUnit.getDataLength() <= DECODER_BUFFER_SIZE) {
|
||||||
decoderBuffer.clear();
|
decoderBuffer.clear();
|
||||||
@ -215,7 +221,20 @@ public class AndroidCpuDecoderRenderer implements VideoDecoderRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (AvcDecoder.decode(data, 0, decodeUnit.getDataLength()) == 0);
|
boolean success = (AvcDecoder.decode(data, 0, decodeUnit.getDataLength()) == 0);
|
||||||
|
if (success) {
|
||||||
|
long timeAfterDecode = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// Add delta time to the totals (excluding probable outliers)
|
||||||
|
long delta = timeAfterDecode - decodeUnit.getReceiveTimestamp();
|
||||||
|
if (delta >= 0 && delta < 300) {
|
||||||
|
decoderTimeMs += timeAfterDecode-timeBeforeDecode;
|
||||||
|
totalTimeMs += delta;
|
||||||
|
totalFrames++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -225,11 +244,17 @@ public class AndroidCpuDecoderRenderer implements VideoDecoderRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAverageDecoderLatency() {
|
public int getAverageDecoderLatency() {
|
||||||
|
if (totalFrames == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return (int)(decoderTimeMs / totalFrames);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAverageEndToEndLatency() {
|
public int getAverageEndToEndLatency() {
|
||||||
|
if (totalFrames == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return (int)(totalTimeMs / totalFrames);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user