[FFmpeg-cvslog] r14281 - trunk/libavcodec/flac.c
michael
subversion
Fri Jul 18 14:03:22 CEST 2008
Author: michael
Date: Fri Jul 18 14:03:21 2008
New Revision: 14281
Log:
Support reading large metadata.
fixes issue187
Modified:
trunk/libavcodec/flac.c
Modified: trunk/libavcodec/flac.c
==============================================================================
--- trunk/libavcodec/flac.c (original)
+++ trunk/libavcodec/flac.c Fri Jul 18 14:03:21 2008
@@ -181,6 +181,7 @@ void ff_flac_parse_streaminfo(AVCodecCon
static int metadata_parse(FLACContext *s)
{
int i, metadata_last, metadata_type, metadata_size, streaminfo_updated=0;
+ int initial_pos= get_bits_count(&s->gb);
if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
skip_bits(&s->gb, 32);
@@ -191,6 +192,11 @@ static int metadata_parse(FLACContext *s
metadata_type = get_bits(&s->gb, 7);
metadata_size = get_bits_long(&s->gb, 24);
+ if(get_bits_count(&s->gb) + 8*metadata_size > s->gb.size_in_bits){
+ skip_bits_long(&s->gb, initial_pos - get_bits_count(&s->gb));
+ break;
+ }
+
av_log(s->avctx, AV_LOG_DEBUG,
" metadata block: flag = %d, type = %d, size = %d\n",
metadata_last, metadata_type, metadata_size);
@@ -612,9 +618,16 @@ static int flac_decode_frame(AVCodecCont
}
if(1 && s->max_framesize){//FIXME truncated
- buf_size= FFMAX(FFMIN(buf_size, s->max_framesize - s->bitstream_size), 0);
+ if(s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))
+ buf_size= FFMIN(buf_size, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));
input_buf_size= buf_size;
+ if(s->bitstream_size + buf_size < buf_size || s->bitstream_index + s->bitstream_size + buf_size < s->bitstream_index)
+ return -1;
+
+ if(s->allocated_bitstream_size < s->bitstream_size + buf_size)
+ s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + buf_size);
+
if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){
// printf("memmove\n");
memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
More information about the ffmpeg-cvslog
mailing list