Dynamic output quality patch
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; } }
Hello Timothy, Wednesday, July 11, 2001, 6:47:09 AM, you wrote: TBT> I got annoyed that my avi's were skipping the other day, and thought TBT> they looked like crap without post-processing, so I wrote a little patch TBT> to dynamically select the output quality based on current CPU usage (at TBT> least for DivX, OpenDivX, and MPEG). Skipping goes away, and most of the TBT> time stuff looks good. TBT> The patch is to mplayer.c from the 0.17a Ideg Counter version, so you'll TBT> probably have to do a little work to apply it to the current version of TBT> that file. Could you please do the patch again with diff -Naur this format is a pain in the ass to read for humans and as it's against idegcounter it makes things even worse. -- Best regards, Felix mailto:atmosfear@users.sourceforge.net _______________________________________________ Mplayer-dev-eng mailing list Mplayer-dev-eng@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/mplayer-dev-eng
Hi,
pain in the ass to read for humans and as it's against idegcounter it makes things even worse. it makes it unusable. because teh whole timing and frame dropping stuff has been rewritten from scratch, at different way...
A'rpi / Astral & ESP-team -- mailto:arpi@thot.banki.hu http://esp-team.scene.hu _______________________________________________ Mplayer-dev-eng mailing list Mplayer-dev-eng@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/mplayer-dev-eng
participants (3)
-
Arpi -
Felix Bünemann -
Timothy B. Terriberry