From c090201ca59f4d16df8af7390472b5eebfa86cab Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Thu, 24 Nov 2011 13:58:01 +0100 Subject: [PATCH] rtpjpegpay: Ceil jpeg dimensions, instead of floor A JPEG image inside an RTP stream has a preceeding RFC2435 header that conveys width/height. The dimensions in this header are limited to be multiples of 8. Since JPEG uses an MCU of 8x8 pixels any image must already indirectly have image data dimensions that are rounded up in order to contain enough data to render the image. Therefore this fix safely rounds the image dimensions in the RFC2435 header up to the closest multiple of 8. --- gst/rtp/gstrtpjpegpay.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gst/rtp/gstrtpjpegpay.c b/gst/rtp/gstrtpjpegpay.c index ff1fe7e..eae2840 100644 --- a/gst/rtp/gstrtpjpegpay.c +++ b/gst/rtp/gstrtpjpegpay.c @@ -314,13 +314,13 @@ gst_rtp_jpeg_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps) if (height <= 0 || height > 2040) goto invalid_dimension; } - pay->height = height / 8; + pay->height = GST_ROUND_UP_8 (height) / 8; if (gst_structure_get_int (caps_structure, "width", &width)) { if (width <= 0 || width > 2040) goto invalid_dimension; } - pay->width = width / 8; + pay->width = GST_ROUND_UP_8 (width) / 8; gst_basertppayload_set_options (basepayload, "video", TRUE, "JPEG", 90000); res = gst_basertppayload_set_outcaps (basepayload, NULL); @@ -459,8 +459,8 @@ gst_rtp_jpeg_pay_read_sof (GstRtpJPEGPay * pay, const guint8 * data, if (width == 0 || width > 2040) goto invalid_dimension; - pay->height = height / 8; - pay->width = width / 8; + pay->height = GST_ROUND_UP_8 (height) / 8; + pay->width = GST_ROUND_UP_8 (width) / 8; /* we only support 3 components */ if (data[off++] != 3) -- 2.7.4