mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
video-info: respect stride alignment
Increase the left padding so that we don't cause stride alignments later when we apply the padding. https://bugzilla.gnome.org/show_bug.cgi?id=694299
This commit is contained in:
parent
fad4589579
commit
5732ced692
1 changed files with 27 additions and 4 deletions
|
@ -730,15 +730,38 @@ gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align)
|
|||
GST_LOG ("padding %u-%ux%u-%u", align->padding_top,
|
||||
align->padding_left, align->padding_right, align->padding_bottom);
|
||||
|
||||
/* add the padding */
|
||||
padded_width = width + align->padding_left + align->padding_right;
|
||||
padded_height = height + align->padding_top + align->padding_bottom;
|
||||
|
||||
n_planes = GST_VIDEO_INFO_N_PLANES (info);
|
||||
|
||||
if (GST_VIDEO_FORMAT_INFO_HAS_PALETTE (vinfo))
|
||||
n_planes--;
|
||||
|
||||
/* first make sure the left padding does not cause alignment problems later */
|
||||
do {
|
||||
GST_LOG ("left padding %u", align->padding_left);
|
||||
aligned = TRUE;
|
||||
for (i = 0; i < n_planes; i++) {
|
||||
gint hedge;
|
||||
|
||||
/* this is the amout of pixels to add as left padding */
|
||||
hedge = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vinfo, i, align->padding_left);
|
||||
hedge *= GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, i);
|
||||
|
||||
GST_LOG ("plane %d, padding %d, alignment %u", i, hedge,
|
||||
align->stride_align[i]);
|
||||
aligned &= (hedge & align->stride_align[i]) == 0;
|
||||
}
|
||||
if (aligned)
|
||||
break;
|
||||
|
||||
GST_LOG ("unaligned padding, increasing padding");
|
||||
/* increase padded_width */
|
||||
align->padding_left += align->padding_left & ~(align->padding_left - 1);
|
||||
} while (!aligned);
|
||||
|
||||
/* add the padding */
|
||||
padded_width = width + align->padding_left + align->padding_right;
|
||||
padded_height = height + align->padding_top + align->padding_bottom;
|
||||
|
||||
do {
|
||||
GST_LOG ("padded dimension %u-%u", padded_width, padded_height);
|
||||
|
||||
|
|
Loading…
Reference in a new issue