[vlc-commits] demux: ogg: fix headers validation

Francois Cartegnie git at videolan.org
Tue Sep 23 15:31:46 CEST 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep 23 15:27:34 2014 +0200| [d65a02c1d5771faf431ba73e716be9e88adcee21] | committer: Francois Cartegnie

demux: ogg: fix headers validation

refs #12270

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

 modules/demux/ogg.c |   27 +++++++++++++++------------
 modules/demux/ogg.h |    2 +-
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index bd3b449..315ec90 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -107,8 +107,11 @@ typedef struct
 } stream_header_t;
 
 #define VORBIS_HEADER_IDENTIFICATION 1
-#define VORBIS_HEADER_COMMENT 2
-#define VORBIS_HEADER_SETUP 3
+#define VORBIS_HEADER_COMMENT        2
+#define VORBIS_HEADER_SETUP          3
+#define VORBIS_HEADER_TO_FLAG(i)     (1 << (i - 1))
+#define VORBIS_HEADERS_VALID(p_stream) \
+    ((p_stream->special.vorbis.i_headers_flags & 0b111) == 0b111)
 
 /*****************************************************************************
  * Local prototypes
@@ -516,7 +519,7 @@ static int Demux( demux_t * p_demux )
 #ifdef HAVE_LIBVORBIS
                 case VLC_CODEC_VORBIS:
                 {
-                    if( p_stream->special.vorbis.b_invalid )
+                    if( !VORBIS_HEADERS_VALID(p_stream) )
                     {
                         msg_Err( p_demux, "missing vorbis headers, can't compute block size" );
                         break;
@@ -997,7 +1000,7 @@ static void Ogg_UpdatePCR( demux_t *p_demux, logical_stream_t *p_stream,
 #ifdef HAVE_LIBVORBIS
         else if ( p_stream->fmt.i_codec == VLC_CODEC_VORBIS &&
                   p_stream->special.vorbis.p_info &&
-                  !p_stream->special.vorbis.b_invalid &&
+                  VORBIS_HEADERS_VALID(p_stream) &&
                   p_stream->i_previous_granulepos > 0 )
         {
             long i_blocksize = vorbis_packet_blocksize(
@@ -2126,7 +2129,7 @@ static void Ogg_CleanSpecificData( logical_stream_t *p_stream )
     {
         FREENULL( p_stream->special.vorbis.p_info );
         FREENULL( p_stream->special.vorbis.p_comment );
-        p_stream->special.vorbis.b_invalid = false;
+        p_stream->special.vorbis.i_headers_flags = 0;
     }
 #else
     VLC_UNUSED( p_stream );
@@ -2578,7 +2581,6 @@ static void Ogg_DecodeVorbisHeader( logical_stream_t *p_stream,
         {
             FREENULL( p_stream->special.vorbis.p_info );
             FREENULL( p_stream->special.vorbis.p_comment );
-            p_stream->special.vorbis.b_invalid = true;
             break;
         }
         vorbis_info_init( p_stream->special.vorbis.p_info );
@@ -2587,12 +2589,13 @@ static void Ogg_DecodeVorbisHeader( logical_stream_t *p_stream,
 
     case VORBIS_HEADER_COMMENT:
     case VORBIS_HEADER_SETUP:
-        if ( p_stream->special.vorbis.p_info && ! p_stream->special.vorbis.b_invalid )
-        {
-            p_stream->special.vorbis.b_invalid = ( 0 != vorbis_synthesis_headerin(
-                p_stream->special.vorbis.p_info,
-                p_stream->special.vorbis.p_comment, p_oggpacket ) );
-        }
+        if ( !p_stream->special.vorbis.p_info ||
+             vorbis_synthesis_headerin(
+                 p_stream->special.vorbis.p_info,
+                 p_stream->special.vorbis.p_comment, p_oggpacket ) )
+            break;
+
+        p_stream->special.vorbis.i_headers_flags |= VORBIS_HEADER_TO_FLAG(i_number);
         // ft
 
     default:
diff --git a/modules/demux/ogg.h b/modules/demux/ogg.h
index dda4684..ff6fb18 100644
--- a/modules/demux/ogg.h
+++ b/modules/demux/ogg.h
@@ -127,7 +127,7 @@ typedef struct logical_stream_s
         {
             vorbis_info *p_info;
             vorbis_comment *p_comment;
-            bool b_invalid;
+            int i_headers_flags;
             int i_prev_blocksize;
         } vorbis;
 #endif



More information about the vlc-commits mailing list