Commit Graph

3932 Commits

Author SHA1 Message Date
wm4 738aeb1c60 screenshot: let VOs pass colorspace information via mp_image
This removes the hack that screenshot_save() got the colorspace
information from the decoder. Instead, require the VOs to set the
colorspace information on the mp_images used to pass around the
screenshot data. This is more correct, as the image may have been
converted/modified in the video filter chain, although there's
nothing yet in the video filter chain which does this correctly.
2012-11-01 02:07:45 +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
wm4 d9839fe862 mp_image: add fields to pass colorspace down the filter chain
Note that this also adds a RGB colorspace for general symmetry. The
frontend (colormatrix property and options) and
mp_get_yuv2rgb_coeffs() don't support this.
2012-10-28 15:31:32 +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 0e81d62c53 Merge branch 'master' into osd_changes
Conflicts:
	libvo/vo_xv.c
2012-10-24 22:38:45 +02:00
wm4 bcf447d7e8 vo_lavc: never draw OSD
This guarantees that only subtitles are drawn. (Before this change, we
relied on the fact that OSD is only visible on user interaction, or if
explicitly request with --osd-level.)
2012-10-24 21:56:35 +02:00
Stefano Pigozzi 281989d384 vo_corevideo: add screenshot capability
Added screenshot capability to the corevideo VO by sending back the raw data
from the CVPixelBuffer.

Also added "screenshot window" functionality from the other OpenGL based VOs,
which uses glReadPixels to read image data back. This was moved to gl_common to
avoid duplication.
2012-10-24 21:56:34 +02:00
wm4 f80a32a8eb core: do not try to redraw OSD if VO doesn't support OSD
This fixes awkward framestepping when seeking with -vo null while paused
(caused because seeking by default draws an OSD bar, and mplayer trying
to redraw the OSD in that case; this logic is actually needed with
vo_xv).

It would have been simpler to just check vo->driver->draw_osd (and leave
that callback to NULL for VOs which don't support OSD), but for now try
to retain the capability to let VOs decide based on the image format
whether to support OSD or not.
2012-10-24 21:56:34 +02:00
Stefano Pigozzi 16d4e09b99 vo_corevideo: fix EOSD artifacts
The new EOSD code suffered from artifacts due to missing setup of a projection
matrix. This commit fixes the problem and uniforms the resize code to the one
driving vo_opengl_old.
2012-10-24 21:56:34 +02:00
wm4 11ed093182 screenshot: allow taking screenshots with subtitles
This adds a new screenshot mode "subtitles", which basically takes the
video frame as decoded, and renders subtitles into it.

This may fail for some pixel formats, because libswscale sucks. If this
becomes ever a real problem, the code could be changed to convert the
image to RGBA first (or whatever the image writer wants), and then
render the subtitles into it. This would avoid the additional image
copy needed with vo_xv too. But for now, it seems better to go with the
current method in the common case: vo_opengl creates an image copy
anyway, and drawing bitmaps to yv12 is better, as no color space
conversion is involved in draw_bmp.c's up/downsampling conversion.
2012-10-24 21:56:34 +02:00
wm4 821c01a5f5 vo_corevideo: uninitialize CoreVideo objects before OpenGL 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 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 d5e4763243 vo_x11: use new OSD API 2012-10-24 21:56:33 +02:00
wm4 a45ad346e4 vo_xv: simplify screenshot code
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).
2012-10-24 21:56:33 +02:00
wm4 b03e357c69 vo_xv: use new OSD API
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.
2012-10-24 21:56:33 +02:00
Rudolf Polzer fef1871d3f vo_lavc: use new OSD API
Merged by wm4 from commits c93978f17b76 and following.
2012-10-24 21:56:33 +02:00
wm4 34d974032b csputils: cosmetic changes 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
Rudolf Polzer 64ac38c4d3 libmpcodecs: move vf_scale.c swscale helper functions to sws_utils.c
Extracted/rebased by wm4 from commits 93978f17b76d..13211ef5fc20.
Actual mp_image_swscale is added in a later commit.
2012-10-24 21:55:43 +02:00
wm4 2cad0e35f6 vo_opengl: fix help output typo 2012-10-23 00:08:59 +02:00
wm4 8bbce10c77 vo_vdpau: fix screenshots
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...
2012-10-21 20:55:02 +02:00
wm4 8c75a38d5f VO: fix screenshot size with -geometry
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.)
2012-10-20 19:33:58 +02:00
wm4 842402c6ca gl_common: hack to support compilation on FreeBSD
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.
2012-10-20 17:31:25 +02:00
Stefano Pigozzi cc6ca112e0 cocoa_common: avoid situational nil dereferencing 2012-10-19 23:47:03 +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 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 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 2db0d229ef libvo: remove eosd_packer.c
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...
2012-10-16 07:26:31 +02:00
wm4 ffd6219ecd vo_direct3d: use new OSD API 2012-10-16 07:26:31 +02:00
wm4 7463cff747 vo_corevideo: add EOSD
Completely untested.
2012-10-16 07:26:31 +02:00
wm4 637f1a4dc6 vo_gl: use gl_osd.c
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.
2012-10-16 07:26:31 +02:00
wm4 cadff3eec7 vo_gl3: move OSD code to gl_osd.c
Other OpenGL-using VOs can use this.

gl_osd.c includes some code for vo_gl.c. The next commit actually
makes use of it.
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 cf61928eec vo_gl, options: remove doublebuffering option (--double)
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.
2012-10-16 07:26:31 +02:00
wm4 42572fdcc0 sub, vo_gl3, vo_vdpau: exit early if there are no sub-images to draw
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).
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 bef616ede9 vo_vdpau: use new EOSD for OSD, remove support for old OSD format
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.
2012-10-16 07:26:31 +02:00
wm4 18ab695a72 vo_vdpau: allow multiple EOSD renderers
Preparation for using new OSD rendering method.
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 3099498154 vo_gl3: use old OSD using the emulation layer
This still renders the OSD using essentially the same mechanisms,
except that the EOSD code for texture handling and rendering is reused.
2012-10-16 07:26:30 +02:00
wm4 3c9c1790fe vo_gl3: support RGBA EOSD
This also adds support for multiple EOSD renderers. This capability is
unused yet, but important for the following commits.
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
Stefano Pigozzi e3fe5b8735 cocoa_common: use the same window level when windowed and fullscreen
This greatly simplifies the code and makes alt tab behave like it is supposed
to: it doesn't put the mplayer window behind the other ones when losing focus.

If you have other programs that are displaying themselves above the normal
window level, avoid them or use --ontop.
2012-10-16 07:19:33 +02:00