]> git.sesse.net Git - vlc/blobdiff - modules/demux/ogg.c
Used VLC_TS_0 in rawvid demuxer.
[vlc] / modules / demux / ogg.c
index 5e50b7a55297a0b22759b5335d9d941525a1c237..7f5b240c2d0cebb35a544c2308e9a9c0c382d793 100644 (file)
@@ -408,7 +408,7 @@ static int Demux( demux_t * p_demux )
                     else
                     {
                         es_out_Control( p_demux->out, ES_OUT_SET_PCR,
-                                        p_stream->i_pcr );
+                                        VLC_TS_0 + p_stream->i_pcr );
                     }
                     continue;
                 }
@@ -439,7 +439,7 @@ static int Demux( demux_t * p_demux )
     }
 
     if( p_sys->i_pcr >= 0 )
-        es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr );
+        es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_pcr );
 
     return 1;
 }
@@ -671,7 +671,9 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         p_stream->p_headers =
             realloc( p_sav = p_stream->p_headers, p_stream->i_headers +
                      p_oggpacket->bytes + (b_store_size ? 2 : 0) + (b_store_num_headers ? 1 : 0) );
-        if( p_stream->p_headers )
+        if( !p_stream->p_headers )
+            p_stream->p_headers = p_sav;
+        else
         {
             uint8_t *p_extra = p_stream->p_headers + p_stream->i_headers;
 
@@ -714,10 +716,6 @@ static void Ogg_DecodePacket( demux_t *p_demux,
                 p_ogg->i_bos--;
             }
         }
-        else
-        {
-                p_stream->p_headers = p_sav;
-        }
 
         b_selected = false; /* Discard the header packet */
     }
@@ -738,7 +736,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
 
                 /* Call the pace control */
                 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
-                                p_stream->i_pcr );
+                                VLC_TS_0 + p_stream->i_pcr );
             }
 
             p_stream->i_previous_pcr = p_stream->i_pcr;
@@ -765,7 +763,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
                 es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
 
                 /* Call the pace control */
-                es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_stream->i_pcr );
+                es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_stream->i_pcr );
             }
         }
     }
@@ -794,9 +792,9 @@ static void Ogg_DecodePacket( demux_t *p_demux,
     if( !( p_block = block_New( p_demux, p_oggpacket->bytes ) ) ) return;
 
     /* Normalize PTS */
-    if( i_pts == 0 ) i_pts = 1;
-    else if( i_pts == -1 && i_interpolated_pts == 0 ) i_pts = 1;
-    else if( i_pts == -1 ) i_pts = 0;
+    if( i_pts == 0 ) i_pts = VLC_TS_0;
+    else if( i_pts == -1 && i_interpolated_pts == 0 ) i_pts = VLC_TS_0;
+    else if( i_pts == -1 ) i_pts = VLC_TS_INVALID;
 
     if( p_stream->fmt.i_cat == AUDIO_ES )
         p_block->i_dts = p_block->i_pts = i_pts;
@@ -806,7 +804,13 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         p_block->i_length = 0;
     }
     else if( p_stream->fmt.i_codec == VLC_CODEC_THEORA )
+    {
         p_block->i_dts = p_block->i_pts = i_pts;
+        if( (p_oggpacket->granulepos & ((1<<p_stream->i_granule_shift)-1)) == 0 )
+        {
+            p_block->i_flags |= BLOCK_FLAG_TYPE_I;
+        }
+    }
     else if( p_stream->fmt.i_codec == VLC_CODEC_DIRAC )
     {
         ogg_int64_t dts = p_oggpacket->granulepos >> 31;
@@ -815,7 +819,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         uint64_t u_pnum = dts + delay;
 
         p_block->i_dts = p_stream->i_pcr;
-        p_block->i_pts = 0;
+        p_block->i_pts = VLC_TS_INVALID;
         /* NB, OggDirac granulepos values are in units of 2*picturerate */
         if( -1 != p_oggpacket->granulepos )
             p_block->i_pts = u_pnum * INT64_C(1000000) / p_stream->f_rate / 2;
@@ -823,7 +827,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
     else
     {
         p_block->i_dts = i_pts;
-        p_block->i_pts = 0;
+        p_block->i_pts = VLC_TS_INVALID;
     }
 
     if( p_stream->fmt.i_codec != VLC_CODEC_VORBIS &&
@@ -1103,7 +1107,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
                     /* Check for audio header (old format) */
                     else if( GetDWLE((oggpacket.packet+96)) == 0x05589F81 )
                     {
-                        unsigned int i_extra_size;
+                        int i_extra_size;
                         unsigned int i_format_tag;
 
                         p_stream->fmt.i_cat = AUDIO_ES;
@@ -1214,7 +1218,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
                     else if( !strncmp( st->streamtype, "audio", 5 ) )
                     {
                         char p_buffer[5];
-                        unsigned int i_extra_size;
+                        int i_extra_size;
                         int i_format_tag;
 
                         st->sh.audio.channels = GetWLE( &oggpacket.packet[1+44] );
@@ -1549,7 +1553,7 @@ static void Ogg_ExtractMeta( demux_t *p_demux, vlc_fourcc_t i_codec, const uint8
 
     switch( i_codec )
     {
-    /* 3 headers with the 2° one being the comments */
+    /* 3 headers with the 2° one being the comments */
     case VLC_CODEC_VORBIS:
         Ogg_ExtractXiphMeta( p_demux, p_headers, i_headers, 1+6, false );
         break;
@@ -1560,7 +1564,7 @@ static void Ogg_ExtractMeta( demux_t *p_demux, vlc_fourcc_t i_codec, const uint8
         Ogg_ExtractXiphMeta( p_demux, p_headers, i_headers, 0, false );
         break;
 
-    /* N headers with the 2° one being the comments */
+    /* N headers with the 2° one being the comments */
     case VLC_CODEC_KATE:
         /* 1 byte for header type, 7 bit for magic, 1 reserved zero byte */
         Ogg_ExtractXiphMeta( p_demux, p_headers, i_headers, 1+7+1, true );
@@ -1826,7 +1830,7 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *p_this,
             uint8_t *p = memchr( &p_oggpacket->packet[42], '\r',
                                  p_oggpacket->bytes - 1 );
             if( p && p[0] == '\r' && p[1] == '\n' )
-                sscanf( (char*)(&p_oggpacket->packet[42]), "%1024s\r\n",
+                sscanf( (char*)(&p_oggpacket->packet[42]), "%1023s\r\n",
                         content_type_string );
         }