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.
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.
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.
We now have a simple function to get a XvImage buffer as mp_image.
Return that as screenshot. We don't even need to copy the image (we
allocate a mp_image struct only, no image data).
Aspect ratio stuff needs to be fixed later. "Fixing" the position of OSD
elements outside of the screen due to panscan needs to be added back as
well (what the removed fixup_osd_position() function did).
The amount of data needed to "backup" an image when OSD is rendered
increases. This is because we support color OSD/subtitles now. The old
code rendered into the Y plane only, while the new code touches all 3
planes. For YV12, which is probably the only format supported not
considering chroma-swapped and packed formats, 0.5 times more memory
is copied when the OSD is used in pause mode.
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.
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.
This wasn't used anymore.
Remove the reference to IMGFMT_MJPEG in vf_dlopen as well. Thus format
is used as FourCC in the TV code (i.e. it's on the demuxer level, just
like raw formats), and never appears in the video filter chain. For
starters, vd_ffmpeg can never produce this format.
Fixes for palette allocation handling.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34304 b3059339-0415-0410-9bf9-f77b7e298cf2
This caused a crash with http://samples.ffmpeg.org/cdxl/fruit.cdxl if
direct rendering was used. (Which is rarely these days.)
With small changes: avoid av_freep() use, as this function is not sane.
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.
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.
Attempting to take screenshots printed vdpau errors on the terminal,
and the resulting screenshots were filled with black.
The problem was that that the screenshot code tried to use an
unallocated output surface (the one at vc->output_surfaces[vc->num_output_surfaces]).
This used to refer to the last allocated surface, until this was
changed by a recently merged commit. That commit also added a separate
screenshot surface. The merge somehow went wrong, and that part was not
integrated.
<uau> wm4: you used an earlier buggy version of a commit
OK...
Always use the same function as the OSD does (get_current_time()). This
loses the logic to display "???" if the time is unknown, as
get_current_time() returns 0 in this case. (The function has far too
many uses to change that now, and it seems to happen rarely in
practice.)
The -geometry switch works by modifying the d_width/d_height values
passed to VOs. Moreover, d_width/d_height seem to be subject to the
-monitorpixelaspect option. Screenshots should not be influenced by
this. Change screenshot supporting VOs to use the original
d_width/d_height values stored in vo->aspdat.prew/h.
(Not all uses of -geometry did this. E.g. --geometry=900x560+0+20 did.)
It seems FreeBSD 10.0-CURRENT as of this time doesn't include the GLX
extension and header file definitions for creating OpenGL 3.x core
contexts. Dump some more hacks into gl_header_fixes.h.
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.
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.
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.
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).
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).
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.
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.)
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.
This contains about the same code as bitmap_packer.c. eosd_packer.c was
added first, and then not merged for a year - then it was added as
bitmap_packer.c with slightly different and incompatible interface. Now
replacing eosd_packer.c with bitmap_packer.c is finally done. So much
wasted work...
Side effect: no direct support for old OSD format anymore. Instead,
sub.c converts sub-images in that format to the packed, alpha-inverted
version.
osd-color suboption is broken.
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.
Useless. It complicated the code and caused flicker, and was useless
otherwise. The manpage describes this option as "should not normally
be used".
One possibly useful effect from the point of view of the user was that
vsync was disabled. You can do this with the --vsync option, or by
changing X/driver settings directly.
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.
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
libass may always return a full change if no subtitle images are
rendered in some cases (empty tracks). Also, a full change despite empty
sub-images list may be reported on initialization. Avoid invoking odd
special cases in the VO code by always exiting early if the sub-image
list is empty.
Note that at least for OSD, the code in sub.c doesn't even send a
request VOCTRL_DRAW_EOSD if the image list is empty. But the subtitle
rendering code in vf_vo.c is independent from this (at least for now).
This allows vo_vdpau to render OSD directly, without the indirection
through the old OSD API, and without the additional conversions.
Remove support for the old OSD format. Only the mplayer DVD subtitle
decoder still generates this format. Although the new OSD interface does
support this format, remove it from vo_vdpau. It would be relatively
hard to support it in the EOSD code, as it requires two surfaces. (These
two surfaces are blended on top of each other to emulate the mplayer OSD
format.) The correct way to implement direct support for DVD subs would
consist of adding a paletted image format of some sort. But even sd_lavc
converts paletted subtitle images to RGBA, so doing something special
just for DVD subs is not worth it.
This means the frontend (sub.c) converts the subtitles to RGBA if it
detects that vo_vdpau does not support them natively.