mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-18 05:54:20 +01:00
Use a callback to notify frame skip
A skipped frame is detected when the producer offers a frame while the current pending frame has not been consumed. However, the producer (in practice the decoder) is not interested in the fact that a frame has been skipped, only the consumer (the renderer) is. Therefore, notify frame skip via a consumer callback. This allows to manage the skipped and rendered frames count at the same place, and remove fps_counter from decoder.
This commit is contained in:
@@ -11,22 +11,9 @@
|
||||
#include "util/buffer_util.h"
|
||||
#include "util/log.h"
|
||||
|
||||
// set the decoded frame as ready for rendering, and notify
|
||||
static void
|
||||
push_frame(struct decoder *decoder) {
|
||||
bool previous_frame_skipped;
|
||||
video_buffer_producer_offer_frame(decoder->video_buffer,
|
||||
&previous_frame_skipped);
|
||||
if (previous_frame_skipped) {
|
||||
fps_counter_add_skipped_frame(decoder->fps_counter);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
decoder_init(struct decoder *decoder, struct video_buffer *vb,
|
||||
struct fps_counter *fps_counter) {
|
||||
decoder_init(struct decoder *decoder, struct video_buffer *vb) {
|
||||
decoder->video_buffer = vb;
|
||||
decoder->fps_counter = fps_counter;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -66,7 +53,7 @@ decoder_push(struct decoder *decoder, const AVPacket *packet) {
|
||||
decoder->video_buffer->producer_frame);
|
||||
if (!ret) {
|
||||
// a frame was received
|
||||
push_frame(decoder);
|
||||
video_buffer_producer_offer_frame(decoder->video_buffer);
|
||||
} else if (ret != AVERROR(EAGAIN)) {
|
||||
LOGE("Could not receive video frame: %d", ret);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user