]> git.sesse.net Git - vlc/blobdiff - modules/packetizer/mpegvideo.c
livehttp: add option to read key-uri and key-file from file
[vlc] / modules / packetizer / mpegvideo.c
index d6f27ee6768befc75604c87e7d406475be5d729d..2020cfb0d41ecc86ff78eedd8d961762296f8191 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * mpegvideo.c: parse and packetize an MPEG1/2 video stream
  *****************************************************************************
- * Copyright (C) 2001-2006 the VideoLAN team
+ * Copyright (C) 2001-2006 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -9,19 +9,19 @@
  *          Gildas Bazin <gbazin@videolan.org>
  *          Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
  *
- * 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.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -73,7 +73,7 @@ vlc_module_begin ()
     set_capability( "packetizer", 50 )
     set_callbacks( Open, Close )
 
-    add_bool( "packetizer-mpegvideo-sync-iframe", false, NULL, SYNC_INTRAFRAME_TEXT,
+    add_bool( "packetizer-mpegvideo-sync-iframe", false, SYNC_INTRAFRAME_TEXT,
               SYNC_INTRAFRAME_LONGTEXT, true )
 vlc_module_end ()
 
@@ -170,7 +170,7 @@ static int Open( vlc_object_t *p_this )
     /* Misc init */
     packetizer_Init( &p_sys->packetizer,
                      p_mp2v_startcode, sizeof(p_mp2v_startcode),
-                     NULL, 0,
+                     NULL, 0, 4,
                      PacketizeReset, PacketizeParse, PacketizeValidate, p_dec );
 
     p_sys->p_seq = NULL;
@@ -265,7 +265,7 @@ static block_t *GetCc( decoder_t *p_dec, bool pb_present[4] )
     if( p_sys->cc.i_data <= 0 )
         return NULL;
 
-    p_cc = block_New( p_dec, p_sys->cc.i_data);
+    p_cc = block_Alloc( p_sys->cc.i_data );
     if( p_cc )
     {
         memcpy( p_cc->p_buffer, p_sys->cc.p_data, p_sys->cc.i_data );
@@ -305,7 +305,7 @@ static block_t *PacketizeParse( void *p_private, bool *pb_ts_used, block_t *p_bl
     decoder_t *p_dec = p_private;
 
     /* Check if we have a picture start code */
-    *pb_ts_used = p_block->i_buffer >= 4 && p_block->p_buffer[3] == 0x00;
+    *pb_ts_used = p_block->p_buffer[3] == 0x00;
 
     return ParseMPEGBlock( p_dec, p_block );
 }
@@ -517,7 +517,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
         if( p_sys->p_seq &&
             p_sys->i_seq_old > p_sys->i_frame_rate/p_sys->i_frame_rate_base )
         {
-            /* Usefull for mpeg1: repeat sequence header every second */
+            /* Useful for mpeg1: repeat sequence header every second */
             block_ChainLastAppend( &p_sys->pp_last, block_Duplicate( p_sys->p_seq ) );
             if( p_sys->p_ext )
             {
@@ -538,7 +538,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
             /* Unofficial 15fps from Xing*/
             { 15, 1001 },
             /* Unofficial economy rates from libmpeg3 */
-            { 5, 1001 }, { 10, 1001 }, { 12, 1001 }, { 15, 1001 },
+            { 5000, 1001 }, { 1000, 1001 }, { 12000, 1001 }, { 15000, 1001 },
             { 1, 1 },  { 1, 1 }  /* invalid */
         };
 
@@ -610,10 +610,12 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
              * of aspect ratio change, we're screwed. --Meuuh
              */
 #if 0
-            p_dec->fmt_out.video.i_aspect =
+            p_dec->fmt_out.video.i_sar_num =
                 mpeg2_aspect[p_sys->i_aspect_ratio_info][0] *
-                VOUT_ASPECT_FACTOR /
-                mpeg2_aspect[p_sys->i_aspect_ratio_info][1];
+                p_dec->fmt_out.video.i_height;
+            p_dec->fmt_out.video.i_sar_den =
+                mpeg2_aspect[p_sys->i_aspect_ratio_info][1] *
+                p_dec->fmt_out.video.i_width;
 #endif
 
         }
@@ -628,7 +630,8 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
     }
     else if( p_frag->p_buffer[3] == 0xb2 && p_frag->i_buffer > 4 )
     {
-        cc_Extract( &p_sys->cc, &p_frag->p_buffer[4], p_frag->i_buffer - 4 );
+        cc_Extract( &p_sys->cc, p_sys->i_top_field_first,
+                    &p_frag->p_buffer[4], p_frag->i_buffer - 4 );
     }
     else if( p_frag->p_buffer[3] == 0x00 )
     {