Mercurial > mplayer.hg
changeset 17480:3993a5fad89a
pass vbv_size & max_rate from encoder to muxer over muxer_stream_t (if this is wrong/silly/10000000l then dont hesitate to flame / reverse)
make a few things like mux_rate, mux_max_delay, ... user settable
fixed buffer underflow errors when muxing to mpeg-ps
author | michael |
---|---|
date | Wed, 25 Jan 2006 01:17:57 +0000 |
parents | 92a9690cc3e2 |
children | 99c0caec4677 |
files | libmpcodecs/ve_lavc.c libmpdemux/muxer.h libmpdemux/muxer_lavf.c |
diffstat | 3 files changed, 30 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/ve_lavc.c Tue Jan 24 23:55:43 2006 +0000 +++ b/libmpcodecs/ve_lavc.c Wed Jan 25 01:17:57 2006 +0000 @@ -362,6 +362,9 @@ lavc_venc_context->bit_rate = lavc_param_vbitrate*1000; else lavc_venc_context->bit_rate = 800000; /* default */ + + //mux_v->wf->nAvgBytesPerSec= lavc_venc_context->bit_rate/8; + lavc_venc_context->bit_rate_tolerance= lavc_param_vrate_tolerance*1000; #if LIBAVCODEC_BUILD >= 4754 lavc_venc_context->time_base= (AVRational){mux_v->h.dwScale, mux_v->h.dwRate}; @@ -402,9 +405,14 @@ lavc_venc_context->rc_qmod_amp= lavc_param_rc_qmod_amp; lavc_venc_context->rc_qmod_freq= lavc_param_rc_qmod_freq; lavc_venc_context->rc_eq= lavc_param_rc_eq; + + mux_v->max_rate= lavc_venc_context->rc_max_rate= lavc_param_rc_max_rate*1000; lavc_venc_context->rc_min_rate= lavc_param_rc_min_rate*1000; + + mux_v->vbv_size= lavc_venc_context->rc_buffer_size= lavc_param_rc_buffer_size*1000; + lavc_venc_context->rc_initial_buffer_occupancy= lavc_venc_context->rc_buffer_size * lavc_param_rc_initial_buffer_occupancy;
--- a/libmpdemux/muxer.h Tue Jan 24 23:55:43 2006 +0000 +++ b/libmpdemux/muxer.h Wed Jan 25 01:17:57 2006 +0000 @@ -43,6 +43,9 @@ // muxer of that stream struct muxer_t *muxer; void *priv; // private stream specific data stored by the muxer + + int vbv_size; + int max_rate; } muxer_stream_t; typedef struct {
--- a/libmpdemux/muxer_lavf.c Tue Jan 24 23:55:43 2006 +0000 +++ b/libmpdemux/muxer_lavf.c Wed Jan 25 01:17:57 2006 +0000 @@ -43,10 +43,19 @@ static char *conf_format = NULL; static int conf_allow_lavf = 0; +static int mux_rate= 0; +static int mux_packet_size= 0; +static float mux_preload= 0.5; +static float mux_max_delay= 0.7; m_option_t lavfopts_conf[] = { {"format", &(conf_format), CONF_TYPE_STRING, 0, 0, 0, NULL}, {"i_certify_that_my_video_stream_does_not_use_b_frames", &conf_allow_lavf, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"muxrate", &mux_rate, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL}, + {"packetsize", &mux_packet_size, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL}, + {"preload", &mux_preload, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL}, + {"delay", &mux_max_delay, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL}, + {NULL, NULL, 0, 0, 0, 0, NULL} }; @@ -173,12 +182,16 @@ ctx = &(spriv->avstream->codec); #endif + if(stream->wf && stream->wf->nAvgBytesPerSec) + ctx->bit_rate = stream->wf->nAvgBytesPerSec * 8; + ctx->rc_buffer_size= stream->vbv_size; + ctx->rc_max_rate= stream->max_rate; + if(stream->type == MUXER_TYPE_AUDIO) { ctx->codec_id = codec_get_wav_id(stream->wf->wFormatTag); ctx->codec_tag = codec_get_wav_tag(ctx->codec_id); mp_msg(MSGT_MUXER, MSGL_INFO, "AUDIO CODEC ID: %x, TAG: %x\n", ctx->codec_id, (uint32_t) ctx->codec_tag); - ctx->bit_rate = stream->wf->nAvgBytesPerSec * 8; ctx->sample_rate = stream->wf->nSamplesPerSec; // mp_msg(MSGT_MUXER, MSGL_INFO, "stream->h.dwSampleSize: %d\n", stream->h.dwSampleSize); ctx->channels = stream->wf->nChannels; @@ -353,7 +366,11 @@ mp_msg(MSGT_MUXER, MSGL_FATAL, "Invalid output format parameters\n"); goto fail; } - + priv->oc->packet_size= mux_packet_size; + priv->oc->mux_rate= mux_rate; + priv->oc->preload= (int)(mux_preload*AV_TIME_BASE); + priv->oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE); + register_protocol(&mp_protocol); if(url_fopen(&priv->oc->pb, mp_filename, URL_WRONLY))