diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-02-02 18:38:47 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-02-02 18:38:47 +0000 |
commit | d8a91afd360084f9cb015beaf3d9e4d606bc9d2a (patch) | |
tree | 0921e828c5b2e23e8e742ea25f368708ea4d12a5 /libavcodec/parser.c | |
parent | b4e021e8c4a6d9883249c0a37e3acc96e18f8fec (diff) | |
download | ffmpeg-d8a91afd360084f9cb015beaf3d9e4d606bc9d2a.tar.gz |
output last ac3 frame and simplify
Originally committed as revision 4926 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/parser.c')
-rw-r--r-- | libavcodec/parser.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 34d49c91e5..ca17acd7d2 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -873,9 +873,8 @@ static int ac3_parse(AVCodecParserContext *s1, len = s->inbuf_ptr - s->inbuf; if (s->frame_size == 0) { /* no header seen : find one. We need at least 7 bytes to parse it */ - len = AC3_HEADER_SIZE - len; - if (len > buf_size) - len = buf_size; + len = FFMIN(AC3_HEADER_SIZE - len, buf_size); + memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; s->inbuf_ptr += len; @@ -898,21 +897,21 @@ static int ac3_parse(AVCodecParserContext *s1, avctx->frame_size = 6 * 256; } } - } else if (len < s->frame_size) { - len = s->frame_size - len; - if (len > buf_size) - len = buf_size; + } else { + len = FFMIN(s->frame_size - len, buf_size); memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; s->inbuf_ptr += len; buf_size -= len; - } else { - *poutbuf = s->inbuf; - *poutbuf_size = s->frame_size; - s->inbuf_ptr = s->inbuf; - s->frame_size = 0; - break; + + if(s->inbuf_ptr - s->inbuf == s->frame_size){ + *poutbuf = s->inbuf; + *poutbuf_size = s->frame_size; + s->inbuf_ptr = s->inbuf; + s->frame_size = 0; + break; + } } } return buf_ptr - buf; |