From af17f81a475706a6d35828054daacfd971420fcb Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 29 Mar 2007 11:24:47 +0000 Subject: [PATCH] gst/videorate/gstvideorate.c (gst_video_rate_flush_prev): Make perfect offsets also, not just timestamps. Original commit message from CVS: 2007-03-29 Andy Wingo * gst/videorate/gstvideorate.c (gst_video_rate_flush_prev): Make perfect offsets also, not just timestamps. * tests/check/elements/videorate.c (test_more): Test that given any incoming offsets, that videorate produces perfect offsets. --- ChangeLog | 8 ++++++++ gst/videorate/gstvideorate.c | 3 +++ tests/check/elements/videorate.c | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/ChangeLog b/ChangeLog index a5601c4e7a..2d74d38439 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-03-29 Andy Wingo + + * gst/videorate/gstvideorate.c (gst_video_rate_flush_prev): Make + perfect offsets also, not just timestamps. + + * tests/check/elements/videorate.c (test_more): Test that given + any incoming offsets, that videorate produces perfect offsets. + 2007-03-29 Wim Taymans * gst-libs/gst/riff/riff-ids.h: diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c index 728ccd7f56..a34ef38656 100644 --- a/gst/videorate/gstvideorate.c +++ b/gst/videorate/gstvideorate.c @@ -438,6 +438,9 @@ gst_video_rate_flush_prev (GstVideoRate * videorate) outbuf = gst_buffer_make_metadata_writable (gst_buffer_ref (videorate->prevbuf)); + GST_BUFFER_OFFSET (outbuf) = videorate->out; + GST_BUFFER_OFFSET_END (outbuf) = videorate->out + 1; + /* this is the timestamp we put on the buffer */ push_ts = videorate->next_ts; diff --git a/tests/check/elements/videorate.c b/tests/check/elements/videorate.c index 0a675fa04f..7958d8341a 100644 --- a/tests/check/elements/videorate.c +++ b/tests/check/elements/videorate.c @@ -153,6 +153,7 @@ GST_START_TEST (test_more) GstBuffer *first, *second, *third, *outbuffer; GList *l; GstCaps *caps; + GRand *rand; videorate = setup_videorate (); fail_unless (gst_element_set_state (videorate, @@ -160,9 +161,15 @@ GST_START_TEST (test_more) "could not set to playing"); assert_videorate_stats (videorate, "creation", 0, 0, 0, 0); + rand = g_rand_new (); + /* first buffer */ first = gst_buffer_new_and_alloc (4); GST_BUFFER_TIMESTAMP (first) = 0; + /* it shouldn't matter what the offsets are, videorate produces perfect + streams */ + GST_BUFFER_OFFSET (first) = g_rand_int (rand); + GST_BUFFER_OFFSET_END (first) = g_rand_int (rand); memset (GST_BUFFER_DATA (first), 1, 4); caps = gst_caps_from_string (VIDEO_CAPS_STRING); gst_buffer_set_caps (first, caps); @@ -180,6 +187,8 @@ GST_START_TEST (test_more) /* second buffer; inbetween second and third output frame's timestamp */ second = gst_buffer_new_and_alloc (4); GST_BUFFER_TIMESTAMP (second) = GST_SECOND * 3 / 50; + GST_BUFFER_OFFSET (first) = g_rand_int (rand); + GST_BUFFER_OFFSET_END (first) = g_rand_int (rand); memset (GST_BUFFER_DATA (second), 2, 4); caps = gst_caps_from_string (VIDEO_CAPS_STRING); gst_buffer_set_caps (second, caps); @@ -203,6 +212,8 @@ GST_START_TEST (test_more) /* third buffer */ third = gst_buffer_new_and_alloc (4); GST_BUFFER_TIMESTAMP (third) = GST_SECOND * 12 / 50; + GST_BUFFER_OFFSET (first) = g_rand_int (rand); + GST_BUFFER_OFFSET_END (first) = g_rand_int (rand); memset (GST_BUFFER_DATA (third), 3, 4); caps = gst_caps_from_string (VIDEO_CAPS_STRING); gst_buffer_set_caps (third, caps); @@ -222,17 +233,28 @@ GST_START_TEST (test_more) l = buffers; fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), 0); fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 1); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 0); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 1); + l = g_list_next (l); fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), GST_SECOND / 25); fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 2); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 1); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 2); + l = g_list_next (l); fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), GST_SECOND * 2 / 25); fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 2); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 2); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 3); + l = g_list_next (l); fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), GST_SECOND * 3 / 25); fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 2); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 3); + fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 4); fail_unless_equals_int (g_list_length (buffers), 4); /* one held by us, three held by each output frame taken from the second */ @@ -247,6 +269,7 @@ GST_START_TEST (test_more) fail_unless_equals_int (g_list_length (buffers), 5); /* cleanup */ + g_rand_free (rand); gst_buffer_unref (first); gst_buffer_unref (second); gst_buffer_unref (third);