diff --git a/gst-libs/gst/video/video-frame.h b/gst-libs/gst/video/video-frame.h index 992d47beb3..c4e9a3f8f2 100644 --- a/gst-libs/gst/video/video-frame.h +++ b/gst-libs/gst/video/video-frame.h @@ -173,9 +173,11 @@ gboolean gst_video_frame_copy_plane (GstVideoFrame *dest, const GstVideoFr * @GST_VIDEO_BUFFER_FLAG_TOP_FIELD: The video frame has the top field only. This is the * same as GST_VIDEO_BUFFER_FLAG_TFF | * GST_VIDEO_BUFFER_FLAG_ONEFIELD (Since: 1.16). + * Use GST_VIDEO_BUFFER_IS_TOP_FIELD() to check for this flag. * @GST_VIDEO_BUFFER_FLAG_BOTTOM_FIELD: The video frame has the bottom field only. This is * the same as GST_VIDEO_BUFFER_FLAG_ONEFIELD * (GST_VIDEO_BUFFER_FLAG_TFF flag unset) (Since: 1.16). + * Use GST_VIDEO_BUFFER_IS_BOTTOM_FIELD() to check for this flag. * @GST_VIDEO_BUFFER_FLAG_MARKER: The #GstBuffer contains the end of a video field or frame * boundary such as the last subframe or packet (Since: 1.18). * @GST_VIDEO_BUFFER_FLAG_LAST: Offset to define more flags @@ -204,6 +206,26 @@ typedef enum { GST_VIDEO_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8) } GstVideoBufferFlags; +/* GST_VIDEO_BUFFER_FLAG_TOP_FIELD is a subset of + * GST_VIDEO_BUFFER_FLAG_BOTTOM_FIELD so needs to be checked accordingly. */ +#define _GST_VIDEO_BUFFER_FLAG_FIELD_MASK GST_VIDEO_BUFFER_FLAG_TOP_FIELD + +/** + * GST_VIDEO_BUFFER_IS_TOP_FIELD: + * @buf: a #GstBuffer + * + * Check if GST_VIDEO_BUFFER_FLAG_TOP_FIELD is set on @buf (Since: 1.18). + */ +#define GST_VIDEO_BUFFER_IS_TOP_FIELD(buf) ((GST_BUFFER_FLAGS (buf) & _GST_VIDEO_BUFFER_FLAG_FIELD_MASK) == GST_VIDEO_BUFFER_FLAG_TOP_FIELD) + +/** + * GST_VIDEO_BUFFER_IS_BOTTOM_FIELD: + * @buf: a #GstBuffer + * + * Check if GST_VIDEO_BUFFER_FLAG_BOTTOM_FIELD is set on @buf (Since: 1.18). + */ +#define GST_VIDEO_BUFFER_IS_BOTTOM_FIELD(buf) ((GST_BUFFER_FLAGS (buf) & _GST_VIDEO_BUFFER_FLAG_FIELD_MASK) == GST_VIDEO_BUFFER_FLAG_BOTTOM_FIELD) + /** * GstVideoFrameMapFlags: * @GST_VIDEO_FRAME_MAP_FLAG_NO_REF: Don't take another reference of the buffer and store it in diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c index 6d98aa9047..989c7b034e 100644 --- a/tests/check/libs/video.c +++ b/tests/check/libs/video.c @@ -3747,6 +3747,30 @@ GST_START_TEST (test_video_meta_align) GST_END_TEST; +GST_START_TEST (test_video_flags) +{ + GstBuffer *buf; + + buf = gst_buffer_new (); + fail_unless (!GST_VIDEO_BUFFER_IS_TOP_FIELD (buf)); + fail_unless (!GST_VIDEO_BUFFER_IS_BOTTOM_FIELD (buf)); + gst_buffer_unref (buf); + + buf = gst_buffer_new (); + 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)); + gst_buffer_unref (buf); + + buf = gst_buffer_new (); + 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)); + gst_buffer_unref (buf); +} + +GST_END_TEST; + static Suite * video_suite (void) { @@ -3797,6 +3821,7 @@ video_suite (void) tcase_add_test (tc_chain, test_video_format_info_plane_to_components); tcase_add_test (tc_chain, test_video_info_align); tcase_add_test (tc_chain, test_video_meta_align); + tcase_add_test (tc_chain, test_video_flags); return s; }