]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/switcher.c
For consistency, remove references to vlc from libvlc
[vlc] / modules / stream_out / switcher.c
index 586bace6754b168f4e8ebf9b8daa0b169befa5a5..7d5b9c7beeb2ad29794a9efc59929e012cdde273 100644 (file)
@@ -32,7 +32,8 @@
 #include <vlc/sout.h>
 #include <vlc/vout.h>
 
-#include "network.h"
+#include <charset.h>
+#include <network.h>
 
 #define HAVE_MMX
 #ifdef HAVE_FFMPEG_AVCODEC_H
@@ -50,7 +51,6 @@
 #define SOUT_CFG_PREFIX "sout-switcher-"
 #define MAX_PICTURES 10
 #define MAX_AUDIO 30
-#define AVCODEC_MAX_VIDEO_FRAME_SIZE (3*1024*1024)
 #define MAX_THRESHOLD 99999999
 
 /*****************************************************************************
@@ -353,19 +353,19 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 
         /* Set CPU capabilities */
         id->ff_enc_c->dsp_mask = 0;
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_MMX) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_MMX;
         }
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_MMXEXT) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT;
         }
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_3DNOW) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_3DNOW;
         }
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_SSE) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_SSE;
             id->ff_enc_c->dsp_mask |= FF_MM_SSE2;
@@ -398,7 +398,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         }
         if ( i == MAX_AUDIO )
         {
-            msg_Err( p_stream, "too many audio streams !" );
+            msg_Err( p_stream, "too many audio streams!" );
             free( id );
             return NULL;
         }
@@ -585,7 +585,7 @@ static int UnpackFromFile( sout_stream_t *p_stream, const char *psz_file,
                            picture_t *p_pic )
 {
     int i, j;
-    FILE *p_file = fopen( psz_file, "r" );
+    FILE *p_file = utf8_fopen( psz_file, "r" );
 
     if ( p_file == NULL )
     {
@@ -650,7 +650,7 @@ static void NetCommand( sout_stream_t *p_stream )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     char psz_buffer[10];
-    int i_len = net_ReadNonBlock( p_stream, p_sys->i_fd, NULL, psz_buffer,
+    int i_len = net_ReadNonBlock( p_stream, p_sys->i_fd, NULL, (char *)&psz_buffer[0],
                                   sizeof( psz_buffer ), 0 );
 
     if ( i_len > 0 )
@@ -726,19 +726,19 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
 
         /* Set CPU capabilities */
         id->ff_enc_c->dsp_mask = 0;
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_MMX) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_MMX;
         }
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_MMXEXT) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT;
         }
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_3DNOW) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_3DNOW;
         }
-        if( !(p_stream->p_libvlc->i_cpu & CPU_CAPABILITY_SSE) )
+        if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) )
         {
             id->ff_enc_c->dsp_mask |= FF_MM_SSE;
             id->ff_enc_c->dsp_mask |= FF_MM_SSE2;
@@ -778,7 +778,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
             return 0;
         }
 
-        id->p_buffer_out = malloc( AVCODEC_MAX_VIDEO_FRAME_SIZE );
+        id->p_buffer_out = malloc( id->ff_enc_c->width * id->ff_enc_c->height * 3 );
         id->p_frame = avcodec_alloc_frame();
         id->p_frame->linesize[0] = p_sys->p_pictures[p_sys->i_cmd-1].p[0].i_pitch;
         id->p_frame->linesize[1] = p_sys->p_pictures[p_sys->i_cmd-1].p[1].i_pitch;
@@ -832,7 +832,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
     }
 
     i_out = avcodec_encode_video( id->ff_enc_c, id->p_buffer_out,
-                                  AVCODEC_MAX_VIDEO_FRAME_SIZE,
+                                  id->ff_enc_c->width * id->ff_enc_c->height * 3,
                                   id->p_frame );
 
     if ( i_out <= 0 )
@@ -846,7 +846,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
         int mb_height = (id->ff_enc_c->height + 15) / 16;
         int h_chroma_shift, v_chroma_shift;
         int i;
-        
+
         avcodec_get_chroma_sub_sample( id->ff_enc_c->pix_fmt, &h_chroma_shift,
                                        &v_chroma_shift );
 
@@ -854,11 +854,11 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
             = id->ff_enc_c->coded_frame->motion_subsample_log2;
         id->p_frame->mb_type = malloc( ((mb_width + 1) * (mb_height + 1) + 1)
                                     * sizeof(uint32_t) );
-        p_stream->p_vlc->pf_memcpy( id->p_frame->mb_type,
+        p_stream->p_libvlc->pf_memcpy( id->p_frame->mb_type,
                                     id->ff_enc_c->coded_frame->mb_type,
                                     (mb_width + 1) * mb_height
                                       * sizeof(id->p_frame->mb_type[0]));
-        
+
         for ( i = 0; i < 2; i++ )
         {
             int stride = ((16 * mb_width )
@@ -871,7 +871,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
             {
                 id->p_frame->motion_val[i] = malloc( 2 * stride * height
                                                 * sizeof(int16_t) );
-                p_stream->p_vlc->pf_memcpy( id->p_frame->motion_val[i],
+                p_stream->p_libvlc->pf_memcpy( id->p_frame->motion_val[i],
                                      id->ff_enc_c->coded_frame->motion_val[i],
                                      2 * stride * height * sizeof(int16_t) );
             }
@@ -879,7 +879,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
             {
                 id->p_frame->ref_index[i] = malloc( b8_stride * 2 * mb_height
                                                * sizeof(int8_t) );
-                p_stream->p_vlc->pf_memcpy( id->p_frame->ref_index[i],
+                p_stream->p_libvlc->pf_memcpy( id->p_frame->ref_index[i],
                                  id->ff_enc_c->coded_frame->ref_index[i],
                                  b8_stride * 2 * mb_height * sizeof(int8_t));
             }
@@ -888,7 +888,7 @@ static block_t *VideoGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
 #endif
 
     p_out = block_New( p_stream, i_out );
-    p_stream->p_vlc->pf_memcpy( p_out->p_buffer, id->p_buffer_out, i_out );
+    p_stream->p_libvlc->pf_memcpy( p_out->p_buffer, id->p_buffer_out, i_out );
     p_out->i_length = p_buffer->i_length;
     p_out->i_pts = p_buffer->i_dts;
     p_out->i_dts = p_buffer->i_dts;
@@ -931,7 +931,7 @@ static block_t *AudioGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
         return NULL;
 
     p_out = block_New( p_stream, i_out );
-    p_stream->p_vlc->pf_memcpy( p_out->p_buffer, id->p_buffer_out, i_out );
+    p_stream->p_libvlc->pf_memcpy( p_out->p_buffer, id->p_buffer_out, i_out );
     p_out->i_length = p_buffer->i_length;
     p_out->i_pts = p_buffer->i_dts;
     p_out->i_dts = p_buffer->i_dts;
@@ -941,4 +941,3 @@ static block_t *AudioGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
 
     return p_out;
 }
-