[Spice-devel] [client v14 23/29] spice-gtk: Optimize handling of the decoded frame buffer

Pavel Grunt pgrunt at redhat.com
Fri May 6 09:54:04 UTC 2016


On Wed, 2016-05-04 at 11:44 +0200, Francois Gouget wrote:
> The MJPEG decoder does not need a zero-filled buffer.
> 
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
> ---
>  src/channel-display-mjpeg.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/channel-display-mjpeg.c b/src/channel-display-mjpeg.c
> index c7e1c6f..927827b 100644
> --- a/src/channel-display-mjpeg.c
> +++ b/src/channel-display-mjpeg.c
> @@ -39,6 +39,7 @@ typedef struct MJpegDecoder {
>      /* ---------- Output frame data ---------- */
>  
>      uint8_t *out_frame;
> +    uint32_t out_size;
>  } MJpegDecoder;
>  
>  
> @@ -85,8 +86,12 @@ static uint8_t* mjpeg_decoder_decode_frame(VideoDecoder
> *video_decoder,
>  
>      decoder->frame_msg = frame_msg;
>      stream_get_dimensions(decoder->base.stream, frame_msg, &width, &height);
> -    g_free(decoder->out_frame);
> -    dest = decoder->out_frame = g_malloc0(width * height * 4);
> +    if (decoder->out_size < width * height * 4) {
> +        g_free(decoder->out_frame);
> +        decoder->out_size = width * height * 4;
> +        decoder->out_frame = g_malloc(decoder->out_size);
> +    }
> +    dest = decoder->out_frame;
>  
>      jpeg_read_header(&decoder->mjpeg_cinfo, 1);
>  #ifdef JCS_EXTENSIONS


More information about the Spice-devel mailing list