video: remove intermediate Plane structure

Remove the GstVideoPlane structure and move the fields directly into the
GstVideoInfo structure. This makes things a little easier to read and also makes
it more likely that we can pass the stride array to external libraries.
This commit is contained in:
Wim Taymans 2011-06-20 11:25:58 +02:00
parent 5eeb468c75
commit 6d9e76f2de
9 changed files with 83 additions and 87 deletions

View file

@ -1442,7 +1442,7 @@ gst_base_text_overlay_shade_planar_Y (GstBaseTextOverlay * overlay,
gint i, j, dest_stride;
guint8 *dest_ptr;
dest_stride = dest->info.plane[0].stride;
dest_stride = dest->info.stride[0];
dest_ptr = dest->data[0];
x0 = CLAMP (x0 - BOX_XPAD, 0, overlay->width);
@ -1468,7 +1468,7 @@ gst_base_text_overlay_shade_packed_Y (GstBaseTextOverlay * overlay,
guint dest_stride, pixel_stride, component_offset;
guint8 *dest_ptr;
dest_stride = dest->info.plane[0].stride;
dest_stride = dest->info.stride[0];
dest_ptr = dest->data[0];
pixel_stride = gst_video_format_get_pixel_stride (dest->info.format, 0);
@ -1591,9 +1591,9 @@ gst_base_text_overlay_blit_NV12_NV21 (GstBaseTextOverlay * overlay,
y_pixels = dest->data[0];
u_pixels = dest->data[1];
v_pixels = dest->data[2];
y_stride = dest->info.plane[0].stride;
u_stride = dest->info.plane[1].stride;
v_stride = dest->info.plane[2].stride;
y_stride = dest->info.stride[0];
u_stride = dest->info.stride[1];
v_stride = dest->info.stride[2];
gst_base_text_overlay_blit_1 (overlay, y_pixels, xpos, ypos,
overlay->text_image, y_stride);
@ -1617,9 +1617,9 @@ gst_base_text_overlay_blit_I420 (GstBaseTextOverlay * overlay,
y_pixels = dest->data[0];
u_pixels = dest->data[1];
v_pixels = dest->data[2];
y_stride = dest->info.plane[0].stride;
u_stride = dest->info.plane[1].stride;
v_stride = dest->info.plane[2].stride;
y_stride = dest->info.stride[0];
u_stride = dest->info.stride[1];
v_stride = dest->info.stride[2];
gst_base_text_overlay_blit_1 (overlay, y_pixels, xpos, ypos,
overlay->text_image, y_stride);

View file

@ -1135,9 +1135,9 @@ theora_handle_image (GstTheoraDec * dec, th_ycbcr_buffer buf, GstBuffer ** out)
height =
gst_video_format_get_component_height (frame.info.format, plane,
dec->vinfo.height);
stride = frame.info.plane[plane].stride;
dest = frame.data[plane];
stride = GST_VIDEO_FRAME_STRIDE (&frame, plane);
dest = GST_VIDEO_FRAME_DATA (&frame, plane);
src = buf[plane].data;
src += ((height == dec->vinfo.height) ? dec->offset_y : dec->offset_y / 2)

View file

@ -1028,8 +1028,8 @@ theora_enc_init_buffer (th_ycbcr_buffer buf, th_info * info,
buf[i].height =
gst_video_format_get_component_height (format, i, info->frame_height);
buf[i].data = frame->data[i];
buf[i].stride = frame->info.plane[i].stride;
buf[i].data = GST_VIDEO_FRAME_DATA (frame, i);
buf[i].stride = GST_VIDEO_FRAME_STRIDE (frame, i);
}
}

View file

@ -46,7 +46,7 @@ gst_buffer_add_meta_video (GstBuffer * buffer, GstVideoFlags flags,
gst_video_info_set_format (&info, format, width, height);
meta = gst_buffer_add_meta_video_full (buffer, flags, format, width, height,
info.n_planes, info.plane);
info.n_planes, info.offset, info.stride);
return meta;
}
@ -54,7 +54,8 @@ gst_buffer_add_meta_video (GstBuffer * buffer, GstVideoFlags flags,
GstMetaVideo *
gst_buffer_add_meta_video_full (GstBuffer * buffer, GstVideoFlags flags,
GstVideoFormat format, guint width, guint height,
guint n_planes, GstVideoPlane plane[GST_VIDEO_MAX_PLANES])
guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
gint stride[GST_VIDEO_MAX_PLANES])
{
GstMetaVideo *meta;
guint i;
@ -69,8 +70,10 @@ gst_buffer_add_meta_video_full (GstBuffer * buffer, GstVideoFlags flags,
meta->buffer = buffer;
meta->n_planes = n_planes;
for (i = 0; i < n_planes; i++)
meta->plane[i] = plane[i];
for (i = 0; i < n_planes; i++) {
meta->offset[i] = offset[i];
meta->stride[i] = stride[i];
}
return meta;
}
@ -118,8 +121,8 @@ gst_meta_video_map (GstMetaVideo * meta, guint plane, gint * stride,
write = (flags & GST_MAP_WRITE) != 0;
g_return_val_if_fail (!write || gst_buffer_is_writable (buffer), NULL);
offset = meta->plane[plane].offset;
*stride = meta->plane[plane].stride;
offset = meta->offset[plane];
*stride = meta->stride[plane];
/* find the memory block for this plane, this is the memory block containing
* the plane offset */
mem = find_mem_for_offset (buffer, &offset, flags);
@ -144,7 +147,7 @@ gst_meta_video_unmap (GstMetaVideo * meta, guint plane, gpointer data)
buffer = meta->buffer;
g_return_val_if_fail (buffer != NULL, FALSE);
offset = meta->plane[plane].offset;
offset = meta->offset[plane];
mem = find_mem_for_offset (buffer, &offset, GST_MAP_READ);
base = data;

View file

@ -30,14 +30,14 @@ G_BEGIN_DECLS
#define GST_META_INFO_VIDEO (gst_meta_video_get_info())
typedef struct _GstMetaVideo GstMetaVideo;
typedef struct _GstMetaVideoPlane GstMetaVideoPlane;
/**
* GstMetaVideo:
* @meta: parent #GstMeta
* @flags: additional video flags
* @n_planes: the number of planes in the image
* @plane: array of #GstMetaVideoPlane
* @offset: array of offsets for the planes
* @stride: array of strides for the planes
* @map: map the memory of a plane
* @unmap: unmap the memory of a plane
*
@ -54,7 +54,8 @@ struct _GstMetaVideo {
guint height;
guint n_planes;
GstVideoPlane plane[GST_VIDEO_MAX_PLANES];
gsize offset[GST_VIDEO_MAX_PLANES];
gint stride[GST_VIDEO_MAX_PLANES];
gpointer (*map) (GstMetaVideo *meta, guint plane, gint *stride,
GstMapFlags flags);
@ -68,7 +69,8 @@ GstMetaVideo * gst_buffer_add_meta_video (GstBuffer *buffer, GstVideoFlags
GstVideoFormat format, guint width, guint height);
GstMetaVideo * gst_buffer_add_meta_video_full (GstBuffer *buffer, GstVideoFlags flags,
GstVideoFormat format, guint width, guint height,
guint n_planes, GstVideoPlane plane[GST_VIDEO_MAX_PLANES]);
guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
gint stride[GST_VIDEO_MAX_PLANES]);
gpointer gst_meta_video_map (GstMetaVideo *meta, guint plane, gint *stride,
GstMapFlags flags);

View file

@ -724,7 +724,7 @@ gst_video_info_set_format (GstVideoInfo * info, GstVideoFormat format,
fill_planes (info);
for (i = 0; i < info->n_planes; i++) {
info->plane[i].stride = get_stride (format, i, info->width);
info->stride[i] = get_stride (format, i, info->width);
}
}
@ -908,7 +908,7 @@ gst_video_frame_map (GstVideoFrame * frame, GstVideoInfo * info,
for (i = 0; i < info->n_planes; i++) {
frame->data[i] =
gst_meta_video_map (meta, i, &frame->info.plane[i].stride, flags);
gst_meta_video_map (meta, i, &frame->info.stride[i], flags);
}
} else {
/* copy the info */
@ -922,7 +922,7 @@ gst_video_frame_map (GstVideoFrame * frame, GstVideoInfo * info,
/* set up pointers */
for (i = 0; i < info->n_planes; i++) {
frame->data[i] = data + info->plane[i].offset;
frame->data[i] = data + info->offset[i];
}
}
return TRUE;
@ -961,7 +961,7 @@ gst_video_frame_unmap (GstVideoFrame * frame)
guint8 *data;
data = frame->data[0];
data -= frame->info.plane[0].offset;
data -= frame->info.offset[0];
gst_buffer_unmap (buffer, data, -1);
}
}
@ -1571,74 +1571,74 @@ fill_planes (GstVideoInfo * info)
case GST_VIDEO_FORMAT_ARGB64:
case GST_VIDEO_FORMAT_AYUV64:
info->n_planes = 1;
info->plane[0].offset = 0;
info->offset[0] = 0;
break;
case GST_VIDEO_FORMAT_I420:
info->n_planes = 3;
info->plane[0].offset = 0;
info->plane[1].offset = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
info->plane[2].offset = info->plane[1].offset +
info->offset[0] = 0;
info->offset[1] = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
info->offset[2] = info->offset[1] +
GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
(GST_ROUND_UP_2 (height) / 2);
break;
case GST_VIDEO_FORMAT_YV12: /* same as I420, but plane 1+2 swapped */
info->n_planes = 3;
info->plane[0].offset = 0;
info->plane[2].offset = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
info->plane[1].offset = info->plane[2].offset +
info->offset[0] = 0;
info->offset[2] = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
info->offset[1] = info->offset[2] +
GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
(GST_ROUND_UP_2 (height) / 2);
break;
case GST_VIDEO_FORMAT_Y41B:
info->n_planes = 3;
info->plane[0].offset = 0;
info->plane[1].offset = GST_ROUND_UP_4 (width) * height;
info->plane[2].offset = (GST_ROUND_UP_4 (width) +
info->offset[0] = 0;
info->offset[1] = GST_ROUND_UP_4 (width) * height;
info->offset[2] = (GST_ROUND_UP_4 (width) +
(GST_ROUND_UP_16 (width) / 4)) * height;
break;
case GST_VIDEO_FORMAT_Y42B:
info->n_planes = 3;
info->plane[0].offset = 0;
info->plane[1].offset = GST_ROUND_UP_4 (width) * height;
info->plane[2].offset =
info->offset[0] = 0;
info->offset[1] = GST_ROUND_UP_4 (width) * height;
info->offset[2] =
(GST_ROUND_UP_4 (width) + (GST_ROUND_UP_8 (width) / 2)) * height;
break;
case GST_VIDEO_FORMAT_Y444:
info->n_planes = 3;
info->plane[0].offset = 0;
info->plane[1].offset = GST_ROUND_UP_4 (width) * height;
info->plane[2].offset = GST_ROUND_UP_4 (width) * height * 2;
info->offset[0] = 0;
info->offset[1] = GST_ROUND_UP_4 (width) * height;
info->offset[2] = GST_ROUND_UP_4 (width) * height * 2;
break;
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
info->n_planes = 2;
info->plane[0].offset = 0;
info->plane[1].offset = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
info->offset[0] = 0;
info->offset[1] = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
break;
case GST_VIDEO_FORMAT_A420:
info->n_planes = 4;
info->plane[0].offset = 0;
info->plane[1].offset = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
info->plane[2].offset = info->plane[1].offset +
info->offset[0] = 0;
info->offset[1] = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
info->offset[2] = info->offset[1] +
GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
(GST_ROUND_UP_2 (height) / 2);
info->plane[3].offset = info->plane[2].offset +
info->offset[3] = info->offset[2] +
GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
(GST_ROUND_UP_2 (height) / 2);
break;
case GST_VIDEO_FORMAT_YUV9:
info->n_planes = 3;
info->plane[0].offset = 0;
info->plane[1].offset = GST_ROUND_UP_4 (width) * height;
info->plane[2].offset = info->plane[1].offset +
info->offset[0] = 0;
info->offset[1] = GST_ROUND_UP_4 (width) * height;
info->offset[2] = info->offset[1] +
GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4) *
(GST_ROUND_UP_4 (height) / 4);
break;
case GST_VIDEO_FORMAT_YVU9:
info->n_planes = 3;
info->plane[0].offset = 0;
info->plane[2].offset = GST_ROUND_UP_4 (width) * height;
info->plane[1].offset = info->plane[2].offset +
info->offset[0] = 0;
info->offset[2] = GST_ROUND_UP_4 (width) * height;
info->offset[1] = info->offset[2] +
GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4) *
(GST_ROUND_UP_4 (height) / 4);
break;

View file

@ -143,7 +143,6 @@ int gst_video_format_get_component_depth (GstVideoFormat format,
int gst_video_format_get_pixel_stride (GstVideoFormat format,
int component) G_GNUC_CONST;
typedef struct _GstVideoPlane GstVideoPlane;
typedef struct _GstVideoInfo GstVideoInfo;
typedef struct _GstVideoFrame GstVideoFrame;
@ -171,19 +170,6 @@ typedef enum {
#define GST_VIDEO_MAX_PLANES 4
/**
* GstVideoPlane:
* @offset: offset of the first pixel in the buffer memory region
* @stride: stride of the image lines. Can be negative when the image is
* upside-down
*
* Information for one video plane.
*/
struct _GstVideoPlane {
gsize offset;
gint stride;
};
/**
* GstVideoInfo:
* @flags: additional video flags
@ -205,7 +191,8 @@ struct _GstVideoPlane {
* @fps_n: the framerate numerator
* @fps_d: the framerate demnominator
* @n_planes: the number of planes in the image
* @plane: array of #GstMetaVideoPlane
* @offset: offsets of the planes
* @stride: strides of the planes
*
* Extra buffer metadata describing image properties
*/
@ -226,9 +213,25 @@ struct _GstVideoInfo {
guint fps_d;
guint n_planes;
GstVideoPlane plane[GST_VIDEO_MAX_PLANES];
gsize offset[GST_VIDEO_MAX_PLANES];
gint stride[GST_VIDEO_MAX_PLANES];
};
void gst_video_info_init (GstVideoInfo *info);
void gst_video_info_set_format (GstVideoInfo *info, GstVideoFormat format,
guint width, guint height);
gboolean gst_video_info_from_caps (GstVideoInfo *info, const GstCaps * caps);
GstCaps * gst_video_info_to_caps (GstVideoInfo *info);
gboolean gst_video_info_convert (GstVideoInfo *info,
GstFormat src_format,
gint64 src_value,
GstFormat dest_format,
gint64 *dest_value);
/**
* GstVideoFrame:
* @info: the #GstVideoInfo
@ -246,20 +249,8 @@ struct _GstVideoFrame {
guint8 *data[GST_VIDEO_MAX_PLANES];
};
void gst_video_info_init (GstVideoInfo *info);
void gst_video_info_set_format (GstVideoInfo *info, GstVideoFormat format,
guint width, guint height);
gboolean gst_video_info_from_caps (GstVideoInfo *info, const GstCaps * caps);
GstCaps * gst_video_info_to_caps (GstVideoInfo *info);
gboolean gst_video_info_convert (GstVideoInfo *info,
GstFormat src_format,
gint64 src_value,
GstFormat dest_format,
gint64 *dest_value);
#define GST_VIDEO_FRAME_DATA(f,c) ((f)->data[c])
#define GST_VIDEO_FRAME_STRIDE(f,c) ((f)->info.stride[c])
gboolean gst_video_frame_map (GstVideoFrame *frame, GstVideoInfo *info,
GstBuffer *buffer, GstMapFlags flags);

View file

@ -177,7 +177,7 @@ videoconvert_convert_convert (VideoConvert * convert,
/* Line conversion to AYUV */
#define FRAME_GET_STRIDE(dir, comp) \
((dir)->info.plane[comp].stride)
((dir)->info.stride[comp])
#define FRAME_GET_LINE(dir, comp, line) \
((dir)->data[comp] + FRAME_GET_STRIDE (dir, comp) * (line))

View file

@ -912,7 +912,7 @@ gst_video_scale_setup_vs_image (VSImage * image, GstVideoFrame * frame,
}
image->real_pixels = frame->data[component];
image->stride = frame->info.plane[component].stride;
image->stride = frame->info.stride[component];
image->pixels =
image->real_pixels + image->border_top * image->stride +