From: Nicolas Dufresne Date: Tue, 3 Mar 2015 20:22:38 +0000 (-0500) Subject: gloverlay: Fix upside down and miss-aligned JPEG X-Git-Tag: 1.19.3~511^2~1989^2~1024 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2729949b39e0eae8ec0776fd3e5bc358c5d9a3d3;p=platform%2Fupstream%2Fgstreamer.git gloverlay: Fix upside down and miss-aligned JPEG LibJPEG uses macroblock of 8x8 sample. In this element we use RGB and Y444, two 24bit formats that are stored in 32bit pixels. This mean we have 32x32 bytes macroblocks. For this reason, we need to allocate our buffer slightly larger. We also need to pass the line pointer in the right order, otherwise the image endup upside-down. https://bugzilla.gnome.org/show_bug.cgi?id=745109 --- diff --git a/ext/gl/gstgloverlay.c b/ext/gl/gstgloverlay.c index de32482..1371264 100644 --- a/ext/gl/gstgloverlay.c +++ b/ext/gl/gstgloverlay.c @@ -610,6 +610,7 @@ gst_gl_overlay_load_jpeg (GstGLFilter * filter) { GstGLOverlay *overlay = GST_GL_OVERLAY (filter); GstVideoInfo v_info; + GstVideoAlignment v_align; GstMapInfo map_info; FILE *fp = NULL; struct jpeg_decompress_struct cinfo; @@ -637,9 +638,13 @@ gst_gl_overlay_load_jpeg (GstGLFilter * filter) gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGB, overlay->image_width, overlay->image_height); + gst_video_alignment_reset (&v_align); + v_align.stride_align[0] = 32 - 1; + gst_video_info_align (&v_info, &v_align); + overlay->image_memory = (GstGLMemory *) gst_gl_memory_alloc (filter->context, NULL, &v_info, 0, - NULL); + &v_align); if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info, GST_MAP_WRITE)) { @@ -647,9 +652,7 @@ gst_gl_overlay_load_jpeg (GstGLFilter * filter) } for (i = 0; i < overlay->image_height; ++i) { - j = (map_info.data + - (((int) overlay->image_height - (i + - 1)) * (int) overlay->image_width * cinfo.num_components)); + j = map_info.data + v_info.stride[0] * i; jpeg_read_scanlines (&cinfo, &j, 1); } jpeg_finish_decompress (&cinfo);