Commit Graph

4204 Commits

Author SHA1 Message Date
wm4 c9fcd20959 vd_lavc: minor simplification for get_format fallback
The default get_format does exactly do this, so we don't need to
duplicate it.

The only potential problem with this is that the logic doesn't entirely
prevent that the avcodec_default_get_format hw_device_ctx path is
triggered, which would probably work, but has unknown consequences and
interactions. But the way the logic currently works it can't happen,
provided the hwaccel metadata libavcodec provides is correct.
2018-05-24 19:56:34 +02:00
wm4 cc2490ea7e input: add a define for the number of mouse buttons and use it
(Why the fuck are there up to 20 mouse buttons?)
2018-05-24 19:56:34 +02:00
Rostislav Pehlivanov 0b3d1d6faf wayland_common: require wl_compositor of version 3
We already did require it, in order to call set_buffer_scale. This
just makes it error out more gracefully.
2018-05-20 02:48:23 +03:00
Rostislav Pehlivanov 43d575616c wayland_common: fix maximized state
Window size should not change if the window has been maximized or tiled.
2018-05-20 02:48:23 +03:00
Niklas Haas 05b392bc94 vo_gpu: allow higher icc-contrast and improve logging
With the advent of actual HDR devices, my real measured ICC profile has
an "infinite" contrast, since the display is completely off on pure
black inputs. 100k:1 might not be enough, so let's just bump it up to
1m:1 to be safe.

Also, improve the logging in the case that the detected contrast is too
high by default.
2018-05-17 22:56:45 +03:00
Anton Kindestam a645c6b2ec drm_atomic: Fix memory leaks in drm_atomic_create
First fix a memory leak when skipping cursor planes by inverting the
check and putting everything, but the free, in the body.

Then fix a missed drmModeFreePlane by simply copying the fields of the
drmModePlane we are interested in and freeing the drmModePlane struct
early.
2018-05-08 02:24:40 +03:00
wm4 e02c9b9902 build: make encoding mode non-optional
Makes it easier to not break the build by confusing the ifdeffery.
2018-05-03 01:08:44 +03:00
wm4 0ab3184526 encode: get rid of the output packet queue
Until recently, ao_lavc and vo_lavc started encoding whenever the core
happened to send them data. Since audio and video are not initialized at
the same time, and the muxer was not necessarily opened when the first
encoder started to produce data, the resulting packets were put into a
queue. As soon as the muxer was opened, the queue was flushed.

Change this to make the core wait with sending data until all encoders
are initialized. This has the advantage that we don't need to queue up
the packets.
2018-05-03 01:08:44 +03:00
wm4 958053ff56 vo_lavc: explicitly skip redraw and repeated frames
The user won't want to have those in the video (I think). The core can
sporadically issue redraws, which is what you want for actual playback,
but not in encode mode. vo_lavc can explicitly detect those and skip
them. It only requires switching to a more advanced internal VO API.

The comments in vo.h are because vo_lavc draws to one of the images in
order to render OSD. This is OK, but might come as a surprise to whoever
calls draw_frame, so document it. (Current callers are OK with it.)
2018-05-03 01:08:44 +03:00
wm4 f18c4175ad encode: remove old timestamp handling
This effectively makes --ocopyts the default. The --ocopyts option
itself is also removed, because it's redundant.
2018-05-03 01:08:44 +03:00
Anton Kindestam a9c2a8e162 drm_atomic: Disallow selecting cursor planes using the options 2018-05-01 20:48:02 +03:00
Anton Kindestam 02d40eee1b drm_common: Be smarter when deciding on which CRTC and Encoder to use
Inspired by kmscube, first try to pick the Encoder and CRTC already
associated with the selected Connector, if any. Otherwise try to find
the first matching encoder & CRTC like before.

The previous behavior had problems when using atomic
modesetting (crtc_setup_atomic) when we picked an Encoder & CRTC that
was currently being used by the fbcon together with another Encoder.
drmModeSetCrtc was able to "steal" the CRTC in this case, but using
atomic modesetting we do not seem to get this behavior automatically.

This should also improve behavior somewhat when run on a multi screen
setup with regards to deinit and VT switching (still sometimes you end
up with a blank screen where you previously had a cloned display of
your fbcon)
2018-05-01 20:48:02 +03:00
Anton Kindestam 4c6f36611d context_drm_egl: fix some comments and log messages that had not been updated since the plane rename commit 2018-05-01 20:48:02 +03:00
Anton Kindestam e60728a622 drm/atomic: Fix crtc_setup_atomic and crtc_release_atomic
Add some properties which where forgotten in crtc_setup_atomic.

In both change to not use DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_NONBLOCK
flags. This should make it more similar to the drmSetCrtc which it aims to
replace (take effect directly, and blocking call). This also saves us the
trouble of having to set up a poll to wait for pageflip, which would've been
neccesary with DRM_MODE_PAGE_FLIP_EVENT, in both crtc_setup_atomic and
crtc_release_atomic.
2018-05-01 20:48:02 +03:00
LongChair ba3d90d9ed drm/atomic: disable video plane when unused.
This patch will make sure that the video plane is hidden when unused.
When using high resolution modes, typically UHD, and embedding mpv,
having the video plane sitting in the back when you don't play any video
is eating a lot of memory bandwidth for compositing.

That patch makes sure that the video layer is just disabled before and
after playback.
2018-05-01 20:48:02 +03:00
LongChair 1ccc56eff0 drm/atomic: add atomic modesetting.
This commit allows to add atomic modesetting when using the atomic renderer.
This is actually needed when using and osd with a smaller size than screen resolution.

It will also make the drm atomic path more consistent
2018-05-01 20:48:02 +03:00
LongChair ed94f8dc00 drm/atomic: refactor planes names
We are currently using primary / overlay planes drm objects, assuming that primary plane is osd and overlay plane is video.
This commit is doing two things :
  - replace the primary / overlay planes members with osd and video planes member without the assumption
  - Add two more options to determine which one of the primary / overlay is associated to osd / video.
  - It will default osd to overlay and video to primary if unspecified
2018-05-01 20:48:02 +03:00
LongChair 49bc07faea drm/atomic: add connector to atomic context
This patch adds
  - DRM connector object to atomic context.
  - fd property to the drm atomic object as well as a method to read blob type properties.

This allows to ensure that the proper connector is picked up, especially when specifying it
from the commandline, and also allows to make sure we're using the right one when embedding
with interop into an application.
2018-05-01 20:48:02 +03:00
LongChair 9f2970f28a drm/atomic: refactor hwdec_drmprime_drm with native resources
That new API was introduced and allows to have several native resources.
Thisuses that mechanisma for drm resources rather than the deprecated
opengl-cb structs.

This patch therefore add two structs that can be used with the drm atomic interop.
 - mpv_opengl_drm_params : which will hold all the drm handles
 - mpv_opengl_drm_osd_size : which will hold osd layer size

This commit adds a drm-osd-size=WxH parameter to commandline which
allows to define the OSD plane dimension. OSD can be upscaled to
screen resolution when having OSD at video resolution is too heavy.

This is especially useful for UHD modes on embedded devices where
the GPU cannot handle UHD modes at a decent framerate.
2018-05-01 20:48:02 +03:00
Jan Ekström 11f915f5ef vo_gpu/video: disable compute shaders if an FBO format was not available
This is actually more generic and better than just lazily plastering
peak calculation together with dumb mode.
2018-05-01 19:24:53 +03:00
Jan Ekström df65ac95ba vo_gpu/video: add improved logging when a user-specified FBO fails
I don't know if we can just return from this function, so for now
just adding this piece of logging.
2018-05-01 19:24:53 +03:00
Akemi 6bd2bdc745 cocoa: change deprecation warning from opengl-cb to libmpv 2018-04-29 15:03:47 +03:00
Emmanuel Gil Peyrot 76211609e3 wayland_common: update to stable xdg-shell
This removes support for older compositors using the unstable version,
but those will still use Xwayland by default, so not a big loss.
2018-04-29 12:33:12 +03:00
Niklas Haas dc16d85379 gpu/video: make HDR peak computing work without work group count
Define a hard-coded value for gl_NumWorkGroups if it is not available.
This adds an additional requirement of needing a shader recompile for
all window size changes.

This was considered a worthwhile compromise as currently f.ex. d3d11
completely lacked any peak computation - this is a major quality of
life upgrade.
2018-04-29 03:51:19 +03:00
Jan Ekström 59d422f042 gpu/video: improve HDR peak computation feature check logging
Now that the feature depends on multiple features, log all of
their states in the message.
2018-04-29 03:51:19 +03:00
wm4 d6af6efbf9 vd_lavc: enable dr by default
I had this enabled for quite a while and experienced no issues. I'm not
aware of other issues either.
2018-04-29 02:21:32 +03:00
wm4 63441d36ef vf_vapoursynth: correctly signal error on script init failure
Otherwise it will do nothing, waiting on nothing forever.
2018-04-29 02:21:32 +03:00
wm4 eb33556cbf egl_helpers: change minimum framebuffer size to 8 bit per component
This is for working around bugs in certain Android devices. At least one
device fails to sort EGLConfigs by size, so eglChooseConfig() ends up
choosing a config with 5/6/5 bits per r/g/b component. The other
attributes in the affected EGLConfigs did not look like they should
affect the sorting process as specified by the EGL 1.4 standard.

The device was reported as:

Sony Xperia Z3 Tablet Compact
Firmware 6.0.1 build number 23.5.A.1.291
GL_VERSION='OpenGL ES 3.0 V@140.0 AU@ (GIT@I741a3d36ca)'
GL_VENDOR='Qualcomm'
GL_RENDERER='Adreno (TM) 330'

Other Qualcom/Adreno devices have been reported as unaffected by this
(including some with same GL_RENDERER string).

"Fix" this by always requiring at least 8 bit. This means it would fail
on devices which cannot provide this. We're fine with this.

mpv-android/mpv-android#112
2018-04-29 02:21:32 +03:00
wm4 b4173c1fd2 encode: do not clear video PTS on VOCTRL_RESET
This was supposed to be a replacement for encode_lavc_discontinuity()
(so we don't need to store last_video_in_pts in a way which requires
synchronization). Unfortunately, VOCTRL_RESET is also called before
termination, and even though it shouldn't matter as far as the VO API is
concerned, it does. It's because vo_lavc.c buffers a frame to compute
the frame duration.

Drop this code. The consequence is that it appears to encode 2 frames
with the same PTS if multiple files are encoded into one. Before this,
it merely dropped a frame (maybe the first of every subsequent file, not
sure).
2018-04-29 02:21:32 +03:00
wm4 67ce9813d6 egl_helpers: log certain EGL attributes
Might be helpful with broken EGL implementations.
2018-04-29 02:21:32 +03:00
wm4 6c8362ef54 encode: rewrite half of it
The main change is that we wait with opening the muxer ("writing
headers") until we have data from all streams. This fixes race
conditions at init due to broken assumptions in the old code.

This also changes a lot of other stuff. I found and fixed a few API
violations (often things for which better mechanisms were invented, and
the old ones are not valid anymore). I try to get away from the public
mutex and shared fields in encode_lavc_context. For now it's still
needed for some timestamp-related fields, but most are gone. It also
removes some bad code duplication between audio and video paths.
2018-04-29 02:21:32 +03:00
wm4 8135e25600 vo: add vo_reconfig2()
1. I want to get away from mp_image_params (maybe).
2. For encoding mode, it's convenient to get the nominal_fps, which is
   a mp_image field, and not in mp_image_params.
2018-04-29 02:21:32 +03:00
wm4 c6b9288465 video: remove internal stereo_out flag
Also rename stereo3d to stereo_in. The only real change is that the
vo_gpu OSD code now uses the actual stereo 3D mode, instead of the
--video-steroe-mode value. (Why does this vo_gpu code even exist?)
2018-04-29 02:21:32 +03:00
wm4 ce4d227986 client API: add some render API extensions for timing
Attempts to enable the following things:
- let a render API user do "proper" audio-sync video timing itself
- make it possible to not re-render repeated frames if the API user has
  better mechanisms available (e.g. waiting for a DisplayLink cycle
  instead)
- allow the user to delay or skip redraws if it makes sense

Basically this information will be needed by API users who want to be
"clever" about optimizing timing and rendering.
2018-04-29 02:21:32 +03:00
wm4 0be3a94e0b vo_libmpv: support GPU rendered screenshots
Like DR, this needed a lot of preparation, and here's the boring glue
code that finally implements it.
2018-04-29 02:21:32 +03:00
wm4 36565c099d vo_libmpv: adjust redraw handling to new API semantics
In MPV_RENDER_PARAM_ADVANCED_CONTROL mode, a simple update callback does
not necessarily make the API user redraw. So handle it differently.

For one, setting vo->want_redraw already uses the "normal" redraw path,
which will call draw_frame() and set next_frame.

Then there are redraws trigered by mpv_render_context_set_parameter(),
which are on the render thread, and would require a separate mechanism.
I decided this is not really a good idea, since it's not even clear that
setting an arbitrary parameter should redraw. Also this could trigger an
unbounded number of redraws. The user can trigger redraws manually if
really needed, depending on the parameter that's being set. If we really
wanted vo_libmpv to do this, we could add a new flag like need_redraw,
which would be 4 lines of code or so.
2018-04-29 02:21:32 +03:00
wm4 44f00a1f58 vo_libmpv: remove annoying indirections
I think this is a bit more readable this way.
2018-04-29 02:21:32 +03:00
wm4 205b2da160 vo_libmpv: move some update() callbacks out of context lock
update() used to require the lock, but now it doesn't matter. It's
slightly better to do it outside of the lock now, in case the update
callback reschedules before returning, and the user render thread tries
to acquire the still held lock (which would require 2 more context
switches).
2018-04-29 02:21:32 +03:00
wm4 1c550326ce vo_libmpv: move up update() function
Avoids a forward declaration.
2018-04-29 02:21:32 +03:00
wm4 9825bbb8cf vo_libmpv: add support for DR
With all the preparation work done, this only has to do the annoying
dance of passing it through all the damn layers.
2018-04-29 02:21:32 +03:00
wm4 67689ff6b4 client API: preparations for allowing render API to use DR etc.
DR (letting the decoder allocate texture memory) requires running the
allocation on the render thread. This is rather hard with the render
API, because the user controls this thread and when it's entered. It was
not possible until now.

This commit adds a bunch of infrastructure to make this possible. We add
a new optional mode (MPV_RENDER_PARAM_ADVANCED_CONTROL) which basically
lets the user's render thread and libmpv agree how this should be done.

Misuse would lead to deadlocks. To make this less likely, strictly
document thread safety/locking issues. In particular, document which
libmpv functions can be called without issues. (The rest has to be
assumed unsafe.)

The worst issue is destruction of the render context while video is
still active. To avoid certain unintended recursive locks (i.e.
deadlocks, unless we'd make the locks recursive), make the update
callback lock separate. Make "killing" the video chain asynchronous, so
we can do extra work while video is being destroyed.

Because losing wakeups is a big deal, setting the update callback now
triggers a wakeup. (It would have been better if the wakeup callback
were a parameter to mpv_render_context_create(), but too late.)

This commit does not add DR yet; the following commit does this.
2018-04-29 02:21:32 +03:00
wm4 76844c9c51 vo: move DR helper code to a separate source file
So it can be reused by vo_libmpv.c, which needs to use it in a slightly
different way.
2018-04-29 02:21:32 +03:00
Jan Ekström 65f0825315 mp_image: fixup a simple 10L in ref_buffer
We didn't want to set the pointer to zero, but the value that the
pointer was pointing towards.
2018-04-21 01:38:21 +03:00
wm4 6435d9ae7f vo_gpu: move some extra code for screenshot to video.c
This also happens to fix some UB on the error path (target being
declared after the first "goto done;").
2018-04-20 17:05:53 +02:00
wm4 78227706ad encode: simplify colorspace setting
This was also refactored at some point, and is now unnecessarily
roundabout.
2018-04-20 12:37:34 +02:00
wm4 20a1f250c6 encode: cosmetics
Mostly whitespace changes; some semantic preserving transformations.
2018-04-20 12:37:34 +02:00
wm4 b3baff399e vo_lavc: remove pointless uint32_t type for int values
params->w/h are int, and the further use of these variables are int. The
uint32_t is probably some refactoring artifact.
2018-04-20 12:37:34 +02:00
wm4 ff24285eb1 video: pass through container fps to filters
This means vf_vapoursynth doesn't need a hack to work around the filter
code, and libavfilter filters now actually get the frame_rate field on
input pads set.

The libavfilter doxygen says the frame_rate field is only to be set if
the frame rate is known to be constant, and uses the word "must" (which
probably means they really mean it?) - but ffmpeg.c sets the field to
mere guesses anyway, and it looks like this normally won't lead to
problems.
2018-04-19 23:22:48 +02:00
wm4 10584159df w32_common: avoid recursive dispatch queue calls
I suppose this doesn't matter in practice, i.e. even if calls relayed
over the dispatch queue will cause WndProc to be invoked, WndProc will
never run for a longer time.

Preparation for removing recursion support from the dispatch queue code.
2018-04-18 01:17:41 +03:00
Aman Gupta ed7bc3a5f3 hwdec_ios: fix crash after mapper_init failure 2018-04-17 01:06:29 +03:00