* NAME: stream->sync() * DESCRIPTION: locate the next stream sync word */
| 105 | * DESCRIPTION: locate the next stream sync word |
| 106 | */ |
| 107 | int mad_stream_sync(struct mad_stream *stream) |
| 108 | { |
| 109 | register unsigned char const *ptr, *end; |
| 110 | stack(__FUNCTION__, __FILE__, __LINE__); |
| 111 | |
| 112 | ptr = mad_bit_nextbyte(&stream->ptr); |
| 113 | end = stream->bufend; |
| 114 | |
| 115 | while (ptr < end - 1 && |
| 116 | !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) |
| 117 | ++ptr; |
| 118 | |
| 119 | if (end - ptr < MAD_BUFFER_GUARD) |
| 120 | return -1; |
| 121 | |
| 122 | mad_bit_init(&stream->ptr, ptr); |
| 123 | |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | /* |
| 128 | * NAME: stream->errorstr() |
no test coverage detected