Mercurial > mplayer.hg
changeset 2626:da9777831e1b
divx4 and lame subconfig support
author | arpi |
---|---|
date | Fri, 02 Nov 2001 03:22:33 +0000 |
parents | a8145a712f25 |
children | 29bc08cc8e43 |
files | cfg-mencoder.h mencoder.c |
diffstat | 2 files changed, 74 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/cfg-mencoder.h Fri Nov 02 03:17:33 2001 +0000 +++ b/cfg-mencoder.h Fri Nov 02 03:22:33 2001 +0000 @@ -9,10 +9,46 @@ extern int use_old_pp; #endif +struct config divx4opts_conf[]={ + {"br", &divx4_param.bitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000}, + {"rc_period", &divx4_param.rc_period, CONF_TYPE_INT, 0,0,0}, + {"rc_reaction_period", &divx4_param.rc_reaction_period, CONF_TYPE_INT, 0,0,0}, + {"rc_reaction_ratio", &divx4_param.rc_reaction_ratio, CONF_TYPE_INT, 0,0,0}, + {"min_quant", &divx4_param.min_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32}, + {"max_quant", &divx4_param.max_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32}, + {"key", &divx4_param.max_key_interval, CONF_TYPE_INT, CONF_MIN,0,0}, + {"deinterlace", &divx4_param.deinterlace, CONF_TYPE_FLAG, 0,0,1}, + {"q", &divx4_param.quality, CONF_TYPE_INT, CONF_RANGE, 1, 5}, + {"help", "TODO: divx4opts help!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0}, + {NULL, NULL, 0, 0, 0, 0} +}; + +struct config lameopts_conf[]={ + {"q", &lame_param_quality, CONF_TYPE_INT, CONF_RANGE, 0, 9}, + {"vbr", &lame_param_vbr, CONF_TYPE_INT, CONF_RANGE, 0, vbr_max_indicator}, + {"cbr", &lame_param_vbr, CONF_TYPE_FLAG, 0, 0, 0}, + {"mode", &lame_param_mode, CONF_TYPE_INT, CONF_RANGE, 0, MAX_INDICATOR}, + {"padding", &lame_param_padding, CONF_TYPE_INT, CONF_RANGE, 0, PAD_MAX_INDICATOR}, + {"br", &lame_param_br, CONF_TYPE_INT, CONF_RANGE, 0, 1024}, + {"ratio", &lame_param_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 100}, + {NULL, NULL, 0, 0, 0, 0} +}; + struct config conf[]={ /* name, pointer, type, flags, min, max */ {"include", cfg_include, CONF_TYPE_FUNC_PARAM, 0, 0, 0}, /* this must be the first!!! */ + {"ofps", &force_ofps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0}, + {"o", &out_filename, CONF_TYPE_STRING, 0, 0, 0}, + + {"mp3file", &mp3_filename, CONF_TYPE_STRING, 0, 0, 0}, + {"ac3file", &ac3_filename, CONF_TYPE_STRING, 0, 0, 0}, + + {"oac", &out_audio_codec, CONF_TYPE_STRING, 0, 0, 0}, + {"ovc", &out_video_codec, CONF_TYPE_STRING, 0, 0, 0}, + + {"divx4opts", divx4opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0}, + {"lameopts", lameopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0}, #include "cfg-common.h"
--- a/mencoder.c Fri Nov 02 03:17:33 2001 +0000 +++ b/mencoder.c Fri Nov 02 03:22:33 2001 +0000 @@ -73,9 +73,25 @@ int force_srate=0; +char* out_filename="test.avi"; +char* mp3_filename=NULL; +char* ac3_filename=NULL; + +char *out_audio_codec=NULL; // override audio codec +char *out_video_codec=NULL; // override video codec + //#include "libmpeg2/mpeg2.h" //#include "libmpeg2/mpeg2_internal.h" +ENC_PARAM divx4_param; + +int lame_param_quality=0; // best +int lame_param_vbr=vbr_default; +int lame_param_mode=-1; // unset +int lame_param_padding=-1; // unset +int lame_param_br=-1; // unset +int lame_param_ratio=-1; // unset + //-------------------------- config stuff: #include "cfgparser.h" @@ -185,7 +201,6 @@ aviwrite_stream_t* mux_v=NULL; FILE* muxer_f=NULL; -ENC_PARAM enc_param; ENC_FRAME enc_frame; ENC_RESULT enc_result; void* enc_handle=NULL; @@ -302,15 +317,12 @@ vo_image_ptr=vo_image; } -divx_quality=4; - if(!init_video(sh_video)){ mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_CouldntInitVideoCodec); exit(1); } - if(sh_audio){ // Go through the codec.conf and find the best codec... sh_audio->codec=NULL; @@ -354,7 +366,7 @@ video_out.draw_frame=draw_frame; // set up output file: -muxer_f=fopen("test.avi","wb"); +muxer_f=fopen(out_filename,"wb"); muxer=aviwrite_new_muxer(); // ============= VIDEO =============== @@ -446,23 +458,15 @@ break; case VCODEC_DIVX4: // init divx4linux: - enc_param.x_dim=sh_video->disp_w; - enc_param.y_dim=sh_video->disp_h; - enc_param.framerate=(float)mux_v->h.dwRate/mux_v->h.dwScale; - enc_param.bitrate=800000; - enc_param.rc_period=0; - enc_param.rc_reaction_period=0; - enc_param.rc_reaction_ratio=0; - enc_param.max_quantizer=0; - enc_param.min_quantizer=0; - enc_param.max_key_interval=0; - enc_param.use_bidirect=0; - enc_param.deinterlace=0; - enc_param.quality=5; // the quality of compression ( 1 - fastest, 5 - best ) - enc_param.obmc=0; - enc_param.handle=NULL; - encore(NULL,ENC_OPT_INIT,&enc_param,NULL); - enc_handle=enc_param.handle; + divx4_param.x_dim=sh_video->disp_w; + divx4_param.y_dim=sh_video->disp_h; + divx4_param.framerate=(float)mux_v->h.dwRate/mux_v->h.dwScale; + if(!divx4_param.bitrate) divx4_param.bitrate=800000; + else if(divx4_param.bitrate<=16000) divx4_param.bitrate*=1000; + if(!divx4_param.quality) divx4_param.quality=5; // the quality of compression ( 1 - fastest, 5 - best ) + divx4_param.handle=NULL; + encore(NULL,ENC_OPT_INIT,&divx4_param,NULL); + enc_handle=divx4_param.handle; break; } @@ -472,25 +476,24 @@ case ACODEC_VBRMP3: lame=lame_init(); - lame_set_bWriteVbrTag(lame,0); lame_set_in_samplerate(lame,sh_audio->samplerate); lame_set_num_channels(lame,mux_a->wf->nChannels); lame_set_out_samplerate(lame,mux_a->h.dwRate); -lame_set_quality(lame,0); // best q -//lame_set_mode(lame,JOINT_STEREO); // j-st -//lame_set_brate(lame,64); -//lame_set_compression_ratio(lame,20); -lame_set_VBR(lame,vbr_default); // ??? -//lame_set_VBR(lame,vbr_abr); // ??? -lame_set_VBR_q(lame,6); // 1 = best vbr q 6=~128k -//lame_set_VBR_mean_bitrate_kbps(lame,128); - +if(lame_param_vbr){ // VBR: + lame_set_VBR(lame,lame_param_vbr); // vbr mode + lame_set_VBR_q(lame,lame_param_quality+1); // 1 = best vbr q 6=~128k + if(lame_param_br>0) lame_set_VBR_mean_bitrate_kbps(lame,lame_param_br); +} else { // CBR: + lame_set_quality(lame,lame_param_quality); // 0 = best q + if(lame_param_br>0) lame_set_brate(lame,lame_param_br); +} +if(lame_param_mode>=0) lame_set_mode(lame,lame_param_mode); // j-st +if(lame_param_ratio>0) lame_set_compression_ratio(lame,lame_param_ratio); lame_init_params(lame); - if(verbose){ -lame_print_config(lame); -lame_print_internals(lame); + lame_print_config(lame); + lame_print_internals(lame); } }