summaryrefslogtreecommitdiffstats
path: root/sub/sub.c
Commit message (Collapse)AuthorAgeFilesLines
* command: add commands for displaying overlayswm42013-10-051-0/+5
| | | | | | Requested by github issue #255. Does not work where mmap is not available (i.e. Windows).
* command: add properties for retrieving OSD dimensionswm42013-10-051-0/+3
|
* Add initial Lua scripting supportwm42013-09-261-0/+11
| | | | | | | | | | | | | | | | | | | | | | 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.
* Revert "sub: support straight alpha additionally to premultiplied alpha"wm42013-08-121-11/+1
| | | | | | | | | | | | | | | | | | | | | | 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.
* sub: support straight alpha additionally to premultiplied alphawm42013-08-121-1/+11
| | | | | | | | | 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-061-3/+3
| | | | Followup commit. Fixes all the files references.
* sub: Do not use deprecated “Sans” fontconfig aliasMartin Herkt2013-07-081-1/+1
|
* sub: update subtitle time offset even if pausedwm42013-06-291-1/+1
| | | | | | 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.
* Move/rename subreader.cwm42013-06-251-1/+0
|
* sub: refactorwm42013-06-011-2/+2
| | | | | | | | | | | | | | | | | | | | 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.
* sub: remove some global variableswm42013-05-301-15/+4
|
* sub: add sd_spu.c to wrap spudec, cleanup mplayer.cwm42013-05-301-15/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: redo how -no-ass is handledwm42013-05-301-13/+26
| | | | | | | | | | | | | | | | | | | | | 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.
* command: simplify sub OSD updatewm42013-05-141-5/+3
| | | | | We can just update all OSD elements in these cases. This way we can also reuse it for commands which need to update the OSD for other reasons.
* sub: add --osd-blur and --sub-text-blur optionswm42013-04-131-0/+1
| | | | | | | | | These require bleeding edge libass (latest git version), and will be ignored otherwise. I'm not sure about the blur factor and scaling. The ASS/VSFilter semantics for blur scaling are a bad mess. Might require further investigation.
* vo: remove and cleanup globalsAlexander Preisinger2013-03-041-1/+1
| | | | | | | | Removes almost every global variabel in vo.h and puts them in a special struct in MPOpts for video output related options. Also we completly remove the options/globals pts and refresh rate because they were unused.
* fix clang compiler warningsStefano Pigozzi2013-03-031-1/+1
|
* m_option: don't define OPT_BASE_STRUCT by defaultwm42013-03-011-1/+0
| | | | | | | | | | | OPT_BASE_STRUCT defines which struct the OPT_ macros (like OPT_INT etc.) reference implicitly, since these macros take struct member names but no struct type. Normally, only cfg-mplayer.h should need this, and other places shouldn't be bothered with having to #undef it. (Some files, like demux_lavf.c, still store their options in MPOpts. In the long term, this should be removed, and handled like e.g. with VO suboptions instead.)
* vo_caca: remove OSD supportwm42013-02-241-18/+0
| | | | | | Recent changes to the OSD code made vo_caca crash when showing OSD. Since this is a joke VO (== I'd rather not waste my time with it), remove the OSD support. It wasn't that great anyway.
* sub: add experimental --force-rgba-osd-rendering switchwm42013-01-131-1/+6
|
* img_convert: add sub_bitmap bounding box functionswm42013-01-131-20/+0
| | | | mp_sub_bitmaps_bb is just sub_bitmaps_bb renamed/moved.
* vo_xv, vo_x11: simplify OSD redrawingwm42013-01-131-13/+1
| | | | | | | | | | | | | In order to support OSD redrawing for vo_xv and vo_x11, draw_bmp.c included an awkward "backup" mechanism to copy and restore image regions that have been changed by OSD/subtitles. Replace this by a much simpler mechanism: keep a reference to the original image, and use that to restore the Xv/X framebuffers. In the worst case, this may increase cache pressure and memory usage, even if no OSD or subtitles are rendered. In practice, it seems to be always faster.
* sub: do not copy the target image if there is no OSD/subswm42013-01-131-0/+21
| | | | | | | | | | | | | | | | | | | | | It's not easy to tell whether the OSD/subs are empty, or if something is drawn. In general you have to use osd_draw() with a custom callback. If nothing is visible, the callback is never invoked. (The actual reason why this is so "hard" is the implementation of osd_libass.c, which doesn't allow separating rendering and drawing of OSD elements, because all OSD elements share the same ASS_Renderer.) To simplify avoiding copies, make osd_draw_on_image() instead of the caller use mp_image_make_writeable(). Introduce osd_draw_on_image_p(), which works like osd_draw_on_image(), but gets the new image allocation from an image pool. This is supposed to be an optimization, because it reduces the frequency of large allocations/deallocations for image data. The result of this is that the frequency of copies needed in conjunction with vf_sub, screenshots, and vo_lavc (encoding) should be reduced. vf_sub now always does true pass-through if no subs are shown. Drop the pts check from vf_sub. This didn't make much sense.
* sub: add ASS to RGBA conversionwm42012-12-281-0/+4
| | | | | This makes implementing new VOs easier, because they don't have to support the ASS format.
* subs: remove --utf8, simplify codeUoti Urpala2012-12-031-1/+0
| | | | | | | | | | | | | | | | | | | Remove the options --utf8 and --unicode which had no effect any more (what they once did should be doable with --subcp). The only use of corresponding variables left in code was subreader.c code using sub_utf8 as a flag indicating whether iconv conversion was active. Change the code to test the existence of iconv context instead. Conflicts: DOCS/man/en/options.rst core/cfg-mplayer.h sub/sub.c sub/sub.h sub/subreader.c Merged from mplayer2 commit ea7311. Note: --unicode was already removed
* sub: add --sub-gray option to display image subs in grayscalewm42012-11-251-2/+5
| | | | | | | | | | MPlayer/mplayer2 still show DVD subtitles in gray. Depending on who you ask, this can be considered a bug or a feature. Include rendering in gray as explicit feature, so the user can decide what is better. This affects all indexed sub bitmaps entering the OSD rendering path. Currently, this means all image subs are affected by this option, but nothing else.
* sub: reimplement -spugauss as --sub-gausswm42012-11-251-0/+5
| | | | | | | | | | | | | | | | Apparently the -spugauss option was popular. The code originally implementing this is gone (scaler stuff in spudec.c). Reimplement it using libswscale to scale and blur image subtitles if the --sub-gauss option is set. The code does some rather lazy padding to allow the blur to spread pixels past the original image bounding box. (This problem exists with normal bilinear scaling too, but is barely noticable.) Technically, this doesn't just blur subtitles, but anything RGBA (or indexed) that enters the OSD rendering path. But only image subtitles produce these OSD formats currently, so no explicit check is done to prevent blurring in other cases.
* vo_xv: don't require frame stepping to remove OSD or subswm42012-11-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | In order to improve performance, vo_xv didn't create a backup of the video frame before drawing OSD and subtitles during normal playback. It required the frontend to do frame stepping if it wanted to redraw the OSD, but no backup of the video frame was available. (Consider the following use case: enable the OSD permanently with --osd-level=3, then pause during playback and do something that shows an OSD message. The player will advance the video by one frame at the time the new OSD message is first drawn.) This also meant that taking a screenshot during playback with vo_xv would include OSD and subtitles in the resulting image. Fix this by always creating a backup before drawing OSD or subtitles. In order to avoid having to create a full copy of the whole image frame, introduce a complex scheme that tries to backup only the changed regions. It's unclear whether the additional complexity in draw_bmp.c for backing up only the changed areas of the frame is worth it. Possibly a simpler implementation would suffice, such as tracking only Y ranges of changed image data, or even just copying the full frame. vo_xv's get_screenshot() now always creates a copy in order not to modify the currently displayed frame.
* osd: make the OSD and sub font more customizablewm42012-11-201-4/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make more aspects of the OSD font customizable. This also affects the font used for unstyled subtitles (such as SRT), or when using the --no-ass option. This adds back some customizability that was lost with commit 74e7a1 (osd: use libass for OSD rendering). Removed options: --ass-border-color --ass-color --font --subfont --subfont-text-scale Added options: --osd-color --osd-border --osd-back-color --osd-shadow-color --osd-font --osd-font-size --osd-border-size --osd-margin-x --osd-margin-y --osd-shadow-offset --osd-spacing --sub-scale The font size is now specified in pixels as it would be rendered on a window with a height of 720 pixels. OSD and subtitles are always scaled with the window height, so specifying or expecting an absolute font size doesn't make sense. Such scaled pixel units are used to specify font border etc. as well. (Note: the font size is directly passed to libass. How the fonts are actually rasterized is outside of our control, but in theory ASS font sizes map to "script" pixels and then are scaled to screen size.) The default settings should be about the same, with slight difference due to rounding to the new scales. The OSD and subtitle fonts are not separately configurable. It has limited use and would double the number of newly added options, which would be more confusing than helpful. It could be easily added later, should the need arise. Other small details that change: - ASS_Style.Encoding is not set to -1 for subs anymore (assuming subs use VSFilter direction in -no-ass mode too) - use a different WrapStyle for OSD - ASS forced styles are not applied to OSD
* Rename directories, move files (step 2 of 2)wm42012-11-121-5/+4
| | | | | | | | | | | | Finish renaming directories and moving files. Adjust all include statements to make the previous commit compile. The two commits are separate, because git is bad at tracking renames and content changes at the same time. Also take this as an opportunity to remove the separation between "common" and "mplayer" sources in the Makefile. ("common" used to be shared between mplayer and mencoder.)
* screenshot, draw_bmp: use colorspace passed with mp_imagewm42012-11-011-6/+3
| | | | | Remove the explicit struct mp_csp_details parameters from all related functions, and use mp_image.colorspace/levels instead.
* draw_bmp: cosmetics, refactorwm42012-10-281-12/+12
| | | | | | | | | | | Mostly pedantic bikeshedding issues. Move some code around, so that the sub_bitmap_to_mp_images() function can be split into two parts. This is better than having a big function with many input and outputs, of which only half are used in each code path. Also, try to make code simpler by using a mp_rect type.
* options: remove --ffactor switchwm42012-10-241-1/+0
| | | | | | | This controlled the generation of the palette for DVD subs if no palette was found. The option name and description is confusing, and it was probably barely useful. Remove the option, and hardcode the behavior to the option's default value.
* options: remove --subfont-autoscale (changes default font scale)wm42012-10-241-6/+1
| | | | | | | | | The code for this option attempted to emulate the old as-documented behavior. It wasn't very good at it, and now that the old OSD code has been removed, it's entirely pointless. This removes the factor 1.7 with which --subfont-text-scale was multiplied.
* options: remove subtitle related options that did nothingwm42012-10-241-9/+1
| | | | | | | Most of these cased working when the OSD was switched to libass, or didn't do anything even before that. Also don't recursively include subreader.h in sub.h.
* sub: simplify OSD redrawing logicwm42012-10-241-15/+1
| | | | | | | | | | | | | Normally, we can redraw the OSD any time. But some drivers don't support OSD redrawing (vo_null etc.), or only "sometimes" (vo_xv). For that, some additional logic is needed. Simplify that logic. This might also fix subtle bugs with the OSD not updating or endless frame stepping in unforseen corner cases. Do this by adding a new flag, which tells whether the OSD should be redrawn. Remove some minor code duplication.
* VO, sub: refactorwm42012-10-241-68/+28
| | | | | | | | | | | | | | | | | | Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD, VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT. Remove draw_osd_with_eosd(), which rendered the OSD by calling VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes a callback as argument. (This basically works like the old OSD API, except multiple OSD bitmap formats are supported and caching is possible.) Remove all mentions of "eosd". It's simply "osd" now. Make OSD size per-OSD-object, as they can be different when using vf_sub. Include display_par/video_par in resolution change detection. Fix the issue with margin borders in vo_corevideo.
* sub: add cache to mp_draw_sub_bitmaps()wm42012-10-241-7/+8
| | | | This caches scaled RGBA sub-bitmaps.
* sub, vf_ass: allow rendering RGBA subs, replace old vf_ass renderingwm42012-10-241-63/+59
| | | | | | | | | | Do this by replacing all the old vf_ass drawing code by draw_bmp.c. Change sub.c to always use osd_draw() for the other OSD drawing routines, and simplify the code a bit. spudec.c subtitles (i.e. DVD subs) are now considered subtitles, and are rendered by vf_ass, if that filter is inserted.
* sub: fix text subtitle aspect ratio with vo_xv and vo_lavc, refactorwm42012-10-241-4/+3
| | | | | | | | | | | | | | | | | | | This fixes that vo_xv didn't display text subtitles correctly when using anamorphic video. It didn't pass the aspect information to the subtitle renderer. Also, try to render OSD correctly with respect to aspect ratio settings: on vo_xv, the OSD is rendered into the video, and needs to be "stretched" too when playing anamorphic video. When the -monitorpixelaspect option is used, even with VOs such as vo_opengl the OSD has to be rendered with that aspect ratio. As preparation for future commits, replace the weird vsfilter_scale value with a somewhat more sensible video_par member. Also, struct mp_eosd_res is a better place for the aspect ratio parameters, as OSD needs this too. Use osd_draw_on_image() directly in vo_lavc, which fixes aspect ratio issues as well.
* Remove things related to old OSDwm42012-10-241-52/+0
| | | | | | | | | | | | | | | To ease changing all the VOs to the new OSD rendering, fallbacks, conversions, support code etc. was left all over the code. Now that all VOs have been changed, all that code is inactive. Remove it. Strip down spudec.c. We don't need the old grayscale and scaling stuff anymore. (Not removing spudec itself yet - I'm not confident that the libavcodec DVD sub decoder is sufficient, and it would also require some hacks to get DVD palette and resolution information from libdvdread to libavcodec.) The option --spuaa, --spualign, --spugauss were used with the old sub scaling code, and don't do anything anymore.
* sub: add function to draw OSD into an imagewm42012-10-241-0/+25
| | | | | | | | The osd_draw_on_image() function renders the full OSD into the provided image. It uses the mp_draw_sub_bitmaps() function added in the previous commit to do the actual work.
* sub: fix and simplify some change detection detailswm42012-10-161-7/+6
| | | | | | | | | | | | | | Fix spudec change detection. The internal changed-flag was not reset when retrieving indexed bitmaps, and subtitles were rescaled every frame, even if they were not changing. Simplify subtitle decoders by not requiring them to check whether the passed-in screen size has changed. sd_lavc did this, and spudec would have needed to do the same. Instead, leave this to the osd_object force_redraw flag. Subtitle decoders (such as libass) can still signal that only the positions of subtitles have changed, but making _all_ subtitle decoders do this just to deal with screen size changes is worthless.
* sub: never decode subs to old OSD formatwm42012-10-161-17/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Instead, sd_lavc.c and spudec.c (the two image sub decoders) always output indexed/paletted images. For this purpose, add SUBBITMAP_INDEXED, and convert the subs to RGBA in img_convert.c instead. If a VO is used that supports the old OSD format only, the indexed bitmaps are converted to the old OSD format by abusing spudec.c in a similar way sd_lavc.c used to do. The main reason why spudec.c is used is because the images must not only be converted to the old format, but also properly scaled, cropped, and aligned (the asm code in libvo/osd.c requires this alignment). Remove support for the old format (packed variant) from the OpenGL VOs. (The packed formats were how the actual OSD format was handled in some GPU-driven VOs for a while.) Remove all conversions from old to new formats. Now all subtitle decoders and OSD renderers produce the new formats only. Add an evil hack to convert the new format (scaled+indexed bitmaps) to the old format. It creates a new spudec instance to convert images to grayscale and to scale them. This is temporary for VOs which don't support new OSD formats yet (vo_xv, vo_x11, vo_lavc).
* sub: cosmetics: move things aroundwm42012-10-161-6/+8
| | | | | | | | | | | | | | | | | | Move sub-bitmap definitions from dec_sub.h to sub.h. While it's a bit odd that OSD data structures are in a file named sub.h, it's definitely way too strange to have them in a file about subtitle decoding. (Maybe sub.h/.c and the sub/ directory should be split out and renamed "osd" at a later point.) Remove including ass_mp.h (and the libass headers) where possible. Remove typedefs for mp_eosd_res and sub_bitmaps structs. Store a mp_eosd_res struct in osd_state instead of just w/h. Note that sbtitles might be rendered using different sizes/margins when filters are involved (the subtitle renderer is not supposed to use the OSD res directly, and the "dim" member removed in the previous commit is something different).
* sub: cleanup: don't pass parameters via global variableswm42012-10-161-12/+7
| | | | | | | | |