summaryrefslogtreecommitdiffstats
path: root/video
Commit message (Collapse)AuthorAgeFilesLines
* video: report negative subtitle/OSD margins if necessarywm42020-03-261-4/+4
| | | | | | | | | | | | | | Until now, it used only coordinates clipped to the screen for this, which meant no negative margins were ever reported to libass. This broke proper rendering of explicitly positioned ASS events (libass simply could not know the real video size in this case.) Fix this by reporting margins even if they're negative. This makes it apparently work correctly with vo_gpu at least. Note that I'm not really sure if anything in the rendering chain required non-negative margins. If so, and that code implicitly assumed it, I suppose crashes and such are possible.
* vd_lavc: make hwdec fallback message more consistentwm42020-03-241-4/+1
| | | | | | | | | | | The "rule" is that a fallback warning message should be shown only shown if software decoding was used before, or in other words when either hwdec was enabled before, but the stream suddenly falls back, or it was attempted to enable it at runtime, and it didn't work. The message wasn't printed the first time in the latter case, because hwdec_notified was not set in forced software decoding mode. Fix it with this commit. Fortunately, the logic becomes simpler.
* wayland: simplify mouse wheel direction calculationJan Ekström2020-03-191-3/+2
| | | | | Based on an idea by sfan5. Remove abs usage, and instead just check for negative value, and set variable to either +/-1.
* options: change option macros and all option declarationswm42020-03-1837-434/+440
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change all OPT_* macros such that they don't define the entire m_option initializer, and instead expand only to a part of it, which sets certain fields. This requires changing almost every option declaration, because they all use these macros. A declaration now always starts with {"name", ... followed by designated initializers only (possibly wrapped in macros). The OPT_* macros now initialize the .offset and .type fields only, sometimes also .priv and others. I think this change makes the option macros less tricky. The old code had to stuff everything into macro arguments (and attempted to allow setting arbitrary fields by letting the user pass designated initializers in the vararg parts). Some of this was made messy due to C99 and C11 not allowing 0-sized varargs with ',' removal. It's also possible that this change is pointless, other than cosmetic preferences. Not too happy about some things. For example, the OPT_CHOICE() indentation I applied looks a bit ugly. Much of this change was done with regex search&replace, but some places required manual editing. In particular, code in "obscure" areas (which I didn't include in compilation) might be broken now. In wayland_common.c the author of some option declarations confused the flags parameter with the default value (though the default value was also properly set below). I fixed this with this change.
* wayland: notify vo if an output changesDudemanguy2020-03-151-0/+2
| | | | | | | | Previously, the vo wasn't always informed if something about the output changed during playback. For instance, changing a display's refresh rate during playback would not update mpv's display fps. Fix this by simply using VO_EVENT_WIN_STATE in output_handle_done which executes whenever something about the output is changed.
* vo_gpu: warn if correct-downscaling is ignoredAvi Halachmi (:avih)2020-03-141-0/+11
| | | | And document that it's ignored with bilinear scaler.
* cocoa-cb: support maximize/minimize on startupder richter2020-03-141-1/+9
| | | | | | | Allow the --window-maximized and --window-minimized flags to actually work when the player is started. since macOS doesn't like using both at the same time the minimized state takes precedence over the maximized state.
* options: change how option range min/max is handledwm42020-03-133-4/+6
| | | | | | | | | | | | | | | | | Before this commit, option declarations used M_OPT_MIN/M_OPT_MAX (and some other identifiers based on these) to signal whether an option had min/max values. Remove these flags, and make it use a range implicitly on the condition if min<max is true. This requires care in all cases when only M_OPT_MIN or M_OPT_MAX were set (instead of both). Generally, the commit replaces all these instances with using DBL_MAX/DBL_MIN for the "unset" part of the range. This also happens to fix some cases where you could pass over-large values to integer options, which were silently truncated, but now cause an error. This commit has some higher potential for regressions.
* options: remove intpair option typewm42020-03-131-1/+2
| | | | | | | | | | | This was mostly unused, and has certain problems. Just get rid of it. It was still used in CDDA (--cdda-span) and a debug option for OpenGL (--opengl-check-pattern). Replace both of these with 2 options, where each sets the start/end values of the former span. Both were undocumented somehow (normally we require all options to be documented), so I'm not caring about compatibility, and not bothering to add it to the API changelog.
* video/out/android_common: use jni helpersAman Gupta2020-03-121-10/+11
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* vo_gpu: generally allow non-storable FBOsNiklas Haas2020-03-082-3/+12
| | | | | | | | | | | | | We have this cap now thanks to e2976e662, but we don't actually make sure our FBOs are storable before we blindly attempt using them with compute shaders. There's no more need to unconditionally set `storage_dst = true` as long as we make sure to include an extra condition on the `fbo_format` selection to prevent users from accidentally enabling compute-shader-only features with non-storable FBOs, alongside some other miscellaneous adjustments to eliminate instances of "assumed storability" from vo_gpu.
* vo_gpu: avoid error spam when ra_fbo fmt is non-storableNiklas Haas2020-03-081-0/+2
| | | | | | | | | | | This simply makes the "is the destination FBO format bad?" check a tiny bit less awful, by making sure we prefer storable FBO formats over non-storable FBO formats. I'd love to make this also conditional on whether or not we actually *need* a storable FBO format, but that logic is decided later, in `pass_draw_to_screen`, and I don't want to replicate the logic. Fixes #7017.
* wayland: always use the fs-screen id for fsDudemanguy2020-03-081-33/+31
| | | | | | | | | Previously if the --fs-screen option was set, it would only use the screen if mpv was launched with --fs and only on startup. During runtime, the toggle would ignore it. Rework the logic here so that mpv's fullscreen always uses --fs-screen if it is set. Additionally, cleanup some unneeded cruft in vo_wayland_reconfig and make find_output more useful.
* drm_prime: double free bugSven Kroeger2020-03-053-15/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes a bug where handle for a framebuffer gets double freed. It seems to happen that the same prime fd gets two framebuffers. As the prime fd is the same the resulting prime handle is also the same. This means one handle but 2 framebuffers and can lead to the following chain: 1. The first framebuffer gets deleted the handle gets also freed via the ioctl. 2. In startup phase not all 4 dumb buffers for overlay drawing are set up. It can happen that the last dumb buffer gets the handle we freed above. 3. The second framebuffer gets freed and the handle will be freed again resulting that the 4's dumb buffer handle is not backed by a buffer. 4. Drm prime continues to assign handles to its prime fds an will lead to have this handle which was just freed to reassign again but to an prime buffer. 5.Now the overlay should be drawn into dumb buffer 4 which still has the same handle but is backed by the wrong buffer. This leads to two different behaviors: - MPV crashes as the drm prime buffers size als calculated by the decoder output format. The overlay output format differs and it takes more space. SO the size check in kernel fails. - MPV is continuing play. This happens when the decoders allocates a bigger buffer than needed for the overlay. For example overlay is Full HD and decoder output is 4k. This leads to the behavior das the overlay wil be drawn into the wrong buffer as its a drm prime buffer and results in a flicker every fourth step.
* drm_prime: forward modifiers from FFMPEG to drm APISven Kroeger2020-03-031-2/+9
| | | | | | * Change drmModeAddFB2 to drmModeAddFB2WithModifiers * Set modifiers flag in API call * fetch and set modifiers according to kernel constraints
* OpenGL: Also detect softpipe as a software driverlinkmauve2020-02-251-0/+1
| | | Because it is.
* cocoa-cb: fix crash with some japanese charactersder richter2020-02-221-1/+2
| | | | | | | | | | | | the actual character that made mpv crash is IDEOGRAPHIC COMMA (U+3001, UTF-8: E3 80 81, 、) and that only in some specific circumstances that could be reliably reproduced on my end. using an NSString instead of the Swift String actually fixes that issues even though they should technically do the exact same thing. i tested all the other String initialisers, but they all had had the same issue. this is kinda only a workaround till i can find a different way of handling it.
* mac, cocoa: fix UI updates on none main queue threadsder richter2020-02-221-2/+4
| | | | | | injecting the Apple Main Thread Checker via DYLD_INSERT_LIBRARIES=libMainThreadChecker.dylib identified several problems that needed fixing.
* cocoa-cb: remove unnecessary semicolonsder richter2020-02-223-16/+16
|
* x11: switch back to StaticGravitywm42020-02-221-4/+1
| | | | | | | | | | | | | | | | | This was changed 6 years ago (444e583b6) and seemed to work fine. But it does seem to cause issues with IceWM sometimes, while with StaticGravity the problem is gone. Comparing both gravity values, reading the confused source code comment, and reading the referenced commit message, I can't determine what it even does, I just remove it. Reproduction: - start mpv in windowed mode, with 2 videos of different size - switch to second video - switch window with alt+tab - switch back to mpv with alt+tab - window moves to X=0 There's probably a better way to fix this. Please send a patch.
* video: drop NV24 aliaswm42020-02-182-4/+0
| | | | | | | Caused build failures with still supported FFmpeg versions. It's unreferenced, so it's not needed. Fixes: #7471
* Remove remains of Libav compatibilitywm42020-02-166-42/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Libav seems rather dead: no release for 2 years, no new git commits in master for almost a year (with one exception ~6 months ago). From what I can tell, some developers resigned themselves to the horrifying idea to post patches to ffmpeg-devel instead, while the rest of the developers went on to greener pastures. Libav was a better project than FFmpeg. Unfortunately, FFmpeg won, because it managed to keep the name and website. Libav was pushed more and more into obscurity: while there was initially a big push for Libav, FFmpeg just remained "in place" and visible for most people. FFmpeg was slowly draining all manpower and energy from Libav. A big part of this was that FFmpeg stole code from Libav (regular merges of the entire Libav git tree), making it some sort of Frankenstein mirror of Libav, think decaying zombie with additional legs ("features") nailed to it. "Stealing" surely is the wrong word; I'm just aping the language that some of the FFmpeg members used to use. All that is in the past now, I'm probably the only person left who is annoyed by this, and with this commit I'm putting this decade long problem finally to an end. I just thought I'd express my annoyance about this fucking shitshow one last time. The most intrusive change in this commit is the resample filter, which originally used libavresample. Since the FFmpeg developer refused to enable libavresample by default for drama reasons, and the API was slightly different, so the filter used some big preprocessor mess to make it compatible to libswresample. All that falls away now. The simplification to the build system is also significant.
* wayland: make resizing betterDudemanguy2020-02-132-6/+32
| | | | | | | | | Resizing the window while preserving the aspect ratio actually kind of sucked. The window size could make big dramatic changes which was pretty unintuitive with respect to where the mouse was actually located. Instead, let's just do some math to ensure that the window size is always contained inside the width/height reported by handle_toplevel_config while preserving the aspect ratio. Fixes #7426.
* wayland: fix autofit and rotating issuesDudemanguy2020-02-131-5/+7
| | | | | | Fixes #7441. Just set screenrc to be equal to current_output's geometry. Also remove some pointless/extra variables and print a warning/fallback to screen 0 if a bad id is passed to --fs-screen.
* zimg: fix previous odd sizes commitwm42020-02-131-4/+2
| | | | | | | | | Obviously, we don't want to lose fractions, and the zimg active_region fields in fact have the type double. The integer division was wrong. Also, always set active_region.width/height. It appears zimg behavior does not change if they're set to the normal integer values, so the extra check to not set them in this case was worthless.
* sws_utils: use zimg by default if availablewm42020-02-121-0/+1
| | | | | This seems stable enough to use. Change the default, and remove it from the sw-fast profile.
* zimg: correct output to odd (chroma un-aligned) sizeswm42020-02-121-10/+18
| | | | | | | | | | As suggested by the zimg author: active_region is not supported on outputs (and the API returns an error), so instead scale to the "full" surface, but adjust the source rectangle such that the cropped output image happens to cover the correct region. Does this even work? Since Balmer Peak doesn't work, I can't really say, but it seems to look correct.
* zimg: fix typos in a commentwm42020-02-121-3/+2
| | | | | | Also remove the "o" case, which was never implemented (probably was an idea to output alpha formats, now obsoleted by zimg's full alpha support).
* vo_drm, wo_wlshm: mention that it's software scalingwm42020-02-112-2/+2
| | | | (But does anyone even read --vo=help output?)
* vo_x11: don't call X11 "crap"wm42020-02-111-1/+1
| | | | | | X11 is in fact beautiful and superior to Wayland. Instead, just state what the problem is in most cases: software scaling. (We have accelerated X11 rendering in vo_gpu and others.)
* zimg: add pal8 unpackerwm42020-02-101-0/+39
| | | | Some pngs are paletted, so this is vaguely interesting.
* img_format: add alias for ffmpeg pal8 formatwm42020-02-102-0/+4
| | | | For the next commit.
* zimg: rename zplanes fieldwm42020-02-101-4/+4
| | | | | | | | | This was a confusing name, because 1. there's also a z_planes[] field, and 2. it was not specific to zimg indexes. Possibly there used to be an idea involved about supporting alpha to non-alpha formats by discarding the alpha plane, but zimg does this now (and zimg will correctly blend the alpha component too).
* zimg: support gray/alpha conversionwm42020-02-101-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | The special thing about this format is 1. mpv assigns the component ID 4 to alpha, and component IDs 2 and 3 are not present, which causes some messy details. 2. zimg always wants the alpha plane as plane 3, and plane 1 and 2 are not present, while FFmpeg/mpv put the alpha plane as plane 1. In theory, 2. could be avoided, since FFmpeg actually doesn't have a any 2 plane formats (alpha is either packed, or plane 3). But having to skip "empty" planes would break expectations. zplanes is not equivalent to the mpv plane count (actually it was always used this way), while zimg does not really have a plane count, but does, in this case, only use plane 0 and 3, while 2 and 3 are unused and unset. z_planes[] (not zplanes) is now always valid for all 4 array entries (because it uses zimg indexes), but a -1 entry means it's an unused plane. I wonder if these conventions taken by mpv/zimg are not just causing extra work. Maybe component IDs should just be indexes by the "natural" order (e.g. R-G-B-A, Y-U-V-A, Y-A), and alpha should be represented as a field that specifies the component ID for it, or just strictly assume that 2/4 component formats always use the last component for alpha.
* zimg: fix some confusion about plane permutationwm42020-02-101-4/+9
| | | | | | | | | | | | | We reorder the planes between mpv and zimg conventions. It turns out the code still confused when which convention was used. So the way it actually works is that the _only_ place where zimg order is used is the zimg_image_buffer.plane[] array. plane_aligned[] and zmask[] were accessed incorrectly, although I guess it rarely had a reason to fail (plane reordering is mostly for RGB, which has planes of all the same size). Adjust some comments accordingly too.
* img_format: add gray/alpha planar formatswm42020-02-102-2/+74
| | | | | | | | | | | | The zimg wrapper "needs" these formats as intermediary when repacking the normal gray/alpha packed format. The packed format is used by the png decoder and encoder, and is thus interesting. Unfortunately, mpv-only formats are a mess right now, because all the existing code is focused around using the FFmpeg metadata for pixel formats. This should be improved, but not now, so make the mess worse. This commit doesn't add support for it to the zimg wrapper yet.
* zimg: add alpha supportwm42020-02-091-18/+63
| | | | | | | | | | | libzimg recently added direct alpha support and new API for it. (The API change is rather minimal, and it turns out we can easily support old and new zimg versions.) This does not support _all_ alpha formats. For example, gray + alpha is not supported yet, because my stupid design in the zimg wrapper would require a planar gray + alpha format, while ffmpeg provides only a packed one.
* vo: fix typo in commentwm42020-02-091-1/+1
|
* vf_format: add w, h parameterswm42020-02-091-3/+11
| | | | Yes, this thing became vf_scale through the back door.
* cocoa-cb: fix auto-selection of title bar style with older SDKsder richter2020-02-081-0/+4
| | | | | returning a nil value only works when build with a +10.14 SDK otherwise we need to fallback to the old mechanism.
* cocoa-cb: simplify cursor hiding and make it less greedyder richter2020-02-083-12/+7
| | | | | | | | | | | | | | | | | | for reasons unknown to me the NSCursor (un)hide functions can be completely unreliable and the cursor can have an unknown state. this only happens on some system and wasn't able to reproduce this. it's probably some dumb race condition that might be possible to work around, though because of the lack of reproducibility on my end it's hard to test. i decided to rework the cursor hiding code yet again and make it a lot less greedy. the cursor will now always unhide when moved and there will never be a situation again the cursor can't be unhidden again. on the other hand there might be edge cases now where the cursor won't hide immediately and you have to move it slightly to make it disappear again. this should be an acceptable tradeoff. Fixes #6886
* wayland: adjust vo_wayland_wait_frame logicDudemanguy2020-02-071-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Wayland uses vo_wayland_wait_frame plus some polling with a timeout for blocking on vsync. Here are a couple of changes that seem to be improvements. First, the poll time is always rounded up instead of truncated. When rendering frames longer than the standard 16.666 ms timeout, it seems that truncating the poll time slightly early may cause some vsync jitter spikes. Waiting longer, even if it's too long, appears to behave better. The second change is to use wl_display_roundtrip instead of wl_display_dispatch_pending. wl_display_dispatch_pending dispatches all events immediately. This is good to avoid blocking, but it's not guaranteed to wait long enough for all events to be processed on the display fd. The preceding wl_display_read_events routine ensures that all events on the display fd are queued. We just need a semi-blocking routine to dispatch them for the most reliable vsync. wl_display_roundtrip will dispatch any events for us, but also wait for a reply from the display server. This makes it ideal for this role. If the compositor doesn't reply to the client something else is probably horribly broken and wrong anyway. It's also not a permanently blocking call like wl_display_dispatch. If there's no frame callback (i.e. the window is hidden), then it does not dispatch any events and returns immediately.
* wayland: toplevel config fixesDudemanguy2020-02-062-3/+18
| | | | | | | | | | | | | | | | | | | | | | | There were a couple of erroneous things in the handle_toplevel_config function. Firstly, looping through the different states was not handled correctly. Launching a window as maximized (can happen in sway for example) was always stuck on true and would never be set to false. Fix this by always checking if XDG_TOPLEVEL_STATE_MAXIMIZED is found or not. Also do a similar thing for the fullscreen state. Additionally, there were some issues with resizing windows and window-scale going back to old sizes. The root of this problem is that the width and height arguments of handle_toplevel_config aren't actually guarenteed to be the actual width and height of the surface. There are times when mpv will set the surface size on its own (like with window-scale) which will be unknown to the toplevel listener. To complicate matters, there are times when we do want to use the width and height arguments (like when resizing with the mouse). Fix this by checking if the width and height arguments reported by handle_toplevel_config changed from the previous call of the function. If the value is different, then we go ahead and use them when setting mpv's geometry. If not, then we just ignore it.
* drm_atomic: do not set immutable propertiesAnton Kindestam2020-02-021-1/+6
| | | | | | | | | | | | | | | On some platforms the ZPOS property might exist, but be immutable. This is at least the case on Intel Sandy Bridge since Linux kernel 5.5.0. Trying to set an immutable property will cause. drmModeAtomicCommit to fail with -EINVAL. On other platforms we might want to set ZPOS to tweak the layering of planes. To reconcile these two, simply have drm_object_set_property check if a property is immutable before attempting to add it to the atomic commit, instead returning an error code (which is, as previously, ignored in the case of ZPOS as we don't strictly need it)
* wayland: remove wayland-frame-wait-offset optiondudemanguy2020-01-314-8/+5
| | | | | | | | | | | | | | | | | This originally existed as a hack for weston. In certain scenarios, a frame taking too long to render would cause vo_wayland_wait_frame to timeout which would result in a ton of dropped frames. The naive solution was to just to add a slight delay to the time value. If a frame took too long, it would likely to fall under the timeout value and all was well. This was exposed to the user since the default delay (1000) was completely arbitrary. However with presentation time, this doesn't appear to be neccesary. Fresh frames that take longer than the display's refresh rate (16.666 ms in most cases) behave well in Weston. In the other two main compositors without presentation time (GNOME and Plasma), they also do not experience any ill effects. It's better not to overcomplicate things, so this "feature" can be removed now.
* w32_common: support minimized and maximized propertiesJames Ross-Gowan2020-01-261-5/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for setting window-minimized and window-maximized in Windows. The minimized and maximized state can be set independently. When the window is minimized, the value of window-maximized will determine whether the window is restored to the maximized state or not. Changing state is done with ShowWindow(), which has commands that change the window state and activate it (eg. SW_RESTORE) and commands that change the window state without activating it (eg. SW_SHOWNOACTIVATE.) It would be nice if we could use commands that don't activate the window, so scripts could change the window state in the backrgound without bringing it to the foreground, but there are some problems with that. There is no command to maximize a window without activating it, so SW_MAXIMIZE is used instead. Also, restoring a window from minimize without activating it seems buggy. On my Windows 10 1909 PC, it always moves the window to the back of the z-order. SW_RESTORE is used instead of SW_SHOWNOACTIVATE because of this. This also changes the way the window is initially shown. Previously, the window was made visible as a consequence of the SWP_SHOWWINDOW flag in the first call to SetWindowPos. In order to set the initial minimized or maximized state of the window, the window is shown with the