2009-02-16 21:58:13 +01:00
|
|
|
/*
|
|
|
|
* VDPAU video output driver
|
|
|
|
*
|
2013-10-23 19:06:14 +02:00
|
|
|
* Copyright (C) 2008 NVIDIA (Rajib Mahapatra <rmahapatra@nvidia.com>)
|
2009-11-15 03:39:22 +01:00
|
|
|
* Copyright (C) 2009 Uoti Urpala
|
2009-02-16 21:58:13 +01:00
|
|
|
*
|
2015-04-13 09:36:54 +02:00
|
|
|
* This file is part of mpv.
|
2009-02-16 21:58:13 +01:00
|
|
|
*
|
2015-04-13 09:36:54 +02:00
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
2009-02-16 21:58:13 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2015-04-13 09:36:54 +02:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2009-02-16 21:58:13 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2015-04-13 09:36:54 +02:00
|
|
|
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2009-02-16 21:58:13 +01:00
|
|
|
*/
|
|
|
|
|
2009-05-09 17:08:30 +02:00
|
|
|
/*
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
* Actual decoding is done in video/decode/vdpau.c
|
2009-02-16 21:58:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2009-09-18 15:27:55 +02:00
|
|
|
#include <stdlib.h>
|
2009-05-06 22:49:51 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2009-11-15 03:39:22 +01:00
|
|
|
#include <limits.h>
|
2012-08-26 18:00:26 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <libavutil/common.h>
|
2009-02-16 21:58:13 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
#include "video/vdpau.h"
|
2014-04-29 15:11:44 +02:00
|
|
|
#include "video/vdpau_mixer.h"
|
2013-11-23 21:26:31 +01:00
|
|
|
#include "video/hwdec.h"
|
2013-12-17 02:39:45 +01:00
|
|
|
#include "common/msg.h"
|
2013-12-17 02:02:25 +01:00
|
|
|
#include "options/options.h"
|
2009-05-06 20:04:37 +02:00
|
|
|
#include "talloc.h"
|
2012-11-09 01:06:43 +01:00
|
|
|
#include "vo.h"
|
2009-02-16 21:58:13 +01:00
|
|
|
#include "x11_common.h"
|
2012-11-09 01:06:43 +01:00
|
|
|
#include "video/csputils.h"
|
2013-11-24 12:58:06 +01:00
|
|
|
#include "sub/osd.h"
|
2013-12-17 02:02:25 +01:00
|
|
|
#include "options/m_option.h"
|
2012-11-09 01:06:43 +01:00
|
|
|
#include "video/mp_image.h"
|
2009-09-07 01:02:24 +02:00
|
|
|
#include "osdep/timer.h"
|
2012-08-26 18:00:26 +02:00
|
|
|
#include "bitmap_packer.h"
|
2009-02-23 10:21:57 +01:00
|
|
|
|
2014-04-08 19:13:15 +02:00
|
|
|
// Returns x + a, but wrapped around to the range [0, m)
|
|
|
|
// a must be within [-m, m], x within [0, m)
|
2010-05-06 03:46:10 +02:00
|
|
|
#define WRAP_ADD(x, a, m) ((a) < 0 \
|
|
|
|
? ((x)+(a)+(m) < (m) ? (x)+(a)+(m) : (x)+(a)) \
|
|
|
|
: ((x)+(a) < (m) ? (x)+(a) : (x)+(a)-(m)))
|
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
|
|
|
|
/* number of video and output surfaces */
|
2010-05-14 04:18:38 +02:00
|
|
|
#define MAX_OUTPUT_SURFACES 15
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2011-10-06 20:46:01 +02:00
|
|
|
/* Pixelformat used for output surfaces */
|
|
|
|
#define OUTPUT_RGBA_FORMAT VDP_RGBA_FORMAT_B8G8R8A8
|
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
/*
|
|
|
|
* Global variable declaration - VDPAU specific
|
|
|
|
*/
|
|
|
|
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx {
|
2013-11-05 22:06:32 +01:00
|
|
|
struct mp_vdpau_ctx *mpvdp;
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
struct vdp_functions *vdp;
|
2009-05-06 22:42:24 +02:00
|
|
|
VdpDevice vdp_device;
|
2013-11-05 22:06:32 +01:00
|
|
|
uint64_t preemption_counter;
|
2014-08-11 23:08:35 +02:00
|
|
|
struct mp_hwdec_info hwdec_info;
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
|
2013-08-17 19:57:18 +02:00
|
|
|
struct m_color colorkey;
|
|
|
|
|
2009-05-06 22:42:24 +02:00
|
|
|
VdpPresentationQueueTarget flip_target;
|
|
|
|
VdpPresentationQueue flip_queue;
|
|
|
|
|
2012-08-26 18:00:26 +02:00
|
|
|
VdpOutputSurface output_surfaces[MAX_OUTPUT_SURFACES];
|
2010-05-14 04:18:38 +02:00
|
|
|
int num_output_surfaces;
|
2013-08-18 05:12:21 +02:00
|
|
|
VdpOutputSurface black_pixel;
|
2013-10-01 23:45:30 +02:00
|
|
|
|
2014-04-29 15:19:03 +02:00
|
|
|
struct mp_image *current_image;
|
2013-10-01 23:45:30 +02:00
|
|
|
|
2009-05-06 22:42:24 +02:00
|
|
|
int output_surface_width, output_surface_height;
|
|
|
|
|
2013-08-18 05:12:21 +02:00
|
|
|
int force_yuv;
|
2014-04-29 15:11:44 +02:00
|
|
|
struct mp_vdpau_mixer *video_mixer;
|
2009-05-06 22:42:24 +02:00
|
|
|
int deint;
|
|
|
|
int pullup;
|
|
|
|
float denoise;
|
|
|
|
float sharpen;
|
2009-11-15 17:39:48 +01:00
|
|
|
int hqscaling;
|
2009-05-06 22:42:24 +02:00
|
|
|
int chroma_deint;
|
2010-02-05 19:13:33 +01:00
|
|
|
int flip_offset_window;
|
|
|
|
int flip_offset_fs;
|
2014-12-09 17:46:35 +01:00
|
|
|
int64_t flip_offset_us;
|
2009-05-06 22:42:24 +02:00
|
|
|
|
|
|
|
VdpRect src_rect_vid;
|
|
|
|
VdpRect out_rect_vid;
|
2012-10-27 22:10:32 +02:00
|
|
|
struct mp_osd_res osd_rect;
|
2009-05-06 22:42:24 +02:00
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 14:25:04 +01:00
|
|
|
int surface_num; // indexes output_surfaces
|
2010-05-14 04:18:38 +02:00
|
|
|
int query_surface_num;
|
2009-11-15 03:39:22 +01:00
|
|
|
VdpTime recent_vsync_time;
|
|
|
|
float user_fps;
|
2012-07-27 02:40:38 +02:00
|
|
|
int composite_detect;
|
2009-11-15 03:39:22 +01:00
|
|
|
unsigned int vsync_interval;
|
|
|
|
uint64_t last_queue_time;
|
2010-05-14 04:18:38 +02:00
|
|
|
uint64_t queue_time[MAX_OUTPUT_SURFACES];
|
2009-11-15 03:39:22 +01:00
|
|
|
uint64_t last_ideal_time;
|
|
|
|
bool dropped_frame;
|
|
|
|
uint64_t dropped_time;
|
2009-05-06 22:42:24 +02:00
|
|
|
uint32_t vid_width, vid_height;
|
|
|
|
uint32_t image_format;
|
|
|
|
VdpYCbCrFormat vdp_pixel_format;
|
2013-08-18 05:12:21 +02:00
|
|
|
bool rgb_mode;
|
2009-05-06 22:42:24 +02:00
|
|
|
|
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-19 19:25:18 +02:00
|
|
|
// OSD
|
|
|
|
struct osd_bitmap_surface {
|
2012-08-31 14:42:30 +02:00
|
|
|
VdpRGBAFormat format;
|
2012-08-26 18:00:26 +02:00
|
|
|
VdpBitmapSurface surface;
|
|
|
|
uint32_t max_width;
|
|
|
|
uint32_t max_height;
|
|
|
|
struct bitmap_packer *packer;
|
2012-09-28 21:49:32 +02:00
|
|
|
// List of surfaces to be rendered
|
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-19 19:25:18 +02:00
|
|
|
struct osd_target {
|
2012-09-28 21:49:32 +02:00
|
|
|
VdpRect source;
|
|
|
|
VdpRect dest;
|
|
|
|
VdpColor color;
|
|
|
|
} *targets;
|
2012-09-28 21:49:09 +02:00
|
|
|
int targets_size;
|
|
|
|
int render_count;
|
2015-03-18 12:33:14 +01:00
|
|
|
int change_id;
|
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-19 19:25:18 +02:00
|
|
|
} osd_surfaces[MAX_OSD_PARTS];
|
2009-05-06 22:49:51 +02:00
|
|
|
|
|
|
|
// Video equalizer
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 23:50:21 +02:00
|
|
|
struct mp_csp_equalizer video_eq;
|
2009-05-06 22:49:51 +02:00
|
|
|
};
|
2009-02-16 21:58:13 +01:00
|
|
|
|
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-19 19:25:18 +02:00
|
|
|
static bool status_ok(struct vo *vo);
|
2014-06-15 20:46:57 +02:00
|
|
|
static void draw_osd(struct vo *vo);
|
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-19 19:25:18 +02:00
|
|
|
|
2011-10-06 20:46:01 +02:00
|
|
|
static int render_video_to_output_surface(struct vo *vo,
|
|
|
|
VdpOutputSurface output_surface,
|
2013-08-18 05:06:46 +02:00
|
|
|
VdpRect *output_rect,
|
|
|
|
VdpRect *video_rect)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-02-16 21:58:13 +01:00
|
|
|
VdpTime dummy;
|
|
|
|
VdpStatus vdp_st;
|
2014-04-29 15:19:03 +02:00
|
|
|
struct mp_image *mpi = vc->current_image;
|
2013-10-01 23:45:30 +02:00
|
|
|
|
2015-01-22 17:57:59 +01:00
|
|
|
vdp_st = vdp->presentation_queue_block_until_surface_idle(vc->flip_queue,
|
|
|
|
output_surface,
|
|
|
|
&dummy);
|
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling "
|
|
|
|
"vdp_presentation_queue_block_until_surface_idle");
|
|
|
|
|
2015-03-23 18:15:40 +01:00
|
|
|
// Clear the borders between video and window (if there are any).
|
|
|
|
// For some reason, video_mixer_render doesn't need it for YUV.
|
|
|
|
// Also, if there is nothing to render, at least clear the screen.
|
|
|
|
if (vc->rgb_mode || !mpi) {
|
2013-08-18 05:12:21 +02:00
|
|
|
int flags = VDP_OUTPUT_SURFACE_RENDER_ROTATE_0;
|
|
|
|
vdp_st = vdp->output_surface_render_output_surface(output_surface,
|
|
|
|
NULL, vc->black_pixel,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
flags);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error clearing screen");
|
2013-08-18 05:12:21 +02:00
|
|
|
}
|
|
|
|
|
2015-03-23 18:15:40 +01:00
|
|
|
if (!mpi)
|
|
|
|
return -1;
|
|
|
|
|
2014-04-29 15:14:19 +02:00
|
|
|
struct mp_vdpau_mixer_frame *frame = mp_vdpau_mixed_frame_get(mpi);
|
|
|
|
struct mp_vdpau_mixer_opts opts = {0};
|
|
|
|
if (frame)
|
|
|
|
opts = frame->opts;
|
|
|
|
|
|
|
|
// Apply custom vo_vdpau suboptions.
|
|
|
|
opts.chroma_deint |= vc->chroma_deint;
|
|
|
|
opts.pullup |= vc->pullup;
|
|
|
|
opts.denoise = MPCLAMP(opts.denoise + vc->denoise, 0, 1);
|
|
|
|
opts.sharpen = MPCLAMP(opts.sharpen + vc->sharpen, -1, 1);
|
|
|
|
if (vc->hqscaling)
|
|
|
|
opts.hqscaling = vc->hqscaling;
|
|
|
|
|
|
|
|
mp_vdpau_mixer_render(vc->video_mixer, &opts, output_surface, output_rect,
|
|
|
|
mpi, video_rect);
|
2009-09-18 23:00:42 +02:00
|
|
|
return 0;
|
2009-09-18 15:27:55 +02:00
|
|
|
}
|
2009-03-26 00:32:27 +01:00
|
|
|
|
2011-10-06 20:46:01 +02:00
|
|
|
static int video_to_output_surface(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
2014-06-15 20:46:57 +02:00
|
|
|
int r = render_video_to_output_surface(vo,
|
|
|
|
vc->output_surfaces[vc->surface_num],
|
|
|
|
&vc->out_rect_vid, &vc->src_rect_vid);
|
|
|
|
draw_osd(vo);
|
|
|
|
return r;
|
2011-10-06 20:46:01 +02:00
|
|
|
}
|
|
|
|
|
2013-10-01 23:45:30 +02:00
|
|
|
static void forget_frames(struct vo *vo, bool seek_reset)
|
2009-09-18 15:27:55 +02:00
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
2014-04-29 15:19:03 +02:00
|
|
|
if (!seek_reset)
|
|
|
|
mp_image_unrefp(&vc->current_image);
|
2013-10-01 23:45:30 +02:00
|
|
|
|
2009-11-15 03:39:22 +01:00
|
|
|
vc->dropped_frame = false;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2014-10-01 17:12:46 +02:00
|
|
|
static int s_size(int s, int disp)
|
|
|
|
{
|
|
|
|
disp = MPMAX(1, disp);
|
|
|
|
s += s / 2;
|
|
|
|
return s >= disp ? s : disp;
|
|
|
|
}
|
|
|
|
|
2009-05-04 02:09:50 +02:00
|
|
|
static void resize(struct vo *vo)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-02-16 21:58:13 +01:00
|
|
|
VdpStatus vdp_st;
|
2012-10-27 22:10:32 +02:00
|
|
|
struct mp_rect src_rect;
|
|
|
|
struct mp_rect dst_rect;
|
|
|
|
vo_get_src_dst_rects(vo, &src_rect, &dst_rect, &vc->osd_rect);
|
|
|
|
vc->out_rect_vid.x0 = dst_rect.x0;
|
|
|
|
vc->out_rect_vid.x1 = dst_rect.x1;
|
|
|
|
vc->out_rect_vid.y0 = dst_rect.y0;
|
|
|
|
vc->out_rect_vid.y1 = dst_rect.y1;
|
|
|
|
vc->src_rect_vid.x0 = src_rect.x0;
|
|
|
|
vc->src_rect_vid.x1 = src_rect.x1;
|
2015-05-01 18:47:27 +02:00
|
|
|
vc->src_rect_vid.y0 = src_rect.y0;
|
|
|
|
vc->src_rect_vid.y1 = src_rect.y1;
|
2012-10-04 17:16:28 +02:00
|
|
|
|
2014-12-09 17:46:35 +01:00
|
|
|
vc->flip_offset_us = vo->opts->fullscreen ?
|
|
|
|
1000LL * vc->flip_offset_fs :
|
|
|
|
1000LL * vc->flip_offset_window;
|
2015-01-23 20:56:11 +01:00
|
|
|
vo_set_flip_queue_params(vo, vc->flip_offset_us, false);
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2012-10-21 00:48:01 +02:00
|
|
|
if (vc->output_surface_width < vo->dwidth
|
|
|
|
|| vc->output_surface_height < vo->dheight) {
|
2014-10-01 17:12:46 +02:00
|
|
|
vc->output_surface_width = s_size(vc->output_surface_width, vo->dwidth);
|
|
|
|
vc->output_surface_height = s_size(vc->output_surface_height, vo->dheight);
|
2009-02-16 21:58:13 +01:00
|
|
|
// Creation of output_surfaces
|
2012-08-26 18:00:26 +02:00
|
|
|
for (int i = 0; i < vc->num_output_surfaces; i++)
|
2010-05-26 07:54:09 +02:00
|
|
|
if (vc->output_surfaces[i] != VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->output_surface_destroy(vc->output_surfaces[i]);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling "
|
|
|
|
"vdp_output_surface_destroy");
|
2010-05-26 07:54:09 +02:00
|
|
|
}
|
2012-08-26 18:00:26 +02:00
|
|
|
for (int i = 0; i < vc->num_output_surfaces; i++) {
|
2009-05-09 17:08:30 +02:00
|
|
|
vdp_st = vdp->output_surface_create(vc->vdp_device,
|
2011-10-06 20:46:01 +02:00
|
|
|
OUTPUT_RGBA_FORMAT,
|
2009-05-09 17:08:30 +02:00
|
|
|
vc->output_surface_width,
|
|
|
|
vc->output_surface_height,
|
|
|
|
&vc->output_surfaces[i]);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_output_surface_create");
|
2013-08-23 23:30:09 +02:00
|
|
|
MP_DBG(vo, "vdpau out create: %u\n",
|
2009-05-09 17:08:30 +02:00
|
|
|
vc->output_surfaces[i]);
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
}
|
2011-12-05 05:36:20 +01:00
|
|
|
vo->want_redraw = true;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2009-05-04 02:09:50 +02:00
|
|
|
static int win_x11_init_vdpau_flip_queue(struct vo *vo)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-05-04 02:09:50 +02:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2009-02-16 21:58:13 +01:00
|
|
|
VdpStatus vdp_st;
|
|
|
|
|
2009-09-07 01:02:24 +02:00
|
|
|
if (vc->flip_target == VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->presentation_queue_target_create_x11(vc->vdp_device,
|
|
|
|
x11->window,
|
|
|
|
&vc->flip_target);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_ERROR(vo, "Error when calling "
|
|
|
|
"vdp_presentation_queue_target_create_x11");
|
2009-09-07 01:02:24 +02:00
|
|
|
}
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2009-09-07 01:02:24 +02:00
|
|
|
/* Emperically this seems to be the first call which fails when we
|
|
|
|
* try to reinit after preemption while the user is still switched
|
|
|
|
* from X to a virtual terminal (creating the vdp_device initially
|
|
|
|
* succeeds, as does creating the flip_target above). This is
|
2014-05-09 21:49:32 +02:00
|
|
|
* probably not guaranteed behavior.
|
2009-09-07 01:02:24 +02:00
|
|
|
*/
|
|
|
|
if (vc->flip_queue == VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->presentation_queue_create(vc->vdp_device, vc->flip_target,
|
|
|
|
&vc->flip_queue);
|
2014-05-09 21:49:32 +02:00
|
|
|
CHECK_VDP_ERROR(vo, "Error when calling vdp_presentation_queue_create");
|
2009-09-07 01:02:24 +02:00
|
|
|
}
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2013-08-17 19:57:18 +02:00
|
|
|
if (vc->colorkey.a > 0) {
|
|
|
|
VdpColor color = {
|
|
|
|
.red = vc->colorkey.r / 255.0,
|
|
|
|
.green = vc->colorkey.g / 255.0,
|
|
|
|
.blue = vc->colorkey.b / 255.0,
|
|
|
|
.alpha = 0,
|
|
|
|
};
|
|
|
|
vdp_st = vdp->presentation_queue_set_background_color(vc->flip_queue,
|
|
|
|
&color);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error setting colorkey");
|
2013-08-17 19:57:18 +02:00
|
|
|
}
|
|
|
|
|
2012-07-27 02:40:38 +02:00
|
|
|
if (vc->composite_detect && vo_x11_screen_is_composited(vo)) {
|
2013-08-23 23:30:09 +02:00
|
|
|
MP_INFO(vo, "Compositing window manager detected. Assuming timing info "
|
|
|
|
"is inaccurate.\n");
|
2014-08-17 02:50:59 +02:00
|
|
|
vc->user_fps = -1;
|
|
|
|
}
|
2009-11-15 03:39:22 +01:00
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Free everything specific to a certain video file
|
2009-05-06 20:04:37 +02:00
|
|
|
static void free_video_specific(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-02-16 21:58:13 +01:00
|
|
|
VdpStatus vdp_st;
|
|
|
|
|
2013-10-01 23:45:30 +02:00
|
|
|
forget_frames(vo, false);
|
2009-03-18 18:02:29 +01:00
|
|
|
|
2013-08-18 05:12:21 +02:00
|
|
|
if (vc->black_pixel != VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->output_surface_destroy(vc->black_pixel);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_output_surface_destroy");
|
2013-08-18 05:12:21 +02:00
|
|
|
}
|
|
|
|
vc->black_pixel = VDP_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
2009-10-22 03:21:14 +02:00
|
|
|
static int initialize_vdpau_objects(struct vo *vo)
|
2009-09-07 01:02:24 +02:00
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
2013-08-18 05:12:21 +02:00
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
|
|
|
VdpStatus vdp_st;
|
2009-09-07 01:02:24 +02:00
|
|
|
|
2015-05-28 21:54:02 +02:00
|
|
|
mp_vdpau_get_format(vc->image_format, NULL, &vc->vdp_pixel_format);
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
|
2014-04-29 15:11:44 +02:00
|
|
|
vc->video_mixer->initialized = false;
|
|
|
|
|
2009-09-07 01:02:24 +02:00
|
|
|
if (win_x11_init_vdpau_flip_queue(vo) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2014-05-22 20:55:05 +02:00
|
|
|
if (vc->black_pixel == VDP_INVALID_HANDLE) {
|
2013-08-18 05:12:21 +02:00
|
|
|
vdp_st = vdp->output_surface_create(vc->vdp_device, OUTPUT_RGBA_FORMAT,
|
|
|
|
1, 1, &vc->black_pixel);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_ERROR(vo, "Allocating clearing surface");
|
2013-08-18 05:12:21 +02:00
|
|
|
const char data[4] = {0};
|
|
|
|
vdp_st = vdp->output_surface_put_bits_native(vc->black_pixel,
|
|
|
|
(const void*[]){data},
|
|
|
|
(uint32_t[]){4}, NULL);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_ERROR(vo, "Initializing clearing surface");
|
2013-08-18 05:12:21 +02:00
|
|
|
}
|
2009-09-07 01:02:24 +02:00
|
|
|
|
2013-10-01 23:45:30 +02:00
|
|
|
forget_frames(vo, false);
|
2009-09-07 01:02:24 +02:00
|
|
|
resize(vo);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mark_vdpau_objects_uninitialized(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
2013-10-01 23:45:30 +02:00
|
|
|
forget_frames(vo, false);
|
2013-08-18 05:12:21 +02:00
|
|
|
vc->black_pixel = VDP_INVALID_HANDLE;
|
2014-04-29 15:11:44 +02:00
|
|
|
vc->video_mixer->video_mixer = VDP_INVALID_HANDLE;
|
2009-09-07 01:02:24 +02:00
|
|
|
vc->flip_queue = VDP_INVALID_HANDLE;
|
|
|
|
vc->flip_target = VDP_INVALID_HANDLE;
|
2012-08-26 18:00:26 +02:00
|
|
|
for (int i = 0; i < MAX_OUTPUT_SURFACES; i++)
|
2009-09-07 01:02:24 +02:00
|
|
|
vc->output_surfaces[i] = VDP_INVALID_HANDLE;
|
|
|
|
vc->vdp_device = VDP_INVALID_HANDLE;
|
2012-09-28 21:49:09 +02:00
|
|
|
for (int i = 0; i < MAX_OSD_PARTS; i++) {
|
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-19 19:25:18 +02:00
|
|
|
struct osd_bitmap_surface *sfc = &vc->osd_surfaces[i];
|
2012-09-28 21:49:09 +02:00
|
|
|
talloc_free(sfc->packer);
|
2015-03-18 12:33:14 +01:00
|
|
|
sfc->change_id = 0;
|
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-19 19:25:18 +02:00
|
|
|
*sfc = (struct osd_bitmap_surface){
|
2012-09-28 21:49:09 +02:00
|
|
|
.surface = VDP_INVALID_HANDLE,
|
|
|
|
};
|
|
|
|
}
|
2009-09-07 01:02:24 +02:00
|
|
|
vc->output_surface_width = vc->output_surface_height = -1;
|
|
|
|
}
|
|
|
|
|
2014-05-09 21:49:32 +02:00
|
|
|
static bool check_preemption(struct vo *vo)
|
2009-09-07 01:02:24 +02:00
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
2014-05-09 21:49:32 +02:00
|
|
|
int r = mp_vdpau_handle_preemption(vc->mpvdp, &vc->preemption_counter);
|
|
|
|
if (r < 1) {
|
2009-09-07 01:02:24 +02:00
|
|
|
mark_vdpau_objects_uninitialized(vo);
|
2014-05-09 21:49:32 +02:00
|
|
|
if (r < 0)
|
|
|
|
return false;
|
|
|
|
vc->vdp_device = vc->mpvdp->vdp_device;
|
|
|
|
if (initialize_vdpau_objects(vo) < 0)
|
|
|
|
return false;
|
2009-09-07 01:02:24 +02:00
|
|
|
}
|
2014-05-09 21:49:32 +02:00
|
|
|
return true;
|
2009-09-07 01:02:24 +02:00
|
|
|
}
|
|
|
|
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
static bool status_ok(struct vo *vo)
|
|
|
|
{
|
2014-05-09 21:49:32 +02:00
|
|
|
return vo->config_ok && check_preemption(vo);
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
}
|
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
/*
|
|
|
|
* connect to X server, create and map window, initialize all
|
|
|
|
* VDPAU objects, create different surfaces etc.
|
|
|
|
*/
|
2014-01-24 21:22:25 +01:00
|
|
|
static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 22:42:24 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
2015-06-04 22:29:21 +02:00
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
|
|
|
VdpStatus vdp_st;
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2014-05-09 21:49:32 +02:00
|
|
|
if (!check_preemption(vo))
|
2009-09-07 01:02:24 +02:00
|
|
|
return -1;
|
2009-11-15 14:50:28 +01:00
|
|
|
|
2015-06-04 22:29:21 +02:00
|
|
|
VdpChromaType chroma_type = VDP_CHROMA_TYPE_420;
|
|
|
|
mp_vdpau_get_format(params->imgfmt, &chroma_type, NULL);
|
|
|
|
|
|
|
|
VdpBool ok;
|
|
|
|
uint32_t max_w, max_h;
|
|
|
|
vdp_st = vdp->video_surface_query_capabilities(vc->vdp_device, chroma_type,
|
|
|
|
&ok, &max_w, &max_h);
|
|
|
|
CHECK_VDP_ERROR(vo, "Error when calling vdp_video_surface_query_capabilities");
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
return -1;
|
|
|
|
if (params->w > max_w || params->h > max_h) {
|
|
|
|
if (ok)
|
|
|
|
MP_ERR(vo, "Video too large for vdpau.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-01-24 21:22:25 +01:00
|
|
|
vc->image_format = params->imgfmt;
|
|
|
|
vc->vid_width = params->w;
|
|
|
|
vc->vid_height = params->h;
|
2011-10-06 20:46:01 +02:00
|
|
|
|
2014-05-22 20:55:17 +02:00
|
|
|
vc->rgb_mode = mp_vdpau_get_rgb_format(params->imgfmt, NULL);
|
2013-08-18 05:12:21 +02:00
|
|
|
|
2009-05-06 20:04:37 +02:00
|
|
|
free_video_specific(vo);
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2014-05-06 20:24:35 +02:00
|
|
|
vo_x11_config_vo_window(vo, NULL, flags, "vdpau");
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2009-09-07 01:02:24 +02:00
|
|
|
if (initialize_vdpau_objects(vo) < 0)
|
2009-02-16 21:58:13 +01:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-26 18:00:26 +02:00
|
|
|
static struct bitmap_packer *make_packer(struct vo *vo, VdpRGBAFormat format)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-05-09 17:08:30 +02:00
|
|
|
|
2012-08-26 18:00:26 +02:00
|
|
|
struct bitmap_packer *packer = talloc_zero(vo, struct bitmap_packer);
|
|
|
|
uint32_t w_max = 0, h_max = 0;
|
|
|
|
VdpStatus vdp_st = vdp->
|
|
|
|
bitmap_surface_query_capabilities(vc->vdp_device, format,
|
|
|
|
&(VdpBool){0}, &w_max, &h_max);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Query to get max OSD surface size failed");
|
2012-08-26 18:00:26 +02:00
|
|
|
packer->w_max = w_max;
|
|
|
|
packer->h_max = h_max;
|
|
|
|
return packer;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
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-19 19:25:18 +02:00
|
|
|
static void draw_osd_part(struct vo *vo, int index)
|
2009-05-06 20:04:37 +02:00
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-02-23 10:21:57 +01:00
|
|
|
VdpStatus vdp_st;
|
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-19 19:25:18 +02:00
|
|
|
struct osd_bitmap_surface *sfc = &vc->osd_surfaces[index];
|
2009-05-06 22:42:24 +02:00
|
|
|
VdpOutputSurface output_surface = vc->output_surfaces[vc->surface_num];
|
2009-02-23 10:21:57 +01:00
|
|
|
int i;
|
|
|
|
|
2009-05-09 17:08:30 +02:00
|
|
|
VdpOutputSurfaceRenderBlendState blend_state = {
|
|
|
|
.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION,
|
|
|
|
.blend_factor_source_color =
|
|
|
|
VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA,
|
|
|
|
.blend_factor_source_alpha =
|
2013-11-18 14:02:14 +01:00
|
|
|
VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO,
|
2009-05-09 17:08:30 +02:00
|
|
|
.blend_factor_destination_color =
|
|
|
|
VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
|
|
|
.blend_factor_destination_alpha =
|
2013-11-18 14:02:14 +01:00
|
|
|
VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO,
|
2009-05-09 17:08:30 +02:00
|
|
|
.blend_equation_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD,
|
|
|
|
.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD,
|
|
|
|
};
|
|
|
|
|
2012-10-05 20:37:16 +02:00
|
|
|
VdpOutputSurfaceRenderBlendState blend_state_premultiplied = blend_state;
|
|
|
|
blend_state_premultiplied.blend_factor_source_color =
|
|
|
|
VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE;
|
|
|
|
|
2012-09-28 21:49:09 +02:00
|
|
|
for (i = 0; i < sfc->render_count; i++) {
|
2012-10-05 20:37:16 +02:00
|
|
|
VdpOutputSurfaceRenderBlendState *blend = &blend_state;
|
|
|
|
if (sfc->format == VDP_RGBA_FORMAT_B8G8R8A8)
|
|
|
|
blend = &blend_state_premultiplied;
|
2009-05-09 17:08:30 +02:00
|
|
|
vdp_st = vdp->
|
|
|
|
output_surface_render_bitmap_surface(output_surface,
|
2012-09-28 21:49:09 +02:00
|
|
|
&sfc->targets[i].dest,
|
|
|
|
sfc->surface,
|
|
|
|
&sfc->targets[i].source,
|
|
|
|
&sfc->targets[i].color,
|
2012-10-05 20:37:16 +02:00
|
|
|
blend,
|
2009-05-09 17:08:30 +02:00
|
|
|
VDP_OUTPUT_SURFACE_RENDER_ROTATE_0);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "OSD: Error when rendering");
|
2009-02-23 10:21:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-19 19:25:18 +02:00
|
|
|
static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
|
2009-05-06 20:04:37 +02:00
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-02-23 10:21:57 +01:00
|
|
|
VdpStatus vdp_st;
|
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-19 19:25:18 +02:00
|
|
|
struct osd_bitmap_surface *sfc = &vc->osd_surfaces[imgs->render_index];
|
2012-08-26 18:00:26 +02:00
|
|
|
bool need_upload = false;
|
2011-10-27 12:07:10 +02:00
|
|
|
|
2015-03-18 12:33:14 +01:00
|
|
|
if (imgs->change_id == sfc->change_id)
|
2012-08-26 18:00:26 +02:00
|
|
|
return; // Nothing changed and we still have the old data
|
2011-10-27 12:07:10 +02:00
|
|
|
|
2012-09-28 21:49:09 +02:00
|
|
|
sfc->render_count = 0;
|
2012-08-26 18:00:26 +02:00
|
|
|
|
2012-10-02 00:25:06 +02:00
|
|
|
if (imgs->format == SUBBITMAP_EMPTY || imgs->num_parts == 0)
|
2012-08-31 14:42:30 +02:00
|
|
|
return;
|
2012-08-26 18:00:26 +02:00
|
|
|
|
|
|
|
need_upload = true;
|
2012-08-31 14:42:30 +02:00
|
|
|
VdpRGBAFormat format;
|
|
|
|
int format_size;
|
2012-09-28 21:19:36 +02:00
|
|
|
switch (imgs->format) {
|
2012-08-31 14:42:30 +02:00
|
|
|
case SUBBITMAP_LIBASS:
|
|
|
|
format = VDP_RGBA_FORMAT_A8;
|
|
|
|
format_size = 1;
|
|
|
|
break;
|
|
|
|
case SUBBITMAP_RGBA:
|
|
|
|
format = VDP_RGBA_FORMAT_B8G8R8A8;
|
|
|
|
format_size = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
};
|
|
|
|
if (sfc->format != format) {
|
|
|
|
talloc_free(sfc->packer);
|
|
|
|
sfc->packer = NULL;
|
|
|
|
};
|
|
|
|
sfc->format = format;
|
2012-08-26 18:00:26 +02:00
|
|
|
if (!sfc->packer)
|
2012-08-31 14:42:30 +02:00
|
|
|
sfc->packer = make_packer(vo, format);
|
2012-09-28 21:19:36 +02:00
|
|
|
sfc->packer->padding = imgs->scaled; // assume 2x2 filter on scaling
|
|
|
|
int r = packer_pack_from_subbitmaps(sfc->packer, imgs);
|
2012-08-26 18:00:26 +02:00
|
|
|
if (r < 0) {
|
2013-08-23 23:30:09 +02:00
|
|
|
MP_ERR(vo, "OSD bitmaps do not fit on a surface with the maximum "
|
|
|
|
"supported size\n");
|
2012-08-26 18:00:26 +02:00
|
|
|
return;
|
|
|
|
} else if (r == 1) {
|
|
|
|
if (sfc->surface != VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->bitmap_surface_destroy(sfc->surface);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_bitmap_surface_destroy");
|
2010-05-26 07:54:09 +02:00
|
|
|
}
|
2013-08-23 23:30:09 +02:00
|
|
|
MP_VERBOSE(vo, "Allocating a %dx%d surface for OSD bitmaps.\n",
|
|
|
|
sfc->packer->w, sfc->packer->h);
|
2012-08-31 14:42:30 +02:00
|
|
|
vdp_st = vdp->bitmap_surface_create(vc->vdp_device, format,
|
2012-08-26 18:00:26 +02:00
|
|
|
sfc->packer->w, sfc->packer->h,
|
|
|
|
true, &sfc->surface);
|
2009-09-02 19:21:24 +02:00
|
|
|
if (vdp_st != VDP_STATUS_OK)
|
2012-08-26 18:00:26 +02:00
|
|
|
sfc->surface = VDP_INVALID_HANDLE;
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "OSD: error when creating surface");
|
2009-02-23 10:21:57 +01:00
|
|
|
}
|
2012-08-31 14:42:30 +02:00
|
|
|
if (imgs->scaled) {
|
|
|
|
char zeros[sfc->packer->used_width * format_size];
|
|
|
|
memset(zeros, 0, sizeof(zeros));
|
|
|
|
vdp_st = vdp->bitmap_surface_put_bits_native(sfc->surface,
|
|
|
|
&(const void *){zeros}, &(uint32_t){0},
|
|
|
|
&(VdpRect){0, 0, sfc->packer->used_width,
|
|
|
|
sfc->packer->used_height});
|
2015-03-23 18:12:05 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "OSD: error uploading OSD bitmap");
|
2012-08-31 14:42:30 +02:00
|
|
|
}
|
2009-02-23 10:21:57 +01:00
|
|
|
|
2012-08-26 18:00:26 +02:00
|
|
|
if (sfc->surface == VDP_INVALID_HANDLE)
|
2009-09-02 19:21:24 +02:00
|
|
|
return;
|
2012-09-28 21:49:09 +02:00
|
|
|
if (sfc->packer->count > sfc->targets_size) {
|
|
|
|
talloc_free(sfc->targets);
|
|
|
|
sfc->targets_size = sfc->packer->count;
|
|
|
|
sfc->targets = talloc_size(vc, sfc->targets_size
|
|
|
|
* sizeof(*sfc->targets));
|
2012-09-28 21:19:36 +02:00
|
|
|
}
|
2012-08-26 18:00:26 +02:00
|
|
|
|
2012-09-28 21:19:36 +02:00
|
|
|
for (int i = 0 ;i < sfc->packer->count; i++) {
|
|
|
|
struct sub_bitmap *b = &imgs->parts[i];
|
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-19 19:25:18 +02:00
|
|
|
struct osd_target *target = sfc->targets + sfc->render_count;
|
2012-09-28 21:19:36 +02:00
|
|
|
int x = sfc->packer->result[i].x;
|
|
|
|
int y = sfc->packer->result[i].y;
|
|
|
|
target->source = (VdpRect){x, y, x + b->w, y + b->h};
|
|
|
|
target->dest = (VdpRect){b->x, b->y, b->x + b->dw, b->y + b->dh};
|
|
|
|
target->color = (VdpColor){1, 1, 1, 1};
|
|
|
|
if (imgs->format == SUBBITMAP_LIBASS) {
|
|
|
|
uint32_t color = b->libass.color;
|
|
|
|
target->color.alpha = 1.0 - ((color >> 0) & 0xff) / 255.0;
|
|
|
|
target->color.blue = ((color >> 8) & 0xff) / 255.0;
|
|
|
|
target->color.green = ((color >> 16) & 0xff) / 255.0;
|
|
|
|
target->color.red = ((color >> 24) & 0xff) / 255.0;
|
2012-08-31 14:42:30 +02:00
|
|
|
}
|
2012-09-28 21:19:36 +02:00
|
|
|
if (need_upload) {
|
|
|
|
vdp_st = vdp->
|
|
|
|
bitmap_surface_put_bits_native(sfc->surface,
|
|
|
|
&(const void *){b->bitmap},
|
|
|
|
&(uint32_t){b->stride},
|
|
|
|
&target->source);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "OSD: putbits failed");
|
2012-08-26 18:00:26 +02:00
|
|
|
}
|
2012-09-28 21:49:09 +02:00
|
|
|
sfc->render_count++;
|
2012-08-26 18:00:26 +02:00
|
|
|
}
|
2012-09-28 21:19:36 +02:00
|
|
|
|
2015-03-18 12:33:14 +01:00
|
|
|
sfc->change_id = imgs->change_id;
|
2012-08-26 18:00:26 +02:00
|
|
|
}
|
2011-10-27 12:07:10 +02:00
|
|
|
|
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-19 19:25:18 +02:00
|
|
|
static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs)
|
2012-08-26 18:00:26 +02:00
|
|
|
{
|
|
|
|
struct vo *vo = ctx;
|
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-19 19:25:18 +02:00
|
|
|
generate_osd_part(vo, imgs);
|
|
|
|
draw_osd_part(vo, imgs->render_index);
|
2012-08-26 18:00:26 +02:00
|
|
|
}
|
|
|
|
|
2014-06-15 20:46:57 +02:00
|
|
|
static void draw_osd(struct vo *vo)
|
2012-08-26 18:00:26 +02:00
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
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-19 19:25:18 +02:00
|
|
|
if (!status_ok(vo))
|
2012-08-26 18:00:26 +02:00
|
|
|
return;
|
|
|
|
|
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-19 19:25:18 +02:00
|
|
|
static const bool formats[SUBBITMAP_COUNT] = {
|
|
|
|
[SUBBITMAP_LIBASS] = true,
|
|
|
|
[SUBBITMAP_RGBA] = true,
|
2012-08-26 18:00:26 +02:00
|
|
|
};
|
|
|
|
|
2014-06-15 20:46:57 +02:00
|
|
|
double pts = vc->current_image ? vc->current_image->pts : 0;
|
|
|
|
osd_draw(vo->osd, vc->osd_rect, pts, 0, formats, draw_osd_cb, vo);
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2010-05-14 04:18:38 +02:00
|
|
|
static int update_presentation_queue_status(struct vo *vo)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2009-02-16 21:58:13 +01:00
|
|
|
VdpStatus vdp_st;
|
2009-05-09 17:08:30 +02:00
|
|
|
|
2010-05-14 04:18:38 +02:00
|
|
|
while (vc->query_surface_num != vc->surface_num) {
|
|
|
|
VdpTime vtime;
|
|
|
|
VdpPresentationQueueStatus status;
|
|
|
|
VdpOutputSurface surface = vc->output_surfaces[vc->query_surface_num];
|
|
|
|
vdp_st = vdp->presentation_queue_query_surface_status(vc->flip_queue,
|
|
|
|
surface,
|
|
|
|
&status, &vtime);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error calling "
|
2010-05-14 04:18:38 +02:00
|
|
|
"presentation_queue_query_surface_status");
|
2014-04-03 19:41:09 +02:00
|
|
|
if (mp_msg_test(vo->log, MSGL_TRACE)) {
|
|
|
|
VdpTime current;
|
|
|
|
vdp_st = vdp->presentation_queue_get_time(vc->flip_queue, ¤t);
|
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling "
|
|
|
|
"vdp_presentation_queue_get_time");
|
|
|
|
MP_TRACE(vo, "Vdpau time: %"PRIu64"\n", (uint64_t)current);
|
|
|
|
MP_TRACE(vo, "Surface %d status: %d time: %"PRIu64"\n",
|
|
|
|
(int)surface, (int)status, (uint64_t)vtime);
|
|
|
|
}
|
2010-05-14 04:18:38 +02:00
|
|
|
if (status == VDP_PRESENTATION_QUEUE_STATUS_QUEUED)
|
|
|
|
break;
|
|
|
|
if (vc->vsync_interval > 1) {
|
|
|
|
uint64_t qtime = vc->queue_time[vc->query_surface_num];
|
2013-12-22 15:48:38 +01:00
|
|
|
int diff = ((int64_t)vtime - (int64_t)qtime) / 1e6;
|
|
|
|
MP_TRACE(vo, "Queue time difference: %d ms\n", diff);
|
2010-05-14 04:18:38 +02:00
|
|
|
if (vtime < qtime + vc->vsync_interval / 2)
|
2013-12-22 15:48:38 +01:00
|
|
|
MP_VERBOSE(vo, "Frame shown too early (%d ms)\n", diff);
|
2010-05-14 04:18:38 +02:00
|
|
|
if (vtime > qtime + vc->vsync_interval)
|
2013-12-22 15:48:38 +01:00
|
|
|
MP_VERBOSE(vo, "Frame shown late (%d ms)\n", diff);
|
2010-05-14 04:18:38 +02:00
|
|
|
}
|
|
|
|
vc->query_surface_num = WRAP_ADD(vc->query_surface_num, 1,
|
|
|
|
vc->num_output_surfaces);
|
|
|
|
vc->recent_vsync_time = vtime;
|
|
|
|
}
|
|
|
|
int num_queued = WRAP_ADD(vc->surface_num, -vc->query_surface_num,
|
|
|
|
vc->num_output_surfaces);
|
2013-08-23 23:30:09 +02:00
|
|
|
MP_DBG(vo, "Queued surface count (before add): %d\n", num_queued);
|
2010-05-14 04:18:38 +02:00
|
|
|
return num_queued;
|
2009-11-15 03:39:22 +01:00
|
|
|
}
|
|
|
|
|
2014-04-08 19:02:57 +02:00
|
|
|
// Return the timestamp of the vsync that must have happened before ts.
|
|
|
|
static inline uint64_t prev_vsync(struct vdpctx *vc, uint64_t ts)
|
2009-11-15 03:39:22 +01:00
|
|
|
{
|
2014-04-08 19:02:57 +02:00
|
|
|
int64_t diff = (int64_t)(ts - vc->recent_vsync_time);
|
|
|
|
int64_t offset = diff % vc->vsync_interval;
|
|
|
|
if (offset < 0)
|
|
|
|
offset += vc->vsync_interval;
|
2009-11-15 03:39:22 +01:00
|
|
|
return ts - offset;
|
|
|
|
}
|
|
|
|
|
2014-09-20 15:14:43 +02:00
|
|
|
static int flip_page_timed(struct vo *vo, int64_t pts_us, int duration)
|
2009-11-15 03:39:22 +01:00
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
|
|
|
VdpStatus vdp_st;
|
|
|
|
|
2014-09-20 15:14:43 +02:00
|
|
|
vc->dropped_frame = true; // changed at end if false
|
|
|
|
|
2014-05-09 21:49:32 +02:00
|
|
|
if (!check_preemption(vo))
|
2014-09-20 15:14:43 +02:00
|
|
|
return 0;
|
2009-09-07 01:02:24 +02:00
|
|
|
|
2014-08-17 02:50:59 +02:00
|
|
|
vc->vsync_interval = 1;
|
|
|
|
if (vc->user_fps > 0) {
|
|
|
|
vc->vsync_interval = 1e9 / vc->user_fps;
|
|
|
|
} else if (vc->user_fps == 0) {
|
|
|
|
vc->vsync_interval = vo_get_vsync_interval(vo) * 1000;
|
|
|
|
}
|
|
|
|
|
2009-11-15 03:39:22 +01:00
|
|
|
if (duration > INT_MAX / 1000)
|
|
|
|
duration = -1;
|
|
|
|
else
|
|
|
|
duration *= 1000;
|
|
|
|
|
2012-07-27 02:40:38 +02:00
|
|
|
if (vc->vsync_interval == 1)
|
2009-11-15 03:39:22 +01:00
|
|
|
duration = -1; // Make sure drop logic is disabled
|
|
|
|
|
vo_vdpau: simplify time management and make it more robust
vo_vdpau used a somewhat complicated and fragile mechanism to convert
the vdpau time to internal mpv time. This was fragile as in it couldn't
deal well with Mesa's (apparently) random timestamps, which can change
the base offset in multiple situations. It can happen when moving the
mpv window to a different screen, and somehow it also happens when
pausing the player.
It seems this mechanism to synchronize the vdpau time is not actually
needed. There are only 2 places where sync_vdptime() is used (i.e.
returning the current vdpau time interpolated by system time).
The first call is for determining the PTS used to queue a frame. This
also uses convert_to_vdptime(). It's easily replaced by querying the
time directly, and adding the wait time to it (rel_pts_ns in the patch).
The second call is pretty odd: it updates the vdpau time a second time
in the same function. From what I can see, this can matter only if
update_presentation_queue_status() is very slow. I'm not sure what to
make out of this, because the call merely queries the presentation
queue. Just assume it isn't slow, and that we don't have to update the
time.
Another potential issue with this is that we call VdpPresentationQueueGetTime()
every frame now, instead of every 5 seconds and interpolating the other
calls via system time. More over, this is per video frame (which can be
portantially dropped, and not per actually displayed frame. Assume this
doesn't matter.
This simplifies the code, and should make it more robust on Mesa. But
note that what Mesa does is obviously insane - this is one situation
where you really need a stable time source. There are still plenty of
race condition windows where things can go wrong, although this commit
should drastically reduce the possibility of this.
In my tests, everything worked well. But I have no access to a Mesa
system with vdpau, so it needs testing by others.
See github issues #520, #694, #695.
2014-04-07 18:33:25 +02:00
|
|
|
VdpTime vdp_time = 0;
|
|
|
|
vdp_st = vdp->presentation_queue_get_time(vc->flip_queue, &vdp_time);
|
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_presentation_queue_get_time");
|
|
|
|
|
|
|
|
int64_t rel_pts_ns = (pts_us - mp_time_us()) * 1000;
|
|
|
|
if (!pts_us || rel_pts_ns < 0)
|
|
|
|
rel_pts_ns = 0;
|
2014-02-02 12:07:08 +01:00
|
|
|
|
vo_vdpau: simplify time management and make it more robust
vo_vdpau used a somewhat complicated and fragile mechanism to convert
the vdpau time to internal mpv time. This was fragile as in it couldn't
deal well with Mesa's (apparently) random timestamps, which can change
the base offset in multiple situations. It can happen when moving the
mpv window to a different screen, and somehow it also happens when
pausing the player.
It seems this mechanism to synchronize the vdpau time is not actually
needed. There are only 2 places where sync_vdptime() is used (i.e.
returning the current vdpau time interpolated by system time).
The first call is for determining the PTS used to queue a frame. This
also uses convert_to_vdptime(). It's easily replaced by querying the
time directly, and adding the wait time to it (rel_pts_ns in the patch).
The second call is pretty odd: it updates the vdpau time a second time
in the same function. From what I can see, this can matter only if
update_presentation_queue_status() is very slow. I'm not sure what to
make out of this, because the call merely queries the presentation
queue. Just assume it isn't slow, and that we don't have to update the
time.
Another potential issue with this is that we call VdpPresentationQueueGetTime()
every frame now, instead of every 5 seconds and interpolating the other
calls via system time. More over, this is per video frame (which can be
portantially dropped, and not per actually displayed frame. Assume this
doesn't matter.
This simplifies the code, and should make it more robust on Mesa. But
note that what Mesa does is obviously insane - this is one situation
where you really need a stable time source. There are still plenty of
race condition windows where things can go wrong, although this commit
should drastically reduce the possibility of this.
In my tests, everything worked well. But I have no access to a Mesa
system with vdpau, so it needs testing by others.
See github issues #520, #694, #695.
2014-04-07 18:33:25 +02:00
|
|
|
uint64_t now = vdp_time;
|
|
|
|
uint64_t pts = now + rel_pts_ns;
|
2009-11-15 03:39:22 +01:00
|
|
|
uint64_t ideal_pts = pts;
|
|
|
|
uint64_t npts = duration >= 0 ? pts + duration : UINT64_MAX;
|
|
|
|
|
2014-04-08 20:16:53 +02:00
|
|
|
/* This should normally never happen.
|
|
|
|
* - The last queued frame can't have a PTS that goes more than 50ms in the
|
video: move display and timing to a separate thread
The VO is run inside its own thread. It also does most of video timing.
The playloop hands the image data and a realtime timestamp to the VO,
and the VO does the rest.
In particular, this allows the playloop to do other things, instead of
blocking for video redraw. But if anything accesses the VO during video
timing, it will block.
This also fixes vo_sdl.c event handling; but that is only a side-effect,
since reimplementing the broken way would require more effort.
Also drop --softsleep. In theory, this option helps if the kernel's
sleeping mechanism is too inaccurate for video timing. In practice, I
haven't ever encountered a situation where it helps, and it just burns
CPU cycles. On the other hand it's probably actively harmful, because
it prevents the libavcodec decoder threads from doing real work.
Side note:
Originally, I intended that multiple frames can be queued to the VO. But
this is not done, due to problems with OSD and other certain features.
OSD in particular is simply designed in a way that it can be neither
timed nor copied, so you do have to render it into the video frame
before you can draw the next frame. (Subtitles have no such restriction.
sd_lavc was even updated to fix this.) It seems the right solution to
queuing multiple VO frames is rendering on VO-backed framebuffers, like
vo_vdpau.c does. This requires VO driver support, and is out of scope
of this commit.
As consequence, the VO has a queue size of 1. The existing video queue
is just needed to compute frame duration, and will be moved out in the
next commit.
2014-08-12 23:02:08 +02:00
|
|
|
* future. This is guaranteed by vo.c, which currently actually queues
|
2014-12-09 17:46:35 +01:00
|
|
|
* ahead by roughly the flip queue offset. Just to be sure
|
2014-04-08 20:16:53 +02:00
|
|
|
* give some additional room by doubling the time.
|
|
|
|
* - The last vsync can never be in the future.
|
|
|
|
*/
|
2014-12-09 17:46:35 +01:00
|
|
|
int64_t max_pts_ahead = vc->flip_offset_us * 1000 * 2;
|
2014-04-08 20:16:53 +02:00
|
|
|
if (vc->last_queue_time > now + max_pts_ahead ||
|
|
|
|
vc->recent_vsync_time > now)
|
|
|
|
{
|
|
|
|
vc->last_queue_time = 0;
|
|
|
|
vc->recent_vsync_time = 0;
|
|
|
|
MP_WARN(vo, "Inconsistent timing detected.\n");
|
|
|
|
}
|
|
|
|
|
2014-04-08 19:02:57 +02:00
|
|
|
#define PREV_VSYNC(ts) prev_vsync(vc, ts)
|
2009-11-15 03:39:22 +01:00
|
|
|
|
|
|
|
/* We hope to be here at least one vsync before the frame should be shown.
|
|
|
|
* If we are running late then don't drop the frame unless there is
|
|
|
|
* already one queued for the next vsync; even if we _hope_ to show the
|
|
|
|
* next frame soon enough to mean this one should be dropped we might
|
|
|
|
* not make the target time in reality. Without this check we could drop
|
|
|
|
* every frame, freezing the display completely if video lags behind.
|
|
|
|
*/
|
2014-09-20 14:54:19 +02:00
|
|
|
if (now > PREV_VSYNC(FFMAX(pts, vc->last_queue_time + vc->vsync_interval)))
|
2009-11-15 03:39:22 +01:00
|
|
|
npts = UINT64_MAX;
|
|
|
|
|
|
|
|
/* Allow flipping a frame at a vsync if its presentation time is a
|
|
|
|
* bit after that vsync and the change makes the flip time delta
|
|
|
|
* from previous frame better match the target timestamp delta.
|
|
|
|
* This avoids instability with frame timestamps falling near vsyncs.
|
|
|
|
* For example if the frame timestamps were (with vsyncs at
|
|
|
|
* integer values) 0.01, 1.99, 4.01, 5.99, 8.01, ... then
|
|
|
|
* straightforward timing at next vsync would flip the frames at
|
|
|
|
* 1, 2, 5, 6, 9; this changes it to 1, 2, 4, 6, 8 and so on with
|
|
|
|
* regular 2-vsync intervals.
|
|
|
|
*
|
|
|
|
* Also allow moving the frame forward if it looks like we dropped
|
|
|
|
* the previous frame incorrectly (now that we know better after
|
|
|
|
* having final exact timestamp information for this frame) and
|
|
|
|
* there would unnecessarily be a vsync without a frame change.
|
|
|
|
*/
|
|
|
|
uint64_t vsync = PREV_VSYNC(pts);
|
2014-09-20 14:54:19 +02:00
|
|
|
if (pts < vsync + vc->vsync_interval / 4
|
2014-04-08 19:02:57 +02:00
|
|
|
&& (vsync - PREV_VSYNC(vc->last_queue_time)
|
2014-09-20 14:54:19 +02:00
|
|
|
> pts - vc->last_ideal_time + vc->vsync_interval / 2
|
2015-03-02 19:09:25 +01:00
|
|
|
|| (vc->dropped_frame && vsync > vc->dropped_time)))
|
2014-09-20 14:54:19 +02:00
|
|
|
pts -= vc->vsync_interval / 2;
|
2009-11-15 03:39:22 +01:00
|
|
|
|
|
|
|
vc->dropped_time = ideal_pts;
|
|
|
|
|
2014-09-20 14:54:19 +02:00
|
|
|
pts = FFMAX(pts, vc->last_queue_time + vc->vsync_interval);
|
2009-11-15 03:39:22 +01:00
|
|
|
pts = FFMAX(pts, now);
|
2014-09-20 14:54:19 +02:00
|
|
|
if (npts < PREV_VSYNC(pts) + vc->vsync_interval)
|
2014-09-20 15:14:43 +02:00
|
|
|
return 0;
|
2009-11-15 03:39:22 +01:00
|
|
|
|
2010-05-14 04:18:38 +02:00
|
|
|
int num_flips = update_presentation_queue_status(vo);
|
|
|
|
vsync = vc->recent_vsync_time + num_flips * vc->vsync_interval;
|
2009-11-15 03:39:22 +01:00
|
|
|
pts = FFMAX(pts, now);
|
2014-09-20 14:54:19 +02:00
|
|
|
pts = FFMAX(pts, vsync + (vc->vsync_interval >> 2));
|
2009-11-15 03:39:22 +01:00
|
|
|
vsync = PREV_VSYNC(pts);
|
2014-09-20 14:54:19 +02:00
|
|
|
if (npts < vsync + vc->vsync_interval)
|
2014-09-20 15:14:43 +02:00
|
|
|
return 0;
|
2014-09-20 14:54:19 +02:00
|
|
|
pts = vsync + (vc->vsync_interval >> 2);
|
2014-04-03 19:41:09 +02:00
|
|
|
VdpOutputSurface frame = vc->output_surfaces[vc->surface_num];
|
|
|
|
vdp_st = vdp->presentation_queue_display(vc->flip_queue, frame,
|
|
|
|
vo->dwidth, vo->dheight, pts);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_presentation_queue_display");
|
2009-02-16 21:58:13 +01:00
|
|
|
|
vo_vdpau: simplify time management and make it more robust
vo_vdpau used a somewhat complicated and fragile mechanism to convert
the vdpau time to internal mpv time. This was fragile as in it couldn't
deal well with Mesa's (apparently) random timestamps, which can change
the base offset in multiple situations. It can happen when moving the
mpv window to a different screen, and somehow it also happens when
pausing the player.
It seems this mechanism to synchronize the vdpau time is not actually
needed. There are only 2 places where sync_vdptime() is used (i.e.
returning the current vdpau time interpolated by system time).
The first call is for determining the PTS used to queue a frame. This
also uses convert_to_vdptime(). It's easily replaced by querying the
time directly, and adding the wait time to it (rel_pts_ns in the patch).
The second call is pretty odd: it updates the vdpau time a second time
in the same function. From what I can see, this can matter only if
update_presentation_queue_status() is very slow. I'm not sure what to
make out of this, because the call merely queries the presentation
queue. Just assume it isn't slow, and that we don't have to update the
time.
Another potential issue with this is that we call VdpPresentationQueueGetTime()
every frame now, instead of every 5 seconds and interpolating the other
calls via system time. More over, this is per video frame (which can be
portantially dropped, and not per actually displayed frame. Assume this
doesn't matter.
This simplifies the code, and should make it more robust on Mesa. But
note that what Mesa does is obviously insane - this is one situation
where you really need a stable time source. There are still plenty of
race condition windows where things can go wrong, although this commit
should drastically reduce the possibility of this.
In my tests, everything worked well. But I have no access to a Mesa
system with vdpau, so it needs testing by others.
See github issues #520, #694, #695.
2014-04-07 18:33:25 +02:00
|
|
|
MP_TRACE(vo, "Queue new surface %d: Vdpau time: %"PRIu64" "
|
|
|
|
"pts: %"PRIu64"\n", (int)frame, now, pts);
|
2014-04-03 19:41:09 +02:00
|
|
|
|
2009-11-15 03:39:22 +01:00
|
|
|
vc->last_queue_time = pts;
|
2010-05-14 04:18:38 +02:00
|
|
|
vc->queue_time[vc->surface_num] = pts;
|
2009-11-15 03:39:22 +01:00
|
|
|
vc->last_ideal_time = ideal_pts;
|
|
|
|
vc->dropped_frame = false;
|
2010-05-14 04:18:38 +02:00
|
|
|
vc->surface_num = WRAP_ADD(vc->surface_num, 1, vc->num_output_surfaces);
|
2014-09-20 15:14:43 +02:00
|
|
|
return 1;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2014-04-29 15:19:03 +02:00
|
|
|
static void draw_image(struct vo *vo, struct mp_image *mpi)
|
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
2014-05-09 21:49:32 +02:00
|
|
|
check_preemption(vo);
|
2014-05-04 10:50:32 +02:00
|
|
|
|
2014-07-29 00:21:02 +02:00
|
|
|
struct mp_image *vdp_mpi = mp_vdpau_upload_video_surface(vc->mpvdp, mpi);
|
2015-02-07 21:14:12 +01:00
|
|
|
if (!vdp_mpi)
|
2014-07-29 00:21:02 +02:00
|
|
|
MP_ERR(vo, "Could not upload image.\n");
|
|
|
|
talloc_free(mpi);
|
2014-05-04 10:50:32 +02:00
|
|
|
|
2014-07-29 00:21:02 +02:00
|
|
|
talloc_free(vc->current_image);
|
|
|
|
vc->current_image = vdp_mpi;
|
2009-09-18 15:27:55 +02:00
|
|
|
|
2014-07-29 00:21:02 +02:00
|
|
|
if (status_ok(vo))
|
|
|
|
video_to_output_surface(vo);
|
2009-09-18 15:27:55 +02:00
|
|
|
}
|
|
|
|
|
2011-10-06 20:46:01 +02:00
|
|
|
// warning: the size and pixel format of surface must match that of the
|
|
|
|
// surfaces in vc->output_surfaces
|
2013-12-21 18:05:23 +01:00
|
|
|
static struct mp_image *read_output_surface(struct vo *vo,
|
2012-10-21 00:48:01 +02:00
|
|
|
VdpOutputSurface surface,
|
|
|
|
int width, int height)
|
2011-10-06 20:46:01 +02:00
|
|
|
{
|
2013-12-21 18:05:23 +01:00
|
|
|
struct vdpctx *vc = vo->priv;
|
2011-10-06 20:46:01 +02:00
|
|
|
VdpStatus vdp_st;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
2014-03-29 00:25:08 +01:00
|
|
|
if (!vo->params)
|
|
|
|
return NULL;
|
|
|
|
|
2015-04-07 11:43:03 +02:00
|
|
|
struct mp_image *image = mp_image_alloc(IMGFMT_BGR0, width, height);
|
video: introduce failure path for image allocations
Until now, failure to allocate image data resulted in a crash (i.e.
abort() was called). This was intentional, because it's pretty silly to
degrade playback, and in almost all situations, the OOM will probably
kill you anyway. (And then there's the standard Linux overcommit
behavior, which also will kill you at some point.)
But I changed my opinion, so here we go. This change does not affect
_all_ memory allocations, just image data. Now in most failure cases,
the output will just be skipped. For video filters, this coincidentally
means that failure is treated as EOF (because the playback core assumes
EOF if nothing comes out of the video filter chain). In other
situations, output might be in some way degraded, like skipping frames,
not scaling OSD, and such.
Functions whose return values changed semantics:
mp_image_alloc
mp_image_new_copy
mp_image_new_ref
mp_image_make_writeable
mp_image_setrefp
mp_image_to_av_frame_and_unref
mp_image_from_av_frame
mp_image_new_external_ref
mp_image_new_custom_ref
mp_image_pool_make_writeable
mp_image_pool_get
mp_image_pool_new_copy
mp_vdpau_mixed_frame_create
vf_alloc_out_image
vf_make_out_image_writeable
glGetWindowScreenshot
2014-06-17 22:43:43 +02:00
|
|
|
if (!image)
|
|
|
|
return NULL;
|
|
|
|
|
2014-04-20 21:27:45 +02:00
|
|
|
image->params.colorspace = MP_CSP_RGB;
|
|
|
|
// hardcoded with conv. matrix
|
|
|
|
image->params.colorlevels = vo->params->outputlevels;
|
2011-10-06 20:46:01 +02:00
|
|
|
|
|
|
|
void *dst_planes[] = { image->planes[0] };
|
|
|
|
uint32_t dst_pitches[] = { image->stride[0] };
|
|
|
|
vdp_st = vdp->output_surface_get_bits_native(surface, NULL, dst_planes,
|
|
|
|
dst_pitches);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_output_surface_get_bits_native");
|
2011-10-06 20:46:01 +02:00
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct mp_image *get_window_screenshot(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
int last_surface = WRAP_ADD(vc->surface_num, -1, vc->num_output_surfaces);
|
|
|
|
VdpOutputSurface screen = vc->output_surfaces[last_surface];
|
2013-12-21 18:05:23 +01:00
|
|
|
struct mp_image *image = read_output_surface(vo, screen,
|
2012-10-21 00:48:01 +02:00
|
|
|
vc->output_surface_width,
|
|
|
|
vc->output_surface_height);
|
2012-11-10 02:02:24 +01:00
|
|
|
mp_image_set_size(image, vo->dwidth, vo->dheight);
|
2011-10-06 20:46:01 +02:00
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
2015-01-21 22:08:24 +01:00
|
|
|
static int query_format(struct vo *vo, int format)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2013-08-18 05:12:21 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
|
|
|
if (mp_vdpau_get_format(format, NULL, NULL))
|
2015-01-21 22:08:24 +01:00
|
|
|
return 1;
|
2014-05-22 20:55:17 +02:00
|
|
|
if (!vc->force_yuv && mp_vdpau_get_rgb_format(format, NULL))
|
2015-01-21 22:08:24 +01:00
|
|
|
return 1;
|
2013-08-18 05:12:21 +02:00
|
|
|
return 0;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2009-05-06 20:04:37 +02:00
|
|
|
static void destroy_vdpau_objects(struct vo *vo)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
struct vdp_functions *vdp = vc->vdp;
|
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
VdpStatus vdp_st;
|
|
|
|
|
2009-05-06 20:04:37 +02:00
|
|
|
free_video_specific(vo);
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2009-05-08 19:57:22 +02:00
|
|
|
if (vc->flip_queue != VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->presentation_queue_destroy(vc->flip_queue);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_presentation_queue_destroy");
|
2009-05-08 19:57:22 +02:00
|
|
|
}
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2009-05-08 19:57:22 +02:00
|
|
|
if (vc->flip_target != VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->presentation_queue_target_destroy(vc->flip_target);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling "
|
2009-05-09 17:08:30 +02:00
|
|
|
"vdp_presentation_queue_target_destroy");
|
2009-05-08 19:57:22 +02:00
|
|
|
}
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2013-07-23 00:45:23 +02:00
|
|
|
for (int i = 0; i < vc->num_output_surfaces; i++) {
|
2009-05-08 19:57:22 +02:00
|
|
|
if (vc->output_surfaces[i] == VDP_INVALID_HANDLE)
|
|
|
|
continue;
|
2009-05-06 22:42:24 +02:00
|
|
|
vdp_st = vdp->output_surface_destroy(vc->output_surfaces[i]);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_output_surface_destroy");
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2012-09-28 21:49:09 +02:00
|
|
|
for (int i = 0; i < MAX_OSD_PARTS; i++) {
|
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-19 19:25:18 +02:00
|
|
|
struct osd_bitmap_surface *sfc = &vc->osd_surfaces[i];
|
2012-09-28 21:49:09 +02:00
|
|
|
if (sfc->surface != VDP_INVALID_HANDLE) {
|
|
|
|
vdp_st = vdp->bitmap_surface_destroy(sfc->surface);
|
2013-12-21 18:05:23 +01:00
|
|
|
CHECK_VDP_WARNING(vo, "Error when calling vdp_bitmap_surface_destroy");
|
2012-09-28 21:49:09 +02:00
|
|
|
}
|
2009-02-23 10:21:57 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 22:06:32 +01:00
|
|
|
mp_vdpau_destroy(vc->mpvdp);
|
|
|
|
vc->mpvdp = NULL;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2009-05-04 02:09:50 +02:00
|
|
|
static void uninit(struct vo *vo)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2014-04-29 15:11:44 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
/* Destroy all vdpau objects */
|
2014-04-29 15:11:44 +02:00
|
|
|
mp_vdpau_mixer_destroy(vc->video_mixer);
|
2009-05-06 20:04:37 +02:00
|
|
|
destroy_vdpau_objects(vo);
|
2009-02-23 10:21:57 +01:00
|
|
|
|
2009-05-04 02:09:50 +02:00
|
|
|
vo_x11_uninit(vo);
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2013-07-22 22:52:42 +02:00
|
|
|
static int preinit(struct vo *vo)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2012-06-25 22:12:03 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
2009-02-16 21:58:13 +01:00
|
|
|
|
2013-11-05 22:06:32 +01:00
|
|
|
if (!vo_x11_init(vo))
|
|
|
|
return -1;
|
|
|
|
|
2014-12-03 21:13:59 +01:00
|
|
|
vc->mpvdp = mp_vdpau_create_device_x11(vo->log, vo->x11->display);
|
2013-11-05 22:06:32 +01:00
|
|
|
if (!vc->mpvdp) {
|
|
|
|
vo_x11_uninit(vo);
|
|
|
|
return -1;
|
|
|
|
}
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
|
2015-01-22 15:32:23 +01:00
|
|
|
vc->hwdec_info.hwctx = &vc->mpvdp->hwctx;
|
2014-08-11 23:08:35 +02:00
|
|
|
|
2014-04-29 15:11:44 +02:00
|
|
|
vc->video_mixer = mp_vdpau_mixer_create(vc->mpvdp, vo->log);
|
|
|
|
|
2014-05-28 01:37:53 +02:00
|
|
|
if (mp_vdpau_guess_if_emulated(vc->mpvdp)) {
|
|
|
|
MP_WARN(vo, "VDPAU is most likely emulated via VA-API.\n"
|
|
|
|
"This is inefficient. Use --vo=opengl instead.\n");
|
|
|
|
}
|
|
|
|
|
2009-05-08 20:48:01 +02:00
|
|
|
// Mark everything as invalid first so uninit() can tell what has been
|
|
|
|
// allocated
|
2009-09-07 01:02:24 +02:00
|
|
|
mark_vdpau_objects_uninitialized(vo);
|
2009-05-08 20:48:01 +02:00
|
|
|
|
2014-05-09 21:49:32 +02:00
|
|
|
mp_vdpau_handle_preemption(vc->mpvdp, &vc->preemption_counter);
|
|
|
|
|
2013-11-05 22:06:32 +01:00
|
|
|
vc->vdp_device = vc->mpvdp->vdp_device;
|
2014-03-19 19:57:08 +01:00
|
|
|
vc->vdp = &vc->mpvdp->vdp;
|
2013-11-05 22:06:32 +01:00
|
|
|
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 23:50:21 +02:00
|
|
|
vc->video_eq.capabilities = MP_CSP_EQ_CAPS_COLORMATRIX;
|
2012-06-25 22:12:03 +02:00
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-06 20:04:37 +02:00
|
|
|
static int get_equalizer(struct vo *vo, const char *name, int *value)
|
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
2013-08-18 05:12:21 +02:00
|
|
|
|
|
|
|
if (vc->rgb_mode)
|
|
|
|
return false;
|
|
|
|
|
2014-04-29 15:11:44 +02:00
|
|
|
return mp_csp_equalizer_get(&vc->video_mixer->video_eq, name, value) >= 0 ?
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 23:50:21 +02:00
|
|
|
VO_TRUE : VO_NOTIMPL;
|
2009-02-28 14:20:01 +01:00
|
|
|
}
|
|
|
|
|
2009-05-06 20:04:37 +02:00
|
|
|
static int set_equalizer(struct vo *vo, const char *name, int value)
|
|
|
|
{
|
|
|
|
struct vdpctx *vc = vo->priv;
|
2009-02-28 14:20:01 +01:00
|
|
|
|
2013-08-18 05:12:21 +02:00
|
|
|
if (vc->rgb_mode)
|
|
|
|
return false;
|
|
|
|
|
2014-04-29 15:11:44 +02:00
|
|
|
if (mp_csp_equalizer_set(&vc->video_mixer->video_eq, name, value) < 0)
|
2009-02-28 14:20:01 +01:00
|
|
|
return VO_NOTIMPL;
|
2014-04-29 15:11:44 +02:00
|
|
|
vc->video_mixer->initialized = false;
|
2009-11-15 14:21:40 +01:00
|
|
|
return true;
|
2009-02-28 14:20:01 +01:00
|
|
|
}
|
|
|
|
|
2011-08-11 20:13:34 +02:00
|
|
|
static void checked_resize(struct vo *vo)
|
|
|
|
{
|
|
|
|
if (!status_ok(vo))
|
|
|
|
return;
|
|
|
|
resize(vo);
|
|
|
|
}
|
|
|
|
|
2009-05-04 02:09:50 +02:00
|
|
|
static int control(struct vo *vo, uint32_t request, void *data)
|
2009-02-16 21:58:13 +01:00
|
|
|
{
|
2009-05-06 20:04:37 +02:00
|
|
|
struct vdpctx *vc = vo->priv;
|
|
|
|
|
2014-05-09 21:49:32 +02:00
|
|
|
check_preemption(vo);
|
2009-09-07 01:02:24 +02:00
|
|
|
|
2009-02-16 21:58:13 +01:00
|
|
|
switch (request) {
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
case VOCTRL_GET_HWDEC_INFO: {
|
2014-08-11 23:08:35 +02:00
|
|
|
struct mp_hwdec_info **arg = data;
|
|
|
|
*arg = &vc->hwdec_info;
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 14:25:04 +01:00
|
|
|
return true;
|
vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").
Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)
Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.
Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)
Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.
Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.
Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 01:49:45 +02:00
|
|
|
}
|
2009-09-05 05:20:03 +02:00
|
|
|
case VOCTRL_GET_PANSCAN:
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_SET_PANSCAN:
|
2011-08-11 20:13:34 +02:00
|
|
|
checked_resize(vo);
|
2009-09-05 05:20:03 +02:00
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_SET_EQUALIZER: {
|
2011-12-05 05:36:20 +01:00
|
|
|
vo->want_redraw = true;
|
2009-09-05 05:20:03 +02:00
|
|
|
struct voctrl_set_equalizer_args *args = data;
|
|
|
|
return set_equalizer(vo, args->name, args->value);
|
|
|
|
}
|
|
|
|
case VOCTRL_GET_EQUALIZER: {
|
|
|
|
struct voctrl_get_equalizer_args *args = data;
|
|
|
|
return get_equalizer(vo, args->name, args->valueptr);
|
|
|
|
}
|
2011-12-05 04:24:18 +01:00
|
|
|
case VOCTRL_REDRAW_FRAME:
|
2011-12-20 02:47:16 +01:00
|
|
|
if (status_ok(vo))
|
|
|
|
video_to_output_surface(vo);
|
2009-09-05 05:33:33 +02:00
|
|
|
return true;
|
2009-09-18 15:27:55 +02:00
|
|
|
case VOCTRL_RESET:
|
2013-10-01 23:45:30 +02:00
|
|
|
forget_frames(vo, true);
|
2009-09-18 15:27:55 +02:00
|
|
|
return true;
|
2015-01-23 22:06:12 +01:00
|
|
|
case VOCTRL_SCREENSHOT_WIN:
|
2011-12-20 02:47:16 +01:00
|
|
|
if (!status_ok(vo))
|
|
|
|
return false;
|
2015-01-24 22:56:02 +01:00
|
|
|
*(struct mp_image **)data = get_window_screenshot(vo);
|
2011-10-06 20:46:01 +02:00
|
|
|
return true;
|
2014-04-29 15:18:19 +02:00
|
|
|
case VOCTRL_GET_PREF_DEINT:
|
|
|
|
*(int *)data = vc->deint;
|
|
|
|
return true;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
2013-05-16 14:02:28 +02:00
|
|
|
|
|
|
|
int events = 0;
|
|
|
|
int r = vo_x11_control(vo, &events, request, data);
|
|
|
|
|
|
|
|
if (events & VO_EVENT_RESIZE) {
|
|
|
|
checked_resize(vo);
|
|
|
|
} else if (events & VO_EVENT_EXPOSE) {
|
|
|
|
vo->want_redraw = true;
|
|
|
|
}
|
2014-11-02 20:26:51 +01:00
|
|
|
vo_event(vo, events);
|
2013-05-16 14:02:28 +02:00
|
|
|
|
|
|
|
return r;
|
2009-02-16 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2012-06-25 22:12:03 +02:00
|
|
|
#define OPT_BASE_STRUCT struct vdpctx
|
|
|
|
|
2009-05-04 02:09:50 +02:00
|
|
|
const struct vo_driver video_out_vdpau = {
|
2013-10-23 19:06:14 +02:00
|
|
|
.description = "VDPAU with X11",
|
|
|
|
.name = "vdpau",
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 23:33:33 +02:00
|
|
|
.caps = VO_CAP_FRAMEDROP,
|
2009-05-04 02:09:50 +02:00
|
|
|
.preinit = preinit,
|
2012-11-04 16:24:18 +01:00
|
|
|
.query_format = query_format,
|
2014-01-24 21:22:25 +01:00
|
|
|
.reconfig = reconfig,
|
2009-05-04 02:09:50 +02:00
|
|
|
.control = control,
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 14:25:04 +01:00
|
|
|
.draw_image = draw_image,
|
2009-11-15 03:39:22 +01:00
|
|
|
.flip_page_timed = flip_page_timed,
|
2009-05-04 02:09:50 +02:00
|
|
|
.uninit = uninit,
|
2012-08-06 17:51:53 +02:00
|
|
|
.priv_size = sizeof(struct vdpctx),
|
2012-06-25 22:12:03 +02:00
|
|
|
.options = (const struct m_option []){
|
|
|
|
OPT_INTRANGE("deint", deint, 0, -4, 4),
|
2013-02-08 21:09:18 +01:00
|
|
|
OPT_FLAG("chroma-deint", chroma_deint, 0, OPTDEF_INT(1)),
|
|
|
|
OPT_FLAG("pullup", pullup, 0),
|
2012-06-25 22:12:03 +02:00
|
|
|
OPT_FLOATRANGE("denoise", denoise, 0, 0, 1),
|
|
|
|
OPT_FLOATRANGE("sharpen", sharpen, 0, -1, 1),
|
|
|
|
OPT_INTRANGE("hqscaling", hqscaling, 0, 0, 9),
|
|
|
|
OPT_FLOAT("fps", user_fps, 0),
|
2013-02-08 21:09:18 +01:00
|
|
|
OPT_FLAG("composite-detect", composite_detect, 0, OPTDEF_INT(1)),
|
2012-06-25 22:12:03 +02:00
|
|
|
OPT_INT("queuetime_windowed", flip_offset_window, 0, OPTDEF_INT(50)),
|
|
|
|
OPT_INT("queuetime_fs", flip_offset_fs, 0, OPTDEF_INT(50)),
|
|
|
|
OPT_INTRANGE("output_surfaces", num_output_surfaces, 0,
|
|
|
|
2, MAX_OUTPUT_SURFACES, OPTDEF_INT(3)),
|
vo_vdpau: use color close to black as default colorkey (instead of green)
The VDPAU default colorkey, although it seems to be driver specific, is
usually green. This is a pretty annoying color, and you usually see it
briefly (as flashes) if the VDPAU window resizes.
Change it to some shade of black. The new default color is close to what
MPlayer picks as colorkey (and apparently it worked well for them):
VdpColor vdp_bg = {0.01, 0.02, 0.03, 0};
Since our OPT_COLOR can set 8 bit colors only, we use '#020507' instead,
which should be the same assuming 8 bit colors.
Obviously, you can't use black, because black is a way too common color,
and would make it too easy to observe the colorkey effect when e.g.
moving a terminal with black background over the video window.
2013-08-17 20:05:28 +02:00
|
|
|
OPT_COLOR("colorkey", colorkey, 0,
|
|
|
|
.defval = &(const struct m_color) {
|
|
|
|
.r = 2, .g = 5, .b = 7, .a = 255,
|
|
|
|
}),
|
2013-08-18 05:12:21 +02:00
|
|
|
OPT_FLAG("force-yuv", force_yuv, 0),
|
2012-06-25 22:12:03 +02:00
|
|
|
{NULL},
|
|
|
|
}
|
2009-05-04 02:09:50 +02:00
|
|
|
};
|