summaryrefslogtreecommitdiffstats
path: root/sub
Commit message (Collapse)AuthorAgeFilesLines
* sub: fix --sub-gausswm42016-06-174-51/+37
| | | | | | | | | | | | | | | | | | | | Implement it directly in sd_lavc.c as well. Blurring requires extending the size of the sub-images by the blur radius. Since we now want sub_bitmaps to be packed into a single image, and we don't want to repack for blurring, we add some extra padding to each sub-bitmap in the initial packing, and then extend their size later. This relies on the previous bitmap_packer commit, which always adds the padding in all cases. Since blurring is now done on parts of a large bitmap, the data pointers can become unaligned, depending on their position. To avoid shitty libswscale printing a dumb warning, allocate an extra image, so that the blurring pass is done on two newly allocated images. (I don't find this feature important enough to waste more time on it.) The previous refactor accidentally broke this feature due to a logic bug in osd.c. It didn't matter before it happened to break, and doesn't matter now since the code paths are different.
* sub: move paletted image handling completely to sd_lavc.cwm42016-06-175-118/+87
| | | | | | | | | | | | | | | | | | | Until now, subtitle renderers could export SUBBITMAP_INDEXED, which is a 8 bit per pixel with palette format. sd_lavc.c was the only renderer doing this, and the result was converted to RGBA in every use-case (except maybe when the subtitles were hidden.) Change it so that sd_lavc.c converts to RGBA on its own. This simplifies everything a bit, and the palette handling can be removed from the common code. This is also preparation for making subtitle images refcounted. The "caching" in img_convert.c is a PITA in this respect, and needs to be redone. So getting rid of some img_convert.c code is a positive side- effect. Also related to refcounted subtitles is packing them into a single mp_image. Fewer objects to refcount is easier, and for the libass format the same will be done. The plan is to remove manual packing from the VOs which need single images entirely.
* sd_lavc: move AVSubtitle bitmap setup code into its own functionwm42016-06-171-34/+44
| | | | No functional changes.
* sd_lavc: work around bug in older ffmpeg releaseswm42016-05-101-2/+6
| | | | | | | | | | | | | | | Older ffmpeg releases don't have ffmpeg git commit 50401f5fb7d778583b03a13bc4440f71063d319d, which fixes ffmpeg's pkt_timebase check to reject its default "unset" timebase as invalid. The consequence was that all non-PGS bitmap subtitle timestamps were forced to 0. Of course this hit _only_ shitty distros using outdated/badly maintained ffmpeg releases, so this is not worth working around. I've already wasted a lot of time on analyzing this dumb issue, and it could be useful for bisecting, so don't drop pre-3.0 ffmpeg just yet. Fixes #3109.
* ass_process_chunk: Use llrint, not lrintRichard H Lee2016-05-101-2/+2
| | | | | | | | | libass's ass_process_chunk expects long long int for the timecode and durations arguments, thus should use llrint instead of lrint. This does not cause any problems on most platforms, but on cygwin, it causes strange subtitle behaviour, like subtitles not showing, getting stuck or old subtitles showing at the same time as new subtitles.
* osd: make osd_ass_0/1 defineswm42016-05-033-11/+9
| | | | So we can concatenate them with strings at compile time.
* sd_ass: minor consistency adjustmentwm42016-04-301-2/+2
|
* sd_add: replace --sub-ass=no with --ass-style-override=stripwm42016-04-301-1/+2
| | | | | | --sub-ass=no / --ass=no still work, but --ass-style-override=strip is preferred now. With this change, --ass-style-override can control all the types of style overriding.
* osd: add italic font for osdst4t1k2016-04-083-0/+3
|
* sub: interpret "text" subtitles as srtwm42016-04-061-0/+3
| | | | | Most players will interpret HTML-style tags (aka srt) in almost any kind of text subtitles; make mpv do this too.
* sd_lavc: use decoder-reordered PTS for PGSwm42016-04-021-3/+21
| | | | | | | | | | | | | | | | There is an obscure feature which requires essentially reordering PTS from different packets. Unfortunately, libavcodec introduced a ridiculously shitty API for this, which works very much unlike the audio/video API. Instead of simply passing through the PTS, it wants to fuck with it for no reason, and even worse, fucks with other fields and changes their semantivcs (??????). This affects AVSubtitle.end_display_time. This probably will cause issues for us, and I have no desire to find out whether it will. Since only PGS requires this, and it happens not to use end_display_time, do it for PGS only. Fixes #3016.
* sd_lavc: add a comment about duration==0 handlingwm42016-04-021-1/+3
| | | | | | | | Basically, this information is useless, because some muxers (hurr libavformat) write bogus information anyway. This means if we e.g. see PGS packets in mkv with duration explicitly set to 0, we must not trust that value anyway. (The FFmpeg API problem is leaking into files, how nice.)
* sd_lavc: fix subtitle display with unknown end timestampswm42016-04-021-1/+1
| | | | | This is a theoretical issue, because subtitle end timestamps for all but the current subtitle are always known.
* sub: force segment switch if video is already aheadwm42016-03-251-0/+8
| | | | | | | | | | | | In particular, this prevents subtitle packets from building up in the subtitle queue if e.g. --vo=null is used. In this situation, sub_get_bitmaps() is never called, and thus the segment never switched. This also seems to help with flickering at segment switch boundaries (if subs are supposed to be visible at the transition points). In theory, this could trigger a switch too early, but the way VO and subtitle renderer interact wrt. timing is a bit iffy anyway.
* vo_opengl, osd: allow osc.lua to react faster on resizeswm42016-03-212-6/+30
| | | | | | | | | Glitches when resizing are still possible, but are reduced. Other VOs could support this too, but don't need to do so. (Totally avoiding glitches would be much more effort, and probably not worth the trouble. How about you just watch the video the player is playing, instead of spending your time resizing the window.)
* osd: fix build with --disable-libasswm42016-03-161-1/+1
|
* osd: cleanup: make OSDTYPE_ constants private to OSD codewm42016-03-083-21/+28
| | | | | | No need to have them everywhere. The only exception/annoyance is MAX_OSD_PARTS, which is now basically duplicated (and at runtime initialization is checked with an assert()).
* osd, lua: manage multiple ASS overlays set with set_osd_ass() callswm42016-03-085-41/+83
| | | | | | | | | | | | | | | | | | | | | | | | | Until now, there was only 1 global ASS overlay that could be set by all scripts. This was often perceived as bug when multiple scripts tried to set their own ASS overlay. This was kind of hard to solve because the script could set its own ASS PlayResX/Y, which makes it impossible to share a single ASS_Renderer for multiple scripts. The OSC unfortunately makes use of this feature (and unfortunately can't be fixed because it's a POS), so we're stuck with this complication. Implement the worst-case solution and fix this by creating separate ASS track and renderer objects for each script that wants to set an ASS overlay. The z-order is decided by the order the scripts set their text first. This is essentially random, unless you do it at script init, and you pass scripts in a specific order. Script initialization is currently serialized (as a feature), so the first loaded script gets lowest Z-order. The Lua script API interestingly remains the same. (And also will remain undocumented, unsupported, and potentially volatile.)
* osd: restructure and move ASS objects into its own structwm42016-03-082-61/+81
| | | | | | All ASS objects used by the OSD renderer go into struct ass_state. Preparation for the following commit.
* osd: refactor how mp_ass_render_frame() is calledwm42016-03-086-16/+22
| | | | | | | | Instead of passing an explicit cache to the function, the res parameter is used. Also, instead of replacing its contents, sub bitmaps are now appended to it (all assuming the format doesn't actually change). This is preparation for the following commits.
* osd, lua: remove weird OSD scalingwm42016-03-074-39/+0
| | | | | | | | | | | | | | | | | | | | | Do not scale OSD mouse input to the ASS OSD script resolution. The original idea of this mechanism was that the user doesn't have to care about the actual resolution of anything, and can just use the OSD resolution consistently. But this made things worse. Remove the implicit scaling, and always use the screen resolution. (Except with --vo=xv, where additional scaling is forced upon everything.) Drop get_osd_resolution(). There is no replacement. Rename get_screen_size() and get_screen_margins() to use "osd" instead of "screen". For anything but --vo=xv these are equivalent, but with --vo=xv the OSD resolution has additional implicit scaling. Add code to osc.lua which emulates the old behavior. Note that none of the changed functions were public API, so implicit breakage of scripts which used it is just going to happen.
* osd: remove unused osd_coords_to_video()wm42016-03-072-22/+0
| | | | Used to be used for dvdnav.
* sub: make preloading more robustwm42016-03-064-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Subtitles can be preloaded, which means they're fully read and copied into ASS_Track. This in turn is mainly for the sake of being able to do subtitle seeking (when it comes down to it, subtitle seeking is the cause for most trouble here). Commit a714f8e92 broke preloaded subtitles which have events with unknown duration, such as some MicroDVD samples. The event list gets cleared on every seek, so the property of being preloaded obviously gets lost. Fix this by moving most of the preloading logic to dec_sub.c. If the subtitle list gets cleared, they are not considered preloaded anymore, and the logic for demuxed subtitles is used. As another minor thing, preloadeding subtitles did neither disable the demux stream, nor did it discard packets. Thus you could get queue overflows in theory (harmless, but annoying). Fix this by explicitly discarding packets in preloaded mode. In summary, now the only difference between preloaded and normal demuxing are: 1. a seek is issued, and all packets are read on start 2. during playback, discard the packets instead of feeding them to the subtitle decoder This is still petty annoying. It would be nice if maintaining the subtitle index (and maybe a subtitle packet cache for instant subtitle presentation when seeking back) could be maintained in the demuxer instead. Half of all file formats with interleaved subtitles have this anyway (mp4, mkv muxed with newer mkvmerge).
* sd_ass: always clear subtitles on seek if duration unknownwm42016-03-051-1/+1
| | | | | | | Although there is logic to prune subtitles as soon as they get too old in this mode, this is not done for the _currently_ shown subtitles. Thus explicitly clearing subtitles on seek is required to avoid duplicate subtitles in certain cases when seeking.
* sd_ass: always handle subtitles with unknown durationwm42016-03-051-2/+14
| | | | | | | | | | | Deals with broken mkv subtitle tracks generated by tvheadend. The subs are srt, but without packet durations. We need this logic for CCs anyway. CCs in particular will be unaffected by this change because they are also marked with unknown duration. It could be that there are actual demuxers outputting CCs - in this case, we rely on the fact that they don't set a (meaningless) packet duration (or we'd have to work that around).
* sub: pass all attachments to the subtitle decoderwm42016-03-034-13/+19
| | | | | | | | | | | | | | | | | Commit 8d4a179c made subtitle decoders pick up fonts strictly from the same source file (i.e. the same demuxer). It breaks some fucked up use-case, and 2 people on this earth complained about the change because of this. Add it back. This copies all attached fonts on each subtitle init. I considered converting attachments to use refcounting, but it'd probably be much more complex. Since it's slightly harder to get a list of active demuxers with duplicate removed, the prev_demuxer variable serves as a hack to achieve almost the same thing, except in weird corner cases. (In which fonts could be added twice.)
* lavc_conv: fix Libav srt subtitleswm42016-02-291-4/+1
| | | | | | | | Use the mp_lavc_set_extradata() function instead of setting up the extradata manually. This takes care of the corner case when extradata_len is 0. This apparently fixes #2888.
* sub: always clip subtitles against segment endwm42016-02-201-1/+5
| | | | | | | | | | | | This happens only if the new segment wasn't read yet. This is not quite proper and a problem with dec_sub.c internals. Ideally, it'd wait with rendering until a new enough segment has been read. Normally, the new segment is available immediately, so the end will be automatically clipped by switching to the right segment in the exact moment it's supposed to become effective. Usually shouldn't cause any problems, though.
* Rewrite ordered chapters and timeline stuffwm42016-02-151-2/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This uses a different method to piece segments together. The old approach basically changes to a new file (with a new start offset) any time a segment ends. This meant waiting for audio/video end on segment end, and then changing to the new segment all at once. It had a very weird impact on the playback core, and some things (like truly gapless segment transitions, or frame backstepping) just didn't work. The new approach adds the demux_timeline pseudo-demuxer, which presents an uniform packet stream from the many segments. This is pretty similar to how ordered chapters are implemented everywhere else. It also reminds of the FFmpeg concat pseudo-demuxer. The "pure" version of this approach doesn't work though. Segments can actually have different codec configurations (different extradata), and subtitles are most likely broken too. (Subtitles have multiple corner cases which break the pure stream-concatenation approach completely.) To counter this, we do two things: - Reinit the decoder with each segment. We go as far as allowing concatenating files with completely different codecs for the sake of EDL (which also uses the timeline infrastructure). A "lighter" approach would try to make use of decoder mechanism to update e.g. the extradata, but that seems fragile. - Clip decoded data to segment boundaries. This is equivalent to normal playback core mechanisms like hr-seek, but now the playback core doesn't need to care about these things. These two mechanisms are equivalent to what happened in the old implementation, except they don't happen in the playback core anymore. In other words, the playback core is completely relieved from timeline implementation details. (Which honestly is exactly what I'm trying to do here. I don't think ordered chapter behavior deserves improvement, even if it's bad - but I want to get it out from the playback core.) There is code duplication between audio and video decoder common code. This is awful and could be shareable - but this will happen later. Note that the audio path has some code to clip audio frames for the purpose of codec preroll/gapless handling, but it's not shared as sharing it would cause more pain than it would help.
* sub: move sub decoder init to a functionwm42016-02-151-30/+44
| | | | Preparation for timeline rewrite.
* sub: remove always-true checkwm42016-02-121-1/+1
| | | | | | | Confuses Coverity with FORWARD_NULL on the mp_err() at the end of the function. These pointers are never NULL. Fixes CID 1350059.
* sub: implement "sub-seek 0"wm42016-02-041-5/+12
| | | | | | | For bitmap subs, implement it properly. For libass, you need newest git master. Fixes #2791.
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-195-35/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This covers source files which were added in mplayer2 and mpv times only, and where all code is covered by LGPL relicensing agreements. There are probably more files to which this applies, but I'm being conservative here. A file named ao_sdl.c exists in MPlayer too, but the mpv one is a complete rewrite, and was added some time after the original ao_sdl.c was removed. The same applies to vo_sdl.c, for which the SDL2 API is radically different in addition (MPlayer supports SDL 1.2 only). common.c contains only code written by me. But common.h is a strange case: although it originally was named mp_common.h and exists in MPlayer too, by now it contains only definitions written by uau and me. The exceptions are the CONTROL_ defines - thus not changing the license of common.h yet. codec_tags.c contained once large tables generated from MPlayer's codecs.conf, but all of these tables were removed. From demux_playlist.c I'm removing a code fragment from someone who was not asked; this probably could be done later (see commit 15dccc37). misc.c is a bit complicated to reason about (it was split off mplayer.c and thus contains random functions out of this file), but actually all functions have been added post-MPlayer. Except get_relative_time(), which was written by uau, but looks similar to 3 different versions of something similar in each of the Unix/win32/OSX timer source files. I'm not sure what that means in regards to copyright, so I've just moved it into another still-GPL source file for now. screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but they're all gone.
* vd_lavc: feed A53_CC side data packets into the demuxer for eia_608 decodingAman Gupta2016-01-181-2/+16
|
* lavc_conv: pass real_time=1 option to ffmpeg for eia_608 decoderAman Gupta2016-01-181-1/+7
|
* ass_mp: add mp_ass_flush_old_events()Aman Gupta2016-01-182-0/+15
|
* sub: fix memory leakswm42016-01-181-3/+6
| | | | | | | | | demux_lavf.c leaked the complete subtitle data if it was put through iconv. lavc_conv.c leaked AVCodecContext.subtitle_header (set by libavcodec), which is fixed by using avcodec_free_context(). It also leaked the subtitle that was decoded last.
* osd: make osd-width/height properties watchablewm42016-01-151-2/+7
|
* demux: merge sh_video/sh_audio/sh_subwm42016-01-124-11/+11
| | | | | | | | | | This is mainly a refactor. I'm hoping it will make some things easier in the future due to cleanly separating codec metadata and stream metadata. Also, declare that the "codec" field can not be NULL anymore. demux.c will set it to "" if it's NULL when added. This gets rid of a corner case everything had to handle, but which rarely happened.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-117-7/+7
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* sub: read subtitles until their timestamps are past videowm42016-01-111-1/+1
| | | | | Change >= to >, because if the timestamps are equal, further subtitle packets with the same timestamps could be required (e.g. ASS).
* sd_ass: fix memory leaks with --sub-ass=nowm42016-01-041-1/+4
| | | | This affects only the codepath which forcibly disables any ASS tags.
* sub: do not check for duplicates if --sub-clear-on-seek is setwm42015-12-311-1/+5
|
* sub: change how subtitles are readwm42015-12-292-15/+35
| | | | | | | | Slightly change how it is decided when a new packet should be read. Switch to demux_read_packet_async(), and let the player "wait properly" until required subtitle packets arrive, instead of blocking everything. Move distinguishing the cases of passive and active reading into the demuxer, where it belongs.
* sub: remove packet list thingwm42015-12-281-27/+1
| | | | | Just a simplification. This packet list lost its function a dozen of commits ago or so.
* sub: do charset conversion in demux_lavf.cwm42015-12-281-34/+2
| | | | | | | | | | | | | Just so I can remove a few lines from dec_sub.c. This is slightly inelegant, as the whole subtitle file has to be read into memory, converted at once in memory, and then provided to libavformat in an awkward way by creating a memory stream instead of using demuxer->stream. It also won't be possible to force the charset on subtitles in binary container formats - but this wasn't exposed before, and we just hope this won't be ever needed. (One motivation was fixing broken files with non-UTF8 muxed.) It also won't be possible to change the charset on the fly, but this was not exposed either.
* sub: refactor initializationwm42015-12-276-135/+66
| | | | | | | | Just simplify by removing parts not needed anymore. This includes merging dec_sub allocation and initialization (since things making initialization complicated were removed), or format support queries (it simply tries to create a decoder, and if that fails, tries the next one).
* sub: minor refactor how video FPS for MicroDVD is setwm42015-12-274-25/+26
| | | | | | | | | So that the video FPs is not required at initialization, and can be set later. (As for whether this MicroDVD crap is worth the trouble to handle it "correctly": MicroDVD files are unfortunately still around, and in at least one case using the video FPS seemed to help indeed.)
* sub: destroy/recreate ASS_Renderer when disabling/enablings subswm42015-12-264-8/+32
| | | | | | | Keeping ASS_Renderers around for a potentially large number of subtitle tracks could lead to excessive memory usage, especially since the libass cache is broken (caches even unneeded data), and might consume up to ~500MB of memory for no reason.
* sub: always recreate ASS_Renderer on subtitle decoder reinitwm42015-12-264-38/+74
| | | | | | | This includes the case of switching ordered chapter boundaries. It will now be recreated on each timeline part switch. This shouldn't be much of a problem with modern libass. (Older libass versions use fontconfig for memory fonts, and will be very slow to reinitialize memory fonts.)
* sub: cache subtitle state per track instead of per demuxer streamwm42015-12-262-13/+4
| | | | | | | | | | | | Since commit 6d9cb893, subtitle state doesn't survive timeline switches (ordered chapters etc.). So there is no point in caching the state per sh_stream anymore (which would be required to deal with multiple segments). Move the cache to struct track. (Whether it's worth caching the subtitle state just for the situation when subtitle tracks get reselected is questionable. But for now, it's nice to have the subtitles immediately show up when reselecting a subtitle.)
* sub: clear subtitle list when crossing timeline boundarywm42015-12-252-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When crossing timeline boundaries (such as switching to a new segment or chapter with ordered chapters), clear the internal text subtitle list. This breaks the sub-seek command, but is otherwise not too harmful. Fixes Sub-OC-test-final7.mkv. (The internal text subtitle list is basically a cache to make subtitles show up at the right time when seeking back.) I suspect this was caused by 76fcef61. The sample file times subtitles slightly before the video frame when it should show up. This is to avoid problems with subtitles showing up a frame later than intended. It also means that a subtitle which is supposed to show up on the start of a timeline part boundary actually might first be shown in a differe