]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/switcher.c
transcode/video: fit sar-calculation
[vlc] / modules / stream_out / switcher.c
index 9faf03eff2a2f97518feb9d561f1148c43da6558..14780596643158d728cbcc994c76523636f2fba7 100644 (file)
@@ -33,8 +33,9 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
-#include <vlc_vout.h>
 #include <vlc_avcodec.h>
+#include <vlc_filter.h>
+#include <vlc_cpu.h>
 
 #include <vlc_block.h>
 
@@ -131,7 +132,7 @@ vlc_module_begin ()
                  GOP_TEXT, GOP_LONGTEXT, true )
     add_integer( SOUT_CFG_PREFIX "qscale", 5, NULL,
                  QSCALE_TEXT, QSCALE_LONGTEXT, true )
-    add_bool( SOUT_CFG_PREFIX "mute-audio", 1, NULL,
+    add_bool( SOUT_CFG_PREFIX "mute-audio", true, NULL,
               AUDIO_TEXT, AUDIO_LONGTEXT, true )
 vlc_module_end ()
 
@@ -266,7 +267,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     var_Get( p_stream, SOUT_CFG_PREFIX "port", &val );
-    p_sys->i_fd = net_ListenUDP1( p_stream, NULL, val.i_int );
+    p_sys->i_fd = net_ListenUDP1( VLC_OBJECT(p_stream), NULL, val.i_int );
     if ( p_sys->i_fd < 0 )
     {
         free( p_sys );
@@ -323,16 +324,16 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         return NULL;
 
     if( p_fmt->i_cat == VIDEO_ES &&
-        ( p_fmt->i_codec == VLC_FOURCC('m', 'p', 'g', 'v') ||
+        ( p_fmt->i_codec == VLC_CODEC_MPGV ||
           p_fmt->i_codec == VLC_FOURCC('f', 'a', 'k', 'e') ) )
     {
         id->b_switcher_video = true;
-        p_fmt->i_codec = VLC_FOURCC('m', 'p', 'g', 'v');
+        p_fmt->i_codec = VLC_CODEC_MPGV;
         msg_Dbg( p_stream, "creating video switcher for fcc=`%4.4s' cmd:%d",
                  (char*)&p_fmt->i_codec, p_sys->i_cmd );
     }
     else if ( p_fmt->i_cat == AUDIO_ES &&
-              p_fmt->i_codec == VLC_FOURCC('m', 'p', 'g', 'a') &&
+              p_fmt->i_codec == VLC_CODEC_MPGA &&
               p_sys->b_audio )
     {
         int i_ff_codec = CODEC_ID_MP2;
@@ -388,13 +389,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         vlc_avcodec_lock();
         if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
         {
-            avcodec_unlock();
+            vlc_avcodec_unlock();
             msg_Err( p_stream, "cannot open encoder" );
             av_free( id->ff_enc_c );
             free( id );
             return NULL;
         }
-        avcodec_unlock();
+        vlc_avcodec_unlock();
 
         id->p_buffer_out = malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE * 2 );
         id->p_samples = calloc( id->ff_enc_c->frame_size * p_fmt->audio.i_channels,
@@ -509,7 +510,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
 
         while ( id->p_queued != NULL )
         {
-            mtime_t i_dts = 0;
+            mtime_t i_dts;
             int i;
 
             if ( p_sys->i_old_cmd != p_sys->i_cmd )
@@ -613,9 +614,12 @@ static int UnpackFromFile( sout_stream_t *p_stream, const char *psz_file,
         return -1;
     }
 
-    vout_InitPicture( VLC_OBJECT(p_stream), p_pic, VLC_FOURCC('I','4','2','0'),
-                      i_width, i_height,
-                      i_width * VOUT_ASPECT_FACTOR / i_height );
+    if( picture_Setup( p_pic, VLC_CODEC_I420,
+                       i_width, i_height, 1, 1 ) )
+    {
+        msg_Err( p_stream, "unknown chroma" );
+        return -1;
+    }
     for ( i = 0; i < p_pic->i_planes; i++ )
     {
         p_pic->p[i].p_pixels = malloc( p_pic->p[i].i_lines *
@@ -795,14 +799,14 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
         id->ff_enc_c->mb_decision = FF_MB_DECISION_SIMPLE;
         id->ff_enc_c->pix_fmt = PIX_FMT_YUV420P;
 
-        avcodec_lock();
+        vlc_avcodec_lock();
         if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
         {
-            avcodec_unlock();
+            vlc_avcodec_unlock();
             msg_Err( p_stream, "cannot open encoder" );
             return 0;
         }
-        avcodec_unlock();
+        vlc_avcodec_unlock();
 
         id->p_buffer_out = malloc( id->ff_enc_c->width * id->ff_enc_c->height * 3 );
         id->p_frame = avcodec_alloc_frame();
@@ -947,6 +951,7 @@ static block_t *AudioGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
     int i_out;
     block_t *p_out;
 
+    (void)p_stream;
     i_out = avcodec_encode_audio( id->ff_enc_c, id->p_buffer_out,
                                   2 * AVCODEC_MAX_AUDIO_FRAME_SIZE,
                                   id->p_samples );