├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── Copyright ├── DOCS ├── client-api-changes.rst ├── client_api_examples │ ├── Copyright │ ├── README.md │ ├── cocoa-openglcb │ │ └── cocoa-openglcb.m │ ├── cocoa │ │ └── cocoabasic.m │ ├── qml │ │ ├── main.cpp │ │ ├── main.h │ │ ├── main.qml │ │ ├── mpvtest.pro │ │ └── mpvtest.qrc │ ├── qml_direct │ │ ├── main.cpp │ │ ├── main.h │ │ ├── main.qml │ │ ├── mpvtest.pro │ │ └── mpvtest.qrc │ ├── qt │ │ ├── qtexample.cpp │ │ ├── qtexample.h │ │ └── qtexample.pro │ ├── qt_opengl │ │ ├── main.cpp │ │ ├── mainwindow.cpp │ │ ├── mainwindow.h │ │ ├── mpvwidget.cpp │ │ ├── mpvwidget.h │ │ └── qt_opengl.pro │ ├── sdl │ │ └── main.c │ └── simple │ │ └── simple.c ├── compile-windows.md ├── contribute.md ├── edl-mpv.rst ├── encoding.rst ├── interface-changes.rst ├── man │ ├── af.rst │ ├── ao.rst │ ├── changes.rst │ ├── encode.rst │ ├── input.rst │ ├── ipc.rst │ ├── lua.rst │ ├── mpv.rst │ ├── options.rst │ ├── osc.rst │ ├── vf.rst │ └── vo.rst ├── mplayer-changes.rst ├── release-policy.md ├── tech-overview.txt └── waf-buildsystem.rst ├── LICENSE ├── README.md ├── TOOLS ├── dylib-unhell.py ├── file2string.pl ├── gen-x11-icon.sh ├── idet.sh ├── lib │ └── Parse │ │ ├── Matroska.pm │ │ └── Matroska │ │ ├── Definitions.pm │ │ ├── Element.pm │ │ ├── Reader.pm │ │ └── Utils.pm ├── lua │ ├── README.md │ ├── audio-hotplug-test.lua │ ├── autocrop.lua │ ├── autodeint.lua │ ├── autoload.lua │ ├── cycle-deinterlace-pullup.lua │ ├── drc-control.lua │ ├── observe-all.lua │ ├── ontop-playback.lua │ ├── pause-when-minimize.lua │ ├── status-line.lua │ └── zones.lua ├── matroska.pl ├── mpv_identify.sh ├── osxbundle.py ├── osxbundle │ └── mpv.app │ │ └── Contents │ │ ├── Info.plist │ │ ├── MacOS │ │ ├── .gitkeep │ │ └── lib │ │ │ └── .gitkeep │ │ ├── PkgInfo │ │ └── Resources │ │ ├── document.icns │ │ ├── icon.icns │ │ └── mpv.conf ├── stats-conv.py ├── umpv ├── uncrustify.cfg ├── vf_dlopen │ ├── Makefile │ ├── filterutils.c │ ├── filterutils.h │ ├── framestep.c │ ├── ildetect.c │ ├── ildetect.sh │ ├── rectangle.c │ ├── telecine.c │ └── tile.c └── zsh.pl ├── audio ├── audio.c ├── audio.h ├── audio_buffer.c ├── audio_buffer.h ├── chmap.c ├── chmap.h ├── chmap_sel.c ├── chmap_sel.h ├── decode │ ├── ad.h │ ├── ad_lavc.c │ ├── ad_spdif.c │ ├── dec_audio.c │ └── dec_audio.h ├── filter │ ├── af.c │ ├── af.h │ ├── af_channels.c │ ├── af_delay.c │ ├── af_drc.c │ ├── af_equalizer.c │ ├── af_format.c │ ├── af_lavcac3enc.c │ ├── af_lavfi.c │ ├── af_lavrresample.c │ ├── af_pan.c │ ├── af_rubberband.c │ ├── af_scaletempo.c │ ├── af_volume.c │ ├── equalizer.h │ └── tools.c ├── fmt-conversion.c ├── fmt-conversion.h ├── format.c ├── format.h ├── mixer.c ├── mixer.h └── out │ ├── ao.c │ ├── ao.h │ ├── ao_alsa.c │ ├── ao_coreaudio.c │ ├── ao_coreaudio_chmap.c │ ├── ao_coreaudio_chmap.h │ ├── ao_coreaudio_exclusive.c │ ├── ao_coreaudio_properties.c │ ├── ao_coreaudio_properties.h │ ├── ao_coreaudio_utils.c │ ├── ao_coreaudio_utils.h │ ├── ao_jack.c │ ├── ao_lavc.c │ ├── ao_null.c │ ├── ao_openal.c │ ├── ao_oss.c │ ├── ao_pcm.c │ ├── ao_pulse.c │ ├── ao_rsound.c │ ├── ao_sdl.c │ ├── ao_sndio.c │ ├── ao_wasapi.c │ ├── ao_wasapi.h │ ├── ao_wasapi_changenotify.c │ ├── ao_wasapi_utils.c │ ├── internal.h │ ├── pull.c │ └── push.c ├── bootstrap.py ├── common ├── av_common.c ├── av_common.h ├── av_log.c ├── av_log.h ├── codecs.c ├── codecs.h ├── common.c ├── common.h ├── encode.h ├── encode_lavc.c ├── encode_lavc.h ├── global.h ├── msg.c ├── msg.h ├── msg_control.h ├── playlist.c ├── playlist.h ├── tags.c ├── tags.h └── version.c ├── demux ├── codec_tags.c ├── codec_tags.h ├── cue.c ├── cue.h ├── demux.c ├── demux.h ├── demux_cue.c ├── demux_disc.c ├── demux_edl.c ├── demux_lavf.c ├── demux_libarchive.c ├── demux_mf.c ├── demux_mkv.c ├── demux_mkv_timeline.c ├── demux_playlist.c ├── demux_rar.c ├── demux_raw.c ├── demux_tv.c ├── ebml.c ├── ebml.h ├── matroska.h ├── packet.c ├── packet.h ├── stheader.h ├── timeline.c └── timeline.h ├── etc ├── encoding-profiles.conf ├── input.conf ├── mplayer-input.conf ├── mpv-gradient.svg ├── mpv-icon-8bit-16x16.png ├── mpv-icon-8bit-32x32.png ├── mpv-icon-8bit-64x64.png ├── mpv-icon.ico ├── mpv-symbolic.svg ├── mpv.conf ├── mpv.desktop ├── mpv.svg └── restore-old-bindings.conf ├── input ├── cmd_list.c ├── cmd_list.h ├── cmd_parse.c ├── cmd_parse.h ├── event.c ├── event.h ├── input.c ├── input.h ├── ipc.c ├── keycodes.c ├── keycodes.h └── pipe-win32.c ├── libmpv ├── client.h ├── mpv.def ├── mpv.pc.in ├── opengl_cb.h └── qthelper.hpp ├── misc ├── bstr.c ├── bstr.h ├── charset_conv.c ├── charset_conv.h ├── ctype.h ├── dispatch.c ├── dispatch.h ├── json.c ├── json.h ├── rendezvous.c ├── rendezvous.h ├── ring.c └── ring.h ├── mpv_talloc.h ├── options ├── m_config.c ├── m_config.h ├── m_option.c ├── m_option.h ├── m_property.c ├── m_property.h ├── options.c ├── options.h ├── parse_commandline.c ├── parse_commandline.h ├── parse_configfile.c ├── parse_configfile.h ├── path.c └── path.h ├── osdep ├── ar │ ├── HIDRemote.h │ └── HIDRemote.m ├── atomics.h ├── compiler.h ├── endian.h ├── glob-win.c ├── io.c ├── io.h ├── macosx_application.h ├── macosx_application.m ├── macosx_application_objc.h ├── macosx_compat.h ├── macosx_events.h ├── macosx_events.m ├── macosx_events_objc.h ├── macosx_versions.h ├── main-fn-cocoa.c ├── main-fn-unix.c ├── main-fn-win.c ├── main-fn.h ├── mpv.exe.manifest ├── mpv.rc ├── path-macosx.m ├── path-unix.c ├── path-win.c ├── path.h ├── semaphore.h ├── semaphore_osx.c ├── subprocess-posix.c ├── subprocess-win.c ├── subprocess.c ├── subprocess.h ├── terminal-unix.c ├── terminal-win.c ├── terminal.h ├── threads.c ├── threads.h ├── timer-darwin.c ├── timer-linux.c ├── timer-win2.c ├── timer.c ├── timer.h ├── w32_keyboard.c ├── w32_keyboard.h ├── win32-console-wrapper.c ├── win32 │ ├── include │ │ ├── pthread.h │ │ └── semaphore.h │ └── pthread.c ├── windows_utils.c └── windows_utils.h ├── player ├── audio.c ├── client.c ├── client.h ├── command.c ├── command.h ├── configfiles.c ├── core.h ├── external_files.c ├── external_files.h ├── loadfile.c ├── lua.c ├── lua │ ├── assdraw.lua │ ├── defaults.lua │ ├── options.lua │ ├── osc.lua │ └── ytdl_hook.lua ├── main.c ├── misc.c ├── osd.c ├── playloop.c ├── screenshot.c ├── screenshot.h ├── scripting.c ├── sub.c └── video.c ├── stream ├── ai_alsa1x.c ├── ai_oss.c ├── ai_sndio.c ├── audio_in.c ├── audio_in.h ├── cache.c ├── cache_file.c ├── cookies.c ├── cookies.h ├── dvb_tune.c ├── dvb_tune.h ├── dvbin.h ├── frequencies.c ├── frequencies.h ├── rar.c ├── rar.h ├── stream.c ├── stream.h ├── stream_avdevice.c ├── stream_bluray.c ├── stream_cdda.c ├── stream_dvb.c ├── stream_dvd.c ├── stream_dvd_common.c ├── stream_dvd_common.h ├── stream_dvdnav.c ├── stream_edl.c ├── stream_file.c ├── stream_lavf.c ├── stream_libarchive.c ├── stream_libarchive.h ├── stream_memory.c ├── stream_mf.c ├── stream_null.c ├── stream_rar.c ├── stream_smb.c ├── stream_tv.c ├── tv.c ├── tv.h ├── tvi_def.h ├── tvi_dummy.c └── tvi_v4l2.c ├── sub ├── ass_mp.c ├── ass_mp.h ├── dec_sub.c ├── dec_sub.h ├── draw_bmp.c ├── draw_bmp.h ├── img_convert.c ├── img_convert.h ├── lavc_conv.c ├── osd.c ├── osd.h ├── osd_dummy.c ├── osd_font.otf ├── osd_libass.c ├── osd_state.h ├── sd.h ├── sd_ass.c └── sd_lavc.c ├── ta ├── README ├── ta.c ├── ta.h ├── ta_talloc.c ├── ta_talloc.h └── ta_utils.c ├── test ├── chmap.c ├── chmap_sel.c ├── gl_video.c └── test_helpers.h ├── travis-deps ├── version.sh ├── video ├── csputils.c ├── csputils.h ├── d3d.h ├── decode │ ├── dec_video.c │ ├── dec_video.h │ ├── dxva2.c │ ├── lavc.h │ ├── rpi.c │ ├── vaapi.c │ ├── vd.h │ ├── vd_lavc.c │ ├── vdpau.c │ └── videotoolbox.c ├── filter │ ├── vf.c │ ├── vf.h │ ├── vf_buffer.c │ ├── vf_crop.c │ ├── vf_dlopen.c │ ├── vf_dlopen.h │ ├── vf_dsize.c │ ├── vf_eq.c │ ├── vf_expand.c │ ├── vf_flip.c │ ├── vf_format.c │ ├── vf_gradfun.c │ ├── vf_lavfi.c │ ├── vf_lavfi.h │ ├── vf_mirror.c │ ├── vf_noformat.c │ ├── vf_pullup.c │ ├── vf_rotate.c │ ├── vf_scale.c │ ├── vf_stereo3d.c │ ├── vf_sub.c │ ├── vf_vapoursynth.c │ ├── vf_vavpp.c │ ├── vf_vdpaupp.c │ ├── vf_vdpaurb.c │ └── vf_yadif.c ├── fmt-conversion.c ├── fmt-conversion.h ├── gpu_memcpy.c ├── gpu_memcpy.h ├── hwdec.h ├── image_writer.c ├── image_writer.h ├── img_format.c ├── img_format.h ├── img_fourcc.h ├── mp_image.c ├── mp_image.h ├── mp_image_pool.c ├── mp_image_pool.h ├── out │ ├── aspect.c │ ├── aspect.h │ ├── bitmap_packer.c │ ├── bitmap_packer.h │ ├── cocoa │ │ ├── events_view.h │ │ ├── events_view.m │ │ ├── mpvadapter.h │ │ ├── video_view.h │ │ ├── video_view.m │ │ ├── window.h │ │ └── window.m │ ├── cocoa_common.h │ ├── cocoa_common.m │ ├── d3d_shader_420p.h │ ├── d3d_shader_nv12.h │ ├── d3d_shader_yuv.hlsl │ ├── dither.c │ ├── dither.h │ ├── drm_common.c │ ├── drm_common.h │ ├── filter_kernels.c │ ├── filter_kernels.h │ ├── opengl │ │ ├── common.c │ │ ├── common.h │ │ ├── context.c │ │ ├── context.h │ │ ├── context_angle.c │ │ ├── context_cocoa.c │ │ ├── context_drm_egl.c │ │ ├── context_dxinterop.c │ │ ├── context_rpi.c │ │ ├── context_rpi.h │ │ ├── context_w32.c │ │ ├── context_wayland.c │ │ ├── context_x11.c │ │ ├── context_x11egl.c │ │ ├── egl_helpers.c │ │ ├── egl_helpers.h │ │ ├── header_fixes.h │ │ ├── hwdec.c │ │ ├── hwdec.h │ │ ├── hwdec_dxva2.c │ │ ├── hwdec_osx.c │ │ ├── hwdec_vaegl.c │ │ ├── hwdec_vaglx.c │ │ ├── hwdec_vdpau.c │ │ ├── lcms.c │ │ ├── lcms.h │ │ ├── nnedi3.c │ │ ├── nnedi3.h │ │ ├── nnedi3_weights.bin │ │ ├── osd.c │ │ ├── osd.h │ │ ├── superxbr.c │ │ ├── superxbr.h │ │ ├── utils.c │ │ ├── utils.h │ │ ├── video.c │ │ ├── video.h │ │ ├── video_shaders.c │ │ └── video_shaders.h │ ├── vo.c │ ├── vo.h │ ├── vo_caca.c │ ├── vo_direct3d.c │ ├── vo_drm.c │ ├── vo_image.c │ ├── vo_lavc.c │ ├── vo_null.c │ ├── vo_opengl.c │ ├── vo_opengl_cb.c │ ├── vo_rpi.c │ ├── vo_sdl.c │ ├── vo_vaapi.c │ ├── vo_vdpau.c │ ├── vo_wayland.c │ ├── vo_x11.c │ ├── vo_xv.c │ ├── w32_common.c │ ├── w32_common.h │ ├── wayland │ │ ├── buffer.c │ │ ├── buffer.h │ │ ├── memfile.c │ │ └── memfile.h │ ├── wayland_common.c │ ├── wayland_common.h │ ├── win32 │ │ ├── displayconfig.c │ │ ├── displayconfig.h │ │ ├── exclusive_hack.c │ │ └── exclusive_hack.h │ ├── win_state.c │ ├── win_state.h │ ├── x11_common.c │ ├── x11_common.h │ └── x11_icon.bin ├── sws_utils.c ├── sws_utils.h ├── vaapi.c ├── vaapi.h ├── vdpau.c ├── vdpau.h ├── vdpau_functions.inc ├── vdpau_mixer.c └── vdpau_mixer.h ├── waftools ├── __init__.py ├── checks │ ├── __init__.py │ ├── custom.py │ └── generic.py ├── clang_compilation_database.py ├── dependencies.py ├── detections │ ├── __init__.py │ ├── compiler.py │ └── devices.py ├── features.py ├── fragments │ ├── cocoa.m │ ├── coreaudio.c │ ├── dvb.c │ ├── gl_x11.c │ ├── iconv.c │ ├── oss_audio.c │ ├── oss_audio_sunaudio.c │ ├── pthreads.c │ ├── pvr.c │ ├── sse.c │ └── wasapi.c ├── generators │ ├── __init__.py │ ├── headers.py │ └── sources.py ├── inflector.py ├── syms.py └── waf_customizations.py ├── wscript └── wscript_build.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | *.d 4 | *.exe 5 | *.pyc 6 | .depend 7 | 8 | /config.h 9 | /config.mak 10 | /config.log 11 | /mpv 12 | /mpv.app 13 | /version.h 14 | /input/input_conf.h 15 | /tags 16 | /TAGS 17 | /video/out/x11_icon.inc 18 | /video/out/opengl/nnedi3_weights.inc 19 | /demux/ebml_defs.c 20 | /demux/ebml_types.h 21 | /sub/osd_font.h 22 | /player/lua/*.inc 23 | /DOCS/man/mpv.1 24 | /DOCS/man/mpv.aux 25 | /DOCS/man/mpv.log 26 | /DOCS/man/mpv.out 27 | /DOCS/man/mpv.pdf 28 | /DOCS/man/mpv.toc 29 | 30 | /waf 31 | /waf-* 32 | /waf3-* 33 | /build 34 | /.waf* 35 | /.lock-waf_* 36 | 37 | /old_build 38 | /Makefile 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | os: 4 | - linux 5 | - osx 6 | env: 7 | matrix: 8 | - LIBAV=libav-stable 9 | - LIBAV=libav-git 10 | - LIBAV=ffmpeg-stable 11 | - LIBAV=ffmpeg-git 12 | global: 13 | # Coverity token 14 | - secure: "H21mSRlMhk4BKS0xHZvCFGJxteCP0hRVUxTuNfM2Z9HBsyutuLEYMtViLO86VtM+Tqla3xXPzUdS4ozLwI72Ax/5ZUDXACROj73yW6QhFB5D6rLut12+FjqC7M33Qv2hl0xwgNBmR5dsm1ToP37+Wn+ecJQNvN8fkTXF+HVzOEw=" 15 | compiler: 16 | - clang 17 | - gcc 18 | 19 | branches: 20 | only: 21 | - master 22 | - ci 23 | - coverity_scan 24 | 25 | matrix: 26 | exclude: 27 | - os: osx 28 | env: LIBAV=libav-stable 29 | - os: osx 30 | env: LIBAV=libav-git 31 | - os: osx 32 | env: LIBAV=ffmpeg-git 33 | - os: osx 34 | compiler: gcc 35 | - os: linux 36 | env: LIBAV=ffmpeg-stable 37 | - os: linux 38 | compiler: clang 39 | 40 | before_install: ./travis-deps libass-stable $LIBAV 41 | script: 42 | - ./bootstrap.py 43 | - ./waf configure 44 | - ./waf build 45 | 46 | notifications: 47 | email: false 48 | irc: 49 | channels: 50 | - "irc.freenode.org#mpv-devel" 51 | on_success: change 52 | on_failure: always 53 | 54 | addons: 55 | coverity_scan: 56 | project: 57 | name: "mpv-player/mpv" 58 | description: "Build submitted via Travis CI" 59 | notification_email: mpv-team@googlegroups.com 60 | build_command_prepend: "./bootstrap.py && ./waf configure" 61 | build_command: "./waf build" 62 | branch_pattern: coverity_scan 63 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Reporting bugs 2 | ============== 3 | 4 | - State your platform and mpv version. 5 | - Make sure you're actually using the latest mpv release. Linux distributions 6 | in particular love redistributing ancient and unmaintained mpv releases. 7 | - Attach a log file made with ``-v`` or ``--log-file=output.txt``. 8 | - Avoid attaching text files packed in archive files (zip/rar/...), unless 9 | explicitly asked so. There are better means, such as using http://sprunge.us 10 | - If you think this is file specific, upload a sample file and link it. 11 | - Don't report multiple unrelated/barely related bugs in one issue. 12 | - Read: https://mpv.io/bug-reports/ 13 | 14 | Asking questions 15 | ================ 16 | 17 | Preferably, asking questions should be done via IRC (#mpv on irc.freenode.net), 18 | but asking questions by opening a github issue is also barely tolerated. 19 | 20 | When asking on IRC (#mpv on irc.freenode.net), don't ask to ask, just state 21 | your problem. Stay long enough until someone gets a chance to reply. Sometimes 22 | it can take hours. 23 | 24 | Sending patches 25 | =============== 26 | 27 | See: https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md 28 | 29 | In particular, be aware that all changes to GPL code must come with the 30 | implicit agreement that they might be LGPLv2.1+ relicensed at a later point. 31 | -------------------------------------------------------------------------------- /Copyright: -------------------------------------------------------------------------------- 1 | mpv is a fork of mplayer2, which is a fork of MPlayer. 2 | 3 | mpv as a whole is licensed as GPL version 2 or later (see LICENSE). Most source 4 | files are GPLv2+, but some files are available under a more liberal license, 5 | such as LGPLv2.1+, BSD, MIT, ISC, and possibly others. Look at the copyright 6 | header of each source file, and grep the sources for "Copyright" if you need 7 | to know details. Files without Copyright notice are licensed as LGPLv2.1+. 8 | 9 | All new contributions must be LGPLv2.1+ licensed, or if the changes are done on 10 | GPL code, must come with the implicit agreement that the project can relicense 11 | the code to LGPLv2.1+ at a later point without asking the contributor. (This 12 | is a safeguard for making potential relicensing of the project to LGPLv2.1+ 13 | easier.) Using a more liberal license compatible to LGPLv2.1+ is also ok. 14 | 15 | Some GPLv3 or LGPLv3 code in mpv can be enabled by building with --enable-gpl3, 16 | and in this case, the resulting binaries must be distributed under GPLv3. 17 | 18 | For information about authors and contributors, consult the git log, which 19 | contains the complete SVN and CVS history as well. 20 | 21 | Note that mplayer2 as a whole is licensed under GPLv3+. This is because it uses 22 | a copy of talloc (part of Samba), which is LGPLv3+, and the next compatible 23 | license for this mix is GPLv3+. 24 | 25 | MPlayer as a whole is licensed under GPLv2 (incompatible to GPLv3!), because 26 | some files are licensed to GPLv2 (and _not_ any later version of the license). 27 | In particular, this affects the file libmpdemux/demux_ty_osd.c. It is disabled 28 | under mplayer2, and has been removed from mpv. 29 | 30 | "v2.1+" in this context means "version 2.1 or later". 31 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/Copyright: -------------------------------------------------------------------------------- 1 | All examples in this directory and its sub-directories are licensed 2 | under one of the following licenses: 3 | 4 | WTFPL, ISC, Ms-PL, AGPLv3, BSD (any) 5 | 6 | Pick any license of your liking, and disregard the others. 7 | 8 | (The full text of each license is available on this website: 9 | http://opensource.org/licenses/alphabetical ) 10 | 11 | Additionally, you may consider the example code to be public domain. 12 | You are free to use any of the example code without further 13 | requirements or need for attribution. 14 | 15 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MPVRENDERER_H_ 2 | #define MPVRENDERER_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | class MpvRenderer; 11 | 12 | class MpvObject : public QQuickFramebufferObject 13 | { 14 | Q_OBJECT 15 | 16 | mpv::qt::Handle mpv; 17 | mpv_opengl_cb_context *mpv_gl; 18 | 19 | friend class MpvRenderer; 20 | 21 | public: 22 | MpvObject(QQuickItem * parent = 0); 23 | virtual ~MpvObject(); 24 | virtual Renderer *createRenderer() const; 25 | public slots: 26 | void command(const QVariant& params); 27 | void setProperty(const QString& name, const QVariant& value); 28 | signals: 29 | void onUpdate(); 30 | private slots: 31 | void doUpdate(); 32 | private: 33 | static void on_update(void *ctx); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 1.0 3 | 4 | import mpvtest 1.0 5 | 6 | Item { 7 | width: 1280 8 | height: 720 9 | 10 | MpvObject { 11 | id: renderer 12 | anchors.fill: parent 13 | 14 | MouseArea { 15 | anchors.fill: parent 16 | onClicked: renderer.command(["loadfile", "../../../test.mkv"]) 17 | } 18 | } 19 | 20 | Rectangle { 21 | id: labelFrame 22 | anchors.margins: -50 23 | radius: 5 24 | color: "white" 25 | border.color: "black" 26 | opacity: 0.8 27 | anchors.fill: box 28 | } 29 | 30 | Row { 31 | id: box 32 | anchors.bottom: renderer.bottom 33 | anchors.left: renderer.left 34 | anchors.right: renderer.right 35 | anchors.margins: 100 36 | 37 | Text { 38 | anchors.margins: 10 39 | wrapMode: Text.WordWrap 40 | text: "QtQuick and mpv are both rendering stuff.\n 41 | Click to load ../../../test.mkv" 42 | } 43 | 44 | // Don't take these controls too seriously. They're for testing. 45 | Column { 46 | CheckBox { 47 | id: checkbox 48 | anchors.margins: 10 49 | // Heavily filtered means good, right? 50 | text: "Make video look like on a Smart TV" 51 | onClicked: { 52 | if (checkbox.checked) { 53 | renderer.command(["vo_cmdline", "sharpen=5.0"]) 54 | } else { 55 | renderer.command(["vo_cmdline", ""]) 56 | } 57 | } 58 | } 59 | Slider { 60 | id: slider 61 | anchors.margins: 10 62 | anchors.left: checkbox.left 63 | anchors.right: checkbox.right 64 | minimumValue: -100 65 | maximumValue: 100 66 | value: 0 67 | onValueChanged: renderer.setProperty("gamma", slider.value | 0) 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml/mpvtest.pro: -------------------------------------------------------------------------------- 1 | QT += qml quick 2 | 3 | HEADERS += main.h 4 | SOURCES += main.cpp 5 | 6 | QT_CONFIG -= no-pkg-config 7 | CONFIG += link_pkgconfig debug 8 | PKGCONFIG += mpv 9 | 10 | RESOURCES += mpvtest.qrc 11 | 12 | OTHER_FILES += main.qml 13 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml/mpvtest.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml_direct/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MPVRENDERER_H_ 2 | #define MPVRENDERER_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | class MpvRenderer : public QObject 11 | { 12 | Q_OBJECT 13 | mpv::qt::Handle mpv; 14 | mpv_opengl_cb_context *mpv_gl; 15 | QQuickWindow *window; 16 | QSize size; 17 | 18 | friend class MpvObject; 19 | public: 20 | MpvRenderer(mpv::qt::Handle a_mpv, mpv_opengl_cb_context *a_mpv_gl); 21 | virtual ~MpvRenderer(); 22 | public slots: 23 | void paint(); 24 | }; 25 | 26 | class MpvObject : public QQuickItem 27 | { 28 | Q_OBJECT 29 | 30 | mpv::qt::Handle mpv; 31 | mpv_opengl_cb_context *mpv_gl; 32 | MpvRenderer *renderer; 33 | 34 | public: 35 | MpvObject(QQuickItem * parent = 0); 36 | virtual ~MpvObject(); 37 | public slots: 38 | void command(const QVariant& params); 39 | void sync(); 40 | void swapped(); 41 | void cleanup(); 42 | signals: 43 | void onUpdate(); 44 | private slots: 45 | void doUpdate(); 46 | void handleWindowChanged(QQuickWindow *win); 47 | private: 48 | static void on_update(void *ctx); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml_direct/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 1.0 3 | 4 | import mpvtest 1.0 5 | 6 | Item { 7 | width: 1280 8 | height: 720 9 | 10 | MpvObject { 11 | id: renderer 12 | 13 | // This object isn't real and not visible; it just renders into the 14 | // background of the containing Window. 15 | width: 0 16 | height: 0 17 | } 18 | 19 | MouseArea { 20 | anchors.fill: parent 21 | onClicked: renderer.command(["loadfile", "../../../test.mkv"]) 22 | } 23 | 24 | Rectangle { 25 | id: labelFrame 26 | anchors.margins: -50 27 | radius: 5 28 | color: "white" 29 | border.color: "black" 30 | opacity: 0.8 31 | anchors.fill: box 32 | } 33 | 34 | Row { 35 | id: box 36 | anchors.bottom: parent.bottom 37 | anchors.left: parent.left 38 | anchors.right: parent.right 39 | anchors.margins: 100 40 | 41 | Text { 42 | anchors.margins: 10 43 | wrapMode: Text.WordWrap 44 | text: "QtQuick and mpv are both rendering stuff.\n 45 | In this example, mpv is always in the background.\n 46 | Click to load ../../../test.mkv" 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml_direct/mpvtest.pro: -------------------------------------------------------------------------------- 1 | QT += qml quick 2 | 3 | HEADERS += main.h 4 | SOURCES += main.cpp 5 | 6 | QT_CONFIG -= no-pkg-config 7 | CONFIG += link_pkgconfig debug 8 | PKGCONFIG += mpv 9 | 10 | RESOURCES += mpvtest.qrc 11 | 12 | OTHER_FILES += main.qml 13 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qml_direct/mpvtest.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qt/qtexample.h: -------------------------------------------------------------------------------- 1 | #ifndef QTEXAMPLE_H 2 | #define QTEXAMPLE_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | class QTextEdit; 9 | 10 | class MainWindow : public QMainWindow 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | private slots: 19 | void on_file_open(); 20 | void on_new_window(); 21 | void on_mpv_events(); 22 | 23 | signals: 24 | void mpv_events(); 25 | 26 | private: 27 | QWidget *mpv_container; 28 | mpv_handle *mpv; 29 | QTextEdit *log; 30 | 31 | void append_log(const QString &text); 32 | 33 | void create_player(); 34 | void handle_mpv_event(mpv_event *event); 35 | }; 36 | 37 | #endif // QTEXAMPLE_H 38 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qt/qtexample.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | TARGET = qtexample 6 | TEMPLATE = app 7 | 8 | QT_CONFIG -= no-pkg-config 9 | CONFIG += link_pkgconfig debug 10 | PKGCONFIG += mpv 11 | 12 | SOURCES += qtexample.cpp 13 | HEADERS += qtexample.h 14 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qt_opengl/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | // Qt sets the locale in the QApplication constructor, but libmpv requires 8 | // the LC_NUMERIC category to be set to "C", so change it back. 9 | setlocale(LC_NUMERIC, "C"); 10 | MainWindow w; 11 | w.show(); 12 | return a.exec(); 13 | } 14 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qt_opengl/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "mpvwidget.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | MainWindow::MainWindow(QWidget *parent) : QWidget(parent) 9 | { 10 | m_mpv = new MpvWidget(this); 11 | m_slider = new QSlider(); 12 | m_slider->setOrientation(Qt::Horizontal); 13 | m_openBtn = new QPushButton("Open"); 14 | m_playBtn = new QPushButton("Pause"); 15 | QHBoxLayout *hb = new QHBoxLayout(); 16 | hb->addWidget(m_openBtn); 17 | hb->addWidget(m_playBtn); 18 | QVBoxLayout *vl = new QVBoxLayout(); 19 | vl->addWidget(m_mpv); 20 | vl->addWidget(m_slider); 21 | vl->addLayout(hb); 22 | setLayout(vl); 23 | connect(m_slider, SIGNAL(sliderMoved(int)), SLOT(seek(int))); 24 | connect(m_openBtn, SIGNAL(clicked()), SLOT(openMedia())); 25 | connect(m_playBtn, SIGNAL(clicked()), SLOT(pauseResume())); 26 | connect(m_mpv, SIGNAL(positionChanged(int)), m_slider, SLOT(setValue(int))); 27 | connect(m_mpv, SIGNAL(durationChanged(int)), this, SLOT(setSliderRange(int))); 28 | } 29 | 30 | void MainWindow::openMedia() 31 | { 32 | QString file = QFileDialog::getOpenFileName(0, "Open a video"); 33 | if (file.isEmpty()) 34 | return; 35 | m_mpv->command(QStringList() << "loadfile" << file); 36 | } 37 | 38 | void MainWindow::seek(int pos) 39 | { 40 | m_mpv->command(QVariantList() << "seek" << pos << "absolute"); 41 | } 42 | 43 | void MainWindow::pauseResume() 44 | { 45 | const bool paused = m_mpv->getProperty("pause").toBool(); 46 | m_mpv->setProperty("pause", !paused); 47 | } 48 | 49 | void MainWindow::setSliderRange(int duration) 50 | { 51 | m_slider->setRange(0, duration); 52 | } 53 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qt_opengl/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MainWindow_H 2 | #define MainWindow_H 3 | 4 | #include 5 | 6 | class MpvWidget; 7 | class QSlider; 8 | class QPushButton; 9 | class MainWindow : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit MainWindow(QWidget *parent = 0); 14 | public Q_SLOTS: 15 | void openMedia(); 16 | void seek(int pos); 17 | void pauseResume(); 18 | private Q_SLOTS: 19 | void setSliderRange(int duration); 20 | private: 21 | MpvWidget *m_mpv; 22 | QSlider *m_slider; 23 | QPushButton *m_openBtn; 24 | QPushButton *m_playBtn; 25 | }; 26 | 27 | #endif // MainWindow_H 28 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qt_opengl/mpvwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYERWINDOW_H 2 | #define PLAYERWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class MpvWidget Q_DECL_FINAL: public QOpenGLWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | MpvWidget(QWidget *parent = 0, Qt::WindowFlags f = 0); 14 | ~MpvWidget(); 15 | void command(const QVariant& params); 16 | void setProperty(const QString& name, const QVariant& value); 17 | QVariant getProperty(const QString& name) const; 18 | QSize sizeHint() const { return QSize(480, 270);} 19 | Q_SIGNALS: 20 | void durationChanged(int value); 21 | void positionChanged(int value); 22 | protected: 23 | void initializeGL() Q_DECL_OVERRIDE; 24 | void paintGL() Q_DECL_OVERRIDE; 25 | private Q_SLOTS: 26 | void swapped(); 27 | void on_mpv_events(); 28 | private: 29 | void handle_mpv_event(mpv_event *event); 30 | static void on_update(void *ctx); 31 | 32 | mpv::qt::Handle mpv; 33 | mpv_opengl_cb_context *mpv_gl; 34 | }; 35 | 36 | 37 | 38 | #endif // PLAYERWINDOW_H 39 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/qt_opengl/qt_opengl.pro: -------------------------------------------------------------------------------- 1 | CONFIG -= app_bundle 2 | QT += widgets 3 | 4 | QT_CONFIG -= no-pkg-config 5 | CONFIG += link_pkgconfig debug 6 | PKGCONFIG += mpv 7 | 8 | HEADERS = \ 9 | mpvwidget.h \ 10 | mainwindow.h 11 | SOURCES = main.cpp \ 12 | mpvwidget.cpp \ 13 | mainwindow.cpp 14 | -------------------------------------------------------------------------------- /DOCS/client_api_examples/simple/simple.c: -------------------------------------------------------------------------------- 1 | // Build with: gcc -o simple simple.c `pkg-config --libs --cflags mpv` 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | static inline void check_error(int status) 10 | { 11 | if (status < 0) { 12 | printf("mpv API error: %s\n", mpv_error_string(status)); 13 | exit(1); 14 | } 15 | } 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | if (argc != 2) { 20 | printf("pass a single media file as argument\n"); 21 | return 1; 22 | } 23 | 24 | mpv_handle *ctx = mpv_create(); 25 | if (!ctx) { 26 | printf("failed creating context\n"); 27 | return 1; 28 | } 29 | 30 | // Enable default key bindings, so the user can actually interact with 31 | // the player (and e.g. close the window). 32 | check_error(mpv_set_option_string(ctx, "input-default-bindings", "yes")); 33 | mpv_set_option_string(ctx, "input-vo-keyboard", "yes"); 34 | int val = 1; 35 | check_error(mpv_set_option(ctx, "osc", MPV_FORMAT_FLAG, &val)); 36 | 37 | // Done setting up options. 38 | check_error(mpv_initialize(ctx)); 39 | 40 | // Play this file. 41 | const char *cmd[] = {"loadfile", argv[1], NULL}; 42 | check_error(mpv_command(ctx, cmd)); 43 | 44 | // Let it play, and wait until the user quits. 45 | while (1) { 46 | mpv_event *event = mpv_wait_event(ctx, 10000); 47 | printf("event: %s\n", mpv_event_name(event->event_id)); 48 | if (event->event_id == MPV_EVENT_SHUTDOWN) 49 | break; 50 | } 51 | 52 | mpv_terminate_destroy(ctx); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /DOCS/man/changes.rst: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | There is no real changelog, but you can look at the following things: 5 | 6 | * The release changelog, which should contain most user-visible changes, 7 | including new features and bug fixes: 8 | 9 | https://github.com/mpv-player/mpv/releases 10 | * The git log, which is the "real" changelog 11 | * The file ``mplayer-changes.rst`` in the ``DOCS`` sub directory on the git 12 | repository, which used to be in place of this section. It documents some 13 | changes that happened since mplayer2 forked off MPlayer. 14 | -------------------------------------------------------------------------------- /TOOLS/file2string.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | # Convert the contents of a file into a C string constant. 7 | # Note that the compiler will implicitly add an extra 0 byte at the end 8 | # of every string, so code using the string may need to remove that to get 9 | # the exact contents of the original file. 10 | # FIXME: why not a char array? 11 | 12 | # treat only alphanumeric and punctuations (excluding " and ?) as safe 13 | my $unsafe_chars = qr{[^][A-Za-z0-9!#%&'()*+,./:;<=>^_{|}~ -]}; 14 | 15 | for my $file (@ARGV) { 16 | open my $fh, '<:raw', $file or next; 17 | print "/* Generated from $file */\n"; 18 | while (<$fh>) { 19 | # replace unsafe chars with their equivalent octal escapes 20 | s/($unsafe_chars)/\\@{[sprintf '%03o', ord($1)]}/gos; 21 | print "\"$_\"\n" 22 | } 23 | close $fh; 24 | } 25 | -------------------------------------------------------------------------------- /TOOLS/gen-x11-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script is expected to be called as TOOLS/gen-x11-icon.sh (it will access 4 | # etc/mpv-icon...), and it will write video/out/x11_icon.bin. 5 | 6 | conv() { 7 | echo 8 | echo `identify -format "icon: %w %h" "$1"` 9 | convert "$1" -depth 8 rgba:- 10 | } 11 | 12 | (echo "# File generated by gen-x11-icon.sh" ; 13 | conv etc/mpv-icon-8bit-16x16.png ; 14 | conv etc/mpv-icon-8bit-32x32.png ; 15 | conv etc/mpv-icon-8bit-64x64.png) | gzip -c > video/out/x11_icon.bin 16 | -------------------------------------------------------------------------------- /TOOLS/lib/Parse/Matroska.pm: -------------------------------------------------------------------------------- 1 | use 5.008; 2 | use strict; 3 | use warnings; 4 | 5 | # ABSTRACT: Module collection to parse Matroska files. 6 | package Parse::Matroska; 7 | 8 | =head1 DESCRIPTION 9 | 10 | Cs L. See the documentation 11 | of the modules mentioned in L for more information 12 | in how to use this module. 13 | 14 | It's intended for this module to contain high-level interfaces 15 | to the other modules in the distribution. 16 | 17 | =head1 SOURCE CODE 18 | 19 | L 20 | 21 | =head1 SEE ALSO 22 | 23 | L, L, 24 | L. 25 | 26 | =cut 27 | 28 | use Parse::Matroska::Reader; 29 | 30 | 1; 31 | -------------------------------------------------------------------------------- /TOOLS/lib/Parse/Matroska/Utils.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | # ABSTRACT: internally-used helper functions 5 | package Parse::Matroska::Utils; 6 | 7 | use Exporter; 8 | our @ISA = qw{Exporter}; 9 | our @EXPORT_OK = qw{uniq uncamelize}; 10 | 11 | =method uniq(@array) 12 | 13 | The same as L. 14 | Included to avoid depending on it since it's 15 | not a core module. 16 | 17 | =cut 18 | sub uniq(@) { 19 | my %seen; 20 | return grep { !$seen{$_}++ } @_; 21 | } 22 | 23 | =method uncamelize($string) 24 | 25 | Converts a "StringLikeTHIS" into a 26 | "string_like_this". 27 | 28 | =cut 29 | sub uncamelize($) { 30 | local $_ = shift; 31 | # lc followed by UC: lc_UC 32 | s/(?<=[a-z])([A-Z])/_\L$1/g; 33 | # UC followed by two lc: _UClclc 34 | s/([A-Z])(?=[a-z]{2})/_\L$1/g; 35 | # strip leading _ that the second regexp might add; lowercase all 36 | s/^_//; lc 37 | } 38 | -------------------------------------------------------------------------------- /TOOLS/lua/README.md: -------------------------------------------------------------------------------- 1 | mpv lua scripts 2 | =============== 3 | 4 | The lua scripts in this folder can be loaded on a one-time basis by 5 | adding the option 6 | 7 | --script=/path/to/script.lua 8 | 9 | to mpv's command line. 10 | 11 | Where appropriate, they may also be placed in ~/.config/mpv/scripts/ from 12 | where they will be automatically loaded when mpv starts. 13 | 14 | Some of these are just for testing mpv internals. 15 | -------------------------------------------------------------------------------- /TOOLS/lua/audio-hotplug-test.lua: -------------------------------------------------------------------------------- 1 | local utils = require("mp.utils") 2 | 3 | mp.observe_property("audio-device-list", "native", function(name, val) 4 | print("Audio device list changed:") 5 | for index, e in ipairs(val) do 6 | print(" - '" .. e.name .. "' (" .. e.description .. ")") 7 | end 8 | end) 9 | 10 | mp.observe_property("audio-out-detected-device", "native", function(name, val) 11 | print("Detected audio device changed:") 12 | print(" - '" .. val) 13 | end) 14 | -------------------------------------------------------------------------------- /TOOLS/lua/observe-all.lua: -------------------------------------------------------------------------------- 1 | -- Test script for property change notification mechanism. 2 | -- Note that watching/reading some properties can be very expensive, or 3 | -- require the player to synchronously wait on network (when playing 4 | -- remote files), so you should in general only watch properties you 5 | -- are interested in. 6 | 7 | local utils = require("mp.utils") 8 | 9 | for i,name in ipairs(mp.get_property_native("property-list")) do 10 | mp.observe_property(name, "native", function(name, val) 11 | print("property '" .. name .. "' changed to '" .. 12 | utils.to_string(val) .. "'") 13 | end) 14 | end 15 | -------------------------------------------------------------------------------- /TOOLS/lua/ontop-playback.lua: -------------------------------------------------------------------------------- 1 | --makes mpv disable ontop when pausing and re-enable it again when resuming playback 2 | --please note that this won't do anything if ontop was not enabled before pausing 3 | 4 | local was_ontop = false 5 | 6 | mp.observe_property("pause", "bool", function(name, value) 7 | local ontop = mp.get_property_native("ontop") 8 | if value then 9 | if ontop then 10 | mp.set_property_native("ontop", false) 11 | was_ontop = true 12 | end 13 | else 14 | if was_ontop and not ontop then 15 | mp.set_property_native("ontop", true) 16 | end 17 | was_ontop = false 18 | end 19 | end) 20 | -------------------------------------------------------------------------------- /TOOLS/lua/pause-when-minimize.lua: -------------------------------------------------------------------------------- 1 | -- This script pauses playback when minimizing the window, and resumes playback 2 | -- if it's brought back again. If the player was already paused when minimizing, 3 | -- then try not to mess with the pause state. 4 | 5 | local did_minimize = false 6 | 7 | mp.observe_property("window-minimized", "bool", function(name, value) 8 | local pause = mp.get_property_native("pause") 9 | if value == true then 10 | if pause == false then 11 | mp.set_property_native("pause", true) 12 | did_minimize = true 13 | end 14 | elseif value == false then 15 | if did_minimize and (pause == true) then 16 | mp.set_property_native("pause", false) 17 | end 18 | did_minimize = false 19 | end 20 | end) 21 | -------------------------------------------------------------------------------- /TOOLS/lua/status-line.lua: -------------------------------------------------------------------------------- 1 | -- Rebuild the terminal status line as a lua script 2 | -- Be aware that this will require more cpu power! 3 | -- Also, this is based on a rather old version of the 4 | -- builtin mpv status line. 5 | 6 | -- Add a string to the status line 7 | function atsl(s) 8 | newStatus = newStatus .. s 9 | end 10 | 11 | function update_status_line() 12 | -- Reset the status line 13 | newStatus = "" 14 | 15 | if mp.get_property_bool("pause") then 16 | atsl("(Paused) ") 17 | elseif mp.get_property_bool("paused-for-cache") then 18 | atsl("(Buffering) ") 19 | end 20 | 21 | if mp.get_property("vid") ~= "no" then 22 | atsl("A") 23 | end 24 | if mp.get_property("aid") ~= "no" then 25 | atsl("V") 26 | end 27 | 28 | atsl(": ") 29 | 30 | atsl(mp.get_property_osd("time-pos")) 31 | 32 | atsl(" / "); 33 | atsl(mp.get_property_osd("duration")); 34 | 35 | atsl(" (") 36 | atsl(mp.get_property_osd("percent-pos", -1)) 37 | atsl("%)") 38 | 39 | local r = mp.get_property_number("speed", -1) 40 | if r ~= 1 then 41 | atsl(string.format(" x%4.2f", r)) 42 | end 43 | 44 | r = mp.get_property_number("avsync", nil) 45 | if r ~= nil then 46 | atsl(string.format(" A-V: %7.3f", r)) 47 | end 48 | 49 | r = mp.get_property("total-avsync-change", 0) 50 | if math.abs(r) > 0.05 then 51 | atsl(string.format(" ct:%7.3f", r)) 52 | end 53 | 54 | r = mp.get_property_number("drop-frame-count", -1) 55 | if r > 0 then 56 | atsl(" Late: ") 57 | atsl(r) 58 | end 59 | 60 | r = mp.get_property_number("cache", 0) 61 | if r > 0 then 62 | atsl(string.format(" Cache: %d%% ", r)) 63 | end 64 | 65 | -- Set the new status line 66 | mp.set_property("options/term-status-msg", newStatus) 67 | end 68 | 69 | -- Register the event 70 | mp.register_event("tick", update_status_line) 71 | 72 | -------------------------------------------------------------------------------- /TOOLS/osxbundle/mpv.app/Contents/MacOS/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/TOOLS/osxbundle/mpv.app/Contents/MacOS/.gitkeep -------------------------------------------------------------------------------- /TOOLS/osxbundle/mpv.app/Contents/MacOS/lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/TOOLS/osxbundle/mpv.app/Contents/MacOS/lib/.gitkeep -------------------------------------------------------------------------------- /TOOLS/osxbundle/mpv.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /TOOLS/osxbundle/mpv.app/Contents/Resources/document.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/TOOLS/osxbundle/mpv.app/Contents/Resources/document.icns -------------------------------------------------------------------------------- /TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns -------------------------------------------------------------------------------- /TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf: -------------------------------------------------------------------------------- 1 | profile=pseudo-gui 2 | -------------------------------------------------------------------------------- /TOOLS/vf_dlopen/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2012 Rudolf Polzer 3 | # 4 | # This file is part of mpv's vf_dlopen examples. 5 | # 6 | # mpv's vf_dlopen examples are free software; you can redistribute them and/or 7 | # modify them under the terms of the GNU Lesser General Public License as 8 | # published by the Free Software Foundation; either version 2.1 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # mpv's vf_dlopen examples are distributed in the hope that they will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with mpv's vf_dlopen examples; if not, write to the Free 18 | # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | # 02110-1301 USA 20 | # 21 | 22 | FILTERS = telecine tile rectangle framestep ildetect 23 | COMMON = filterutils.o 24 | 25 | OBJECTS = $(patsubst %,%.o,$(FILTERS)) $(COMMON) 26 | HEADERS = $(wildcard *.h) 27 | OUT = $(patsubst %,%.so,$(FILTERS)) 28 | 29 | CFLAGS ?= -Wall -Wextra -O3 -march=native -mtune=native -ffast-math 30 | 31 | CPPFLAGS += -I../../video/filter 32 | CFLAGS += -fPIC 33 | LDFLAGS += -shared -fPIC 34 | 35 | ifneq ($(LTO),) 36 | CFLAGS += -flto 37 | LDFLAGS += $(CFLAGS) -flto 38 | endif 39 | 40 | all: $(OUT) 41 | 42 | clean: 43 | $(RM) $(OBJECTS) $(OUT) 44 | 45 | %.so: %.o $(COMMON) 46 | $(CC) $(LDFLAGS) $(LIBS) -o $@ $(COMMON) $< 47 | 48 | # FIXME replace this by real dependency tracking 49 | %.o: %.c $(HEADERS) 50 | 51 | -------------------------------------------------------------------------------- /TOOLS/vf_dlopen/filterutils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Rudolf Polzer 3 | * 4 | * This file is part of mpv's vf_dlopen examples. 5 | * 6 | * mpv's vf_dlopen examples are free software; you can redistribute them and/or 7 | * modify them under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation; either version 2.1 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * mpv's vf_dlopen examples are distributed in the hope that they will be 12 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with mpv's vf_dlopen examples; if not, write to the Free 18 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | * 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "filterutils.h" 26 | 27 | void copy_plane( 28 | unsigned char *dest, unsigned dest_stride, 29 | const unsigned char *src, unsigned src_stride, 30 | unsigned length, 31 | unsigned rows 32 | ) 33 | { 34 | unsigned i; 35 | assert(dest_stride >= length); 36 | assert(src_stride >= length); 37 | for (i = 0; i < rows; ++i) 38 | memcpy(&dest[dest_stride * i], &src[src_stride * i], length); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /TOOLS/vf_dlopen/filterutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Rudolf Polzer 3 | * 4 | * This file is part of mpv's vf_dlopen examples. 5 | * 6 | * mpv's vf_dlopen examples are free software; you can redistribute them and/or 7 | * modify them under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation; either version 2.1 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * mpv's vf_dlopen examples are distributed in the hope that they will be 12 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with mpv's vf_dlopen examples; if not, write to the Free 18 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | * 02110-1301 USA 20 | */ 21 | 22 | void copy_plane( 23 | unsigned char *dest, unsigned dest_stride, 24 | const unsigned char *src, unsigned src_stride, 25 | unsigned length, 26 | unsigned rows 27 | ); 28 | -------------------------------------------------------------------------------- /audio/chmap_sel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_CHMAP_SEL_H 19 | #define MP_CHMAP_SEL_H 20 | 21 | #include 22 | 23 | #include "chmap.h" 24 | 25 | struct mp_chmap_sel { 26 | // should be considered opaque 27 | bool allow_any, allow_waveext; 28 | bool speakers[MP_SPEAKER_ID_COUNT]; 29 | struct mp_chmap *chmaps; 30 | int num_chmaps; 31 | 32 | struct mp_chmap chmaps_storage[20]; 33 | 34 | void *tmp; // set to any talloc context to allow more chmaps entries 35 | }; 36 | 37 | void mp_chmap_sel_add_any(struct mp_chmap_sel *s); 38 | void mp_chmap_sel_add_waveext(struct mp_chmap_sel *s); 39 | void mp_chmap_sel_add_waveext_def(struct mp_chmap_sel *s); 40 | void mp_chmap_sel_add_map(struct mp_chmap_sel *s, const struct mp_chmap *map); 41 | void mp_chmap_sel_add_speaker(struct mp_chmap_sel *s, int id); 42 | bool mp_chmap_sel_adjust(const struct mp_chmap_sel *s, struct mp_chmap *map); 43 | bool mp_chmap_sel_fallback(const struct mp_chmap_sel *s, struct mp_chmap *map); 44 | bool mp_chmap_sel_get_def(const struct mp_chmap_sel *s, struct mp_chmap *map, 45 | int num); 46 | 47 | struct mp_log; 48 | void mp_chmal_sel_log(const struct mp_chmap_sel *s, struct mp_log *log, int lev); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /audio/decode/ad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_AD_H 19 | #define MPLAYER_AD_H 20 | 21 | #include "common/codecs.h" 22 | #include "demux/stheader.h" 23 | #include "demux/demux.h" 24 | 25 | #include "audio/format.h" 26 | #include "audio/audio.h" 27 | #include "dec_audio.h" 28 | 29 | struct mp_decoder_list; 30 | 31 | /* interface of video decoder drivers */ 32 | struct ad_functions { 33 | const char *name; 34 | void (*add_decoders)(struct mp_decoder_list *list); 35 | int (*init)(struct dec_audio *da, const char *decoder); 36 | void (*uninit)(struct dec_audio *da); 37 | int (*control)(struct dec_audio *da, int cmd, void *arg); 38 | int (*decode_packet)(struct dec_audio *da, struct demux_packet *pkt, 39 | struct mp_audio **out); 40 | }; 41 | 42 | enum ad_ctrl { 43 | ADCTRL_RESET = 1, // flush and reset state, e.g. after seeking 44 | }; 45 | 46 | #endif /* MPLAYER_AD_H */ 47 | -------------------------------------------------------------------------------- /audio/decode/dec_audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_DEC_AUDIO_H 19 | #define MPLAYER_DEC_AUDIO_H 20 | 21 | #include "audio/chmap.h" 22 | #include "audio/audio.h" 23 | #include "demux/demux.h" 24 | #include "demux/stheader.h" 25 | 26 | struct mp_audio_buffer; 27 | struct mp_decoder_list; 28 | 29 | struct dec_audio { 30 | struct mp_log *log; 31 | struct MPOpts *opts; 32 | struct mpv_global *global; 33 | const struct ad_functions *ad_driver; 34 | struct sh_stream *header; 35 | char *decoder_desc; 36 | 37 | bool try_spdif; 38 | 39 | // set every time a jump in timestamps is encountered 40 | bool pts_reset; 41 | 42 | // For free use by the ad_driver 43 | void *priv; 44 | 45 | // Strictly internal (dec_audio.c). 46 | 47 | double pts; // endpts of previous frame 48 | struct demux_packet *packet; 49 | struct mp_audio *current_frame; 50 | int current_state; 51 | }; 52 | 53 | struct mp_decoder_list *audio_decoder_list(void); 54 | int audio_init_best_codec(struct dec_audio *d_audio); 55 | void audio_uninit(struct dec_audio *d_audio); 56 | 57 | void audio_work(struct dec_audio *d_audio); 58 | 59 | #define AUDIO_OK 1 60 | #define AUDIO_WAIT 0 61 | #define AUDIO_EOF -1 62 | #define AUDIO_SKIP -2 63 | int audio_get_frame(struct dec_audio *d_audio, struct mp_audio **out_frame); 64 | 65 | void audio_reset_decoding(struct dec_audio *d_audio); 66 | 67 | #endif /* MPLAYER_DEC_AUDIO_H */ 68 | -------------------------------------------------------------------------------- /audio/filter/equalizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Anders Johansson ajh@atri.curtin.edu.au 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | #ifndef MPLAYER_EQUALIZER_H 21 | #define MPLAYER_EQUALIZER_H 22 | 23 | /* Equalizer plugin header file defines struct used for setting or 24 | getting the gain of a specific channel and frequency */ 25 | 26 | typedef struct equalizer_s 27 | { 28 | float gain; // Gain in dB -15 - 15 29 | int channel; // Channel number 0 - 5 30 | int band; // Frequency band 0 - 9 31 | }equalizer_t; 32 | 33 | /* The different frequency bands are: 34 | nr. center frequency 35 | 0 31.25 Hz 36 | 1 62.50 Hz 37 | 2 125.0 Hz 38 | 3 250.0 Hz 39 | 4 500.0 Hz 40 | 5 1.000 kHz 41 | 6 2.000 kHz 42 | 7 4.000 kHz 43 | 8 8.000 kHz 44 | 9 16.00 kHz 45 | */ 46 | 47 | #endif /* MPLAYER_EQUALIZER_H */ 48 | -------------------------------------------------------------------------------- /audio/fmt-conversion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include "format.h" 21 | #include "fmt-conversion.h" 22 | 23 | static const struct { 24 | enum AVSampleFormat sample_fmt; 25 | int fmt; 26 | } audio_conversion_map[] = { 27 | {AV_SAMPLE_FMT_U8, AF_FORMAT_U8}, 28 | {AV_SAMPLE_FMT_S16, AF_FORMAT_S16}, 29 | {AV_SAMPLE_FMT_S32, AF_FORMAT_S32}, 30 | {AV_SAMPLE_FMT_FLT, AF_FORMAT_FLOAT}, 31 | {AV_SAMPLE_FMT_DBL, AF_FORMAT_DOUBLE}, 32 | 33 | {AV_SAMPLE_FMT_U8P, AF_FORMAT_U8P}, 34 | {AV_SAMPLE_FMT_S16P, AF_FORMAT_S16P}, 35 | {AV_SAMPLE_FMT_S32P, AF_FORMAT_S32P}, 36 | {AV_SAMPLE_FMT_FLTP, AF_FORMAT_FLOATP}, 37 | {AV_SAMPLE_FMT_DBLP, AF_FORMAT_DOUBLEP}, 38 | 39 | {AV_SAMPLE_FMT_NONE, 0}, 40 | }; 41 | 42 | enum AVSampleFormat af_to_avformat(int fmt) 43 | { 44 | for (int i = 0; audio_conversion_map[i].fmt; i++) { 45 | if (audio_conversion_map[i].fmt == fmt) 46 | return audio_conversion_map[i].sample_fmt; 47 | } 48 | return AV_SAMPLE_FMT_NONE; 49 | } 50 | 51 | int af_from_avformat(enum AVSampleFormat sample_fmt) 52 | { 53 | for (int i = 0; audio_conversion_map[i].fmt; i++) { 54 | if (audio_conversion_map[i].sample_fmt == sample_fmt) 55 | return audio_conversion_map[i].fmt; 56 | } 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /audio/fmt-conversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_SAMPLE_FMT_CONVERSION_H 19 | #define MPLAYER_SAMPLE_FMT_CONVERSION_H 20 | 21 | enum AVSampleFormat af_to_avformat(int fmt); 22 | int af_from_avformat(enum AVSampleFormat sample_fmt); 23 | 24 | #endif /* MPLAYER_SAMPLE_FMT_CONVERSION_H */ 25 | -------------------------------------------------------------------------------- /audio/mixer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_MIXER_H 19 | #define MPLAYER_MIXER_H 20 | 21 | #include 22 | 23 | // Values of MPOpts.softvol 24 | enum { 25 | SOFTVOL_NO = 0, 26 | SOFTVOL_YES = 1, 27 | SOFTVOL_AUTO = 2, 28 | }; 29 | 30 | struct mpv_global; 31 | struct ao; 32 | struct af_stream; 33 | struct mixer; 34 | 35 | struct mixer *mixer_init(void *talloc_ctx, struct mpv_global *global); 36 | void mixer_reinit_audio(struct mixer *mixer, struct ao *ao, struct af_stream *af); 37 | void mixer_uninit_audio(struct mixer *mixer); 38 | bool mixer_audio_initialized(struct mixer *mixer); 39 | void mixer_getvolume(struct mixer *mixer, float *l, float *r); 40 | void mixer_setvolume(struct mixer *mixer, float l, float r); 41 | void mixer_addvolume(struct mixer *mixer, float step); 42 | void mixer_getbothvolume(struct mixer *mixer, float *b); 43 | void mixer_setmute(struct mixer *mixer, bool mute); 44 | bool mixer_getmute(struct mixer *mixer); 45 | void mixer_getbalance(struct mixer *mixer, float *bal); 46 | void mixer_setbalance(struct mixer *mixer, float bal); 47 | float mixer_getmaxvolume(struct mixer *mixer); 48 | char *mixer_get_volume_restore_data(struct mixer *mixer); 49 | 50 | #endif /* MPLAYER_MIXER_H */ 51 | -------------------------------------------------------------------------------- /audio/out/ao_coreaudio_chmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPV_COREAUDIO_CHMAP_H 19 | #define MPV_COREAUDIO_CHMAP_H 20 | 21 | #include 22 | 23 | struct mp_chmap; 24 | 25 | bool ca_init_chmap(struct ao *ao, AudioDeviceID device); 26 | void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count, 27 | struct mp_chmap *out_map); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /bootstrap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This script simply downloads waf to the current directory 4 | 5 | from __future__ import print_function 6 | import os, sys, stat, hashlib, subprocess 7 | 8 | WAFRELEASE = "waf-1.8.12" 9 | WAFURLS = ["https://waf.io/" + WAFRELEASE, 10 | "http://www.freehackers.org/~tnagy/release/" + WAFRELEASE] 11 | SHA256HASH = "01bf2beab2106d1558800c8709bc2c8e496d3da4a2ca343fe091f22fca60c98b" 12 | 13 | if os.path.exists("waf"): 14 | wafver = subprocess.check_output([sys.executable, './waf', '--version']).decode() 15 | if WAFRELEASE.split('-')[1] == wafver.split(' ')[1]: 16 | print("Found 'waf', skipping download.") 17 | sys.exit(0) 18 | 19 | try: 20 | from urllib.request import urlopen, URLError 21 | except: 22 | from urllib2 import urlopen, URLError 23 | 24 | waf = None 25 | 26 | for WAFURL in WAFURLS: 27 | try: 28 | print("Downloading {}...".format(WAFURL)) 29 | waf = urlopen(WAFURL).read() 30 | break 31 | except URLError: 32 | print("Download failed.") 33 | 34 | if not waf: 35 | print("Could not download {}.".format(WAFRELEASE)) 36 | 37 | sys.exit(1) 38 | 39 | if SHA256HASH == hashlib.sha256(waf).hexdigest(): 40 | with open("waf", "wb") as wf: 41 | wf.write(waf) 42 | 43 | os.chmod("waf", os.stat("waf").st_mode | stat.S_IXUSR) 44 | print("Checksum verified.") 45 | else: 46 | print("The checksum of the downloaded file does not match!") 47 | print(" - got: {}".format(hashlib.sha256(waf).hexdigest())) 48 | print(" - expected: {}".format(SHA256HASH)) 49 | print("Please download and verify the file manually.") 50 | 51 | sys.exit(1) 52 | -------------------------------------------------------------------------------- /common/av_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_AVCOMMON_H 19 | #define MP_AVCOMMON_H 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | struct mp_decoder_list; 28 | struct demux_packet; 29 | struct AVDictionary; 30 | struct mp_log; 31 | 32 | int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size); 33 | void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st); 34 | void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb); 35 | int64_t mp_pts_to_av(double mp_pts, AVRational *tb); 36 | double mp_pts_from_av(int64_t av_pts, AVRational *tb); 37 | void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads); 38 | void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type); 39 | int mp_codec_to_av_codec_id(const char *codec); 40 | const char *mp_codec_from_av_codec_id(int codec_id); 41 | void mp_set_avdict(struct AVDictionary **dict, char **kv); 42 | void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d); 43 | int mp_set_avopts(struct mp_log *log, void *avobj, char **kv); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /common/av_log.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_AV_LOG_H 2 | #define MP_AV_LOG_H 3 | struct mpv_global; 4 | struct mp_log; 5 | void init_libav(struct mpv_global *global); 6 | void uninit_libav(struct mpv_global *global); 7 | void print_libav_versions(struct mp_log *log, int v); 8 | #endif 9 | -------------------------------------------------------------------------------- /common/codecs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_CODECS_H 19 | #define MP_CODECS_H 20 | 21 | struct mp_decoder_entry { 22 | const char *family; // decoder module (e.g. ad_lavc => "lavc") 23 | const char *codec; // name of the codec (e.g. "mp3") 24 | const char *decoder; // decoder name (e.g. "mp3float") 25 | const char *desc; // human readable description 26 | }; 27 | 28 | struct mp_decoder_list { 29 | struct mp_decoder_entry *entries; 30 | int num_entries; 31 | }; 32 | 33 | void mp_add_decoder(struct mp_decoder_list *list, const char *family, 34 | const char *codec, const char *decoder, const char *desc); 35 | 36 | struct mp_decoder_list *mp_select_decoders(struct mp_decoder_list *all, 37 | const char *codec, 38 | const char *selection); 39 | 40 | struct mp_decoder_list *mp_select_decoder_list(struct mp_decoder_list *all, 41 | const char *codec, 42 | const char *family, 43 | const char *selection); 44 | 45 | void mp_append_decoders(struct mp_decoder_list *list, struct mp_decoder_list *a); 46 | 47 | struct mp_log; 48 | void mp_print_decoders(struct mp_log *log, int msgl, const char *header, 49 | struct mp_decoder_list *list); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /common/encode.h: -------------------------------------------------------------------------------- 1 | #ifndef MPLAYER_ENCODE_H 2 | #define MPLAYER_ENCODE_H 3 | 4 | #include 5 | 6 | #include "demux/demux.h" 7 | 8 | struct mpv_global; 9 | struct mp_log; 10 | struct encode_lavc_context; 11 | 12 | struct encode_opts { 13 | char *file; 14 | char *format; 15 | char **fopts; 16 | float fps; 17 | float maxfps; 18 | char *vcodec; 19 | char **vopts; 20 | char *acodec; 21 | char **aopts; 22 | int harddup; 23 | float voffset; 24 | float aoffset; 25 | int copyts; 26 | int rawts; 27 | int autofps; 28 | int neverdrop; 29 | int video_first; 30 | int audio_first; 31 | int metadata; 32 | }; 33 | 34 | // interface for mplayer.c 35 | struct encode_lavc_context *encode_lavc_init(struct encode_opts *options, 36 | struct mpv_global *global); 37 | void encode_lavc_finish(struct encode_lavc_context *ctx); 38 | void encode_lavc_free(struct encode_lavc_context *ctx); 39 | void encode_lavc_discontinuity(struct encode_lavc_context *ctx); 40 | bool encode_lavc_showhelp(struct mp_log *log, struct encode_opts *options); 41 | int encode_lavc_getstatus(struct encode_lavc_context *ctx, char *buf, int bufsize, float relative_position); 42 | void encode_lavc_expect_stream(struct encode_lavc_context *ctx, int mt); 43 | void encode_lavc_set_metadata(struct encode_lavc_context *ctx, 44 | struct mp_tags *metadata); 45 | void encode_lavc_set_video_fps(struct encode_lavc_context *ctx, float fps); 46 | void encode_lavc_set_audio_pts(struct encode_lavc_context *ctx, double pts); 47 | bool encode_lavc_didfail(struct encode_lavc_context *ctx); // check if encoding failed 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /common/global.h: -------------------------------------------------------------------------------- 1 | #ifndef MPV_MPV_H 2 | #define MPV_MPV_H 3 | 4 | // This should be accessed by glue code only, never normal code. 5 | // The only purpose of this is to make mpv library-safe. 6 | // Think hard before adding new members. 7 | struct mpv_global { 8 | struct MPOpts *opts; 9 | struct mp_log *log; 10 | struct mp_client_api *client_api; 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /common/msg_control.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_MSG_CONTROL_H 2 | #define MP_MSG_CONTROL_H 3 | 4 | #include 5 | 6 | struct mpv_global; 7 | void mp_msg_init(struct mpv_global *global); 8 | void mp_msg_uninit(struct mpv_global *global); 9 | void mp_msg_update_msglevels(struct mpv_global *global); 10 | void mp_msg_force_stderr(struct mpv_global *global, bool force_stderr); 11 | bool mp_msg_has_status_line(struct mpv_global *global); 12 | 13 | void mp_msg_flush_status_line(struct mp_log *log); 14 | 15 | struct mp_log_buffer_entry { 16 | char *prefix; 17 | int level; 18 | char *text; 19 | }; 20 | 21 | // Use --msg-level option for log level of this log buffer 22 | #define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1) 23 | 24 | struct mp_log_buffer; 25 | struct mp_log_buffer *mp_msg_log_buffer_new(struct mpv_global *global, 26 | int size, int level, 27 | void (*wakeup_cb)(void *ctx), 28 | void *wakeup_cb_ctx); 29 | void mp_msg_log_buffer_destroy(struct mp_log_buffer *buffer); 30 | struct mp_log_buffer_entry *mp_msg_log_buffer_read(struct mp_log_buffer *buffer); 31 | 32 | int mp_msg_open_stats_file(struct mpv_global *global, const char *path); 33 | int mp_msg_find_level(const char *s); 34 | 35 | extern const char *const mp_log_levels[MSGL_MAX + 1]; 36 | extern const int mp_mpv_log_levels[MSGL_MAX + 1]; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /common/tags.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_TAGS_H 2 | #define MP_TAGS_H 3 | 4 | #include "misc/bstr.h" 5 | 6 | struct mp_tags { 7 | char **keys; 8 | char **values; 9 | int num_keys; 10 | }; 11 | 12 | void mp_tags_set_str(struct mp_tags *tags, const char *key, const char *value); 13 | void mp_tags_set_bstr(struct mp_tags *tags, bstr key, bstr value); 14 | char *mp_tags_get_str(struct mp_tags *tags, const char *key); 15 | char *mp_tags_get_bstr(struct mp_tags *tags, bstr key); 16 | void mp_tags_clear(struct mp_tags *tags); 17 | struct mp_tags *mp_tags_dup(void *tparent, struct mp_tags *tags); 18 | struct mp_tags *mp_tags_filtered(void *tparent, struct mp_tags *tags, char **list); 19 | void mp_tags_merge(struct mp_tags *tags, struct mp_tags *src); 20 | struct AVDictionary; 21 | void mp_tags_copy_from_av_dictionary(struct mp_tags *tags, 22 | struct AVDictionary *av_dict); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /common/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include "common.h" 19 | #include "version.h" 20 | #ifdef NO_BUILD_TIMESTAMPS 21 | #undef BUILDDATE 22 | #define BUILDDATE "UNKNOWN" 23 | #endif 24 | 25 | const char *const mpv_version = "mpv " VERSION; 26 | const char *const mpv_builddate = BUILDDATE; 27 | -------------------------------------------------------------------------------- /demux/codec_tags.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_CODEC_TAGS_H 19 | #define MP_CODEC_TAGS_H 20 | 21 | #include 22 | #include 23 | 24 | struct mp_codec_params; 25 | 26 | void mp_set_codec_from_tag(struct mp_codec_params *c); 27 | 28 | void mp_set_pcm_codec(struct mp_codec_params *c, bool sign, bool is_float, 29 | int bits, bool is_be); 30 | 31 | const char *mp_map_mimetype_to_video_codec(const char *mimetype); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /demux/cue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_CUE_H_ 19 | #define MP_CUE_H_ 20 | 21 | #include 22 | 23 | #include "misc/bstr.h" 24 | 25 | struct cue_file { 26 | struct cue_track *tracks; 27 | int num_tracks; 28 | struct mp_tags *tags; 29 | }; 30 | 31 | struct cue_track { 32 | double pregap_start; // corresponds to INDEX 00 33 | double start; // corresponds to INDEX 01 34 | char *filename; 35 | int source; 36 | struct mp_tags *tags; 37 | }; 38 | 39 | bool mp_probe_cue(struct bstr data); 40 | struct cue_file *mp_parse_cue(struct bstr data); 41 | int mp_check_embedded_cue(struct cue_file *f); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /demux/demux_rar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include "common/common.h" 19 | #include "common/playlist.h" 20 | #include "stream/stream.h" 21 | #include "stream/rar.h" 22 | #include "demux.h" 23 | 24 | static int open_file(struct demuxer *demuxer, enum demux_check check) 25 | { 26 | if (RarProbe(demuxer->stream)) 27 | return -1; 28 | 29 | int count; 30 | rar_file_t **files; 31 | if (RarParse(demuxer->stream, &count, &files)) 32 | return -1; 33 | 34 | void *tmp = talloc_new(NULL); 35 | talloc_steal(tmp, files); 36 | 37 | struct playlist *pl = talloc_zero(demuxer, struct playlist); 38 | demuxer->playlist = pl; 39 | 40 | // make it load rar:// 41 | pl->disable_safety = true; 42 | 43 | char *prefix = mp_url_escape(tmp, demuxer->stream->url, "~|"); 44 | for (int n = 0; n < count; n++) { 45 | // stream_rar.c does the real work 46 | playlist_add_file(pl, 47 | talloc_asprintf(tmp, "rar://%s|%s", prefix, files[n]->name)); 48 | RarFileDelete(files[n]); 49 | } 50 | 51 | demuxer->filetype = "rar"; 52 | demuxer->fully_read = true; 53 | 54 | talloc_free(tmp); 55 | return 0; 56 | } 57 | 58 | const struct demuxer_desc demuxer_desc_rar = { 59 | .name = "rar", 60 | .desc = "Rar archive file", 61 | .open = open_file, 62 | }; 63 | -------------------------------------------------------------------------------- /demux/matroska.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_MATROSKA_H 19 | #define MPLAYER_MATROSKA_H 20 | 21 | struct timeline; 22 | void build_ordered_chapter_timeline(struct timeline *tl); 23 | 24 | #endif /* MPLAYER_MATROSKA_H */ 25 | -------------------------------------------------------------------------------- /demux/packet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_DEMUX_PACKET_H 19 | #define MPLAYER_DEMUX_PACKET_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | // Holds one packet/frame/whatever 26 | typedef struct demux_packet { 27 | int len; 28 | double pts; 29 | double dts; 30 | double duration; 31 | int64_t pos; // position in source file byte stream 32 | unsigned char *buffer; 33 | bool keyframe; 34 | int stream; // source stream index 35 | struct demux_packet *next; 36 | struct AVPacket *avpacket; // keep the buffer allocation 37 | } demux_packet_t; 38 | 39 | struct demux_packet *new_demux_packet(size_t len); 40 | struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt); 41 | struct demux_packet *new_demux_packet_from(void *data, size_t len); 42 | void demux_packet_shorten(struct demux_packet *dp, size_t len); 43 | void free_demux_packet(struct demux_packet *dp); 44 | struct demux_packet *demux_copy_packet(struct demux_packet *dp); 45 | 46 | void demux_packet_copy_attribs(struct demux_packet *dst, struct demux_packet *src); 47 | 48 | int demux_packet_set_padding(struct demux_packet *dp, int start, int end); 49 | 50 | #endif /* MPLAYER_DEMUX_PACKET_H */ 51 | -------------------------------------------------------------------------------- /demux/timeline.c: -------------------------------------------------------------------------------- 1 | #include "common/common.h" 2 | #include "stream/stream.h" 3 | #include "demux.h" 4 | 5 | #include "timeline.h" 6 | 7 | struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log, 8 | struct demuxer *demuxer) 9 | { 10 | if (!demuxer->desc->load_timeline) 11 | return NULL; 12 | 13 | struct timeline *tl = talloc_ptrtype(NULL, tl); 14 | *tl = (struct timeline){ 15 | .global = global, 16 | .log = log, 17 | .cancel = demuxer->stream->cancel, 18 | .demuxer = demuxer, 19 | .track_layout = demuxer, 20 | }; 21 | 22 | demuxer->desc->load_timeline(tl); 23 | 24 | if (tl->num_parts) 25 | return tl; 26 | timeline_destroy(tl); 27 | return NULL; 28 | } 29 | 30 | void timeline_destroy(struct timeline *tl) 31 | { 32 | if (!tl) 33 | return; 34 | for (int n = 0; n < tl->num_sources; n++) { 35 | struct demuxer *d = tl->sources[n]; 36 | if (d != tl->demuxer) 37 | free_demuxer_and_stream(d); 38 | } 39 | talloc_free(tl); 40 | } 41 | -------------------------------------------------------------------------------- /demux/timeline.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_TIMELINE_H_ 2 | #define MP_TIMELINE_H_ 3 | 4 | struct timeline_part { 5 | double start; 6 | double source_start; 7 | struct demuxer *source; 8 | }; 9 | 10 | struct timeline { 11 | struct mpv_global *global; 12 | struct mp_log *log; 13 | struct mp_cancel *cancel; 14 | 15 | // main source 16 | struct demuxer *demuxer; 17 | 18 | // All referenced files. The source file must be at sources[0]. 19 | struct demuxer **sources; 20 | int num_sources; 21 | 22 | // Segments to play, ordered by time. parts[num_parts] must be valid; its 23 | // start field sets the duration, and source must be NULL. 24 | struct timeline_part *parts; 25 | int num_parts; 26 | 27 | struct demux_chapter *chapters; 28 | int num_chapters; 29 | 30 | // Which source defines the overall track list (over the full timeline). 31 | struct demuxer *track_layout; 32 | }; 33 | 34 | struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log, 35 | struct demuxer *demuxer); 36 | void timeline_destroy(struct timeline *tl); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /etc/mpv-icon-8bit-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/etc/mpv-icon-8bit-16x16.png -------------------------------------------------------------------------------- /etc/mpv-icon-8bit-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/etc/mpv-icon-8bit-32x32.png -------------------------------------------------------------------------------- /etc/mpv-icon-8bit-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/etc/mpv-icon-8bit-64x64.png -------------------------------------------------------------------------------- /etc/mpv-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/etc/mpv-icon.ico -------------------------------------------------------------------------------- /etc/mpv.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=mpv Media Player 4 | Name[ca]=Reproductor multimèdia mpv 5 | Name[cs]=mpv přehrávač 6 | Name[pl]=Odtwarzacz mpv 7 | Name[ru]=Проигрыватель mpv 8 | Name[zh-CN]=mpv 媒体播放器 9 | Name[zh-TW]=mpv 媒體播放器 10 | GenericName=Multimedia player 11 | GenericName[cs]=Multimediální přehrávač 12 | GenericName[zh-CN]=多媒体播放器 13 | GenericName[zh-TW]=多媒體播放器 14 | Comment=Play movies and songs 15 | Comment[ca]=Reproduïu vídeos i cançons 16 | Comment[cs]=Přehrává filmy a hudbu 17 | Comment[de]=Filme und Musik abspielen 18 | Comment[es]=Reproduzca vídeos y canciones 19 | Comment[fr]=Lecteur multimédia 20 | Comment[it]=Lettore multimediale 21 | Comment[pl]=Odtwarzaj filmy i muzykę 22 | Comment[ru]=Воспроизвести фильмы и музыку 23 | Comment[zh-CN]=播放电影和歌曲 24 | Comment[zh-TW]=播放電影和歌曲 25 | Icon=mpv 26 | TryExec=mpv 27 | Exec=mpv --profile=pseudo-gui -- %U 28 | Terminal=false 29 | Categories=AudioVideo;Audio;Video;Player;TV; 30 | MimeType=application/ogg;application/x-ogg;application/sdp;application/smil;application/x-smil;application/streamingmedia;application/x-streamingmedia;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/aac;audio/x-aac;audio/m4a;audio/x-m4a;audio/mp1;audio/x-mp1;audio/mp2;audio/x-mp2;audio/mp3;audio/x-mp3;audio/mpeg;audio/x-mpeg;audio/mpegurl;audio/x-mpegurl;audio/mpg;audio/x-mpg;audio/rn-mpeg;audio/ogg;audio/scpls;audio/x-scpls;audio/vnd.rn-realaudio;audio/wav;audio/x-pn-windows-pcm;audio/x-realaudio;audio/x-pn-realaudio;audio/x-ms-wma;audio/x-pls;audio/x-wav;video/mpeg;video/x-mpeg;video/x-mpeg2;video/mp4;video/msvideo;video/x-msvideo;video/ogg;video/quicktime;video/vnd.rn-realvideo;video/x-ms-afs;video/x-ms-asf;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvxvideo;video/x-avi;video/x-fli;video/x-flv;video/x-theora;video/x-matroska;video/webm;audio/x-flac;audio/x-vorbis+ogg;video/x-ogm+ogg;audio/x-shorten;audio/x-ape;audio/x-wavpack;audio/x-tta;audio/AMR;audio/ac3;video/mp2t;audio/flac;audio/mp4; 31 | X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb 32 | -------------------------------------------------------------------------------- /etc/restore-old-bindings.conf: -------------------------------------------------------------------------------- 1 | 2 | # This file contains all bindings that were removed after a certain release. 3 | # If you want MPlayer bindings, use mplayer-input.conf 4 | 5 | # Pick the bindings you want back and add them to your own input.conf. Append 6 | # this file to your input.conf if you want them all back: 7 | # 8 | # cat restore-old-bindings.conf >> ~/.config/mpv/input.conf 9 | # 10 | # Older installations use ~/.mpv/input.conf instead. 11 | 12 | # changed in mpv 0.10.0 13 | 14 | O osd 15 | D cycle deinterlace 16 | d cycle framedrop 17 | 18 | # changed in mpv 0.7.0 19 | 20 | ENTER playlist_next force 21 | 22 | # changed in mpv 0.6.0 23 | 24 | ESC quit 25 | 26 | # changed in mpv 0.5.0 27 | 28 | PGUP seek 600 29 | PGDWN seek -600 30 | RIGHT seek 10 31 | LEFT seek -10 32 | + add audio-delay 0.100 33 | - add audio-delay -0.100 34 | ( add balance -0.1 35 | ) add balance 0.1 36 | F cycle sub-forced-only 37 | TAB cycle program 38 | A cycle angle 39 | U stop 40 | o osd 41 | I show_text "${filename}" 42 | -------------------------------------------------------------------------------- /input/cmd_parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_PARSE_COMMAND_H 19 | #define MP_PARSE_COMMAND_H 20 | 21 | #include "misc/bstr.h" 22 | 23 | struct mp_log; 24 | struct mp_cmd; 25 | struct mpv_node; 26 | 27 | // Parse text and return corresponding struct mp_cmd. 28 | // The location parameter is for error messages. 29 | struct mp_cmd *mp_input_parse_cmd_(struct mp_log *log, bstr str, const char *loc); 30 | 31 | // Similar to mp_input_parse_cmd(), but takes a list of strings instead. 32 | // Also, MP_ON_OSD_AUTO | MP_EXPAND_PROPERTIES are not set by default. 33 | // Keep in mind that these functions (naturally) don't take multiple commands, 34 | // i.e. a ";" argument does not start a new command. 35 | struct mp_cmd *mp_input_parse_cmd_strv(struct mp_log *log, const char **argv); 36 | 37 | struct mp_cmd *mp_input_parse_cmd_node(struct mp_log *log, struct mpv_node *node); 38 | 39 | // After getting a command from mp_input_get_cmd you need to free it using this 40 | // function 41 | void mp_cmd_free(struct mp_cmd *cmd); 42 | 43 | void mp_cmd_dump(struct mp_log *log, int msgl, char *header, struct mp_cmd *cmd); 44 | 45 | // This creates a copy of a command (used by the auto repeat stuff). 46 | struct mp_cmd *mp_cmd_clone(struct mp_cmd *cmd); 47 | 48 | extern const struct m_option_type m_option_type_cycle_dir; 49 | 50 | #define OPT_CYCLEDIR(...) \ 51 | OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_cycle_dir) 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /input/event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include "misc/bstr.h" 19 | 20 | struct input_ctx; 21 | 22 | enum mp_dnd_action { 23 | DND_REPLACE, 24 | DND_APPEND, 25 | }; 26 | 27 | // Enqueue files for playback after drag and drop 28 | void mp_event_drop_files(struct input_ctx *ictx, int num_files, char **files, 29 | enum mp_dnd_action append); 30 | 31 | // Drop data in a specific format (identified by the mimetype). 32 | // Returns <0 on error, ==0 if data was ok but empty, >0 on success. 33 | int mp_event_drop_mime_data(struct input_ctx *ictx, const char *mime_type, 34 | bstr data, enum mp_dnd_action append); 35 | -------------------------------------------------------------------------------- /libmpv/mpv.def: -------------------------------------------------------------------------------- 1 | mpv_client_api_version 2 | mpv_client_name 3 | mpv_command 4 | mpv_command_async 5 | mpv_command_node 6 | mpv_command_node_async 7 | mpv_command_string 8 | mpv_create 9 | mpv_create_client 10 | mpv_detach_destroy 11 | mpv_error_string 12 | mpv_event_name 13 | mpv_free 14 | mpv_free_node_contents 15 | mpv_get_property 16 | mpv_get_property_async 17 | mpv_get_property_osd_string 18 | mpv_get_property_string 19 | mpv_get_sub_api 20 | mpv_get_time_us 21 | mpv_get_wakeup_pipe 22 | mpv_initialize 23 | mpv_load_config_file 24 | mpv_observe_property 25 | mpv_opengl_cb_draw 26 | mpv_opengl_cb_init_gl 27 | mpv_opengl_cb_report_flip 28 | mpv_opengl_cb_render 29 | mpv_opengl_cb_set_update_callback 30 | mpv_opengl_cb_uninit_gl 31 | mpv_request_event 32 | mpv_request_log_messages 33 | mpv_resume 34 | mpv_set_option 35 | mpv_set_option_string 36 | mpv_set_property 37 | mpv_set_property_async 38 | mpv_set_property_string 39 | mpv_set_wakeup_callback 40 | mpv_suspend 41 | mpv_terminate_destroy 42 | mpv_unobserve_property 43 | mpv_wait_async_requests 44 | mpv_wait_event 45 | mpv_wakeup -------------------------------------------------------------------------------- /libmpv/mpv.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PREFIX@ 2 | exec_prefix=@PREFIX@ 3 | libdir=@LIBDIR@ 4 | includedir=@INCDIR@ 5 | 6 | Name: mpv 7 | Description: mpv media player client library 8 | Version: @VERSION@ 9 | Requires: 10 | Libs: -L${libdir} -lmpv 11 | Libs.private: @PRIV_LIBS@ 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /misc/charset_conv.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_CHARSET_CONV_H 2 | #define MP_CHARSET_CONV_H 3 | 4 | #include 5 | #include "misc/bstr.h" 6 | 7 | struct mp_log; 8 | 9 | enum { 10 | MP_ICONV_VERBOSE = 1, // print errors instead of failing silently 11 | MP_ICONV_ALLOW_CUTOFF = 2, // allow partial input data 12 | MP_STRICT_UTF8 = 4, // don't fall back to UTF-8-BROKEN when guessing 13 | }; 14 | 15 | bool mp_charset_is_utf8(const char *user_cp); 16 | bool mp_charset_is_utf16(const char *user_cp); 17 | bool mp_charset_requires_guess(const char *user_cp); 18 | const char *mp_charset_guess(void *talloc_ctx, struct mp_log *log, bstr buf, 19 | const char *user_cp, int flags); 20 | bstr mp_iconv_to_utf8(struct mp_log *log, bstr buf, const char *cp, int flags); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /misc/ctype.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_CTYPE_H_ 2 | #define MP_CTYPE_H_ 3 | 4 | // Roughly follows C semantics, but doesn't account for EOF, allows char as 5 | // parameter, and is locale independent (always uses "C" locale). 6 | 7 | static inline int mp_isprint(char c) { return (unsigned char)c >= 32; } 8 | static inline int mp_isspace(char c) { return c == ' ' || c == '\f' || c == '\n' || 9 | c == '\r' || c == '\t' || c =='\v'; } 10 | static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; } 11 | static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; } 12 | static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; } 13 | static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); } 14 | static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); } 15 | 16 | static inline char mp_tolower(char c) { return mp_isupper(c) ? c - 'A' + 'a' : c; } 17 | static inline char mp_toupper(char c) { return mp_islower(c) ? c - 'a' + 'A' : c; } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /misc/dispatch.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_DISPATCH_H_ 2 | #define MP_DISPATCH_H_ 3 | 4 | typedef void (*mp_dispatch_fn)(void *data); 5 | struct mp_dispatch_queue; 6 | 7 | struct mp_dispatch_queue *mp_dispatch_create(void *talloc_parent); 8 | void mp_dispatch_set_wakeup_fn(struct mp_dispatch_queue *queue, 9 | void (*wakeup_fn)(void *wakeup_ctx), 10 | void *wakeup_ctx); 11 | void mp_dispatch_enqueue(struct mp_dispatch_queue *queue, 12 | mp_dispatch_fn fn, void *fn_data); 13 | void mp_dispatch_enqueue_autofree(struct mp_dispatch_queue *queue, 14 | mp_dispatch_fn fn, void *fn_data); 15 | void mp_dispatch_run(struct mp_dispatch_queue *queue, 16 | mp_dispatch_fn fn, void *fn_data); 17 | void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout); 18 | void mp_dispatch_suspend(struct mp_dispatch_queue *queue); 19 | void mp_dispatch_resume(struct mp_dispatch_queue *queue); 20 | void mp_dispatch_lock(struct mp_dispatch_queue *queue); 21 | void mp_dispatch_unlock(struct mp_dispatch_queue *queue); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /misc/json.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_JSON_H 19 | #define MP_JSON_H 20 | 21 | // We reuse mpv_node. 22 | #include "libmpv/client.h" 23 | 24 | int json_parse(void *ta_parent, struct mpv_node *dst, char **src, int max_depth); 25 | void json_skip_whitespace(char **src); 26 | int json_write(char **s, struct mpv_node *src); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /misc/rendezvous.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "rendezvous.h" 4 | 5 | static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; 6 | static pthread_cond_t wakeup = PTHREAD_COND_INITIALIZER; 7 | 8 | static struct waiter *waiters; 9 | 10 | struct waiter { 11 | void *tag; 12 | struct waiter *next; 13 | intptr_t *value; 14 | }; 15 | 16 | /* A barrier for 2 threads, which can exchange a value when they meet. 17 | * The first thread to call this function will block. As soon as two threads 18 | * are calling this function with the same tag value, they will unblock, and 19 | * on each thread the call return the value parameter of the _other_ thread. 20 | * 21 | * tag is an arbitrary value, but it must be an unique pointer. If there are 22 | * more than 2 threads using the same tag, things won't work. Typically, it 23 | * will have to point to a memory allocation or to the stack, while pointing 24 | * it to static data is always a bug. 25 | * 26 | * This shouldn't be used for performance critical code (uses a linked list 27 | * of _all_ waiters in the process, and temporarily wakes up _all_ waiters on 28 | * each second call). 29 | * 30 | * This is inspired by: http://9atom.org/magic/man2html/2/rendezvous */ 31 | intptr_t mp_rendezvous(void *tag, intptr_t value) 32 | { 33 | struct waiter wait = { .tag = tag, .value = &value }; 34 | pthread_mutex_lock(&lock); 35 | struct waiter **prev = &waiters; 36 | while (*prev) { 37 | if ((*prev)->tag == tag) { 38 | intptr_t tmp = *(*prev)->value; 39 | *(*prev)->value = value; 40 | value = tmp; 41 | (*prev)->value = NULL; // signals completion 42 | *prev = (*prev)->next; // unlink 43 | pthread_cond_broadcast(&wakeup); 44 | goto done; 45 | } 46 | prev = &(*prev)->next; 47 | } 48 | *prev = &wait; 49 | while (wait.value) 50 | pthread_cond_wait(&wakeup, &lock); 51 | done: 52 | pthread_mutex_unlock(&lock); 53 | return value; 54 | } 55 | -------------------------------------------------------------------------------- /misc/rendezvous.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_RENDEZVOUS_H_ 2 | #define MP_RENDEZVOUS_H_ 3 | 4 | #include 5 | 6 | intptr_t mp_rendezvous(void *tag, intptr_t value); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /mpv_talloc.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "osdep/compiler.h" 6 | 7 | #include "ta/ta_talloc.h" 8 | -------------------------------------------------------------------------------- /options/parse_commandline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_PARSER_MPCMD_H 19 | #define MPLAYER_PARSER_MPCMD_H 20 | 21 | #include 22 | 23 | struct playlist; 24 | struct m_config; 25 | struct mpv_global; 26 | 27 | int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, 28 | struct mpv_global *global, char **argv); 29 | void m_config_preparse_command_line(m_config_t *config, struct mpv_global *global, 30 | char **argv); 31 | 32 | #endif /* MPLAYER_PARSER_MPCMD_H */ 33 | -------------------------------------------------------------------------------- /options/parse_configfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_PARSER_CFG_H 19 | #define MPLAYER_PARSER_CFG_H 20 | 21 | #include "m_config.h" 22 | 23 | int m_config_parse_config_file(m_config_t* config, const char *conffile, 24 | char *initial_section, int flags); 25 | 26 | int m_config_parse(m_config_t *config, const char *location, bstr data, 27 | char *initial_section, int flags); 28 | 29 | #endif /* MPLAYER_PARSER_CFG_H */ 30 | -------------------------------------------------------------------------------- /osdep/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef MPV_COMPILER_H 2 | #define MPV_COMPILER_H 3 | 4 | #define MP_EXPAND_ARGS(...) __VA_ARGS__ 5 | 6 | #ifdef __GNUC__ 7 | 8 | #define MP_NORETURN __attribute__((noreturn)) 9 | 10 | /** Use gcc attribute to check printf fns. a1 is the 1-based index of 11 | * the parameter containing the format, and a2 the index of the first 12 | * argument. **/ 13 | #ifdef __MINGW32__ 14 | // MinGW maps "printf" to the non-standard MSVCRT functions, even if 15 | // __USE_MINGW_ANSI_STDIO is defined and set to 1. We need to use "gnu_printf", 16 | // which isn't necessarily available on other GCC compatible compilers. 17 | #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2))) 18 | #else 19 | #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (printf, a1, a2))) 20 | #endif 21 | 22 | #else 23 | #define PRINTF_ATTRIBUTE(a1, a2) 24 | #define MP_NORETURN 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /osdep/endian.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_ENDIAN_H_ 2 | #define MP_ENDIAN_H_ 3 | 4 | #include 5 | 6 | #if !defined(BYTE_ORDER) 7 | 8 | #if defined(__BYTE_ORDER) 9 | #define BYTE_ORDER __BYTE_ORDER 10 | #define LITTLE_ENDIAN __LITTLE_ENDIAN 11 | #define BIG_ENDIAN __BIG_ENDIAN 12 | #elif defined(__DARWIN_BYTE_ORDER) 13 | #define BYTE_ORDER __DARWIN_BYTE_ORDER 14 | #define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN 15 | #define BIG_ENDIAN __DARWIN_BIG_ENDIAN 16 | #else 17 | #include 18 | #if AV_HAVE_BIGENDIAN 19 | #define BYTE_ORDER 1234 20 | #define LITTLE_ENDIAN 4321 21 | #define BIG_ENDIAN 1234 22 | #else 23 | #define BYTE_ORDER 1234 24 | #define LITTLE_ENDIAN 1234 25 | #define BIG_ENDIAN 4321 26 | #endif 27 | #endif 28 | 29 | #endif /* !defined(BYTE_ORDER) */ 30 | 31 | #if BYTE_ORDER == BIG_ENDIAN 32 | #define MP_SELECT_LE_BE(LE, BE) BE 33 | #else 34 | #define MP_SELECT_LE_BE(LE, BE) LE 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /osdep/macosx_application.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPV_MACOSX_APPLICATION 19 | #define MPV_MACOSX_APPLICATION 20 | 21 | // Menu Keys identifing menu items 22 | typedef enum { 23 | MPM_H_SIZE, 24 | MPM_N_SIZE, 25 | MPM_D_SIZE, 26 | MPM_MINIMIZE, 27 | MPM_ZOOM, 28 | } MPMenuKey; 29 | 30 | // multithreaded wrapper for mpv_main 31 | int cocoa_main(int argc, char *argv[]); 32 | void cocoa_register_menu_item_action(MPMenuKey key, void* action); 33 | 34 | #endif /* MPV_MACOSX_APPLICATION */ 35 | -------------------------------------------------------------------------------- /osdep/macosx_application_objc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #import 19 | #include "osdep/macosx_application.h" 20 | 21 | @interface Application : NSApplication 22 | - (void)initialize_menu; 23 | - (void)registerSelector:(SEL)selector forKey:(MPMenuKey)key; 24 | - (void)stopPlayback; 25 | 26 | @property(nonatomic, retain) NSMutableDictionary *menuItems; 27 | @property(nonatomic, retain) NSArray *files; 28 | @property(nonatomic, assign) size_t openCount; 29 | @end 30 | -------------------------------------------------------------------------------- /osdep/macosx_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Application Event Handling 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | 21 | #ifndef MPV_MACOSX_COMPAT 22 | #define MPV_MACOSX_COMPAT 23 | 24 | #import 25 | #include "osdep/macosx_versions.h" 26 | 27 | #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8) 28 | @interface NSArray (SubscriptingAdditions) 29 | - (id)objectAtIndexedSubscript:(NSUInteger)index; 30 | @end 31 | 32 | @interface NSMutableArray (SubscriptingAdditions) 33 | - (void)setObject: (id)object atIndexedSubscript:(NSUInteger)index; 34 | @end 35 | 36 | @interface NSDictionary (SubscriptingAdditions) 37 | - (id)objectForKeyedSubscript:(id)key; 38 | @end 39 | 40 | @interface NSMutableDictionary (SubscriptingAdditions) 41 | - (void)setObject: (id)object forKeyedSubscript:(id)key; 42 | @end 43 | 44 | #if __has_feature(objc_bool) 45 | #define YES __objc_yes 46 | #define NO __objc_no 47 | #else 48 | #define YES ((BOOL)1) 49 | #define NO ((BOOL)0) 50 | #endif 51 | 52 | #endif 53 | 54 | #endif /* MPV_MACOSX_COMPAT */ 55 | -------------------------------------------------------------------------------- /osdep/macosx_events.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Cocoa Application Event Handling 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | #ifndef MACOSX_EVENTS_H 21 | #define MACOSX_EVENTS_H 22 | #include "input/keycodes.h" 23 | 24 | struct input_ctx; 25 | 26 | void cocoa_put_key(int keycode); 27 | void cocoa_put_key_with_modifiers(int keycode, int modifiers); 28 | void cocoa_put_key_event(void *event); 29 | 30 | void cocoa_start_event_monitor(void); 31 | 32 | void cocoa_init_apple_remote(void); 33 | void cocoa_uninit_apple_remote(void); 34 | 35 | void cocoa_init_media_keys(void); 36 | void cocoa_uninit_media_keys(void); 37 | 38 | void cocoa_set_input_context(struct input_ctx *input_context); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /osdep/macosx_events_objc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Cocoa Application Event Handling 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | #import 21 | #import "ar/HIDRemote.h" 22 | #include "osdep/macosx_events.h" 23 | 24 | struct input_ctx; 25 | 26 | @interface EventsResponder : NSObject 27 | 28 | + (EventsResponder *)sharedInstance; 29 | 30 | - (void)setInputContext:(struct input_ctx *)ctx; 31 | 32 | /// Blocks until inputContext is present. 33 | - (void)waitForInputContext; 34 | 35 | - (void)wakeup; 36 | 37 | - (bool)queueCommand:(char *)cmd; 38 | 39 | - (void)putKey:(int)keycode; 40 | 41 | - (void)handleFilesArray:(NSArray *)files; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /osdep/macosx_versions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPV_MACOSX_VERSIONS 19 | #define MPV_MACOSX_VERSIONS 20 | 21 | #if !defined(MAC_OS_X_VERSION_10_8) 22 | # define MAC_OS_X_VERSION_10_8 1080 23 | #endif 24 | 25 | #if !defined(MAC_OS_X_VERSION_10_9) 26 | # define MAC_OS_X_VERSION_10_9 1090 27 | #endif 28 | 29 | #endif /* MPV_MACOSX_VERSIONS */ 30 | -------------------------------------------------------------------------------- /osdep/main-fn-cocoa.c: -------------------------------------------------------------------------------- 1 | #include "osdep/macosx_application.h" 2 | 3 | // This is needed because Cocoa absolutely requires creating the NSApplication 4 | // singleton and running it in the "main" thread. It is apparently not 5 | // possible to do this on a separate thread at all. It is not known how 6 | // Apple managed this colossal fuckup. 7 | int main(int argc, char *argv[]) 8 | { 9 | return cocoa_main(argc, argv); 10 | } 11 | -------------------------------------------------------------------------------- /osdep/main-fn-unix.c: -------------------------------------------------------------------------------- 1 | #include "main-fn.h" 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | return mpv_main(argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /osdep/main-fn.h: -------------------------------------------------------------------------------- 1 | int mpv_main(int argc, char *argv[]); 2 | -------------------------------------------------------------------------------- /osdep/mpv.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | mpv - The Movie Player 10 | 11 | 12 | True/PM 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /osdep/mpv.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows resource file for mpv 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | #include 21 | #include "version.h" 22 | 23 | 1 VERSIONINFO 24 | FILEVERSION 2,0,0,0 25 | PRODUCTVERSION 2,0,0,0 26 | FILEOS VOS__WINDOWS32 27 | FILETYPE VFT_APP 28 | { 29 | BLOCK "StringFileInfo" 30 | { 31 | BLOCK "000004b0" // LANG_NEUTRAL,UNICODE_CP 32 | { 33 | VALUE "Comments","mpv is distributed under the terms of the GNU General Public License Version 2 or later.\000" 34 | VALUE "CompanyName", "mpv\000" 35 | VALUE "FileDescription", "mpv\000" 36 | VALUE "FileVersion",VERSION 37 | VALUE "LegalCopyright", " (C) 2000-2016 mpv/mplayer2/MPlayer\000" 38 | //VALUE "LegalTrademarks"," \000"; 39 | VALUE "OriginalFilename", "mpv.exe\000" 40 | VALUE "ProductName", "mpv\000" 41 | VALUE "ProductVersion",VERSION 42 | //VALUE "SpecialBuild","\000" 43 | } 44 | } 45 | BLOCK "VarFileInfo" 46 | { 47 | VALUE "Translation",0,0x04b0 48 | } 49 | } 50 | 51 | IDI_ICON1 ICON DISCARDABLE "etc/mpv-icon.ico" 52 | 53 | // for some reason RT_MANIFEST does not work 54 | 1 24 "mpv.exe.manifest" 55 | -------------------------------------------------------------------------------- /osdep/path-macosx.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #import 19 | #include "options/path.h" 20 | #include "osdep/path.h" 21 | 22 | const char *mp_get_platform_path_osx(void *talloc_ctx, const char *type) 23 | { 24 | if (strcmp(type, "osxbundle") == 0) { 25 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 26 | NSString *path = [[NSBundle mainBundle] resourcePath]; 27 | char *res = talloc_strdup(talloc_ctx, [path UTF8String]); 28 | [pool release]; 29 | return res; 30 | } 31 | if (strcmp(type, "desktop") == 0 && getenv("HOME")) 32 | return mp_path_join(talloc_ctx, getenv("HOME"), "Desktop"); 33 | return NULL; 34 | } 35 | -------------------------------------------------------------------------------- /osdep/path.h: -------------------------------------------------------------------------------- 1 | #ifndef OSDEP_PATH_H 2 | #define OSDEP_PATH_H 3 | 4 | // Return a platform-specific path, identified by the type parameter. If the 5 | // return value is allocated, talloc_ctx is used as talloc parent context. 6 | // 7 | // The following type values are defined: 8 | // "home" the native mpv-specific user config dir 9 | // "old_home" same as "home", but lesser priority (compatibility) 10 | // "osxbundle" OSX bundle resource path 11 | // "global" the least priority, global config file location 12 | // "desktop" path to desktop contents 13 | // 14 | // It is allowed to return a static string, so the caller must set talloc_ctx 15 | // to something other than NULL to avoid memory leaks. 16 | typedef const char *(*mp_get_platform_path_cb)(void *talloc_ctx, const char *type); 17 | 18 | // Conforming to mp_get_platform_path_cb. 19 | const char *mp_get_platform_path_win(void *talloc_ctx, const char *type); 20 | const char *mp_get_platform_path_osx(void *talloc_ctx, const char *type); 21 | const char *mp_get_platform_path_unix(void *talloc_ctx, const char *type); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /osdep/semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_SEMAPHORE_H_ 2 | #define MP_SEMAPHORE_H_ 3 | 4 | #include 5 | #include 6 | 7 | // OSX provides non-working empty stubs, so we emulate them. 8 | // This should be AS-safe, but cancellation issues were ignored. 9 | // sem_getvalue() is not provided. 10 | // sem_post() won't always correctly return an error on overflow. 11 | // Process-shared semantics are not provided. 12 | 13 | #ifdef __APPLE__ 14 | 15 | #define MP_SEMAPHORE_EMULATION 16 | 17 | #include 18 | 19 | #define MP_SEM_VALUE_MAX 4096 20 | 21 | typedef struct { 22 | int wakeup_pipe[2]; 23 | pthread_mutex_t lock; 24 | // protected by lock 25 | unsigned int count; 26 | } mp_sem_t; 27 | 28 | int mp_sem_init(mp_sem_t *sem, int pshared, unsigned int value); 29 | int mp_sem_wait(mp_sem_t *sem); 30 | int mp_sem_trywait(mp_sem_t *sem); 31 | int mp_sem_timedwait(mp_sem_t *sem, const struct timespec *abs_timeout); 32 | int mp_sem_post(mp_sem_t *sem); 33 | int mp_sem_destroy(mp_sem_t *sem); 34 | 35 | #undef sem_init 36 | #undef sem_wait 37 | #undef sem_trywait 38 | #undef sem_timedwait 39 | #undef sem_post 40 | #undef sem_getvalue 41 | #undef sem_destroy 42 | #undef sem_getvalue 43 | #undef sem_t 44 | #undef SEM_VALUE_MAX 45 | 46 | #define sem_init mp_sem_init 47 | #define sem_wait mp_sem_wait 48 | #define sem_trywait mp_sem_trywait 49 | #define sem_timedwait mp_sem_timedwait 50 | #define sem_post mp_sem_post 51 | #define sem_destroy mp_sem_destroy 52 | #define sem_t mp_sem_t 53 | #define SEM_VALUE_MAX MP_SEM_VALUE_MAX 54 | 55 | #define sem_getvalue (void) 56 | 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /osdep/subprocess.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include "common/common.h" 21 | #include "common/msg.h" 22 | #include "common/msg_control.h" 23 | 24 | #include "subprocess.h" 25 | 26 | struct subprocess_args { 27 | struct mp_log *log; 28 | char **args; 29 | }; 30 | 31 | static void *run_subprocess(void *ptr) 32 | { 33 | struct subprocess_args *p = ptr; 34 | pthread_detach(pthread_self()); 35 | 36 | mp_msg_flush_status_line(p->log); 37 | 38 | char *err = NULL; 39 | if (mp_subprocess(p->args, NULL, NULL, NULL, NULL, &err) < 0) 40 | mp_err(p->log, "Running subprocess failed: %s\n", err); 41 | 42 | talloc_free(p); 43 | return NULL; 44 | } 45 | 46 | void mp_subprocess_detached(struct mp_log *log, char **args) 47 | { 48 | struct subprocess_args *p = talloc_zero(NULL, struct subprocess_args); 49 | p->log = mp_log_new(p, log, NULL); 50 | int num_args = 0; 51 | for (int n = 0; args[n]; n++) 52 | MP_TARRAY_APPEND(p, p->args, num_args, talloc_strdup(p, args[n])); 53 | MP_TARRAY_APPEND(p, p->args, num_args, NULL); 54 | pthread_t thread; 55 | if (pthread_create(&thread, NULL, run_subprocess, p)) 56 | talloc_free(p); 57 | } 58 | -------------------------------------------------------------------------------- /osdep/subprocess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_SUBPROCESS_H_ 19 | #define MP_SUBPROCESS_H_ 20 | 21 | #include 22 | 23 | struct mp_cancel; 24 | 25 | typedef void (*subprocess_read_cb)(void *ctx, char *data, size_t size); 26 | 27 | // Start a subprocess. Uses callbacks to read from stdout and stderr. 28 | int mp_subprocess(char **args, struct mp_cancel *cancel, void *ctx, 29 | subprocess_read_cb on_stdout, subprocess_read_cb on_stderr, 30 | char **error); 31 | // mp_subprocess return values. -1 is a generic error code. 32 | #define MP_SUBPROCESS_EKILLED_BY_US -2 33 | 34 | struct mp_log; 35 | void mp_subprocess_detached(struct mp_log *log, char **args); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /osdep/terminal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GyS-TermIO v2.0 (for GySmail v3) 3 | * a very small replacement of ncurses library 4 | * 5 | * copyright (C) 1999 A'rpi/ESP-team 6 | * 7 | * This file is part of mpv. 8 | * 9 | * mpv is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * mpv is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with mpv. If not, see . 21 | */ 22 | 23 | #ifndef MPLAYER_GETCH2_H 24 | #define MPLAYER_GETCH2_H 25 | 26 | #include 27 | #include 28 | 29 | struct input_ctx; 30 | 31 | /* Global initialization for terminal output. */ 32 | int terminal_init(void); 33 | 34 | /* Setup ictx to read keys from the terminal */ 35 | void terminal_setup_getch(struct input_ctx *ictx); 36 | 37 | /* Undo terminal_init(), and also terminal_setup_getch() */ 38 | void terminal_uninit(void); 39 | 40 | /* Return whether the process has been backgrounded. */ 41 | bool terminal_in_background(void); 42 | 43 | /* Get terminal-size in columns/rows. */ 44 | void terminal_get_size(int *w, int *h); 45 | 46 | // Windows only. 47 | void mp_write_console_ansi(void *wstream, char *buf); 48 | 49 | /* Windows-only function to attach to the parent process's console */ 50 | bool terminal_try_attach(void); 51 | 52 | #endif /* MPLAYER_GETCH2_H */ 53 | -------------------------------------------------------------------------------- /osdep/threads.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "config.h" 23 | 24 | #if HAVE_BSD_THREAD_NAME 25 | #include 26 | #endif 27 | 28 | #include "threads.h" 29 | #include "timer.h" 30 | 31 | int mpthread_mutex_init_recursive(pthread_mutex_t *mutex) 32 | { 33 | pthread_mutexattr_t attr; 34 | pthread_mutexattr_init(&attr); 35 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 36 | int r = pthread_mutex_init(mutex, &attr); 37 | pthread_mutexattr_destroy(&attr); 38 | return r; 39 | } 40 | 41 | void mpthread_set_name(const char *name) 42 | { 43 | char tname[80]; 44 | snprintf(tname, sizeof(tname), "mpv/%s", name); 45 | #if HAVE_GLIBC_THREAD_NAME 46 | if (pthread_setname_np(pthread_self(), tname) == ERANGE) { 47 | tname[15] = '\0'; // glibc-checked kernel limit 48 | pthread_setname_np(pthread_self(), tname); 49 | } 50 | #elif HAVE_BSD_THREAD_NAME 51 | pthread_set_name_np(pthread_self(), tname); 52 | #elif HAVE_NETBSD_THREAD_NAME 53 | pthread_setname_np(pthread_self(), "%s", (void *)tname); 54 | #elif HAVE_OSX_THREAD_NAME 55 | pthread_setname_np(tname); 56 | #endif 57 | } 58 | -------------------------------------------------------------------------------- /osdep/threads.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_OSDEP_THREADS_H_ 2 | #define MP_OSDEP_THREADS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Helper to reduce boiler plate. 8 | int mpthread_mutex_init_recursive(pthread_mutex_t *mutex); 9 | 10 | // Set thread name (for debuggers). 11 | void mpthread_set_name(const char *name); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /osdep/timer-darwin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Precise timer routines using Mach timing 3 | * 4 | * Copyright (c) 2003-2004, Dan Villiom Podlaski Christiansen 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "config.h" 27 | #include "common/msg.h" 28 | #include "timer.h" 29 | 30 | static double timebase_ratio; 31 | 32 | void mp_sleep_us(int64_t us) 33 | { 34 | uint64_t deadline = us / 1e6 / timebase_ratio + mach_absolute_time(); 35 | 36 | mach_wait_until(deadline); 37 | } 38 | 39 | uint64_t mp_raw_time_us(void) 40 | { 41 | return mach_absolute_time() * timebase_ratio * 1e6; 42 | } 43 | 44 | void mp_raw_time_init(void) 45 | { 46 | struct mach_timebase_info timebase; 47 | 48 | mach_timebase_info(&timebase); 49 | timebase_ratio = (double)timebase.numer / (double)timebase.denom * 1e-9; 50 | } 51 | -------------------------------------------------------------------------------- /osdep/timer-linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * precise timer routines for Linux/UNIX 3 | * copyright (C) LGB & A'rpi/ASTRAL 4 | * 5 | * This file is part of mpv. 6 | * 7 | * mpv is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * mpv is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with mpv. If not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "config.h" 26 | #include "timer.h" 27 | 28 | #if HAVE_NANOSLEEP 29 | void mp_sleep_us(int64_t us) 30 | { 31 | if (us < 0) 32 | return; 33 | struct timespec ts; 34 | ts.tv_sec = us / 1000000; 35 | ts.tv_nsec = (us % 1000000) * 1000; 36 | nanosleep(&ts, NULL); 37 | } 38 | #else 39 | void mp_sleep_us(int64_t us) 40 | { 41 | if (us < 0) 42 | return; 43 | usleep(us); 44 | } 45 | #endif 46 | 47 | #if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC) 48 | uint64_t mp_raw_time_us(void) 49 | { 50 | struct timespec ts; 51 | if (clock_gettime(CLOCK_MONOTONIC, &ts)) 52 | abort(); 53 | return ts.tv_sec * 1000000LL + ts.tv_nsec / 1000; 54 | } 55 | #else 56 | uint64_t mp_raw_time_us(void) 57 | { 58 | struct timeval tv; 59 | gettimeofday(&tv,NULL); 60 | return tv.tv_sec * 1000000LL + tv.tv_usec; 61 | } 62 | #endif 63 | 64 | void mp_raw_time_init(void) 65 | { 66 | } 67 | -------------------------------------------------------------------------------- /osdep/timer-win2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * precise timer routines for Windows 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "timer.h" 25 | 26 | static LARGE_INTEGER perf_freq; 27 | 28 | void mp_sleep_us(int64_t us) 29 | { 30 | if (us < 0) 31 | return; 32 | // Sleep(0) won't sleep for one clocktick as the unix usleep 33 | // instead it will only make the thread ready 34 | // it may take some time until it actually starts to run again 35 | if (us < 1000) 36 | us = 1000; 37 | Sleep(us / 1000); 38 | } 39 | 40 | uint64_t mp_raw_time_us(void) 41 | { 42 | LARGE_INTEGER perf_count; 43 | QueryPerformanceCounter(&perf_count); 44 | 45 | // Convert QPC units (1/perf_freq seconds) to microseconds. This will work 46 | // without overflow because the QPC value is guaranteed not to roll-over 47 | // within 100 years, so perf_freq must be less than 2.9*10^9. 48 | return perf_count.QuadPart / perf_freq.QuadPart * 1000000 + 49 | perf_count.QuadPart % perf_freq.QuadPart * 1000000 / perf_freq.QuadPart; 50 | } 51 | 52 | void mp_raw_time_init(void) 53 | { 54 | QueryPerformanceFrequency(&perf_freq); 55 | timeBeginPeriod(1); // request 1ms timer resolution 56 | } 57 | -------------------------------------------------------------------------------- /osdep/w32_keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_W32_KEYBOARD 19 | #define MP_W32_KEYBOARD 20 | 21 | #include 22 | 23 | /* Convert a Windows virtual key code to an mpv key */ 24 | int mp_w32_vkey_to_mpkey(UINT vkey, bool extended); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /osdep/win32/include/semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_WRAP_SEMAPHORE_H_ 2 | #define MP_WRAP_SEMAPHORE_H_ 3 | 4 | #include 5 | 6 | // See pthread.h for rationale. 7 | #define sem_init m_sem_init 8 | #define sem_destroy m_sem_destroy 9 | #define sem_wait m_sem_wait 10 | #define sem_trywait m_sem_trywait 11 | #define sem_timedwait m_sem_timedwait 12 | #define sem_post m_sem_post 13 | 14 | #define SEM_VALUE_MAX 100 15 | 16 | typedef struct { 17 | pthread_mutex_t lock; 18 | pthread_cond_t wakeup; 19 | unsigned int value; 20 | } sem_t; 21 | 22 | int sem_init(sem_t *sem, int pshared, unsigned int value); 23 | int sem_destroy(sem_t *sem); 24 | int sem_wait(sem_t *sem); 25 | int sem_trywait(sem_t *sem); 26 | int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout); 27 | int sem_post(sem_t *sem); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /osdep/windows_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_WINDOWS_UTILS_H_ 19 | #define MP_WINDOWS_UTILS_H_ 20 | 21 | #include 22 | 23 | char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid); 24 | #define mp_GUID_to_str(guid) mp_GUID_to_str_buf((char[40]){0}, 40, (guid)) 25 | char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr); 26 | #define mp_HRESULT_to_str(hr) mp_HRESULT_to_str_buf((char[60]){0}, 60, (hr)) 27 | #define mp_LastError_to_str() mp_HRESULT_to_str(HRESULT_FROM_WIN32(GetLastError())) 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /player/client.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_CLIENT_H_ 2 | #define MP_CLIENT_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "libmpv/client.h" 8 | 9 | struct MPContext; 10 | struct mpv_handle; 11 | struct mp_client_api; 12 | struct mp_log; 13 | 14 | // Includes space for \0 15 | #define MAX_CLIENT_NAME 64 16 | 17 | void mp_clients_init(struct MPContext *mpctx); 18 | void mp_clients_destroy(struct MPContext *mpctx); 19 | int mp_clients_num(struct MPContext *mpctx); 20 | bool mp_clients_all_initialized(struct MPContext *mpctx); 21 | 22 | bool mp_client_exists(struct MPContext *mpctx, const char *client_name); 23 | void mp_client_broadcast_event(struct MPContext *mpctx, int event, void *data); 24 | int mp_client_send_event(struct MPContext *mpctx, const char *client_name, 25 | int event, void *data); 26 | int mp_client_send_event_dup(struct MPContext *mpctx, const char *client_name, 27 | int event, void *data); 28 | bool mp_client_event_is_registered(struct MPContext *mpctx, int event); 29 | void mp_client_property_change(struct MPContext *mpctx, const char *name); 30 | 31 | struct mpv_handle *mp_new_client(struct mp_client_api *clients, const char *name); 32 | struct mp_log *mp_client_get_log(struct mpv_handle *ctx); 33 | struct MPContext *mp_client_get_core(struct mpv_handle *ctx); 34 | struct MPContext *mp_client_api_get_core(struct mp_client_api *api); 35 | 36 | void mp_resume_all(struct mpv_handle *ctx); 37 | 38 | // m_option.c 39 | void *node_get_alloc(struct mpv_node *node); 40 | 41 | // vo_opengl_cb.c 42 | struct mpv_opengl_cb_context; 43 | struct mpv_global; 44 | struct osd_state; 45 | struct mpv_opengl_cb_context *mp_opengl_create(struct mpv_global *g, 46 | struct mp_client_api *client_api); 47 | void kill_video(struct mp_client_api *client_api); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /player/external_files.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_FIND_SUBFILES_H 19 | #define MPLAYER_FIND_SUBFILES_H 20 | 21 | #include 22 | 23 | struct subfn { 24 | int type; // STREAM_SUB/STREAM_AUDIO 25 | int priority; 26 | char *fname; 27 | char *lang; 28 | }; 29 | 30 | struct mpv_global; 31 | struct subfn *find_external_files(struct mpv_global *global, const char *fname); 32 | 33 | bool mp_might_be_subtitle_file(const char *filename); 34 | 35 | #endif /* MPLAYER_FINDFILES_H */ 36 | -------------------------------------------------------------------------------- /player/screenshot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_SCREENSHOT_H 19 | #define MPLAYER_SCREENSHOT_H 20 | 21 | #include 22 | 23 | struct MPContext; 24 | 25 | // One time initialization at program start. 26 | void screenshot_init(struct MPContext *mpctx); 27 | 28 | // Request a taking & saving a screenshot of the currently displayed frame. 29 | // mode: 0: -, 1: save the actual output window contents, 2: with subtitles. 30 | // each_frame: If set, this toggles per-frame screenshots, exactly like the 31 | // screenshot slave command (MP_CMD_SCREENSHOT). 32 | // osd: show status on OSD 33 | void screenshot_request(struct MPContext *mpctx, int mode, bool each_frame, 34 | bool osd); 35 | 36 | // filename: where to store the screenshot; doesn't try to find an alternate 37 | // name if the file already exists 38 | // mode, osd: same as in screenshot_request() 39 | void screenshot_to_file(struct MPContext *mpctx, const char *filename, int mode, 40 | bool osd); 41 | 42 | // mode is the same as in screenshot_request() 43 | struct mp_image *screenshot_get_rgb(struct MPContext *mpctx, int mode); 44 | 45 | // Called by the playback core code when a new frame is displayed. 46 | void screenshot_flip(struct MPContext *mpctx); 47 | 48 | #endif /* MPLAYER_SCREENSHOT_H */ 49 | -------------------------------------------------------------------------------- /stream/ai_sndio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "config.h" 5 | 6 | #include 7 | #include "audio_in.h" 8 | #include "common/msg.h" 9 | 10 | int ai_sndio_setup(audio_in_t *ai) 11 | { 12 | struct sio_par par; 13 | 14 | sio_initpar(&par); 15 | 16 | par.bits = 16; 17 | par.sig = 1; 18 | par.le = SIO_LE_NATIVE; 19 | par.rchan = ai->req_channels; 20 | par.rate = ai->req_samplerate; 21 | par.appbufsz = ai->req_samplerate; /* 1 sec */ 22 | 23 | if (!sio_setpar(ai->sndio.hdl, &par) || !sio_getpar(ai->sndio.hdl, &par)) { 24 | MP_ERR(ai, "could not configure sndio audio"); 25 | return -1; 26 | } 27 | 28 | ai->channels = par.rchan; 29 | ai->samplerate = par.rate; 30 | ai->samplesize = par.bits; 31 | ai->bytes_per_sample = par.bps; 32 | ai->blocksize = par.round * par.bps; 33 | 34 | return 0; 35 | } 36 | 37 | int ai_sndio_init(audio_in_t *ai) 38 | { 39 | int err; 40 | 41 | const char *device = ai->sndio.device; 42 | if (!device) 43 | device = "default"; 44 | if ((ai->sndio.hdl = sio_open(device, SIO_REC, 0)) == NULL) { 45 | MP_ERR(ai, "could not open sndio audio"); 46 | return -1; 47 | } 48 | 49 | err = ai_sndio_setup(ai); 50 | 51 | return err; 52 | } 53 | -------------------------------------------------------------------------------- /stream/cookies.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HTTP Cookies 3 | * Reads Netscape and Mozilla cookies.txt files 4 | * 5 | * Copyright (c) 2003 Dave Lambley 6 | * 7 | * This file is part of mpv. 8 | * 9 | * mpv is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * mpv is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with mpv. If not, see . 21 | */ 22 | 23 | #ifndef MPLAYER_COOKIES_H 24 | #define MPLAYER_COOKIES_H 25 | 26 | char *cookies_lavf(void *talloc_ctx, struct mp_log *log, char *file); 27 | 28 | #endif /* MPLAYER_COOKIES_H */ 29 | -------------------------------------------------------------------------------- /stream/dvb_tune.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of MPlayer. 3 | * 4 | * MPlayer is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * MPlayer is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with MPlayer; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #ifndef MPLAYER_DVB_TUNE_H 20 | #define MPLAYER_DVB_TUNE_H 21 | 22 | #include "dvbin.h" 23 | 24 | struct mp_log; 25 | 26 | int dvb_get_tuner_types(int fe_fd, struct mp_log *log, int** tuner_types); 27 | int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt); 28 | int dvb_fix_demuxes(dvb_priv_t *priv, int cnt); 29 | int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid, dmx_pes_type_t pestype); 30 | int dvb_get_pmt_pid(dvb_priv_t *priv, int card, int service_id); 31 | int dvb_demux_stop(int fd); 32 | int dvb_demux_start(int fd); 33 | int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, 34 | int tone, bool is_dvb_s2, int stream_id, fe_spectral_inversion_t specInv, 35 | fe_modulation_t modulation, fe_guard_interval_t guardInterval, 36 | fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, 37 | fe_code_rate_t HP_CodeRate, fe_code_rate_t LP_CodeRate, 38 | fe_hierarchy_t hier, int timeout); 39 | 40 | #endif /* MPLAYER_DVB_TUNE_H */ 41 | -------------------------------------------------------------------------------- /stream/stream_avdevice.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include "config.h" 19 | 20 | #include "stream.h" 21 | 22 | static int open_f(stream_t *stream) 23 | { 24 | stream->type = STREAMTYPE_AVDEVICE; 25 | stream->demuxer = "lavf"; 26 | 27 | return STREAM_OK; 28 | } 29 | 30 | const stream_info_t stream_info_avdevice = { 31 | .name = "avdevice", 32 | .open = open_f, 33 | .protocols = (const char*const[]){ "avdevice", "av", NULL }, 34 | }; 35 | -------------------------------------------------------------------------------- /stream/stream_dvd_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_STREAM_DVD_COMMON_H 19 | #define MPLAYER_STREAM_DVD_COMMON_H 20 | 21 | #include 22 | #include 23 | #include "stream.h" 24 | 25 | extern const char * const dvd_audio_stream_channels[6]; 26 | extern const char * const dvd_audio_stream_types[8]; 27 | 28 | void dvd_set_speed(stream_t *stream, char *device, unsigned speed); 29 | int mp_dvdtimetomsec(dvd_time_t *dt); 30 | 31 | int dvd_probe(const char *path, const char *ext, const char *sig); 32 | 33 | #endif /* MPLAYER_STREAM_DVD_COMMON_H */ 34 | -------------------------------------------------------------------------------- /stream/stream_edl.c: -------------------------------------------------------------------------------- 1 | // Dummy stream implementation to enable demux_edl, which is in turn a 2 | // dummy demuxer implementation to enable tl_edl. 3 | 4 | #include "stream.h" 5 | 6 | static int s_open (struct stream *stream) 7 | { 8 | stream->type = STREAMTYPE_EDL; 9 | stream->demuxer = "edl"; 10 | 11 | return STREAM_OK; 12 | } 13 | 14 | const stream_info_t stream_info_edl = { 15 | .name = "edl", 16 | .open = s_open, 17 | .protocols = (const char*const[]){"edl", NULL}, 18 | }; 19 | -------------------------------------------------------------------------------- /stream/stream_libarchive.h: -------------------------------------------------------------------------------- 1 | struct mp_log; 2 | 3 | struct mp_archive { 4 | struct archive *arch; 5 | struct stream *primary_src; 6 | char buffer[4096]; 7 | }; 8 | 9 | void mp_archive_free(struct mp_archive *mpa); 10 | 11 | #define MP_ARCHIVE_FLAG_UNSAFE 1 12 | struct mp_archive *mp_archive_new(struct mp_log *log, struct stream *src, 13 | int flags); 14 | -------------------------------------------------------------------------------- /stream/stream_mf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stream layer for multiple files input, based on previous work from Albeu 3 | * 4 | * Copyright (C) 2006 Benjamin Zores 5 | * Original author: Albeu 6 | * 7 | * This file is part of mpv. 8 | * 9 | * mpv is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * mpv is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with mpv. If not, see . 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | 28 | #include "stream.h" 29 | 30 | static int 31 | mf_stream_open (stream_t *stream) 32 | { 33 | stream->type = STREAMTYPE_MF; 34 | stream->demuxer = "mf"; 35 | stream->allow_caching = false; 36 | 37 | return STREAM_OK; 38 | } 39 | 40 | const stream_info_t stream_info_mf = { 41 | .name = "mf", 42 | .open = mf_stream_open, 43 | .protocols = (const char*const[]){ "mf", NULL }, 44 | }; 45 | -------------------------------------------------------------------------------- /stream/stream_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Original author: Albeu 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | 22 | #include 23 | #include 24 | 25 | #include "stream.h" 26 | 27 | static int open_s(stream_t *stream) 28 | { 29 | return 1; 30 | } 31 | 32 | const stream_info_t stream_info_null = { 33 | .name = "null", 34 | .open = open_s, 35 | .protocols = (const char*const[]){ "null", NULL }, 36 | .can_write = true, 37 | }; 38 | -------------------------------------------------------------------------------- /stream/stream_tv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stream layer for TV Input, based on previous work from Albeu 3 | * 4 | * Copyright (C) 2006 Benjamin Zores 5 | * Original author: Albeu 6 | * 7 | * This file is part of mpv. 8 | * 9 | * mpv is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * mpv is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with mpv. If not, see . 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | 28 | #include "stream.h" 29 | #include "options/m_option.h" 30 | #include "tv.h" 31 | 32 | #include 33 | 34 | #define OPT_BASE_STRUCT struct tv_stream_params 35 | static const m_option_t stream_opts_fields[] = { 36 | OPT_STRING("channel", channel, 0), 37 | OPT_INT("input", input, 0), 38 | {0} 39 | }; 40 | 41 | static void 42 | tv_stream_close (stream_t *stream) 43 | { 44 | } 45 | static int 46 | tv_stream_open (stream_t *stream) 47 | { 48 | 49 | stream->type = STREAMTYPE_TV; 50 | stream->close=tv_stream_close; 51 | stream->demuxer = "tv"; 52 | stream->allow_caching = false; 53 | 54 | return STREAM_OK; 55 | } 56 | 57 | const stream_info_t stream_info_tv = { 58 | .name = "tv", 59 | .open = tv_stream_open, 60 | .protocols = (const char*const[]){ "tv", NULL }, 61 | .priv_size = sizeof(tv_param_t), 62 | .priv_defaults = &(const struct tv_stream_params){ 63 | .input = -1, 64 | }, 65 | .options = stream_opts_fields, 66 | .url_options = (const char*const[]){ 67 | "hostname=channel", 68 | "filename=input", 69 | NULL 70 | }, 71 | }; 72 | -------------------------------------------------------------------------------- /sub/dec_sub.h: -------------------------------------------------------------------------------- 1 | #ifndef MPLAYER_DEC_SUB_H 2 | #define MPLAYER_DEC_SUB_H 3 | 4 | #include 5 | #include 6 | 7 | #include "osd.h" 8 | 9 | struct demuxer; 10 | struct sh_stream; 11 | struct mpv_global; 12 | struct demux_packet; 13 | 14 | struct dec_sub; 15 | struct sd; 16 | 17 | enum sd_ctrl { 18 | SD_CTRL_SUB_STEP, 19 | SD_CTRL_SET_VIDEO_PARAMS, 20 | SD_CTRL_GET_RESOLUTION, 21 | SD_CTRL_SET_TOP, 22 | SD_CTRL_SET_VIDEO_DEF_FPS, 23 | }; 24 | 25 | struct dec_sub *sub_create(struct mpv_global *global, struct demuxer *demuxer, 26 | struct sh_stream *sh); 27 | void sub_destroy(struct dec_sub *sub); 28 | void sub_lock(struct dec_sub *sub); 29 | void sub_unlock(struct dec_sub *sub); 30 | 31 | bool sub_read_all_packets(struct dec_sub *sub); 32 | bool sub_read_packets(struct dec_sub *sub, double video_pts); 33 | void sub_get_bitmaps(struct dec_sub *sub, struct mp_osd_res dim, double pts, 34 | struct sub_bitmaps *res); 35 | char *sub_get_text(struct dec_sub *sub, double pts); 36 | void sub_reset(struct dec_sub *sub); 37 | void sub_select(struct dec_sub *sub, bool selected); 38 | 39 | int sub_control(struct dec_sub *sub, enum sd_ctrl cmd, void *arg); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /sub/draw_bmp.h: -------------------------------------------------------------------------------- 1 | #ifndef MPLAYER_DRAW_BMP_H 2 | #define MPLAYER_DRAW_BMP_H 3 | 4 | #include "osd.h" 5 | 6 | struct mp_image; 7 | struct sub_bitmaps; 8 | struct mp_draw_sub_cache; 9 | void mp_draw_sub_bitmaps(struct mp_draw_sub_cache **cache, struct mp_image *dst, 10 | struct sub_bitmaps *sbs); 11 | 12 | extern const bool mp_draw_sub_formats[SUBBITMAP_COUNT]; 13 | 14 | #endif /* MPLAYER_DRAW_BMP_H */ 15 | 16 | // vim: ts=4 sw=4 et tw=80 17 | -------------------------------------------------------------------------------- /sub/img_convert.h: -------------------------------------------------------------------------------- 1 | #ifndef MPLAYER_SUB_IMG_CONVERT_H 2 | #define MPLAYER_SUB_IMG_CONVERT_H 3 | 4 | #include 5 | 6 | struct osd_conv_cache; 7 | struct sub_bitmaps; 8 | struct mp_rect; 9 | 10 | struct osd_conv_cache *osd_conv_cache_new(void); 11 | 12 | // These functions convert from one OSD format to another. On success, they copy 13 | // the converted image data into c, and change imgs to point to the data. 14 | bool osd_conv_idx_to_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs); 15 | bool osd_conv_ass_to_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs); 16 | // Sub postprocessing 17 | bool osd_conv_blur_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs, 18 | double gblur); 19 | bool osd_scale_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs); 20 | bool osd_conv_idx_to_gray(struct osd_conv_cache *c, struct sub_bitmaps *imgs); 21 | 22 | bool mp_sub_bitmaps_bb(struct sub_bitmaps *imgs, struct mp_rect *out_bb); 23 | 24 | // Intentionally limit the maximum number of bounding rects to something low. 25 | // This prevents the algorithm from degrading to O(N^2). 26 | // Most subtitles yield a very low number of bounding rects (<5). 27 | #define MP_SUB_BB_LIST_MAX 15 28 | 29 | int mp_get_sub_bb_list(struct sub_bitmaps *sbs, struct mp_rect *out_rc_list, 30 | int rc_list_count); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /sub/osd_dummy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "config.h" 6 | #include "mpv_talloc.h" 7 | #include "osd.h" 8 | 9 | const char *const osd_ass_0 = ""; 10 | const char *const osd_ass_1 = ""; 11 | 12 | void osd_init_backend(struct osd_state *osd) 13 | { 14 | } 15 | 16 | void osd_destroy_backend(struct osd_state *osd) 17 | { 18 | } 19 | 20 | void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function) 21 | { 22 | } 23 | 24 | void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj, 25 | struct sub_bitmaps *out_imgs) 26 | { 27 | *out_imgs = (struct sub_bitmaps) {0}; 28 | } 29 | 30 | void osd_object_get_resolution(struct osd_state *osd, int obj, 31 | int *out_w, int *out_h) 32 | { 33 | *out_w = 0; 34 | *out_h = 0; 35 | } 36 | -------------------------------------------------------------------------------- /sub/osd_font.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/sub/osd_font.otf -------------------------------------------------------------------------------- /sub/osd_state.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_OSD_STATE_H_ 2 | #define MP_OSD_STATE_H_ 3 | 4 | #include 5 | 6 | #include "osd.h" 7 | 8 | #define OSD_CONV_CACHE_MAX 4 9 | 10 | struct osd_object { 11 | int type; // OSDTYPE_* 12 | bool is_sub; 13 | 14 | bool force_redraw; 15 | 16 | // OSDTYPE_SUB/OSDTYPE_SUB2/OSDTYPE_OSD/OSDTYPE_EXTERNAL 17 | char *text; 18 | 19 | // OSDTYPE_OSD 20 | struct osd_progbar_state progbar_state; 21 | 22 | // OSDTYPE_SUB/OSDTYPE_SUB2 23 | struct dec_sub *sub; 24 | 25 | // OSDTYPE_EXTERNAL 26 | int external_res_x, external_res_y; 27 | 28 | // OSDTYPE_EXTERNAL2 29 | struct sub_bitmaps *external2; 30 | 31 | // caches for OSD conversion (internal to render_object()) 32 | struct osd_conv_cache *cache[OSD_CONV_CACHE_MAX]; 33 | struct sub_bitmaps cached; 34 | 35 | // VO cache state 36 | int vo_change_id; 37 | struct mp_osd_res vo_res; 38 | 39 | // Internally used by osd_libass.c 40 | struct sub_bitmap *parts_cache; 41 | struct ass_track *osd_track; 42 | struct ass_renderer *osd_render; 43 | struct ass_library *osd_ass_library; 44 | }; 45 | 46 | struct osd_state { 47 | pthread_mutex_t lock; 48 | 49 | struct osd_object *objs[MAX_OSD_PARTS]; 50 | 51 | bool render_subs_in_filter; 52 | 53 | bool want_redraw; 54 | 55 | struct MPOpts *opts; 56 | struct mpv_global *global; 57 | struct mp_log *log; 58 | 59 | struct mp_draw_sub_cache *draw_cache; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /sub/sd.h: -------------------------------------------------------------------------------- 1 | #ifndef MPLAYER_SD_H 2 | #define MPLAYER_SD_H 3 | 4 | #include "dec_sub.h" 5 | #include "demux/packet.h" 6 | 7 | // up to 210 ms overlaps or gaps are removed 8 | #define SUB_GAP_THRESHOLD 0.210 9 | // don't change timings if durations are smaller 10 | #define SUB_GAP_KEEP 0.4 11 | 12 | struct sd { 13 | struct mpv_global *global; 14 | struct mp_log *log; 15 | struct MPOpts *opts; 16 | 17 | const struct sd_functions *driver; 18 | void *priv; 19 | 20 | struct demuxer *demuxer; 21 | struct mp_codec_params *codec; 22 | }; 23 | 24 | struct sd_functions { 25 | const char *name; 26 | bool accept_packets_in_advance; 27 | int (*init)(struct sd *sd); 28 | void (*decode)(struct sd *sd, struct demux_packet *packet); 29 | void (*reset)(struct sd *sd); 30 | void (*select)(struct sd *sd, bool selected); 31 | void (*uninit)(struct sd *sd); 32 | 33 | bool (*accepts_packet)(struct sd *sd); // implicit default if NULL: true 34 | int (*control)(struct sd *sd, enum sd_ctrl cmd, void *arg); 35 | 36 | void (*get_bitmaps)(struct sd *sd, struct mp_osd_res dim, double pts, 37 | struct sub_bitmaps *res); 38 | char *(*get_text)(struct sd *sd, double pts); 39 | }; 40 | 41 | struct lavc_conv; 42 | struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name, 43 | char *extradata, int extradata_len); 44 | char *lavc_conv_get_extradata(struct lavc_conv *priv); 45 | char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet); 46 | void lavc_conv_reset(struct lavc_conv *priv); 47 | void lavc_conv_uninit(struct lavc_conv *priv); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ta/README: -------------------------------------------------------------------------------- 1 | TA ("Tree Allocator") is a wrapper around malloc() and related functions, 2 | adding features like automatically freeing sub-trees of memory allocations if 3 | a parent allocation is freed. 4 | 5 | Generally, the idea is that every TA allocation can have a parent (indicated 6 | by the ta_parent argument in allocation function calls). If a parent is freed, 7 | its child allocations are automatically freed as well. It is also allowed to 8 | free a child before the parent, or to move a child to another parent with 9 | ta_set_parent(). 10 | 11 | It also provides a bunch of convenience macros and debugging facilities. 12 | 13 | The TA functions are documented in the implementation files (ta.c, ta_utils.c). 14 | 15 | TA is intended to be useable as library independent from mpv. It doesn't 16 | depend on anything mpv specific. 17 | 18 | Note: 19 | ----- 20 | 21 | mpv doesn't use the TA API yet for two reasons: first, the TA API is not 22 | necessarily finalized yet. Second, it should be easily possible to revert 23 | the commit adding TA, and changing all the code would not allow this. 24 | 25 | Especially the naming schema for some TA functions is still somewhat 26 | undecided. (The talloc naming is a bit verbose at times.) 27 | 28 | For now, mpv goes through a talloc wrapper, which maps the talloc API to TA. 29 | New code should still use talloc as well. At one point, all talloc calls 30 | will be replaced with TA calls, and the talloc wrapper will be removed. 31 | 32 | Documentation for the talloc API is here: 33 | 34 | http://talloc.samba.org/talloc/doc/html/modules.html 35 | 36 | There are some minor differences with mpv's talloc bridge. mpv calls abort() 37 | on allocation failures, and the talloc_set_destructor() signature is slightly 38 | different. libtalloc also has a weird 256MB limit per allocation. The talloc 39 | wrapper supports only a strict subset of libtalloc functionality used by mpv. 40 | -------------------------------------------------------------------------------- /test/chmap.c: -------------------------------------------------------------------------------- 1 | #include "test_helpers.h" 2 | #include "audio/chmap.h" 3 | 4 | static void test_mp_chmap_diff(void **state) { 5 | struct mp_chmap a; 6 | struct mp_chmap b; 7 | 8 | mp_chmap_from_str(&a, bstr0("3.1")); 9 | mp_chmap_from_str(&b, bstr0("2.1")); 10 | 11 | assert_int_equal(mp_chmap_diffn(&a, &b), 1); 12 | 13 | mp_chmap_from_str(&b, bstr0("6.1(back)")); 14 | assert_int_equal(mp_chmap_diffn(&a, &b), 0); 15 | assert_int_equal(mp_chmap_diffn(&b, &a), 3); 16 | } 17 | 18 | int main(void) { 19 | const struct CMUnitTest tests[] = { 20 | cmocka_unit_test(test_mp_chmap_diff), 21 | }; 22 | return cmocka_run_group_tests(tests, NULL, NULL); 23 | } 24 | -------------------------------------------------------------------------------- /test/gl_video.c: -------------------------------------------------------------------------------- 1 | #include "test_helpers.h" 2 | #include "video/out/opengl/video.h" 3 | 4 | static void test_scale_ambient_lux_limits(void **state) { 5 | float x; 6 | x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 16.0); 7 | assert_double_equal(x, 2.40f); 8 | 9 | x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 64.0); 10 | assert_double_equal(x, 1.961f); 11 | } 12 | 13 | static void test_scale_ambient_lux_sign(void **state) { 14 | float x; 15 | x = gl_video_scale_ambient_lux(16.0, 64.0, 1.961, 2.40, 64.0); 16 | assert_double_equal(x, 2.40f); 17 | } 18 | 19 | static void test_scale_ambient_lux_clamping(void **state) { 20 | float x; 21 | x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 0.0); 22 | assert_double_equal(x, 2.40f); 23 | } 24 | 25 | static void test_scale_ambient_lux_log10_midpoint(void **state) { 26 | float x; 27 | // 32 corresponds to the the midpoint after converting lux to the log10 scale 28 | x = gl_video_scale_ambient_lux(16.0, 64.0, 2.40, 1.961, 32.0); 29 | float mid_gamma = (2.40 - 1.961) / 2 + 1.961; 30 | assert_double_equal(x, mid_gamma); 31 | } 32 | 33 | int main(void) { 34 | const struct CMUnitTest tests[] = { 35 | cmocka_unit_test(test_scale_ambient_lux_limits), 36 | cmocka_unit_test(test_scale_ambient_lux_sign), 37 | cmocka_unit_test(test_scale_ambient_lux_clamping), 38 | cmocka_unit_test(test_scale_ambient_lux_log10_midpoint), 39 | }; 40 | return cmocka_run_group_tests(tests, NULL, NULL); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /test/test_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_TESTS_H 2 | #define MP_TESTS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #define assert_double_equal(a, b) assert_true(fabs(a - b) <= DBL_EPSILON) 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export LC_ALL=C 4 | 5 | version_h="version.h" 6 | print=yes 7 | 8 | for ac_option do 9 | ac_arg=$(echo $ac_option | cut -d '=' -f 2-) 10 | case "$ac_option" in 11 | --extra=*) 12 | extra="-$ac_arg" 13 | ;; 14 | --versionh=*) 15 | version_h="$(pwd)/$ac_arg" 16 | print=no 17 | ;; 18 | --cwd=*) 19 | cwd="$ac_arg" 20 | ;; 21 | *) 22 | echo "Unknown parameter: $ac_option" >&2 23 | exit 1 24 | ;; 25 | 26 | esac 27 | done 28 | 29 | if test "$cwd" ; then 30 | cd "$cwd" 31 | fi 32 | 33 | # Extract revision number from file used by daily tarball snapshots 34 | # or from "git describe" output 35 | git_revision=$(cat snapshot_version 2> /dev/null) 36 | test "$git_revision" || test ! -e .git || git_revision="$(git rev-parse --short HEAD)" 37 | test "$git_revision" && git_revision="git-$git_revision" 38 | version="$git_revision" 39 | 40 | # releases extract the version number from the VERSION file 41 | releaseversion="$(cat VERSION 2> /dev/null)" 42 | if test "$releaseversion" ; then 43 | test "$version" && version="-$version" 44 | version="$releaseversion$version" 45 | fi 46 | 47 | test "$version" || version=UNKNOWN 48 | 49 | VERSION="${version}${extra}" 50 | 51 | if test "$print" = yes ; then 52 | echo "$VERSION" 53 | exit 0 54 | fi 55 | 56 | NEW_REVISION="#define VERSION \"${VERSION}\"" 57 | OLD_REVISION=$(head -n 1 "$version_h" 2> /dev/null) 58 | BUILDDATE="#define BUILDDATE \"$(date)\"" 59 | 60 | # Update version.h only on revision changes to avoid spurious rebuilds 61 | if test "$NEW_REVISION" != "$OLD_REVISION"; then 62 | cat < "$version_h" 63 | $NEW_REVISION 64 | $BUILDDATE 65 | EOF 66 | fi 67 | -------------------------------------------------------------------------------- /video/d3d.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_D3D_H_ 2 | #define MP_D3D_H_ 3 | 4 | #include 5 | 6 | #include "hwdec.h" 7 | 8 | struct mp_d3d_ctx { 9 | struct mp_hwdec_ctx hwctx; 10 | IDirect3DDevice9 *d3d9_device; 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /video/decode/rpi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include "lavc.h" 19 | #include "common/common.h" 20 | 21 | static const char *const codecs[][2] = { 22 | {"h264", "h264_mmal"}, 23 | {"mpeg2video", "mpeg2_mmal"}, 24 | {0} 25 | }; 26 | 27 | static const char *map_codec(const char *c) 28 | { 29 | for (int n = 0; codecs[n][0]; n++) { 30 | if (c && strcmp(codecs[n][0], c) == 0) 31 | return codecs[n][1]; 32 | } 33 | return NULL; 34 | } 35 | 36 | static int init_decoder(struct lavc_ctx *ctx, int w, int h) 37 | { 38 | return 0; 39 | } 40 | 41 | static void uninit(struct lavc_ctx *ctx) 42 | { 43 | } 44 | 45 | static int init(struct lavc_ctx *ctx) 46 | { 47 | return 0; 48 | } 49 | 50 | static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info, 51 | const char *decoder) 52 | { 53 | return map_codec(decoder) ? 0 : HWDEC_ERR_NO_CODEC; 54 | } 55 | 56 | static const char *get_codec(struct lavc_ctx *ctx, const char *codec) 57 | { 58 | return map_codec(codec); 59 | } 60 | 61 | const struct vd_lavc_hwdec mp_vd_lavc_rpi = { 62 | .type = HWDEC_RPI, 63 | .image_format = IMGFMT_MMAL, 64 | .probe = probe, 65 | .init = init, 66 | .uninit = uninit, 67 | .init_decoder = init_decoder, 68 | .get_codec = get_codec, 69 | }; 70 | -------------------------------------------------------------------------------- /video/decode/vd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_VD_H 19 | #define MPLAYER_VD_H 20 | 21 | #include "video/mp_image.h" 22 | #include "demux/stheader.h" 23 | #include "dec_video.h" 24 | 25 | struct demux_packet; 26 | struct mp_decoder_list; 27 | 28 | /* interface of video decoder drivers */ 29 | typedef struct vd_functions 30 | { 31 | const char *name; 32 | void (*add_decoders)(struct mp_decoder_list *list); 33 | int (*init)(struct dec_video *vd, const char *decoder); 34 | void (*uninit)(struct dec_video *vd); 35 | int (*control)(struct dec_video *vd, int cmd, void *arg); 36 | struct mp_image *(*decode)(struct dec_video *vd, struct demux_packet *pkt, 37 | int flags); 38 | } vd_functions_t; 39 | 40 | // NULL terminated array of all drivers 41 | extern const vd_functions_t *const mpcodecs_vd_drivers[]; 42 | 43 | enum vd_ctrl { 44 | VDCTRL_RESET = 1, // reset decode state after seeking 45 | VDCTRL_QUERY_UNSEEN_FRAMES, // current decoder lag 46 | VDCTRL_FORCE_HWDEC_FALLBACK, // force software decoding fallback 47 | VDCTRL_GET_HWDEC, 48 | }; 49 | 50 | #endif /* MPLAYER_VD_H */ 51 | -------------------------------------------------------------------------------- /video/filter/vf_flip.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "config.h" 23 | #include "common/msg.h" 24 | 25 | #include "video/mp_image.h" 26 | #include "vf.h" 27 | 28 | #include "video/out/vo.h" 29 | 30 | static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) 31 | { 32 | mp_image_vflip(mpi); 33 | return mpi; 34 | } 35 | 36 | static int query_format(struct vf_instance *vf, unsigned int fmt) 37 | { 38 | if (!IMGFMT_IS_HWACCEL(fmt)) 39 | return vf_next_query_format(vf, fmt); 40 | return 0; 41 | } 42 | 43 | static int vf_open(vf_instance_t *vf){ 44 | vf->filter=filter; 45 | vf->query_format = query_format; 46 | return 1; 47 | } 48 | 49 | const vf_info_t vf_info_flip = { 50 | .description = "flip image upside-down", 51 | .name = "flip", 52 | .open = vf_open, 53 | }; 54 | -------------------------------------------------------------------------------- /video/filter/vf_lavfi.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_VF_LAVFI_H_ 2 | #define MP_VF_LAVFI_H_ 3 | 4 | #include "common/common.h" 5 | #include "vf.h" 6 | 7 | struct vf_lw_opts; 8 | 9 | extern const struct m_sub_options vf_lw_conf; 10 | 11 | int vf_lw_set_graph(struct vf_instance *vf, struct vf_lw_opts *lavfi_opts, 12 | char *filter, char *opts, ...) PRINTF_ATTRIBUTE(4,5); 13 | void *vf_lw_old_priv(struct vf_instance *vf); 14 | void vf_lw_update_graph(struct vf_instance *vf, char *filter, char *opts, ...) 15 | PRINTF_ATTRIBUTE(3,4); 16 | void vf_lw_set_reconfig_cb(struct vf_instance *vf, 17 | int (*reconfig)(struct vf_instance *vf, 18 | struct mp_image_params *in, 19 | struct mp_image_params *out)); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /video/filter/vf_mirror.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include "vf.h" 21 | #include "vf_lavfi.h" 22 | 23 | static int vf_open(vf_instance_t *vf) 24 | { 25 | return vf_lw_set_graph(vf, NULL, NULL, "hflip") >= 0; 26 | } 27 | 28 | const vf_info_t vf_info_mirror = { 29 | .description = "horizontal mirror", 30 | .name = "mirror", 31 | .open = vf_open, 32 | }; 33 | -------------------------------------------------------------------------------- /video/filter/vf_noformat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "config.h" 24 | #include "common/msg.h" 25 | 26 | #include "video/img_format.h" 27 | #include "video/mp_image.h" 28 | #include "vf.h" 29 | 30 | #include "options/m_option.h" 31 | 32 | static struct vf_priv_s { 33 | int fmt; 34 | } const vf_priv_dflt = { 35 | IMGFMT_420P 36 | }; 37 | 38 | //===========================================================================// 39 | 40 | static int query_format(struct vf_instance *vf, unsigned int fmt){ 41 | if(fmt!=vf->priv->fmt) 42 | return vf_next_query_format(vf,fmt); 43 | return 0; 44 | } 45 | 46 | static int vf_open(vf_instance_t *vf){ 47 | vf->query_format=query_format; 48 | return 1; 49 | } 50 | 51 | #define OPT_BASE_STRUCT struct vf_priv_s 52 | static const m_option_t vf_opts_fields[] = { 53 | OPT_IMAGEFORMAT("fmt", fmt, 0), 54 | {0} 55 | }; 56 | 57 | const vf_info_t vf_info_noformat = { 58 | .description = "disallow one output format", 59 | .name = "noformat", 60 | .open = vf_open, 61 | .priv_size = sizeof(struct vf_priv_s), 62 | .priv_defaults = &vf_priv_dflt, 63 | .options = vf_opts_fields, 64 | }; 65 | 66 | //===========================================================================// 67 | -------------------------------------------------------------------------------- /video/fmt-conversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_FMT_CONVERSION_H 19 | #define MPLAYER_FMT_CONVERSION_H 20 | 21 | #include 22 | 23 | enum AVPixelFormat imgfmt2pixfmt(int fmt); 24 | int pixfmt2imgfmt(enum AVPixelFormat pix_fmt); 25 | 26 | #endif /* MPLAYER_FMT_CONVERSION_H */ 27 | -------------------------------------------------------------------------------- /video/gpu_memcpy.h: -------------------------------------------------------------------------------- 1 | #ifndef GPU_MEMCPY_SSE4_H_ 2 | #define GPU_MEMCPY_SSE4_H_ 3 | 4 | #include 5 | 6 | void *gpu_memcpy(void *restrict d, const void *restrict s, size_t size); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /video/img_fourcc.h: -------------------------------------------------------------------------------- 1 | #ifndef MPV_IMG_FOURCC_H 2 | #define MPV_IMG_FOURCC_H 3 | 4 | #include "osdep/endian.h" 5 | 6 | #define MP_FOURCC(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((unsigned)(d)<<24)) 7 | 8 | #if BYTE_ORDER == BIG_ENDIAN 9 | #define MP_FOURCC_E(a,b,c,d) MP_FOURCC(a,b,c,d) 10 | #else 11 | #define MP_FOURCC_E(a,b,c,d) MP_FOURCC(d,c,b,a) 12 | #endif 13 | 14 | #define MP_FOURCC_RGB8 MP_FOURCC_E(8, 'B', 'G', 'R') 15 | #define MP_FOURCC_RGB12 MP_FOURCC_E(12, 'B', 'G', 'R') 16 | #define MP_FOURCC_RGB15 MP_FOURCC_E(15, 'B', 'G', 'R') 17 | #define MP_FOURCC_RGB16 MP_FOURCC_E(16, 'B', 'G', 'R') 18 | #define MP_FOURCC_RGB24 MP_FOURCC_E(24, 'B', 'G', 'R') 19 | #define MP_FOURCC_RGB32 MP_FOURCC_E('A', 'B', 'G', 'R') 20 | 21 | #define MP_FOURCC_BGR8 MP_FOURCC_E(8, 'R', 'G', 'B') 22 | #define MP_FOURCC_BGR12 MP_FOURCC_E(12, 'R', 'G', 'B') 23 | #define MP_FOURCC_BGR15 MP_FOURCC_E(15, 'R', 'G', 'B') 24 | #define MP_FOURCC_BGR16 MP_FOURCC_E(16, 'R', 'G', 'B') 25 | #define MP_FOURCC_BGR24 MP_FOURCC_E(24, 'R', 'G', 'B') 26 | #define MP_FOURCC_BGR32 MP_FOURCC_E('A', 'R', 'G', 'B') 27 | 28 | #define MP_FOURCC_YVU9 MP_FOURCC('Y', 'U', 'V', '9') 29 | #define MP_FOURCC_YUV9 MP_FOURCC('Y', 'V', 'U', '9') 30 | #define MP_FOURCC_YV12 MP_FOURCC('Y', 'V', '1', '2') 31 | #define MP_FOURCC_I420 MP_FOURCC('I', '4', '2', '0') 32 | #define MP_FOURCC_IYUV MP_FOURCC('I', 'Y', 'U', 'V') 33 | #define MP_FOURCC_Y800 MP_FOURCC('Y', '8', '0', '0') 34 | #define MP_FOURCC_Y8 MP_FOURCC('Y', '8', ' ', ' ') 35 | #define MP_FOURCC_NV12 MP_FOURCC('N', 'V', '1', '2') 36 | #define MP_FOURCC_NV21 MP_FOURCC('N', 'V', '2', '1') 37 | 38 | #define MP_FOURCC_UYVY MP_FOURCC('U', 'Y', 'V', 'Y') 39 | #define MP_FOURCC_YUY2 MP_FOURCC('Y', 'U', 'Y', '2') 40 | 41 | #define MP_FOURCC_MJPEG MP_FOURCC('M', 'J', 'P', 'G') 42 | 43 | // NOTE: no "HM12" decoder exists, as vd_hmblck has been removed 44 | // likely breaks video with some TV cards 45 | #define MP_FOURCC_HM12 0x32314D48 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /video/mp_image_pool.h: -------------------------------------------------------------------------------- 1 | #ifndef MPV_MP_IMAGE_POOL_H 2 | #define MPV_MP_IMAGE_POOL_H 3 | 4 | #include 5 | 6 | struct mp_image_pool; 7 | 8 | struct mp_image_pool *mp_image_pool_new(int max_count); 9 | struct mp_image *mp_image_pool_get(struct mp_image_pool *pool, int fmt, 10 | int w, int h); 11 | void mp_image_pool_clear(struct mp_image_pool *pool); 12 | 13 | void mp_image_pool_set_lru(struct mp_image_pool *pool); 14 | 15 | struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt, 16 | int w, int h); 17 | 18 | typedef struct mp_image *(*mp_image_allocator)(void *data, int fmt, int w, int h); 19 | void mp_image_pool_set_allocator(struct mp_image_pool *pool, 20 | mp_image_allocator cb, void *cb_data); 21 | 22 | struct mp_image *mp_image_pool_new_copy(struct mp_image_pool *pool, 23 | struct mp_image *img); 24 | bool mp_image_pool_make_writeable(struct mp_image_pool *pool, 25 | struct mp_image *img); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /video/out/aspect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_ASPECT_H 19 | #define MPLAYER_ASPECT_H 20 | 21 | struct mp_log; 22 | struct mp_vo_opts; 23 | struct mp_image_params; 24 | struct mp_rect; 25 | struct mp_osd_res; 26 | void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts, 27 | int vo_caps, struct mp_image_params *video, 28 | int window_w, int window_h, double monitor_par, 29 | struct mp_rect *out_src, 30 | struct mp_rect *out_dst, 31 | struct mp_osd_res *out_osd); 32 | 33 | #endif /* MPLAYER_ASPECT_H */ 34 | -------------------------------------------------------------------------------- /video/out/cocoa/events_view.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #import 19 | #import "video/out/cocoa/mpvadapter.h" 20 | 21 | @interface MpvEventsView : NSView 22 | @property(nonatomic, retain) MpvCocoaAdapter *adapter; 23 | - (void)setFullScreen:(BOOL)willBeFullscreen; 24 | - (void)clear; 25 | - (BOOL)canHideCursor; 26 | - (void)signalMousePosition; 27 | @end 28 | -------------------------------------------------------------------------------- /video/out/cocoa/mpvadapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #import 19 | #include "video/out/vo.h" 20 | 21 | @interface MpvCocoaAdapter : NSObject 22 | - (void)setNeedsResize; 23 | - (void)signalMouseMovement:(NSPoint)point; 24 | - (void)putKeyEvent:(NSEvent*)event; 25 | - (void)putKey:(int)mpkey withModifiers:(int)modifiers; 26 | - (void)putAxis:(int)mpkey delta:(float)delta; 27 | - (void)putCommand:(char*)cmd; 28 | - (void)handleFilesArray:(NSArray *)files; 29 | - (void)didChangeWindowedScreenProfile:(NSScreen *)screen; 30 | - (void)performAsyncResize:(NSSize)size; 31 | - (void)didChangeMousePosition; 32 | 33 | - (BOOL)isInFullScreenMode; 34 | - (BOOL)keyboardEnabled; 35 | - (BOOL)mouseEnabled; 36 | - (NSScreen *)fsScreen; 37 | - (BOOL)fsModeAllScreens; 38 | @property(nonatomic, assign) struct vo *vout; 39 | @end 40 | -------------------------------------------------------------------------------- /video/out/cocoa/video_view.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #import 19 | #import "video/out/cocoa/mpvadapter.h" 20 | 21 | @interface MpvVideoView : NSView 22 | @property(nonatomic, retain) MpvCocoaAdapter *adapter; 23 | - (NSRect)frameInPixels; 24 | @end 25 | -------------------------------------------------------------------------------- /video/out/cocoa/video_view.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #include "osdep/macosx_compat.h" 19 | #include "video/out/cocoa_common.h" 20 | #include "video_view.h" 21 | 22 | @implementation MpvVideoView 23 | @synthesize adapter = _adapter; 24 | 25 | - (id)initWithFrame:(NSRect)frame { 26 | self = [super initWithFrame:frame]; 27 | if (self) { 28 | [self setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)setFrameSize:(NSSize)size 34 | { 35 | [super setFrameSize:size]; 36 | [self.adapter setNeedsResize]; 37 | } 38 | 39 | - (NSRect)frameInPixels 40 | { 41 | return [self convertRectToBacking:[self frame]]; 42 | } 43 | 44 | 45 | - (void)drawRect:(NSRect)rect 46 | { 47 | [self.adapter performAsyncResize:[self frameInPixels].size]; 48 | } 49 | @end 50 | -------------------------------------------------------------------------------- /video/out/cocoa/window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #import 19 | #import "video/out/cocoa/mpvadapter.h" 20 | 21 | @protocol MpvSizing 22 | - (void)queueNewVideoSize:(NSSize)newSize; 23 | @end 24 | 25 | @interface MpvVideoWindow : NSWindow 26 | @property(nonatomic, retain) MpvCocoaAdapter *adapter; 27 | - (BOOL)canBecomeKeyWindow; 28 | - (BOOL)canBecomeMainWindow; 29 | - (void)mulSize:(float)multiplier; 30 | @end 31 | -------------------------------------------------------------------------------- /video/out/cocoa_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Cocoa OpenGL Backend 3 | * 4 | * This file is part of mpv. 5 | * 6 | * mpv is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * mpv is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with mpv. If not, see . 18 | */ 19 | 20 | #ifndef MPLAYER_COCOA_COMMON_H 21 | #define MPLAYER_COCOA_COMMON_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | struct vo; 28 | struct vo_cocoa_state; 29 | 30 | void vo_cocoa_init(struct vo *vo); 31 | void vo_cocoa_uninit(struct vo *vo); 32 | 33 | int vo_cocoa_config_window(struct vo *vo); 34 | 35 | int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg); 36 | 37 | void vo_cocoa_swap_buffers(struct vo *vo); 38 | void vo_cocoa_set_opengl_ctx(struct vo *vo, CGLContextObj ctx); 39 | 40 | #endif /* MPLAYER_COCOA_COMMON_H */ 41 | -------------------------------------------------------------------------------- /video/out/d3d_shader_yuv.hlsl: -------------------------------------------------------------------------------- 1 | // Compile with: 2 | // fxc.exe /Tps_2_0 -DUSE_420P=1 /Fhd3d_shader_420p.h d3d_shader_yuv.hlsl /Vnd3d_shader_420p 3 | // fxc.exe /Tps_2_0 -DUSE_NV12=1 /Fhd3d_shader_nv12.h d3d_shader_yuv.hlsl /Vnd3d_shader_nv12 4 | 5 | // Be careful with this shader. You can't use constant slots, since we don't 6 | // load the shader with D3DX. All uniform variables are mapped to hardcoded 7 | // constant slots. 8 | 9 | sampler2D tex0 : register(s0); 10 | sampler2D tex1 : register(s1); 11 | sampler2D tex2 : register(s2); 12 | 13 | uniform float4x4 colormatrix : register(c0); 14 | 15 | float4 main(float2 t0 : TEXCOORD0, 16 | float2 t1 : TEXCOORD1, 17 | float2 t2 : TEXCOORD2) 18 | : COLOR 19 | { 20 | #ifdef USE_420P 21 | float4 c = float4(tex2D(tex0, t0).x, 22 | tex2D(tex1, t1).x, 23 | tex2D(tex2, t2).x, 24 | 1); 25 | #endif 26 | #ifdef USE_NV12 27 | float4 c = float4(tex2D(tex0, t0).x, 28 | tex2D(tex1, t1).xz, 29 | 1); 30 | #endif 31 | return mul(c, colormatrix); 32 | } 33 | -------------------------------------------------------------------------------- /video/out/dither.h: -------------------------------------------------------------------------------- 1 | void mp_make_fruit_dither_matrix(float *out_matrix, int size); 2 | void mp_make_ordered_dither_matrix(unsigned char *m, int size); 3 | -------------------------------------------------------------------------------- /video/out/drm_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_VT_SWITCHER_H 19 | #define MP_VT_SWITCHER_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | struct kms { 26 | struct mp_log *log; 27 | int fd; 28 | drmModeConnector *connector; 29 | drmModeEncoder *encoder; 30 | drmModeModeInfo mode; 31 | uint32_t crtc_id; 32 | }; 33 | 34 | struct vt_switcher { 35 | int tty_fd; 36 | struct mp_log *log; 37 | void (*handlers[2])(void*); 38 | void *handler_data[2]; 39 | }; 40 | 41 | bool vt_switcher_init(struct vt_switcher *s, struct mp_log *log); 42 | void vt_switcher_destroy(struct vt_switcher *s); 43 | void vt_switcher_poll(struct vt_switcher *s, int timeout_ms); 44 | void vt_switcher_interrupt_poll(struct vt_switcher *s); 45 | 46 | void vt_switcher_acquire(struct vt_switcher *s, void (*handler)(void*), void *user_data); 47 | void vt_switcher_release(struct vt_switcher *s, void (*handler)(void*), void *user_data); 48 | 49 | struct kms *kms_create(struct mp_log *log); 50 | bool kms_setup(struct kms *kms, const char *device_path, int conn_id, int mode_id); 51 | void kms_destroy(struct kms *kms); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /video/out/filter_kernels.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * This file can be distributed under the 3-clause license ("New BSD License"). 5 | * 6 | * You can alternatively redistribute the non-Glumpy parts of this file and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | */ 11 | 12 | #ifndef MPLAYER_FILTER_KERNELS_H 13 | #define MPLAYER_FILTER_KERNELS_H 14 | 15 | #include 16 | 17 | struct filter_window { 18 | const char *name; 19 | double radius; // Preferred radius, should only be changed if resizable 20 | double (*weight)(struct filter_window *k, double x); 21 | bool resizable; // Filter supports any given radius 22 | double params[2]; // User-defined custom filter parameters. Not used by 23 | // all filters 24 | double blur; // Blur coefficient (sharpens or widens the filter) 25 | }; 26 | 27 | struct filter_kernel { 28 | struct filter_window f; // the kernel itself 29 | struct filter_window w; // window storage 30 | bool clamp; // clamp to the range [0-1] 31 | // Constant values 32 | const char *window; // default window 33 | bool polar; // whether or not the filter uses polar coordinates 34 | // The following values are set by mp_init_filter() at runtime. 35 | int size; // number of coefficients (may depend on radius) 36 | double inv_scale; // scale factor (<1.0 is upscale, >1.0 downscale) 37 | }; 38 | 39 | extern const struct filter_window mp_filter_windows[]; 40 | extern const struct filter_kernel mp_filter_kernels[]; 41 | 42 | const struct filter_window *mp_find_filter_window(const char *name); 43 | const struct filter_kernel *mp_find_filter_kernel(const char *name); 44 | 45 | bool mp_init_filter(struct filter_kernel *filter, const int *sizes, 46 | double scale); 47 | void mp_compute_lut(struct filter_kernel *filter, int count, float *out_array); 48 | 49 | #endif /* MPLAYER_FILTER_KERNELS_H */ 50 | -------------------------------------------------------------------------------- /video/out/opengl/context_rpi.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #include "common.h" 7 | 8 | struct mp_egl_rpi { 9 | struct mp_log *log; 10 | struct GL *gl; 11 | EGLDisplay egl_display; 12 | EGLContext egl_context; 13 | EGLSurface egl_surface; 14 | // yep, the API keeps a pointer to it 15 | EGL_DISPMANX_WINDOW_T egl_window; 16 | }; 17 | 18 | int mp_egl_rpi_init(struct mp_egl_rpi *p, DISPMANX_ELEMENT_HANDLE_T window, 19 | int w, int h); 20 | void mp_egl_rpi_destroy(struct mp_egl_rpi *p); 21 | -------------------------------------------------------------------------------- /video/out/opengl/egl_helpers.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #include "egl_helpers.h" 19 | #include "common.h" 20 | 21 | void mp_egl_get_depth(struct GL *gl, EGLConfig fbc) 22 | { 23 | EGLint tokens[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE}; 24 | int *ptrs[] = {&gl->fb_r, &gl->fb_g, &gl->fb_b}; 25 | for (int n = 0; n < MP_ARRAY_SIZE(tokens); n++) { 26 | EGLint depth = 0; 27 | if (eglGetConfigAttrib(eglGetCurrentDisplay(), fbc, tokens[n], &depth)) 28 | *ptrs[n] = depth; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /video/out/opengl/egl_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_GL_EGL_HELPERS_H 2 | #define MP_GL_EGL_HELPERS_H 3 | 4 | #include 5 | #include 6 | 7 | struct GL; 8 | void mp_egl_get_depth(struct GL *gl, EGLConfig fbc); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /video/out/opengl/hwdec_dxva2.c: -------------------------------------------------------------------------------- 1 | #include "common/common.h" 2 | 3 | #include "hwdec.h" 4 | #include "utils.h" 5 | #include "video/d3d.h" 6 | #include "video/hwdec.h" 7 | 8 | // This does not provide real (zero-copy) interop - it merely exists for 9 | // making sure the same D3D device is used for decoding and display, which 10 | // may help with OpenGL fullscreen mode. 11 | 12 | struct priv { 13 | struct mp_d3d_ctx ctx; 14 | }; 15 | 16 | static void destroy(struct gl_hwdec *hw) 17 | { 18 | struct priv *p = hw->priv; 19 | if (p->ctx.d3d9_device) 20 | IDirect3DDevice9_Release(p->ctx.d3d9_device); 21 | } 22 | 23 | static int create(struct gl_hwdec *hw) 24 | { 25 | GL *gl = hw->gl; 26 | if (hw->hwctx || !gl->MPGetNativeDisplay) 27 | return -1; 28 | 29 | struct priv *p = talloc_zero(hw, struct priv); 30 | hw->priv = p; 31 | 32 | p->ctx.d3d9_device = gl->MPGetNativeDisplay("IDirect3DDevice9"); 33 | if (!p->ctx.d3d9_device) 34 | return -1; 35 | 36 | p->ctx.hwctx.type = HWDEC_DXVA2_COPY; 37 | p->ctx.hwctx.d3d_ctx = &p->ctx; 38 | 39 | MP_VERBOSE(hw, "Using libmpv supplied device %p.\n", p->ctx.d3d9_device); 40 | 41 | hw->hwctx = &p->ctx.hwctx; 42 | hw->converted_imgfmt = 0; 43 | return 0; 44 | } 45 | 46 | static int reinit(struct gl_hwdec *hw, struct mp_image_params *params) 47 | { 48 | return -1; 49 | } 50 | 51 | static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, 52 | GLuint *out_textures) 53 | { 54 | return -1; 55 | } 56 | 57 | const struct gl_hwdec_driver gl_hwdec_dxva2 = { 58 | .api_name = "dxva2", 59 | .imgfmt = -1, 60 | .create = create, 61 | .reinit = reinit, 62 | .map_image = map_image, 63 | .destroy = destroy, 64 | }; 65 | -------------------------------------------------------------------------------- /video/out/opengl/lcms.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_GL_LCMS_H 2 | #define MP_GL_LCMS_H 3 | 4 | #include 5 | #include 6 | #include "misc/bstr.h" 7 | 8 | extern const struct m_sub_options mp_icc_conf; 9 | extern const struct mp_icc_opts gl_lcms_opts_vhq_def; 10 | 11 | struct mp_icc_opts { 12 | char *profile; 13 | int profile_auto; 14 | char *cache_dir; 15 | char *size_str; 16 | int intent; 17 | }; 18 | 19 | struct lut3d; 20 | struct mp_log; 21 | struct mpv_global; 22 | struct gl_lcms; 23 | 24 | struct gl_lcms *gl_lcms_init(void *talloc_ctx, struct mp_log *log, 25 | struct mpv_global *global); 26 | void gl_lcms_set_options(struct gl_lcms *p, struct mp_icc_opts *opts); 27 | void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile); 28 | bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **); 29 | bool gl_lcms_has_changed(struct gl_lcms *p); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /video/out/opengl/nnedi3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_GL_NNEDI3_H 19 | #define MP_GL_NNEDI3_H 20 | 21 | #include "config.h" 22 | #include "common.h" 23 | #include "utils.h" 24 | 25 | #define HAVE_NNEDI HAVE_GPL3 26 | 27 | #define NNEDI3_UPLOAD_UBO 0 28 | #define NNEDI3_UPLOAD_SHADER 1 29 | 30 | struct nnedi3_opts { 31 | int neurons; 32 | int window; 33 | int upload; 34 | }; 35 | 36 | extern const struct nnedi3_opts nnedi3_opts_def; 37 | extern const struct m_sub_options nnedi3_conf; 38 | 39 | const float* get_nnedi3_weights(const struct nnedi3_opts *conf, int *size); 40 | 41 | void pass_nnedi3(GL *gl, struct gl_shader_cache *sc, int planes, int tex_num, 42 | int step, float tex_mul, const struct nnedi3_opts *conf, 43 | struct gl_transform *transform); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /video/out/opengl/nnedi3_weights.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/video/out/opengl/nnedi3_weights.bin -------------------------------------------------------------------------------- /video/out/opengl/osd.h: -------------------------------------------------------------------------------- 1 | #ifndef MPLAYER_GL_OSD_H 2 | #define MPLAYER_GL_OSD_H 3 | 4 | #include 5 | #include 6 | 7 | #include "utils.h" 8 | #include "sub/osd.h" 9 | 10 | struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd); 11 | void mpgl_osd_destroy(struct mpgl_osd *ctx); 12 | 13 | void mpgl_osd_set_options(struct mpgl_osd *ctx, bool pbo); 14 | 15 | void mpgl_osd_generate(struct mpgl_osd *ctx, struct mp_osd_res res, double pts, 16 | int stereo_mode, int draw_flags); 17 | enum sub_bitmap_format mpgl_osd_get_part_format(struct mpgl_osd *ctx, int index); 18 | struct gl_vao *mpgl_osd_get_vao(struct mpgl_osd *ctx); 19 | void mpgl_osd_draw_part(struct mpgl_osd *ctx, int vp_w, int vp_h, int index); 20 | int64_t mpgl_get_change_counter(struct mpgl_osd *ctx); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /video/out/opengl/superxbr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_GL_SUPERXBR_H 19 | #define MP_GL_SUPERXBR_H 20 | 21 | #include "common.h" 22 | #include "utils.h" 23 | 24 | extern const struct superxbr_opts superxbr_opts_def; 25 | extern const struct m_sub_options superxbr_conf; 26 | 27 | void pass_superxbr(struct gl_shader_cache *sc, int planes, int tex_num, 28 | int step, float tex_mul, const struct superxbr_opts *conf, 29 | struct gl_transform *transform); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /video/out/opengl/video_shaders.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_GL_VIDEO_SHADERS_H 19 | #define MP_GL_VIDEO_SHADERS_H 20 | 21 | #include 22 | 23 | #include "common.h" 24 | #include "utils.h" 25 | #include "video.h" 26 | 27 | extern const struct deband_opts deband_opts_def; 28 | extern const struct m_sub_options deband_conf; 29 | 30 | void sampler_prelude(struct gl_shader_cache *sc, int tex_num); 31 | void pass_sample_separated_gen(struct gl_shader_cache *sc, struct scaler *scaler, 32 | int d_x, int d_y); 33 | void pass_sample_polar(struct gl_shader_cache *sc, struct scaler *scaler); 34 | void pass_sample_bicubic_fast(struct gl_shader_cache *sc); 35 | void pass_sample_oversample(struct gl_shader_cache *sc, struct scaler *scaler, 36 | int w, int h); 37 | 38 | void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc); 39 | void pass_delinearize(struct gl_shader_cache *sc, enum mp_csp_trc trc); 40 | 41 | void pass_sample_deband(struct gl_shader_cache *sc, struct deband_opts *opts, 42 | int tex_num, GLenum tex_target, float tex_mul, 43 | float img_w, float img_h, AVLFG *lfg); 44 | 45 | void pass_sample_unsharp(struct gl_shader_cache *sc, float param); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /video/out/w32_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MPLAYER_W32_COMMON_H 19 | #define MPLAYER_W32_COMMON_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "common/common.h" 26 | 27 | struct vo; 28 | 29 | int vo_w32_init(struct vo *vo); 30 | void vo_w32_uninit(struct vo *vo); 31 | int vo_w32_control(struct vo *vo, int *events, int request, void *arg); 32 | void vo_w32_config(struct vo *vo); 33 | HWND vo_w32_hwnd(struct vo *vo); 34 | void vo_w32_run_on_thread(struct vo *vo, void (*cb)(void *ctx), void *ctx); 35 | 36 | #endif /* MPLAYER_W32_COMMON_H */ 37 | -------------------------------------------------------------------------------- /video/out/wayland/memfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv video player. 3 | * Copyright © 2014 Alexander Preisinger 4 | * 5 | * mpv is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * mpv is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with mpv. If not, see . 17 | */ 18 | 19 | #ifndef MPLAYER_WAYLAND_MEMFILE_H 20 | #define MPLAYER_WAYLAND_MEMFILE_H 21 | 22 | // create file decsriptor to memory space without filesystem representation 23 | // truncates to size immediately 24 | int memfile_create(off_t size); 25 | 26 | #endif /* MPLAYER_WAYLAND_MEMFILE_H */ 27 | -------------------------------------------------------------------------------- /video/out/win32/displayconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_WIN32_DISPLAYCONFIG_H_ 19 | #define MP_WIN32_DISPLAYCONFIG_H_ 20 | 21 | #include 22 | 23 | // Given a GDI monitor device name, get the precise refresh rate using the 24 | // Windows 7 DisplayConfig API. Returns 0.0 on failure. 25 | double mp_w32_displayconfig_get_refresh_rate(const wchar_t *device); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /video/out/win32/exclusive_hack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of mpv. 3 | * 4 | * mpv is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * mpv is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with mpv. If not, see . 16 | */ 17 | 18 | #ifndef MP_WIN32_EXCLUSIVE_HACK_H_ 19 | #define MP_WIN32_EXCLUSIVE_HACK_H_ 20 | 21 | #include 22 | 23 | // Returns true if any program on the computer is in exclusive fullscreen mode 24 | bool mp_w32_is_in_exclusive_mode(void); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /video/out/win_state.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_WIN_STATE_H_ 2 | #define MP_WIN_STATE_H_ 3 | 4 | #include "common/common.h" 5 | 6 | struct vo; 7 | 8 | enum { 9 | // By user settings, the window manager's chosen window position should 10 | // be overridden. 11 | VO_WIN_FORCE_POS = (1 << 0), 12 | }; 13 | 14 | struct vo_win_geometry { 15 | // Bitfield of VO_WIN_* flags 16 | int flags; 17 | // Position & size of the window. In xinerama coordinates, i.e. they're 18 | // relative to the virtual desktop encompassing all screens, not the 19 | // current screen. 20 | struct mp_rect win; 21 | // Aspect ratio of the current monitor. 22 | // (calculated from screen size and options.) 23 | double monitor_par; 24 | }; 25 | 26 | void vo_calc_window_geometry(struct vo *vo, const struct mp_rect *screen, 27 | struct vo_win_geometry *out_geo); 28 | void vo_apply_window_geometry(struct vo *vo, const struct vo_win_geometry *geo); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /video/out/x11_icon.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/video/out/x11_icon.bin -------------------------------------------------------------------------------- /video/vdpau_mixer.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_VDPAU_MIXER_H_ 2 | #define MP_VDPAU_MIXER_H_ 3 | 4 | #include 5 | 6 | #include "mp_image.h" 7 | #include "vdpau.h" 8 | 9 | struct mp_vdpau_mixer_opts { 10 | int deint; 11 | int chroma_deint; 12 | int pullup; 13 | float denoise; 14 | float sharpen; 15 | int hqscaling; 16 | }; 17 | 18 | #define MP_VDP_HISTORY_FRAMES 2 19 | 20 | struct mp_vdpau_mixer_frame { 21 | // settings 22 | struct mp_vdpau_mixer_opts opts; 23 | // video data 24 | VdpVideoMixerPictureStructure field; 25 | VdpVideoSurface past[MP_VDP_HISTORY_FRAMES]; 26 | VdpVideoSurface current; 27 | VdpVideoSurface future[MP_VDP_HISTORY_FRAMES]; 28 | }; 29 | 30 | struct mp_vdpau_mixer { 31 | struct mp_log *log; 32 | struct mp_vdpau_ctx *ctx; 33 | bool initialized; 34 | 35 | struct mp_image_params image_params; 36 | struct mp_vdpau_mixer_opts opts; 37 | 38 | VdpChromaType current_chroma_type; 39 | int current_w, current_h; 40 | 41 | // set initialized=false to force reinit when changed 42 | struct mp_csp_equalizer video_eq; 43 | 44 | VdpVideoMixer video_mixer; 45 | }; 46 | 47 | struct mp_image *mp_vdpau_mixed_frame_create(struct mp_image *base); 48 | 49 | struct mp_vdpau_mixer_frame *mp_vdpau_mixed_frame_get(struct mp_image *mpi); 50 | 51 | struct mp_vdpau_mixer *mp_vdpau_mixer_create(struct mp_vdpau_ctx *vdp_ctx, 52 | struct mp_log *log); 53 | void mp_vdpau_mixer_destroy(struct mp_vdpau_mixer *mixer); 54 | 55 | int mp_vdpau_mixer_render(struct mp_vdpau_mixer *mixer, 56 | struct mp_vdpau_mixer_opts *opts, 57 | VdpOutputSurface output, VdpRect *output_rect, 58 | struct mp_image *video, VdpRect *video_rect); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /waftools/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | -------------------------------------------------------------------------------- /waftools/checks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/waftools/checks/__init__.py -------------------------------------------------------------------------------- /waftools/detections/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/waftools/detections/__init__.py -------------------------------------------------------------------------------- /waftools/detections/devices.py: -------------------------------------------------------------------------------- 1 | __cdrom_devices_map__ = { 2 | 'win32': 'D:', 3 | 'cygwin': 'D:', 4 | 'darwin': '/dev/disk1', 5 | 'freebsd': '/dev/cd0', 6 | 'openbsd': '/dev/rcd0c', 7 | 'linux': '/dev/sr0', 8 | 'default': '/dev/cdrom' 9 | } 10 | 11 | __dvd_devices_map__ = { 12 | 'win32': 'D:', 13 | 'cygwin': 'D:', 14 | 'darwin': '/dev/rdiskN', 15 | 'freebsd': '/dev/cd0', 16 | 'openbsd': '/dev/rcd0c', 17 | 'linux': '/dev/sr0', 18 | 'default': '/dev/dvd' 19 | } 20 | 21 | def __default_cdrom_device__(ctx): 22 | default = __cdrom_devices_map__['default'] 23 | return __cdrom_devices_map__.get(ctx.env.DEST_OS, default) 24 | 25 | def __default_dvd_device__(ctx): 26 | default = __dvd_devices_map__['default'] 27 | return __dvd_devices_map__.get(ctx.env.DEST_OS, default) 28 | 29 | def configure(ctx): 30 | ctx.define('DEFAULT_DVD_DEVICE', __default_dvd_device__(ctx)) 31 | ctx.define('DEFAULT_CDROM_DEVICE', __default_cdrom_device__(ctx)) 32 | -------------------------------------------------------------------------------- /waftools/fragments/cocoa.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | #include "osdep/macosx_compat.h" 6 | 7 | int main(int argc, char **argv) { 8 | @autoreleasepool { 9 | NSArray *ary = @[@1, @2, @3]; 10 | NSLog(@"test subscripting: %@", ary[0]); 11 | NSApplicationLoad(); 12 | CVDisplayLinkRef link; 13 | CVDisplayLinkCreateWithCGDisplay(0, &link); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /waftools/fragments/coreaudio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv) 6 | { 7 | AudioComponentDescription desc = (AudioComponentDescription) { 8 | .componentType = kAudioUnitType_Output, 9 | .componentSubType = kAudioUnitSubType_DefaultOutput, 10 | .componentManufacturer = kAudioUnitManufacturer_Apple, 11 | }; 12 | 13 | AudioComponentFindNext(NULL, &desc); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /waftools/fragments/dvb.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | int main(void) {return 0;} 11 | -------------------------------------------------------------------------------- /waftools/fragments/gl_x11.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) { 7 | glXCreateContext(NULL, NULL, NULL, True); 8 | glXQueryExtensionsString(NULL, 0); 9 | glXGetProcAddressARB(""); 10 | glXGetCurrentDisplay(); 11 | glFinish(); 12 | (void)GL_RGB32F; // arbitrary OpenGL 3.0 symbol 13 | (void)GL_LUMINANCE16; // arbitrary OpenGL legacy-only symbol 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /waftools/fragments/iconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define INBUFSIZE 1024 5 | #define OUTBUFSIZE 4096 6 | 7 | char inbuffer[INBUFSIZE]; 8 | char outbuffer[OUTBUFSIZE]; 9 | 10 | int main(void) { 11 | size_t numread; 12 | iconv_t icdsc; 13 | char *tocode="UTF-8"; 14 | char *fromcode="cp1250"; 15 | if ((icdsc = iconv_open(tocode, fromcode)) != (iconv_t)(-1)) { 16 | while ((numread = read(0, inbuffer, INBUFSIZE))) { 17 | char *iptr=inbuffer; 18 | char *optr=outbuffer; 19 | size_t inleft=numread; 20 | size_t outleft=OUTBUFSIZE; 21 | if (iconv(icdsc, &iptr, &inleft, &optr, &outleft) 22 | != (size_t)(-1)) { 23 | write(1, outbuffer, OUTBUFSIZE - outleft); 24 | } 25 | } 26 | if (iconv_close(icdsc) == -1) 27 | ; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /waftools/fragments/oss_audio.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) { 4 | return SNDCTL_DSP_SETFRAGMENT; 5 | } 6 | -------------------------------------------------------------------------------- /waftools/fragments/oss_audio_sunaudio.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) { 4 | return SNDCTL_DSP_SETFRAGMENT; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /waftools/fragments/pthreads.c: -------------------------------------------------------------------------------- 1 | #include 2 | static void *func(void *arg) { return arg; } 3 | int main(void) { 4 | pthread_t tid; 5 | return pthread_create (&tid, 0, func, 0) != 0; 6 | } 7 | -------------------------------------------------------------------------------- /waftools/fragments/pvr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) 4 | { 5 | struct v4l2_ext_controls ext; 6 | return !!&ext.controls->value; 7 | } 8 | -------------------------------------------------------------------------------- /waftools/fragments/sse.c: -------------------------------------------------------------------------------- 1 | #pragma GCC push_options 2 | #pragma GCC target("sse4.1") 3 | #include 4 | 5 | void *a_ptr; 6 | 7 | int main(void) 8 | { 9 | __m128i xmm0; 10 | __m128i* p = (__m128i*)a_ptr; 11 | 12 | _mm_sfence(); 13 | 14 | xmm0 = _mm_stream_load_si128(p + 1); 15 | _mm_store_si128(p + 2, xmm0); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /waftools/fragments/wasapi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | const GUID *check1[] = { 10 | &IID_IAudioClient, 11 | &IID_IAudioRenderClient, 12 | &IID_IAudioClient, 13 | &IID_IAudioEndpointVolume, 14 | }; 15 | int main(void) { 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /waftools/generators/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haasn/mpvhq-old/5173b0706f69f4bd180e81d010b684a6b087f952/waftools/generators/__init__.py -------------------------------------------------------------------------------- /waftools/generators/headers.py: -------------------------------------------------------------------------------- 1 | def __cp_to_variant__(ctx, variant, basename): 2 | src = ctx.bldnode.search_node(basename).read() 3 | node = ctx.bldnode.make_node("{0}/{1}".format(variant, basename)) 4 | node.parent.mkdir() 5 | node.write(src) 6 | 7 | def __write_config_h__(ctx): 8 | ctx.start_msg("Writing configuration header:") 9 | ctx.write_config_header('config.h') 10 | __cp_to_variant__(ctx, ctx.options.variant, 'config.h') 11 | ctx.end_msg("config.h", "PINK") 12 | 13 | # Approximately escape the string as C string literal 14 | def __escape_c_string(s): 15 | return s.replace("\"", "\\\"").replace("\n", "\\n") 16 | 17 | def __get_features_string__(ctx): 18 | import inflector 19 | stuff = [] 20 | for dependency_identifier in ctx.satisfied_deps: 21 | defkey = inflector.define_key(dependency_identifier) 22 | if ctx.is_defined(defkey) and ctx.get_define(defkey) == "1": 23 | stuff.append(dependency_identifier) 24 | stuff.sort() 25 | return " ".join(stuff) 26 | 27 | def __add_mpv_defines__(ctx): 28 | from sys import argv 29 | ctx.define("CONFIGURATION", " ".join(argv)) 30 | ctx.define("MPV_CONFDIR", ctx.env.CONFLOADDIR) 31 | ctx.define("FULLCONFIG", __escape_c_string(__get_features_string__(ctx))) 32 | 33 | def configure(ctx): 34 | __add_mpv_defines__(ctx) 35 | __write_config_h__(ctx) 36 | -------------------------------------------------------------------------------- /waftools/generators/sources.py: -------------------------------------------------------------------------------- 1 | from waflib.Build import BuildContext 2 | import os 3 | 4 | def __file2string_cmd__(ctx): 5 | return '"${{BIN_PERL}}" "{0}/TOOLS/file2string.pl" "${{SRC}}" > "${{TGT}}"' \ 6 | .format(ctx.srcnode.abspath()) 7 | 8 | def __matroska_cmd__(ctx, argument): 9 | return '"${{BIN_PERL}}" "{0}/TOOLS/matroska.pl" "{1}" "${{SRC}}" > "${{TGT}}"' \ 10 | .format(ctx.srcnode.abspath(), argument) 11 | 12 | def __zshcomp_cmd__(ctx, argument): 13 | return '"${{BIN_PERL}}" "{0}/TOOLS/zsh.pl" "{1}" > "${{TGT}}"' \ 14 | .format(ctx.srcnode.abspath(), argument) 15 | 16 | def __file2string__(ctx, **kwargs): 17 | ctx( 18 | rule = __file2string_cmd__(ctx), 19 | before = ("c",), 20 | name = os.path.basename(kwargs['target']), 21 | **kwargs 22 | ) 23 | 24 | def __matroska_header__(ctx, **kwargs): 25 | ctx( 26 | rule = __matroska_cmd__(ctx, '--generate-header'), 27 | before = ("c",), 28 | name = os.path.basename(kwargs['target']), 29 | **kwargs 30 | ) 31 | 32 | def __matroska_definitions__(ctx, **kwargs): 33 | ctx( 34 | rule = __matroska_cmd__(ctx, '--generate-definitions'), 35 | before = ("c",), 36 | **kwargs 37 | ) 38 | 39 | def __zshcomp__(ctx, **kwargs): 40 | ctx( 41 | rule = __zshcomp_cmd__(ctx, ctx.bldnode.abspath() + '/mpv'), 42 | after = ("c", "cprogram",), 43 | name = os.path.basename(kwargs['target']), 44 | **kwargs 45 | ) 46 | 47 | BuildContext.file2string = __file2string__ 48 | BuildContext.matroska_header = __matroska_header__ 49 | BuildContext.matroska_definitions = __matroska_definitions__ 50 | BuildContext.zshcomp = __zshcomp__ 51 | -------------------------------------------------------------------------------- /waftools/inflector.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def _underscore(word): 4 | """ Converts a word "into_it_s_underscored_version" 5 | Convert any "CamelCased" or "ordinary Word" into an 6 | "underscored_word".""" 7 | 8 | return re.sub('[^A-Z^a-z^0-9]+', '_', \ 9 | re.sub('([a-z\d])([A-Z])', '\\1_\\2', \ 10 | re.sub('([A-Z]+)([A-Z][a-z])', '\\1_\\2', re.sub('::', '/', word)))).lower() 11 | 12 | def storage_key(dep): 13 | return _underscore(dep) 14 | 15 | def define_key(dep): 16 | return ("have_" + storage_key(dep)).upper() 17 | 18 | def define_dict(dep): 19 | return {'define_name': define_key(dep)} 20 | 21 | def storage_dict(dep): 22 | return {'uselib_store': storage_key(dep)} 23 | -------------------------------------------------------------------------------- /waftools/waf_customizations.py: -------------------------------------------------------------------------------- 1 | from waflib.Configure import conf 2 | 3 | @conf 4 | def get_config_header(self, defines=True, headers=False, define_prefix=''): 5 | """ 6 | Only difference is it outputs `#define VAR 0` or `#define VAR value` 7 | instead of `#undef VAR` or `#define VAR val`. 8 | """ 9 | from waflib.Tools.c_config import DEFKEYS, INCKEYS 10 | lst = [] 11 | if headers: 12 | for x in self.env[INCKEYS]: 13 | lst.append('#include <%s>' % x) 14 | 15 | if defines: 16 | for x in self.env[DEFKEYS]: 17 | val = self.is_defined(x) and self.get_define(x) or "0" 18 | lst.append('#define %s %s' % (define_prefix + x, val)) 19 | 20 | return "\n".join(lst) 21 | 22 | from waflib import TaskGen 23 | 24 | @TaskGen.extension('.m') 25 | def m_hook(self, node): 26 | """ 27 | Makes waf call the c compiler for objective-c files 28 | """ 29 | return self.create_compiled_task('c', node) 30 | 31 | def build(ctx): 32 | from waflib import Task 33 | 34 | cls = Task.classes['cprogram'] 35 | class cprogram(cls): 36 | try: 37 | run_str = cls.orig_run_str + '${LAST_LINKFLAGS}' 38 | except AttributeError: 39 | try: 40 | run_str = cls.hcode + '${LAST_LINKFLAGS}' 41 | except TypeError: 42 | run_str = cls.hcode.decode('iso8859-1') + '${LAST_LINKFLAGS}' 43 | 44 | cls = Task.classes['macplist'] 45 | class macplist(cls): 46 | def run(self): 47 | from waflib import Utils 48 | if getattr(self, 'code', None): 49 | txt = self.code 50 | else: 51 | txt = self.inputs[0].read() 52 | txt = Utils.subst_vars(txt, self.env) 53 | self.outputs[0].write(txt) 54 | --------------------------------------------------------------------------------