[vlc-devel] commit: Fixed a few errors in flac packetizer. (Laurent Aimar )

git version control git at videolan.org
Sat Feb 13 15:12:22 CET 2010


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Feb 13 14:25:56 2010 +0100| [1967b52da22aaba559635ecd518aa48873cf0f08] | committer: Laurent Aimar 

Fixed a few errors in flac packetizer.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1967b52da22aaba559635ecd518aa48873cf0f08
---

 modules/packetizer/flac.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules/packetizer/flac.c b/modules/packetizer/flac.c
index 053dbef..4d29a51 100644
--- a/modules/packetizer/flac.c
+++ b/modules/packetizer/flac.c
@@ -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;
             }




More information about the vlc-devel mailing list