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

Francois Cartegnie git at videolan.org
Tue Sep 23 16:35:31 CEST 2014


vlc/vlc-2.2 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep 23 15:27:34 2014 +0200| [faf9aa57fa3d27e0f7f9bebeb334250f37a4e731] | committer: Jean-Baptiste Kempf

demux: ogg: fix headers validation

refs #12270

(cherry picked from commit d65a02c1d5771faf431ba73e716be9e88adcee21)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 5d30cee..b895ed3 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -106,8 +106,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
@@ -509,7 +512,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;
@@ -990,7 +993,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(
@@ -2139,7 +2142,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 );
@@ -2528,7 +2531,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 );
@@ -2537,12 +2539,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