Commit ea2619aa authored by Guillaume Desmottes's avatar Guillaume Desmottes 🐐 Committed by Olivier Crête

video: fix GST_VIDEO_FRAME_IS_BOTTOM_FIELD()

GST_VIDEO_FRAME_FLAG_BOTTOM_FIELD is a subset of
GST_VIDEO_FRAME_FLAG_TOP_FIELD so needs to be checked accordingly.

Fix #726
parent 26f386ce
......@@ -125,7 +125,12 @@ gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFr
#define GST_VIDEO_FRAME_IS_RFF(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_RFF))
#define GST_VIDEO_FRAME_IS_ONEFIELD(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_ONEFIELD))
#define GST_VIDEO_FRAME_IS_TOP_FIELD(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_TOP_FIELD))
#define GST_VIDEO_FRAME_IS_BOTTOM_FIELD(f) (GST_VIDEO_FRAME_FLAG_IS_SET(f, GST_VIDEO_FRAME_FLAG_BOTTOM_FIELD))
/* GST_VIDEO_FRAME_FLAG_BOTTOM_FIELD is a subset of
* GST_VIDEO_FRAME_FLAG_TOP_FIELD so needs to be checked accordingly. */
#define _GST_VIDEO_FRAME_FLAG_FIELD_MASK GST_VIDEO_FRAME_FLAG_TOP_FIELD
#define GST_VIDEO_FRAME_IS_BOTTOM_FIELD(f) (((f)->flags & _GST_VIDEO_FRAME_FLAG_FIELD_MASK) == GST_VIDEO_FRAME_FLAG_BOTTOM_FIELD)
/* dealing with planes */
#define GST_VIDEO_FRAME_N_PLANES(f) (GST_VIDEO_INFO_N_PLANES(&(f)->info))
......
......@@ -3750,22 +3750,40 @@ GST_END_TEST;
GST_START_TEST (test_video_flags)
{
GstBuffer *buf;
GstVideoInfo info;
GstVideoFrame frame;
buf = gst_buffer_new ();
gst_video_info_init (&info);
fail_unless (gst_video_info_set_interlaced_format (&info,
GST_VIDEO_FORMAT_RGB, GST_VIDEO_INTERLACE_MODE_ALTERNATE, 4, 4));
buf = gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (&info));
fail_unless (!GST_VIDEO_BUFFER_IS_TOP_FIELD (buf));
fail_unless (!GST_VIDEO_BUFFER_IS_BOTTOM_FIELD (buf));
fail_unless (gst_video_frame_map (&frame, &info, buf, GST_MAP_READ));
fail_unless (!GST_VIDEO_FRAME_IS_TOP_FIELD (&frame));
fail_unless (!GST_VIDEO_FRAME_IS_BOTTOM_FIELD (&frame));
gst_video_frame_unmap (&frame);
gst_buffer_unref (buf);
buf = gst_buffer_new ();
buf = gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (&info));
GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_FLAG_TOP_FIELD);
fail_unless (GST_VIDEO_BUFFER_IS_TOP_FIELD (buf));
fail_unless (!GST_VIDEO_BUFFER_IS_BOTTOM_FIELD (buf));
fail_unless (gst_video_frame_map (&frame, &info, buf, GST_MAP_READ));
fail_unless (GST_VIDEO_FRAME_IS_TOP_FIELD (&frame));
fail_unless (!GST_VIDEO_FRAME_IS_BOTTOM_FIELD (&frame));
gst_video_frame_unmap (&frame);
gst_buffer_unref (buf);
buf = gst_buffer_new ();
buf = gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (&info));
GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_FLAG_BOTTOM_FIELD);
fail_unless (!GST_VIDEO_BUFFER_IS_TOP_FIELD (buf));
fail_unless (GST_VIDEO_BUFFER_IS_BOTTOM_FIELD (buf));
fail_unless (gst_video_frame_map (&frame, &info, buf, GST_MAP_READ));
fail_unless (!GST_VIDEO_FRAME_IS_TOP_FIELD (&frame));
fail_unless (GST_VIDEO_FRAME_IS_BOTTOM_FIELD (&frame));
gst_video_frame_unmap (&frame);
gst_buffer_unref (buf);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment