Commit 8547ffaa authored by Laurent Aimar's avatar Laurent Aimar

* stream_out: sout_buffer_t -> block_t.

parent 298f0e46
...@@ -31,21 +31,12 @@ ...@@ -31,21 +31,12 @@
#include <vlc/input.h> #include <vlc/input.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#include "codecs.h"
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin(); vlc_module_begin();
set_description( _("Display stream output") ); set_description( _("Display stream output") );
set_capability( "sout stream", 50 ); set_capability( "sout stream", 50 );
...@@ -53,6 +44,14 @@ vlc_module_begin(); ...@@ -53,6 +44,14 @@ vlc_module_begin();
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
struct sout_stream_sys_t struct sout_stream_sys_t
{ {
input_thread_t *p_input; input_thread_t *p_input;
...@@ -175,32 +174,31 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -175,32 +174,31 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
while( p_buffer ) while( p_buffer )
{ {
sout_buffer_t *p_next; block_t *p_next = p_buffer->p_next;
block_t *p_block;
p_buffer->p_next = NULL;
if( id->p_es->p_dec && p_buffer->i_size > 0 && if( id->p_es->p_dec && p_buffer->i_buffer > 0 )
(p_block = block_New( p_stream, p_buffer->i_size )) )
{ {
p_block->i_dts = p_buffer->i_dts <= 0 ? 0 : if( p_buffer->i_dts <= 0 )
p_buffer->i_dts + p_sys->i_delay; p_buffer->i_dts= 0;
p_block->i_pts = p_buffer->i_pts <= 0 ? 0 : else
p_buffer->i_pts + p_sys->i_delay; p_buffer->i_dts += p_sys->i_delay;
p_stream->p_vlc->pf_memcpy( p_block->p_buffer, if( p_buffer->i_pts <= 0 )
p_buffer->p_buffer, p_buffer->i_size ); p_buffer->i_pts= 0;
else
p_buffer->i_pts += p_sys->i_delay;
input_DecodeBlock( id->p_es->p_dec, p_block ); input_DecodeBlock( id->p_es->p_dec, p_buffer );
} }
/* *** go to next buffer *** */
p_next = p_buffer->p_next;
sout_BufferDelete( p_stream->p_sout, p_buffer );
p_buffer = p_next; p_buffer = p_next;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dummy.c: dummy stream output module * dummy.c: dummy stream output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2004 VideoLAN * Copyright (C) 2003-2004 VideoLAN
* $Id: dummy.c,v 1.4 2004/01/25 14:34:25 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -38,7 +38,7 @@ static void Close ( vlc_object_t * ); ...@@ -38,7 +38,7 @@ static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * ); static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* ); static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -99,18 +99,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -99,18 +99,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_buffer_t *p_next; block_ChainRelease( p_buffer );
while( p_buffer )
{
p_next = p_buffer->p_next;
sout_BufferDelete( p_stream->p_sout, p_buffer );
p_buffer = p_next;
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* duplicate.c: duplicate stream output module * duplicate.c: duplicate stream output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2004 VideoLAN * Copyright (C) 2003-2004 VideoLAN
* $Id: duplicate.c,v 1.12 2004/01/25 14:34:25 gbazin Exp $ * $Id$
* *
* Author: Laurent Aimar <fenrir@via.ecp.fr> * Author: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -31,19 +31,11 @@ ...@@ -31,19 +31,11 @@
#include <vlc/sout.h> #include <vlc/sout.h>
/***************************************************************************** /*****************************************************************************
* Exported prototypes * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *,
sout_buffer_t* );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin(); vlc_module_begin();
set_description( _("Duplicate stream output") ); set_description( _("Duplicate stream output") );
set_capability( "sout stream", 50 ); set_capability( "sout stream", 50 );
...@@ -52,6 +44,15 @@ vlc_module_begin(); ...@@ -52,6 +44,15 @@ vlc_module_begin();
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *,
block_t* );
struct sout_stream_sys_t struct sout_stream_sys_t
{ {
int i_nb_streams; int i_nb_streams;
...@@ -242,7 +243,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -242,7 +243,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
* Send: * Send:
*****************************************************************************/ *****************************************************************************/
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_stream_t *p_dup_stream; sout_stream_t *p_dup_stream;
...@@ -251,18 +252,18 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -251,18 +252,18 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
/* Loop through the linked list of buffers */ /* Loop through the linked list of buffers */
while( p_buffer ) while( p_buffer )
{ {
sout_buffer_t *p_next = p_buffer->p_next; block_t *p_next = p_buffer->p_next;
p_buffer->p_next = NULL; p_buffer->p_next = NULL;
for( i_stream = 0; i_stream < p_sys->i_nb_streams - 1; i_stream++ ) for( i_stream = 0; i_stream < p_sys->i_nb_streams - 1; i_stream++ )
{ {
sout_buffer_t *p_dup; block_t *p_dup;
p_dup_stream = p_sys->pp_streams[i_stream]; p_dup_stream = p_sys->pp_streams[i_stream];
if( id->pp_ids[i_stream] ) if( id->pp_ids[i_stream] )
{ {
p_dup = sout_BufferDuplicate( p_stream->p_sout, p_buffer ); p_dup = block_Duplicate( p_buffer );
p_dup_stream->pf_send( p_dup_stream, id->pp_ids[i_stream], p_dup_stream->pf_send( p_dup_stream, id->pp_ids[i_stream],
p_dup ); p_dup );
...@@ -277,7 +278,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -277,7 +278,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
} }
else else
{ {
sout_BufferDelete( p_stream->p_sout, p_buffer ); block_Release( p_buffer );
} }
p_buffer = p_next; p_buffer = p_next;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* es.c: Elementary stream output module * es.c: Elementary stream output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2004 VideoLAN * Copyright (C) 2003-2004 VideoLAN
* $Id: es.c,v 1.5 2004/01/25 14:34:25 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -40,7 +40,7 @@ static void Close ( vlc_object_t * ); ...@@ -40,7 +40,7 @@ static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * ); static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* ); static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -288,9 +288,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -288,9 +288,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
return( NULL ); return( NULL );
} }
/* XXX beurk */
p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader );
id = malloc( sizeof( sout_stream_id_t ) ); id = malloc( sizeof( sout_stream_id_t ) );
id->p_mux = p_mux; id->p_mux = p_mux;
id->p_input = sout_MuxAddStream( p_mux, p_fmt ); id->p_input = sout_MuxAddStream( p_mux, p_fmt );
...@@ -320,7 +317,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -320,7 +317,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_MuxSendBuffer( id->p_mux, id->p_input, p_buffer ); sout_MuxSendBuffer( id->p_mux, id->p_input, p_buffer );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gather.c: gathering stream output module * gather.c: gathering stream output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2004 VideoLAN * Copyright (C) 2003-2004 VideoLAN
* $Id: gather.c,v 1.3 2004/01/25 14:34:25 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -49,7 +49,7 @@ vlc_module_end(); ...@@ -49,7 +49,7 @@ vlc_module_end();
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * ); static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, static int Send( sout_stream_t *, sout_stream_id_t *,
sout_buffer_t* ); block_t* );
struct sout_stream_id_t struct sout_stream_id_t
{ {
...@@ -187,7 +187,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -187,7 +187,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
* Send: * Send:
*****************************************************************************/ *****************************************************************************/
static int Send( sout_stream_t *p_stream, static int Send( sout_stream_t *p_stream,
sout_stream_id_t *id, sout_buffer_t *p_buffer ) sout_stream_id_t *id, block_t *p_buffer )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
......
...@@ -52,7 +52,7 @@ vlc_module_end(); ...@@ -52,7 +52,7 @@ vlc_module_end();
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * ); static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, static int Send( sout_stream_t *, sout_stream_id_t *,
sout_buffer_t* ); block_t* );
struct sout_stream_sys_t struct sout_stream_sys_t
{ {
...@@ -87,7 +87,7 @@ struct sout_stream_sys_t ...@@ -87,7 +87,7 @@ struct sout_stream_sys_t
uint16_t i_sequence; uint16_t i_sequence;
uint32_t i_timestamp_start; uint32_t i_timestamp_start;
uint8_t ssrc[4]; uint8_t ssrc[4];
sout_buffer_t *packet; block_t *packet;
/* */ /* */
int i_es; int i_es;
...@@ -95,7 +95,7 @@ struct sout_stream_sys_t ...@@ -95,7 +95,7 @@ struct sout_stream_sys_t
}; };
typedef int (*pf_rtp_packetizer_t)( sout_stream_t *, sout_stream_id_t *, typedef int (*pf_rtp_packetizer_t)( sout_stream_t *, sout_stream_id_t *,
sout_buffer_t * ); block_t * );
struct sout_stream_id_t struct sout_stream_id_t
{ {
...@@ -125,7 +125,7 @@ struct sout_stream_id_t ...@@ -125,7 +125,7 @@ struct sout_stream_id_t
httpd_url_t *p_rtsp_url; httpd_url_t *p_rtsp_url;
}; };
static int AccessOutGrabberWrite( sout_access_out_t *, sout_buffer_t * ); static int AccessOutGrabberWrite( sout_access_out_t *, block_t * );
static int HttpSetup( sout_stream_t *p_stream, vlc_url_t * ); static int HttpSetup( sout_stream_t *p_stream, vlc_url_t * );
static int RtspSetup( sout_stream_t *p_stream, vlc_url_t * ); static int RtspSetup( sout_stream_t *p_stream, vlc_url_t * );
...@@ -274,8 +274,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -274,8 +274,6 @@ static int Open( vlc_object_t *p_this )
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_sout->i_preheader = __MAX( p_sout->i_preheader,
p_sys->p_mux->i_preheader );
/* create the SDP only once */ /* create the SDP only once */
p_sys->psz_sdp = p_sys->psz_sdp =
...@@ -362,7 +360,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -362,7 +360,7 @@ static void Close( vlc_object_t * p_this )
sout_AccessOutDelete( p_sys->p_grab ); sout_AccessOutDelete( p_sys->p_grab );
if( p_sys->packet ) if( p_sys->packet )
{ {
sout_BufferDelete( p_stream->p_sout, p_sys->packet ); block_Release( p_sys->packet );
} }
} }
...@@ -475,13 +473,13 @@ static char *SDPGenerate( sout_stream_t *p_stream, char *psz_destination, vlc_bo ...@@ -475,13 +473,13 @@ static char *SDPGenerate( sout_stream_t *p_stream, char *psz_destination, vlc_bo
/***************************************************************************** /*****************************************************************************
* *
*****************************************************************************/ *****************************************************************************/
static int rtp_packetize_l16 ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int rtp_packetize_l16 ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_l8 ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int rtp_packetize_l8 ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_mpa ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int rtp_packetize_mpa ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_mpv ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int rtp_packetize_mpv ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_ac3 ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int rtp_packetize_ac3 ( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_split( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int rtp_packetize_split( sout_stream_t *, sout_stream_id_t *, block_t * );
static int rtp_packetize_mp4a ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int rtp_packetize_mp4a ( sout_stream_t *, sout_stream_id_t *, block_t * );
static void sprintf_hexa( char *s, uint8_t *p_data, int i_data ) static void sprintf_hexa( char *s, uint8_t *p_data, int i_data )
{ {
...@@ -728,9 +726,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -728,9 +726,9 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_buffer_t *p_next; block_t *p_next;
if( p_stream->p_sys->p_mux ) if( p_stream->p_sys->p_mux )
{ {
...@@ -745,7 +743,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -745,7 +743,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
{ {
break; break;
} }
sout_BufferDelete( p_stream->p_sout, p_buffer ); block_Release( p_buffer );
p_buffer = p_next; p_buffer = p_next;
} }
} }
...@@ -754,7 +752,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -754,7 +752,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream, static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
...@@ -762,10 +760,10 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream, ...@@ -762,10 +760,10 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
uint32_t i_timestamp = i_dts * 9 / 100; uint32_t i_timestamp = i_dts * 9 / 100;
uint8_t *p_data = p_buffer->p_buffer; uint8_t *p_data = p_buffer->p_buffer;
unsigned int i_data = p_buffer->i_size; unsigned int i_data = p_buffer->i_buffer;
unsigned int i_max = p_sys->i_mtu - 12; unsigned int i_max = p_sys->i_mtu - 12;
int i_packet = ( p_buffer->i_size + i_max - 1 ) / i_max; int i_packet = ( p_buffer->i_buffer + i_max - 1 ) / i_max;
while( i_data > 0 ) while( i_data > 0 )
{ {
...@@ -773,7 +771,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream, ...@@ -773,7 +771,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
/* output complete packet */ /* output complete packet */
if( p_sys->packet && if( p_sys->packet &&
p_sys->packet->i_size + i_data > i_max ) p_sys->packet->i_buffer + i_data > i_max )
{ {
sout_AccessOutWrite( p_sys->p_access, p_sys->packet ); sout_AccessOutWrite( p_sys->p_access, p_sys->packet );
p_sys->packet = NULL; p_sys->packet = NULL;
...@@ -782,7 +780,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream, ...@@ -782,7 +780,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
if( p_sys->packet == NULL ) if( p_sys->packet == NULL )
{ {
/* allocate a new packet */ /* allocate a new packet */
p_sys->packet = sout_BufferNew( p_stream->p_sout, p_sys->i_mtu ); p_sys->packet = block_New( p_stream, p_sys->i_mtu );
p_sys->packet->p_buffer[ 0] = 0x80; p_sys->packet->p_buffer[ 0] = 0x80;
p_sys->packet->p_buffer[ 1] = p_sys->i_payload_type; p_sys->packet->p_buffer[ 1] = p_sys->i_payload_type;
p_sys->packet->p_buffer[ 2] = ( p_sys->i_sequence >> 8)&0xff; p_sys->packet->p_buffer[ 2] = ( p_sys->i_sequence >> 8)&0xff;
...@@ -795,7 +793,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream, ...@@ -795,7 +793,7 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
p_sys->packet->p_buffer[ 9] = p_sys->ssrc[1]; p_sys->packet->p_buffer[ 9] = p_sys->ssrc[1];
p_sys->packet->p_buffer[10] = p_sys->ssrc[2]; p_sys->packet->p_buffer[10] = p_sys->ssrc[2];
p_sys->packet->p_buffer[11] = p_sys->ssrc[3]; p_sys->packet->p_buffer[11] = p_sys->ssrc[3];
p_sys->packet->i_size = 12; p_sys->packet->i_buffer = 12;
p_sys->packet->i_dts = i_dts; p_sys->packet->i_dts = i_dts;
p_sys->packet->i_length = p_buffer->i_length / i_packet; p_sys->packet->i_length = p_buffer->i_length / i_packet;
...@@ -804,13 +802,12 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream, ...@@ -804,13 +802,12 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
p_sys->i_sequence++; p_sys->i_sequence++;
} }
i_size = __MIN( i_data, p_sys->i_mtu - p_sys->packet->i_size ); i_size = __MIN( i_data, p_sys->i_mtu - p_sys->packet->i_buffer );
memcpy( &p_sys->packet->p_buffer[p_sys->packet->i_size], memcpy( &p_sys->packet->p_buffer[p_sys->packet->i_buffer],
p_data, p_data, i_size );
i_size );
p_sys->packet->i_size += i_size; p_sys->packet->i_buffer += i_size;
p_data += i_size; p_data += i_size;
i_data -= i_size; i_data -= i_size;
} }
...@@ -819,20 +816,20 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream, ...@@ -819,20 +816,20 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
} }
static int AccessOutGrabberWrite( sout_access_out_t *p_access, static int AccessOutGrabberWrite( sout_access_out_t *p_access,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_stream_t *p_stream = (sout_stream_t*)p_access->p_sys; sout_stream_t *p_stream = (sout_stream_t*)p_access->p_sys;
//fprintf( stderr, "received buffer size=%d\n", p_buffer->i_size ); //fprintf( stderr, "received buffer size=%d\n", p_buffer->i_buffer );
// //
while( p_buffer ) while( p_buffer )
{ {
sout_buffer_t *p_next; block_t *p_next;
AccessOutGrabberWriteBuffer( p_stream, p_buffer ); AccessOutGrabberWriteBuffer( p_stream, p_buffer );
p_next = p_buffer->p_next; p_next = p_buffer->p_next;
sout_BufferDelete( p_access->p_sout, p_buffer ); block_Release( p_buffer );
p_buffer = p_next; p_buffer = p_next;
} }
...@@ -1032,7 +1029,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args, ...@@ -1032,7 +1029,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
/**************************************************************************** /****************************************************************************
* rtp_packetize_*: * rtp_packetize_*:
****************************************************************************/ ****************************************************************************/
static void rtp_packetize_common( sout_stream_id_t *id, sout_buffer_t *out, static void rtp_packetize_common( sout_stream_id_t *id, block_t *out,
int b_marker, int64_t i_pts ) int b_marker, int64_t i_pts )
{ {
uint32_t i_timestamp = i_pts * (int64_t)id->i_clock_rate / I64C(1000000); uint32_t i_timestamp = i_pts * (int64_t)id->i_clock_rate / I64C(1000000);
...@@ -1051,24 +1048,24 @@ static void rtp_packetize_common( sout_stream_id_t *id, sout_buffer_t *out, ...@@ -1051,24 +1048,24 @@ static void rtp_packetize_common( sout_stream_id_t *id, sout_buffer_t *out,
out->p_buffer[10] = id->ssrc[2]; out->p_buffer[10] = id->ssrc[2];
out->p_buffer[11] = id->ssrc[3]; out->p_buffer[11] = id->ssrc[3];
out->i_size = 12; out->i_buffer = 12;
id->i_sequence++; id->i_sequence++;
} }
static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id, static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in ) block_t *in )
{ {
int i_max = id->i_mtu - 12 - 4; /* payload max in one packet */ int i_max = id->i_mtu - 12 - 4; /* payload max in one packet */
int i_count = ( in->i_size + i_max - 1 ) / i_max; int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer; uint8_t *p_data = in->p_buffer;
int i_data = in->i_size; int i_data = in->i_buffer;
int i; int i;
for( i = 0; i < i_count; i++ ) for( i = 0; i < i_count; i++ )
{ {
int i_payload = __MIN( i_max, i_data ); int i_payload = __MIN( i_max, i_data );
sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 16 + i_payload ); block_t *out = block_New( p_stream, 16 + i_payload );
/* rtp common header */ /* rtp common header */
rtp_packetize_common( id, out, (i == i_count - 1)?1:0, in->i_pts ); rtp_packetize_common( id, out, (i == i_count - 1)?1:0, in->i_pts );
...@@ -1080,7 +1077,7 @@ static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1080,7 +1077,7 @@ static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id,
out->p_buffer[15] = ( (i*i_max) )&0xff; out->p_buffer[15] = ( (i*i_max) )&0xff;
memcpy( &out->p_buffer[16], p_data, i_payload ); memcpy( &out->p_buffer[16], p_data, i_payload );
out->i_size = 16 + i_payload; out->i_buffer = 16 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count; out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count; out->i_length = in->i_length / i_count;
...@@ -1095,13 +1092,13 @@ static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1095,13 +1092,13 @@ static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id,
/* rfc2250 */ /* rfc2250 */
static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id, static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in ) block_t *in )
{ {
int i_max = id->i_mtu - 12 - 4; /* payload max in one packet */ int i_max = id->i_mtu - 12 - 4; /* payload max in one packet */
int i_count = ( in->i_size + i_max - 1 ) / i_max; int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer; uint8_t *p_data = in->p_buffer;
int i_data = in->i_size; int i_data = in->i_buffer;
int i; int i;
int b_sequence_start = 0; int b_sequence_start = 0;
int i_temporal_ref = 0; int i_temporal_ref = 0;
...@@ -1110,10 +1107,10 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1110,10 +1107,10 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
int b_start_slice = 0; int b_start_slice = 0;
/* preparse this packet to get some info */ /* preparse this packet to get some info */
if( in->i_size > 4 ) if( in->i_buffer > 4 )
{ {
uint8_t *p = p_data; uint8_t *p = p_data;
int i_rest = in->i_size; int i_rest = in->i_buffer;
for( ;; ) for( ;; )
{ {
...@@ -1163,7 +1160,7 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1163,7 +1160,7 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
for( i = 0; i < i_count; i++ ) for( i = 0; i < i_count; i++ )
{ {
int i_payload = __MIN( i_max, i_data ); int i_payload = __MIN( i_max, i_data );
sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, block_t *out = block_New( p_stream,
16 + i_payload ); 16 + i_payload );
uint32_t h = ( i_temporal_ref << 16 )| uint32_t h = ( i_temporal_ref << 16 )|
( b_sequence_start << 13 )| ( b_sequence_start << 13 )|
...@@ -1184,7 +1181,7 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1184,7 +1181,7 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
memcpy( &out->p_buffer[16], p_data, i_payload ); memcpy( &out->p_buffer[16], p_data, i_payload );
out->i_size = 16 + i_payload; out->i_buffer = 16 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count; out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count; out->i_length = in->i_length / i_count;
...@@ -1197,19 +1194,19 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1197,19 +1194,19 @@ static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id, static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in ) block_t *in )
{ {
int i_max = id->i_mtu - 12 - 2; /* payload max in one packet */ int i_max = id->i_mtu - 12 - 2; /* payload max in one packet */
int i_count = ( in->i_size + i_max - 1 ) / i_max; int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer; uint8_t *p_data = in->p_buffer;
int i_data = in->i_size; int i_data = in->i_buffer;
int i; int i;
for( i = 0; i < i_count; i++ ) for( i = 0; i < i_count; i++ )
{ {
int i_payload = __MIN( i_max, i_data ); int i_payload = __MIN( i_max, i_data );
sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 14 + i_payload ); block_t *out = block_New( p_stream, 14 + i_payload );
/* rtp common header */ /* rtp common header */
rtp_packetize_common( id, out, (i == i_count - 1)?1:0, in->i_pts ); rtp_packetize_common( id, out, (i == i_count - 1)?1:0, in->i_pts );
...@@ -1220,7 +1217,7 @@ static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1220,7 +1217,7 @@ static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id,
/* data */ /* data */
memcpy( &out->p_buffer[14], p_data, i_payload ); memcpy( &out->p_buffer[14], p_data, i_payload );
out->i_size = 14 + i_payload; out->i_buffer = 14 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count; out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count; out->i_length = in->i_length / i_count;
...@@ -1234,26 +1231,26 @@ static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1234,26 +1231,26 @@ static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id,
} }
static int rtp_packetize_split( sout_stream_t *p_stream, sout_stream_id_t *id, static int rtp_packetize_split( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in ) block_t *in )
{ {
int i_max = id->i_mtu - 12; /* payload max in one packet */ int i_max = id->i_mtu - 12; /* payload max in one packet */
int i_count = ( in->i_size + i_max - 1 ) / i_max; int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer; uint8_t *p_data = in->p_buffer;
int i_data = in->i_size; int i_data = in->i_buffer;
int i; int i;
for( i = 0; i < i_count; i++ ) for( i = 0; i < i_count; i++ )
{ {
int i_payload = __MIN( i_max, i_data ); int i_payload = __MIN( i_max, i_data );
sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 12 + i_payload ); block_t *out = block_New( p_stream, 12 + i_payload );
/* rtp common header */ /* rtp common header */
rtp_packetize_common( id, out, ((i == i_count - 1)?1:0), rtp_packetize_common( id, out, ((i == i_count - 1)?1:0),
(in->i_pts > 0 ? in->i_pts : in->i_dts) ); (in->i_pts > 0 ? in->i_pts : in->i_dts) );
memcpy( &out->p_buffer[12], p_data, i_payload ); memcpy( &out->p_buffer[12], p_data, i_payload );
out->i_size = 12 + i_payload; out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count; out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count; out->i_length = in->i_length / i_count;
...@@ -1267,26 +1264,26 @@ static int rtp_packetize_split( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1267,26 +1264,26 @@ static int rtp_packetize_split( sout_stream_t *p_stream, sout_stream_id_t *id,
} }
static int rtp_packetize_l16( sout_stream_t *p_stream, sout_stream_id_t *id, static int rtp_packetize_l16( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in ) block_t *in )
{ {
int i_max = id->i_mtu - 12; /* payload max in one packet */ int i_max = id->i_mtu - 12; /* payload max in one packet */
int i_count = ( in->i_size + i_max - 1 ) / i_max; int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer; uint8_t *p_data = in->p_buffer;
int i_data = in->i_size; int i_data = in->i_buffer;
int i_packet = 0; int i_packet = 0;
while( i_data > 0 ) while( i_data > 0 )
{ {
int i_payload = (__MIN( i_max, i_data )/4)*4; int i_payload = (__MIN( i_max, i_data )/4)*4;
sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 12 + i_payload ); block_t *out = block_New( p_stream, 12 + i_payload );
/* rtp common header */ /* rtp common header */
rtp_packetize_common( id, out, 0, rtp_packetize_common( id, out, 0,
(in->i_pts > 0 ? in->i_pts : in->i_dts) ); (in->i_pts > 0 ? in->i_pts : in->i_dts) );
memcpy( &out->p_buffer[12], p_data, i_payload ); memcpy( &out->p_buffer[12], p_data, i_payload );
out->i_size = 12 + i_payload; out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i_packet * in->i_length / i_count; out->i_dts = in->i_dts + i_packet * in->i_length / i_count;
out->i_length = in->i_length / i_count; out->i_length = in->i_length / i_count;
...@@ -1301,26 +1298,26 @@ static int rtp_packetize_l16( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1301,26 +1298,26 @@ static int rtp_packetize_l16( sout_stream_t *p_stream, sout_stream_id_t *id,
} }
static int rtp_packetize_l8( sout_stream_t *p_stream, sout_stream_id_t *id, static int rtp_packetize_l8( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in ) block_t *in )
{ {
int i_max = id->i_mtu - 12; /* payload max in one packet */ int i_max = id->i_mtu - 12; /* payload max in one packet */
int i_count = ( in->i_size + i_max - 1 ) / i_max; int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer; uint8_t *p_data = in->p_buffer;
int i_data = in->i_size; int i_data = in->i_buffer;
int i_packet = 0; int i_packet = 0;
while( i_data > 0 ) while( i_data > 0 )
{ {
int i_payload = (__MIN( i_max, i_data )/2)*2; int i_payload = (__MIN( i_max, i_data )/2)*2;
sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 12 + i_payload ); block_t *out = block_New( p_stream, 12 + i_payload );
/* rtp common header */ /* rtp common header */
rtp_packetize_common( id, out, 0, rtp_packetize_common( id, out, 0,
(in->i_pts > 0 ? in->i_pts : in->i_dts) ); (in->i_pts > 0 ? in->i_pts : in->i_dts) );
memcpy( &out->p_buffer[12], p_data, i_payload ); memcpy( &out->p_buffer[12], p_data, i_payload );
out->i_size = 12 + i_payload; out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i_packet * in->i_length / i_count; out->i_dts = in->i_dts + i_packet * in->i_length / i_count;
out->i_length = in->i_length / i_count; out->i_length = in->i_length / i_count;
...@@ -1334,19 +1331,19 @@ static int rtp_packetize_l8( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1334,19 +1331,19 @@ static int rtp_packetize_l8( sout_stream_t *p_stream, sout_stream_id_t *id,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int rtp_packetize_mp4a( sout_stream_t *p_stream, sout_stream_id_t *id, static int rtp_packetize_mp4a( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in ) block_t *in )
{ {
int i_max = id->i_mtu - 16; /* payload max in one packet */ int i_max = id->i_mtu - 16; /* payload max in one packet */
int i_count = ( in->i_size + i_max - 1 ) / i_max; int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer; uint8_t *p_data = in->p_buffer;
int i_data = in->i_size; int i_data = in->i_buffer;
int i; int i;
for( i = 0; i < i_count; i++ ) for( i = 0; i < i_count; i++ )
{ {
int i_payload = __MIN( i_max, i_data ); int i_payload = __MIN( i_max, i_data );
sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 16 + i_payload ); block_t *out = block_New( p_stream, 16 + i_payload );
/* rtp common header */ /* rtp common header */
rtp_packetize_common( id, out, ((i == i_count - 1)?1:0), rtp_packetize_common( id, out, ((i == i_count - 1)?1:0),
...@@ -1356,12 +1353,12 @@ static int rtp_packetize_mp4a( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -1356,12 +1353,12 @@ static int rtp_packetize_mp4a( sout_stream_t *p_stream, sout_stream_id_t *id,
out->p_buffer[12] = 0; out->p_buffer[12] = 0;
out->p_buffer[13] = 2*8; out->p_buffer[13] = 2*8;
/* for each AU length 13 bits + idx 3bits, */ /* for each AU length 13 bits + idx 3bits, */
out->p_buffer[14] = ( in->i_size >> 5 )&0xff; out->p_buffer[14] = ( in->i_buffer >> 5 )&0xff;
out->p_buffer[15] = ( (in->i_size&0xff)<<3 )|0; out->p_buffer[15] = ( (in->i_buffer&0xff)<<3 )|0;
memcpy( &out->p_buffer[16], p_data, i_payload ); memcpy( &out->p_buffer[16], p_data, i_payload );
out->i_size = 16 + i_payload; out->i_buffer = 16 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count; out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count; out->i_length = in->i_length / i_count;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* standard.c: standard stream output module * standard.c: standard stream output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2004 VideoLAN * Copyright (C) 2003-2004 VideoLAN
* $Id: standard.c,v 1.18 2004/01/25 14:34:25 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -42,7 +42,7 @@ static void Close ( vlc_object_t * ); ...@@ -42,7 +42,7 @@ static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * ); static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* ); static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -290,9 +290,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -290,9 +290,6 @@ static int Open( vlc_object_t *p_this )
} }
#endif #endif
/* XXX beurk */
p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader );
p_stream->pf_add = Add; p_stream->pf_add = Add;
p_stream->pf_del = Del; p_stream->pf_del = Del;
p_stream->pf_send = Send; p_stream->pf_send = Send;
...@@ -368,7 +365,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -368,7 +365,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_instance_t *p_sout = p_stream->p_sout; sout_instance_t *p_sout = p_stream->p_sout;
......
...@@ -46,22 +46,33 @@ ...@@ -46,22 +46,33 @@
#endif #endif
/***************************************************************************** /*****************************************************************************
* Exported prototypes * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close( vlc_object_t * );
vlc_module_begin();
set_description( _("Transcode stream output") );
set_capability( "sout stream", 50 );
add_shortcut( "transcode" );
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * ); static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* ); static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
static int transcode_audio_ffmpeg_new ( sout_stream_t *, sout_stream_id_t * ); static int transcode_audio_ffmpeg_new ( sout_stream_t *, sout_stream_id_t * );
static void transcode_audio_ffmpeg_close ( sout_stream_t *, sout_stream_id_t * ); static void transcode_audio_ffmpeg_close ( sout_stream_t *, sout_stream_id_t * );
static int transcode_audio_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, sout_buffer_t *, sout_buffer_t ** ); static int transcode_audio_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, block_t *, block_t ** );
static int transcode_video_ffmpeg_new ( sout_stream_t *, sout_stream_id_t * ); static int transcode_video_ffmpeg_new ( sout_stream_t *, sout_stream_id_t * );
static void transcode_video_ffmpeg_close ( sout_stream_t *, sout_stream_id_t * ); static void transcode_video_ffmpeg_close ( sout_stream_t *, sout_stream_id_t * );
static int transcode_video_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, sout_buffer_t *, sout_buffer_t ** ); static int transcode_video_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, block_t *, block_t ** );
static int transcode_video_ffmpeg_getframebuf( struct AVCodecContext *, AVFrame *); static int transcode_video_ffmpeg_getframebuf( struct AVCodecContext *, AVFrame *);
...@@ -78,16 +89,6 @@ static int pi_channels_maps[6] = ...@@ -78,16 +89,6 @@ static int pi_channels_maps[6] =
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
}; };
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("Transcode stream output") );
set_capability( "sout stream", 50 );
add_shortcut( "transcode" );
set_callbacks( Open, Close );
vlc_module_end();
#define PICTURE_RING_SIZE 64 #define PICTURE_RING_SIZE 64
struct sout_stream_sys_t struct sout_stream_sys_t
...@@ -96,7 +97,7 @@ struct sout_stream_sys_t ...@@ -96,7 +97,7 @@ struct sout_stream_sys_t
sout_stream_t * p_out; sout_stream_t * p_out;
sout_stream_id_t * id_video; sout_stream_id_t * id_video;
sout_buffer_t * p_buffers; block_t * p_buffers;
vlc_mutex_t lock_out; vlc_mutex_t lock_out;
vlc_cond_t cond; vlc_cond_t cond;
picture_t * pp_pics[PICTURE_RING_SIZE]; picture_t * pp_pics[PICTURE_RING_SIZE];
...@@ -367,9 +368,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -367,9 +368,6 @@ static int Open( vlc_object_t *p_this )
avcodec_init(); avcodec_init();
avcodec_register_all(); avcodec_register_all();
/* ffmpeg needs some padding at the end of each buffer */
p_stream->p_sout->i_padding += FF_INPUT_BUFFER_PADDING_SIZE;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -541,13 +539,23 @@ static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -541,13 +539,23 @@ static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
if( id->b_transcode ) if( id->b_transcode )
{ {
sout_buffer_t *p_buffer_out; block_t *p_buffer_out;
/* Be sure to have padding */
p_buffer = block_Realloc( p_buffer, 0, p_buffer->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE );
if( p_buffer == NULL )
{
return VLC_EGENERIC;
}
p_buffer->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
memset( &p_buffer->p_buffer[p_buffer->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE );
if( id->f_src.i_cat == AUDIO_ES ) if( id->f_src.i_cat == AUDIO_ES )
{ {
transcode_audio_ffmpeg_process( p_stream, id, p_buffer, transcode_audio_ffmpeg_process( p_stream, id, p_buffer,
...@@ -558,11 +566,11 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -558,11 +566,11 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
if( transcode_video_ffmpeg_process( p_stream, id, p_buffer, if( transcode_video_ffmpeg_process( p_stream, id, p_buffer,
&p_buffer_out ) != VLC_SUCCESS ) &p_buffer_out ) != VLC_SUCCESS )
{ {
sout_BufferDelete( p_stream->p_sout, p_buffer ); block_Release( p_buffer );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
sout_BufferDelete( p_stream->p_sout, p_buffer ); block_Release( p_buffer );
if( p_buffer_out ) if( p_buffer_out )
{ {
...@@ -576,7 +584,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -576,7 +584,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
} }
else else
{ {
sout_BufferDelete( p_stream->p_sout, p_buffer ); block_Release( p_buffer );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
...@@ -832,12 +840,12 @@ static void transcode_audio_ffmpeg_close( sout_stream_t *p_stream, ...@@ -832,12 +840,12 @@ static void transcode_audio_ffmpeg_close( sout_stream_t *p_stream,
static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
sout_stream_id_t *id, sout_stream_id_t *id,
sout_buffer_t *in, block_t *in,
sout_buffer_t **out ) block_t **out )
{ {
aout_buffer_t aout_buf; aout_buffer_t aout_buf;
block_t *p_block; block_t *p_block;
int i_buffer = in->i_size; int i_buffer = in->i_buffer;
char *p_buffer = in->p_buffer; char *p_buffer = in->p_buffer;
id->i_dts = in->i_dts; id->i_dts = in->i_dts;
*out = NULL; *out = NULL;
...@@ -947,14 +955,14 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, ...@@ -947,14 +955,14 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
p_block = id->p_encoder->pf_header( id->p_encoder ); p_block = id->p_encoder->pf_header( id->p_encoder );
while( p_block ) while( p_block )
{ {
sout_buffer_t *p_out; block_t *p_out;
block_t *p_prev_block = p_block; block_t *p_prev_block = p_block;
p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer ); p_out = block_New( p_stream, p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer); memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
p_out->i_dts = p_out->i_pts = in->i_dts; p_out->i_dts = p_out->i_pts = in->i_dts;
p_out->i_length = 0; p_out->i_length = 0;
sout_BufferChain( out, p_out ); block_ChainAppend( out, p_out );
p_block = p_block->p_next; p_block = p_block->p_next;
block_Release( p_prev_block ); block_Release( p_prev_block );
...@@ -1064,15 +1072,15 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1064,15 +1072,15 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
p_block = id->p_encoder->pf_encode_audio( id->p_encoder, &aout_buf ); p_block = id->p_encoder->pf_encode_audio( id->p_encoder, &aout_buf );
while( p_block ) while( p_block )
{ {
sout_buffer_t *p_out; block_t *p_out;
block_t *p_prev_block = p_block; block_t *p_prev_block = p_block;
p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer ); p_out = block_New( p_stream, p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer); memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
p_out->i_dts = p_block->i_dts; p_out->i_dts = p_block->i_dts;
p_out->i_pts = p_block->i_pts; p_out->i_pts = p_block->i_pts;
p_out->i_length = p_block->i_length; p_out->i_length = p_block->i_length;
sout_BufferChain( out, p_out ); block_ChainAppend( out, p_out );
p_block = p_block->p_next; p_block = p_block->p_next;
block_Release( p_prev_block ); block_Release( p_prev_block );
...@@ -1200,25 +1208,6 @@ static int transcode_video_ffmpeg_new( sout_stream_t *p_stream, ...@@ -1200,25 +1208,6 @@ static int transcode_video_ffmpeg_new( sout_stream_t *p_stream,
msg_Err( p_stream, "cannot open decoder" ); msg_Err( p_stream, "cannot open decoder" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
#if 0
if( i_ff_codec == CODEC_ID_MPEG4 && id->ff_dec_c->extradata_size > 0 )
{
int b_gotpicture;
AVFrame frame;
uint8_t *p_vol = malloc( id->ff_dec_c->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE );
memcpy( p_vol, id->ff_dec_c->extradata,
id->ff_dec_c->extradata_size );
memset( p_vol + id->ff_dec_c->extradata_size, 0,
FF_INPUT_BUFFER_PADDING_SIZE );
avcodec_decode_video( id->ff_dec_c, &frame, &b_gotpicture,
id->ff_dec_c->extradata,
id->ff_dec_c->extradata_size );
free( p_vol );
}
#endif
} }
/* Open encoder */ /* Open encoder */
...@@ -1382,7 +1371,7 @@ static void transcode_video_ffmpeg_close ( sout_stream_t *p_stream, ...@@ -1382,7 +1371,7 @@ static void transcode_video_ffmpeg_close ( sout_stream_t *p_stream,
} }
static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out ) sout_stream_id_t *id, block_t *in, block_t **out )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
int i_used; int i_used;
...@@ -1394,7 +1383,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1394,7 +1383,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
*out = NULL; *out = NULL;
i_data = in->i_size; i_data = in->i_buffer;
p_data = in->p_buffer; p_data = in->p_buffer;
for( ;; ) for( ;; )
...@@ -1530,16 +1519,16 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1530,16 +1519,16 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
p_block = id->p_encoder->pf_header( id->p_encoder ); p_block = id->p_encoder->pf_header( id->p_encoder );
while( p_block ) while( p_block )
{ {
sout_buffer_t *p_out; block_t *p_out;
block_t *p_prev_block = p_block; block_t *p_prev_block = p_block;
p_out = sout_BufferNew( p_stream->p_sout, p_out = block_New( p_stream,
p_block->i_buffer ); p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, memcpy( p_out->p_buffer, p_block->p_buffer,
p_block->i_buffer); p_block->i_buffer);
p_out->i_dts = p_out->i_pts = in->i_dts; p_out->i_dts = p_out->i_pts = in->i_dts;
p_out->i_length = 0; p_out->i_length = 0;
sout_BufferChain( out, p_out ); block_ChainAppend( out, p_out );
p_block = p_block->p_next; p_block = p_block->p_next;
block_Release( p_prev_block ); block_Release( p_prev_block );
...@@ -1710,23 +1699,9 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1710,23 +1699,9 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
{ {
block_t *p_block; block_t *p_block;
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic ); p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
while( p_block ) if( p_block )
{ {
sout_buffer_t *p_out; block_ChainAppend( out, p_block );
block_t *p_prev_block = p_block;
p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
p_out->i_dts = p_block->i_dts;
p_out->i_pts = p_block->i_pts;
p_out->i_length = p_block->i_length;
p_out->i_flags =
(p_block->i_flags << SOUT_BUFFER_FLAGS_BLOCK_SHIFT)
& SOUT_BUFFER_FLAGS_BLOCK_MASK;
sout_BufferChain( out, p_out );
p_block = p_block->p_next;
block_Release( p_prev_block );
} }
free( p_pic ); free( p_pic );
} }
...@@ -1742,11 +1717,9 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1742,11 +1717,9 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
static int EncoderThread( sout_stream_sys_t * p_sys ) static int EncoderThread( sout_stream_sys_t * p_sys )
{ {
sout_stream_t * p_stream = p_sys->p_out;
sout_stream_id_t * id = p_sys->id_video; sout_stream_id_t * id = p_sys->id_video;
picture_t * p_pic; picture_t * p_pic;
int i_plane; int i_plane;
sout_buffer_t * p_buffer;
while ( !p_sys->b_die && !p_sys->b_error ) while ( !p_sys->b_die && !p_sys->b_error )
{ {
...@@ -1771,23 +1744,9 @@ static int EncoderThread( sout_stream_sys_t * p_sys ) ...@@ -1771,23 +1744,9 @@ static int EncoderThread( sout_stream_sys_t * p_sys )
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic ); p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
vlc_mutex_lock( &p_sys->lock_out ); vlc_mutex_lock( &p_sys->lock_out );
while( p_block ) if( p_block )
{ {
sout_buffer_t *p_out; block_ChainAppend( &p_sys->p_buffers, p_block );
block_t *p_prev_block = p_block;
p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
p_out->i_dts = p_block->i_dts;
p_out->i_pts = p_block->i_pts;
p_out->i_length = p_block->i_length;
p_out->i_flags =
(p_block->i_flags << SOUT_BUFFER_FLAGS_BLOCK_SHIFT)
& SOUT_BUFFER_FLAGS_BLOCK_MASK;
sout_BufferChain( &p_sys->p_buffers, p_out );
p_block = p_block->p_next;
block_Release( p_prev_block );
} }
vlc_mutex_unlock( &p_sys->lock_out ); vlc_mutex_unlock( &p_sys->lock_out );
...@@ -1810,13 +1769,7 @@ static int EncoderThread( sout_stream_sys_t * p_sys ) ...@@ -1810,13 +1769,7 @@ static int EncoderThread( sout_stream_sys_t * p_sys )
free( p_pic ); free( p_pic );
} }
p_buffer = p_sys->p_buffers; block_ChainRelease( p_sys->p_buffers );
while ( p_buffer != NULL )
{
sout_buffer_t * p_next = p_buffer->p_next;
sout_BufferDelete( p_stream->p_sout, p_buffer );
p_buffer = p_next;
}
return 0; return 0;
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Copyright (C) 2003 Antoine Missout * Copyright (C) 2003 Antoine Missout
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* $Id: frame.c,v 1.2 2004/03/03 11:39:06 massiot Exp $ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -1636,56 +1636,56 @@ static int do_next_start_code( transrate_t *tr ) ...@@ -1636,56 +1636,56 @@ static int do_next_start_code( transrate_t *tr )
} }
void E_(process_frame)( sout_stream_t *p_stream, void E_(process_frame)( sout_stream_t *p_stream,
sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out ) sout_stream_id_t *id, block_t *in, block_t **out )
{ {
transrate_t *tr = &id->tr; transrate_t *tr = &id->tr;
bs_transrate_t *bs = &tr->bs; bs_transrate_t *bs = &tr->bs;
sout_buffer_t *p_out; block_t *p_out;
double next_fact_x = 1.0; double next_fact_x = 1.0;
/* The output buffer can't be bigger than the input buffer. */ /* The output buffer can't be bigger than the input buffer. */
p_out = sout_BufferNew( p_stream->p_sout, in->i_size ); p_out = block_New( p_stream, in->i_buffer );
p_out->i_length = in->i_length; p_out->i_length = in->i_length;
p_out->i_dts = in->i_dts; p_out->i_dts = in->i_dts;
p_out->i_pts = in->i_pts; p_out->i_pts = in->i_pts;
p_out->i_flags = in->i_flags; p_out->i_flags = in->i_flags;
sout_BufferChain( out, p_out ); block_ChainAppend( out, p_out );
bs->p_rw = bs->p_ow = bs->p_w = p_out->p_buffer; bs->p_rw = bs->p_ow = bs->p_w = p_out->p_buffer;
bs->p_c = bs->p_r = in->p_buffer; bs->p_c = bs->p_r = in->p_buffer;
bs->p_r += in->i_size + 4; bs->p_r += in->i_buffer + 4;
bs->p_rw += in->i_size; bs->p_rw += in->i_buffer;
*(in->p_buffer + in->i_size) = 0; *(in->p_buffer + in->i_buffer) = 0;
*(in->p_buffer + in->i_size + 1) = 0; *(in->p_buffer + in->i_buffer + 1) = 0;
*(in->p_buffer + in->i_size + 2) = 1; *(in->p_buffer + in->i_buffer + 2) = 1;
*(in->p_buffer + in->i_size + 3) = 0; *(in->p_buffer + in->i_buffer + 3) = 0;
/* Calculate how late we are */ /* Calculate how late we are */
tr->quant_corr = 0.0 + B_HANDICAP; tr->quant_corr = 0.0 + B_HANDICAP;
tr->level_i = 0; tr->level_i = 0;
tr->level_p = 0; tr->level_p = 0;
bs->i_byte_in = in->i_size; bs->i_byte_in = in->i_buffer;
bs->i_byte_out = 0; bs->i_byte_out = 0;
if (tr->i_current_gop_size - in->i_size > 100) if (tr->i_current_gop_size - in->i_buffer > 100)
{ {
if (tr->i_wanted_gop_size == in->i_size) if (tr->i_wanted_gop_size == in->i_buffer)
{ {
next_fact_x = 1.0; next_fact_x = 1.0;
} }
else if ( tr->i_wanted_gop_size < in->i_size ) else if ( tr->i_wanted_gop_size < in->i_buffer )
{ {
/* We're really late */ /* We're really late */
next_fact_x = 10.0; next_fact_x = 10.0;
} }
else else
{ {
next_fact_x = ((double)(tr->i_current_gop_size - in->i_size)) / next_fact_x = ((double)(tr->i_current_gop_size - in->i_buffer)) /
(tr->i_wanted_gop_size - in->i_size); (tr->i_wanted_gop_size - in->i_buffer);
} }
if (next_fact_x > QUANT_I) if (next_fact_x > QUANT_I)
...@@ -1710,7 +1710,7 @@ void E_(process_frame)( sout_stream_t *p_stream, ...@@ -1710,7 +1710,7 @@ void E_(process_frame)( sout_stream_t *p_stream,
for ( ; ; ) for ( ; ; )
{ {
uint8_t *p_end = &in->p_buffer[in->i_size]; uint8_t *p_end = &in->p_buffer[in->i_buffer];
/* Search next start code */ /* Search next start code */
for( ;; ) for( ;; )
...@@ -1759,15 +1759,15 @@ void E_(process_frame)( sout_stream_t *p_stream, ...@@ -1759,15 +1759,15 @@ void E_(process_frame)( sout_stream_t *p_stream,
} }
bs->i_byte_out += bs->p_w - bs->p_ow; bs->i_byte_out += bs->p_w - bs->p_ow;
p_out->i_size = bs->p_w - bs->p_ow; p_out->i_buffer = bs->p_w - bs->p_ow;
tr->i_current_gop_size -= in->i_size; tr->i_current_gop_size -= in->i_buffer;
tr->i_wanted_gop_size -= p_out->i_size; tr->i_wanted_gop_size -= p_out->i_buffer;
tr->i_new_gop_size += bs->i_byte_out; tr->i_new_gop_size += bs->i_byte_out;
#if 0 #if 0
msg_Dbg( p_stream, "%d: %d -> %d (r: %f, n:%f, corr:%f)", msg_Dbg( p_stream, "%d: %d -> %d (r: %f, n:%f, corr:%f)",
tr->picture_coding_type, in->i_size, p_out->i_size, tr->picture_coding_type, in->i_buffer, p_out->i_size,
(float)in->i_size / p_out->i_size, (float)in->i_buffer / p_out->i_size,
next_fact_x, tr->quant_corr); next_fact_x, tr->quant_corr);
#endif #endif
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* transrate.c: MPEG2 video transrating module * transrate.c: MPEG2 video transrating module
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: transrate.c,v 1.7 2004/03/03 11:20:52 massiot Exp $ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -45,12 +45,12 @@ static void Close ( vlc_object_t * ); ...@@ -45,12 +45,12 @@ static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * ); static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * ); static int Send( sout_stream_t *, sout_stream_id_t *, block_t * );
static int transrate_video_process( sout_stream_t *, sout_stream_id_t *, sout_buffer_t *, sout_buffer_t ** ); static int transrate_video_process( sout_stream_t *, sout_stream_id_t *, block_t *, block_t ** );
void E_(process_frame)( sout_stream_t *p_stream, void E_(process_frame)( sout_stream_t *p_stream,
sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out ); sout_stream_id_t *id, block_t *in, block_t **out );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -130,8 +130,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -130,8 +130,6 @@ static int Open( vlc_object_t *p_this )
p_stream->p_sys = p_sys; p_stream->p_sys = p_sys;
p_stream->p_sout->i_padding += 200;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -205,13 +203,18 @@ static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -205,13 +203,18 @@ static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer ) block_t *p_buffer )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
if( id->b_transrate ) if( id->b_transrate )
{ {
sout_buffer_t *p_buffer_out; block_t *p_buffer_out;
/* be sure to have at least 8 bytes of padding (maybe only 4) */
p_buffer = block_Realloc( p_buffer, 0, p_buffer->i_buffer + 8 );
p_buffer->i_buffer -= 8;
memset( &p_buffer->p_buffer[p_buffer->i_buffer], 0, 8 );
transrate_video_process( p_stream, id, p_buffer, &p_buffer_out ); transrate_video_process( p_stream, id, p_buffer, &p_buffer_out );
if( p_buffer_out ) if( p_buffer_out )
...@@ -226,13 +229,13 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -226,13 +229,13 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
} }
else else
{ {
sout_BufferDelete( p_stream->p_sout, p_buffer ); block_Release( p_buffer );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
static int transrate_video_process( sout_stream_t *p_stream, static int transrate_video_process( sout_stream_t *p_stream,
sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out ) sout_stream_id_t *id, block_t *in, block_t **out )
{ {
transrate_t *tr = &id->tr; transrate_t *tr = &id->tr;
bs_transrate_t *bs = &tr->bs; bs_transrate_t *bs = &tr->bs;
...@@ -241,16 +244,16 @@ static int transrate_video_process( sout_stream_t *p_stream, ...@@ -241,16 +244,16 @@ static int transrate_video_process( sout_stream_t *p_stream,
while ( in != NULL ) while ( in != NULL )
{ {
sout_buffer_t * p_next = in->p_next; block_t * p_next = in->p_next;
int i_flags = in->i_flags; int i_flags = in->i_flags;
in->p_next = NULL; in->p_next = NULL;
sout_BufferChain( &id->p_next_gop, in ); block_ChainAppend( &id->p_next_gop, in );
id->i_next_gop_duration += in->i_length; id->i_next_gop_duration += in->i_length;
id->i_next_gop_size += in->i_size; id->i_next_gop_size += in->i_buffer;
in = p_next; in = p_next;
if( ((i_flags & (BLOCK_FLAG_TYPE_I << SOUT_BUFFER_FLAGS_BLOCK_SHIFT)) if( ((i_flags & BLOCK_FLAG_TYPE_I )
&& id->i_next_gop_duration >= 300000) && id->i_next_gop_duration >= 300000)
|| (id->i_next_gop_duration > p_stream->p_sys->i_shaping_delay) ) || (id->i_next_gop_duration > p_stream->p_sys->i_shaping_delay) )
{ {
...@@ -275,17 +278,17 @@ static int transrate_video_process( sout_stream_t *p_stream, ...@@ -275,17 +278,17 @@ static int transrate_video_process( sout_stream_t *p_stream,
while ( id->p_current_buffer != NULL ) while ( id->p_current_buffer != NULL )
{ {
sout_buffer_t * p_next = id->p_current_buffer->p_next; block_t * p_next = id->p_current_buffer->p_next;
if ( tr->fact_x == 1.0 ) if ( tr->fact_x == 1.0 )
{ {
bs->i_byte_out += id->p_current_buffer->i_size; bs->i_byte_out += id->p_current_buffer->i_buffer;
id->p_current_buffer->p_next = NULL; id->p_current_buffer->p_next = NULL;
sout_BufferChain( out, id->p_current_buffer ); block_ChainAppend( out, id->p_current_buffer );
} }
else else
{ {
E_(process_frame)( p_stream, id, id->p_current_buffer, out ); E_(process_frame)( p_stream, id, id->p_current_buffer, out );
sout_BufferDelete(p_stream->p_sout, id->p_current_buffer); block_Release( id->p_current_buffer);
} }
id->p_current_buffer = p_next; id->p_current_buffer = p_next;
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Copyright (C) 2003 Antoine Missout * Copyright (C) 2003 Antoine Missout
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* $Id: transrate.h,v 1.1 2004/03/03 11:20:52 massiot Exp $ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -98,8 +98,8 @@ struct sout_stream_id_t ...@@ -98,8 +98,8 @@ struct sout_stream_id_t
void *id; void *id;
vlc_bool_t b_transrate; vlc_bool_t b_transrate;
sout_buffer_t *p_current_buffer; block_t *p_current_buffer;
sout_buffer_t *p_next_gop; block_t *p_next_gop;
mtime_t i_next_gop_duration; mtime_t i_next_gop_duration;
size_t i_next_gop_size; size_t i_next_gop_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment