Add host processing latency to performance stats overlay

This commit is contained in:
Timothy Lusk
2023-06-07 18:09:59 -04:00
committed by Cameron Gutman
parent 90afecd766
commit 46f887efec
7 changed files with 47 additions and 8 deletions

View File

@@ -1292,7 +1292,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
@SuppressWarnings("deprecation")
@Override
public int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType,
int frameNumber, int frameType, long receiveTimeMs, long enqueueTimeMs) {
int frameNumber, int frameType, char frameHostProcessingLatency,
long receiveTimeMs, long enqueueTimeMs) {
if (stopping) {
// Don't bother if we're stopping
return MoonBridge.DR_OK;
@@ -1334,6 +1335,10 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
sb.append(context.getString(R.string.perf_overlay_decoder, decoder)).append('\n');
sb.append(context.getString(R.string.perf_overlay_incomingfps, fps.receivedFps)).append('\n');
sb.append(context.getString(R.string.perf_overlay_renderingfps, fps.renderedFps)).append('\n');
sb.append(context.getString(R.string.perf_overlay_hostprocessinglatency,
(float)lastTwo.minHostProcessingLatency / 10,
(float)lastTwo.maxHostProcessingLatency / 10,
(float)lastTwo.totalHostProcessingLatency / 10 / Math.max(lastTwo.framesWithHostProcessingLatency, 1))).append('\n');
sb.append(context.getString(R.string.perf_overlay_netdrops,
(float)lastTwo.framesLost / lastTwo.totalFrames * 100)).append('\n');
sb.append(context.getString(R.string.perf_overlay_netlatency,
@@ -1533,6 +1538,17 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
}
}
else {
if (frameHostProcessingLatency != 0) {
if (activeWindowVideoStats.minHostProcessingLatency != 0) {
activeWindowVideoStats.minHostProcessingLatency = (char) Math.min(activeWindowVideoStats.minHostProcessingLatency, frameHostProcessingLatency);
} else {
activeWindowVideoStats.minHostProcessingLatency = frameHostProcessingLatency;
}
activeWindowVideoStats.framesWithHostProcessingLatency += 1;
}
activeWindowVideoStats.maxHostProcessingLatency = (char) Math.max(activeWindowVideoStats.maxHostProcessingLatency, frameHostProcessingLatency);
activeWindowVideoStats.totalHostProcessingLatency += frameHostProcessingLatency;
activeWindowVideoStats.totalFramesReceived++;
activeWindowVideoStats.totalFrames++;

View File

@@ -11,6 +11,10 @@ class VideoStats {
int totalFramesRendered;
int frameLossEvents;
int framesLost;
char minHostProcessingLatency;
char maxHostProcessingLatency;
int totalHostProcessingLatency;
int framesWithHostProcessingLatency;
long measurementStartTimestamp;
void add(VideoStats other) {
@@ -22,6 +26,15 @@ class VideoStats {
this.frameLossEvents += other.frameLossEvents;
this.framesLost += other.framesLost;
if (this.minHostProcessingLatency == 0) {
this.minHostProcessingLatency = other.minHostProcessingLatency;
} else {
this.minHostProcessingLatency = (char) Math.min(this.minHostProcessingLatency, other.minHostProcessingLatency);
}
this.maxHostProcessingLatency = (char) Math.max(this.maxHostProcessingLatency, other.maxHostProcessingLatency);
this.totalHostProcessingLatency += other.totalHostProcessingLatency;
this.framesWithHostProcessingLatency += other.framesWithHostProcessingLatency;
if (this.measurementStartTimestamp == 0) {
this.measurementStartTimestamp = other.measurementStartTimestamp;
}
@@ -37,6 +50,10 @@ class VideoStats {
this.totalFramesRendered = other.totalFramesRendered;
this.frameLossEvents = other.frameLossEvents;
this.framesLost = other.framesLost;
this.minHostProcessingLatency = other.minHostProcessingLatency;
this.maxHostProcessingLatency = other.maxHostProcessingLatency;
this.totalHostProcessingLatency = other.totalHostProcessingLatency;
this.framesWithHostProcessingLatency = other.framesWithHostProcessingLatency;
this.measurementStartTimestamp = other.measurementStartTimestamp;
}
@@ -48,6 +65,10 @@ class VideoStats {
this.totalFramesRendered = 0;
this.frameLossEvents = 0;
this.framesLost = 0;
this.minHostProcessingLatency = 0;
this.maxHostProcessingLatency = 0;
this.totalHostProcessingLatency = 0;
this.framesWithHostProcessingLatency = 0;
this.measurementStartTimestamp = 0;
}

View File

@@ -10,7 +10,8 @@ public abstract class VideoDecoderRenderer {
// This is called once for each frame-start NALU. This means it will be called several times
// for an IDR frame which contains several parameter sets and the I-frame data.
public abstract int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType,
int frameNumber, int frameType, long receiveTimeMs, long enqueueTimeMs);
int frameNumber, int frameType, char frameHostProcessingLatency,
long receiveTimeMs, long enqueueTimeMs);
public abstract void cleanup();

View File

@@ -167,11 +167,11 @@ public class MoonBridge {
}
public static int bridgeDrSubmitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType,
int frameNumber, int frameType,
int frameNumber, int frameType, char frameHostProcessingLatency,
long receiveTimeMs, long enqueueTimeMs) {
if (videoRenderer != null) {
return videoRenderer.submitDecodeUnit(decodeUnitData, decodeUnitLength,
decodeUnitType, frameNumber, frameType, receiveTimeMs, enqueueTimeMs);
decodeUnitType, frameNumber, frameType, frameHostProcessingLatency, receiveTimeMs, enqueueTimeMs);
}
else {
return DR_OK;