summaryrefslogtreecommitdiffstats
path: root/core
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'sub_mess'wm42013-06-049-357/+209
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This branch heavily refactors the subtitle code (both loading and rendering), and adds support for a few new formats through FFmpeg. We don't remove any of the old code yet. There are still some subtleties related to subreader.c to be resolved: code page detection & conversion, timing post-processing, UTF-16 subtitle support, support for the -subfps option. Also, SRT reading and loading ASS via libass should be turned into proper demuxers. (SRT is needed because Libav's is gravely broken, and we want ASS loading via libass to cover full libass format support. Both should be demuxers which are probed _before_ libavformat, so that all subtitles can be loaded through the demuxer infrastructure, and libavformat subtitles don't need to be treated in a special way.)
| * sub: always show subtitles on terminal with -no-videowm42013-06-041-2/+4
| | | | | | | | | | | | | | | | | | | | | | Until now, this happened only when the -no-ass option was used. This difference in behavior doesn't make much sense, so change it so that whether -no-ass is used or not doesn't matter. (-no-ass enables the OSD subtitle renderer, which has the terminal fallback, while the normal path is video only.) the changes in set_osd_subtitle() and reinit_video_chain() are for resetting the state correctly when switching between video/no-video.
| * core: add common function to initialize AVPacketwm42013-06-032-0/+22
| | | | | | | | | | | | | | | | | | | | Audio and video had their own (very similar) functions to initialize an AVPacket (ffmpeg's packet struct) from a demux_packet (mplayer's packet struct). Add a common function for these. Also use this function for sd_lavc_conv. This is actually a functional change, as some libavfilter subtitle demuxers add weird out-of-band stuff as side-data.
| * sub: pass subtitle packets directlywm42013-06-031-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this, subtitle packets were returned as data ptr/len pairs, and mplayer.c got the rest (pts and duration) directly from the demuxer data structures. Then mplayer.c reassembled the packet data structure again. Pass packets directly instead. The mplayer.c side stays a bit awkward, because the (now by default unused) DVD path keeps getting in the way. In demux.c there's lots of weird stuff (3 functions that read packets, really?), but we want to keep the code equivalent for now to avoid hitting weird issues and corner cases.
| * sub: use libass even if -no-ass is usedwm42013-06-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The -no-ass option used to disable all use of libass completely. This doesn't work this way anymore, and the text subtitle path has an inherent dependency on libass. Currently -no-ass does 3 things: 1. Strip tags and formatting on display, and use a separate renderer for the result. (Which might be the terminal, or libass via OSD code.) 2. Not loading attached fonts from Matroska files. 3. Use subreader.c instead of libass for reading .ass files. 1. and 2. are ok and what the user (probably wants), but 3. doesn't really make sense anymore. subreader.c reads .ass files just fine, but then does some strange things to them (something about coalescing and re-adding newlines?), leading to even more broken display with -no-ass. Instead of fighting with subreader.c, just use libass as loader.
| * sub: turn subassconvert_ functions into sub converterswm42013-06-031-20/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This means subassconvert.c is split in sd_srt.c and sd_microdvd.c. Now this code is involved in the sub conversion chain like sd_movtext is. The invocation of the converter in sd_ass.c is removed. This requires some other changes to make the new sub converter code work with loading external subtitles. Until now, subtitles loaded via subreader.c was assumed to be in plaintext, or for some formats, in ASS (except in -no-ass mode). Then these were added to an ASS_Track. Change this so that subtitles are always in their original format (as far as decoders/converters for them are available), and turn every sub event read by subreader.c as packet to the dec_sub.c subtitle chain. This removes differences between external/demuxed and -ass/-no-ass code paths further.
| * sub: basic subtitle converterswm42013-06-031-7/+0
| | | | | | | | | | | | | | | | | | | | Add a basic infrastructure for subtitle converters. These converters work sort-of like decoders, except that they produce packets instead of subtitle bitmaps. They are put in front of actual decoders. Start with sd_movtext. 4 lines of code are blown up to a 55 lines file, but fortunately this is not going to be that bad for the following converters.
| * sub: refactorwm42013-06-012-33/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the sub decoder stuff independent from sh_sub (except for initialization of course). Sub decoders now access a struct sd only, instead of getting access to sh_sub. The glue code in dec_sub.c is similarily independent from osd. Some simplifications are made. For example, the switch_id stuff is unneeded: the frontend code just has to make sure to call osd_changed() any time subtitles are switched. This is also preparation for introducing subtitle converters. It's much cleaner to completely separate demuxer header/renderer glue/decoders for this purpose, especially since sub converters might completely change how demuxer headers have to be interpreted. Also pass data as demux_packets. Currently, this doesn't help much, but libavcodec converters might need scary stuff like packet side data, so it's perhaps better to go with passing packets.
| * core: add demux_sub pseudo demuxerwm42013-06-012-42/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Subtitle files are opened in mplayer.c, not using the demuxer infrastructure in general. Pretend that this is not the case (outside of the loading code) by opening a pseudo demuxer that does nothing. One advantage is that the initialization code is now the same, and there's no confusion about what the difference between track->stream, track->sh_sub and mpctx->sh_sub is supposed to be. This is a bit stupid, and it would be much better if there were proper subtitle demuxers (there are many in recent FFmpeg, but not Libav). So for now this is just a transition to a more proper architecture. Look at demux_sub like an artifical limb: it's ugly, but don't hate it - it helps you to get on with your life.
| * sub: various minor subtitle related changeswm42013-06-011-11/+10
| | | | | | | | Just pushing some code around.
| * sub: remove some global variableswm42013-05-305-19/+32
| |
| * options: add --no-sub-visibility for symmetrywm42013-05-302-24/+2
| | | | | | | | | | Not really useful, but for symmetry with the sub-visibility property (mapped to the 'v' key by default).
| * sub: add sd_spu.c to wrap spudec, cleanup mplayer.cwm42013-05-303-132/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This unifies the subtitle rendering path. Now all subtitle rendering goes through sd_ass.c/sd_lavc.c/sd_spu.c. Before that commit, the spudec.h functions were used directly in mplayer.c, which introduced many special cases. Add sd_spu.c, which is just a small wrapper connecting the new subtitle render API with the dusty old vobsub decoder in spudec.c. One detail that changes is that we always pass the palette as extra data, instead of passing the libdvdread palette as pointer to spudec directly. This is a bit roundabout, but actually makes the code simpler and more elegant: the difference between DVD and non-DVD dvdsubs is reduced. Ideally, we would just delete spudec.c and use libavcodec's DVD sub decoder. However, DVD playback with demux_mpg produces packets incompatible to lavc. There are incompatibilities the other way around as well: packets from libavformat's vobsub demuxer are incompatible to spudec.c. So we define a new subtitle codec name for demux_mpg subs, "dvd_subtitle_mpg", which only sd_spu can decode. There is actually code in spudec.c to "assemble" fragments into complete packets, but using the whole spudec.c is easier than trying to move this code into demux_mpg to fix subtitle packets. As additional complication, Libav 9.x can't decode DVD subs correctly, so use sd_spu in that case as well.
| * sub: use DVD PTS fallback code in normal sub decoding pathwm42013-05-301-0/+14
| | | | | | | | | | | | | | | | | | | | It appears demux_mpg doesn't output timestamps for subtitles. The vobsub code handled this by doing its own PTS calculations. This code is absent from the normal subtitle decoder path. Copy this code into the normal path, so that we can unify the subtitle decoder paths in a later commit. Decoding subtitles with sd_lavc when playing DVD with demux_mpg still doesn't work.
| * sub: redo how -no-ass is handledwm42013-05-304-121/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The -no-ass switch used to disable any use of libass for text subtitles. This is not really the case anymore, because libass is now always involved when rendering text. The only remaining use of -no-ass is disabling styling or showing subtitles on the terminal. On the other hand, the old subtitle rendering path is a big reason why the subtitle code is still a big mess with an awful number of obscure special cases. In order to simplify it, remove the old subtitle rendering code, and always go through sd_ass.c. Basically, we use ASS_Track as central data structure for storing text subtitles instead of struct sub_data. This also makes libass mandatory for all text subs, even if they are printed to the terminal in -no-video mode. (We could add something like sd_text to avoid this, but it's not worth the trouble.) struct sub_data and subreader.c are still around, even its ASS/SSA reader. But struct sub_data is freed right after converting it to ASS_Track. The internal ASS reader actually can handle some obscure cases libass can't, like files encoded in UTF-16.
* | fix build on linuxStefano Pigozzi2013-06-031-0/+2
| | | | | | | | missing ifdef in the previous commit made the build fail
* | osx: add Apple Remote supportStefano Pigozzi2013-06-036-3/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After killing the non functional AR support in c8fd9e5 I got much complaints so this adds AR support back in (and it works). I am using the HIDRemote class by Felix Schwarz and that part of the code is under the BSD license. I slightly modified it replacing [NSApplication sharedApplication] with NSApp. The code of the class is quite complex (probably because it had to deal with all the edge cases with IOKit) but it works nicely as a black box. In a later commit I'll remove the deprecation warnings caused by HIDRemote's usage of Gestalt. Check out `etc/input.conf` for the default bindings. Apple Remote functionality is automatically compiled in when cocoa is enabled. It can be disabled at runtime with the `--no-ar` option.
* | osx: create macosx_events to deal with keyDown eventsStefano Pigozzi2013-06-032-0/+8
| | | | | | | | | | | | On OSX with Cocoa enabled keyDown events are now handled with addLocalMonitorForEventsMatchingMask:handler:. This allows to respond to events even when there is no VO initialized but the GUI is focused.
* | m_option: fix -vo opengl lscale validationwm42013-06-031-0/+7
|/ | | | | | | | | OPT_STRING_VALIDATE actually did nothing. This made -vo opengl crash or misbehave when passing an invalid value for the lscale, cscale or 3dlut- size (the only users for this option type). The code added with this commit was either blatantly forgotten with the commit introducing this option type, or somehow lost.
* core: avoid deselecting and reselecting stream needlesslywm42013-05-291-2/+6
| | | | | | | | | The core deselected all streams on initialization, and then selected the streams it actually wanted. This was no problem for demux_mkv/demux_lavf, but old demuxers (like demux_asf) could lose some packets. The problem is that these demuxers can buffer some data on initialization, which then is flushed on track switching. Fix this by explicitly avoiding deselecting a wanted stream.
* options: remove some questionable -lavdopts suboptionswm42013-05-292-12/+0
| | | | | | Most of these are rather questionable, the rest you rarely need to set manually. You still can set all of them with -lavdopts-o (because libavcodec has AVOptions for them).
* mplayer: fix volume setting with --gapless-audiowm42013-05-292-16/+26
| | | | | | | | | | | | | | | | | | | | | Playing something with "mpv f1.mkv f2.mkv --gapless-audio --volume=20" caused the volume to be reset when playing a new file. Normally, the volume should not be reset (unless explicitly requested with per-file options), and without either --gapless-audio or --volume it works as expected. The underlying problem is that volume was saved only when the AO was uninitialized, and also the volume was always set when starting a file. Fix this by saving the volume when playback ends, and when the audio is reinitialized. To make sure the volume is never restored twice or saved in the wrong situation, introduce INITIALIZED_VOL. Also note that this volume saving and restoring only happens if the --volume option is used. mixer.c does its own bookkeeping of volume. The main reason for this is that the volume option could be reset by per-file options (see manpage), and mixer.c doesn't know anything about this stuff. This is probably dumb, and maybe some things could be simplified. But for now this will work.
* demux_lavf: minimal probing and reduced analyzeduration for AAC over HTTPwm42013-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | When AAC is streamed over HTTP, using libavformat defaults is pathetically slow. One solution for that is skipping probing and using the mimetype to identify that it's AAC instead. This is what we did before this commit (and ffmpeg does it too, but their logic is too "inaccessible" for mpv). This is still pretty fragile though. Make it a bit more robust by requiring minimal probing. A probescore of 25 is reached after feeding 2 KB to libavformat (instead of > 500 KB for the normal probescore), so use that. This is done only when streaming AAC from HTTP to reduce the possibility of weird breakages for other formats. Also reduce analyzeduration. The default analyzeduration will make libavformat read lots of data, which makes playback start slow. So we set analyzeduration to a low value. On the other hand, doing that for other formats is risky, because there are unspecified effects with certain "strange" formats (like transport streams). So we do this only if we're streaming AAC from HTTP as well. tl;dr libavformat is shit for media players
* options: add allow-mimetype suboption for demux_lavfwm42013-05-272-0/+4
| | | | | | | This can control whether demux_lavf should use the HTTP mime type to determine the format, instead of probing the data with the libavformat API. Do this to allow easier debugging in case the mimetype is incorrect. (This is done only for AAC streams right now.)
* mplayer: output status line normally with --no-consolecontrolswm42013-05-271-1/+1
| | | | | | | | | | | | | | In commit 0e07189, I made the status line always print a newline, instead of cutting the output at 80 columns (or if stderr is a terminal, whatever width the terminal reports). This is better in the case the output goes into a log file or a pipe. This caused problems for people who want to pipe raw video to mpv, so change it again. (Not sure why they won't use FIFOs instead.) Now output untrimmed lines if the slave mode flag is set, which makes sense to do, too. The current slave mode is still on life support, though.
* Replace calls to usec_sleep()wm42013-05-262-2/+2
| | | | | | This is just dumb sed replacement to mp_sleep_us(). Also remove the now unused usec_sleep() wrapper.
* Replace all calls to GetTimer()/GetTimerMS()wm42013-05-267-75/+66
| | | | | | | | | | | | | | | | | | | | | | GetTimer() is generally replaced with mp_time_us(). Both calls return microseconds, but the latter uses int64_t, us defined to never wrap, and never returns 0 or negative values. GetTimerMS() has no direct replacement. Instead the other functions are used. For some code, switch to mp_time_sec(), which returns the time as double float value in seconds. The returned time is offset to program start time, so there is enough precision left to deliver microsecond resolution for at least 100 years. Unless it's casted to a float (or the CPU reduces precision), which is why we still use mp_time_us() out of paranoia in places where precision is clearly needed. Always switch to the correct time. The whole point of the new timer calls is that they don't wrap, and storing microseconds in unsigned int variables would negate this. In some cases, remove wrap-around handling for time values.
* vo: rip out VO timer wakeup mechanism againwm42013-05-261-12/+2
| | | | | | | This was used by some VOs to do timing of cursor autohiding, but we recently moved that out of the VOs. Even though this mechanism might be a good idea and could be needed again in future (but for what?), it's unused now. So better just get rid of it.
* timer: refactor, add 64 bit timer functionwm42013-05-261-5/+2
| | | | | | | | | | | | | | Make OS specific timer code export a mp_raw_time_us() function, and add generic implementations of GetTimer()/GetTimerMS() using this function. New mpv code is supposed to call mp_time_us() in situations where precision is absolutely needed, or mp_time_s() otherwise. Make it so that mp_time_us() will return a value near program start. We don't set it to 0 though to avoid confusion with relative vs. absolute time. Instead, pick an arbitrary offset. Move the test program in timer-darwin.c to timer.c, and modify it to work with the generic timer functions.
* core: do mouse cursor hiding business in frontendwm42013-05-265-7/+57
| | | | | Do this so that not every VO backend has to setup a timer for cursor hiding and interpret the --cursor-autohide option.
* vf_lavfi: allow setting avoptswm42013-05-261-0/+4
|
* macosx_application: implement "Quit & remember position"Stefano Pigozzi2013-05-231-1/+1
| | | | | | | Add a menu item to quit and save the current playback position using the code added with commit ce9a854. Fixes #85
* command: auto-insert yadif when switching deinterlacingwm42013-05-231-6/+40
| | | | | | | | | | | | | | | | | | | | | | | If VO deinterlacing is unavailable, try to insert vf_yadif. If vf_lavfi is available, actually use vf_yadif from libavfilter. The libavfilter version of this filter is faster, more correct, etc., so it is preferred. Unfortunately vf_yadif obviously doesn't support VFCTRL_GET/SET_DEINTERLACE, and with the current state of the libavfilter API, it doesn't look like there is any simple way to emulate it. Instead, we simply insert the filter with a specific label, and if deinterlacing is to be disabled, the filter is removed again by label. This won't do the right thing if the user inserts any deinterlacing filter manually (except native vf_yadif, which understands the VFCTRL). For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing) will just insert a second deinterlacer filter. In these cases, the user is supposed to map a command that toggles his own filter instead of using 'D' and the deinterlace property. The same applies if the user wants to pass different parameters to the deinterlacer filters.
* m_option: allow removing filter entries by content with -vf-delwm42013-05-231-89/+88
| | | | | | | | | | | | | | If a complete filter description is passed to -vf-del, search for an existing filter with the same label or the same name/arguments, and delete it. The rules for filter entry equality are the same as with the -vf-toggle option. E.g. -vf-add gradfun=123:gradfun=456 -vf-del gradfun=456 does what you would expect.
* m_option: move code aroundwm42013-05-231-139/+146
| | | | Move the helper functions for parsing -vf, and rename some.
* m_option, vf: add label supportwm42013-05-232-25/+83
| | | | | | | | | | | | | | | | | Can be used to refer to filters by name. Intended to be used when the filter chain is changed at runtime. A label can be assigned to a filter by prefixing it with '@name:', where 'name' is an user-chosen identifier. For example, a filter added with '-vf-add @label1:gradfun=123' can be removed with '-vf-del @label1'. If a filter with an already existing label is added, the existing filter is replaced with the new filter (this happens for both -vf-add and -vf-pre). If a filter is replaced, the new filter takes the position of the old filter, instead of being appended/prepended to the filter chain as usual. For -vf-toggle, labels are compared if at least one of the filters has a label; otherwise they are compared by filter name and arguments (like before). This means two filters are never considered equal if one has a label and the other one does not.
* core: support mpv directory itself as a valid location for config files on ↵elevengu2013-05-231-9/+22
| | | | | | | | | | Windows This prefers ./ on Windows if-and-only-if the file being searched for already exists there. (If the mpv directory is non-writable, the result is still intended behavior.) This change is transparent to most users because the user has to move the config files there intentionally, and if anything, not being detected would be the surprising behavior.
* mplayer: don't cut status line if --no-consolecontrols is usedwm42013-05-211-1/+4
|
* options: remove dead -dr1 optionwm42013-05-212-3/+0
|
* dec_video: get rid of two global variableswm42013-05-213-3/+6
|
* mplayer: re-add some legacy slave mode output for issue #92wm42013-05-211-5/+15
| | | | | | In the long run this should be done differently. ID_... output sucks. This commit will be reverted as soon as I have a good idea how this should be done properly.
*