summaryrefslogtreecommitdiffstats
path: root/sub
Commit message (Collapse)AuthorAgeFilesLines
* ass: remove some pointless ifdefferywm42014-07-221-4/+0
| | | | | This will print compiler warnings about unused variables with older libass versions, but that's harmless.
* Revert "Remove DVD and Bluray support"wm42014-07-152-0/+19
| | | | | | This reverts commit 4b93210e0c244a65ef10a566abed2ad25ecaf9a1. *shrug*
* Remove DVD and Bluray supportwm42014-07-142-19/+0
| | | | It never worked well. Just remux your DVD and BD images to mkv.
* build: include <strings.h> for strcasecmp()wm42014-07-102-0/+2
| | | | | | | It happens to work without strings.h on glibc or with _GNU_SOURCE, but the POSIX standard requires including <strings.h>. Hopefully fixes OSX build.
* Audit and replace all ctype.h useswm42014-07-013-10/+9
| | | | | | | | | | | | | | | | Something like "char *s = ...; isdigit(s[0]);" triggers undefined behavior, because char can be signed, and thus s[0] can be a negative value. The is*() functions require unsigned char _or_ EOF. EOF is a special value outside of unsigned char range, thus the argument to the is*() functions can't be a char. This undefined behavior can actually trigger crashes if the implementation of these functions e.g. uses lookup tables, which are then indexed with out-of-range values. Replace all <ctype.h> uses with our own custom mp_is*() functions added with misc/ctype.h. As a bonus, these functions are locale-independent. (Although currently, we _require_ C locale for other reasons.)
* Basic xdg directory implementationKenneth Zhou2014-06-262-3/+3
| | | | | | | | | | Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files. This also negates the need to have separate user and global variants of mp_find_config_file() Closes #864, #109. Signed-off-by: wm4 <wm4@nowhere>
* sd_lavc: fix stupiditywm42014-06-191-2/+5
| | | | | | Reallocating an array while you still have pointers to it -> bad idea. Recent regression.
* sd_lavc: improve bitmap subtitle timingwm42014-06-181-71/+103
| | | | | | | | | | | | | | | | | | | | | Until now, bitmap subtitles were decoded at "some" point, and then simply replaced the old subtitle. Although the subtitle is selected by time (PTS), it could happen that a subtitle was replaced too early. One consequence is that this might lead to flicker even if the subtitles are timed to follow each other without a gap (although most subtitles are explicitly timed to introduce such a gap). With this commit the past 4 subtitles are kept (instead of 1), so that the correct one can be picked by time. This should fix the aforementioned cases, but more importantly will allow demuxing/decoding and video display to be somewhat asynchronous. Still missing: somehow making sure the correct range of decoded subtitles is available, instead of just passing along whatever comes from the demuxer, and hoping that 4 queued subtitles are enough. But it should certainly be good enough for now. This removes a check that resets the subtitles if the PTS is 5 minutes before the end of the current subtitle; this is probably not needed.
* video: introduce failure path for image allocationswm42014-06-173-16/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, failure to allocate image data resulted in a crash (i.e. abort() was called). This was intentional, because it's pretty silly to degrade playback, and in almost all situations, the OOM will probably kill you anyway. (And then there's the standard Linux overcommit behavior, which also will kill you at some point.) But I changed my opinion, so here we go. This change does not affect _all_ memory allocations, just image data. Now in most failure cases, the output will just be skipped. For video filters, this coincidentally means that failure is treated as EOF (because the playback core assumes EOF if nothing comes out of the video filter chain). In other situations, output might be in some way degraded, like skipping frames, not scaling OSD, and such. Functions whose return values changed semantics: mp_image_alloc mp_image_new_copy mp_image_new_ref mp_image_make_writeable mp_image_setrefp mp_image_to_av_frame_and_unref mp_image_from_av_frame mp_image_new_external_ref mp_image_new_custom_ref mp_image_pool_make_writeable mp_image_pool_get mp_image_pool_new_copy mp_vdpau_mixed_frame_create vf_alloc_out_image vf_make_out_image_writeable glGetWindowScreenshot
* sub: prefer ffmpeg microdvd converter over internal onewm42014-06-151-1/+1
| | | | | | We certainly don't want to maintain and improve the internal converter, but we still need the internal one for Libav. (In the Libav case, demux_subreader.c will be used to read the MicroDVD file.)
* video/out: change aspects of OSD handlingwm42014-06-153-20/+0
| | | | | | | | | Let the VOs draw the OSD on their own, instead of making OSD drawing a separate VO driver call. Further, let it be the VOs responsibility to request subtitles with the correct PTS. We also basically allow the VO to request OSD/subtitles at any time. OSX changes untested.
* sub: add --sub-scale-with-window optionwm42014-06-141-4/+7
| | | | Implements the feature requested in #839 and #186.
* options: remove use of an inverted option valuewm42014-06-131-1/+1
| | | | | Now MPOpts.sub_fix_timing corresponds to the commandline switch directly, instead of storing the inverted value.
* Add more constwm42014-06-116-8/+8
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* osd: Center the volume icon in the osd fontChrisK22014-06-101-0/+0
|
* sub: remove old style override optionwm42014-06-051-27/+0
| | | | Didn't work too well.
* sub: add --ass-style-override=force optionwm42014-06-051-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (The old "force" choice of that option is renamed to "force-default".) This allows overriding native ASS script subtitle styles with the style provided by the --sub-text-* options (like --sub-text-font etc.). This is disabled by default, and needs to be explicitly enabled with the --ass-style-override=force option and input property. This uses in fact exactly the same options (--sub-text-*) and semantics as the ones used to configure unstyled text subtitles. It's recommended to combine this with this in the mpv config file: ass-force-style="ScaledBorderAndShadow=1" # work around dumb libass behavior Also, adding a key binding to toggle this behavior should be added, because overriding can easily break: L cycle ass-style-override This would cycle override behavior on Shift+L and allows quickly disabling/enabling style overrides. Note: ASS should be considered a vector format rather than a subtitle format. There is no easy or reliable way to determine whether the style of a given subtitle event can be changed without destroying visuals or not. This patch relies on a simple heuristic, which often works and often breaks.
* osd/libass: use BorderStyle=4 for backgroundwm42014-06-011-0/+11
| | | | Avoids (some) overlaps. Hopefully fixes #822.
* sub: fix undefined behavior in ASS color calculation (2)wm42014-05-101-2/+2
| | | | Same problem as previous commit, fix by using the MP_ASS_RGBA() macro.
* sub: fix undefined behavior in ASS color calculationwm42014-05-101-1/+1
| | | | | | | This might shift bits into the sign, which is undefined behavior. Making the right operand unsigned was supposed to help with this, but it seems it did nothing, and C99 makes the result type dependent on the left operand only.
* options: merge ---sub-auto-match with --sub-autowm42014-05-041-2/+2
| | | | There's no reason why these should be separate.
* osd: make code C99wm42014-04-261-5/+3
| | | | | | | This used an unnamed union, which is allowed in GNU C and C11, but not C99. This broke the build with some older compilers. Replaces pull request #744.
* video: make mp_image use mp_image_params directlywm42014-04-211-10/+10
| | | | | Minor cleanup, so that we can stuff more information into mp_image_params later.
* ass_mp: don't use --subcp for --ass-styleswm42014-03-311-1/+1
| | | | | | | | | | | | | The --ass-styles option is implemented by calling ass_read_styles(). This function can take a codepage (so libass will use iconv to convert it). This was implemented before our --subcp option was changed, and this code was not updated. Now libass fails opening iconv, because --subcp is not always (and not by default) a valid iconv codepage. Just always pass NULL, which means the file passed to --ass-styles must be in UTF-8. The --ass-styles option is a fringe option anyway (and will destroy your subtitles), so having codepage support for it isn't important at all.
* Remove some more unneeded version checkswm42014-03-161-5/+1
| | | | | All of these check against things that happened before the latest supported FFmpeg/Libav release.
* sub: remove old MPlayer DVD sub decoderwm42014-03-165-946/+0
| | | | | The DVD sub decoder in Libav 9 was broken/incomplete, so we kept the MPlayer decoder around. Now it's not needed anymore.
* demux_libass: change how external ASS subtitles are loadedwm42014-03-153-15/+5
| | | | | | | | | | Instead of parsing the ASS file in demux_libass.c and trying to pass the ASS_Track to the subtitle renderer, just read all file data in demux_libass.c, and let the subtitle renderer pass the file contents to ass_process_codec_private(). (This happens to parse full files too.) Makes the code simpler, though it also relies harder on the (messy) probe logic in demux_libass.c.
* sub: use new FFmpeg API to check MicroDVD FPSwm42014-03-041-3/+5
| | | | | | Before this, it wasn't possible to distinguish MicroDVD subtitles without FPS header, and subtitles with FPS header equal to FFmpeg's fallback FPS.
* sd_ass: add a very simple and evil way to override ASS subtitle styleswm42014-03-011-0/+27
| | | | | | --ass-style-override=force now attempts to override the 'Default' style. May or may not work. In some situations it will work, but also mess up seemingly unrelated things like signs typeset with ASS.
* sd_lavc: handle subtitles with no subtitle resolution setxylosper2014-02-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Set subtitle resolution to video resolution when avctx->width and avctx->height are zero. This can happen with broken vobsubs that have no size set in their .idx file (or Matroska extradata). At least with the test file provided in issue #551, using the video resolution as fallback instead of what guess_resolution() does is better. Note that these files clearly are broken. It seems this particular file was created by trying to use ffmpeg to transcode DVB subtitles to vobsub, and ffmpeg "forgot" to set the subtitle resolution in the destination file. On the other hand, ffmpeg DVB and PGS decoders set the resolution on the first subtitle packet (or somewhere close), so it's not really clear what to do here. Closes #551. Signed-off-by: wm4 <wm4@nowhere> Patch by xylosper, rewritten commit message by wm4.
* sub: handle vobsub-in-mp4wm42014-02-133-0/+41
| | | | | | | | | | | The mplayer decoder (spudec.c) actually handled this. There was explicit code for binary palettes (16 32 bit values), and the subtitle resolution was handled by video resolution coincidentally matching the subtitle resolution. Whoever puts vobsub into mp4 should be punished. Fixes the sample gundam_sample.mp4, closes github issue #547.
* threads: add wrapper for initializing recursive mutexeswm42014-01-311-5/+2
| | | | Damn this overly verbose pthread API.
* sd_lavc: skip 0 sized sub-bitmapswm42014-01-291-2/+4
| | | | | | | Not everything in the OSD path handles 0x0 sized sub-bitmaps well. At least the code implementing --sub-gray had severe problems with it. Fix this by skipping such bitmaps.
* sub: fix crash with certain uses of --vf=subwm42014-01-263-32/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If, for some reason, the subtitle renderer attempts to render a subtitle before SD_CTRL_SET_VIDEO_PARAMS was called, it passed a value calculated from invalid values. This can happen with --vf=sub and --start. The crash happens if 1. there was a subtitle packet that falls into the timestamp of the rendered video frame, 2. the playloop hasn't informed the subtitle decoder about the video resolution yet (normally unneeded, because that is used for weird corner cases only, so this code is a bit fuzzy), and 3. something actually requests a frame to be drawn from the subtitle renderer, like with vf_sub. The actual crash was due to passing NaN as pixel aspect to libass, which then created glyphs with ridiculous sizes, involving a few integer overflows and unchecked mallocs. The sd_lavc.c and sd_spu.c cases probably don't crash, but I'm not sure, and it's better fix them anyway. Not bothering with sd_spu.c, this crap is for compatibility and will be removed soon. Note that this would have been no problem, had the code checked whether SD_CTRL_SET_VIDEO_PARAMS was actually called. This commit adds such a check (although it basically checks after using the parameters). Regression since 49caa0a7 and 633fde4a.
* video/out: don't access aspdat in VOswm42014-01-222-0/+18
| | | | | | | | | | | vo->aspdat is basically an outdated version of vo->params, plus some weirdness. Get rid of it, which will allow further cleanups and which will make multithreading easier (less state to care about). Also, simplify some VO code by using mp_image_set_attributes() instead of caring about display size, colorspace, etc. manually. Add the function osd_res_from_image_params(), which is often needed in the case OSD renders into an image.
* osd: fix dvdnav highlightswm42014-01-181-1/+2
| | | | Broken by previous commit.
* sub: uglify OSD code path with lockingwm42014-01-185-126/+285
| | | | | | | | | | | | | | | Do two things: 1. add locking to struct osd_state 2. make struct osd_state opaque While 1. is somewhat simple, 2. is quite horrible. Lots of code accesses lots of osd_state (and osd_object) members. To make sure everything is accessed synchronously, I prefer making osd_state opaque, even if it means adding pretty dumb accessors. All of this is meant to allow running VO in their own threads. Eventually, VOs will request OSD on their own, which means osd_state will be accessed from foreign threads.
* sub: uglify sub decoder with lockingwm42014-01-173-6/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | The plan is to make the whole OSD thread-safe, and we start with this. We just put locks on all entry points (fortunately, dec_sub.c and all sd_*.c decoders are very closed off, and only the entry points in dec_sub.h let you access it). I think this is pretty ugly, but at least it's very simple. There's a special case with sub_get_bitmaps(): this function returns pointers to decoder data (specifically, libass images). There's no way to synchronize this internally, so expose sub_lock/sub_unlock functions. To make things simpler, and especially because the lock is sort-of exposed to the outside world, make the locks recursive. Although the only case where this is actually needed (although trivial) is sub_set_extradata(). One corner case are ASS subtitles: for some reason, we keep a single ASS_Renderer instance for subtitles around (probably to avoid rescanning fonts with ordered chapters), and this ASS_Renderer instance is not synchronized. Also, demux_libass.c loads ASS_Track objects, which are directly passed to sd_ass.c. These things are not synchronized (and would be hard to synchronize), and basically we're out of luck. But I think for now, accesses happen reasonably serialized, so there is no actual problem yet, even if we start to access OSD from other threads.
* sd_lavc: use mp_lavc_set_extradata()wm42014-01-111-2/+2
| | | | | This includes the magical input padding required by libavcodec, which we possibly didn't do before this commit.
* sub: fix frame based subtitle timestamp handlingwm42014-01-091-1/+1
| | | | | | Subtitle formats with frame based timing require using the video FPS to compute proper subtitle timestamps. But it looks like the calculation to do that was inversed.
* Fix subtitle delay inversionMartin Herkt2014-01-061-1/+1
|
* vo: dropping subtitle files on the VO window adds them as subtitle fileswm42014-01-042-0/+9
| | | | | | | Note that we don't try to be clever about detecting the files as subtitles: we just check the file extension. We could go all the way and check the files by opening them with a demuxer, but that would probably do more bad than good.
* osd_libass: use bstr_xappend()wm42013-12-301-22/+25
| | | | Partially, just enough to drop mp_append_utf8_buffer().
* player: add --secondary-sid for displaying a second subtitle streamwm42013-12-243-23/+29
| | | | | | | This is relatively hacky, but it's Christmas, so it's ok. This does two things: 1. allow selecting two subtitle tracks, and 2. include a hack that renders the second subtitle always as toptitle. See manpage additions how to use this.
* msg: rename mp_msg_log -> mp_msgwm42013-12-211-2/+2
| | | | Same for companion functions.
* msg: convert defines to enumwm42013-12-211-2/+2
| | | | Also get rid of MSGL_HINT and the many MSGL_DBG* levels.
* path lookup functions: mp_msg conversionswm42013-12-212-11/+9
| | | | | | | | | | | | | | | | | There's a single mp_msg() in path.c, but all path lookup functions seem to depend on it, so we get a rat-tail of stuff we have to change. This is probably a good thing though, because we can have the path lookup functions also access options, so we could allow overriding the default config path, or ignore the MPV_HOME environment variable, and such things. Also take the chance to consistently add talloc_ctx parameters to the path lookup functions. Also, this change causes a big mess on configfiles.c. It's the same issue: everything suddenly needs a (different) context argument. Make it less wild by providing a mp_load_auto_profiles() function, which isolates most of it to configfiles.c.
* charset_conv: mp_msg conversionswm42013-12-211-2/+2
|
* sub/osd: mp_msg conversionswm42013-12-2115-75/+95
|
* find_subfiles: mp_msg conversionswm42013-12-212-11/+13
|
* Reduce recursive config.h inclusions in headerswm42013-12-181-0/+1
| | | | | | In my opinion, config.h inclusions should be kept to a minimum. MPlayer code really liked including config.h everywhere, though, even in often used header files. Try to reduce this.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-1713-24/+24
|
* Move options/config related files from mpvcore/ to options/wm42013-12-179-11/+11
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-161-2/+2
| | | | | | | | | The tmsg stuff was for the internal gettext() based translation system, which nobody ever attempted to use and thus was removed. mp_gtext() and set_osd_tmsg() were also for this. mp_dbg was once enabled in debug mode only, but since we have log level for enabling debug messages, it seems utterly useless.
* osd_libass: update styles when OSD changes PlayReswm42013-12-152-8/+15
| | | | | | | The OSD style settings depend on the PlayRes, simply because all style values are implicitly scaled by the PlayResY in libass. Also, the OSC changes the PlayResY in certain situations, so something could go wrong. But not sure if this actually matters in practice.
* osd: use separate ASS_Renderer for each OSD objectwm42013-12-153-46/+53
| | | | | | | | This simplifies things, although it is slightly less efficient (probably uses a bit more memory). This also happens to fix that the OSC dropped the libass cache on every frame.
* player: don't store subtitle renderer in osd_statewm42013-12-152-5/+2
| | | | | | | | This doesn't have much value. It can't be accessed by anything else than the actual subtitle renderer (sd_ass.c). sd_ass.c could create the renderer itself, except that we apparently want to save memory (and some font loading time) when using ordered chapters or multiple subtitle tracks.
* dvdnav: support mouse interactionwm42013-12-132-0/+20
|
* Add prelimimary (basic, possibly broken) dvdnav supportwm42013-12-124-4/+26