Commit Graph

205 Commits

Author SHA1 Message Date
wm4 af8ded53db sd_ass: fix ASS subtitles coming from demux_lavf
libavformat demuxes ASS subtitles as complete ASS event, rather than
Matroska-mangled events without time codes.
2012-11-16 22:54:22 +01:00
wm4 dd7dc2ee3d subreader: replace sub_free() by talloc destructor
Makes it less annoying to free the sub_data.
2012-11-16 21:21:15 +01:00
Stefano Pigozzi bec630c347 clang: fix all warnings except deprecations 2012-11-13 22:19:18 +01:00
wm4 4873b32c59 Rename directories, move files (step 2 of 2)
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.)
2012-11-12 20:08:18 +01:00
wm4 84829a4ea1 Merge branch 'osd_changes' into master
Conflicts:
	DOCS/man/en/options.rst
2012-11-01 02:12:47 +01:00
wm4 f4069259cf draw_bmp: remove swscale bug workaround
ffmpeg ticket #1852 is fixed with 425c30dda. This didn't actually happen
in practice.
2012-11-01 02:07:46 +01:00
wm4 9ba52ea6ef screenshot, draw_bmp: use colorspace passed with mp_image
Remove the explicit struct mp_csp_details parameters from all related
functions, and use mp_image.colorspace/levels instead.
2012-11-01 02:07:45 +01:00
reimar 6c141b60b5 subreader: do not write outside array bounds
Extra checks to ensure we really do not write outside
array bounds.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35313 b3059339-0415-0410-9bf9-f77b7e298cf2
2012-10-31 22:45:38 +01:00
reimar 78899a096f spudec: set pointers to NULL after free
Set pointers to NULL after free.
For the pal_image one it would have been possible
to leak the old pointer of the malloc for "image" failed.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35303 b3059339-0415-0410-9bf9-f77b7e298cf2
2012-10-31 22:43:26 +01:00
wm4 d072e857d7 csputils: better support for integer color values 2012-10-28 15:31:32 +01:00
wm4 65b313a8b0 draw_bmp, csputils: use function instead of macro 2012-10-28 15:31:32 +01:00
wm4 18d4eebedb draw_bmp: cosmetics, refactor
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.
2012-10-28 15:31:31 +01:00
wm4 f50d0b16e0 draw_bmp: remove CONDITIONAL2 code
This was sometimes slower, sometimes slightly faster. Remove it.
2012-10-24 23:12:26 +02:00
wm4 0e81d62c53 Merge branch 'master' into osd_changes
Conflicts:
	libvo/vo_xv.c
2012-10-24 22:38:45 +02:00
wm4 3d98e8c674 options: remove --ffactor switch
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.
2012-10-24 21:56:35 +02:00
wm4 a8824f12dd options: remove --subfont-autoscale (changes default font scale)
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.
2012-10-24 21:56:35 +02:00
wm4 2afd7ebb4e options: remove subtitle related options that did nothing
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.
2012-10-24 21:56:35 +02:00
Rudolf Polzer e1e056fe5d draw_bmp: fix IMGFMT_BGR32 use 2012-10-24 21:56:35 +02:00
wm4 77016efd27 sub: add clarifying comments 2012-10-24 21:56:35 +02:00
wm4 4b4e4b5690 draw_bmp: fix for yuy2 format
mp_get_chroma_shift() modifies its argument even if it fails, so we have
to restore that.

mp_image didn't set chroma shifts for yuy2.
2012-10-24 21:56:34 +02:00
wm4 0c49ddc818 sub: simplify OSD redrawing logic
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.
2012-10-24 21:56:34 +02:00
wm4 4d11f32162 VO, sub: refactor
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.
2012-10-24 21:56:34 +02:00
wm4 a4f9077f6c draw_bmp: don't try to call swscale if image format not supported
If that happens, we silently fail.
2012-10-24 21:56:34 +02:00
wm4 bf68634d15 sub: add cache to mp_draw_sub_bitmaps()
This caches scaled RGBA sub-bitmaps.
2012-10-24 21:56:34 +02:00
wm4 97c6425140 sub, vf_ass: allow rendering RGBA subs, replace old vf_ass rendering
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.
2012-10-24 21:56:33 +02:00
wm4 98f74335d5 sub: fix text subtitle aspect ratio with vo_xv and vo_lavc, refactor
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.
2012-10-24 21:56:33 +02:00
wm4 f6197249a7 spudec: use csputils for color conversion
Just to get rid of that conversion copy&pasted from the internet.

R and G are swapped for unknown reasons. Testing various subtitles
seem to yield the same results as VLC. The sub-bitmap renderers output
the correct colors. The colorspace conversion is used without problems
for vo_gl, vo_gl3 and vo_vdpau. The problem is most likely that
apparently, the DVD palette read from the subtitle track extradata is
converted to YUV using vobsub_palette_to_yuv(), and swapped in the
process. Or in other words, the YUV colors spu->global_palette are
encoded with R and G swapped.

Add some utility definition to csputils.c/h to make converting single
color values easier.
2012-10-24 21:56:33 +02:00
wm4 fd5c4a1984 Remove things related to old OSD
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.
2012-10-24 21:56:33 +02:00
wm4 7b203b5e05 img_convert: fix alignment for RGBA images
draw_bmp.c uses libswscale, which has strict alignment requirements on
input images. Since imp_convert.c is currently the only producer of RGBA
sub-bitmaps, the overall code becomes easier if the alignment is done on
image allocation, rather than forcing draw_bmp.c to create an aligned
copy.

talloc doesn't align to 16 bytes, as required by libswscale. Apparently,
system malloc (glibc/Linux/32 bit) aligns to 8 bytes only, so talloc's
own code to align to 16 bytes is ineffective. Work around by using
mp_image to allocate the image.
2012-10-24 21:56:33 +02:00
wm4 c139cd2b93 sub: add function to draw OSD into an image
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.
2012-10-24 21:56:33 +02:00
wm4 0e72b0d5d3 draw_bmp: compensate for libswscale writing past image bounds
libswscale tends to overwrite the area between (w,y)-(0,y+1). It tries
to process multiple pixels at once, and if the memory past the last x
pixel is inside a SIMD operation, but still below the image stride, it
overwrites that data with black.

This happens with vo_x11 and 32 bit RGBA formats. The bug is visible as
black bar right of the subtitle bounding box. Fix by giving libswscale
more alignment. Then the "outside" pixels are inside, and are processed
normally instead of overwritten with black.

NOTE: we do not increase the alignment constant, because this is a
separate issue from pointer alignment. libavutil's av_malloc() wouldn't
actually satisfy the increased alignment either.
2012-10-24 21:56:33 +02:00
Rudolf Polzer aa1047a35a sub: add helper to draw sub-bitmaps into an image
Merged by wm4 from commits 93978f17b76d..13211ef5fc20. Changed copyright
header in draw_bmp.c to "mpv", and removed the one in draw_bmp.h.
2012-10-24 21:56:29 +02:00
wm4 a781fe14f7 osd_libass: increase robustness when handling internal OSD escapes
The \xFF escape is used internally to insert special OSD symbols (which
need a font change to the internal OSD font). There was potential for
breakage when \xFF was followed by \0, because then "in" would be
advanced past the string's end.

Normally this can't happen, as it would require invalid UTF-8 input
data. But we don't check input for UTF-8 validness, so there's a
potential issue here. Garbled output is ok on invalid UTF-8 input,
but crashing is not.

Make it more robust by checking for this.
2012-10-22 01:55:58 +02:00
wm4 7b65202e47 osd_libass: fix stupid dangling pointer crash
append_utf8_buffer() reallocates the buffer passed to it, and returns
the new pointer.

This bug was originally introduced in mplayer2 when that project merged
mpv's osd_libass.c. That merge changed some minor things, including ASS
escape handling. When mpv used this better method of escape handling too
(commit 0ff7dd992f), the bug was duplicated.
2012-10-22 01:55:55 +02:00
wm4 4e89851aa1 Merge branch 'master' into osd_changes
Conflicts:
	Makefile
	command.c
	libvo/gl_common.c
	libvo/vo_corevideo.m
	libvo/vo_opengl.c
	libvo/vo_opengl_old.c
	libvo/vo_opengl_shaders.glsl
	sub/ass_mp.c
	sub/osd_libass.c
	sub/sd_ass.c
2012-10-16 07:30:30 +02:00
wm4 f45eab6fae sub: fix and simplify some change detection details
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.
2012-10-16 07:26:45 +02:00
wm4 84c3480686 spudec.c: crop subs, set scaled flag
Crop subtitle images produced by spudec.c: instead of returning a frame-
sized bitmap (with possibly large transparent regions), return a cropped
down rectangle of the visible part only. The old spudec scaler code had
this as spudec_cut_image(), but it worked on the data converted to the
old OSD format only.

Move most code to setup the sub-bitmap from spudec_get_indexed() to
spudec_process_data(), so that cropping can be done every time a new
subtitle is decoded, instead of every frame.

Set the sub_bitmaps->scaled flag. Without it, vo_gl and vo_vdpau
produced ugly artifacts on the borders.
2012-10-16 07:26:32 +02:00
wm4 44c62a6852 sub: switch to premultiplied alpha
Fixes problems with ugly borders.

Note that at least in the DVD sub case, we could have just set all
transparent pixels to black to solve this.

vo_direct3d.c change untested, because mingw is a miserable pile of
crap.
2012-10-16 07:26:32 +02:00
wm4 3ad918bbc6 sub: never decode subs to old OSD format
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).
2012-10-16 07:26:32 +02:00
wm4 cc05910f16 sub: cosmetics: move things around
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).
2012-10-16 07:26:32 +02:00
wm4 05f4f00e24 sub: cleanup: don't pass parameters via global variables
Passing parameters from caller to subtitle renderer was done by
temporarily setting certain members in the osd_state struct (which for
all practical purposes are as good as global variables). This was the
only purpose of these members.

Rather than using such a messy way to pass parameter, put these into a
struct sub_render_params. The struct was already introduced in earlier
commits, and this commit just removes the parameter passing hack.
2012-10-16 07:26:32 +02:00
wm4 17f5019b46 sub: always go through sub.c for OSD rendering
Before this commit, vf_vo.c and vf_ass.c were manually calling the
subtitle decoder to retrieve images to render. In particular, this
circumvented the sub-bitmap conversion & caching layer in sub.c.

Change this so that subtitle decoding isn't special anymore, and draws
all subtitles with the normal OSD drawing API.

This is also a step towards removing the need for vf_ass auto-insertion.
In fact, if auto-insertion would be disabled now, VOs with "old" OSD
rendering could still render ASS subtitles in monochrome, because
there is still ASS -> old-OSD bitmap conversion in the sub.c mechanism.

The code is written with the assumption that the subtitle rendering
filter (vf_ass) can render all subtitle formats. Since vf_ass knows the
ASS format only, rendering image subs (i.e. RGBA subs) with it simply
fails. This means that with vo_xv (vf_ass auto-inserted), image subs
wouldn't be rendered. Use a dumb hack to disable rendering subs with a
filter, if we detect that the subs are not in ASS format. (Trying to
render the subs first would probably result in purging the conversion
cache on every frame.)
2012-10-16 07:26:31 +02:00
wm4 34b3a9c5e9 sub, VO: remove vo_osd_resized() function
VOs which could render the OSD in window size (as opposed to video size,
like vo_xv) and which could cache the OSD called this when the window
size changed. This was needed, because VOs used another OSD function to
check whether the OSD changed before passing the new window size to the
OSD code.

This was really just an artifact of OSD change detection, and now that
the affected VOs use the new OSD rendering API, it's done automatically.
2012-10-16 07:26:31 +02:00
wm4 8f8f6e6d9d sub: remove logic for disabling hinting on scaled EOSD
This was an extremely obscure setting, as it was used only with vo_gl
if its scaled-osd suboption was used. If you really want this, you can
set the desired ass-hinting value directly, and there will be literally
no loss in functionality.

Note that this didn't actually test whether the EOSD was scaled.
Basically, it only checked whether vo_gl had the scaled-osd suboption
set.
2012-10-16 07:26:31 +02:00
wm4 466fc6d4d1 sub: make it easier to set DVD sub decoding with sd_lavc
With this commit, the player will still use spudec.c (the "old" DVD sub
decoder), rather than ffmpeg. But it brings the changes needed to enable
this down to a single line change:

--- a/mplayer.c
+++ b/mplayer.c
@@ -1988,7 +1988,7 @@ static void reinit_subs(struct MPContext *mpctx)
 #endif
         vo_osd_changed(OSDTYPE_SUBTITLE);
     } else if (track->stream) {
-        if (mpctx->sh_sub->type == 'v')
+        if (mpctx->sh_sub->type == 'v' && false)
             init_vo_spudec(mpctx);
         else
             sub_init(mpctx->sh_sub, mpctx->osd);

Also, copy the DVD resolution heuristics from spudec.c (from the
spudec_new_scaled() function). I'm not sure if this is correct or even
needed, but the sd_lavc codd explicitly reverted back to spudec with
code carrying this comment:

    // Assume resolution heuristics only work for PGS and DVB

so it seems likely that the required heuristics were missing, and that
the spudec heuristics may make the DVD compatibility situation at least
as good as with spudec.

Note that it's unlikely that we enable sd_lavc for DVD subs by default,
as there are other problems in combination with direct DVD playback.
2012-10-16 07:26:31 +02:00
wm4 5357b38d40 osd_libass: set RTL base direction to neutral
We are using libass for OSD rendering. One problem with that is that
libass has to be bug-compatible to VSFilter. This includes the setting
for the default RTL base direction. Neutral would be most reasonable,
but VSFilter assumes LTR.

This commit forces the default to neutral.

Unconfirmed whether this actually works as intended.

See the following libass commits:

9dbd12d shaper: allow font encoding -1 for neutral base direction
a80c45c shaper: always use LTR base direction by default
2012-10-16 07:26:31 +02:00
wm4 252ddcc014 sub: cleanup: remove vo_osd_probar_type/value global variables 2012-10-16 07:26:31 +02:00
wm4 e62b3a1750 sub: cosmetics: turn some defines into enums 2012-10-16 07:26:31 +02:00
wm4 5fc5ae752b sub: allow converting DVD subs to RGBA
The mplayer DVD sub decoder is the only remaining OSD image producer
that still requires the old mplayer OSD format (SUBBITMAP_OLD_PLANAR).

To make supporting this format optional in VOs, add a step that allows
converting these images to RGBA in case the VO doesn't have direct
support for it.

Note: the mplayer DVD sub decoder uses the old mplayer OSD format
(SUBBITMAP_OLD_PLANAR), which is assumed to use premultiplied alpha.
However, it seems DVDs allow only binary transparency, so the rendered
result will be the same.
2012-10-16 07:26:30 +02:00
wm4 3365514951 sub: allow rendering OSD in ASS image format directly, simplify
Before this commit, the OSD was drawn using libass, but the resulting
bitmaps were converted to the internal mplayer OSD format. We want to
get rid of the old OSD format, because it's monochrome, and can't even
be rendered directly using modern video output methods (like with
OpenGL/Direct3D/VDPAU).

Change it so that VOs can get the ASS images directly, without
additional conversions. (This also has the consequence that the OSD can
render colors now.) Currently, this is vo_gl3 only. The other VOs still
use the old method. Also, the old OSD format is still used for all VOs
with DVD subtitles (spudec).

Rewrite sub.c. Remove all the awkward flags and bounding boxes and
change detection things. It turns out that much of that isn't needed.

Move code related to converting subtitle images to img_convert.c. (It
has to be noted that all of these conversions were already done before
in some places, and that the new code actually makes less use of them.)
2012-10-16 07:26:30 +02:00
wm4 2a5fcd2801 sub: add preliminary emulation layer to draw OSD with EOSD
This basically pushes the old OSD bitmaps via VOCTRL_DRAW_EOSD to the
VO, instead of using the old callback-based interface.

Future commits will change the code such that sub.c pushes images
rendered by libass directly, rather than converting them to the old
OSD format first.
2012-10-16 07:26:30 +02:00
wm4 ffb7a2fe17 sub: create sub_bitmap array even when using libass
One sub_bitmaps struct could contain either a libass ASS_Image list, or
a mplayer native list of sub-bitmaps. This caused code duplication in
vo_vdpau.c and bitmap_packer.c.

Avoid this by creating such a sub_bitmap array even with libass. This
basically copies the list and recreates it in mplayer's native format.
It gets rid of the code duplication, and will make implementing extended
subtitle and OSD rendering in other VOs easier.

Also do some cosmetic changes and other preparations for the following
commits.
2012-10-16 07:26:28 +02:00
wm4 0ff7dd992f osd_libass: fix \n escapes
Apparently libass can't be made to not interpret "\n" as escape. That
means "\n" can't be printed literally. Use the same hack that was added
to mplayer2 when that project merged osd_libass.c: add an invisible
zero-width joiner character between "\" and "n". It seems U+FEFF is
deprecated, because it has been redefined as BOM mark. Use U+2060, which
seems to be the replacement.
2012-10-14 22:28:51 +02:00
wm4 c9df2c8bd8 sub: add --ass-style-override option to disable style overrides
There are a number of options which modify ASS subtitle rendering. Most
of these do things that can interfere with the styling done by subtitle
scripts, resulting in incorrect rendering. Add the --ass-style-override
option to make it easy to disable all overrides. This helps trouble-
shooting, and makes it more practical to use the override features. (You
can simply toggle the ass-style-override property at runtime, should
one of the style override options break subtitle rendering at a certain
point.)

This mainly affects whether most --ass-* options are applied, as well
as --sub-pos. Some things, like explicit style overrides loaded with
--ass-force-style, can't be changed at runtime using the
ass-style-override property.
2012-10-12 10:13:42 +02:00
wm4 2f6713bede sub: enable sub-pos with libass
The --sub-pos option and sub-pos property control the vertical position
of a subtitle.

Also change how sub-pos is handled in the old subtitle renderer (used
with -no-ass). The new behavior doesn't render subtitles out of the
screen if the subtitle is located near the top screen border and has
too many lines.
2012-10-12 10:13:42 +02:00
Uoti Urpala 1959ba006c subs, vo_vdpau: support RGBA color for PGS subtitles
Support passing bitmap subtitles to VOs in full RGBA color, and
implement this for libavcodec-decoded subtitle formats on decoding
side and vo_vdpau on display side. Currently this is enabled for PGS
(blu-ray) and DVB subtitles.

VDPAU seems to have sampling issues similar to known GL ones when
drawing a sub-rectangle from a larger texture with scaling, where
adjacent pixels outside the specified source rectangle affect the
result. As the bitmap subtitles may be scaled, add padding support to
the bitmap packer code.

In principle, this could be used for colored DVD subtitles too.
However, the libavcodec DVD decoder lacks parts of the resolution and
palette handling that are present in spudec.c.

Conflicts:
	libvo/vo_gl.c
	sub/dec_sub.h
	sub/sd_lavc.c
2012-09-18 21:07:30 +02:00
wm4 f97a85595b options: remove -subalign
It can't be re-implemented, because this isn't supported by libass. The
-subalign option and the associated sub-align slave property did
nothing. Remove them.
2012-09-18 21:07:29 +02:00
wm4 b554a59b58 subs: restore support for sub_step command with libass
This was destroyed by Uoti Urpala in commit "subs: always use sub...".
Features should be either kept working or completely removed, but not
just crippled, which only inflates the code and frustrates users.
2012-09-18 21:04:46 +02:00
Uoti Urpala fd52cb65f4 subs, vo: do sub bitmap change detection by comparing IDs
vo_vdpau and vo_gl cache the last subtitle bitmaps uploaded to video
card in case they stay the same over multiple frames. Detecting
whether the bitmaps have changed and should be re-uploaded was
somewhat fragile. Change the VO API to provide a bitmap ID which can
be compared with what the VO has to determine whether a new upload of
the bitmaps is needed.

Conflicts:
	libvo/vo_gl.c

Note: the changes for vo_gl.c were not merged. Instead, eosd_packer is
modified to use the new way of detecting EOSD changes. This takes care
of vo_gl, vo_gl3 and vo_direct3d, which all render EOSD. They don't
need to be updated in turn.
2012-09-18 21:04:46 +02:00
Uoti Urpala 89a5714893 subs: always use sub decoder framework for libass rendering
Remove subtitle selection code setting osd->ass_track directly and
vf_ass/vf_vo code rendering the track directly with libass. Instead,
do track selection and rendering with dec_sub.c functions.

Before, mpctx->set_of_ass_tracks[] contained bare libass tracks
generated from external subtitle files. For use with dec_sub.c, it now
contains struct sh_sub instances with decoder already initialized.

This commit breaks the sub_step command ('g' and 'y' keys) for
libass-rendered subtitles. It could be fixed, but it's so useless -
especially as with the existing implementation there's no practical
way to get subtitle delay back to normal after using it - that I
didn't bother.

Conflicts:
	command.c
	mp_core.h
	mplayer.c
2012-09-18 21:04:46 +02:00
Uoti Urpala 9bb03b7db4 subs: libass: use a single persistent renderer for subtitles
To draw libass subtitles, the code used ASS_Renderer objects created
in vf_vo (VO rendering) or vf_ass. They were destroyed and recreated
together with the video filter  chain. Change the code to use a single
persistent renderer instance stored in the main osd_state struct.
Because libass seems to misbehave if fonts are changed while a
renderer exists (even if ass_set_fonts() is called on the renderer
afterwards), the renderer is recreated after adding embedded fonts.

The known benefits are simpler code and avoiding delays when switching
between timeline parts from different files (libass fontconfig
initialization, needed when creating a new renderer, can take a long
time in some cases; switching between files rebuilds the video filter
chain, and this required recreating the renderers). On the other hand,
I'm not sure whether this could cause inefficient bitmap caching in
libass; explicitly resetting the renderer in some cases could be
beneficial. The new code does not keep the distinction of separate
renderers for vsfilter munged aspect vs normal; this means that
changing subtitle tracks can lose cache for the previous track.

The new code always sets some libass parameters on each rendering
call, which were previously only set if they had potentially changed.
This should be harmless as libass itself has checks to see if the
values differ from previous ones.

Conflicts:
	command.c
	libmpcodecs/vf_ass.c
	libmpcodecs/vf_vo.c
	mplayer.c
	sub/ass_mp.c
2012-09-18 21:04:46 +02:00
Uoti Urpala 44d8ec9272 sd_lavc: use subtitle framework for former av_sub.c code
Change libavcodec subtitle decoding code (used for some bitmap
subtitle types) to use the same decoding framework as sd_ass. The
functionality that was previously in av_sub.c and was directly called
from mplayer.c is now in sd_lavc.c.

Conflicts:
	mplayer.c
	sub/av_sub.h
	sub/sd_lavc.c

Merged from mplayer2. The remaining use of is_av_sub() is replaced by
a check whether a subtitle decoder is active, which should give the
same results.
2012-09-18 21:04:46 +02:00
wm4 0f155921b0 core: manage tracks in the frontend
Introduce a general track struct for every audio/video/subtitle track
known to the frontend. External files (subtitles) are now represented
as tracks too. This mainly serves to clean up the subtitle selection
code: now every subtitle is simply a track, instead of using a messy
numbering that goes by subtitle type (as it was stored in the
global_sub_pos field). The mplayer fontend will list external subtitle
files as additional tracks.

The timeline code now tries to match the exact demuxer IDs of all
tracks. This may cause problems when Matroska files with different
track numberings are used with EDL timelines. Change demux_lavf not
to set demuxer IDs, since most time they are not set.
2012-09-18 21:04:45 +02:00
wm4 b65424f5c2 osd_libass: fix displaying empty text, fix API usage
If empty text is rendered, the bounding box is empty. Instead of
continuing with a bogus bounding box that would result in garbage
being rendered on screen, make the OSD image invisible.

This happened when playing demuxer SRT subtitles (e.g. SRT embedded in
MKV) with -no-ass at the moment a subtitle line disappeared.

Unrelated to this issue, fix libass API usage. Delete the event with
libass_flush_events(), instead of trying to reuse the previous event.

Based on a patch by uau.
2012-08-21 18:58:15 +02:00
Uoti Urpala 009d9d8706 Adjust ffmpeg/libav #includes to work with recent upstream changes
The <libavutil/avutil.h> stopped including <libavutil/common.h>
recursively in recent ffmpeg/libav git revisions. As a result, some
files no longer got needed definitions, causing a build failure.
Modify #include lines in various files to fix build with the latest
versions of ffmpeg/libav headers.
2012-08-21 18:22:00 +02:00
wm4 988dad5fc7 osd: get rid of useless initialization function
The function merely printed redundant messages that were not visible by
default.
2012-08-20 15:36:05 +02:00
wm4 4adc0064db sub: remove unused definitions 2012-08-20 15:36:05 +02:00
wm4 41fbcee1f5 Remove dvdnav support (DVD menus)
When the internal mplayer MPEG demuxer was removed (commit 1fde09db),
the default demuxer when using dvdnav was set to libavformat. Now it
turns out that this doesn't work with libavformat. It will terminate
playback right after the audio runs out (instead of looping it like the
video, or whatever it's supposed to do). I'm not sure what exactly the
problem is, but since 1. even mplayer-svn can't handle DVD menus
directly (missing highlights), 2. DVD menus are essentially worthless,
and 3. I don't directly watch DVDs, don't bother with it and remove it.

For basic playback, there's still libdvdread support.

Also, use pkg-config for libdvdread, and drop support for in-tree
libdvdread. Remove support for in-tree libdvdcss as well.
2012-08-16 17:17:49 +02:00
wm4 fb563de255 sub: fix confusion of ass_library handles
Commit 7484ae8e2e attempted to introduce two ass_library handles
(as it was needed to deal with how ass_library manages fonts), but the
commit was completely bogus: it assumed osd_state->ass_library would be
used by osd_libass.c only, which is not the case. As result, some of the
subtitle code used the wrong ass_library handle.

We need two ass_library handles in osd_state. The one from the mplayer
core for subtitles (osd_state->ass_library), and one for OSD rendering
(osd_state->osd_ass_library).
2012-08-07 19:21:46 +02:00
wm4 7484ae8e2e osd_libass: allocate separate ASS_Library for OSD
osd_libass.c used the same ASS_Library object as the player core. This
caused a problem: when playing a new file, all fonts loaded by the
ASS_Library object were unloaded, including the OSD font. Parts of the
OSD would stop being rendered correctly.

Solve this by creating a separate ASS_Library, with its own set of
fonts.
2012-08-07 02:15:27 +02:00
wm4 0268b1a445 osd: reset OSD change state even if VO doesn't draw OSD
Commit 168293e0ae assumed the OSD drawing routines (which have the
functions osd_draw_text/_ext as entrypoint) would always be called, and
relied on that to reset the change flag.

Some VOs, such as vo_null, didn't do this. Pausing could turn into
endless framestepping in some cases. Restore the part of the OSD drawing
logic that dealt with this. (Alternatively, the VOs could be obliged to
always call the OSD drawing routines, even if the VO doesn't actually
draw the OSD. But it seems even more messy to rely on that.)
2012-08-07 01:58:43 +02:00
wm4 2287245136 VO: remove old VO glue
This transition to a new VO API started over 4 years ago. It's time to
finally end it, and get rid of the horrible hacks.

Also removes some previously undetected dead code from spudec.c.
2012-08-07 01:29:56 +02:00
wm4 a62b9cf7a3 osd: free buffer allocated with av_malloc with av_free
free() was used before, which could in theory lead to crashes if
the OSD buffer was freed or resized. (Whether using free() actually
works depends on what function libavutil's av_malloc() uses internally.
On Linux, it seems to use memalign(), which uses free() as counterpart
for deallocation, so the bug never triggered for me.)
2012-08-04 22:22:37 +02:00
wm4 a78bb28ed6 sub: simplify code by always defining sub_cp 2012-08-03 06:53:10 +02:00
mplayer-svn 2e125e7984 subassconvert: order colour names alphabetically / better match W3 list
Order colour names alphabetically / better match W3 list.

Patch by Federico Kereki, fkereki gmail

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35006 b3059339-0415-0410-9bf9-f77b7e298cf2

Add a few new CSS colors.

Patch by Federico Kereki, fkereki gmail

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35007 b3059339-0415-0410-9bf9-f77b7e298cf2

Author: cehoyos
2012-08-03 03:47:09 +02:00
mplayer-svn 97f0ed25ed spudec: use more precise alpha handling for -spuaa 4
Use more precise alpha handling for -spuaa 4.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34874 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
2012-08-03 03:34:38 +02:00
mplayer-svn 0dc290269d av_sub, spudec: support multiple rectangles
av_sub: support multiple rectangles.

The "packet_t" structure is renamed with a prefix,
because it is used a public header.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34872 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: cigaes
2012-08-03 03:34:38 +02:00
mplayer-svn 0461f5e669 subreader: eliminate duplicate subtitle lines
Eliminate duplicate subtitle lines which will most likely
be artefacts from ASS effects.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34574 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
2012-08-03 01:43:03 +02:00
mplayer-svn d5b964852a subreader: SSA reader: do not strip commas in commands
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34573 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
2012-08-03 01:43:03 +02:00
mplayer-svn 335c6259d2 subreader: fix reading of aqr/subrip09 subtitles
NULL return would indicate EOF, thus the "clear subtitle" entries
would cause sub file parsing to stop.
In addition the wrong sub end times would be used with CONFIG_SORTSUB.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33993 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
2012-08-03 01:26:22 +02:00
mplayer-svn c5b0ec92f9 subreader: get rid of some code duplication
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33992 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
2012-08-03 01:21:52 +02:00
wm4 ebaaa41f2a Remove teletext support
Teletext requires special OSD support. Because I can't even test
teletext, I can't restore support for it. Since teletext can be
considered ancient and obscure, and since it doesn't make sense to keep
the remaining teletext code without being able to use it, I'm removing
it.
2012-08-03 00:12:46 +02:00
wm4 168293e0ae osd: minor simplification of vo_osd_changed()
vo_osd_changed() was a weird function: it was used both to query and
mutate state, which is a bad combination. The VOs used it to query
and reset the state, and the mplayer frontend mostly used it to set
the state. In some cases, the frontend did both (that code used a
variable "int hack" to backup the state and set it again).

Simplify it and make the VOs use a vo_osd_has_changed() function to
query whether the OSD bitmaps have to be recreated. vo_osd_changed()
on the other hand is now used to update state only. The OSD change
state is reset when osd_draw_text() is called.

Update vo_corevideo.m to use vo_osd_resized() as well (forgotten change
from libass-OSD merge).

Simplify osd_set_text() and its usages.
2012-08-01 18:23:28 +02:00
wm4 c92538dfaa Remove dead code
This was done with the help of callcatcher [1]. Only functions which
are statically known to be unused are removed.

Some unused functions are not removed yet, because they might be needed
in the near future (such as open_output_stream for the encode branch).

There is one user visible change: the --subcc option did nothing, and is
removed with this commit.

[1] http://www.skynet.ie/~caolan/Packages/callcatcher.html
2012-08-01 17:07:35 +02:00
wm4 6e8633c734 configure: remove checks for malloc.h and alloca()
Including <malloc.h>, especially if all you want is malloc(), has no
legitimate uses (on sane platforms at least). Remove the check for it,
and remove all uses in the code.

Remove unused check for alloca().
2012-07-30 22:14:33 +02:00
wm4 261243496e configure: remove memalign check
Also, replace the only use of memalign: use av_malloc instead in sub.c.
(av_malloc allocates with the required alignment restrictions.)
2012-07-30 22:14:33 +02:00
wm4 69c13af381 ass_mp.c: remap libass log levels
libass is way too chatty. The application using it shouldn't be forced
to print useless messages, especially not if the action was initiated
by the application, and libass successfully completes it.

Note that this might be a problem that should be fixed in libass, but
remapping the log levels is needed anyway (instead of relying on the
coincidence that the log level values are similar).
2012-07-30 01:49:35 +02:00
wm4 93de744a2b sub: silence output of subtitle search message
This message is not so interesting.
2012-07-30 01:45:07 +02:00
wm4 6009965cdd sub: remove unrar_exec
This removes the ability to open compressed bitmap subtitles from rar
files. The code makes me afraid, and I never needed this feature.
2012-07-30 01:40:42 +02:00
wm4 08caadb9c0 bstr: rename bstr() function to bstr0(), and typedef bstr to struct bstr
Replace all uses of bstr() with bstr0().
Also remove the ridiculous C++ workaround.
2012-07-28 23:47:42 +02:00
wm4 71e51d948c osd: osd_font.h -> osd_font.pfb
osd_font.pfb is an actual font file extracted from osd_font.h.
file2string.py is used to turn it back into a header during the
build process.
2012-07-28 23:36:08 +02:00
wm4 85a3a0d5bc osd: remove freetype font rendering code
The previous commit made libass the default OSD renderer. This commit
removes the disabled freetype renderer completely. The commits were
done separately to make rolling back easier, because using libass for
OSD rendering is a risky choice.

Also remove freetype/fontconfig/fribidi code. This is all done by
libass now.

If mplayer is compiled without libass, no OSD is displayed.
2012-07-28 23:36:08 +02:00
wm4 74e7a1e937 osd: use libass for OSD rendering
The OSD will now be rendered with libass. The old rendering code, which
used freetype/fontconfig and did text layout manually, is disabled. To
re-enable the old code, use the --disable-libass-osd configure switch.

Some switches do nothing with the new code enabled, such as -subalign,
-sub-bg-alpha, -sub-bg-color, and many more. (The reason is mostly that
the code for rendering unstyled subtitles with libass doesn't make any
attempts to support them. Some of them could be supported in theory.)

Teletext rendering is not implemented in the new OSD rendering code. I
don't have any teletext sources for testing, and since teletext is
being phased out world-wide, the need for this is questionable.

Note that rendering is extremely inefficient, mostly because the libass
output is blended with the extremely strange mplayer OSD format. This
could be improved at a later point.

Remove most OSD rendering from vo_aa.c, because that was extremely
hacky, can't be made work with osd_libass, and didn't work anyway in
my tests.

Internally, some cleanup is done. Subtitle and OSD related variable
declarations were literally all over the place. Move them to sub.h and
sub.c, which were hoarding most of these declarations already. Make the
player core in mplayer.c free of concerns like bitmap font loading.

The old OSD rendering code has been moved to osd_ft.c. The font_load.c
and font_load_ft.c are only needed and compiled if the old OSD
rendering code is configured.
2012-07-28 23:36:07 +02:00
wm4 ac771d288d osd: enable line breaking for OSD text
OSD text wider than the window will be broken to fit the width. The line
breaking algorithm is naive and intended as temporary, until the OSD
render code is possibly replaced by "something better".

Newline characters are also considered.
2012-07-28 20:57:37 +02:00
wm4 2793e7eb70 Merge remote-tracking branch 'origin/master' 2012-05-20 11:42:44 +02:00
Uoti Urpala f63dbaddb6 font_load_ft.c: fix possible crash with recent Fontconfig
Calling FcFontMatch with last argument NULL triggers an assertion
failure in latest libfontconfig (2.9.0). Change the code to use a
dummy address, like another nearby call to FcFontMatch already did.

Whether the code triggering the assertion failure was run depended on
font settings and/or available system fonts (the code looks like you'd
have to get a non-scalable font first). Thus it didn't usually happen
even with problematic libfontconfig version.
2012-05-17 17:38:00 +03:00
wm4 97ac824124 Merge remote-tracking branch 'origin/master'
Conflicts:
	bstr.c
	bstr.h
	libvo/cocoa_common.m
	libvo/gl_common.c
	libvo/video_out.c
	mplayer.c
	screenshot.c
	sub/subassconvert.c

Merge of cocoa_common.m done by pigoz.

Picking my version of screenshot.c. The fix in commit aadf1002f8 will
be redone in a follow-up commit, as the original commit causes too many
conflicts with the work done locally in this branch, and other work in
progress.
2012-04-29 10:01:28 +02:00
wm4 87f4cafe9c Merge remote-tracking branch 'origin/master'
Conflicts:
	command.c
	libao2/ao_alsa.c
	libao2/ao_dsound.c
	libao2/ao_pulse.c
	libao2/audio_out.h
	mixer.c
	mixer.h
	mplayer.c

Replace my mixer changes with uau's implementation, which is based on
my code.
2012-04-28 00:54:26 +02:00
Uoti Urpala 81eb911763 subassconvert: make subrip attribute parsing more robust
Add general code to separate the HTML-like attribute=value syntax used
in srt font tags into attribute and value parts. This simplifies some
of the parsing code, makes detection of malformed input more robust,
and allows warning about unrecognized attributes.
2012-04-17 02:43:15 +03:00
wm4 f0ce95607f subassconvert: handle unquoted attributes in subrip font tags
Previously, mplayer didn't convert tags like <font color=#00FF00>. But
such subtitles exist in the wild, and should be handled.
2012-04-17 01:27:22 +03:00