summaryrefslogtreecommitdiffstats
path: root/sub
Commit message (Collapse)AuthorAgeFilesLines
* 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).
| * sub: add subtitle charset conversionwm42013-06-251-2/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This code was once part of subreader.c, then traveled to libass, and now made its way back to the fork of the fork of the original code, MPlayer. It works pretty much the same as subreader.c, except that we have to concatenate some packets to do auto-detection. This is rather annoying, but for all we know the actual source file could be a binary format. Unlike subreader.c, the iconv context is reopened on each packet. This is simpler, and with respect to multibyte encodings, more robust. Reopening is probably not a very fast, but I suspect subtitle charset conversion is not an operation that happens often or has to be fast. Also, this auto-detection is disabled for microdvd - this is the only format we know that has binary data in its packets, but is actually decoded to text. FFmpeg doesn't really allow us to solve this properly, because a) the input packets can be binary, and b) the output will be checked whether it's UTF-8, and if it's not, the output is thrown away and an error message is printed. We could just recode the decoded subtitles before sd_ass if it weren't for that.
| * sub: attempt to use video FPS for frame based subtitle formatswm42013-06-251-0/+4
| | | | | | | | | | This only affects demux_subreader.c for now. Maybe there is some hope this can be used for libavformat demuxers too, but I'm not sure yet.
| * sub: add demux_libass wrapper, drop old hackswm42013-06-252-30/+0
| | | | | | | | | | | | | | | | | | | | | | | | demux_libass.c allows us to make subtitle format detection part of the normal file loading process. libass has no probe function, but trying to load the start of a file (the first 4 KB) is good enough. Hope that libass can even handle random binary input gracefully without printing stupid log messages, and that the libass parser doesn't accept too many non-ASS files as input. This doesn't handle the -subcp option correctly yet. This will be fixed later.
| * subreader: turn into actual demuxerwm42013-06-251-65/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | subreader.c (before this commit renamed to demux_subreader.c) was special cased to the -sub option. The plan is using the normal demuxer codepath for all subtitle formats (so we can prefer libavformat demuxers for most formats). There are some subtle changes. The probe size is restricted to 32 KB (instead of unlimitted + giving up after 100 lines of input). For formats like MicroDVD, the video FPS isn't used anymore, because it's not available on the subtitle demuxer level. Instead, hardcode it to 23.976 FPS (libavformat seems to do the same). The user can probably still use -sub-fps to fix the timing. Checking the file extension for ".utf"/".utf8"/".utf-8" is simply removed (seems worthless, was in the way, and I've never seen this anywhere).
| * Move/rename subreader.cwm42013-06-256-1461/+1
| |
| * sd_ass: fix nonsensewm42013-06-251-1/+4
| | | | | | | | | | | | Actually check the newly added text for whitespace, and not the uninitialized buffer after it. Also, if an even is only whitespace, don't add it at all.
| * sd_ass: disable special handling of subtitles with duration 0wm42013-06-252-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sd_ass contains some code that treats subtitle events with duration 0 specially, and adjust their duration so that they will disappear with the next event. This is most likely not needed anymore. Some subtitle formats allow omitting the duration so that the event is visible until the next one, but both subreader.c as well as libavformat subtitle demuxers already handle this. Subtitles embedded in mp4 files (movtext) used to trigger this code. But these files appear to export subtitle duration correctly (at least libavcodec's movtext decoder is using this assumption). Since commit 6dbedd2 changed demux_lavf to actually copy the packet duration field, the code removed with this commit isn't needed anymore for correct display of movtext subtitles. (The change in sd_movtext is for dropping empty subtitle events, which would now be "displayed" - libavcodec does the same.) On the other hand, this code incorrectly displayed hidden events in .srt subtitles. See for example the first event in SubRip_capability_tester.srt (part of FFmpeg's FATE). These intentionally have a duration of 0, and should not be displayed. (As of with this commit, they are still displayed in external .srt subs because of subreader.c hacks.) However, we can't be 100% sure that this code is really unneeded, so just comment the code. Hopefully it can be removed if there are no regressions after some weeks or months.
| * sd_ass: handle libavformat ASS comment packets as wellwm42013-06-232-18/+14
| | | | | | | | | | | | | | | | | | | | | | | | Currently, we are filtering libavformat style ASS packets by checking whether they are prefixed "Dialogue: ". Unfortunately, comment packets are demuxed too. These start with "Comment: ", so they are not caught. Change the filtering, and use the codec ID instead. libavformat uses "ssa" as codec ID for ASS subtitles, while mpv uses "ass". Also, at least FFmpeg will change the ASS packet format to the same format mpv and Matroska use, and identify these with "ass" as codec ID, so this is works out nicely.
| * subreader: remove overlap handling codewm42013-06-231-243/+3
| | | | | | | | | | | | | | | | | | | | | | Some of this (fixing timing) is now done in dec_sub.c (although it's not active for subreader.c code yet - this will be fixed when subreader.c subs are read through a demuxer wrapper). Another reason to remove this is that this code doesn't do much good anymore. libass does handle overlap, and trying to fold overlapping lines into single subtitle events will prevent libass from handling this properly.
| * sub: do some timing postprocessing on preloaded subswm42013-06-231-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the -subfps option (which unfortunately is still useful), and fixes minor annoying timing errors (which unfortunately still happen). Note that none of these affect ASS or image subtitles. ASS is specially handled: libass loads subtitles as ASS_Track. There are no actual packets passed around, and sd_ass just uses the ASS_Track. Disable the --sub-no-text-pp option. It's misleading now and always was completely useless.
| * sub: preload external text subtitleswm42013-06-232-1/+61
| | | | | | | | | | | | | | | | If a subtitle is external, read it completely and add all subtitle events in advance when the subtitle track is selected. This is done for text subtitles only. (Note that subreader.c and subtitles loaded with libass are different and don't have anything to do with this commit.)
| * stream: remove padding parameter from stream_read_complete()wm42013-06-231-1/+1
| | | | | | | | | | | | | | | | Seems like a completely unnecessary complication. Instead, always add a 1 byte padding (could be extended if a caller needs it), and clear it. Also add some documentation. There was some, but it was outdated and incomplete.
* | sd_srt: handle '<font color="##FFA500">'wm42013-06-181-0/+2
|/ | | | Wow this is stupid.
* stream: remove stream_reset()wm42013-06-161-2/+0
| | | | | | | | | This function was called in various places. Most time, it was used before a seek. In other cases, the purpose was apparently resetting the EOF flag. As far as I can see, this makes no sense anymore. At least the stream_reset() calls paired with stream_seek() are completely pointless. A seek will either seek inside the buffer (and reset the EOF flag), or do an actual seek and reset all state.
* sd_srt, sd_microdvd: set ASS script resolutionwm42013-06-033-1/+18
| | | | | | | | | | | | | | | | | Both converters can output \pos and deal with font sizes, so they assume a specific script resolution (PlayResX/PlayResY). The implicit assumption was that a specific resolution was guaranteed. The MP_ASS_FONT_PLAYRESY constant is connected to this. Better make it explicit, so that the implicit dependency on MP_ASS_FONT_PLAYRESY is removed. (Unfortunately, libavcodec sub converters still don't set PlayResX/PlayResY explicitly, so the value set by that constant can't be declared as arbitrary yet.) PlayResY=288 is most likely the SSA natural script resolution (or something like this?), as well as the libass and VSFilter default. PlayResX=384 is the