Commit a8538b58 authored by Simon Morlat's avatar Simon Morlat
Browse files

first increment ptime, then decrease quality

parent 674c20e4
...@@ -88,32 +88,33 @@ static int audio_bitrate_driver_execute_action(MSBitrateDriver *objbase, const M ...@@ -88,32 +88,33 @@ static int audio_bitrate_driver_execute_action(MSBitrateDriver *objbase, const M
if (action->type==MSRateControlActionDecreaseBitrate){ if (action->type==MSRateControlActionDecreaseBitrate){
/*reducing bitrate of the codec isn't sufficient. Increasing ptime is much more efficient*/ /*reducing bitrate of the codec isn't sufficient. Increasing ptime is much more efficient*/
inc_ptime(obj); if (inc_ptime(obj)==-1){
if (obj->nom_bitrate>0){ if (obj->nom_bitrate>0){
int cur_br=0; int cur_br=0;
int new_br; int new_br;
if (ms_filter_call_method(obj->encoder,MS_FILTER_GET_BITRATE,&obj->cur_bitrate)!=0){ if (ms_filter_call_method(obj->encoder,MS_FILTER_GET_BITRATE,&obj->cur_bitrate)!=0){
ms_message("MSAudioBitrateDriver: Encoder has current bitrate %i",obj->cur_bitrate); ms_message("MSAudioBitrateDriver: Encoder has current bitrate %i",obj->cur_bitrate);
} }
/*if max ptime is reached, then try to reduce the codec bitrate if possible */ /*if max ptime is reached, then try to reduce the codec bitrate if possible */
if (ms_filter_call_method(obj->encoder,MS_FILTER_GET_BITRATE,&cur_br)!=0){ if (ms_filter_call_method(obj->encoder,MS_FILTER_GET_BITRATE,&cur_br)!=0){
ms_message("MSAudioBitrateDriver: GET_BITRATE failed"); ms_message("MSAudioBitrateDriver: GET_BITRATE failed");
return 0; return 0;
} }
new_br=cur_br-((cur_br*action->value)/100); new_br=cur_br-((cur_br*action->value)/100);
ms_message("MSAudioBitrateDriver: Attempting to reduce audio bitrate to %i",new_br); ms_message("MSAudioBitrateDriver: Attempting to reduce audio bitrate to %i",new_br);
if (ms_filter_call_method(obj->encoder,MS_FILTER_SET_BITRATE,&new_br)!=0){ if (ms_filter_call_method(obj->encoder,MS_FILTER_SET_BITRATE,&new_br)!=0){
ms_message("MSAudioBitrateDriver: SET_BITRATE failed, incrementing ptime"); ms_message("MSAudioBitrateDriver: SET_BITRATE failed, incrementing ptime");
inc_ptime(obj); inc_ptime(obj);
return 0; return 0;
}
new_br=0;
ms_filter_call_method(obj->encoder,MS_FILTER_GET_BITRATE,&new_br);
ms_message("MSAudioBitrateDriver: bitrate actually set to %i",new_br);
obj->cur_bitrate=new_br;
} }
new_br=0;
ms_filter_call_method(obj->encoder,MS_FILTER_GET_BITRATE,&new_br);
ms_message("MSAudioBitrateDriver: bitrate actually set to %i",new_br);
obj->cur_bitrate=new_br;
} }
}else if (action->type==MSRateControlActionDecreasePacketRate){ }else if (action->type==MSRateControlActionDecreasePacketRate){
inc_ptime(obj); inc_ptime(obj);
......
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