[MPlayer-dev-eng] [PATCH] Better double frame rate output and frame limit option.

Vicente Sendra visenri at yahoo.es
Tue Dec 18 02:12:47 CET 2012


Finally, i finished all my test for the new system.


////////////////////////////////////////
    New fpslimit option
////////////////////////////////////////

The new option fpslimit has this syntax:
 
-fpslimit <option1:option2..>

 -options:
  mode=<0 .. 2>
    working mode, 
    0(default) disables frame limit
    1 fixed frame limit
    2 automatic frame limit detection
  fastdrop=<0.0 .. 10.0>
    makes some extra drops if > 0
  min=<value>
    lower limit for fps (set to max in mode 1)
  max=<value>
    upper limit for fps
  start=<value>
    starting limit for fps (set to max in mode 1)

In mode 1 the system simply drops frames trying to limit
output frame rate to specified value ("max").

In mode 2 the system calculates a max frame rate based on
vflip time.
Roughly speaking, it lowers max frame rate if vflip time
gets big, and raises frame rate if if vflip time is low and
video frame rate is higher than max frame rate.
("min" and "max" options limit the calculated value, and
"start" sets the initial value, if not specified or 0, no
limits are applied. If "start" is not set a value is
calculated from video frame rate and average frame rate
output).
It takes a few seconds to get the right value.

Fastdrop reacts in a fast way to vflip time, triggering
extra frame drops, it makes the system react faster, highly
recommended for either mode 1 or 2, makes fps limit
precision (specified or calculated) less important.
Higher values trigger a frame drop faster, normaly should be 
set to 1.

Mode 1 can be used in all vo drivers, but must be used for
vo drivers where vflip generates a wait in almost all frames
(vsync enabled, but no buffering), mode 2 would drop lots of
frames. Also, for these drivers, fastdrop option must not be
used.

Example (no buffering) : -fpslimit mode=1:max=60
Example (with buffering):-fpslimit mode=1:fastdrop=1:max=60
(fastdrop is optional, but recommended)

Mode 2 should be used for vo drivers that do not delay vflip
to next vertical refresh (vsync enabled, but buffering
allows to return immediately).

Example (no buffering) : do not use
Example (with buffering):-fpslimit mode=2:fastdrop=1:max=60
(fastdrop is optional, but recommended)

 
////////////////////////////////////////
    New framedrop logic
////////////////////////////////////////
 
-Works even with no sound.
-Drops frames by sync or fpslimit.
-Works for all frames, read and interpolated (created by vf)

////////////////////////////////////////
    New double frame rate output
////////////////////////////////////////
 
-Accurate timing for frames created by video filters

 In correct-pts mode frame time is set by video filter.
 to make this work video filter needs to know video frame 
 time, this is supplied by new control option:
 VFCTRL_SET_FRAMETIME.
 
 In normal mode frame time is calculated taking into account
 the number of frames created by video filter(s) and video 
 frame time. (vf_num_queued_frames function returns number 
 of frames created for each read frame).
 
 In both modes, filters that add frames always queue them
 (previously this only happened in correct-pts mode).
 
 Changes were needed in decode_video function(dec_video.c) 
 to avoid the message:
 "Too many buffered pts"
 This happens with vanilla mplayer.
 When framedropping dropped some frames, pts values accumulated
 in the buffer.
 
 I think there are two things here that are not perfect
 (but at least not worse than before):
 
 -Why generate_video_frame function (correct-pts mode) calls
  this function like this:
  decode_video(sh_video, start, in_size, drop_frame, pts, NULL);
  
  And not like this (like in normal mode):
  decode_video(sh_video, start, in_size, drop_frame, sh_video->pts, &full_frame);
  
  The problem is full_frame should be used to check if frame is 
  complete and not an interlaced frame.
  Right now it works as vanilla code, but i think it's not ok, 
  because if we call this function with drop_frame <> 0 with an 
  incomplete frame we'll get a return value of null and, in this 
  case makes generate_video_frame return with a -1 (and -1 should 
  only be returned for full dropped frames).
  
 -I've got errors in correct-pts mode with mpeg2 files:
  "mpeg_decode_postinit() failure"
  followed by a lot of erros.
  
////////////////////////////////////////
    Filter yadif compatible with new double frame rate output
////////////////////////////////////////

Added internal field: buffered_frametime
Added handling of VFCTRL_SET_FRAMETIME

////////////////////////////////////////
    Filter tfields compatible with new double frame rate output
////////////////////////////////////////
  
- vf_tfields.c

Added internal fields: buffered_frametime, do_deinterlace
Added control function
Added handling of :
VFCTRL_SET_FRAMETIME, VFCTRL_GET_DEINTERLACE, VFCTRL_SET_DEINTERLACE
Added mode 5 for this filter, like mode 1, but just skips filtering

VFCTRL_SET_DEINTERLACE is only allowed in mode 1,5.
A question here: can the filter configuration (video output size) be changed on the fly, so we can allow this in all modes?.


////////////////////////////////////////
    mplayer.c
////////////////////////////////////////

I know it's a big patch.

Some notes:

For easy testing/debugging I've added some outputs like this (should be removed when done):

time sleeping:
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Frametime_sleep : %3.3f  ", (*time_frame)*1000);

time between frames:
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Wait until: : %5.3f\n", dif_flip*1000);

Information for fpslimit
+        mp_msg(MSGT_CPLAYER, MSGL_INFO, "Frametime_error I:%d T:%3.3f F:%3.3f E:%3.3f FD:%3.3f IO:%d \n",                                                         
+               interpolated, fpsl_target_frametime*1000, frame_time*1000, fpsl_frametime_error*1000, vflip_frame_time_usage_fastdrop*1000, int_frames_output);    

dropped frames:
mp_msg(MSGT_CPLAYER, MSGL_INFO, "DROPPED INT. FRAME by VOUT \n");

checking pts:
mp_msg(MSGT_CPLAYER, MSGL_INFO, "PTS: %3.3f \n", sh_video->pts);

mp_msg(MSGT_CPLAYER, MSGL_INFO, "PTSdec: %3.3f , %3.3f \n",pts, sh_video->pts);

frame stats:
+        if (sh_video->timer > 0.5)
+            saddf(line, &pos, width, "%2.3f %2.1f %3.3f ",
+                  vflip_min_time*1000,
+                  vflip_frame_time_usage*1000,
+                  vout_frame_time_avg*1000);

Global variables marked with //- can be changed to local once we finish debugging.


I think there are enough comments to understand the new parts, but don`t hesitate to ask me if you don't, I'll try to explain it asap.

Also, tell me if there is something that should be changed/corrected/done in another way, any suggestions are welcome.

I'm very interested in testing this as much as possible, as far as i tested, it works as vanilla code with fpslimit disabled.

New double frame rate output works in both modes (correct-pts and normal) but i could not test mpeg2 streams in correct-pts because of the errors i said previously.

All the work has been done over 35196 and then updated to r35689.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfg-mplayer.h.diff
Type: application/octet-stream
Size: 1139 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20121218/c2a490e1/attachment-0007.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dec_video.c.diff
Type: application/octet-stream
Size: 1022 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20121218/c2a490e1/attachment-0008.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf.h.diff
Type: application/octet-stream
Size: 805 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20121218/c2a490e1/attachment-0009.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf.c.diff
Type: application/octet-stream
Size: 529 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20121218/c2a490e1/attachment-0010.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf_tfields.c.diff
Type: application/octet-stream
Size: 5359 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20121218/c2a490e1/attachment-0011.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf_yadif.c.diff
Type: application/octet-stream
Size: 2920 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20121218/c2a490e1/attachment-0012.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplayer.c.diff
Type: application/octet-stream
Size: 47373 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20121218/c2a490e1/attachment-0013.obj>


More information about the MPlayer-dev-eng mailing list