X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Ftransrate%2Ftransrate.c;h=af73e7c2ef620e53947fb1ee04d43f1093717fbf;hb=fa4bde0b26a6c7a2a617362ea0b17144686e39fe;hp=3ef91de6791d740d809714f1c36380f2b68af8ed;hpb=85b29bdc288a1573d43bd524908be5748a9b3640;p=vlc diff --git a/modules/stream_out/transrate/transrate.c b/modules/stream_out/transrate/transrate.c index 3ef91de679..af73e7c2ef 100644 --- a/modules/stream_out/transrate/transrate.c +++ b/modules/stream_out/transrate/transrate.c @@ -1,7 +1,7 @@ /***************************************************************************** * transrate.c: MPEG2 video transrating module ***************************************************************************** - * Copyright (C) 2003 VideoLAN (Centrale Réseaux) and its contributors + * Copyright (C) 2003 the VideoLAN team * $Id$ * * Authors: Christophe Massiot @@ -19,21 +19,25 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include #define NDEBUG 1 +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include -#include -#include -#include +#include +#include +#include +#include +#include #include "transrate.h" @@ -52,14 +56,43 @@ static int transrate_video_process( sout_stream_t *, sout_stream_id_t *, block_ /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_category( CAT_SOUT ); - set_subcategory( SUBCAT_SOUT_STREAM ); - set_description( _("MPEG2 video transrating stream output") ); - set_capability( "sout stream", 50 ); - add_shortcut( "transrate" ); - set_callbacks( Open, Close ); -vlc_module_end(); + +#define VB_TEXT N_("Video bitrate") +/*xgettext:no-c-format*/ +#define VB_LONGTEXT N_( \ + "New target video bitrate. Quality is ok for -10/15\% of the original" \ + "bitrate." ) + +#define SHAPING_TEXT N_("Shaping delay") +#define SHAPING_LONGTEXT N_( \ + "Amount of data used for transrating in ms." ) + +#define MPEG4_MATRIX_TEXT N_("Use MPEG4 matrix") +#define MPEG4_MATRIX_LONGTEXT N_( \ + "Use the MPEG4 quantification matrix." ) + +#define SOUT_CFG_PREFIX "sout-transrate-" + +vlc_module_begin () + set_category( CAT_SOUT ) + set_subcategory( SUBCAT_SOUT_STREAM ) + set_description( N_("MPEG2 video transrating stream output") ) + set_capability( "sout stream", 50 ) + add_shortcut( "transrate" ) + set_shortname( N_("Transrate") ) + set_callbacks( Open, Close ) + + add_integer( SOUT_CFG_PREFIX "vb", 3 * 100 * 1000, NULL, + VB_TEXT, VB_LONGTEXT, false ) + add_integer( SOUT_CFG_PREFIX "shaping", 500, NULL, + SHAPING_TEXT, SHAPING_LONGTEXT, false ) + add_bool( SOUT_CFG_PREFIX "mpeg4-matrix", false, NULL, + MPEG4_MATRIX_TEXT, MPEG4_MATRIX_LONGTEXT, false ) +vlc_module_end () + +static const char *const ppsz_sout_options[] = { + "vb", "shaping", "mpeg4-matrix", NULL +}; struct sout_stream_sys_t { @@ -79,46 +112,30 @@ static int Open( vlc_object_t *p_this ) { sout_stream_t *p_stream = (sout_stream_t*)p_this; sout_stream_sys_t *p_sys; - char *val; p_sys = malloc( sizeof( sout_stream_sys_t ) ); p_sys->p_out = sout_StreamNew( p_stream->p_sout, p_stream->psz_next ); - p_sys->i_vbitrate = 0; + config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, + p_stream->p_cfg ); + p_sys->i_vbitrate = var_CreateGetInteger( p_stream, SOUT_CFG_PREFIX "vb" ); + if( p_sys->i_vbitrate < 16000 ) + p_sys->i_vbitrate *= 1000; - if( ( val = sout_cfg_find_value( p_stream->p_cfg, "vb" ) ) ) - { - p_sys->i_vbitrate = atoi( val ); - if( p_sys->i_vbitrate < 16000 ) - { - p_sys->i_vbitrate *= 1000; - } - } - else + p_sys->i_shaping_delay = var_CreateGetInteger( p_stream, + SOUT_CFG_PREFIX "shaping" ) * 1000; + if( p_sys->i_shaping_delay <= 0 ) { - p_sys->i_vbitrate = 3000000; + msg_Err( p_stream, + "invalid shaping (%"PRId64"ms) reseting to 500ms", + p_sys->i_shaping_delay / 1000 ); + p_sys->i_shaping_delay = 500000; } - p_sys->i_shaping_delay = 500000; - if( ( val = sout_cfg_find_value( p_stream->p_cfg, "shaping" ) ) ) - { - p_sys->i_shaping_delay = (int64_t)atoi( val ) * 1000; - if( p_sys->i_shaping_delay <= 0 ) - { - msg_Err( p_stream, - "invalid shaping ("I64Fd"ms) reseting to 500ms", - p_sys->i_shaping_delay / 1000 ); - p_sys->i_shaping_delay = 500000; - } - } - - p_sys->b_mpeg4_matrix = 0; - if( sout_cfg_find( p_stream->p_cfg, "mpeg4-matrix" ) ) - { - p_sys->b_mpeg4_matrix = 1; - } + p_sys->b_mpeg4_matrix = var_CreateGetBool( p_stream, + SOUT_CFG_PREFIX "mpeg4-matrix" ); - msg_Dbg( p_stream, "codec video %dkb/s max gop="I64Fd"us", + msg_Dbg( p_stream, "codec video %dkb/s max gop=%"PRId64"us", p_sys->i_vbitrate / 1024, p_sys->i_shaping_delay ); if( !p_sys->p_out ) @@ -174,13 +191,13 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) /* open output stream */ id->id = p_sys->p_out->pf_add( p_sys->p_out, p_fmt ); - id->b_transrate = VLC_TRUE; + id->b_transrate = true; } else { msg_Dbg( p_stream, "not transrating a stream (fcc=`%4.4s')", (char*)&p_fmt->i_codec ); id->id = p_sys->p_out->pf_add( p_sys->p_out, p_fmt ); - id->b_transrate = VLC_FALSE; + id->b_transrate = false; if( id->id == NULL ) { @@ -305,11 +322,11 @@ static int transrate_video_process( sout_stream_t *p_stream, i_new_bitrate = (mtime_t)tr->i_current_output * 8000 / (id->i_next_gop_duration / 1000); if (i_new_bitrate > p_stream->p_sys->i_vbitrate + 300000) - msg_Err(p_stream, "%lld -> %lld d=%lld", + msg_Err(p_stream, "%"PRId64" -> %"PRId64" d=%"PRId64, i_bitrate, i_new_bitrate, id->i_next_gop_duration); else - msg_Dbg(p_stream, "%lld -> %lld d=%lld", + msg_Dbg(p_stream, "%"PRId64" -> %"PRId64" d=%"PRId64, i_bitrate, i_new_bitrate, id->i_next_gop_duration); }