summaryrefslogtreecommitdiffstats
path: root/mencoder.c
diff options
context:
space:
mode:
authorods15 <ods15@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-02-19 04:31:14 +0000
committerods15 <ods15@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-02-19 04:31:14 +0000
commit0d29a779f819a3465480d7f2df523d07094e2e58 (patch)
treef3981c6d6824f7187f1efb3b100a70ecfe64dcc4 /mencoder.c
parent8f51734daf98412abdce30e0e2106e69bbda8acb (diff)
downloadmpv-0d29a779f819a3465480d7f2df523d07094e2e58.tar.bz2
mpv-0d29a779f819a3465480d7f2df523d07094e2e58.tar.xz
deobfuscate some a/v sync code
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17648 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'mencoder.c')
-rw-r--r--mencoder.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/mencoder.c b/mencoder.c
index d06acc1ebf..f63fee0d21 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -1274,29 +1274,30 @@ if(demuxer2){ // 3-pass encoding, read control file (frameno.avi)
// check frame duplicate/drop:
//printf("\r### %5.3f ###\n",v_timer_corr);
+float mux_frametime = (float)mux_v->h.dwScale/mux_v->h.dwRate;
-if(v_timer_corr>=(float)mux_v->h.dwScale/mux_v->h.dwRate &&
- (skip_limit<0 || skip_flag<skip_limit) ){
- v_timer_corr-=(float)mux_v->h.dwScale/mux_v->h.dwRate;
+if (v_timer_corr >= mux_frametime && (skip_limit<0 || skip_flag < skip_limit)) {
+ v_timer_corr-=mux_frametime;
++skip_flag; // skip
-} else
-while(v_timer_corr<=-(float)mux_v->h.dwScale/mux_v->h.dwRate &&
- (skip_limit<0 || (-skip_flag)<skip_limit) ){
- v_timer_corr+=(float)mux_v->h.dwScale/mux_v->h.dwRate;
+}
+while (v_timer_corr <= -mux_frametime && (skip_limit<0 || -skip_flag < skip_limit)) {
+ v_timer_corr+=mux_frametime;
--skip_flag; // dup
}
-while( (v_pts_corr<=-(float)mux_v->h.dwScale/mux_v->h.dwRate && skip_flag>0)
- || (v_pts_corr<=-2*(float)mux_v->h.dwScale/mux_v->h.dwRate) ){
- v_pts_corr+=(float)mux_v->h.dwScale/mux_v->h.dwRate;
+// either v_pts_corr is big, more than 2 times framerate, then we follow its advice,
+// or, it cancels out v_timer_corr, in which case be happy and do nothing.
+
+while ((v_pts_corr <= -mux_frametime && skip_flag > 0) || (v_pts_corr <= -2*mux_frametime)) {
+ v_pts_corr+=mux_frametime;
--skip_flag; // dup
}
-if( (v_pts_corr>=(float)mux_v->h.dwScale/mux_v->h.dwRate && skip_flag<0)
- || (v_pts_corr>=2*(float)mux_v->h.dwScale/mux_v->h.dwRate) )
- if(skip_flag<=0){ // we can't skip more than 1 frame now
- v_pts_corr-=(float)mux_v->h.dwScale/mux_v->h.dwRate;
+if ((v_pts_corr >= mux_frametime && skip_flag < 0) || (v_pts_corr >= 2*mux_frametime)) {
+ if (skip_flag<=0) { // we can't skip more than 1 frame now
+ v_pts_corr-=mux_frametime;
++skip_flag; // skip
}
+}
} // demuxer2