diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-08-26 18:56:24 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-08-26 18:56:24 +0000 |
commit | 4e2d6a456d0c72b374abc1c9903969134b7c0304 (patch) | |
tree | 6be4c83725c7d14fa78e2f1b8244b2c4e8c0a10b /libavcodec/parser.c | |
parent | 6ff3b2b838ed0c8cce17229339aed214b0212bb3 (diff) | |
download | ffmpeg-4e2d6a456d0c72b374abc1c9903969134b7c0304.tar.gz |
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
Originally committed as revision 6103 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/parser.c')
-rw-r--r-- | libavcodec/parser.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 59087cdb82..9c50770b01 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -634,9 +634,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1, } /* no header seen : find one. We need at least MPA_HEADER_SIZE bytes to parse it */ - len = MPA_HEADER_SIZE - len; - if (len > buf_size) - len = buf_size; + len = FFMIN(MPA_HEADER_SIZE - len, buf_size); if (len > 0) { memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; @@ -736,14 +734,25 @@ static int mpegaudio_parse(AVCodecParserContext *s1, if (len < s->frame_size) { if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE) s->frame_size = MPA_MAX_CODED_FRAME_SIZE; - len = s->frame_size - len; - if (len > buf_size) - len = buf_size; + 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; } + + if(s->frame_size > 0 && buf_ptr - buf == s->inbuf_ptr - s->inbuf + && buf_size + buf_ptr - buf >= s->frame_size){ + if(s->header_count > 0){ + *poutbuf = buf; + *poutbuf_size = s->frame_size; + } + buf_ptr = buf + s->frame_size; + s->inbuf_ptr = s->inbuf; + s->frame_size = 0; + break; + } + // next_data: if (s->frame_size > 0 && (s->inbuf_ptr - s->inbuf) >= s->frame_size) { |