Commit c090201c authored by Sebastian Rasmussen's avatar Sebastian Rasmussen Committed by Sebastian Dröge

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.
parent 0249a73a
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment