mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
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.
This commit is contained in:
parent
0249a73a3e
commit
c090201ca5
1 changed files with 4 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue