gst/rawparse/gstrawparse.c: Handle framesizes > 4096 with multiple frames per buffer correctly in pull mode and handl...

Original commit message from CVS:
* gst/rawparse/gstrawparse.c: (gst_raw_parse_push_buffer),
(gst_raw_parse_loop):
Handle framesizes > 4096 with multiple frames per buffer correctly
in pull mode and handle short reads better.
Also put offset and offset_end on outgoing buffers.
This commit is contained in:
Sebastian Dröge 2008-01-19 16:13:31 +00:00
parent a0283af747
commit 252d4044bf
2 changed files with 22 additions and 5 deletions

View file

@ -1,3 +1,11 @@
2008-01-19 Sebastian Dröge <slomo@circular-chaos.org>
* gst/rawparse/gstrawparse.c: (gst_raw_parse_push_buffer),
(gst_raw_parse_loop):
Handle framesizes > 4096 with multiple frames per buffer correctly
in pull mode and handle short reads better.
Also put offset and offset_end on outgoing buffers.
2008-01-19 Sebastian Dröge <slomo@circular-chaos.org> 2008-01-19 Sebastian Dröge <slomo@circular-chaos.org>
* gst/rawparse/gstrawparse.c: (gst_raw_parse_loop): * gst/rawparse/gstrawparse.c: (gst_raw_parse_loop):

View file

@ -221,9 +221,13 @@ gst_raw_parse_push_buffer (GstRawParse * rp, GstBuffer * buffer)
gst_util_uint64_scale (rp->n_frames, GST_SECOND * rp->fps_d, rp->fps_n); gst_util_uint64_scale (rp->n_frames, GST_SECOND * rp->fps_d, rp->fps_n);
GST_BUFFER_DURATION (buffer) = GST_BUFFER_DURATION (buffer) =
gst_util_uint64_scale (nframes * GST_SECOND, rp->fps_d, rp->fps_n); gst_util_uint64_scale (nframes * GST_SECOND, rp->fps_d, rp->fps_n);
GST_BUFFER_OFFSET (buffer) = rp->offset / rp->framesize;
GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET (buffer) + nframes;
} else { } else {
GST_BUFFER_TIMESTAMP (buffer) = rp->segment.start; GST_BUFFER_TIMESTAMP (buffer) = rp->segment.start;
GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE; GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_OFFSET (buffer) = rp->offset / rp->framesize;
GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET (buffer) + nframes;
} }
gst_buffer_set_caps (buffer, GST_PAD_CAPS (rp->srcpad)); gst_buffer_set_caps (buffer, GST_PAD_CAPS (rp->srcpad));
if (rp->discont) { if (rp->discont) {
@ -296,7 +300,7 @@ gst_raw_parse_loop (GstElement * element)
goto pause; goto pause;
} }
if (rp_class->multiple_frames_per_buffer) if (rp_class->multiple_frames_per_buffer && rp->framesize < 4096)
size = 4096 - (4096 % rp->framesize); size = 4096 - (4096 % rp->framesize);
else else
size = rp->framesize; size = rp->framesize;
@ -330,10 +334,15 @@ gst_raw_parse_loop (GstElement * element)
GST_DEBUG_OBJECT (rp, "Short read at offset %" G_GINT64_FORMAT GST_DEBUG_OBJECT (rp, "Short read at offset %" G_GINT64_FORMAT
", got only %u of %u bytes", rp->offset, GST_BUFFER_SIZE (buffer), ", got only %u of %u bytes", rp->offset, GST_BUFFER_SIZE (buffer),
size); size);
gst_buffer_unref (buffer);
buffer = NULL; if (size > rp->framesize) {
ret = GST_FLOW_UNEXPECTED; GST_BUFFER_SIZE (buffer) -= GST_BUFFER_SIZE (buffer) % rp->framesize;
goto pause; } else {
gst_buffer_unref (buffer);
buffer = NULL;
ret = GST_FLOW_UNEXPECTED;
goto pause;
}
} }
if (rp->need_newsegment) { if (rp->need_newsegment) {