[FFmpeg-cvslog] r17790 - trunk/libavcodec/flacdec.c

jbr subversion
Wed Mar 4 00:49:36 CET 2009


Author: jbr
Date: Wed Mar  4 00:49:36 2009
New Revision: 17790

Log:
flacdec: Avoid parsing the STREAMINFO multiple times.

Modified:
   trunk/libavcodec/flacdec.c

Modified: trunk/libavcodec/flacdec.c
==============================================================================
--- trunk/libavcodec/flacdec.c	Wed Mar  4 00:32:10 2009	(r17789)
+++ trunk/libavcodec/flacdec.c	Wed Mar  4 00:49:36 2009	(r17790)
@@ -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(AVCo
     /* 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(AVCodecCon
  */
 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;
     }




More information about the ffmpeg-cvslog mailing list