I got annoyed that my avi's were skipping the other day, and thought they looked like crap without post-processing, so I wrote a little patch to dynamically select the output quality based on current CPU usage (at least for DivX, OpenDivX, and MPEG). Skipping goes away, and most of the time stuff looks good. The patch is to mplayer.c from the 0.17a Ideg Counter version, so you'll probably have to do a little work to apply it to the current version of that file. 363a364
int output_quality; 958a971 output_quality=divx_quality; 993c1006 < printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) );
printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",output_quality>4?4:output_quality) ); 1008c1021 < dec_set.postproc_level = divx_quality;
dec_set.postproc_level = (1<<output_quality)-1; 1017c1030 < picture->pp_options=divx_quality;
picture->pp_options=(1<<output_quality)-1; 1019c1032 < if(divx_quality){
if(output_quality){ 1146a1160,1161 double cvideo_base_vtime; double cvideo_base_vframe; 1372a1388,1389 cvideo_base_vframe=v_frame; cvideo_base_vtime=video_time_usage; 1377a1395 float vdecode_time; 1398c1416,1417 < t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
t2=GetTimer();t=t2-t; vdecode_time=t*0.000001f;video_time_usage+=vdecode_time;
1421c1440,1441 < t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; ---
t2=GetTimer();t=t2-t; vdecode_time=t*0.000001f;video_time_usage+=vdecode_time;
1455c1475,1476 < t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; ---
t2=GetTimer();t=t2-t; vdecode_time=t*0.000001f;video_time_usage+=vdecode_time;
1512c1533,1534 < t+=GetTimer(); video_time_usage+=t*0.000001; ---
t+=GetTimer(); vdecode_time=t*0.000001f; video_time_usage+=vdecode_time;
1545a1568,1618
/*Output quality adjustments:*/ /*If we took a long time decoding this frame, downgrade the quality.*/ if(output_quality>0&& (video_time_usage-cvideo_base_vtime)*v_frame>= (0.95*v_frame-(vout_time_usage+audio_time_usage))* (v_frame-cvideo_base_vframe-frame_correction)){ output_quality>>=1; /*printf("\nDowngrading quality to %i.\n",output_quality);*/ switch(sh_video->codec->driver){ case 3:{ /*OpenDivX*/ DEC_SET dec_set; dec_set.postproc_level=(1<<output_quality)-1; decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); }break; #ifdef USE_DIRECTSHOW case 4:{ /*W32/DirectShow*/ DS_SetValue_DivX("Quality",output_quality>4?4:output_quality); }break; #endif /*case 1: ??*/ case 2:{ picture->pp_options=(1<<output_quality)-1; }break; } } /*If we had plenty of extra time, upgrade the quality.*/ else if(output_quality<divx_quality&& vdecode_time<0.50f*frame_time&& (video_time_usage-cvideo_base_vtime)*v_frame< (0.67*v_frame-(vout_time_usage+audio_time_usage))* (v_frame-cvideo_base_vframe-frame_correction)){ output_quality++; /*printf("\nUpgrading quality to %i.\n",output_quality);*/ switch(sh_video->codec->driver){ case 3:{ /*OpenDivX*/ DEC_SET dec_set; dec_set.postproc_level=(1<<output_quality)-1; decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); }break; #ifdef USE_DIRECTSHOW case 4:{ /*W32/DirectShow*/ DS_SetValue_DivX("Quality",output_quality>4?4:output_quality); }break; #endif /*case 1: ??*/ case 2:{ picture->pp_options=(1<<output_quality)-1; }break; } }