mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
flacdec: Avoid parsing the STREAMINFO multiple times.
Originally committed as revision 17790 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
636f1c4cd0
commit
7d0303587d
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user