From: Wim Taymans Date: Mon, 20 Aug 2012 08:16:59 +0000 (+0200) Subject: videopool: improve alignment X-Git-Tag: 1.19.3~511^2~6004 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f56e1222dae16efe0ee6f60c86d18d117c0df28c;p=platform%2Fupstream%2Fgstreamer.git videopool: improve alignment Check the alignment of the strides in gst_video_info_align and increase the padding on the frame until the strides are aligned. --- diff --git a/gst-libs/gst/video/gstvideopool.c b/gst-libs/gst/video/gstvideopool.c index a231065..45d6fa6 100644 --- a/gst-libs/gst/video/gstvideopool.c +++ b/gst-libs/gst/video/gstvideopool.c @@ -102,6 +102,7 @@ gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align) gint width, height; gint padded_width, padded_height; gint i, n_planes; + gboolean aligned; width = GST_VIDEO_INFO_WIDTH (info); height = GST_VIDEO_INFO_HEIGHT (info); @@ -113,13 +114,31 @@ gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align) padded_width = width + align->padding_left + align->padding_right; padded_height = height + align->padding_top + align->padding_bottom; - gst_video_info_set_format (info, GST_VIDEO_INFO_FORMAT (info), - padded_width, padded_height); + n_planes = GST_VIDEO_INFO_N_PLANES (info); + do { + GST_LOG ("padded dimension %u-%u", padded_width, padded_height); + + gst_video_info_set_format (info, GST_VIDEO_INFO_FORMAT (info), + padded_width, padded_height); + + /* check alignment */ + aligned = TRUE; + for (i = 0; i < n_planes; i++) { + GST_LOG ("plane %d, stride %d, alignment %u", i, info->stride[i], + align->stride_align[i]); + aligned &= (info->stride[i] & align->stride_align[i]) == 0; + } + if (aligned) + break; + + GST_LOG ("unaligned strides, increasing dimension"); + /* increase padded_width */ + padded_width += padded_width & ~(padded_width - 1); + } while (!aligned); info->width = width; info->height = height; - n_planes = GST_VIDEO_INFO_N_PLANES (info); if (GST_VIDEO_FORMAT_INFO_HAS_PALETTE (vinfo)) n_planes--;