[Spice-devel] [spice v16 03/23] mjpeg: Use src_area as the authoritative source for the frame dimensions

Pavel Grunt pgrunt at redhat.com
Wed Jun 8 15:29:40 UTC 2016


Hi Francois,

On Tue, 2016-06-07 at 15:58 +0200, Francois Gouget wrote:
> Video frames correspond to QXL_DRAW_COPY operations where the frame area
> is defined by the SpiceCopy.src_area field.

Do you think it can have an effect on the bug:
 https://bugs.freedesktop.org/show_bug.cgi?id=94372

Thanks,
Pavel

> 
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
> ---
>  server/mjpeg-encoder.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
> index e3646db..7dcea50 100644
> --- a/server/mjpeg-encoder.c
> +++ b/server/mjpeg-encoder.c
> @@ -706,7 +706,7 @@ static void mjpeg_encoder_adjust_fps(MJpegEncoder
> *encoder, uint64_t now)
>   */
>  static int mjpeg_encoder_start_frame(MJpegEncoder *encoder,
>                                       SpiceBitmapFmt format,
> -                                     int width, int height,
> +                                     const SpiceRect *src,
>                                       uint8_t **dest, size_t *dest_len,
>                                       uint32_t frame_mm_time)
>  {
> @@ -777,10 +777,12 @@ static int mjpeg_encoder_start_frame(MJpegEncoder
> *encoder,
>          return VIDEO_ENCODER_FRAME_UNSUPPORTED;
>      }
>  
> +    encoder->cinfo.image_width = src->right - src->left;
> +    encoder->cinfo.image_height = src->bottom - src->top;
>      if (encoder->pixel_converter != NULL) {
> -        unsigned int stride = width * 3;
> +        JDIMENSION stride = encoder->cinfo.image_width * 3;
>          /* check for integer overflow */
> -        if (stride < width) {
> +        if (stride < encoder->cinfo.image_width) {
>              return VIDEO_ENCODER_FRAME_UNSUPPORTED;
>          }
>          if (encoder->row_size < stride) {
> @@ -790,9 +792,6 @@ static int mjpeg_encoder_start_frame(MJpegEncoder
> *encoder,
>      }
>  
>      spice_jpeg_mem_dest(&encoder->cinfo, dest, dest_len);
> -
> -    encoder->cinfo.image_width      = width;
> -    encoder->cinfo.image_height     = height;
>      jpeg_set_defaults(&encoder->cinfo);
>      encoder->cinfo.dct_method       = JDCT_IFAST;
>      quality = mjpeg_quality_samples[encoder->rate_control.quality_id];
> @@ -935,8 +934,7 @@ static int mjpeg_encoder_encode_frame(VideoEncoder
> *video_encoder,
>  {
>      MJpegEncoder *encoder = (MJpegEncoder*)video_encoder;
>  
> -    int ret = mjpeg_encoder_start_frame(encoder, bitmap->format,
> -                                        width, height,
> +    int ret = mjpeg_encoder_start_frame(encoder, bitmap->format, src,
>                                          outbuf, outbuf_size,
>                                          frame_mm_time);
>      if (ret != VIDEO_ENCODER_FRAME_ENCODE_DONE) {


More information about the Spice-devel mailing list