mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avcodec/tak_parser: don't return error values
The API does not allow it. Also set poutbuf and poutbuf_size to NULL/0 on error. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
e460dcc832
commit
23599834bd
@ -46,15 +46,16 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
|||||||
int needed = buf_size ? TAK_MAX_FRAME_HEADER_BYTES : 8;
|
int needed = buf_size ? TAK_MAX_FRAME_HEADER_BYTES : 8;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
*poutbuf = buf;
|
||||||
|
*poutbuf_size = buf_size;
|
||||||
|
|
||||||
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
||||||
TAKStreamInfo ti;
|
TAKStreamInfo ti;
|
||||||
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
|
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
|
||||||
return ret;
|
return buf_size;
|
||||||
if (!ff_tak_decode_frame_header(avctx, &gb, &ti, 127))
|
if (!ff_tak_decode_frame_header(avctx, &gb, &ti, 127))
|
||||||
s->duration = t->ti.last_frame_samples ? t->ti.last_frame_samples
|
s->duration = t->ti.last_frame_samples ? t->ti.last_frame_samples
|
||||||
: t->ti.frame_samples;
|
: t->ti.frame_samples;
|
||||||
*poutbuf = buf;
|
|
||||||
*poutbuf_size = buf_size;
|
|
||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
|||||||
const uint8_t *tmp_buf = buf;
|
const uint8_t *tmp_buf = buf;
|
||||||
|
|
||||||
if (ff_combine_frame(pc, END_NOT_FOUND, &tmp_buf, &tmp_buf_size) != -1)
|
if (ff_combine_frame(pc, END_NOT_FOUND, &tmp_buf, &tmp_buf_size) != -1)
|
||||||
return AVERROR(ENOMEM);
|
goto fail;
|
||||||
consumed += tmp_buf_size;
|
consumed += tmp_buf_size;
|
||||||
buf += tmp_buf_size;
|
buf += tmp_buf_size;
|
||||||
buf_size -= tmp_buf_size;
|
buf_size -= tmp_buf_size;
|
||||||
@ -78,7 +79,7 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
|||||||
|
|
||||||
if ((ret = init_get_bits8(&gb, pc->buffer + t->index,
|
if ((ret = init_get_bits8(&gb, pc->buffer + t->index,
|
||||||
pc->index - t->index)) < 0)
|
pc->index - t->index)) < 0)
|
||||||
return ret;
|
goto fail;
|
||||||
if (!ff_tak_decode_frame_header(avctx, &gb,
|
if (!ff_tak_decode_frame_header(avctx, &gb,
|
||||||
pc->frame_start_found ? &ti : &t->ti, 127) &&
|
pc->frame_start_found ? &ti : &t->ti, 127) &&
|
||||||
!ff_tak_check_crc(pc->buffer + t->index,
|
!ff_tak_check_crc(pc->buffer + t->index,
|
||||||
@ -103,9 +104,7 @@ found:
|
|||||||
|
|
||||||
if (consumed && !buf_size && next == END_NOT_FOUND ||
|
if (consumed && !buf_size && next == END_NOT_FOUND ||
|
||||||
ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
|
ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
|
||||||
*poutbuf = NULL;
|
goto fail;
|
||||||
*poutbuf_size = 0;
|
|
||||||
return buf_size + consumed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next != END_NOT_FOUND) {
|
if (next != END_NOT_FOUND) {
|
||||||
@ -116,6 +115,11 @@ found:
|
|||||||
*poutbuf = buf;
|
*poutbuf = buf;
|
||||||
*poutbuf_size = buf_size;
|
*poutbuf_size = buf_size;
|
||||||
return next;
|
return next;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
*poutbuf = NULL;
|
||||||
|
*poutbuf_size = 0;
|
||||||
|
return buf_size + consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVCodecParser ff_tak_parser = {
|
AVCodecParser ff_tak_parser = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user