mpegvideoparse: avoid scanning for start codes twice

... since a previous terminating start code serves as subsequent start code.
This commit is contained in:
Mark Nauwelaerts 2012-05-22 21:00:31 +02:00
parent 5c4dd29838
commit c5664dcda7

View File

@ -513,7 +513,8 @@ retry:
/* if already found a previous start code, e.g. start of frame, go for next */ /* if already found a previous start code, e.g. start of frame, go for next */
if (mpvparse->last_sc >= 0) { if (mpvparse->last_sc >= 0) {
off = mpvparse->last_sc; off = packet.offset = mpvparse->last_sc;
packet.size = 0;
goto next; goto next;
} }
@ -550,8 +551,9 @@ retry:
next: next:
/* start is fine as of now */ /* start is fine as of now */
*skipsize = 0; *skipsize = 0;
/* position a bit further than last sc */ /* terminating start code may have been found in prev scan already */
off++; if (((gint) packet.size) >= 0) {
off = packet.offset + packet.size;
/* so now we have start code at start of data; locate next start code */ /* so now we have start code at start of data; locate next start code */
if (!gst_mpeg_video_parse (&packet, data, size, off)) { if (!gst_mpeg_video_parse (&packet, data, size, off)) {
off = -1; off = -1;
@ -559,6 +561,9 @@ next:
g_assert (packet.offset >= 4); g_assert (packet.offset >= 4);
off = packet.offset - 4; off = packet.offset - 4;
} }
} else {
off = -1;
}
GST_LOG_OBJECT (mpvparse, "next start code at %d", off); GST_LOG_OBJECT (mpvparse, "next start code at %d", off);
if (off < 0) { if (off < 0) {
@ -570,8 +575,7 @@ next:
} else { } else {
GST_LOG_OBJECT (mpvparse, "need more data"); GST_LOG_OBJECT (mpvparse, "need more data");
/* resume scan where we left it */ /* resume scan where we left it */
/* need - 4 since off is incremented later on */ mpvparse->last_sc = size - 3;
mpvparse->last_sc = size - 4;
/* request best next available */ /* request best next available */
off = G_MAXUINT; off = G_MAXUINT;
goto exit; goto exit;