]> git.sesse.net Git - vlc/blobdiff - modules/demux/pva.c
Add V4L2 64-bits integer controls (refs #5302)
[vlc] / modules / demux / pva.c
index f94f5f61bc83fd61731ee6285c716eaa74e20564..d25702de7a6b34900b033479fcb8d70693f0b438 100644 (file)
@@ -84,7 +84,7 @@ static int Open( vlc_object_t *p_this )
     es_format_t  fmt;
     const uint8_t *p_peek;
 
-    if( stream_Peek( p_demux->s, &p_peek, 5 ) < 5 ) return VLC_EGENERIC;
+    if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 ) return VLC_EGENERIC;
     if( p_peek[0] != 'A' || p_peek[1] != 'V' || p_peek[4] != 0x55 )
     {
         /* In case we had forced this demuxer we try to resynch */
@@ -92,10 +92,14 @@ static int Open( vlc_object_t *p_this )
             return VLC_EGENERIC;
     }
 
+    p_sys = malloc( sizeof( demux_sys_t ) );
+    if( unlikely(p_sys == NULL) )
+        return VLC_ENOMEM;
+
     /* Fill p_demux field */
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_demux->p_sys = p_sys;
 
     /* Register one audio and one video stream */
     es_format_Init( &fmt, AUDIO_ES, VLC_CODEC_MPGA );
@@ -133,6 +137,8 @@ static void Close( vlc_object_t *p_this )
 
 /*****************************************************************************
  * Demux:
+ *****************************************************************************
+ * See http://multimedia.cx/mirror/av_format_v1.pdf
  *****************************************************************************/
 static int Demux( demux_t *p_demux )
 {
@@ -254,7 +260,7 @@ static int Demux( demux_t *p_demux )
                 p_frame->p_buffer += 8;
                 p_frame->i_buffer -= 8;
                 /* XXX this a hack, some streams aren't compliant and
-                 * doesn't set pes_start flag */
+                 * don't set pes_start flag */
                 if( p_sys->p_pes && p_frame->i_buffer > 4 &&
                     p_frame->p_buffer[0] == 0x00 &&
                     p_frame->p_buffer[1] == 0x00 &&
@@ -390,6 +396,7 @@ static void ParsePES( demux_t *p_demux )
     /* FIXME find real max size */
     block_ChainExtract( p_pes, hdr, 30 );
 
+    /* See ยง2.4.3.6 of ISO 13818-1 */
     if( hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 1 )
     {
         msg_Warn( p_demux, "invalid hdr [0x%2.2x:%2.2x:%2.2x:%2.2x]",
@@ -397,7 +404,8 @@ static void ParsePES( demux_t *p_demux )
         block_ChainRelease( p_pes );
         return;
     }
-    GetWBE( &hdr[4] ); /* i_pes_size */
+    // hdr[4] i_pes_size, 2 bytes
+    // hdr[6] Marker -> original_or_copy
 
     /* we assume mpeg2 PES */
     i_skip = hdr[8] + 9;