<div dir="ltr">ack<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 13, 2015 at 10:26 PM, Francois Gouget <span dir="ltr"><<a href="mailto:fgouget@codeweavers.com" target="_blank">fgouget@codeweavers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It is redundant with the corresponding callbacks.<br>
---<br>
<br>
This patch only depends on patch 1/11 and is independent from the rest<br>
of the series.<br>
<br>
server/mjpeg_encoder.c | 22 +++++++++++++---------<br>
server/mjpeg_encoder.h | 2 +-<br>
server/red_worker.c | 4 ++--<br>
3 files changed, 16 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c<br>
index 95d841f..9a41ef3 100644<br>
--- a/server/mjpeg_encoder.c<br>
+++ b/server/mjpeg_encoder.c<br>
@@ -164,7 +164,6 @@ struct MJpegEncoder {<br>
unsigned int bytes_per_pixel; /* bytes per pixel of the input buffer */<br>
void (*pixel_converter)(uint8_t *src, uint8_t *dest);<br>
<br>
- int rate_control_is_active;<br>
MJpegEncoderRateControl rate_control;<br>
MJpegEncoderRateControlCbs cbs;<br>
void *cbs_opaque;<br>
@@ -185,21 +184,25 @@ static uint32_t get_min_required_playback_delay(uint64_t frame_enc_size,<br>
uint64_t byte_rate,<br>
uint32_t latency);<br>
<br>
-MJpegEncoder *mjpeg_encoder_new(int bit_rate_control, uint64_t starting_bit_rate,<br>
+static inline int rate_control_is_active(MJpegEncoder* encoder)<br>
+{<br>
+ return encoder->cbs.get_roundtrip_ms != NULL;<br>
+}<br>
+<br>
+MJpegEncoder *mjpeg_encoder_new(uint64_t starting_bit_rate,<br>
MJpegEncoderRateControlCbs *cbs, void *opaque)<br>
{<br>
MJpegEncoder *enc;<br>
<br>
- spice_assert(!bit_rate_control || (cbs && cbs->get_roundtrip_ms && cbs->get_source_fps));<br>
+ spice_assert(!cbs || (cbs && cbs->get_roundtrip_ms && cbs->get_source_fps));<br>
<br>
enc = spice_new0(MJpegEncoder, 1);<br>
<br>
enc->first_frame = TRUE;<br>
- enc->rate_control_is_active = bit_rate_control;<br>
enc->rate_control.byte_rate = starting_bit_rate / 8;<br>
enc->starting_bit_rate = starting_bit_rate;<br>
<br>
- if (bit_rate_control) {<br>
+ if (cbs) {<br>
struct timespec time;<br>
<br>
clock_gettime(CLOCK_MONOTONIC, &time);<br>
@@ -211,6 +214,7 @@ MJpegEncoder *mjpeg_encoder_new(int bit_rate_control, uint64_t starting_bit_rate<br>
enc->rate_control.quality_eval_data.reason = MJPEG_QUALITY_EVAL_REASON_RATE_CHANGE;<br>
enc->rate_control.warmup_start_time = ((uint64_t) time.tv_sec) * 1000000000 + time.tv_nsec;<br>
} else {<br>
+ enc->cbs.get_roundtrip_ms = NULL;<br>
mjpeg_encoder_reset_quality(enc, MJPEG_LEGACY_STATIC_QUALITY_ID, MJPEG_MAX_FPS, 0);<br>
}<br>
<br>
@@ -607,7 +611,7 @@ static void mjpeg_encoder_adjust_params_to_bit_rate(MJpegEncoder *encoder)<br>
uint32_t latency = 0;<br>
uint32_t src_fps;<br>
<br>
- spice_assert(encoder->rate_control_is_active);<br>
+ spice_assert(rate_control_is_active(encoder));<br>
<br>
rate_control = &encoder->rate_control;<br>
quality_eval = &rate_control->quality_eval_data;<br>
@@ -692,7 +696,7 @@ static void mjpeg_encoder_adjust_fps(MJpegEncoder *encoder, uint64_t now)<br>
MJpegEncoderRateControl *rate_control = &encoder->rate_control;<br>
uint64_t adjusted_fps_time_passed;<br>
<br>
- spice_assert(encoder->rate_control_is_active);<br>
+ spice_assert(rate_control_is_active(encoder));<br>
<br>
adjusted_fps_time_passed = (now - rate_control->adjusted_fps_start_time) / 1000 / 1000;<br>
<br>
@@ -734,7 +738,7 @@ int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,<br>
{<br>
uint32_t quality;<br>
<br>
- if (encoder->rate_control_is_active) {<br>
+ if (rate_control_is_active(encoder)) {<br>
MJpegEncoderRateControl *rate_control = &encoder->rate_control;<br>
struct timespec time;<br>
uint64_t now;<br>
@@ -1131,7 +1135,7 @@ void mjpeg_encoder_client_stream_report(MJpegEncoder *encoder,<br>
end_frame_mm_time - start_frame_mm_time,<br>
end_frame_delay, audio_delay);<br>
<br>
- if (!encoder->rate_control_is_active) {<br>
+ if (!rate_control_is_active(encoder)) {<br>
spice_debug("rate control was not activated: ignoring");<br>
return;<br>
}<br>
diff --git a/server/mjpeg_encoder.h b/server/mjpeg_encoder.h<br>
index 741ea1c..d584b92 100644<br>
--- a/server/mjpeg_encoder.h<br>
+++ b/server/mjpeg_encoder.h<br>
@@ -49,7 +49,7 @@ typedef struct MJpegEncoderStats {<br>
double avg_quality;<br>
} MJpegEncoderStats;<br>
<br>
-MJpegEncoder *mjpeg_encoder_new(int bit_rate_control, uint64_t starting_bit_rate,<br>
+MJpegEncoder *mjpeg_encoder_new(uint64_t starting_bit_rate,<br>
MJpegEncoderRateControlCbs *cbs, void *opaque);<br>
void mjpeg_encoder_destroy(MJpegEncoder *encoder);<br>
<br>
diff --git a/server/red_worker.c b/server/red_worker.c<br>
index 5deb30b..e0ff8e9 100644<br>
--- a/server/red_worker.c<br>
+++ b/server/red_worker.c<br>
@@ -3100,9 +3100,9 @@ static void red_display_create_stream(DisplayChannelClient *dcc, Stream *stream)<br>
mjpeg_cbs.update_client_playback_delay = red_stream_update_client_playback_latency;<br>
<br>
initial_bit_rate = red_stream_get_initial_bit_rate(dcc, stream);<br>
- agent->mjpeg_encoder = mjpeg_encoder_new(TRUE, initial_bit_rate, &mjpeg_cbs, agent);<br>
+ agent->mjpeg_encoder = mjpeg_encoder_new(initial_bit_rate, &mjpeg_cbs, agent);<br>
} else {<br>
- agent->mjpeg_encoder = mjpeg_encoder_new(FALSE, 0, NULL, NULL);<br>
+ agent->mjpeg_encoder = mjpeg_encoder_new(0, NULL, NULL);<br>
}<br>
red_channel_client_pipe_add(&dcc->common.base, &agent->create_item);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.1.4<br>
<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Marc-André Lureau</div>
</div>