* This function is based on av_fifo_generic_read, which is why there is a comment
* about a memory barrier for SMP.
*/
* This function is based on av_fifo_generic_read, which is why there is a comment
* about a memory barrier for SMP.
*/
-static uint8_t* flac_fifo_read_wrap(FLACParseContext *fpc, int offset, int len,
- uint8_t** wrap_buf, int* allocated_size)
+static uint8_t *flac_fifo_read_wrap(FLACParseContext *fpc, int offset, int len,
+ uint8_t **wrap_buf, int *allocated_size)
* A second call to flac_fifo_read (with new offset and len) should be called
* to get the post-wrap buf if the returned len is less than the requested.
**/
* A second call to flac_fifo_read (with new offset and len) should be called
* to get the post-wrap buf if the returned len is less than the requested.
**/
for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS; i++)
(*end_handle)->link_penalty[i] = FLAC_HEADER_NOT_PENALIZED_YET;
for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS; i++)
(*end_handle)->link_penalty[i] = FLAC_HEADER_NOT_PENALIZED_YET;
-static int find_headers_search(FLACParseContext *fpc, uint8_t *buf, int buf_size,
- int search_start)
-
+static int find_headers_search(FLACParseContext *fpc, uint8_t *buf,
+ int buf_size, int search_start)
{
int size = 0, mod_offset = (buf_size - 1) % 4, i, j;
uint32_t x;
for (i = 0; i < mod_offset; i++) {
{
int size = 0, mod_offset = (buf_size - 1) % 4, i, j;
uint32_t x;
for (i = 0; i < mod_offset; i++) {
- if ((AV_RB16(buf + i) & 0xFFFE) == 0xFFF8)
- size = find_headers_search_validate(fpc, search_start + i);
+ if ((AV_RB16(buf + i) & 0xFFFE) == 0xFFF8) {
+ int ret = find_headers_search_validate(fpc, search_start + i);
+ size = FFMAX(size, ret);
+ }
}
for (; i < buf_size - 1; i += 4) {
x = AV_RN32(buf + i);
if (((x & ~(x + 0x01010101)) & 0x80808080)) {
for (j = 0; j < 4; j++) {
}
for (; i < buf_size - 1; i += 4) {
x = AV_RN32(buf + i);
if (((x & ~(x + 0x01010101)) & 0x80808080)) {
for (j = 0; j < 4; j++) {
- if ((AV_RB16(buf + i + j) & 0xFFFE) == 0xFFF8)
- size = find_headers_search_validate(fpc, search_start + i + j);
+ if ((AV_RB16(buf + i + j) & 0xFFFE) == 0xFFF8) {
+ int ret = find_headers_search_validate(fpc, search_start + i + j);
+ size = FFMAX(size, ret);
+ }
/* If there are frames in the middle we expect this deduction,
as they are probably valid and this one follows it */
/* If there are frames in the middle we expect this deduction,
as they are probably valid and this one follows it */
if (header->fi.is_var_size)
fpc->pc->pts = header->fi.frame_or_sample_num;
else if (header->best_child)
if (header->fi.is_var_size)
fpc->pc->pts = header->fi.frame_or_sample_num;
else if (header->best_child)
- /* Note that as (non-modified) parameters, buf can be non-NULL, */
- /* while buf_size is 0. */
- while ((buf && buf_size && read_end < buf + buf_size &&
+ /* Also note that buf can't be NULL. */
+ while ((buf_size && read_end < buf + buf_size &&
read_end = read_start + MAX_FRAME_HEADER_SIZE;
} else {
/* The maximum read size is the upper-bound of what the parser
read_end = read_start + MAX_FRAME_HEADER_SIZE;
} else {
/* The maximum read size is the upper-bound of what the parser
av_fifo_generic_write(fpc->fifo_buf, (void*) read_start,
read_end - read_start, NULL);
} else {
av_fifo_generic_write(fpc->fifo_buf, (void*) read_start,
read_end - read_start, NULL);
} else {
fpc->nb_headers_buffered = nb_headers;
/* Wait till FLAC_MIN_HEADERS to output a valid frame. */
if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) {
fpc->nb_headers_buffered = nb_headers;
/* Wait till FLAC_MIN_HEADERS to output a valid frame. */
if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) {
if (fpc->best_header && fpc->best_header->max_score <= 0) {
// Only accept a bad header if there is no other option to continue
if (fpc->best_header && fpc->best_header->max_score <= 0) {
// Only accept a bad header if there is no other option to continue
- s->duration = 0;
- *poutbuf_size = fpc->best_header->offset;
- *poutbuf = flac_fifo_read_wrap(fpc, 0, *poutbuf_size,
- &fpc->wrap_buf,
- &fpc->wrap_buf_allocated_size);
+ s->duration = 0;
+ *poutbuf_size = fpc->best_header->offset;
+ *poutbuf = flac_fifo_read_wrap(fpc, 0, *poutbuf_size,
+ &fpc->wrap_buf,
+ &fpc->wrap_buf_allocated_size);