mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
video: Clean up interlaced flags and enums
There's a new GstVideoFrameFlags enum now that contains the frame specific flags only. GstVideoFlags does not contain the TFF/TFF/ONEFIELD flags anymore because these are strictly frame specific. Also add fallback to parse these fields from the GstBufferFlags in gst_video_frame_map() if there's no GstVideoMeta attached to the buffer.
This commit is contained in:
parent
131bf5fb47
commit
91ffe7dd5e
5 changed files with 52 additions and 34 deletions
|
@ -39,8 +39,8 @@ gst_video_meta_transform (GstBuffer * dest, GstMeta * meta,
|
|||
dmeta->buffer = dest;
|
||||
|
||||
GST_DEBUG ("copy video metadata");
|
||||
dmeta->flags = smeta->flags;
|
||||
dmeta->format = smeta->format;
|
||||
dmeta->frame_flags = smeta->frame_flags;
|
||||
dmeta->id = smeta->id;
|
||||
dmeta->width = smeta->width;
|
||||
dmeta->height = smeta->height;
|
||||
|
@ -164,8 +164,8 @@ default_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info)
|
|||
/**
|
||||
* gst_buffer_add_video_meta:
|
||||
* @buffer: a #GstBuffer
|
||||
* @flags: #GstVideoFlags
|
||||
* @format: a #GstVideoFormat
|
||||
* @frame_flags: #GstVideoFrameFlags
|
||||
* @width: the width
|
||||
* @height: the height
|
||||
*
|
||||
|
@ -178,16 +178,18 @@ default_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info)
|
|||
* Returns: the #GstVideoMeta on @buffer.
|
||||
*/
|
||||
GstVideoMeta *
|
||||
gst_buffer_add_video_meta (GstBuffer * buffer, GstVideoFlags flags,
|
||||
GstVideoFormat format, guint width, guint height)
|
||||
gst_buffer_add_video_meta (GstBuffer * buffer,
|
||||
GstVideoFormat format, GstVideoFrameFlags frame_flags, guint width,
|
||||
guint height)
|
||||
{
|
||||
GstVideoMeta *meta;
|
||||
GstVideoInfo info;
|
||||
|
||||
gst_video_info_set_format (&info, format, width, height);
|
||||
|
||||
meta = gst_buffer_add_video_meta_full (buffer, flags, format, width, height,
|
||||
info.finfo->n_planes, info.offset, info.stride);
|
||||
meta =
|
||||
gst_buffer_add_video_meta_full (buffer, format, frame_flags, width,
|
||||
height, info.finfo->n_planes, info.offset, info.stride);
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
@ -195,8 +197,8 @@ gst_buffer_add_video_meta (GstBuffer * buffer, GstVideoFlags flags,
|
|||
/**
|
||||
* gst_buffer_add_video_meta_full:
|
||||
* @buffer: a #GstBuffer
|
||||
* @flags: #GstVideoFlags
|
||||
* @format: a #GstVideoFormat
|
||||
* @frame_flags: #GstVideoFrameFlags
|
||||
* @width: the width
|
||||
* @height: the height
|
||||
* @n_planes: number of planes
|
||||
|
@ -208,9 +210,9 @@ gst_buffer_add_video_meta (GstBuffer * buffer, GstVideoFlags flags,
|
|||
* Returns: the #GstVideoMeta on @buffer.
|
||||
*/
|
||||
GstVideoMeta *
|
||||
gst_buffer_add_video_meta_full (GstBuffer * buffer, GstVideoFlags flags,
|
||||
GstVideoFormat format, guint width, guint height,
|
||||
guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
|
||||
gst_buffer_add_video_meta_full (GstBuffer * buffer,
|
||||
GstVideoFormat format, GstVideoFrameFlags frame_flags, guint width,
|
||||
guint height, guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
|
||||
gint stride[GST_VIDEO_MAX_PLANES])
|
||||
{
|
||||
GstVideoMeta *meta;
|
||||
|
@ -219,8 +221,8 @@ gst_buffer_add_video_meta_full (GstBuffer * buffer, GstVideoFlags flags,
|
|||
meta =
|
||||
(GstVideoMeta *) gst_buffer_add_meta (buffer, GST_VIDEO_META_INFO, NULL);
|
||||
|
||||
meta->flags = flags;
|
||||
meta->format = format;
|
||||
meta->frame_flags = frame_flags;
|
||||
meta->id = 0;
|
||||
meta->width = width;
|
||||
meta->height = height;
|
||||
|
|
|
@ -58,8 +58,8 @@ struct _GstVideoMeta {
|
|||
|
||||
GstBuffer *buffer;
|
||||
|
||||
GstVideoFlags flags;
|
||||
GstVideoFormat format;
|
||||
GstVideoFrameFlags frame_flags;
|
||||
gint id;
|
||||
guint width;
|
||||
guint height;
|
||||
|
@ -79,10 +79,10 @@ const GstMetaInfo * gst_video_meta_get_info (void);
|
|||
#define gst_buffer_get_video_meta(b) ((GstVideoMeta*)gst_buffer_get_meta((b),GST_VIDEO_META_API_TYPE))
|
||||
GstVideoMeta * gst_buffer_get_video_meta_id (GstBuffer *buffer, gint id);
|
||||
|
||||
GstVideoMeta * gst_buffer_add_video_meta (GstBuffer *buffer, GstVideoFlags flags,
|
||||
GstVideoFormat format, guint width, guint height);
|
||||
GstVideoMeta * gst_buffer_add_video_meta_full (GstBuffer *buffer, GstVideoFlags flags,
|
||||
GstVideoFormat format, guint width, guint height,
|
||||
GstVideoMeta * gst_buffer_add_video_meta (GstBuffer *buffer, GstVideoFormat format,
|
||||
GstVideoFrameFlags frame_flags, guint width, guint height);
|
||||
GstVideoMeta * gst_buffer_add_video_meta_full (GstBuffer *buffer, GstVideoFormat format,
|
||||
GstVideoFrameFlags frame_flags, guint width, guint height,
|
||||
guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
|
||||
gint stride[GST_VIDEO_MAX_PLANES]);
|
||||
|
||||
|
|
|
@ -260,7 +260,8 @@ video_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||
if (priv->add_videometa) {
|
||||
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
|
||||
|
||||
gst_buffer_add_video_meta_full (*buffer, 0, GST_VIDEO_INFO_FORMAT (info),
|
||||
gst_buffer_add_video_meta_full (*buffer, GST_VIDEO_INFO_FORMAT (info),
|
||||
GST_VIDEO_FRAME_FLAG_NONE,
|
||||
GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info),
|
||||
GST_VIDEO_INFO_N_PLANES (info), info->offset, info->stride);
|
||||
}
|
||||
|
|
|
@ -1030,12 +1030,15 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
|
|||
else
|
||||
meta = gst_buffer_get_video_meta_id (buffer, id);
|
||||
|
||||
/* copy the info */
|
||||
frame->info = *info;
|
||||
|
||||
if (meta) {
|
||||
frame->info.flags = meta->flags;
|
||||
frame->info.finfo = &formats[meta->format].info;
|
||||
frame->info.width = meta->width;
|
||||
frame->info.height = meta->height;
|
||||
frame->id = meta->id;
|
||||
frame->frame_flags = meta->frame_flags;
|
||||
|
||||
for (i = 0; i < info->finfo->n_planes; i++)
|
||||
gst_video_meta_map (meta, i, &frame->map[i], &frame->data[i],
|
||||
|
@ -1046,9 +1049,15 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
|
|||
if (id != -1)
|
||||
goto no_metadata;
|
||||
|
||||
/* copy the info */
|
||||
frame->info = *info;
|
||||
frame->id = id;
|
||||
frame->frame_flags = 0;
|
||||
|
||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_TFF))
|
||||
frame->frame_flags |= GST_VIDEO_FRAME_FLAG_TFF;
|
||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_RFF))
|
||||
frame->frame_flags |= GST_VIDEO_FRAME_FLAG_RFF;
|
||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_ONEFIELD))
|
||||
frame->frame_flags |= GST_VIDEO_FRAME_FLAG_ONEFIELD;
|
||||
|
||||
gst_buffer_map (buffer, &frame->map[0], flags);
|
||||
|
||||
|
|
|
@ -329,10 +329,6 @@ typedef enum {
|
|||
/**
|
||||
* GstVideoFlags:
|
||||
* @GST_VIDEO_FLAG_NONE: no flags
|
||||
* @GST_VIDEO_FLAG_INTERLACED: The video is interlaced
|
||||
* @GST_VIDEO_FLAG_TFF: The video has the top field first
|
||||
* @GST_VIDEO_FLAG_RFF: The video has the repeat flag
|
||||
* @GST_VIDEO_FLAG_ONEFIELD: one field
|
||||
* @GST_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d
|
||||
* denote the maximum fps of the video
|
||||
*
|
||||
|
@ -340,11 +336,7 @@ typedef enum {
|
|||
*/
|
||||
typedef enum {
|
||||
GST_VIDEO_FLAG_NONE = 0,
|
||||
GST_VIDEO_FLAG_INTERLACED = (1 << 0),
|
||||
GST_VIDEO_FLAG_TFF = (1 << 1),
|
||||
GST_VIDEO_FLAG_RFF = (1 << 2),
|
||||
GST_VIDEO_FLAG_ONEFIELD = (1 << 3),
|
||||
GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 4)
|
||||
GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 0)
|
||||
} GstVideoFlags;
|
||||
|
||||
/**
|
||||
|
@ -601,6 +593,21 @@ gboolean gst_video_info_convert (GstVideoInfo *info,
|
|||
gint64 src_value,
|
||||
GstFormat dest_format,
|
||||
gint64 *dest_value);
|
||||
/**
|
||||
* GstVideoFrameFlags:
|
||||
* @GST_VIDEO_FRAME_FLAG_NONE: no flags
|
||||
* @GST_VIDEO_FRAME_FLAG_TFF: The video frame has the top field first
|
||||
* @GST_VIDEO_FRAME_FLAG_RFF: The video frame has the repeat flag
|
||||
* @GST_VIDEO_FRAME_FLAG_ONEFIELD: The video frame has one field
|
||||
*
|
||||
* Extra video frame flags
|
||||
*/
|
||||
typedef enum {
|
||||
GST_VIDEO_FRAME_FLAG_NONE = 0,
|
||||
GST_VIDEO_FRAME_FLAG_TFF = (1 << 0),
|
||||
GST_VIDEO_FRAME_FLAG_RFF = (1 << 1),
|
||||
GST_VIDEO_FRAME_FLAG_ONEFIELD = (1 << 2)
|
||||
} GstVideoFrameFlags;
|
||||
|
||||
/**
|
||||
* GstVideoFrame:
|
||||
|
@ -616,6 +623,7 @@ gboolean gst_video_info_convert (GstVideoInfo *info,
|
|||
*/
|
||||
struct _GstVideoFrame {
|
||||
GstVideoInfo info;
|
||||
GstVideoFrameFlags frame_flags;
|
||||
|
||||
GstBuffer *buffer;
|
||||
gpointer meta;
|
||||
|
@ -693,7 +701,6 @@ gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFr
|
|||
|
||||
/**
|
||||
* GstVideoBufferFlags:
|
||||
* @GST_VIDEO_BUFFER_FLAG_INTERLACED: Mark #GstBuffer as interlaced
|
||||
* @GST_VIDEO_BUFFER_FLAG_TFF: If the #GstBuffer is interlaced, then the first field
|
||||
* in the video frame is the top field. If unset, the
|
||||
* bottom field is first.
|
||||
|
@ -707,10 +714,9 @@ gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFr
|
|||
* Additional video buffer flags.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_VIDEO_BUFFER_FLAG_INTERLACED = (GST_BUFFER_FLAG_LAST << 0),
|
||||
GST_VIDEO_BUFFER_FLAG_TFF = (GST_BUFFER_FLAG_LAST << 1),
|
||||
GST_VIDEO_BUFFER_FLAG_RFF = (GST_BUFFER_FLAG_LAST << 2),
|
||||
GST_VIDEO_BUFFER_FLAG_ONEFIELD = (GST_BUFFER_FLAG_LAST << 3),
|
||||
GST_VIDEO_BUFFER_FLAG_TFF = (GST_BUFFER_FLAG_LAST << 0),
|
||||
GST_VIDEO_BUFFER_FLAG_RFF = (GST_BUFFER_FLAG_LAST << 1),
|
||||
GST_VIDEO_BUFFER_FLAG_ONEFIELD = (GST_BUFFER_FLAG_LAST << 2),
|
||||
|
||||
GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8)
|
||||
} GstVideoBufferFlags;
|
||||
|
|
Loading…
Reference in a new issue