[Spice-devel] [PATCH spice-server 24/28] server/red_worker.c: use the bit rate of old streams as a start point for new streams
Alon Levy
alevy at redhat.com
Sun Apr 14 06:35:28 PDT 2013
On Tue, Feb 26, 2013 at 01:04:10PM -0500, Yonit Halperin wrote:
> mjpeg_encoder modify the initial bit we supply it, according to the
> client feedback. If it reaches a bit rate which is higher than the
> initial one, we use the higher bit rate as the new bit rate estimation.
ACK to this and the rest.
> ---
> server/mjpeg_encoder.c | 5 +++++
> server/mjpeg_encoder.h | 2 ++
> server/red_worker.c | 16 +++++++++++++++-
> 3 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
> index 277794b..7825955 100644
> --- a/server/mjpeg_encoder.c
> +++ b/server/mjpeg_encoder.c
> @@ -1237,3 +1237,8 @@ static void mjpeg_encoder_process_server_drops(MJpegEncoder *encoder)
> server_state->num_frames_encoded = 0;
> server_state->num_frames_dropped = 0;
> }
> +
> +uint64_t mjpeg_encoder_get_bit_rate(MJpegEncoder *encoder)
> +{
> + return encoder->rate_control.byte_rate * 8;
> +}
> diff --git a/server/mjpeg_encoder.h b/server/mjpeg_encoder.h
> index 0ee2e96..310d289 100644
> --- a/server/mjpeg_encoder.h
> +++ b/server/mjpeg_encoder.h
> @@ -102,4 +102,6 @@ void mjpeg_encoder_client_stream_report(MJpegEncoder *encoder,
> */
> void mjpeg_encoder_notify_server_frame_drop(MJpegEncoder *encoder);
>
> +uint64_t mjpeg_encoder_get_bit_rate(MJpegEncoder *encoder);
> +
> #endif
> diff --git a/server/red_worker.c b/server/red_worker.c
> index acf391d..954b950 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -693,6 +693,7 @@ struct DisplayChannelClient {
> StreamAgent stream_agents[NUM_STREAMS];
> int use_mjpeg_encoder_rate_control;
> uint32_t streams_max_latency;
> + uint64_t streams_max_bit_rate;
> };
>
> struct DisplayChannel {
> @@ -2616,6 +2617,16 @@ static void red_stop_stream(RedWorker *worker, Stream *stream)
> region_clear(&stream_agent->vis_region);
> region_clear(&stream_agent->clip);
> spice_assert(!pipe_item_is_linked(&stream_agent->destroy_item));
> + if (stream_agent->mjpeg_encoder && dcc->use_mjpeg_encoder_rate_control) {
> + uint64_t stream_bit_rate = mjpeg_encoder_get_bit_rate(stream_agent->mjpeg_encoder);
> +
> + if (stream_bit_rate > dcc->streams_max_bit_rate) {
> + spice_debug("old max-bit-rate=%.2f new=%.2f",
> + dcc->streams_max_bit_rate / 8.0 / 1024.0 / 1024.0,
> + stream_bit_rate / 8.0 / 1024.0 / 1024.0);
> + dcc->streams_max_bit_rate = stream_bit_rate;
> + }
> + }
> stream->refs++;
> red_channel_client_pipe_add(&dcc->common.base, &stream_agent->destroy_item);
> }
> @@ -2874,10 +2885,13 @@ static uint64_t red_stream_get_initial_bit_rate(DisplayChannelClient *dcc,
> mcc = red_client_get_main(dcc->common.base.client);
> max_bit_rate = main_channel_client_get_bitrate_per_sec(mcc);
>
> + if (max_bit_rate > dcc->streams_max_bit_rate) {
> + dcc->streams_max_bit_rate = max_bit_rate;
> + }
>
> /* dividing the available bandwidth among the active streams, and saving
> * (1-RED_STREAM_CHANNEL_CAPACITY) of it for other messages */
> - return (RED_STREAM_CHANNEL_CAPACITY * max_bit_rate *
> + return (RED_STREAM_CHANNEL_CAPACITY * dcc->streams_max_bit_rate *
> stream->width * stream->height) / dcc->common.worker->streams_size_total;
> }
>
> --
> 1.8.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list