]> git.sesse.net Git - vlc/commitdiff
* include/input_ext-plugins.h: export input_DecodeBlock().
authorGildas Bazin <gbazin@videolan.org>
Sun, 30 Nov 2003 22:47:55 +0000 (22:47 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sun, 30 Nov 2003 22:47:55 +0000 (22:47 +0000)
* modules/stream_out/display.c: simplifications.
* modules/stream_out/transcode.c: memset of sout_stream_sys_t.
* modules/packetizer/mpeg4video.c: not all containers provide a pts info, in which case we use the dts.

include/input_ext-plugins.h
modules/packetizer/mpeg4video.c
modules/stream_out/display.c
modules/stream_out/transcode.c

index 2b50d33860a4751be76ce888cd58da31be37cb9a..5995a7f4f888e6f57bd19112014fbf5998194c9d 100644 (file)
@@ -3,7 +3,7 @@
  *                      but exported to plug-ins
  *****************************************************************************
  * Copyright (C) 1999-2002 VideoLAN
- * $Id: input_ext-plugins.h,v 1.45 2003/11/24 20:50:45 fenrir Exp $
+ * $Id: input_ext-plugins.h,v 1.46 2003/11/30 22:47:55 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -59,7 +59,7 @@ decoder_t * input_RunDecoder( input_thread_t *, es_descriptor_t * );
 void input_EndDecoder( input_thread_t *, es_descriptor_t * );
 
 VLC_EXPORT( void, input_DecodePES, ( decoder_t *, pes_packet_t * ) );
-void input_DecodeBlock( decoder_t *, block_t * );
+VLC_EXPORT( void, input_DecodeBlock,( decoder_t *, block_t * ) );
 
 void input_EscapeDiscontinuity( input_thread_t * );
 void input_EscapeAudioDiscontinuity( input_thread_t * );
index 68943d1f6d2d9bbf83debd1e964d062357df2c65..1dad70f91da8f1cdfd84b7af4923eb90663c0503 100644 (file)
@@ -2,7 +2,7 @@
  * mpeg4video.c: mpeg 4 video packetizer
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: mpeg4video.c,v 1.18 2003/11/30 22:14:39 fenrir Exp $
+ * $Id: mpeg4video.c,v 1.19 2003/11/30 22:47:55 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
@@ -282,7 +282,17 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
         else if( p_start[3] == 0xb6 )
         {
             p_sys->b_vop = VLC_TRUE;
-            p_sys->i_pts = p_block->i_pts;
+
+            /* The pts information is not available in all the containers.
+             * FIXME: calculate the pts correctly */
+            if( p_sys->i_pts )
+            {
+                p_sys->i_pts = p_block->i_pts;
+            }
+            else
+            {
+                p_sys->i_pts = p_block->i_dts;
+            }
             p_sys->i_dts = p_block->i_dts;
         }
         p_start += 4; /* Next */
index a5d444b073139996f1ff8bf37eeaa371275f8a42..2c0073f66aa01a7d0f0b42c3d4267a02dd701a98 100644 (file)
@@ -2,7 +2,7 @@
  * display.c
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: display.c,v 1.9 2003/11/26 22:56:04 gbazin Exp $
+ * $Id: display.c,v 1.10 2003/11/30 22:47:55 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -125,7 +125,7 @@ struct sout_stream_id_t
 };
 
 
-static sout_stream_id_t * Add      ( sout_stream_t *p_stream, es_format_t *p_fmt )
+static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     sout_stream_id_t *id;
@@ -142,7 +142,7 @@ static sout_stream_id_t * Add      ( sout_stream_t *p_stream, es_format_t *p_fmt
     id->p_es = input_AddES( p_sys->p_input,
                             NULL,           /* no program */
                             12,             /* es_id */
-                            p_fmt->i_cat, /* UNKNOWN_ES,*/    /* es category */
+                            p_fmt->i_cat,   /* es category */
                             NULL,           /* description */
                             0 );            /* no extra data */
 
@@ -157,56 +157,8 @@ static sout_stream_id_t * Add      ( sout_stream_t *p_stream, es_format_t *p_fmt
     id->p_es->i_stream_id   = 1;
     id->p_es->i_fourcc      = p_fmt->i_codec;
     id->p_es->b_force_decoder = VLC_TRUE;
-    switch( p_fmt->i_cat )
-    {
-        case AUDIO_ES:
-            id->p_es->p_bitmapinfoheader = NULL;
-            id->p_es->p_waveformatex =
-                malloc( sizeof( WAVEFORMATEX ) + p_fmt->i_extra );
-#define p_wf    ((WAVEFORMATEX*)id->p_es->p_waveformatex)
-            p_wf->wFormatTag     = WAVE_FORMAT_UNKNOWN;
-            p_wf->nChannels      = p_fmt->audio.i_channels;
-            p_wf->nSamplesPerSec = p_fmt->audio.i_rate;
-            p_wf->nAvgBytesPerSec= p_fmt->i_bitrate / 8;
-            p_wf->nBlockAlign    = p_fmt->audio.i_blockalign;
-            p_wf->wBitsPerSample = 0;
-            p_wf->cbSize         = p_fmt->i_extra;
-            if( p_fmt->i_extra > 0 )
-            {
-                memcpy( &p_wf[1],
-                        p_fmt->p_extra,
-                        p_fmt->i_extra );
-            }
-#undef p_wf
-            break;
-        case VIDEO_ES:
-            id->p_es->p_waveformatex = NULL;
-            id->p_es->p_bitmapinfoheader = malloc( sizeof( BITMAPINFOHEADER ) + p_fmt->i_extra );
-#define p_bih ((BITMAPINFOHEADER*)id->p_es->p_bitmapinfoheader)
-            p_bih->biSize   = sizeof( BITMAPINFOHEADER ) + p_fmt->i_extra;
-            p_bih->biWidth  = p_fmt->video.i_width;
-            p_bih->biHeight = p_fmt->video.i_height;
-            p_bih->biPlanes   = 0;
-            p_bih->biBitCount = 0;
-            p_bih->biCompression = 0;
-            p_bih->biSizeImage   = 0;
-            p_bih->biXPelsPerMeter = 0;
-            p_bih->biYPelsPerMeter = 0;
-            p_bih->biClrUsed       = 0;
-            p_bih->biClrImportant  = 0;
-            if( p_fmt->i_extra > 0 )
-            {
-                memcpy( &p_bih[1],
-                        p_fmt->p_extra,
-                        p_fmt->i_extra );
-            }
-#undef p_bih
-            break;
-        default:
-            msg_Err( p_stream, "unknown es type" );
-            free( id );
-            return NULL;
-    }
+
+    es_format_Copy( &id->p_es->fmt, p_fmt );
 
     if( input_SelectES( p_sys->p_input, id->p_es ) )
     {
@@ -222,7 +174,7 @@ static sout_stream_id_t * Add      ( sout_stream_t *p_stream, es_format_t *p_fmt
     return id;
 }
 
-static int     Del      ( sout_stream_t *p_stream, sout_stream_id_t *id )
+static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
 
@@ -241,44 +193,20 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
     while( p_buffer )
     {
         sout_buffer_t *p_next;
-        pes_packet_t *p_pes;
-        data_packet_t   *p_data;
+        block_t *p_block;
 
-        if( p_buffer->i_size > 0 )
+        if( p_buffer->i_size > 0 &&
+            (p_block = block_New( p_stream, p_buffer->i_size )) )
         {
-            if( !( p_pes = input_NewPES( p_sys->p_input->p_method_data ) ) )
-            {
-                msg_Err( p_stream, "cannot allocate new PES" );
-                return VLC_EGENERIC;
-            }
-            if( !( p_data = input_NewPacket( p_sys->p_input->p_method_data,
-                                             p_buffer->i_size ) ) )
-            {
-                msg_Err( p_stream, "cannot allocate new data_packet" );
-                return VLC_EGENERIC;
-            }
-            p_data->p_payload_end = p_data->p_payload_start + p_buffer->i_size;
-
-            p_pes->i_dts = p_buffer->i_dts <= 0 ? 0 :
-                           p_buffer->i_dts + p_sys->i_delay;
-            p_pes->i_pts = p_buffer->i_pts <= 0 ? 0 :
-                           p_buffer->i_pts + p_sys->i_delay;
-            p_pes->p_first = p_pes->p_last = p_data;
-            p_pes->i_nb_data = 1;
-            p_pes->i_pes_size = p_buffer->i_size;
-
-            p_stream->p_vlc->pf_memcpy( p_data->p_payload_start,
-                                        p_buffer->p_buffer,
-                                        p_buffer->i_size );
-
-            if( id->p_es->p_dec )
-            {
-                input_DecodePES( id->p_es->p_dec, p_pes );
-            }
-            else
-            {
-                input_DeletePES( p_sys->p_input->p_method_data, p_pes );
-            }
+            p_block->i_dts = p_buffer->i_dts <= 0 ? 0 :
+                             p_buffer->i_dts + p_sys->i_delay;
+            p_block->i_pts = p_buffer->i_pts <= 0 ? 0 :
+                             p_buffer->i_pts + p_sys->i_delay;
+
+            p_stream->p_vlc->pf_memcpy( p_block->p_buffer,
+                                        p_buffer->p_buffer, p_buffer->i_size );
+
+            input_DecodeBlock( id->p_es->p_dec, p_block );
         }
 
         /* *** go to next buffer *** */
@@ -289,4 +217,3 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
 
     return VLC_SUCCESS;
 }
-
index dccbfa080fd60171fcf9eeb073b1fe57e218900f..7c0b7edc10021c583be5b3454e52dc7031bb2181 100644 (file)
@@ -2,7 +2,7 @@
  * transcode.c
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: transcode.c,v 1.56 2003/11/29 18:36:13 massiot Exp $
+ * $Id: transcode.c,v 1.57 2003/11/30 22:47:55 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -125,20 +125,11 @@ static int Open( vlc_object_t *p_this )
     char *codec;
 
     p_sys = malloc( sizeof( sout_stream_sys_t ) );
+    memset( p_sys, 0, sizeof(struct sout_stream_sys_t) );
     p_sys->p_out = sout_stream_new( p_stream->p_sout, p_stream->psz_next );
 
-    p_sys->i_acodec      = 0;
-    p_sys->i_sample_rate = 0;
-    p_sys->i_channels    = 0;
-    p_sys->i_abitrate    = 0;
-
-    p_sys->i_vcodec     = 0;
-    p_sys->i_vbitrate   = 0;
     p_sys->i_vtolerance = -1;
-    p_sys->i_width      = 0;
-    p_sys->i_height     = 0;
     p_sys->i_key_int    = -1;
-    p_sys->i_b_frames   = 0;
     p_sys->i_qmin       = 2;
     p_sys->i_qmax       = 31;
 #if LIBAVCODEC_BUILD >= 4673
@@ -146,12 +137,6 @@ static int Open( vlc_object_t *p_this )
 #else
     p_sys->i_hq         = VLC_FALSE;
 #endif
-    p_sys->b_deinterlace= VLC_FALSE;
-
-    p_sys->i_crop_top   = 0;
-    p_sys->i_crop_bottom= 0;
-    p_sys->i_crop_right = 0;
-    p_sys->i_crop_left  = 0;
 
     if( ( codec = sout_cfg_find_value( p_stream->p_cfg, "acodec" ) ) )
     {
@@ -909,7 +894,7 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
             /* dumb downmixing */
             for( i = 0; i < aout_buf.i_nb_samples; i++ )
             {
-                uint16_t *p_buffer = aout_buf.p_buffer;
+                uint16_t *p_buffer = (uint16_t *)aout_buf.p_buffer;
                 for( j = 0 ; j < id->p_encoder->fmt_in.audio.i_channels; j++ )
                 {
                     p_buffer[i*id->p_encoder->fmt_in.audio.i_channels+j] =
@@ -1168,7 +1153,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
         /* decode frame */
         frame = id->p_ff_pic;
         p_sys->i_input_pts = in->i_pts;
-       if( id->ff_dec )
+        if( id->ff_dec )
         {
             i_used = avcodec_decode_video( id->ff_dec_c, frame,
                                            &b_gotpicture,
@@ -1177,8 +1162,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
         else
         {
             /* raw video */
-            avpicture_fill( (AVPicture*)frame,
-                            p_data,
+            avpicture_fill( (AVPicture*)frame, p_data,
                             id->ff_dec_c->pix_fmt,
                             id->ff_dec_c->width, id->ff_dec_c->height );
             i_used = i_data;