[Spice-commits] 2 commits - server/mjpeg-encoder.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 21 08:07:21 UTC 2019


 server/mjpeg-encoder.c |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

New commits:
commit 3d7f1cc5121134a8daba3e83bff0daa556981d85
Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue May 21 02:43:18 2019 +0200

    mjpeg: Pull more code in get_min_required_playback_delay()
    
    This reduces code duplication and passing the MJpegEncoder object
    makes it possible to modify the playback calculation without adding
    more arguments.
    
    Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
index b03fffe1..4a02e7c8 100644
--- a/server/mjpeg-encoder.c
+++ b/server/mjpeg-encoder.c
@@ -181,9 +181,8 @@ typedef struct MJpegEncoder {
 } MJpegEncoder;
 
 static void mjpeg_encoder_process_server_drops(MJpegEncoder *encoder);
-static uint32_t get_min_required_playback_delay(uint64_t frame_enc_size,
-                                                uint64_t byte_rate,
-                                                uint32_t latency);
+static uint32_t get_min_required_playback_delay(const MJpegEncoder *encoder,
+                                                uint64_t frame_enc_size);
 
 static void mjpeg_video_buffer_free(VideoBuffer *video_buffer)
 {
@@ -534,10 +533,7 @@ complete_sample:
     spice_debug("MJpeg quality sample end %p: quality %d fps %d",
                 encoder, mjpeg_quality_samples[rate_control->quality_id], rate_control->fps);
     if (encoder->cbs.update_client_playback_delay) {
-        uint32_t latency = mjpeg_encoder_get_latency(encoder);
-        uint32_t min_delay = get_min_required_playback_delay(final_quality_enc_size,
-                                                             rate_control->byte_rate,
-                                                             latency);
+        uint32_t min_delay = get_min_required_playback_delay(encoder, final_quality_enc_size);
 
         encoder->cbs.update_client_playback_delay(encoder->cbs.opaque, min_delay);
     }
@@ -1166,10 +1162,11 @@ static void mjpeg_encoder_handle_positive_client_stream_report(MJpegEncoder *enc
  * the video playback jitter buffer should be at least (send_time*2 + net_latency) for
  * preventing underflow
  */
-static uint32_t get_min_required_playback_delay(uint64_t frame_enc_size,
-                                                uint64_t byte_rate,
-                                                uint32_t latency)
+static uint32_t get_min_required_playback_delay(const MJpegEncoder *encoder,
+                                                uint64_t frame_enc_size)
 {
+    uint64_t byte_rate = encoder->rate_control.byte_rate;
+    uint32_t latency = mjpeg_encoder_get_latency(encoder);
     uint32_t one_frame_time;
     uint32_t min_delay;
 
@@ -1219,8 +1216,7 @@ static void mjpeg_encoder_client_stream_report(VideoEncoder *video_encoder,
                        rate_control->num_recent_enc_frames;
     }
     spice_debug("recent size avg %.2f (KB)", avg_enc_size / 1024.0);
-    min_playback_delay = get_min_required_playback_delay(avg_enc_size, rate_control->byte_rate,
-                                                         mjpeg_encoder_get_latency(encoder));
+    min_playback_delay = get_min_required_playback_delay(encoder, avg_enc_size);
     spice_debug("min-delay %u client-delay %d", min_playback_delay, end_frame_delay);
 
     if (min_playback_delay > end_frame_delay) {
commit 7515a0ac57788a824ffa7f2588647424de56bf6b
Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue May 21 02:43:07 2019 +0200

    mjpeg: Constify some MJpegEncoder* parameters
    
    Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
index 1400519b..b03fffe1 100644
--- a/server/mjpeg-encoder.c
+++ b/server/mjpeg-encoder.c
@@ -335,13 +335,13 @@ spice_jpeg_mem_dest(j_compress_ptr cinfo,
 }
 /* end of code from libjpeg */
 
-static inline uint32_t mjpeg_encoder_get_source_fps(MJpegEncoder *encoder)
+static inline uint32_t mjpeg_encoder_get_source_fps(const MJpegEncoder *encoder)
 {
     return encoder->cbs.get_source_fps ?
         encoder->cbs.get_source_fps(encoder->cbs.opaque) : MJPEG_MAX_FPS;
 }
 
-static inline uint32_t mjpeg_encoder_get_latency(MJpegEncoder *encoder)
+static inline uint32_t mjpeg_encoder_get_latency(const MJpegEncoder *encoder)
 {
     return encoder->cbs.get_roundtrip_ms ?
         encoder->cbs.get_roundtrip_ms(encoder->cbs.opaque) / 2 : 0;


More information about the Spice-commits mailing list