]> git.sesse.net Git - vlc/blobdiff - modules/demux/nsv.c
Qt: add events extender
[vlc] / modules / demux / nsv.c
index a156c1ccd0595db37a7afb2bd83092694ce6caa2..049b06819ede996e1f8789525f40d685b2a807ab 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * nsv.c: NullSoft Video demuxer.
  *****************************************************************************
- * Copyright (C) 2004-2007 the VideoLAN team
+ * Copyright (C) 2004-2007 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -104,10 +104,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->p_sys = p_sys;
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
 
     es_format_Init( &p_sys->fmt_audio, AUDIO_ES, 0 );
     p_sys->p_audio = NULL;
@@ -118,7 +122,7 @@ static int Open( vlc_object_t *p_this )
     es_format_Init( &p_sys->fmt_sub, SPU_ES, 0 );
     p_sys->p_sub = NULL;
 
-    p_sys->i_pcr   = 1;
+    p_sys->i_pcr   = 0;
     p_sys->i_time  = 0;
     p_sys->i_pcr_inc = 0;
 
@@ -203,7 +207,7 @@ static int Demux( demux_t *p_demux )
     }
 
     /* Set PCR */
-    es_out_Control( p_demux->out, ES_OUT_SET_PCR, (int64_t)p_sys->i_pcr );
+    es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_pcr );
 
     /* Read video */
     i_size = ( header[0] >> 4 ) | ( header[1] << 4 ) | ( header[2] << 12 );
@@ -251,8 +255,8 @@ static int Demux( demux_t *p_demux )
                     }
 
                     /* Skip the first part (it is the language name) */
-                    p_frame->i_pts = p_sys->i_pcr;
-                    p_frame->i_dts = p_sys->i_pcr + 4000000;    /* 4s */
+                    p_frame->i_pts = VLC_TS_0 + p_sys->i_pcr;
+                    p_frame->i_dts = VLC_TS_0 + p_sys->i_pcr + 4000000;    /* 4s */
 
                     es_out_Send( p_demux->out, p_sys->p_sub, p_frame );
                 }
@@ -272,7 +276,7 @@ static int Demux( demux_t *p_demux )
         /* msg_Dbg( p_demux, "frame video size=%d", i_size ); */
         if( i_size > 0 && ( p_frame = stream_Block( p_demux->s, i_size ) ) )
         {
-            p_frame->i_dts = p_sys->i_pcr;
+            p_frame->i_dts = VLC_TS_0 + p_sys->i_pcr;
             es_out_Send( p_demux->out, p_sys->p_video, p_frame );
         }
     }
@@ -300,7 +304,7 @@ static int Demux( demux_t *p_demux )
         if( ( p_frame = stream_Block( p_demux->s, i_size ) ) )
         {
             p_frame->i_dts =
-            p_frame->i_pts = p_sys->i_pcr;
+            p_frame->i_pts = VLC_TS_0 + p_sys->i_pcr;
             es_out_Send( p_demux->out, p_sys->p_audio, p_frame );
         }
     }
@@ -455,7 +459,7 @@ static int ReadNSVf( demux_t *p_demux )
     return stream_Read( p_demux->s, NULL, i_size ) == i_size ? VLC_SUCCESS : VLC_EGENERIC;
 }
 /*****************************************************************************
- * ReadNSVf:
+ * ReadNSVs:
  *****************************************************************************/
 static int ReadNSVs( demux_t *p_demux )
 {
@@ -488,6 +492,7 @@ static int ReadNSVs( demux_t *p_demux )
         case VLC_FOURCC( 'V', 'P', '6', '0' ):
         case VLC_FOURCC( 'V', 'P', '6', '1' ):
         case VLC_FOURCC( 'V', 'P', '6', '2' ):
+        case VLC_FOURCC( 'V', 'P', '8', '0' ):
         case VLC_FOURCC( 'H', '2', '6', '4' ):
         case VLC_FOURCC( 'N', 'O', 'N', 'E' ):
             break;