summaryrefslogtreecommitdiffstats
path: root/video
Commit message (Collapse)AuthorAgeFilesLines
* video: refactor GPU memcpy usagewm42015-09-255-82/+86
| | | | | | | | | | | | | | | | | Make the GPU memcpy from the dxva2 code generally useful to other parts of the player. We need to check at configure time whether SSE intrinsics work at all. (At least in this form, they won't work on clang, for example. It also won't work on non-x86.) Introduce a mp_image_copy_gpu(), and make the dxva2 code use it. Do some awkward stuff to share the existing code used by mp_image_copy(). I'm hoping that FFmpeg will sooner or later provide a function like this, so we can remove most of this again. (There is a patch, bit it's stuck in limbo since forever.) All this is used by the following commit.
* vd_lavc: Fix recovery from vdpau preemptionPhilip Langdale2015-09-251-3/+3
| | | | | Flushing buffers, and thereby triggering decoder reinitialisation needs to happen before attempting, and failing, to decode.
* vo_rpi, wayland: fix buildwm42015-09-251-2/+2
| | | | | | Broken by commit d47dff3f. If something is going to include EGL.h, header_fixes.h has to know. This definitely affected vo_rpi, and probably affects wayland builds (with x11egl didabled) as well.
* vo_opengl: vaapi: undo vaAcquireBufferHandle() correctly on errorwm42015-09-251-2/+4
| | | | | | | Checking and resetting the VAImage.buf field is non-sense, even if it happened to work out in the normal case. buf is actually freed when vaDestroyImage() is called (not quite intuitive), and we need an extra field to know whether vaReleaseBufferHandle() has to be called.
* vaapi: cosmetics, minor fixeswm42015-09-251-3/+3
| | | | | | | | | | Printing "Using vaDeriveImage()" every frame is too verbose, so raise the log level. mp_image strides are in int and not unsigned int; fix this. It's not like it actually matters, though. Finish a comment.
* vo_opengl: vaapi: handle YV12 correctlywm42015-09-251-0/+3
| | | | This specific FourCC has its planes swapped compared to FFmpeg yuv420p.
* vo_opengl: vaapi: document DRM fourcc upstream defineswm42015-09-251-3/+4
| | | | | | | | | | | Add the upstream symbolic names as comments. Normally, these should be defined in libdrm's drm_fourcc.h header. But DRM_FORMAT_R8 and DRM_FORMAT_GR88 are not defined anywhere, except in the kernel userland headers of Linux 4.3 (!). We don't want mpv to depend on bleeding-edge Linux kernel headers, so this will have to do. Also, just for completeness, add fourccs for the 3 and 4 channel formats. I didn't manage to test them, though.
* vo_opengl: vaapi: use dummy image to determine plane layoutwm42015-09-251-9/+8
| | | | | | | Reduces the amount of hardcoded assumptions about the layout drastically. (Now adding yuv420 support would be just adjusting an if, if you ignore the other problems, such as determining the hw format at all early enough.)
* vo_opengl: vaapi: remove unnecessary loopwm42015-09-251-2/+1
| | | | Not sure what I was thinking.
* vo_opengl: vaapi: fix cleanupwm42015-09-251-0/+2
| | | | | | | Don't call eglDestroyImageKHR() on the same ID possibly more than once. Clear the image reference on termination, or we would leak up to 1 image per VO recreation.
* vo_opengl: support new VAAPI EGL interopwm42015-09-252-0/+251
| | | | | | | | | | | | | | | | | | | | | | | Should work much better than the old GLX interop code. Requires Mesa 11, and explicitly selecting the X11 EGL backend with: --vo=opengl:backend=x11egl Should it turn out that the new interop works well, we will try to autodetect EGL by default. This code still uses some bad assumptions, like expecting surfaces to be in NV12. (This is probably ok, because virtually all HW will use this format. But we should at least check this on init or so, instead of failing to render an image if our assumption doesn't hold up.) This repo was a lot of help: https://github.com/gbeauchesne/ffvademo The kodi code was also helpful (the magic FourCC it uses for EGL_LINUX_DRM_FOURCC_EXT are nowhere documented, and EGL_IMAGE_INTERNAL_FORMAT_EXT as used in ffvademo does not actually exist). (This is the 3rd VAAPI GL interop that was implemented in this player.)
* vo_opengl: add mechanism to retrieve Display from EGL contextwm42015-09-251-0/+18
| | | | | | | | | | The VAAPI EGL interop code will need access to the X11 Display. While GLX could return it from the current GLX context, EGL has no such mechanism. (At least no standard one supported by all implementations.) So mpv makes up such a mechanism. For internal purposes, this is very rather awkward solution, but it's needed for libmpv anyway.
* vo_opengl: load certain EGL extensions needed for VAAPI EGL interopwm42015-09-254-1/+50
| | | | | | | | | These extensions use a bunch of EGL types, so we need to include the EGL headers in common.h to use our GL function loader with this. In the future, we should probably require presence of the EGL headers to reduce the hacks. This might be not so simple at least with OSX, so for now this has to do.
* vo_opengl: actually set hardware decoder mapped texture formatwm42015-09-244-3/+6
| | | | | | | | | | | Surfaces used by hardware decoding formats can be mapped exactly like a specific software pixel format, e.g. RGBA or NV12. p->image_params is supposed to be set to this format, but it wasn't. (How did this ever work?) Also, setting params->imgfmt in the hwdec interop drivers is pointless and redundant. (Change them to asserts, because why not.)
* client API: rename GL_MP_D3D_interfaceswm42015-09-243-4/+12
| | | | | | | | | | | | | This is a pseudo-OpenGL extension for letting libmpv query native windowing system handles from the API user. (It uses the OpenGL extension mechanism because I'm lazy. In theory it would be nicer to let the user pass them with mpv_opengl_cb_init_gl(), but this would require a more intrusive API change to extend its argument list.) The naming of the extension and associated function was unnecessarily Windows specific (using "D3D"), even though it would work just fine for other platforms. So deprecate the old names and introduce new ones. The old ones still work.
* vo_opengl: remove sharpen scalers, add sharpen sub-optionwm42015-09-234-46/+34
| | | | | | | | | | | | This turns the old scalers (inherited from MPlayer) into a pre- processing step (after color conversion and before scaling). The code for the "sharpen5" scaler is reused for this. The main reason MPlayer implemented this as scalers was perhaps because FBOs were too expensive, and making it a scaler allowed to implement this in 1 pass. But unsharp masking is not really a scaler, and I would guess the result is more like combining bilinear scaling and unsharp masking.
* vo_opengl: move deband_opts declaration to where it's usedwm42015-09-232-8/+8
| | | | At least one thing the current option code can do right.
* vo_opengl: remove unsued chroma_location fieldwm42015-09-232-2/+0
| | | | | This was redundant to forcing the value with vf_format, so the vo_opengl sub-option was removed. This field is just a leftover.
* vo_opengl: move shader file caching to video.cwm42015-09-234-50/+44
| | | | | | It's just about loading and cachign small files, not does not necessarily have anything to do with shaders. Move it to video.c where it's used.
* vd_lavc: do not abort hardware decoding on errorswm42015-09-231-8/+7
| | | | | | | | | | Usually, libavcodec ignores errors reported by the hardware decoding API, so it's not like we can actually escape if the hardware is somehow acting up. For normal fallback purposes, or if parts of the hw decoding API which we actually check fails, we do this by setting and checking the hwdec_failed flag anyway.
* vf_vavpp: allocate output surfaces with the same size as inputwm42015-09-233-1/+15
| | | | | | | | | | | | | This can happen if the hw decoder allocates padded surfaces (e.g. mod16), but the VPP output surface was allocated with the exact size. Apparently VPP requires matching input and output sizes, or it will add artifacts. In this case, it added mirrored pixels to the bottom few pixels. Note that the previous commit should have fixed this. But it didn't work, while this commit does. Fixes #2320.
* va_vavpp: set input/output processing regionwm42015-09-231-2/+2
| | | | | | | | If not set, VPP will use the whole surface. This is a problem if the surfaces are padded, and especially if the surfaces are padded by different amounts. This is an attempt to fix #2320, but it appears to do nothing at all.
* vd_lavc: minor cleanup to hwdec fallback codewm42015-09-231-15/+8
| | | | | | | | | The comment was largely outdated, and described the old situation when we used a "violent" fallback by making get_buffer2 fail completely. Also, for the case when the hw decoder initialization succeeded (in get_format), but get_buffer2 for some reason requests something unexpected, we also can fallback more gracefully and in the same way.
* win32: allow multiple windows at the same timewm42015-09-221-6/+1
| | | | | | | | | | | | | | | | Window classes are process-wide (or at least DLL-wide), so you can't have 2 classes with the same name. Our code attempted to do this when for example 2 libmpv instances were created within the same process. This failed, because RegisterWindowEx() fails if the class already exists. Fix this by ignoring RegisterWindowEx() errors. If the class can really not be registered, we will fail on CreateWindowEx() instead. Of course we also can't unregister the class, as another thread might be using it. Windows will free the class automatically if the DLL is unloaded or the process terminates. Fixes #2319 (hopefully).
* vf_yadif: add hack for Libav compatibilitywm42015-09-201-3/+12
| | | | | | Libav accepts slightly different options compared to FFmpeg. Sigh... This was "broken" in 25755f5f. Fixes #2335.
* vf_vdpaurb: query_format is still requiredPhilip Langdale2015-09-181-0/+6
| | | | | | | I took this out because I thought the filter chain would auto-negotiate using nv12 without the explicit hint, and it does in the basic case with no intermediate filter, but once you start adding filters, it can end up negotiating a different format and then failing.
* vf_vdpaurb: Pass through non-hardware-decoded contentPhilip Langdale2015-09-151-9/+8
| | | | | | | | | | Today, vdpaurb will fail if it's used with non-hardware-decoded content. This created work for the user as they have to explicitly add or not add it, depending on the content. As an improvement, we can make vdpaurb pass through any frames that aren't hardware decoded, so that it can always be present in the filter chain, if desired.
* video/filter: remove some vf_lavfi wrapperswm42015-09-115-304/+0
| | | | | | | | | | | | | | | | I see no point in keeping these around. Keeping wrappers for some select libavfilter filters just because MPlayer had these filters is not a good reason. Ultimately, all real filtering work should go to libavfilter, and users should get used to using vf_lavfi directly. We might even not require the awful double-nested syntax for using libavfilter one day. vf_rotate, vf_yadif, vf_stereo3d are kept because mpv uses them internally. (They all extend the lavfi filters or change their defaults.) vf_mirror is kept for symmetry with vf_flip. vf_gradfun and vf_pullup are probably semi-popular, so I'll remove them not yet - only after some more discussion.
* vf_lavfi: cosmetics: fix coding stylewm42015-09-111-11/+11
|
* vf: vf_stereo3d depends on libavfilterwm42015-09-111-1/+1
|
* video: make --field-dominance set interlaced flagKevin Mitchell2015-09-101-4/+6
| | | | fixes #2289
* vo_rpi: fix compilationwm42015-09-111-2/+2
| | | | The recent OpenGL refactor commits forgot to update this file.
* video: do not use deprecated libavutil pixdesc fieldswm42015-09-101-5/+15
| | | | | | These were normalized and are saner now. We want to use the new fields, and also get rid of the deprecation warnings, so use them. There's no release yet which uses these, so some ifdeffery is unfortunately needed.
* vo_opengl: fix shader compilation with debanding and OSX hwdecwm42015-09-103-8/+10
| | | | | | 2 things are being stupid here: Apple for requiring rectangle textures with their IOSurface interop for no reason, and OpenGL having a different sampler type for rectangle textures.
* vo_opengl: move sampler type mapping to a functionwm42015-09-102-7/+14
|
* vo_opengl: fix deband sub-option handlingwm42015-09-091-1/+6
| | | | This all has to be done manually.
* vo_opengl: implement debanding (and remove source-shader)Niklas Haas2015-09-096-84/+195
| | | | | | | | | | The removal of source-shader is a side effect, since this effectively replaces it - and the video-reading code has been significantly restructured to make more sense and be more readable. This means users no longer have to constantly download and maintain a separate deband.glsl installation alongside mpv, which was the only real use case for source-shader that we found either way.
* vo_opengl: move self-contained shader routines to a separate fileNiklas Haas2015-09-094-348/+424
| | | | | | | | | | | This is mostly to cut down somewhat on the amount of code bloat in video.c by moving out helper functions (including scaler kernels and color management routines) to a separate file. It would certainly be possible to move out more functions (eg. dithering or CMS code) with some extra effort/refactoring, but this is a start. Signed-off-by: wm4 <wm4@nowhere>
* vo_opengl: reduce code duplication for scaler optionsNiklas Haas2015-09-091-33/+16
| | | | | This simple refactor cuts down on the immense amount of overhead and duplication across all of the related scale-* options.
* vo_opengl: remove gl_ prefixes from files in video/out/openglNiklas Haas2015-09-0926-40/+40
| | | | | This is a bit redundant with the name of the directory itself, and not in line with existing naming conventions.
* vo_opengl: move gl_* files to their own subdirNiklas Haas2015-09-0926-24/+24
| | | | | This is mainly just to keep things a bit more organized and separated inside the codebase.
* vo_opengl: minor refactorNiklas Haas2015-09-091-5/+5
| | | | | Just making the argument order for pass_load_fbotex more consistent with finish_pass_fbo.
* vo_opengl: filter allowed options in dumb-modewm42015-09-081-14/+14
| | | | | | | Instead of the other way around of disabling disallowed options. This is more robust and also slightly simpler, at least conceptually. If new vo_opengl features are added, they don't need to be explicitly disabled for dumb-mode just to avoid that it accidentally breaks.
* vo_opengl: move gl_video_opts copying code to separate functionwm42015-09-082-15/+22
| | | | | | | | | | Sigh... Hopefully this code will be completely unnecessary one day, as it's only needed due to the sub-option parser craziness. Move dumb_mode to the top of the struct, so the C universal initializer doesn't cause warnings with all those broken compilers.
* vo_opengl: restore single pass optimization as separate code pathwm42015-09-072-30/+78
| | | | | | | | | | | | | | | | | | | | | | The single path optimization, rendering the video in one shader pass and without FBO indirections, was removed soem commits ago. It didn't have a place in this code, and caused considerable complexity and maintenance issues. On the other hand, it still has some worth, such as for use with extremely crappy hardware (GLES only or OpenGL 2.1 without FBO extension). Ideally, these use cases would be handled by a separate VO (say, vo_gles). While cleaner, this would still cause code duplication and other complexity. The third option is making the single-pass optimization a completely separate code path, with most vo_opengl features disabled. While this does duplicate some functionality (such as "unpacking" the video data from textures), it's also relatively unintrusive, and the high quality code path doesn't need to take it into account at all. On another positive node, this "dumb-mode" could be forced in other cases where OpenGL 2.1 is not enough, and where we don't want to care about versions this old.
* vo_opengl: move video source rectangle computation to a functionwm42015-09-071-18/+29
| | | | Needed for the following commit.
* vo_opengl: comsetics: remove unnecessary line breakwm42015-09-071-4/+2
|
* vo_opengl: require FBOs and get rid of the single-pass optimizationNiklas Haas2015-09-071-82/+34
| | | | | | | This change makes vo_opengl slightly less compatible (ancient devices without FBOs will no longer work) and decreases performance in the simplest case (vo=opengl), in exchange for significantly reducing code complexity and making everything easier to reason about.
* vo_opengl: use the correct attribute name for vertex positionwm42015-09-041-2/+2
| | | | | | This didn't seem entirely sane. It probably worked by accident, because "position" is always the first attribute, and thus the default value 0 for the location was always correct.
* vd_lavc: better hwdec log outputwm42015-09-022-4/+17
| | | | | | | | | | | | Often, we don't know whether hardware decoding will work until we've tried. (This used to be different, but API changes and improvements in libavcodec led to this situation.) We will often output that we're going to use hardware decoding, and then print a fallback warning. Instead, print the status once we have decoded a frame. Some of the old messages are turned into verbose messages, which should be helpful for debugging. Also add some new ones.
* vd_lavc: factor all hwdec fallbacks into the same functionwm42015-09-021-24/+19
| | | | | | | | The fallback at initialization time was basically duplicated, maybe for the sake of showing a different error message. This doesn't matter anymore; not much can fail at initialization anymore. Most meaningful and common errors happen either at probing or in get_format (when the actual hw decoder is initialized).
* vo_opengl: improve robustness against PBO failurewm42015-09-021-29/+40
| | | | | | | | | | | | | | If PBO upload fails, disable PBOs and revert to the normal codepath. In theory we should retry PBO upload on failure (because OpenGL specifies that it can sporadically fail), but since it normally doesn't happen, and the fallback will work, I'm not bothering. Some restructuring is needed, since glUnmapBuffer needs to be called earlier. In fact, the old code structure didn't make too much sense, and is a leftover from MPlayer's direct rendering support, which let the decoder decode to a PBO-mapped region. This means the buffer_ptr field can be dropped. Drop buffer_size as well, since it only had 2 possible values (0 or the size required for the current config).
* vo_opengl: enable pbo by default with opengl-hqwm42015-09-021-0/+1
| | | | | | | | | Can significantly help with very large video resolutions on nvidia drivers. It doesn't seem to have negative effects on Intel drivers either. (Although it could have on Intel drivers for older hardware.) For now, this is only for --vo=opengl-hq. Maybe --vo=opengl should use it too, but it's still meant to be the crappy, fail-safe default.
* vo_opengl: slightly simplify plane size determinationwm42015-09-021-2/+5
| | | | | | | | Setup a dummy image for the given image params, and get the plane sizes from that. Admittedly not much of a simplification, but conceptually it's simpler and less error-prone, as the image layout is guaranteed to be the same, rather than essentially duplicating the way it is determined.
* vo_opengl: don't distinguish "real" and texture sizewm42015-09-023-34/+28
| | | | | | | | This is from times when we supported padded/non-NPOT textures. The difference is not useful anymore, and theoretical support for different sizes is most likely buggy and unmaintained. So remove it. Also remove the tex_ prefix wherever it appears.
* vo_opengl: simplify PBO copywm42015-09-021-6/+2
| | | | | | | | Use mp_image_copy() instead of copying manually. (This function checks whether the destination is regarded writeable, which it is not, because the destination is the source image with changed pointers, so refcounting has to be removed from the destination image by resetting mpi->bufs.)
* vo_opengl: rename get_image to map_imagewm42015-09-021-2/+2
|
* vo_opengl: remove redundant statement in PBO codewm42015-09-022-5/+0
| | | | | | | | This shouldn't be needed anymore. Textures are now always allocated with the exact size. Any padding (including non-NPOT support) is gone. The texture sizes will always match the memory plane sizes. Drop the unused and forgotten "npot" field from the option struct too.
* vo_opengl: remove some leftoverswm42015-09-011-4/+0
| | | | Forgotten in the previous commit.
* vo_opengl, vda: return to old statewm42015-09-012-31/+5
| | | | | | | | Undo 292266f2. Reapply 3e12e79b. An additional copy is not really justified, as it could reduce performance. On the other hand, we can force API users to create a GL 3.x context.
* vo_rpi, vo_opengl: do not globally terminate EGL on VO uninitwm42015-08-311-2/+1
| | | | | |</