summaryrefslogtreecommitdiff
path: root/libavcodec/flacdec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2009-03-03 23:49:36 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2009-03-03 23:49:36 +0000
commit7d0303587d755b1b1c910bd69debedfa57fddf9e (patch)
tree9b8f633140c6f1a04e1a0c4eea5d8e152ededa45 /libavcodec/flacdec.c
parent636f1c4cd036354a91f7c0ba5729195077edb49d (diff)
downloadffmpeg-7d0303587d755b1b1c910bd69debedfa57fddf9e.tar.gz
flacdec: Avoid parsing the STREAMINFO multiple times.
Originally committed as revision 17790 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flacdec.c')
-rw-r--r--libavcodec/flacdec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 895214c746..eaccfa52d4 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -66,6 +66,7 @@ typedef struct FLACContext {
int sample_shift; ///< shift required to make output samples 16-bit or 32-bit
int is32; ///< flag to indicate if output should be 32-bit instead of 16-bit
enum decorrelation_type decorrelation; ///< channel decorrelation type in the current frame
+ int got_streaminfo; ///< indicates if the STREAMINFO has been read
int32_t *decoded[MAX_CHANNELS]; ///< decoded samples
uint8_t *bitstream;
@@ -144,6 +145,7 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
/* initialize based on the demuxer-supplied streamdata header */
ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
allocate_buffers(s);
+ s->got_streaminfo = 1;
return 0;
}
@@ -226,7 +228,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
*/
static int metadata_parse(FLACContext *s)
{
- int i, metadata_last, metadata_type, metadata_size, streaminfo_updated=0;
+ int i, metadata_last, metadata_type, metadata_size;
int initial_pos= get_bits_count(&s->gb);
if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
@@ -245,10 +247,11 @@ static int metadata_parse(FLACContext *s)
if (metadata_size) {
switch (metadata_type) {
case FLAC_METADATA_TYPE_STREAMINFO:
+ if (!s->got_streaminfo) {
ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s,
s->gb.buffer+get_bits_count(&s->gb)/8);
- streaminfo_updated = 1;
-
+ s->got_streaminfo = 1;
+ }
default:
for (i = 0; i < metadata_size; i++)
skip_bits(&s->gb, 8);
@@ -256,7 +259,7 @@ static int metadata_parse(FLACContext *s)
}
} while (!metadata_last);
- if (streaminfo_updated)
+ if (s->got_streaminfo)
allocate_buffers(s);
return 1;
}