summaryrefslogtreecommitdiffstats
path: root/sub
Commit message (Collapse)AuthorAgeFilesLines
* sd_lavc, sd_spu: make dvdsub stretching conditional on --stretch-dvd-subs.Rudolf Polzer2013-11-074-8/+40
| | | | | | | | | | | | We found that the stretching - although it usually improves the looks of the fonts - is incorrect. On DVD, subtitles can cover the full area of the picture, and they have the same pixel aspect as the movie itself. Too bad many commercially released DVDs use bitmap fonts made with the wrong pixel aspect (i.e. assuming 1:1) - --stretch-dvd-subs will make these more pretty then.
* sd_ass, sd_lavc: use the input video's pixel aspect for scaling subtitles.Rudolf Polzer2013-11-072-4/+25
| | | | | | | The previous code used the output video's pixel aspect for stretching purposes, breaking rendering with e.g. -vf scale in the chain. Now subtitles are stretched using the input video's pixel aspect only, matching the intentions of the original subtitle author.
* configure: uniform the defines to #define HAVE_xxx (0|1)Stefano Pigozzi2013-11-032-3/+3
| | | | | | | | | | | | | | | | | | | | | The configure followed 5 different convetions of defines because the next guy always wanted to introduce a new better way to uniform it[1]. For an hypothetic feature 'hurr' you could have had: * #define HAVE_HURR 1 / #undef HAVE_DURR * #define HAVE_HURR / #undef HAVE_DURR * #define CONFIG_HURR 1 / #undef CONFIG_DURR * #define HAVE_HURR 1 / #define HAVE_DURR 0 * #define CONFIG_HURR 1 / #define CONFIG_DURR 0 All is now uniform and uses: * #define HAVE_HURR 1 * #define HAVE_DURR 0 We like definining to 0 as opposed to `undef` bcause it can help spot typos and is very helpful when doing big reorganizations in the code. [1]: http://xkcd.com/927/ related
* sd_lavc: display DVD subs with unknown durationwm42013-10-311-0/+6
| | | | | | | | | | | | | | | | | | DVD subs (rarely) have subtitle events without end timestamp. The duration is unknown, and they should be displayed until they're replaced by the next event. FFmpeg fails hard to make us aware whether duration is unknown or actually 0, so we can't distinguish between these two cases. It fails at this twice: AVPacket.duration is set to 0 if duration is unknown, and AVSubtitle.end_display_time has the same issue. Add a hack that considers all bitmap subtitles with duration==0 as events with uknown length. I'd rather accidentally display a hidden subtitle (if they exist at all), instead of not displaying random subtitles at all. See github issue #325.
* command: sub_seek: avoid getting stuckwm42013-10-071-2/+5
| | | | | | | | | First, don't try to seek if the result is 0 (i.e. nothing found, or subtitle event happens to be exactly on spot). Second, since we never can make sure that we actually seek to the exact subtitle PTS (seeking "snaps" to video PTS), offset the seek by 10ms. Since most subtitle events are longer than 10ms, this should work fine.
* command: add commands for displaying overlayswm42013-10-052-0/+8
| | | | | | Requested by github issue #255. Does not work where mmap is not available (i.e. Windows).
* command: add properties for retrieving OSD dimensionswm42013-10-052-0/+5
|
* osd_libass: add "Default" dummy stylewm42013-09-263-2/+11
| | | | | | This is pretty much a hack for the OSC. It will allow it to rely on a somewhat predictable style, instead of having to overwrite all user OSD settings manually with override tags.
* Add initial Lua scripting supportwm42013-09-264-0/+70
| | | | | | | | | | | | | | | | | | | | | | This is preliminary. There are still tons of issues, and any aspect of scripting may change in the future. I decided to merge this (preliminary) work now because it makes it easier to develop it, not because it's done. lua.rst is clear enough about it (plus some sarcasm). This requires linking to Lua. Lua has no official pkg-config file, but there are distribution specific .pc files, all with different names. Adding a non-pkg-config based configure test was considered, but we'd rather not. One major complication is that libquvi links against Lua too, and if the Lua version is different from mpv's, you will get a crash as soon as libquvi uses Lua. (libquvi by design always runs when a file is opened.) I would consider this the problem of distros and whoever builds mpv, but to make things easier for users, we add a terrible runtime test to the configure script, which probes whether libquvi will crash. This is disabled when cross-compiling, but in that case we hope the user knows what he is doing.
* options: allow selecting the libass shaperwm42013-09-251-0/+3
| | | | | | I'm using the word "languages" instead of "scripts" in the manpage, but I think that's easier to understand with a smaller amount of descriptions.
* options: make --ass-hinting a choice, instead of using magic numberswm42013-09-251-1/+1
| | | | | options.c still doesn't use the constants defined by the libass headers, but it's still better than exposing those to the user directly.
* sd_ass: minor simplificationwm42013-09-241-14/+8
| | | | | There shouldn't be any functional changes. Just reduce the amount of pointless temporary variables.
* sd_ass: remove dead codewm42013-09-241-48/+0
| | | | | | This code was made inactive some months ago. At this time it wasn't entirely clear whether this code was still needed, but now I'm pretty sure it isn't. Even if it is, it didn't work anymore.
* sub/ass_mp: remove superfluous message prefixesMartin Herkt2013-09-231-3/+2
|
* find_subfiles: fix really dumb bug causing segfaultswm42013-09-171-1/+1
| | | | | | | NULL pointer deref when a .sub file with the same filename as the video file was present. I was probably half asleep when writing this code.
* find_subfiles: fix off-by-1 errorGabriel Peixoto2013-09-081-1/+1
| | | | | | | This could lead to a segfault, fixes #219 Signed-off-by: Gabriel Peixoto <gabrielrcp@gmail.com> Signed-off-by: wm4 <wm4@nowhere>
* osc: rename osd_font, add some glyphsChrisK22013-09-082-4/+2
| | | | | | | | | | Cherry picked from various commits in lua_experiment by ChrisK2. The metrics of the OSD symbols change slightly, possibly due to the font editor that was used, and the metrics were not correct to begin with. (But the real reason seems unknown.) Remove the rescaling of the OSD font in ASS_USE_OSD_FONT, because the height more or less fits now. (This change wasn't in the lua_experiment branch.)
* osd_libass: make sure Z-order is well defined for multiple eventswm42013-09-081-0/+1
| | | | Otherwise, events may overlap in arbitrary ways.
* mplayer: don't auto-load explicitly loaded subtitle fileswm42013-09-071-0/+4
| | | | | | | | | | | Even if a subtitle was explicitly loaded with -sub, it was still auto- loaded (if auto-loading applied to that file). Fix this by explicitly checking whether a file is already loaded. The check is maximal naive and just compares the filenames as strings. The change in find_subfiles.c is so that "-sub something.ass" happens to work (auto-loading prepended a "./" to it, so the naive filename comparison check didn't work).
* find_subfiles: don't auto-load .sub file if .idx file existswm42013-09-071-22/+55
| | | | | | | | | | | | | | | | External vobsubs usually come as .idx/.sub pairs. Loading the .idx file implicitly loads the .sub file, whereas loading the .sub file will kind of work, but miss important information such as subtitle resolution. Or in other words, if the .idx file exists, adding the .sub file as track is useless and confusing. Explicitly remove .sub file from the auto-load suntitle list in these cases. Standalone .sub files are still loaded. We also drop that weird logic that excluded .utf8 files from being loaded if -subcp was in use. I hope the associated use case didn't make much sense to begin with. If not, we could still implement it properly, instead of this weird hack.
* find_subfiles: some cleanupswm42013-09-072-8/+0
| | | | | | | Remove a crap assert() (what... either it can't happen, or it should error or at least abort() if it can't be handled). Remove some dead definitions.
* find_subfiles: use stat() instead of opening the file to check existencewm42013-09-071-3/+1
| | | | | | | Use mp_path_exists() to check for existence of a file (which in turn uses stat()), instead of opening and closing it. The difference is that if we don't have sufficient permissions to read the subtitle files, we will loudly complain. Personally, I prefer this behavior.
* find_subfiles: don't try to open URLs as directorieswm42013-09-071-0/+3
| | | | | Did things like opendir("http://..."). Makes no sense, and just generates noise.
* sd_lavc_conv: fix build with older ffmpeg/libavwm42013-08-241-0/+17
| | | | Sigh...
* sub: add webvtt-in-webm supportwm42013-08-241-1/+124
| | | | | | | | | | | | | | The way this was added to FFmpeg is less than ideal, because it requires text parsing in the Matroska demuxer. But in order to use the FFmpeg webvtt-to-ass converter, we still have to mimic this in some way. We do this by putting the parsing into sd_lavc_conv.c, before the subtitle packet is passed to libavcodec. At least this keeps the ugliness out of unrelated code. There is some change that FFmpeg will fix their design eventually. Instead of rewriting the parsing code, we simply borrow it from FFmpeg's Matroska demuxer.
* sd_lavc_conv: don't check AV_CODEC_PROP_TEXT_SUB flagwm42013-08-151-7/+3
| | | | | | | | Not actually useful. This would break whenever a new text subtitle format would be added, which requires a binary->text transformation. (mov_text is one such format; disable it.) In general, we would have to know which packet formats are binary, which we don't, so the only reasonable way to handle this is a white list.
* sub: don't print detected charset if it's UTF-8wm42013-08-151-1/+1
| | | | | Too noisy. This also fixes that iconv() was called if "utf8" was used as codepage.
* sub: if charset detection fails, treat it as broken UTF-8wm42013-08-151-1/+1
| | | | | | | | | | | Broken UTF-8 in this context means we treat it as UTF-8, but we also interpret broken UTF-8 sequences as Latin1. Also, run our own UTF-8 check function before the charset detectors. This prevents from ENCA's UTF-8 check possibly messing up (like detecting 7-bit clean UTF-8 as ASCII, or other things). It also takes care of UTF-8 detection if no charset detector (ENCA, libguess) is compiled in, and it lets us deal better with cut-off UTF-8 sequences.
* sub: fix accidental subtitle overlapswm42013-08-141-1/+6
| | | | | | | | | | | | | | | | | | The fix_overlaps_and_gaps() function in dec_sub.c fixes small gaps or overlaps between subtitle events. However, sometimes it could happen that the corrected subtitle events could overlap by 1ms due to bad rounding, making libass shift subtitles to reduce collisions. (The second subtitle will be shown above the previous one, even if both subtitles are visible only for 1ms.) sd_ass.c rounds the timestamps when converting to integers for unknown reasons. I think it would work fine without that rounding, but since I have no clue why it rounds, and since it could be needed to ensure correct timestamps with ASS subtitles demuxed from Matroska, I'd rather not touch it. So the solution is to use already rounded timestamps to calculate the new subtitle duration in fix_overlaps_and_gaps(). See github issue #182.
* Revert "sub: support straight alpha additionally to premultiplied alpha"wm42013-08-124-92/+17
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 689a25003fc8098e5fdfbb2faefc0e18365d3acb, with some adjustments to code that was added after that commit. I just messed up big time. We don't need this, and in fact the commit confused straight and premultiplied alpha at one point (just a simple inverted condition due to an oversight), which is why it looked like it was working. In commit 2827295 I wrote: Also, libva can't decide whether it accepts straight or premultiplied alpha for OSD sub-pictures [...] That was just me messing up and being severely confused by my own bugs. VA API uses premultiplied alpha, which by the way is nice and thoughtful of the VA API devs. Well, this was stupid. But in the end, I'm glad that I could actually reduce codesize by a good amount again.
* img_convert: add function to scale RGBA OSD imageswm42013-08-122-1/+46
|
* sub: support straight alpha additionally to premultiplied alphawm42013-08-124-16/+91
| | | | | | | | | This is for VAAPI support. VAAPI does not support premultiplied alpha for OSD. (Normally, we prefer premultiplied, because it has better behavior on scaling.) I'm not sure whether blending in the ASS->RGBA part is correct and I didn't test it extensively.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-0615-35/+35
| | | | Followup commit. Fixes all the files references.
* Fix some -Wshadow warningswm42013-07-232-6/+6
| | | | | | In general, this warning can hint to actual bugs. We don't enable it yet, because it would conflict with some unmerged code, and we should check with clang too (this commit was done by testing with gcc).
* sd_ass: remove unused variable warningStefano Pigozzi2013-07-201-1/+1
| | | | The `track` variable is used only if `LIBASS_VERSION >= 0x01020000`.
* sws_utils: don't recursively include libswscale headerwm42013-07-181-0/+1
| | | | Add libswscale includes where they are actually needed instead.
* sd_lavc: don't stretch DVD subtitles to video aspectwm42013-07-161-4/+16
| | | | | | | | | | | | | | | | | | | | | | I'm not sure what's correct: stretching the DVD subtitles from storage aspect ratio to video display aspect ratio, or displaying subtitles using 1:1 PAR. Until now, DVD subtitles (as well as all other bitmap subtitles) were always stretched to the video. There are good arguments why this would be the correct behavior: DVDs were made for playback on TV, which display anamorphic video by adjusting the horizontal refresh rate, and thus wouldn't even be capable of DVD subtitles with square PAR (other than resampling the subtitles additionally). However, I haven't seen a sample yet where subtitles do _not_ look stretched using this method. Rendering them at 1:1 PAR looks better. Technically, we render them at display PAR (and not 1:1 PAR). Do this in a way so that the subtitle area is always inside of the video frame if display and video aspect ratios mismatch. For DVB subtitles, the old method looks more correct, so this is special cased to DVD subtitles. I might revert this commit if it turns out that it's an disimprovement.
* sd_ass: fix font aspect ratio with non-ASS subswm42013-07-161-4/+4
| | | | | | For subtitles that were not ASS, the subtitle font aspect was always set to that of the video, the exact opposite of how it was supposed to behave.
* Fix build on Libav (again)wm42013-07-151-0/+1
| | | | | | .... This time actually tested with an actual Libav copy.
* Fix build on Libavwm42013-07-151-0/+1
| | | | Sigh, why does this happen all the time...
* sd_ass: scale blur by original video size if requestedwm42013-07-151-0/+9
|
* sd_add: add terrible hack for (xy-)vsfilter compatibilitywm42013-07-152-9/+133
| | | | | | Much has been said about this topic, we don't need to say even more. See additions to options.rst.
* Cleanup some include statementswm42013-07-121-1/+1
|
* demux: remove facility for partial packet readswm42013-07-111-2/+3
| | | | | | | | | | | | | | | | | | Partial packet reads were needed because the video/audio parsers were working on top of them. So it could happen that a parser read a part of a packet, and returned that to the decoder. With libavformat/libavcodec, packets are already parsed, and everything is much simpler. Most of the simplifications in ad_spdif could have been done earlier. Remove some other stuff as well, like the questionable slave mode start time reporting (could be replaced by proper code, but we don't bother). Remove the unused skip_audio_frame() functionality as well (it was used by old demuxers). Some functions become private to demux.c, like demux_fill_buffer(). Introduce new packet read functions, which have simpler semantics. Packets returned from them are owned by the caller, and all packets in the demux.c packet queue are considered unread. Remove special code that dropped subtitle packets with size 0. This used to be needed because it caused special cases in the old code.
* Merge branch 'master' into remove_old_demuxerswm42013-07-081-1/+1
|\ | | | | | | | | | | Conflicts: DOCS/man/en/changes.rst DOCS/man/en/options.rst
| * sub: Do not use deprecated “Sans” fontconfig aliasMartin Herkt2013-07-081-1/+1
| |
* | Remove old demuxerswm42013-07-071-0/+1
|/ | | | | | | | | | Delete demux_avi, demux_asf, demux_mpg, demux_ts. libavformat does better than them (except in rare corner cases), and the demuxers have a bad influence on the rest of the code. Often they don't output proper packets, and require additional audio and video parsing. Most work only in --no-correct-pts mode. Remove them to facilitate further cleanups.
* sd_lavc: respect forced subs only setting for DVD subswm42013-06-291-3/+9
| | | | | Like the old spudec.c code did. Untested, I (probably) don't have a sample with subtitles that have this flag set.
* sd_ass: convert pts to integer for get_text()wm42013-06-291-3/+2
| | | | Gives more consistent rounding, which makes sub_step behave better.
* dec_sub: introduce sub_control(), use it for sub_stepwm42013-06-294-16/+34
| | | | | | | This means the direct libass usage can be removed from command.c, and no weird hacks for retrieving the ASS_Track are needed. Also fix a bug when using this feature with ordered chapters.
* sub: update subtitle time offset even if pausedwm42013-06-292-2/+2
| | | | | | This was changed as part of commit b44202b as an intended simplification, but it's actually nicer to have the subtitles update immediately even if paused.
* core: rename mplayer.h and quvi.cwm42013-06-281-1/+0
| | | | | | mplayer.h used to be used for much more stuff, but all what is left are quvi related definitions. Rename quvi.c as well to make its purpose clearer.
* dec_sub: fix memory leak when using subtitle codepage conversionwm42013-06-281-0/+1
|
* dec_sub: don't print sub charset of it's emptywm42013-06-281-1/+1
|
* Merge branch 'sub_mess2'wm42013-06-2511-1833/+384
|\ | | | | | | ...the return.
| * options: add -sub-speed optionwm42013-06-251-2/+9
| | | | | | | | | | | | | | | | Should we actually get into trouble for unproper handling of frame-based subtitle formats, this might be the simplest way to work this around. Also is a bit more intuitive than -subfps, which might use an unknown, misdetected, or non-sense video FPS. Still pretty silly, though.
| * dec_sub: add hack to display last MicroDVD subtitle eventwm42013-06-251-0/+11
| | | | | | | | The old subreader.c infrastructure handled this in a similar way.
| * sub: add hack for Libav SRT demuxerwm42013-06-252-1/+101
| | | | | | | | | | | | | | Before this commit, SRT demuxing and display actually happened to work on Libav. But it was using the libavcodec srt converter (which is essentially unmaintained in Libav), and timing postprocessing didn't work. For some background explanations see sd_lavf_srt.c.
| * dec_sub: allow postprocessing between decoderswm42013-06-251-14/+41
| | | | | | | | | | | | | | Until now, timing and charset recoding postprocessing was applied on packets as they were output by the demuxer, and then passed to the decoders. Make it so that postprocessing can happen after some decoders in special situations.
| * dec_sub: change sublist memory allocationwm42013-06-251-10/+9
| |
| * dec_sub: move code aroundwm42013-06-251-45/+51
| |
| * sub: prevent subtitle conversion if subs are known UTF-8wm42013-06-251-1/+1
| | | | | | | | | | Currently this happens only in an obscure case (reading UTF-16 files with the old subreader).
| *