mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
videorate: Error out on streams with no way to guess framerate
This is better than going into an infinite loop. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/761>
This commit is contained in:
parent
90ff086a43
commit
cb6edaf6f8
2 changed files with 11 additions and 26 deletions
|
@ -1469,6 +1469,14 @@ gst_video_rate_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
||||||
|
|
||||||
if (videorate->to_rate_numerator == 0 && videorate->prevbuf &&
|
if (videorate->to_rate_numerator == 0 && videorate->prevbuf &&
|
||||||
!videorate->force_variable_rate) {
|
!videorate->force_variable_rate) {
|
||||||
|
if (!GST_BUFFER_PTS_IS_VALID (buffer) ||
|
||||||
|
!GST_BUFFER_PTS_IS_VALID (videorate->prevbuf)) {
|
||||||
|
GST_ELEMENT_ERROR (videorate, STREAM, FAILED, (NULL),
|
||||||
|
("videorate requires a non-variable framerate on the output caps or the"
|
||||||
|
" two first consecutive buffers to have valid timestamps to guess the"
|
||||||
|
" framerate."));
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
gst_video_rate_check_variable_rate (videorate, buffer);
|
gst_video_rate_check_variable_rate (videorate, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1540,7 +1540,7 @@ GST_END_TEST;
|
||||||
GST_START_TEST (test_nopts_in_middle)
|
GST_START_TEST (test_nopts_in_middle)
|
||||||
{
|
{
|
||||||
GstElement *videorate;
|
GstElement *videorate;
|
||||||
GstBuffer *first, *second, *third;
|
GstBuffer *first, *second;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
videorate =
|
videorate =
|
||||||
|
@ -1576,33 +1576,10 @@ GST_START_TEST (test_nopts_in_middle)
|
||||||
gst_buffer_ref (second);
|
gst_buffer_ref (second);
|
||||||
|
|
||||||
/* pushing gives away my reference ... */
|
/* pushing gives away my reference ... */
|
||||||
fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
|
fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_ERROR);
|
||||||
/* ... and the first one should have been pushed out */
|
|
||||||
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
||||||
fail_unless_equals_int (g_list_length (buffers), 1);
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
||||||
|
|
||||||
/* ... and the first one was replaced */
|
|
||||||
assert_videorate_stats (videorate, "second", 2, 1, 0, 0);
|
|
||||||
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
|
||||||
|
|
||||||
/* third buffer */
|
|
||||||
third = gst_buffer_new_and_alloc (4);
|
|
||||||
GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
|
|
||||||
gst_buffer_memset (third, 0, 0, 4);
|
|
||||||
ASSERT_BUFFER_REFCOUNT (third, "third", 1);
|
|
||||||
gst_buffer_ref (third);
|
|
||||||
|
|
||||||
/* pushing gives away my reference ... */
|
|
||||||
fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK);
|
|
||||||
/* ... and a copy is now stuck inside videorate */
|
|
||||||
ASSERT_BUFFER_REFCOUNT (third, "third", 1);
|
|
||||||
|
|
||||||
/* and now it should have pushed out the second one */
|
|
||||||
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
||||||
ASSERT_BUFFER_REFCOUNT (first, "first", 1);
|
|
||||||
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
|
|
||||||
ASSERT_BUFFER_REFCOUNT (third, "third", 1);
|
|
||||||
assert_videorate_stats (videorate, "third", 3, 2, 0, 0);
|
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
gst_buffer_unref (first);
|
gst_buffer_unref (first);
|
||||||
|
|
Loading…
Reference in a new issue