videoflip: reset orientation if not present in a tag update

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4377>
This commit is contained in:
Guillaume Desmottes 2023-04-13 14:19:29 +02:00
parent c0fa04fcaf
commit 7c4e36acfd
3 changed files with 41 additions and 0 deletions

View file

@ -1789,6 +1789,8 @@ gst_video_flip_sink_event (GstBaseTransform * trans, GstEvent * event)
if (gst_video_orientation_from_tag (taglist, &method)) {
if (gst_tag_list_get_scope (taglist) == GST_TAG_SCOPE_STREAM) {
vf->got_orientation_stream_tag = TRUE;
} else if (gst_tag_list_get_scope (taglist) == GST_TAG_SCOPE_GLOBAL) {
vf->global_tag_method = method;
}
if (gst_tag_list_get_scope (taglist) == GST_TAG_SCOPE_GLOBAL
@ -1799,12 +1801,33 @@ gst_video_flip_sink_event (GstBaseTransform * trans, GstEvent * event)
} else {
gst_video_flip_set_method (vf, method, TRUE);
}
} else {
// no orientation in tag
if (gst_tag_list_get_scope (taglist) == GST_TAG_SCOPE_STREAM) {
GST_DEBUG_OBJECT (vf,
"stream tag does not contain orientation, restore the global one: %d",
vf->global_tag_method);
vf->got_orientation_stream_tag = FALSE;
gst_video_flip_set_method (vf, vf->global_tag_method, TRUE);
} else if (gst_tag_list_get_scope (taglist) == GST_TAG_SCOPE_GLOBAL) {
vf->global_tag_method = GST_VIDEO_ORIENTATION_IDENTITY;
if (!vf->got_orientation_stream_tag) {
GST_DEBUG_OBJECT (vf,
"global taglist withtout orientation, set to identity");
gst_video_flip_set_method (vf, GST_VIDEO_ORIENTATION_IDENTITY,
TRUE);
} else {
// keep using the orientation from the stream tag
}
}
}
break;
case GST_EVENT_STREAM_START:
GST_DEBUG_OBJECT (vf, "new stream, reset orientation from tags");
vf->got_orientation_stream_tag = FALSE;
vf->global_tag_method = GST_VIDEO_ORIENTATION_IDENTITY;
gst_video_flip_set_method (vf, GST_VIDEO_ORIENTATION_IDENTITY, TRUE);
break;
default:

View file

@ -81,6 +81,8 @@ struct _GstVideoFlip {
GstVideoOrientationMethod tag_method;
/* TRUE if we received orientation from tag event with GST_TAG_SCOPE_STREAM */
gboolean got_orientation_stream_tag;
/* orientation received from a tag with GST_TAG_SCOPE_STREAM */
GstVideoOrientationMethod global_tag_method;
GstVideoOrientationMethod proposed_method;
gboolean change_configuring_method;
GstVideoOrientationMethod configuring_method;

View file

@ -455,6 +455,22 @@ GST_START_TEST (test_orientation_tag_scopes)
// caps is updated as the frame is now rotated
caps_update (flip, &in_info, TRUE);
// sending a stream tag without orientation switch back to the global one, so no orientation change (global: 90, stream: /)
send_orientation_tag (flip, NULL, GST_TAG_SCOPE_STREAM);
caps_not_updated (flip, &in_info);
// remove orientation from global tag, restoring identity (global: /, stream: /)
send_orientation_tag (flip, NULL, GST_TAG_SCOPE_GLOBAL);
caps_update (flip, &in_info, FALSE);
// send rotation in stream tag (global: /, stream: 90)
send_orientation_tag (flip, "rotate-90", GST_TAG_SCOPE_STREAM);
caps_update (flip, &in_info, TRUE);
// sending a global tag without orientation does not change the rotation (global: /, stream: 90)
send_orientation_tag (flip, NULL, GST_TAG_SCOPE_GLOBAL);
caps_not_updated (flip, &in_info);
gst_harness_teardown (flip);
}