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;
......
This diff is collapsed.
...@@ -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;
......
This diff is collapsed.
...@@ -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