summaryrefslogtreecommitdiffstats
path: root/video/out/vo.c
Commit message (Collapse)AuthorAgeFilesLines
* vo: hide opengl-cb in --vo=helpwm42015-03-101-1/+1
| | | | Avoids stupid questions.
* vo_opengl: fix smoothmotion coefficient calculationStefano Pigozzi2015-02-131-0/+1
| | | | | Using prev_pts as the start of the scale was plain wrong. Change it to prev_vsync.
* vo: minor simplificationwm42015-02-071-13/+8
| | | | Whatever.
* vo: handle very long frame durations with smoothmotion enabledwm42015-01-261-1/+1
| | | | | | | | | | | | | | | With mf://, rather long frame durations are common. By default, one frame takes 1 second. This causes the if branch changed with this commit to always being taken, which in turn leads to the player not being woken up correctly. (As a consequence, it "freezes" by waiting for events that never come, and moving the mouse cursor over the window will wake it up again and advance video.) Obviously, the code should account for how long the video frame takes. The code is probably still not fully correct, but for now this fixes the issue at hand. Fixes #1521.
* vo: fix redraw logicwm42015-01-251-4/+2
| | | | | | | | It actually can and does happen that you want to redraw, even if no image was queued yet. Broken by commit 28582322. Fixes #1510.
* vo: generic redraw supportwm42015-01-241-5/+3
| | | | | | | | | | | | | | | | | | | | Usually, a VO must react to VOCTRL_REDRAW_FRAME in order to redraw the current screen correctly if video is paused (this is done to update OSD). But if it's not supported, we can just draw the current image again in the generic vo.c code. Unfortunately, this turned out pretty useless, because the VOs which would benefit from this need to redraw even if there is no image, in order to draw a black screen in --idle --force-window mode. The way redrawing is handled in the X11 common code and in vo_x11 and vo_xv is in the way, and I'm not sure what exactly vo_wayland requires. Other VOs have a non-trivial implementation of VOCTRL_REDRAW_FRAME, which (probably) makes redrawing slightly more efficient, e.g. by skipping texture upload. So for now, no VO uses this new functionality, but since it's trivial, commit it anyway. The vo_driver->untimed case is for forcibly disabling redraw for vo_lavc and vo_image always.
* vo: simplify VOs by adding generic screenshot supportwm42015-01-241-12/+31
| | | | | | | | | | | At the time screenshot support was added, images weren't refcounted yet, so screenshots required specialized implementations in the VOs. But now we can handle these things much simpler. Also see commit 5bb24980. If there are VOs in the future which can't do this (e.g. they need to write to the image passed to vo_driver->draw_image), this still could be disabled on a per-VO basis etc., so we lose no potential performance advantages.
* vo: fix disabling/enabling smoothmotion at runtimewm42015-01-231-4/+6
| | | | | | | | | | | | | vo.c queried the VO at initialization whether it wants to be updated on every display frame, or every video frame. If the smoothmotion option was changed at runtime, the rendering mode in vo.c wasn't updated. Just let vo_opengl set the mode directly. Abuse the existing vo_set_flip_queue_offset() function for this. Also add a comment suggesting the use of --display-fps to the manpage, which doesn't have anything to do with the rest of this commit, but is important to make smoothmotion run well.
* vo: allow dropping additional frames with smoothmotionwm42015-01-231-6/+6
| | | | | | | | | | | | | The logic disabled framedropping if the frame was interpolated (i.e. the render call is only done to interpolate between the previous frame, and the frame before that). It seems doing this wasn't even necessary, and broke framedrop in smoothmotion mode. In fact, this code did nothing for display with video fps below display fps. It did prevent the framedrop counter from going up, though. So change it so that dropped interpolated frames are never reported. (Doing so can give confusing results, such as dropping 1000s of frames on slow operations like video start or changing filters.)
* vo: cosmeticswm42015-01-231-22/+24
|
* vo: fix framedrop in normal casewm42015-01-231-1/+2
| | | | | vsync_timed is true if smoothmotion is used. That would mean framedrop is always disabled in the normal case.
* vo_opengl: add smoothmotion frame blendingStefano Pigozzi2015-01-231-6/+46
| | | | | | | | | | | | | | | | | | | SmoothMotion is a way to time and blend frames made popular by MadVR. It's intended behaviour is to remove stuttering caused by mismatches between the display refresh rate and the video fps, while preserving the video's original artistic qualities (no soap opera effect). It's supposed to make 24fps video playback on 60hz monitors as close as possible to a 24hz monitor. Instead of drawing a frame once once it's pts has passed the vsync time, we redraw at the display refresh rate, and if we detect the vsync is between two frames we interpolated them (depending on their position relative to the vsync). We actually interpolate as few frames as possible to avoid a blur effect as much as possible. For example, if we were to play back a 1fps video on a 60hz monitor, we would blend at most on 1 vsync for each frame (while the other 59 vsyncs would be rendered as is). Frame interpolation is always done before scaling and in linear light when possible (an ICC profile is used, or :srgb is used).
* video: remove vfcap.hwm42015-01-211-1/+0
| | | | | | | | | | | | | | | | | And remove all uses of the VFCAP_CSP_SUPPORTED* constants. This is supposed to reduce conversions if many filters are used (with many incompatible pixel formats), and also for preferring the VO's natively supported pixel formats (as opposed to conversion). This is worthless by now. Not only do the main VOs not use software conversion, but also the way vf_lavfi and libavfilter work mostly break the way the old MPlayer mechanism worked. Other important filters like vf_vapoursynth do not support "proper" format negotation either. Part of this was already removed with the vf_scale cleanup from today. While I'm touching every single VO, also fix the query_format argument (it's not a FourCC anymore).
* vo: never autoselect vo_nullwm42015-01-211-2/+4
| | | | Same deal as with commit d44b4ccb.
* vo_opengl_old: remove this VOwm42015-01-201-4/+0
| | | | | At this point, there is probably no hardware left that doesn't do OpenGL 2.1, and at the same time is fast enough to handle video.
* vo: restore framedropwm42015-01-201-1/+1
| | | | Fix inverted condition in commit 234d6329.
* video: fix waiting for last frame/format reconfigwm42015-01-191-0/+1
| | | | | | | | | | | We still need to send the VO a duration in these cases. Disabling framedrop has logically absolutely nothing to do with these cases; it was overlooked in commit 918b06c4. So we always send the frame duration (or a guess for it), and check whether framedropping is actually enabled in the VO code. (It would be cleaner to send framedrop as a flag, but I don't care about that right now.)
* player: respect --untimed on last framewm42015-01-161-2/+1
| | | | | | | | | | | | | | The last video frame is another case that has a separate code path, although it's pretty similar to the one in commit 73e5aa87. Fix this in a different way, which also takes care of the last frame case, although without context the code becomes slightly more tricky. As further cleanup, move the decision about framedropping itself to the same place, so the check in vo.c becomes much simpler. The check for the vo->driver->encode flag, which is remvoed completely, was redundant too. Fixes #1480.
* vo: don't synchronize when seekingwm42015-01-121-1/+7
| | | | | | | | | Don't use vo_control() for sending VOCTRL_RESET when starting a seek. This means vo_seek_reset() won't wait until the VO actually processed VOCTRL_RESET. It happens asynchronously instead. The impact of this change should be minimal, unless the VO is somehow too busy (like blocking on vsync).
* vo: add functions to increment drop_countxylosper2015-01-081-0/+7
| | | | | Add two functions which increment drop_count thread-safely. This is for the commit followed.
* video: batch query_format callswm42015-01-031-5/+7
| | | | | | | There are currently 568 pixel formats (actually fewer, but the namespace is this big), and for each format elaborate synchronization was done to call it synchronously on the VO. This is completely unnecessary, and we can do with just a single call.
* video: pass some VO params as structwm42014-12-311-14/+10
| | | | | Not particularly elegant, but better than adding more and more stuff to the relevant function signatures.
* vo_opengl: better probe handlingwm42014-12-191-3/+5
| | | | | | | | | | | | | Involve detection of software renderers in the probing properly. Other VOs could handle probing also more gracefully, and e.g. produce less noise if an API is unavailable. (Although other than the OpenGL VOs, only vo_wayland will.) Now the "sw" suboption for vo_opengl[_old] is strictly speaking not needed anymore. Doing "--vo=opengl" disables the probing logic, and will always force it, if possible. Includes some simplifications as well.
* vo: fix some nonsensewm42014-12-101-3/+2
| | | | | | | | | Commit d38bc531 is incorrect: the 50ms queue-ahead value and the flip queue offset have different functions. The latter is about calling flip_page in advance, so the change attempted to show video frames 50ms in advance on all VOs. The change was for vo_opengl_cb, but that can be handled differently.
* client API: expose OpenGL rendererwm42014-12-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds API to libmpv that lets host applications use the mpv opengl renderer. This is a more flexible (and possibly more portable) option to foreign window embedding (via --wid). This assumes that methods like context sharing and multithreaded OpenGL rendering are infeasible, and that a way is needed to integrate it with an application that uses a single thread to render everything. Add an example that does this with QtQuick/qml. The example is relatively lazy, but still shows how relatively simple the integration is. The FBO indirection could probably be avoided, but would require more work (and would probably lead to worse QtQuick integration, because it would have to ignore transformations like rotation). Because this makes mpv directly use the host application's OpenGL context, there is no platform specific code involved in mpv, except for hw decoding interop. main.qml is derived from some Qt example. The following things are still missing: - a way to do better video timing - expose GL renderer options, allow changing them at runtime - support for color equalizer controls - support for screenshots
* vo: include normal render-ahead time in flip_queue_offsetwm42014-12-091-2/+3
| | | | | | A small refactor; shouldn't change any behavior. Do this so immediate display can be achieved.
* video/out: minor simplification to event query functionwm42014-11-091-5/+4
| | | | The "clear" parameter is confusing and useless.
* command: make window-scale property observablewm42014-11-021-0/+26
| | | | | | | | | | | | Add a generic mechanism to the VO to relay "extra" events from VO to player. Use it to notify the core of window resizes, which in turn will be used to mark all affected properties ("window-scale" in this case) as changed. (I refrained from hacking this as internal command into input_ctx, or to poll the state change, etc. - but in the end, maybe it would be best to actually pass the client API context directly to the places where events can happen.)
* Set thread name for debuggingwm42014-10-191-0/+3
| | | | | | | | | | Especially with other components (libavcodec, OSX stuff), the thread list can get quite populated. Setting the thread name helps when debugging. Since this is not portable, we check the OS variants in waf configure. old-configure just gets a special-case for glibc, since doing a full check here would probably be a waste of effort.
* video: return responsibility of video redraw back to playloopwm42014-10-031-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | When the VO was moved it its own thread, responsibility for redrawing was given to the VO thread itself. So if there was a condition that indicated that redrawing was required, like expose events or certain VOCTRLs, the VO thread was redrawing itself. This worked fine, but there are some corner cases where this works rather badly. E.g. if I fullscreen the player and hit panscan controls with mpv's default autorepeat rate, playback stops. This happens because the VO redraws itself after every panscan change command. Running each (repeated) command takes so long due to redrawing and (involuntary) waiting on vsync, that it never leaves the input processing loop while the key is held down. I suspect that in my case, redrawing in fullscreen mode just gets slow enough that it takes 2 vsyncs instead of 1 on average, and the processing time gets larger than the autorepeat delay. Fix this by taking redraw control from the VO, and instead let the playloop issue a "real" redraw command to the VO if needed. This basically reverts redraw handling to what it was before moving the VO to a thread. CC: @mpv-player/stable
* video: fix redrawing when pausing after framedropwm42014-09-211-1/+1
| | | | | | | When pausing after a frame was just dropped, we're logically at the dropped frame, and thus should redraw the dropped frame. This was implemented, but didn't work after unpausing for the second time, because of a minor logic bug.
* vo_vdpau: better integration with the generic framedrop codewm42014-09-201-6/+11
| | | | | | | | | | | | | | | | | | | | vo_vdpau uses its own framedrop code, mostly for historic reasons. It has some tricky heuristics, of which I'm not sure how they work, or if they have any effect at all, but in any case, I want to keep this code for now. One day it might get fully ported to the vo.c framedrop code, or just removed. But improve its interaction with the user-visible framedrop controls. Make --framedrop actually enable and disable the vo_vdpau framedrop code, and increment the number of dropped frames correctly. The code path for other VOs should be equivalent. The vo_vdpau behavior should, except for the improvements mentioned above, be mostly equivalent as well. One minor change is that frames "shown" during preemption are always count as dropped. Remove the statement from the manpage that vo_vdpau is the default; this hasn't been the case for a while.
* video: wake up core as soon as possiblewm42014-09-161-0/+1
| | | | | | | | There's no reason to let the core wait until the frame is done displaying. In practice, the core normally didn't need this additional wakeup, and the VO was quick enough to fetch the new frame, before the core even attempted to queue a new frame. But it wasn't entirely clean, and the correct wakeup handling might matter in some cases.
* vo_corevideo: remove this VOStefano Pigozzi2014-09-061-4/+0
| | | | | | | This was kept in the codebase because it is slightly faster than --vo=opengl on really old Intel cards (from the GMA era). Time to kill it, and let it rest. Fixes #1061
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+1
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* video: avoid unnecessary frame droppingwm42014-08-231-1/+5
| | | | | | | | | If duration<0, it means the duration is unknown. Disable framedropping, because end_time makes no sense in this case. Also, strictly never drop the first frame. This fixes weird behavior with the cover-art case (for the 100th time).
* video: some debugging outputwm42014-08-221-0/+4
|
* video: don't assume query_format is thread-safewm42014-08-201-0/+15
| | | | Although it's probably safe for most VOs, there's no guarantee.
* video: add VOCTRL_GET_RECENT_FLIP_TIMEwm42014-08-181-1/+6
| | | | | | This could be used by VO implementations to report a recent vsync time to the generic VO code, which in turn will use it and the display FPS to estimate at which point in time the next vsync will happen.
* video: dump vsync phase into stats filewm42014-08-181-2/+4
| | | | | | | For debugging (drawing fun plots with TOOLS/stats-conv.py). Also move last_flip under the correct comment: it's not protected by the lock, and can be accessed by the VO thread only.
* video: make vo_opengl the default over vo_vdpauwm42014-08-171-3/+3
| | | | | | | | | | | | | Nvidia's vdpau implementation is pretty good, but other factors make it much less attractive for use as default VO. For example, Mesa often has low quality drivers (mess up things with the presentation queue and the vdpau API time source). Intel ruins things completely, and we're likely to run on emulation via OpenGL. Compositing has unknown effects (to me anyway), but appears to reduce the vdpau advantages. One important reason to prefer vo_vdpau was that it could do proper framedropping. Framedropping got fixed for the other VOs, so this reason is going away.
* video: take refresh rate changes into accountwm42014-08-171-10/+27
| | | | | | | | | | | | | | | This works only on X11, and only if the refresh rate changes due to the window being moved to another screen (detected by us). It doesn't include system screen reconfiguration yet. This calls VOCTRL_GET_DISPLAY_FPS on every frame, which makes me uneasy. It means extra thread communication with the win32 and Cocoa backends. On the other hand, a frame doesn't happen _that_ often, and the communication should still be pretty cheap and fast, so it's probably ok. Also needs some extra fuzz for vo_vdpau.c, because that does everything differently.
* video: add --display-fps switch to control framedrop FPSwm42014-08-161-3/+7
| | | | | | Since the display FPS is currently detected on X11 only (and even there it's known to be wrong on certain setups), it seems like a good idea to make this user-configurable.
* video: add VO framedropping modewm42014-08-151-17/+102
| | | | | | | | | | | | | | | | | | | | | | | | This mostly uses the same idea as with vo_vdpau.c, but much simplified. On X11, it tries to get the display framerate with XF86VM, and limits the frequency of new video frames against it. Note that this is an old extension, and is confirmed not to work correctly with multi-monitor setups. But we're using it because it was already around (it is also used by vo_vdpau). This attempts to predict the next vsync event by using the time of the last frame and the display FPS. Even if that goes completely wrong, the results are still relatively good. On other systems, or if the X11 code doesn't return a display FPS, a framerate of 1000 is assumed. This is infinite for all practical purposes, and means that only frames which are definitely too late are dropped. This probably has worse results, but is still useful. "--framedrop=yes" is basically replaced with "--framedrop=decoder". The old framedropping mode is kept around, and should perhaps be improved. Dropping on the decoder level is still useful if decoding itself is too slow.
* vo: eliminate a redundant variablewm42014-08-151-10/+5
| | | | | Originally, I probably had plans to allow NULL images to handle things like the last frame case, but that idea was dropped later.
* vo: remove unused libavutil includewm42014-08-141-2/+0
|
* vo: fix mingw compilationwm42014-08-141-0/+2
|
* video: fix and simplify video format changes and last frame displaywm42014-08-121-62/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous commit broke these things, and fixing them is separate in this commit in order to reduce the volume of changes. Move the image queue from the VO to the playback core. The image queue is a remnant of the old way how vdpau was implemented, and increasingly became more and more an artifact. In the end, it did only one thing: computing the duration of the current frame. This was done by taking the PTS difference between the current and the future frame. We keep this, but by moving it out of the VO, we don't have to special-case format changes anymore. This simplifies the code a lot. Since we need the queue to compute the duration only, a queue size larger than 2 makes no sense, and we can hardcode that. Also change how the last frame is handled. The last frame is a bit of a problem, because video timing works by showing one frame after another, which makes it a special case. Make the VO provide a function to notify us when the frame is done, instead. The frame duration is used for that. This is not perfect. For example, changing playback speed during the last frame doesn't update the end time. Pausing will not stop the clock that times the last frame. But I don't think this matters for such a corner case.
* video: move display and timing to a separate threadwm42014-08-121-64/+381
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The VO is run inside its own thread. It also does most of video timing. The playloop hands the image data and a realtime timestamp to the VO, and the VO does the rest. In particular, this allows the playloop to do other things, instead of blocking for video redraw. But if anything accesses the VO during video timing, it will block. This also fixes vo_sdl.c event handling; but that is only a side-effect, since reimplementing the broken way would require more effort. Also drop --softsleep. In theory, this option helps if the kernel's sleeping mechanism is too inaccurate for video timing. In practice, I haven't ever encountered a situation where it helps, and it just burns CPU cycles. On the other hand it's probably actively harmful, because it prevents the libavcodec decoder threads from doing real work. Side note: Originally, I intended that multiple frames can be queued to the VO. But this is not done, due to problems with OSD and other certain features. OSD in particular is simply designed in a way that it can be neither timed nor copied, so you do have to render it into the video frame before you can draw the next frame. (Subtitles have no such restriction. sd_lavc was even updated to fix this.) It seems the right solution to queuing multiple VO frames is rendering on VO-backed framebuffers, like vo_vdpau.c does. This requires VO driver support, and is out of scope of this commit. As consequence, the VO has a queue size of 1. The existing video queue is just needed to compute frame duration, and will be moved out in the next commit.
* vdpau: don't upload video images in advancewm42014-07-291-6/+0
| | | | | | | | | | | | With software decoding, images were uploaded to vdpau surfaces as they were queued to the VO. This makes it slightly more complicated (especially later on), and has no advantages - so stop doing it. The only reason why this was done explicitly was due to attempts to keep the code equivalent (instead of risking performance regressions). The original code did this naturally for certain reasons, but now that we can measure that it has no advantages and just requires extra code, we can just drop it.
* vo: remove vo_mouse_movement() wrapperwm42014-07-271<