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
This commit is contained in:
Guillaume Desmottes 2020-02-07 11:18:24 +05:30 committed by Olivier Crête
parent 26f386ce8b
commit ea2619aadc
2 changed files with 27 additions and 4 deletions

View file

@ -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))

View file

@ -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);
}