videopool: improve alignment
Align each plane instead of each component, we might otherwise apply the alignment adjustement twice if a plane contains multiple components.
This commit is contained in:
parent
2bffebcb02
commit
ca77174f91
@ -101,7 +101,7 @@ gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align)
|
|||||||
const GstVideoFormatInfo *vinfo = info->finfo;
|
const GstVideoFormatInfo *vinfo = info->finfo;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint padded_width, padded_height;
|
gint padded_width, padded_height;
|
||||||
gint i, n_comp;
|
gint i, n_planes;
|
||||||
|
|
||||||
width = GST_VIDEO_INFO_WIDTH (info);
|
width = GST_VIDEO_INFO_WIDTH (info);
|
||||||
height = GST_VIDEO_INFO_HEIGHT (info);
|
height = GST_VIDEO_INFO_HEIGHT (info);
|
||||||
@ -119,24 +119,30 @@ gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align)
|
|||||||
info->width = width;
|
info->width = width;
|
||||||
info->height = height;
|
info->height = height;
|
||||||
|
|
||||||
n_comp = GST_VIDEO_INFO_N_COMPONENTS (info);
|
n_planes = GST_VIDEO_INFO_N_PLANES (info);
|
||||||
if (GST_VIDEO_FORMAT_INFO_HAS_PALETTE (vinfo))
|
if (GST_VIDEO_FORMAT_INFO_HAS_PALETTE (vinfo))
|
||||||
n_comp--;
|
n_planes--;
|
||||||
|
|
||||||
/* FIXME, not quite correct, NV12 would apply the vedge twice on the second
|
for (i = 0; i < n_planes; i++) {
|
||||||
* plane */
|
gint vedge, hedge, comp;
|
||||||
for (i = 0; i < n_comp; i++) {
|
|
||||||
gint vedge, hedge, plane;
|
|
||||||
|
|
||||||
hedge = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vinfo, i, align->padding_left);
|
/* Find the component for this plane, FIXME, we assume the plane number and
|
||||||
vedge = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (vinfo, i, align->padding_top);
|
* component number is the same for now, for scaling the dimensions this is
|
||||||
plane = GST_VIDEO_FORMAT_INFO_PLANE (vinfo, i);
|
* currently true for all formats but it might not be when adding new
|
||||||
|
* formats. We might need to add a plane subsamling in the format info to
|
||||||
|
* make this more generic or maybe use a plane -> component mapping. */
|
||||||
|
comp = i;
|
||||||
|
|
||||||
GST_DEBUG ("plane %d: hedge %d vedge %d align %d stride %d", plane, hedge,
|
hedge =
|
||||||
vedge, align->stride_align[i], info->stride[plane]);
|
GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vinfo, comp, align->padding_left);
|
||||||
|
vedge =
|
||||||
|
GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (vinfo, comp, align->padding_top);
|
||||||
|
|
||||||
info->offset[plane] += (vedge * info->stride[plane]) +
|
GST_DEBUG ("plane %d: comp: %d, hedge %d vedge %d align %d stride %d", i,
|
||||||
(hedge * GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, i));
|
comp, hedge, vedge, align->stride_align[i], info->stride[i]);
|
||||||
|
|
||||||
|
info->offset[i] += (vedge * info->stride[i]) +
|
||||||
|
(hedge * GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, comp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user