]> git.sesse.net Git - vlc/commitdiff
Fixed a few errors in flac packetizer.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 13 Feb 2010 13:25:56 +0000 (14:25 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 13 Feb 2010 14:12:00 +0000 (15:12 +0100)
modules/packetizer/flac.c

index 053dbef2985e4aa13ecd7bb93bce41e4c21b5599..4d29a514fe91f585ce11c3614f02e274924bbc66 100644 (file)
@@ -145,6 +145,7 @@ static void Close( vlc_object_t *p_this )
     decoder_t *p_dec = (decoder_t *)p_this;
     decoder_sys_t *p_sys = p_dec->p_sys;
 
+    block_BytestreamRelease( &p_sys->bytestream );
     free( p_sys );
 }
 
@@ -157,10 +158,10 @@ static void ProcessHeader( decoder_t *p_dec )
 
     bs_t bs;
 
-    if( !p_dec->fmt_in.i_extra )
+    if( p_dec->fmt_in.i_extra < 8 + 14 )
         return;
 
-    bs_init( &bs, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
+    bs_init( &bs, (uint8_t*)p_dec->fmt_in.p_extra + 8, p_dec->fmt_in.i_extra - 8 );
 
     p_sys->stream_info.min_blocksize = bs_read( &bs, 16 );
     p_sys->stream_info.max_blocksize = bs_read( &bs, 16 );
@@ -288,7 +289,8 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
                 date_Set( &p_sys->end_date, p_sys->i_pts );
             }
             p_sys->i_state = STATE_NEXT_SYNC;
-            p_sys->i_frame_size = 1;
+            p_sys->i_frame_size = p_sys->b_stream_info && p_sys->stream_info.min_framesize > 0 ?
+                                                            p_sys->stream_info.min_framesize : 1;
 
         case STATE_NEXT_SYNC:
             /* TODO: If pp_block == NULL, flush the buffer without checking the
@@ -320,6 +322,13 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
 
             if( p_sys->i_state != STATE_SEND_DATA )
             {
+                if( p_sys->b_stream_info && p_sys->stream_info.max_framesize > 0 &&
+                    p_sys->i_frame_size > p_sys->stream_info.max_framesize )
+                {
+                    block_SkipByte( &p_sys->bytestream );
+                    p_sys->i_state = STATE_NOSYNC;
+                    return NULL;
+                }
                 /* Need more data */
                 return NULL;
             }