mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-29 18:48:44 +00:00
video: Add an helper to extrapolate strides
Many of the legacy APIs, specifically in the Linux Kernel, have a single stride for the pictures. In this context, it is common to extrapolate the other strides based on the selected pixel format. Such function have been copy pasted from video4linux2 plugin into wayland, kms and v4l2codecs plugins. This patch implements a generalized from of that function and make it available to everyone through the video library. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1567>
This commit is contained in:
parent
c9b127dae3
commit
fa1f042d1d
2 changed files with 42 additions and 0 deletions
|
@ -7565,6 +7565,44 @@ gst_video_format_info_component (const GstVideoFormatInfo * info, guint plane,
|
|||
components[c] = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_video_format_info_extrapolate_stride:
|
||||
* @info: #GstVideoFormatInfo
|
||||
* @plane: a plane number
|
||||
* @stride: The fist plane stride
|
||||
*
|
||||
* Extrapolate @plane stride from the first stride of an image. This helper is
|
||||
* useful to support legacy API were only one stride is supported.
|
||||
*
|
||||
* Returns: The extrapolated stride for @plane
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
gint
|
||||
gst_video_format_info_extrapolate_stride (const GstVideoFormatInfo * finfo,
|
||||
gint plane, gint stride)
|
||||
{
|
||||
gint estride;
|
||||
gint comp[GST_VIDEO_MAX_COMPONENTS];
|
||||
gint i;
|
||||
|
||||
/* there is nothing to extrapolate on first plane */
|
||||
if (plane == 0)
|
||||
return stride;
|
||||
|
||||
gst_video_format_info_component (finfo, plane, comp);
|
||||
|
||||
/* For now, all planar formats have a single component on first plane, but
|
||||
* if there was a planar format with more, we'd have to make a ratio of the
|
||||
* number of component on the first plane against the number of component on
|
||||
* the current plane. */
|
||||
estride = 0;
|
||||
for (i = 0; comp[i] >= 0; i++)
|
||||
estride += GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (finfo, comp[i], stride);
|
||||
|
||||
return estride;
|
||||
}
|
||||
|
||||
struct RawVideoFormats
|
||||
{
|
||||
GstVideoFormat *formats;
|
||||
|
|
|
@ -711,6 +711,10 @@ struct _GstVideoFormatInfo {
|
|||
GST_VIDEO_API
|
||||
void gst_video_format_info_component (const GstVideoFormatInfo *info, guint plane, gint components[GST_VIDEO_MAX_COMPONENTS]);
|
||||
|
||||
GST_VIDEO_API
|
||||
gint gst_video_format_info_extrapolate_stride (const GstVideoFormatInfo * finfo,
|
||||
gint plane, gint stride);
|
||||
|
||||
/* format properties */
|
||||
|
||||
GST_VIDEO_API
|
||||
|
|
Loading…
Reference in a new issue