Mercurial > mplayer.hg
annotate libvo/vo_vdpau.c @ 36962:6bb8d4f4a7b0
Add missing #include.
author | ib |
---|---|
date | Mon, 24 Mar 2014 11:09:39 +0000 |
parents | 5d3f93051de9 |
children |
rev | line source |
---|---|
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1 /* |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
2 * VDPAU video output driver |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
3 * |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
4 * Copyright (C) 2008 NVIDIA |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
5 * |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
6 * This file is part of MPlayer. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
7 * |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
8 * MPlayer is free software; you can redistribute it and/or modify |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
11 * (at your option) any later version. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
12 * |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
13 * MPlayer is distributed in the hope that it will be useful, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
17 * |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License along |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
21 */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
22 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
23 /** |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
24 * \defgroup VDPAU_Presentation VDPAU Presentation |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
25 * \ingroup Decoder |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
26 * |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
27 * Actual decoding and presentation are implemented here. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
28 * All necessary frame information is collected through |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
29 * the "vdpau_render_state" structure after parsing all headers |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
30 * etc. in libavcodec for different codecs. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
31 * |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
32 * @{ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
33 */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
34 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
35 #include <stdio.h> |
35903 | 36 #include <strings.h> |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
37 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
38 #include "config.h" |
32461 | 39 #include "sub/ass_mp.h" |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
40 #include "mp_msg.h" |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
41 #include "video_out.h" |
36517 | 42 #define NO_DRAW_FRAME |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
43 #include "video_out_internal.h" |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
32750
diff
changeset
|
44 #include "libmpcodecs/vf.h" |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
45 #include "x11_common.h" |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
46 #include "aspect.h" |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
32461
diff
changeset
|
47 #include "sub/font_load.h" |
32467 | 48 #include "sub/sub.h" |
32460 | 49 #include "sub/eosd.h" |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
50 #include "subopt-helper.h" |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
51 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
52 #include "libavcodec/vdpau.h" |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
53 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
54 #include "libavutil/common.h" |
28729 | 55 #include "libavutil/mathematics.h" |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
56 |
28675 | 57 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
58 static vo_info_t info = { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
59 "VDPAU with X11", |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
60 "vdpau", |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
61 "Rajib Mahapatra <rmahapatra@nvidia.com> and others", |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
62 "" |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
63 }; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
64 |
30925
f8939d5b14b5
Mark some more LIBVO_EXTERN declarations as const where possible.
reimar
parents:
30758
diff
changeset
|
65 const LIBVO_EXTERN(vdpau) |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
66 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
67 #define CHECK_ST_ERROR(message) \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
68 if (vdp_st != VDP_STATUS_OK) { \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
69 mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] %s: %s\n", \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
70 message, vdp_get_error_string(vdp_st)); \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
71 return -1; \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
72 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
73 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
74 #define CHECK_ST_WARNING(message) \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
75 if (vdp_st != VDP_STATUS_OK) \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
76 mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] %s: %s\n", \ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
77 message, vdp_get_error_string(vdp_st)); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
78 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
79 /* number of video and output surfaces */ |
30006
73d653fd865f
Improve VDPAU render performance by increasing number of output surfaces.
cehoyos
parents:
29861
diff
changeset
|
80 #define NUM_OUTPUT_SURFACES 3 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
81 #define MAX_VIDEO_SURFACES 50 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
82 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
83 /* number of palette entries */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
84 #define PALETTE_SIZE 256 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
85 |
28675 | 86 /* Initial maximum number of EOSD surfaces */ |
87 #define EOSD_SURFACES_INITIAL 512 | |
88 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
89 /* |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
90 * Global variable declaration - VDPAU specific |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
91 */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
92 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
93 /* Declaration for all variables of win_x11_init_vdpau_procs() and |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
94 * win_x11_init_vdpau_flip_queue() functions |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
95 */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
96 static VdpDevice vdp_device; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
97 static VdpGetProcAddress *vdp_get_proc_address; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
98 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
99 static VdpPresentationQueueTarget vdp_flip_target; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
100 static VdpPresentationQueue vdp_flip_queue; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
101 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
102 static VdpDeviceDestroy *vdp_device_destroy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
103 static VdpVideoSurfaceCreate *vdp_video_surface_create; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
104 static VdpVideoSurfaceDestroy *vdp_video_surface_destroy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
105 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
106 static VdpGetErrorString *vdp_get_error_string; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
107 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
108 /* May be used in software filtering/postprocessing options |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
109 * in MPlayer (./mplayer -vf ..) if we copy video_surface data to |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
110 * system memory. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
111 */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
112 static VdpVideoSurfacePutBitsYCbCr *vdp_video_surface_put_bits_y_cb_cr; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
113 static VdpOutputSurfacePutBitsNative *vdp_output_surface_put_bits_native; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
114 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
115 static VdpOutputSurfaceCreate *vdp_output_surface_create; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
116 static VdpOutputSurfaceDestroy *vdp_output_surface_destroy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
117 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
118 /* VideoMixer puts video_surface data on displayable output_surface. */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
119 static VdpVideoMixerCreate *vdp_video_mixer_create; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
120 static VdpVideoMixerDestroy *vdp_video_mixer_destroy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
121 static VdpVideoMixerRender *vdp_video_mixer_render; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
122 static VdpVideoMixerSetFeatureEnables *vdp_video_mixer_set_feature_enables; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
123 static VdpVideoMixerSetAttributeValues *vdp_video_mixer_set_attribute_values; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
124 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
125 static VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
126 static VdpPresentationQueueCreate *vdp_presentation_queue_create; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
127 static VdpPresentationQueueDestroy *vdp_presentation_queue_destroy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
128 static VdpPresentationQueueDisplay *vdp_presentation_queue_display; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
129 static VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
130 static VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11; |
31763
550ffba86d9c
Make the VDPAU background black instead of the default green.
cehoyos
parents:
31317
diff
changeset
|
131 static VdpPresentationQueueSetBackgroundColor *vdp_presentation_queue_set_background_color; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
132 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
133 static VdpOutputSurfaceRenderOutputSurface *vdp_output_surface_render_output_surface; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
134 static VdpOutputSurfacePutBitsIndexed *vdp_output_surface_put_bits_indexed; |
28675 | 135 static VdpOutputSurfaceRenderBitmapSurface *vdp_output_surface_render_bitmap_surface; |
136 | |
137 static VdpBitmapSurfaceCreate *vdp_bitmap_surface_create; | |
138 static VdpBitmapSurfaceDestroy *vdp_bitmap_surface_destroy; | |
139 static VdpBitmapSurfacePutBitsNative *vdp_bitmap_surface_putbits_native; | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
140 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
141 static VdpDecoderCreate *vdp_decoder_create; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
142 static VdpDecoderDestroy *vdp_decoder_destroy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
143 static VdpDecoderRender *vdp_decoder_render; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
144 |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
145 static VdpGenerateCSCMatrix *vdp_generate_csc_matrix; |
29735 | 146 static VdpPreemptionCallbackRegister *vdp_preemption_callback_register; |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
147 |
28696
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
148 /* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */ |
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
149 #define osd_surface output_surfaces[NUM_OUTPUT_SURFACES] |
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
150 static VdpOutputSurface output_surfaces[NUM_OUTPUT_SURFACES + 1]; |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
151 static VdpOutputSurface rgba_surface; |
28933
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
152 static VdpVideoSurface deint_surfaces[3]; |
29017
c9a2d95c580a
New vdpau deinterlacing code needs one reference surface less.
cehoyos
parents:
29016
diff
changeset
|
153 static mp_image_t *deint_mpi[2]; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
154 static int output_surface_width, output_surface_height; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
155 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
156 static VdpVideoMixer video_mixer; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
157 static int deint; |
28709
4e89476f8952
Do not forget the chosen deinterlacer for -vo vdpau.
cehoyos
parents:
28708
diff
changeset
|
158 static int deint_type; |
28933
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
159 static int deint_counter; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
160 static int pullup; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
161 static float denoise; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
162 static float sharpen; |
29727 | 163 static int colorspace; |
28944
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
164 static int chroma_deint; |
29756 | 165 static int force_mixer; |
28684 | 166 static int top_field_first; |
29752 | 167 static int flip; |
29781
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
168 static int hqscaling; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
169 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
170 static VdpDecoder decoder; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
171 static int decoder_max_refs; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
172 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
173 static VdpRect src_rect_vid; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
174 static VdpRect out_rect_vid; |
28598
4172d83194f2
Extend calc_src_dst_rects to also calculate the border values needed for
reimar
parents:
28582
diff
changeset
|
175 static int border_x, border_y; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
176 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
177 static struct vdpau_render_state surface_render[MAX_VIDEO_SURFACES]; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
178 static int surface_num; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
179 static int vid_surface_num; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
180 static uint32_t vid_width, vid_height; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
181 static uint32_t image_format; |
29066
ab51a502ebb5
Add support for IMGFMT_YUY2 and IMGFMT_UYVY to vo vdpau.
cehoyos
parents:
29065
diff
changeset
|
182 static VdpChromaType vdp_chroma_type; |
ab51a502ebb5
Add support for IMGFMT_YUY2 and IMGFMT_UYVY to vo vdpau.
cehoyos
parents:
29065
diff
changeset
|
183 static VdpYCbCrFormat vdp_pixel_format; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
184 |
29735 | 185 static volatile int is_preempted; |
186 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
187 /* draw_osd */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
188 static unsigned char *index_data; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
189 static int index_data_size; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
190 static uint32_t palette[PALETTE_SIZE]; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
191 |
28675 | 192 // EOSD |
193 // Pool of surfaces | |
194 struct { | |
195 VdpBitmapSurface surface; | |
196 int w; | |
197 int h; | |
198 char in_use; | |
199 } *eosd_surfaces; | |
200 | |
201 // List of surfaces to be rendered | |
202 struct { | |
203 VdpBitmapSurface surface; | |
204 VdpRect source; | |
205 VdpRect dest; | |
206 VdpColor color; | |
207 } *eosd_targets; | |
208 | |
209 static int eosd_render_count; | |
210 static int eosd_surface_count; | |
211 | |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
212 // Video equalizer |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
213 static VdpProcamp procamp; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
214 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
215 /* |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
216 * X11 specific |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
217 */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
218 static int visible_buf; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
219 |
28805
b382d065ba53
As for vo_gl, do not rely on draw_osd to render EOSD.
reimar
parents:
28804
diff
changeset
|
220 static void draw_eosd(void); |
b382d065ba53
As for vo_gl, do not rely on draw_osd to render EOSD.
reimar
parents:
28804
diff
changeset
|
221 |
29016
8e95cca7c58d
Stephen Warren reported that VDPAU deinterlacing did not work correctly.
cehoyos
parents:
29005
diff
changeset
|
222 static void push_deint_surface(VdpVideoSurface surface) |
8e95cca7c58d
Stephen Warren reported that VDPAU deinterlacing did not work correctly.
cehoyos
parents:
29005
diff
changeset
|
223 { |
8e95cca7c58d
Stephen Warren reported that VDPAU deinterlacing did not work correctly.
cehoyos
parents:
29005
diff
changeset
|
224 deint_surfaces[2] = deint_surfaces[1]; |
8e95cca7c58d
Stephen Warren reported that VDPAU deinterlacing did not work correctly.
cehoyos
parents:
29005
diff
changeset
|
225 deint_surfaces[1] = deint_surfaces[0]; |
8e95cca7c58d
Stephen Warren reported that VDPAU deinterlacing did not work correctly.
cehoyos
parents:
29005
diff
changeset
|
226 deint_surfaces[0] = surface; |
8e95cca7c58d
Stephen Warren reported that VDPAU deinterlacing did not work correctly.
cehoyos
parents:
29005
diff
changeset
|
227 } |
8e95cca7c58d
Stephen Warren reported that VDPAU deinterlacing did not work correctly.
cehoyos
parents:
29005
diff
changeset
|
228 |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
229 static const uint32_t rotate_flags[4] = { |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
230 VDP_OUTPUT_SURFACE_RENDER_ROTATE_0, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
231 VDP_OUTPUT_SURFACE_RENDER_ROTATE_90, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
232 VDP_OUTPUT_SURFACE_RENDER_ROTATE_180, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
233 VDP_OUTPUT_SURFACE_RENDER_ROTATE_270 |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
234 }; |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
235 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
236 static void video_to_output_surface(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
237 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
238 VdpTime dummy; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
239 VdpStatus vdp_st; |
28684 | 240 int i; |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
241 if (image_format == IMGFMT_BGRA) { |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
242 vdp_st = vdp_output_surface_render_output_surface(output_surfaces[surface_num], |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
243 &out_rect_vid, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
244 rgba_surface, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
245 &src_rect_vid, NULL, NULL, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
246 rotate_flags[vo_rotate & 3]); |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
247 CHECK_ST_WARNING("Error when calling vdp_output_surface_render_output_surface") |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
248 return; |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
249 } |
29026
17e9f67f086b
Simplify vdpau deinterlacing code and fix timing for deint=2.
cehoyos
parents:
29018
diff
changeset
|
250 if (vid_surface_num < 0) |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
251 return; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
252 |
29026
17e9f67f086b
Simplify vdpau deinterlacing code and fix timing for deint=2.
cehoyos
parents:
29018
diff
changeset
|
253 if (deint < 2 || deint_surfaces[0] == VDP_INVALID_HANDLE) |
17e9f67f086b
Simplify vdpau deinterlacing code and fix timing for deint=2.
cehoyos
parents:
29018
diff
changeset
|
254 push_deint_surface(surface_render[vid_surface_num].surface); |
17e9f67f086b
Simplify vdpau deinterlacing code and fix timing for deint=2.
cehoyos
parents:
29018
diff
changeset
|
255 |
28708 | 256 for (i = 0; i <= !!(deint > 1); i++) { |
28684 | 257 int field = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME; |
258 VdpOutputSurface output_surface; | |
28724 | 259 if (i) { |
28805
b382d065ba53
As for vo_gl, do not rely on draw_osd to render EOSD.
reimar
parents:
28804
diff
changeset
|
260 draw_eosd(); |
28724 | 261 draw_osd(); |
28684 | 262 flip_page(); |
28724 | 263 } |
28684 | 264 if (deint) |
29026
17e9f67f086b
Simplify vdpau deinterlacing code and fix timing for deint=2.
cehoyos
parents:
29018
diff
changeset
|
265 field = (top_field_first == i) ^ (deint > 1) ? |
28684 | 266 VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD: |
267 VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD; | |
268 output_surface = output_surfaces[surface_num]; | |
269 vdp_st = vdp_presentation_queue_block_until_surface_idle(vdp_flip_queue, | |
270 output_surface, | |
271 &dummy); | |
272 CHECK_ST_WARNING("Error when calling vdp_presentation_queue_block_until_surface_idle") | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
273 |
28689 | 274 vdp_st = vdp_video_mixer_render(video_mixer, VDP_INVALID_HANDLE, 0, |
28933
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
275 field, 2, deint_surfaces + 1, |
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
276 deint_surfaces[0], |
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
277 1, &surface_render[vid_surface_num].surface, |
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
278 &src_rect_vid, |
28689 | 279 output_surface, |
280 NULL, &out_rect_vid, 0, NULL); | |
281 CHECK_ST_WARNING("Error when calling vdp_video_mixer_render") | |
29026
17e9f67f086b
Simplify vdpau deinterlacing code and fix timing for deint=2.
cehoyos
parents:
29018
diff
changeset
|
282 push_deint_surface(surface_render[vid_surface_num].surface); |
28684 | 283 } |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
284 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
285 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
286 static void resize(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
287 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
288 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
289 int i; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
290 struct vo_rect src_rect; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
291 struct vo_rect dst_rect; |
28598
4172d83194f2
Extend calc_src_dst_rects to also calculate the border values needed for
reimar
parents:
28582
diff
changeset
|
292 struct vo_rect borders; |
4172d83194f2
Extend calc_src_dst_rects to also calculate the border values needed for
reimar
parents:
28582
diff
changeset
|
293 calc_src_dst_rects(vid_width, vid_height, &src_rect, &dst_rect, &borders, NULL); |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
294 out_rect_vid.x0 = dst_rect.left; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
295 out_rect_vid.x1 = dst_rect.right; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
296 out_rect_vid.y0 = dst_rect.top; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
297 out_rect_vid.y1 = dst_rect.bottom; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
298 src_rect_vid.x0 = src_rect.left; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
299 src_rect_vid.x1 = src_rect.right; |
29752 | 300 src_rect_vid.y0 = flip ? src_rect.bottom : src_rect.top; |
301 src_rect_vid.y1 = flip ? src_rect.top : src_rect.bottom; | |
28598
4172d83194f2
Extend calc_src_dst_rects to also calculate the border values needed for
reimar
parents:
28582
diff
changeset
|
302 border_x = borders.left; |
4172d83194f2
Extend calc_src_dst_rects to also calculate the border values needed for
reimar
parents:
28582
diff
changeset
|
303 border_y = borders.top; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
304 #ifdef CONFIG_FREETYPE |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
305 // adjust font size to display size |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
306 force_load_font = 1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
307 #endif |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
308 vo_osd_changed(OSDTYPE_OSD); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
309 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
310 if (output_surface_width < vo_dwidth || output_surface_height < vo_dheight) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
311 if (output_surface_width < vo_dwidth) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
312 output_surface_width += output_surface_width >> 1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
313 output_surface_width = FFMAX(output_surface_width, vo_dwidth); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
314 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
315 if (output_surface_height < vo_dheight) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
316 output_surface_height += output_surface_height >> 1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
317 output_surface_height = FFMAX(output_surface_height, vo_dheight); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
318 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
319 // Creation of output_surfaces |
28696
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
320 for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) { |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
321 if (output_surfaces[i] != VDP_INVALID_HANDLE) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
322 vdp_output_surface_destroy(output_surfaces[i]); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
323 vdp_st = vdp_output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
324 output_surface_width, output_surface_height, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
325 &output_surfaces[i]); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
326 CHECK_ST_WARNING("Error when calling vdp_output_surface_create") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
327 mp_msg(MSGT_VO, MSGL_DBG2, "OUT CREATE: %u\n", output_surfaces[i]); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
328 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
329 } |
36251 | 330 // clear surfaces |
331 for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) { | |
332 vdp_output_surface_render_output_surface(output_surfaces[i], NULL, | |
333 VDP_INVALID_HANDLE, NULL, | |
334 NULL, NULL, VDP_OUTPUT_SURFACE_RENDER_ROTATE_0); | |
335 } | |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
336 video_to_output_surface(); |
36208 | 337 if (visible_buf) { |
338 draw_eosd(); | |
339 draw_osd(); | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
340 flip_page(); |
36208 | 341 } |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
342 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
343 |
29735 | 344 static void preemption_callback(VdpDevice device, void *context) |
345 { | |
346 mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Display preemption detected\n"); | |
347 is_preempted = 1; | |
348 } | |
349 | |
36319 | 350 static void mark_vdpau_objects_uninitialized(void); |
351 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
352 /* Initialize vdp_get_proc_address, called from preinit() */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
353 static int win_x11_init_vdpau_procs(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
354 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
355 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
356 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
357 struct vdp_function { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
358 const int id; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
359 void *pointer; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
360 }; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
361 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
362 const struct vdp_function *dsc; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
363 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
364 static const struct vdp_function vdp_func[] = { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
365 {VDP_FUNC_ID_GET_ERROR_STRING, &vdp_get_error_string}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
366 {VDP_FUNC_ID_DEVICE_DESTROY, &vdp_device_destroy}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
367 {VDP_FUNC_ID_VIDEO_SURFACE_CREATE, &vdp_video_surface_create}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
368 {VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, &vdp_video_surface_destroy}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
369 {VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
370 &vdp_video_surface_put_bits_y_cb_cr}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
371 {VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
372 &vdp_output_surface_put_bits_native}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
373 {VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, &vdp_output_surface_create}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
374 {VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, &vdp_output_surface_destroy}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
375 {VDP_FUNC_ID_VIDEO_MIXER_CREATE, &vdp_video_mixer_create}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
376 {VDP_FUNC_ID_VIDEO_MIXER_DESTROY, &vdp_video_mixer_destroy}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
377 {VDP_FUNC_ID_VIDEO_MIXER_RENDER, &vdp_video_mixer_render}, |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
378 {VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES, |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
379 &vdp_video_mixer_set_feature_enables}, |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
380 {VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES, |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
381 &vdp_video_mixer_set_attribute_values}, |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
382 {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
383 &vdp_presentation_queue_target_destroy}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
384 {VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE, &vdp_presentation_queue_create}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
385 {VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
386 &vdp_presentation_queue_destroy}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
387 {VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
388 &vdp_presentation_queue_display}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
389 {VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
390 &vdp_presentation_queue_block_until_surface_idle}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
391 {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
392 &vdp_presentation_queue_target_create_x11}, |
31763
550ffba86d9c
Make the VDPAU background black instead of the default green.
cehoyos
parents:
31317
diff
changeset
|
393 {VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR, |
550ffba86d9c
Make the VDPAU background black instead of the default green.
cehoyos
parents:
31317
diff
changeset
|
394 &vdp_presentation_queue_set_background_color}, |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
395 {VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
396 &vdp_output_surface_render_output_surface}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
397 {VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
398 &vdp_output_surface_put_bits_indexed}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
399 {VDP_FUNC_ID_DECODER_CREATE, &vdp_decoder_create}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
400 {VDP_FUNC_ID_DECODER_RENDER, &vdp_decoder_render}, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
401 {VDP_FUNC_ID_DECODER_DESTROY, &vdp_decoder_destroy}, |
28675 | 402 {VDP_FUNC_ID_BITMAP_SURFACE_CREATE, &vdp_bitmap_surface_create}, |
403 {VDP_FUNC_ID_BITMAP_SURFACE_DESTROY, &vdp_bitmap_surface_destroy}, | |
404 {VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE, | |
405 &vdp_bitmap_surface_putbits_native}, | |
406 {VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE, | |
407 &vdp_output_surface_render_bitmap_surface}, | |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
408 {VDP_FUNC_ID_GENERATE_CSC_MATRIX, &vdp_generate_csc_matrix}, |
29735 | 409 {VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER, |
410 &vdp_preemption_callback_register}, | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
411 {0, NULL} |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
412 }; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
413 |
36319 | 414 mark_vdpau_objects_uninitialized(); |
415 | |
29861
356c49d60826
Do not dynamically load libvdpau.so.1, but link at compile time.
cehoyos
parents:
29843
diff
changeset
|
416 vdp_st = vdp_device_create_x11(mDisplay, mScreen, |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
417 &vdp_device, &vdp_get_proc_address); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
418 if (vdp_st != VDP_STATUS_OK) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
419 mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_device_create_x11: %i\n", vdp_st); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
420 return -1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
421 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
422 |
29067
a560ab3e03e5
Make sure we do not accidentally use the vdp_get_error_string from the
reimar
parents:
29066
diff
changeset
|
423 vdp_get_error_string = NULL; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
424 for (dsc = vdp_func; dsc->pointer; dsc++) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
425 vdp_st = vdp_get_proc_address(vdp_device, dsc->id, dsc->pointer); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
426 if (vdp_st != VDP_STATUS_OK) { |
29713 | 427 mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_get_proc_address(function id %d): %s\n", |
428 dsc->id, vdp_get_error_string ? vdp_get_error_string(vdp_st) : "?"); | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
429 return -1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
430 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
431 } |
29735 | 432 vdp_st = vdp_preemption_callback_register(vdp_device, |
433 preemption_callback, NULL); | |
434 CHECK_ST_ERROR("Error when calling vdp_preemption_callback_register") | |
435 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
436 return 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
437 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
438 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
439 /* Initialize vdpau_flip_queue, called from config() */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
440 static int win_x11_init_vdpau_flip_queue(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
441 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
442 VdpStatus vdp_st; |
31767 | 443 // {0, 0, 0, 0} makes the video shine through any black window on top |
31766
1abfb1bfd2a6
Reduce probability that a window on top of VDPAU uses the overlay colour.
cehoyos
parents:
31765
diff
changeset
|
444 VdpColor vdp_bg = {0.01, 0.02, 0.03, 0}; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
445 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
446 vdp_st = vdp_presentation_queue_target_create_x11(vdp_device, vo_window, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
447 &vdp_flip_target); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
448 CHECK_ST_ERROR("Error when calling vdp_presentation_queue_target_create_x11") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
449 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
450 vdp_st = vdp_presentation_queue_create(vdp_device, vdp_flip_target, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
451 &vdp_flip_queue); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
452 CHECK_ST_ERROR("Error when calling vdp_presentation_queue_create") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
453 |
31763
550ffba86d9c
Make the VDPAU background black instead of the default green.
cehoyos
parents:
31317
diff
changeset
|
454 vdp_st = vdp_presentation_queue_set_background_color(vdp_flip_queue, &vdp_bg); |
550ffba86d9c
Make the VDPAU background black instead of the default green.
cehoyos
parents:
31317
diff
changeset
|
455 CHECK_ST_ERROR("Error when calling vdp_presentation_queue_set_background_color") |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
456 return 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
457 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
458 |
29727 | 459 static int update_csc_matrix(void) |
460 { | |
461 VdpStatus vdp_st; | |
462 VdpCSCMatrix matrix; | |
463 static const VdpVideoMixerAttribute attributes[] = {VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX}; | |
464 const void *attribute_values[] = {&matrix}; | |
29729 | 465 static const VdpColorStandard vdp_colors[] = {0, VDP_COLOR_STANDARD_ITUR_BT_601, VDP_COLOR_STANDARD_ITUR_BT_709, VDP_COLOR_STANDARD_SMPTE_240M}; |
466 static const char * const vdp_names[] = {NULL, "BT.601", "BT.709", "SMPTE-240M"}; | |
29727 | 467 int csp = colorspace; |
468 | |
469 if (!csp) | |
470 csp = vid_width >= 1280 || vid_height > 576 ? 2 : 1; | |
471 | |
472 mp_msg(MSGT_VO, MSGL_V, "[vdpau] Updating CSC matrix for %s\n", | |
473 vdp_names[csp]); | |
474 | |
475 vdp_st = vdp_generate_csc_matrix(&procamp, vdp_colors[csp], &matrix); | |
476 CHECK_ST_WARNING("Error when generating CSC matrix") | |
477 | |
478 vdp_st = vdp_video_mixer_set_attribute_values(video_mixer, 1, attributes, | |
479 attribute_values); | |
480 CHECK_ST_WARNING("Error when setting CSC matrix") | |
481 return VO_TRUE; | |
482 } | |
483 | |
29713 | 484 static int create_vdp_mixer(VdpChromaType vdp_chroma_type) |
485 { | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
486 #define VDP_NUM_MIXER_PARAMETER 3 |
29781
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
487 #define MAX_NUM_FEATURES 6 |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
488 int i; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
489 VdpStatus vdp_st; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
490 int feature_count = 0; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
491 VdpVideoMixerFeature features[MAX_NUM_FEATURES]; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
492 VdpBool feature_enables[MAX_NUM_FEATURES]; |
28658 | 493 static const VdpVideoMixerAttribute denoise_attrib[] = {VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL}; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
494 const void * const denoise_value[] = {&denoise}; |
28658 | 495 static const VdpVideoMixerAttribute sharpen_attrib[] = {VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL}; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
496 const void * const sharpen_value[] = {&sharpen}; |
28944
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
497 static const VdpVideoMixerAttribute skip_chroma_attrib[] = {VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE}; |
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
498 const uint8_t skip_chroma_value = 1; |
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
499 const void * const skip_chroma_value_ptr[] = {&skip_chroma_value}; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
500 static const VdpVideoMixerParameter parameters[VDP_NUM_MIXER_PARAMETER] = { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
501 VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
502 VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
503 VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
504 }; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
505 const void *const parameter_values[VDP_NUM_MIXER_PARAMETER] = { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
506 &vid_width, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
507 &vid_height, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
508 &vdp_chroma_type |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
509 }; |
28934 | 510 features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL; |
28708 | 511 if (deint == 4) |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
512 features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
513 if (pullup) |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
514 features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
515 if (denoise) |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
516 features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
517 if (sharpen) |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
518 features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_SHARPNESS; |
29781
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
519 if (hqscaling) |
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
520 features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 + (hqscaling - 1); |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
521 |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
522 vdp_st = vdp_video_mixer_create(vdp_device, feature_count, features, |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
523 VDP_NUM_MIXER_PARAMETER, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
524 parameters, parameter_values, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
525 &video_mixer); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
526 CHECK_ST_ERROR("Error when calling vdp_video_mixer_create") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
527 |
29713 | 528 for (i = 0; i < feature_count; i++) |
529 feature_enables[i] = VDP_TRUE; | |
28933
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
530 if (deint < 3) |
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
531 feature_enables[0] = VDP_FALSE; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
532 if (feature_count) |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
533 vdp_video_mixer_set_feature_enables(video_mixer, feature_count, features, feature_enables); |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
534 if (denoise) |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
535 vdp_video_mixer_set_attribute_values(video_mixer, 1, denoise_attrib, denoise_value); |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
536 if (sharpen) |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
537 vdp_video_mixer_set_attribute_values(video_mixer, 1, sharpen_attrib, sharpen_value); |
28944
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
538 if (!chroma_deint) |
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
539 vdp_video_mixer_set_attribute_values(video_mixer, 1, skip_chroma_attrib, skip_chroma_value_ptr); |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
540 |
29727 | 541 update_csc_matrix(); |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
542 return 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
543 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
544 |
31975 | 545 static void mark_invalid(void) |
29713 | 546 { |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
547 int i; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
548 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
549 decoder = VDP_INVALID_HANDLE; |
31975 | 550 video_mixer = VDP_INVALID_HANDLE; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
551 |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
552 rgba_surface = VDP_INVALID_HANDLE; |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
553 |
28936
fd9de1e70d47
Move initialisation of deint_surfaces[] to free_video_specific().
cehoyos
parents:
28935
diff
changeset
|
554 for (i = 0; i < 3; i++) |
fd9de1e70d47
Move initialisation of deint_surfaces[] to free_video_specific().
cehoyos
parents:
28935
diff
changeset
|
555 deint_surfaces[i] = VDP_INVALID_HANDLE; |
fd9de1e70d47
Move initialisation of deint_surfaces[] to free_video_specific().
cehoyos
parents:
28935
diff
changeset
|
556 |
29017
c9a2d95c580a
New vdpau deinterlacing code needs one reference surface less.
cehoyos
parents:
29016
diff
changeset
|
557 for (i = 0; i < 2; i++) |
28956
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
558 if (deint_mpi[i]) { |
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
559 deint_mpi[i]->usage_count--; |
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
560 deint_mpi[i] = NULL; |
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
561 } |
31975 | 562 } |
563 | |
564 // Free everything specific to a certain video file | |
565 static void free_video_specific(void) | |
566 { | |
567 int i; | |
568 VdpStatus vdp_st; | |
569 | |
570 if (decoder != VDP_INVALID_HANDLE) | |
571 vdp_decoder_destroy(decoder); | |
572 decoder_max_refs = -1; | |
28956
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
573 |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
574 if (rgba_surface != VDP_INVALID_HANDLE) { |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
575 vdp_st = vdp_output_surface_destroy(rgba_surface); |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
576 CHECK_ST_WARNING("Error destroying RGBA surface") |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
577 } |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
578 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
579 for (i = 0; i < MAX_VIDEO_SURFACES; i++) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
580 if (surface_render[i].surface != VDP_INVALID_HANDLE) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
581 vdp_st = vdp_video_surface_destroy(surface_render[i].surface); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
582 CHECK_ST_WARNING("Error when calling vdp_video_surface_destroy") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
583 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
584 surface_render[i].surface = VDP_INVALID_HANDLE; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
585 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
586 |
28676
d5c295360163
Only check for vdp_video_mixer_destroy failure when we actually executed that function.
reimar
parents:
28675
diff
changeset
|
587 if (video_mixer != VDP_INVALID_HANDLE) { |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
588 vdp_st = vdp_video_mixer_destroy(video_mixer); |
28676
d5c295360163
Only check for vdp_video_mixer_destroy failure when we actually executed that function.
reimar
parents:
28675
diff
changeset
|
589 CHECK_ST_WARNING("Error when calling vdp_video_mixer_destroy") |
d5c295360163
Only check for vdp_video_mixer_destroy failure when we actually executed that function.
reimar
parents:
28675
diff
changeset
|
590 } |
31975 | 591 mark_invalid(); |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
592 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
593 |
29828
fe055da6637c
Fail in query_format() if a VDPAU decoder is not available.
cehoyos
parents:
29827
diff
changeset
|
594 static int create_vdp_decoder(uint32_t format, uint32_t width, uint32_t height, |
fe055da6637c
Fail in query_format() if a VDPAU decoder is not available.
cehoyos
parents:
29827
diff
changeset
|
595 int max_refs) |
28989 | 596 { |
597 VdpStatus vdp_st; | |
598 VdpDecoderProfile vdp_decoder_profile; | |
599 if (decoder != VDP_INVALID_HANDLE) | |
600 vdp_decoder_destroy(decoder); | |
29828
fe055da6637c
Fail in query_format() if a VDPAU decoder is not available.
cehoyos
parents:
29827
diff
changeset
|
601 switch (format) { |
29713 | 602 case IMGFMT_VDPAU_MPEG1: |
603 vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG1; | |
604 break; | |
605 case IMGFMT_VDPAU_MPEG2: | |
606 vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG2_MAIN; | |
607 break; | |
608 case IMGFMT_VDPAU_H264: | |
609 vdp_decoder_profile = VDP_DECODER_PROFILE_H264_HIGH; | |
610 mp_msg(MSGT_VO, MSGL_V, "[vdpau] Creating H264 hardware decoder for %d reference frames.\n", max_refs); | |
611 break; | |
612 case IMGFMT_VDPAU_WMV3: | |
613 vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_MAIN; | |
614 break; | |
615 case IMGFMT_VDPAU_VC1: | |
616 vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_ADVANCED; | |
617 break; | |
29843
f6d56a15f1d8
Support VDPAU hardware accelerated decoding of MPEG-4 ASP on capable
cehoyos
parents:
29830
diff
changeset
|
618 case IMGFMT_VDPAU_MPEG4: |
f6d56a15f1d8
Support VDPAU hardware accelerated decoding of MPEG-4 ASP on capable
cehoyos
parents:
29830
diff
changeset
|
619 vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP; |
f6d56a15f1d8
Support VDPAU hardware accelerated decoding of MPEG-4 ASP on capable
cehoyos
parents:
29830
diff
changeset
|
620 break; |
29827
d6d8b9d5a4fb
Add a default to switch(image_format), suppresses a warning after a future patch.
cehoyos
parents:
29781
diff
changeset
|
621 default: |
d6d8b9d5a4fb
Add a default to switch(image_format), suppresses a warning after a future patch.
cehoyos
parents:
29781
diff
changeset
|
622 goto err_out; |
28989 | 623 } |
624 vdp_st = vdp_decoder_create(vdp_device, vdp_decoder_profile, | |
29828
fe055da6637c
Fail in query_format() if a VDPAU decoder is not available.
cehoyos
parents:
29827
diff
changeset
|
625 width, height, max_refs, &decoder); |
28989 | 626 CHECK_ST_WARNING("Failed creating VDPAU decoder"); |
627 if (vdp_st != VDP_STATUS_OK) { | |
29827
d6d8b9d5a4fb
Add a default to switch(image_format), suppresses a warning after a future patch.
cehoyos
parents:
29781
diff
changeset
|
628 err_out: |
28989 | 629 decoder = VDP_INVALID_HANDLE; |
630 decoder_max_refs = 0; | |
28991 | 631 return 0; |
28989 | 632 } |
633 decoder_max_refs = max_refs; | |
28991 | 634 return 1; |
28989 | 635 } |
636 | |
29735 | 637 static void mark_vdpau_objects_uninitialized(void) |
638 { | |
639 int i; | |
640 | |
641 for (i = 0; i < MAX_VIDEO_SURFACES; i++) | |
642 surface_render[i].surface = VDP_INVALID_HANDLE; | |
643 vdp_flip_queue = VDP_INVALID_HANDLE; | |
644 vdp_flip_target = VDP_INVALID_HANDLE; | |
645 for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) | |
646 output_surfaces[i] = VDP_INVALID_HANDLE; | |
647 vdp_device = VDP_INVALID_HANDLE; | |
648 for (i = 0; i < eosd_surface_count; i++) | |
649 eosd_surfaces[i].surface = VDP_INVALID_HANDLE; | |
650 output_surface_width = output_surface_height = -1; | |
651 eosd_render_count = 0; | |
652 visible_buf = 0; | |
31975 | 653 mark_invalid(); |
29735 | 654 } |
655 | |
656 static int handle_preemption(void) | |
657 { | |
658 if (!is_preempted) | |
659 return 0; | |
660 is_preempted = 0; | |
661 mp_msg(MSGT_VO, MSGL_INFO, "[vdpau] Attempting to recover from preemption.\n"); | |
662 if (win_x11_init_vdpau_procs() < 0 || | |
663 win_x11_init_vdpau_flip_queue() < 0 || | |
664 create_vdp_mixer(vdp_chroma_type) < 0) { | |
665 mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Recovering from preemption failed\n"); | |
666 is_preempted = 1; | |
667 return -1; | |
668 } | |
669 resize(); | |
670 mp_msg(MSGT_VO, MSGL_INFO, "[vdpau] Recovered from display preemption.\n"); | |
671 return 1; | |
672 } | |
673 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
674 /* |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
675 * connect to X server, create and map window, initialize all |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
676 * VDPAU objects, create different surfaces etc. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
677 */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
678 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
679 uint32_t d_height, uint32_t flags, char *title, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
680 uint32_t format) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
681 { |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
682 VdpStatus vdp_st; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
683 XVisualInfo vinfo; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
684 XSetWindowAttributes xswa; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
685 XWindowAttributes attribs; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
686 unsigned long xswamask; |
28936
fd9de1e70d47
Move initialisation of deint_surfaces[] to free_video_specific().
cehoyos
parents:
28935
diff
changeset
|
687 int depth; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
688 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
689 #ifdef CONFIG_XF86VM |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
690 int vm = flags & VOFLAG_MODESWITCHING; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
691 #endif |
29752 | 692 flip = flags & VOFLAG_FLIPPING; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
693 |
36444 | 694 if (IMGFMT_IS_VDPAU(image_format) && decoder == VDP_INVALID_HANDLE) { |
695 mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] Unexpected reinit, query_format called too often?\n"); | |
696 // force a full reinit, otherwise we might run into issues with | |
697 // some implementations | |
698 image_format = 0; | |
699 } | |
36332
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
700 if (image_format == format && |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
701 vid_width == width && |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
702 vid_height == height) { |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
703 // at most aspect change, avoid reinit |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
704 vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
705 flags, CopyFromParent, "vdpau", title); |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
706 resize(); |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
707 return 0; |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
708 } |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
709 image_format = format; |
29005 | 710 vid_width = width; |
711 vid_height = height; | |
712 free_video_specific(); | |
29828
fe055da6637c
Fail in query_format() if a VDPAU decoder is not available.
cehoyos
parents:
29827
diff
changeset
|
713 if (IMGFMT_IS_VDPAU(image_format) |
fe055da6637c
Fail in query_format() if a VDPAU decoder is not available.
cehoyos
parents:
29827
diff
changeset
|
714 && !create_vdp_decoder(image_format, vid_width, vid_height, 2)) |
29005 | 715 return -1; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
716 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
717 visible_buf = 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
718 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
719 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
720 #ifdef CONFIG_XF86VM |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
721 if (vm) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
722 vo_vm_switch(); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
723 #endif |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
724 XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
725 depth = attribs.depth; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
726 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
727 depth = 24; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
728 XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
729 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
730 xswa.background_pixel = 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
731 xswa.border_pixel = 0; |
29234
6c47111fe28e
Do not use flag CWBackPixel when calling vo_x11_create_vo_window():
cehoyos
parents:
29070
diff
changeset
|
732 /* Do not use CWBackPixel: It leads to VDPAU errors after |
6c47111fe28e
Do not use flag CWBackPixel when calling vo_x11_create_vo_window():
cehoyos
parents:
29070
diff
changeset
|
733 aspect ratio changes. */ |
6c47111fe28e
Do not use flag CWBackPixel when calling vo_x11_create_vo_window():
cehoyos
parents:
29070
diff
changeset
|
734 xswamask = CWBorderPixel; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
735 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
736 vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
737 flags, CopyFromParent, "vdpau", title); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
738 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
739 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
740 #ifdef CONFIG_XF86VM |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
741 if (vm) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
742 /* Grab the mouse pointer in our window */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
743 if (vo_grabpointer) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
744 XGrabPointer(mDisplay, vo_window, True, 0, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
745 GrabModeAsync, GrabModeAsync, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
746 vo_window, None, CurrentTime); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
747 XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
748 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
749 #endif |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
750 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
751 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
752 if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
753 vo_fs = 1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
754 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
755 /* -----VDPAU related code here -------- */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
756 if (vdp_flip_queue == VDP_INVALID_HANDLE && win_x11_init_vdpau_flip_queue()) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
757 return -1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
758 |
29066
ab51a502ebb5
Add support for IMGFMT_YUY2 and IMGFMT_UYVY to vo vdpau.
cehoyos
parents:
29065
diff
changeset
|
759 vdp_chroma_type = VDP_CHROMA_TYPE_420; |
ab51a502ebb5
Add support for IMGFMT_YUY2 and IMGFMT_UYVY to vo vdpau.
cehoyos
parents:
29065
diff
changeset
|
760 switch (image_format) { |
29713 | 761 case IMGFMT_YV12: |
762 case IMGFMT_I420: | |
763 case IMGFMT_IYUV: | |
764 vdp_pixel_format = VDP_YCBCR_FORMAT_YV12; | |
765 break; | |
766 case IMGFMT_NV12: | |
767 vdp_pixel_format = VDP_YCBCR_FORMAT_NV12; | |
768 break; | |
769 case IMGFMT_YUY2: | |
770 vdp_pixel_format = VDP_YCBCR_FORMAT_YUYV; | |
771 vdp_chroma_type = VDP_CHROMA_TYPE_422; | |
772 break; | |
773 case IMGFMT_UYVY: | |
774 vdp_pixel_format = VDP_YCBCR_FORMAT_UYVY; | |
775 vdp_chroma_type = VDP_CHROMA_TYPE_422; | |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
776 break; |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
777 case IMGFMT_BGRA: |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
778 vdp_st = vdp_output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
779 vid_width, vid_height, |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
780 &rgba_surface); |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
781 CHECK_ST_ERROR("Error creating RGBA surface") |
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
782 break; |
29066
ab51a502ebb5
Add support for IMGFMT_YUY2 and IMGFMT_UYVY to vo vdpau.
cehoyos
parents:
29065
diff
changeset
|
783 } |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
784 if (create_vdp_mixer(vdp_chroma_type)) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
785 return -1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
786 |
29713 | 787 surface_num = 0; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
788 vid_surface_num = -1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
789 resize(); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
790 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
791 return 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
792 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
793 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
794 static void check_events(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
795 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
796 int e = vo_x11_check_events(mDisplay); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
797 |
29735 | 798 if (handle_preemption() < 0) |
799 return; | |
800 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
801 if (e & VO_EVENT_RESIZE) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
802 resize(); |
36207
658a648d3301
Handle expose event also when not paused and do not draw
reimar
parents:
36206
diff
changeset
|
803 else if (e & VO_EVENT_EXPOSE) { |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
804 /* did we already draw a buffer */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
805 if (visible_buf) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
806 /* redraw the last visible buffer */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
807 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
808 vdp_st = vdp_presentation_queue_display(vdp_flip_queue, |
36206
7227ed885f0c
Fix expose event redraw to actually redraw the correct frame.
reimar
parents:
36205
diff
changeset
|
809 output_surfaces[(surface_num + NUM_OUTPUT_SURFACES - 1) % NUM_OUTPUT_SURFACES], |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
810 vo_dwidth, vo_dheight, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
811 0); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
812 CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
813 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
814 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
815 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
816 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
817 static void draw_osd_I8A8(int x0,int y0, int w,int h, unsigned char *src, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
818 unsigned char *srca, int stride) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
819 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
820 VdpOutputSurface output_surface = output_surfaces[surface_num]; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
821 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
822 int i, j; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
823 int pitch; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
824 int index_data_size_required; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
825 VdpRect output_indexed_rect_vid; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
826 VdpOutputSurfaceRenderBlendState blend_state; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
827 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
828 if (!w || !h) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
829 return; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
830 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
831 index_data_size_required = 2*w*h; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
832 if (index_data_size < index_data_size_required) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
833 index_data = realloc(index_data, index_data_size_required); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
834 index_data_size = index_data_size_required; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
835 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
836 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
837 // index_data creation, component order - I, A, I, A, ..... |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
838 for (i = 0; i < h; i++) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
839 for (j = 0; j < w; j++) { |
29713 | 840 index_data[i*2*w + j*2] = src [i*stride + j]; |
841 index_data[i*2*w + j*2 + 1] = -srca[i*stride + j]; | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
842 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
843 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
844 output_indexed_rect_vid.x0 = x0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
845 output_indexed_rect_vid.y0 = y0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
846 output_indexed_rect_vid.x1 = x0 + w; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
847 output_indexed_rect_vid.y1 = y0 + h; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
848 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
849 pitch = w*2; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
850 |
28696
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
851 // write source_data to osd_surface. |
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
852 vdp_st = vdp_output_surface_put_bits_indexed(osd_surface, |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
853 VDP_INDEXED_FORMAT_I8A8, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
854 (const void *const*)&index_data, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
855 &pitch, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
856 &output_indexed_rect_vid, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
857 VDP_COLOR_TABLE_FORMAT_B8G8R8X8, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
858 (void *)palette); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
859 CHECK_ST_WARNING("Error when calling vdp_output_surface_put_bits_indexed") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
860 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
861 blend_state.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
862 blend_state.blend_factor_source_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE; |
36419 | 863 blend_state.blend_factor_source_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
864 blend_state.blend_factor_destination_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; |
36419 | 865 blend_state.blend_factor_destination_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
866 blend_state.blend_equation_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
867 blend_state.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
868 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
869 vdp_st = vdp_output_surface_render_output_surface(output_surface, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
870 &output_indexed_rect_vid, |
28696
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
871 osd_surface, |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
872 &output_indexed_rect_vid, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
873 NULL, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
874 &blend_state, |
36197 | 875 rotate_flags[vo_rotate & 3]); |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
876 CHECK_ST_WARNING("Error when calling vdp_output_surface_render_output_surface") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
877 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
878 |
29713 | 879 static void draw_eosd(void) |
880 { | |
28675 | 881 VdpStatus vdp_st; |
882 VdpOutputSurface output_surface = output_surfaces[surface_num]; | |
883 VdpOutputSurfaceRenderBlendState blend_state; | |
884 int i; | |
885 | |
886 blend_state.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION; | |
887 blend_state.blend_factor_source_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA; | |
36419 | 888 blend_state.blend_factor_source_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO; |
28675 | 889 blend_state.blend_factor_destination_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; |
36419 | 890 blend_state.blend_factor_destination_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO; |
28675 | 891 blend_state.blend_equation_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; |
892 blend_state.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; | |
893 | |
29713 | 894 for (i = 0; i < eosd_render_count; i++) { |
28675 | 895 vdp_st = vdp_output_surface_render_bitmap_surface( |
896 output_surface, &eosd_targets[i].dest, | |
897 eosd_targets[i].surface, &eosd_targets[i].source, | |
898 &eosd_targets[i].color, &blend_state, | |
36197 | 899 rotate_flags[vo_rotate & 3]); |
28675 | 900 CHECK_ST_WARNING("EOSD: Error when rendering") |
901 } | |
902 } | |
903 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
904 static void generate_eosd(struct mp_eosd_image_list *imgs) |
29713 | 905 { |
28675 | 906 VdpStatus vdp_st; |
907 VdpRect destRect; | |
908 int j, found; | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
909 struct mp_eosd_image *img = eosd_image_first(imgs); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
910 struct mp_eosd_image *i; |
28675 | 911 |
912 // Nothing changed, no need to redraw | |
913 if (imgs->changed == 0) | |
28807
338065cac802
Remove duplicate OSD drawing introduced due to a conflict between r28840 and r28839.
reimar
parents:
28805
diff
changeset
|
914 return; |
28675 | 915 eosd_render_count = 0; |
916 // There's nothing to render! | |
917 if (!img) | |
918 return; | |
919 | |
920 if (imgs->changed == 1) | |
921 goto eosd_skip_upload; | |
922 | |
29713 | 923 for (j = 0; j < eosd_surface_count; j++) |
28675 | 924 eosd_surfaces[j].in_use = 0; |
925 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
926 for (i = img; i; i = eosd_image_next(imgs)) { |
28675 | 927 // Try to reuse a suitable surface |
928 found = -1; | |
29713 | 929 for (j = 0; j < eosd_surface_count; j++) { |
28675 | 930 if (eosd_surfaces[j].surface != VDP_INVALID_HANDLE && !eosd_surfaces[j].in_use && |
931 eosd_surfaces[j].w >= i->w && eosd_surfaces[j].h >= i->h) { | |
932 found = j; | |
933 break; | |
934 } | |
935 } | |
936 // None found, allocate a new surface | |
937 if (found < 0) { | |
29713 | 938 for (j = 0; j < eosd_surface_count; j++) { |
28675 | 939 if (!eosd_surfaces[j].in_use) { |
940 if (eosd_surfaces[j].surface != VDP_INVALID_HANDLE) | |
941 vdp_bitmap_surface_destroy(eosd_surfaces[j].surface); | |
942 found = j; | |
943 break; | |
944 } | |
945 } | |
946 // Allocate new space for surface/target arrays | |
947 if (found < 0) { | |
948 j = found = eosd_surface_count; | |
949 eosd_surface_count = eosd_surface_count ? eosd_surface_count*2 : EOSD_SURFACES_INITIAL; | |
950 eosd_surfaces = realloc(eosd_surfaces, eosd_surface_count * sizeof(*eosd_surfaces)); | |
951 eosd_targets = realloc(eosd_targets, eosd_surface_count * sizeof(*eosd_targets)); | |
29713 | 952 for (j = found; j < eosd_surface_count; j++) { |
28675 | 953 eosd_surfaces[j].surface = VDP_INVALID_HANDLE; |
954 eosd_surfaces[j].in_use = 0; | |
955 } | |
956 } | |
957 vdp_st = vdp_bitmap_surface_create(vdp_device, VDP_RGBA_FORMAT_A8, | |
958 i->w, i->h, VDP_TRUE, &eosd_surfaces[found].surface); | |
959 CHECK_ST_WARNING("EOSD: error when creating surface") | |
960 eosd_surfaces[found].w = i->w; | |
961 eosd_surfaces[found].h = i->h; | |
962 } | |
963 eosd_surfaces[found].in_use = 1; | |
964 eosd_targets[eosd_render_count].surface = eosd_surfaces[found].surface; | |
965 destRect.x0 = 0; | |
966 destRect.y0 = 0; | |
967 destRect.x1 = i->w; | |
968 destRect.y1 = i->h; | |
969 vdp_st = vdp_bitmap_surface_putbits_native(eosd_targets[eosd_render_count].surface, | |
970 (const void *) &i->bitmap, &i->stride, &destRect); | |
971 CHECK_ST_WARNING("EOSD: putbits failed") | |
972 eosd_render_count++; | |
973 } | |
974 | |
975 eosd_skip_upload: | |
976 eosd_render_count = 0; | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
977 for (i = eosd_image_first(imgs); i; i = eosd_image_next(imgs)) { |
28675 | 978 // Render dest, color, etc. |
29713 | 979 eosd_targets[eosd_render_count].color.alpha = 1.0 - ((i->color >> 0) & 0xff) / 255.0; |
980 eosd_targets[eosd_render_count].color.blue = ((i->color >> 8) & 0xff) / 255.0; | |
981 eosd_targets[eosd_render_count].color.green = ((i->color >> 16) & 0xff) / 255.0; | |
982 eosd_targets[eosd_render_count].color.red = ((i->color >> 24) & 0xff) / 255.0; | |
983 eosd_targets[eosd_render_count].dest.x0 = i->dst_x; | |
984 eosd_targets[eosd_render_count].dest.y0 = i->dst_y; | |
985 eosd_targets[eosd_render_count].dest.x1 = i->w + i->dst_x; | |
986 eosd_targets[eosd_render_count].dest.y1 = i->h + i->dst_y; | |
987 eosd_targets[eosd_render_count].source.x0 = 0; | |
988 eosd_targets[eosd_render_count].source.y0 = 0; | |
989 eosd_targets[eosd_render_count].source.x1 = i->w; | |
990 eosd_targets[eosd_render_count].source.y1 = i->h; | |
28675 | 991 eosd_render_count++; |
992 } | |
993 } | |
994 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
995 static void draw_osd(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
996 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
997 mp_msg(MSGT_VO, MSGL_DBG2, "DRAW_OSD\n"); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
998 |
29735 | 999 if (handle_preemption() < 0) |
1000 return; | |
1001 | |
28598
4172d83194f2
Extend calc_src_dst_rects to also calculate the border values needed for
reimar
parents:
28582
diff
changeset
|
1002 vo_draw_text_ext(vo_dwidth, vo_dheight, border_x, border_y, border_x, border_y, |
4172d83194f2
Extend calc_src_dst_rects to also calculate the border values needed for
reimar
parents:
28582
diff
changeset
|
1003 vid_width, vid_height, draw_osd_I8A8); |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1004 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1005 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1006 static void flip_page(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1007 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1008 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1009 mp_msg(MSGT_VO, MSGL_DBG2, "\nFLIP_PAGE VID:%u -> OUT:%u\n", |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1010 surface_render[vid_surface_num].surface, output_surfaces[surface_num]); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1011 |
29735 | 1012 if (handle_preemption() < 0) |
1013 return; | |
1014 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1015 vdp_st = vdp_presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1016 vo_dwidth, vo_dheight, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1017 0); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1018 CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1019 |
28696
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
1020 surface_num = (surface_num + 1) % NUM_OUTPUT_SURFACES; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1021 visible_buf = 1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1022 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1023 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1024 static int draw_slice(uint8_t *image[], int stride[], int w, int h, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1025 int x, int y) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1026 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1027 VdpStatus vdp_st; |
36322 | 1028 struct vdpau_frame_data *rndr = (struct vdpau_frame_data *)image[0]; |
1029 int max_refs = image_format == IMGFMT_VDPAU_H264 ? ((VdpPictureInfoH264 *)rndr->info)->num_ref_frames : 2; | |
29735 | 1030 |
1031 if (handle_preemption() < 0) | |
1032 return VO_TRUE; | |
1033 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1034 if (!IMGFMT_IS_VDPAU(image_format)) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1035 return VO_FALSE; |
28989 | 1036 if ((decoder == VDP_INVALID_HANDLE || decoder_max_refs < max_refs) |
29828
fe055da6637c
Fail in query_format() if a VDPAU decoder is not available.
cehoyos
parents:
29827
diff
changeset
|
1037 && !create_vdp_decoder(image_format, vid_width, vid_height, max_refs)) |
28989 | 1038 return VO_FALSE; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29234
diff
changeset
|
1039 |
36322 | 1040 vdp_st = vdp_decoder_render(decoder, rndr->render_state->surface, rndr->info, rndr->bitstream_buffers_used, rndr->bitstream_buffers); |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1041 CHECK_ST_WARNING("Failed VDPAU decoder rendering"); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1042 return VO_TRUE; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1043 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1044 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1045 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1046 static struct vdpau_render_state *get_surface(int number) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1047 { |
35193 | 1048 if (number >= MAX_VIDEO_SURFACES) |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1049 return NULL; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1050 if (surface_render[number].surface == VDP_INVALID_HANDLE) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1051 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1052 vdp_st = vdp_video_surface_create(vdp_device, vdp_chroma_type, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1053 vid_width, vid_height, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1054 &surface_render[number].surface); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1055 CHECK_ST_WARNING("Error when calling vdp_video_surface_create") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1056 if (vdp_st != VDP_STATUS_OK) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1057 return NULL; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1058 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1059 mp_msg(MSGT_VO, MSGL_DBG2, "VID CREATE: %u\n", surface_render[number].surface); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1060 return &surface_render[number]; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1061 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1062 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1063 static uint32_t draw_image(mp_image_t *mpi) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1064 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1065 if (IMGFMT_IS_VDPAU(image_format)) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1066 struct vdpau_render_state *rndr = mpi->priv; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1067 vid_surface_num = rndr - surface_render; |
30009 | 1068 mpi->usage_count++; |
1069 if (deint_mpi[1]) | |
1070 deint_mpi[1]->usage_count--; | |
1071 deint_mpi[1] = deint_mpi[0]; | |
1072 deint_mpi[0] = mpi; | |
29756 | 1073 } else if (image_format == IMGFMT_BGRA) { |
1074 VdpStatus vdp_st; | |
1075 VdpRect r = {0, 0, vid_width, vid_height}; | |
36205
c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
reimar
parents:
36197
diff
changeset
|
1076 vdp_st = vdp_output_surface_put_bits_native(rgba_surface, |
29756 | 1077 (void const*const*)mpi->planes, |
1078 mpi->stride, &r); | |
1079 CHECK_ST_ERROR("Error when calling vdp_output_surface_put_bits_native") | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1080 } else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1081 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1082 void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]}; |
28933
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
1083 struct vdpau_render_state *rndr = get_surface(deint_counter); |
29018
b04ff8b244bb
New VDPAU deinterlacing code needs one reference surface less for software decoding.
cehoyos
parents:
29017
diff
changeset
|
1084 deint_counter = (deint_counter + 1) % 3; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1085 vid_surface_num = rndr - surface_render; |
29070 | 1086 if (image_format == IMGFMT_NV12) |
1087 destdata[1] = destdata[2]; | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1088 vdp_st = vdp_video_surface_put_bits_y_cb_cr(rndr->surface, |
29066
ab51a502ebb5
Add support for IMGFMT_YUY2 and IMGFMT_UYVY to vo vdpau.
cehoyos
parents:
29065
diff
changeset
|
1089 vdp_pixel_format, |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1090 (const void *const*)destdata, |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1091 mpi->stride); // pitch |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1092 CHECK_ST_ERROR("Error when calling vdp_video_surface_put_bits_y_cb_cr") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1093 } |
29054
d865fa57c316
10l: Don't use MP_IMGFIELD_TOP_FIRST if MP_IMGFIELD_ORDERED is not set.
cehoyos
parents:
29026
diff
changeset
|
1094 if (mpi->fields & MP_IMGFIELD_ORDERED) |
29055 | 1095 top_field_first = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST); |
29054
d865fa57c316
10l: Don't use MP_IMGFIELD_TOP_FIRST if MP_IMGFIELD_ORDERED is not set.
cehoyos
parents:
29026
diff
changeset
|
1096 else |
d865fa57c316
10l: Don't use MP_IMGFIELD_TOP_FIRST if MP_IMGFIELD_ORDERED is not set.
cehoyos
parents:
29026
diff
changeset
|
1097 top_field_first = 1; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1098 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1099 video_to_output_surface(); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1100 return VO_TRUE; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1101 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1102 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1103 static uint32_t get_image(mp_image_t *mpi) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1104 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1105 struct vdpau_render_state *rndr; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1106 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1107 // no dr for non-decoding for now |
29716 | 1108 if (!IMGFMT_IS_VDPAU(image_format)) |
1109 return VO_FALSE; | |
1110 if (mpi->type != MP_IMGTYPE_NUMBERED) | |
1111 return VO_FALSE; | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1112 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1113 rndr = get_surface(mpi->number); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1114 if (!rndr) { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1115 mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] no surfaces available in get_image\n"); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1116 // TODO: this probably breaks things forever, provide a dummy buffer? |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1117 return VO_FALSE; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1118 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1119 mpi->flags |= MP_IMGFLAG_DIRECT; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1120 mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1121 mpi->planes[0] = mpi->planes[1] = mpi->planes[2] = NULL; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1122 // hack to get around a check and to avoid a special-case in vd_ffmpeg.c |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1123 mpi->planes[0] = (void *)rndr; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1124 mpi->num_planes = 1; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1125 mpi->priv = rndr; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1126 return VO_TRUE; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1127 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1128 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1129 static int query_format(uint32_t format) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1130 { |
29752 | 1131 int default_flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_EOSD | VFCAP_EOSD_UNSCALED | VFCAP_FLIP; |
36332
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
1132 // if we are already using it we obviously support it |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
1133 if (format == image_format && decoder != VDP_INVALID_HANDLE) |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
1134 return default_flags; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1135 switch (format) { |
29756 | 1136 case IMGFMT_BGRA: |
1137 if (force_mixer) | |
1138 return 0; | |
29713 | 1139 case IMGFMT_YV12: |
1140 case IMGFMT_I420: | |
1141 case IMGFMT_IYUV: | |
1142 case IMGFMT_NV12: | |
1143 case IMGFMT_YUY2: | |
1144 case IMGFMT_UYVY: | |
1145 return default_flags | VOCAP_NOSLICES; | |
1146 case IMGFMT_VDPAU_MPEG1: | |
1147 case IMGFMT_VDPAU_MPEG2: | |
1148 case IMGFMT_VDPAU_H264: | |
1149 case IMGFMT_VDPAU_WMV3: | |
1150 case IMGFMT_VDPAU_VC1: | |
29843
f6d56a15f1d8
Support VDPAU hardware accelerated decoding of MPEG-4 ASP on capable
cehoyos
parents:
29830
diff
changeset
|
1151 case IMGFMT_VDPAU_MPEG4: |
36444 | 1152 // Note: this will break the current decoder |
1153 // Not all implementations support safely instantiating | |
1154 // a second decoder, so this is the "lesser evil" | |
1155 if (create_vdp_decoder(format, 48, 48, 2)) { | |
1156 vdp_decoder_destroy(decoder); | |
1157 decoder = VDP_INVALID_HANDLE; | |
1158 decoder_max_refs = -1; | |
29829 | 1159 return default_flags; |
36444 | 1160 } |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1161 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1162 return 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1163 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1164 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1165 static void DestroyVdpauObjects(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1166 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1167 int i; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1168 VdpStatus vdp_st; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1169 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1170 free_video_specific(); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1171 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1172 vdp_st = vdp_presentation_queue_destroy(vdp_flip_queue); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1173 CHECK_ST_WARNING("Error when calling vdp_presentation_queue_destroy") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1174 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1175 vdp_st = vdp_presentation_queue_target_destroy(vdp_flip_target); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1176 CHECK_ST_WARNING("Error when calling vdp_presentation_queue_target_destroy") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1177 |
28696
fdc03572004c
Change code to actually work when NUM_OUTPUT_SURFACES is changed.
reimar
parents:
28689
diff
changeset
|
1178 for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) { |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1179 vdp_st = vdp_output_surface_destroy(output_surfaces[i]); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1180 output_surfaces[i] = VDP_INVALID_HANDLE; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1181 CHECK_ST_WARNING("Error when calling vdp_output_surface_destroy") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1182 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1183 |
28675 | 1184 for (i = 0; i<eosd_surface_count; i++) { |
1185 if (eosd_surfaces[i].surface != VDP_INVALID_HANDLE) { | |
1186 vdp_st = vdp_bitmap_surface_destroy(eosd_surfaces[i].surface); | |
1187 CHECK_ST_WARNING("Error when calling vdp_bitmap_surface_destroy") | |
1188 } | |
1189 eosd_surfaces[i].surface = VDP_INVALID_HANDLE; | |
1190 } | |
1191 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1192 vdp_st = vdp_device_destroy(vdp_device); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1193 CHECK_ST_WARNING("Error when calling vdp_device_destroy") |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1194 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1195 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1196 static void uninit(void) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1197 { |
29751
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1198 int i; |
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1199 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1200 if (!vo_config_count) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1201 return; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1202 visible_buf = 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1203 |
29751
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1204 for (i = 0; i < MAX_VIDEO_SURFACES; i++) { |
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1205 // Allocated in ff_vdpau_add_data_chunk() |
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1206 av_freep(&surface_render[i].bitstream_buffers); |
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1207 surface_render[i].bitstream_buffers_allocated = 0; |
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1208 } |
593354e0500d
Free memory allocated in ff_vdpau_add_data_chunk() on uninit.
cehoyos
parents:
29735
diff
changeset
|
1209 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1210 /* Destroy all vdpau objects */ |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1211 DestroyVdpauObjects(); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1212 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1213 free(index_data); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1214 index_data = NULL; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1215 |
28675 | 1216 free(eosd_surfaces); |
1217 eosd_surfaces = NULL; | |
1218 free(eosd_targets); | |
1219 eosd_targets = NULL; | |
1220 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1221 #ifdef CONFIG_XF86VM |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1222 vo_vm_close(); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1223 #endif |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1224 vo_x11_uninit(); |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1225 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1226 |
28828
56eee6ffba9b
Make data related to suboption parsing const in libvo
reimar
parents:
28807
diff
changeset
|
1227 static const opt_t subopts[] = { |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1228 {"deint", OPT_ARG_INT, &deint, (opt_test_f)int_non_neg}, |
28944
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
1229 {"chroma-deint", OPT_ARG_BOOL, &chroma_deint, NULL}, |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1230 {"pullup", OPT_ARG_BOOL, &pullup, NULL}, |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1231 {"denoise", OPT_ARG_FLOAT, &denoise, NULL}, |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1232 {"sharpen", OPT_ARG_FLOAT, &sharpen, NULL}, |
29727 | 1233 {"colorspace", OPT_ARG_INT, &colorspace, NULL}, |
29756 | 1234 {"force-mixer", OPT_ARG_BOOL, &force_mixer, NULL}, |
29781
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
1235 {"hqscaling", OPT_ARG_INT, &hqscaling, (opt_test_f)int_non_neg}, |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1236 {NULL} |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1237 }; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1238 |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1239 static const char help_msg[] = |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1240 "\n-vo vdpau command line help:\n" |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1241 "Example: mplayer -vo vdpau:deint=2\n" |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1242 "\nOptions:\n" |
28707
a81065b771e7
Document that all vdpau deinterlacers respect -field-dominance.
cehoyos
parents:
28702
diff
changeset
|
1243 " deint (all modes > 0 respect -field-dominance)\n" |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1244 " 0: no deinterlacing\n" |
28708 | 1245 " 1: only show first field\n" |
28956
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
1246 " 2: bob deinterlacing\n" |
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
1247 " 3: temporal deinterlacing (resource-hungry)\n" |
6d0da4fd4544
Allow to use vdpau temporal deinterlacers with hardware accelerated decoding.
cehoyos
parents:
28944
diff
changeset
|
1248 " 4: temporal-spatial deinterlacing (very resource-hungry)\n" |
28944
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
1249 " chroma-deint\n" |
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
1250 " Operate on luma and chroma when using temporal deinterlacing (default)\n" |
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
1251 " Use nochroma-deint to speed up temporal deinterlacing\n" |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1252 " pullup\n" |
30758
33765d7d6e0a
Documentation: Add linebreak and try to be less ambiguous.
cehoyos
parents:
30462
diff
changeset
|
1253 " Try to skip deinterlacing for progressive frames\n" |
33765d7d6e0a
Documentation: Add linebreak and try to be less ambiguous.
cehoyos
parents:
30462
diff
changeset
|
1254 " (needs at least temporal deinterlacing, useful for telecined content)\n" |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1255 " denoise\n" |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1256 " Apply denoising, argument is strength from 0.0 to 1.0\n" |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1257 " sharpen\n" |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1258 " Apply sharpening or softening, argument is strength from -1.0 to 1.0\n" |
29727 | 1259 " colorspace\n" |
1260 " 0: guess based on video resolution\n" | |
1261 " 1: ITU-R BT.601 (default)\n" | |
1262 " 2: ITU-R BT.709\n" | |
29729 | 1263 " 3: SMPTE-240M\n" |
29781
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
1264 " hqscaling\n" |
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
1265 " 0: default VDPAU scaler\n" |
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
1266 " 1-9: high quality VDPAU scaler (needs capable hardware)\n" |
29756 | 1267 " force-mixer\n" |
1268 " Use the VDPAU mixer (default)\n" | |
1269 " Use noforce-mixer to allow BGRA output (disables all above options)\n" | |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1270 ; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1271 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1272 static int preinit(const char *arg) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1273 { |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1274 int i; |
36332
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
1275 image_format = 0; |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
1276 vid_width = 0; |
9de70162224b
Avoid reinitializing VDPAU on e.g. simple aspect changes.
reimar
parents:
36322
diff
changeset
|
1277 vid_height = 0; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1278 |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1279 deint = 0; |
28709
4e89476f8952
Do not forget the chosen deinterlacer for -vo vdpau.
cehoyos
parents:
28708
diff
changeset
|
1280 deint_type = 3; |
28933
b0badbd680c6
Initial support for advanced VDPAU deinterlacers (software-decoded video
cehoyos
parents:
28892
diff
changeset
|
1281 deint_counter = 0; |
29017
c9a2d95c580a
New vdpau deinterlacing code needs one reference surface less.
cehoyos
parents:
29016
diff
changeset
|
1282 deint_mpi[0] = deint_mpi[1] = NULL; |
28944
cb18135338dd
Add chroma-deint option to vo vdpau (nochroma-deint speeds up deinterlacing).
cehoyos
parents:
28936
diff
changeset
|
1283 chroma_deint = 1; |
29713 | 1284 pullup = 0; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1285 denoise = 0; |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1286 sharpen = 0; |
29727 | 1287 colorspace = 1; |
29756 | 1288 force_mixer = 1; |
29781
508417d485d6
Add new VDPAU feature high-quality-scaling (and require newer library).
cehoyos
parents:
29757
diff
changeset
|
1289 hqscaling = 0; |
28638
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1290 if (subopt_parse(arg, subopts) != 0) { |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1291 mp_msg(MSGT_VO, MSGL_FATAL, help_msg); |
7b16ccf423b4
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
reimar
parents:
28611
diff
changeset
|
1292 return -1; |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1293 } |
28709
4e89476f8952
Do not forget the chosen deinterlacer for -vo vdpau.
cehoyos
parents:
28708
diff
changeset
|
1294 if (deint) |
4e89476f8952
Do not forget the chosen deinterlacer for -vo vdpau.
cehoyos
parents:
28708
diff
changeset
|
1295 deint_type = deint; |
29729 | 1296 if (colorspace < 0 || colorspace > 3) { |
29727 | 1297 mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] Invalid color space specified, " |
1298 "using BT.601\n"); | |
1299 colorspace = 1; | |
1300 } | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1301 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1302 // full grayscale palette. |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1303 for (i = 0; i < PALETTE_SIZE; ++i) |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1304 palette[i] = (i << 16) | (i << 8) | i; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1305 index_data = NULL; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1306 index_data_size = 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1307 |
28675 | 1308 eosd_surface_count = eosd_render_count = 0; |
1309 eosd_surfaces = NULL; | |
1310 eosd_targets = NULL; | |
1311 | |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1312 procamp.struct_version = VDP_PROCAMP_VERSION; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1313 procamp.brightness = 0.0; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1314 procamp.contrast = 1.0; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1315 procamp.saturation = 1.0; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1316 procamp.hue = 0.0; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1317 |
36371
bbf289ad03f2
vo_vdpau: Initialize variables before, not after setup code.
reimar
parents:
36332
diff
changeset
|
1318 if (!vo_init() || win_x11_init_vdpau_procs()) |
bbf289ad03f2
vo_vdpau: Initialize variables before, not after setup code.
reimar
parents:
36332
diff
changeset
|
1319 return -1; |
bbf289ad03f2
vo_vdpau: Initialize variables before, not after setup code.
reimar
parents:
36332
diff
changeset
|
1320 |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1321 return 0; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1322 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1323 |
33320 | 1324 static int get_equalizer(const char *name, int *value) |
29713 | 1325 { |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1326 if (!strcasecmp(name, "brightness")) |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1327 *value = procamp.brightness * 100; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1328 else if (!strcasecmp(name, "contrast")) |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1329 *value = (procamp.contrast-1.0) * 100; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1330 else if (!strcasecmp(name, "saturation")) |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1331 *value = (procamp.saturation-1.0) * 100; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1332 else if (!strcasecmp(name, "hue")) |
28729 | 1333 *value = procamp.hue * 100 / M_PI; |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1334 else |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1335 return VO_NOTIMPL; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1336 return VO_TRUE; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1337 } |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1338 |
33320 | 1339 static int set_equalizer(const char *name, int value) |
29713 | 1340 { |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1341 if (!strcasecmp(name, "brightness")) |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1342 procamp.brightness = value / 100.0; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1343 else if (!strcasecmp(name, "contrast")) |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1344 procamp.contrast = value / 100.0 + 1.0; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1345 else if (!strcasecmp(name, "saturation")) |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1346 procamp.saturation = value / 100.0 + 1.0; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1347 else if (!strcasecmp(name, "hue")) |
28729 | 1348 procamp.hue = value / 100.0 * M_PI; |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1349 else |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1350 return VO_NOTIMPL; |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1351 |
29727 | 1352 return update_csc_matrix(); |
28725
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1353 } |
b9c26620ada7
Support brightness, contrast, hue and saturation adjustments via
cehoyos
parents:
28724
diff
changeset
|
1354 |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
33301
diff
changeset
|
1355 static int control(uint32_t request, void *data) |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1356 { |
29735 | 1357 if (handle_preemption() < 0) |
1358 return VO_FALSE; | |
1359 | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1360 switch (request) { |
29713 | 1361 case VOCTRL_GET_DEINTERLACE: |
1362 *(int*)data = deint; | |
1363 return VO_TRUE; | |
1364 case VOCTRL_SET_DEINTERLACE: | |
29756 | 1365 if (image_format == IMGFMT_BGRA) |
1366 return VO_NOTIMPL; | |
29713 | 1367 deint = *(int*)data; |
1368 if (deint) | |
1369 deint = deint_type; | |
1370 if (deint_type > 2) { | |
1371 VdpStatus vdp_st; | |
1372 VdpVideoMixerFeature features[1] = | |
1373 {deint_type == 3 ? | |
1374 VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL : | |
1375 VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL}; | |
1376 VdpBool feature_enables[1] = {deint ? VDP_TRUE : VDP_FALSE}; | |
1377 vdp_st = vdp_video_mixer_set_feature_enables(video_mixer, 1, | |
1378 features, | |
1379 feature_enables); | |
1380 CHECK_ST_WARNING("Error changing deinterlacing settings") | |
1381 } | |
1382 return VO_TRUE; | |
1383 case VOCTRL_QUERY_FORMAT: | |
1384 return query_format(*(uint32_t *)data); | |
1385 case VOCTRL_GET_IMAGE: | |
1386 return get_image(data); | |
1387 case VOCTRL_DRAW_IMAGE: | |
1388 return draw_image(data); | |
1389 case VOCTRL_GUISUPPORT: | |
1390 return VO_TRUE; | |
1391 case VOCTRL_BORDER: | |
1392 vo_x11_border(); | |
1393 resize(); | |
1394 return VO_TRUE; | |
1395 case VOCTRL_FULLSCREEN: | |
1396 vo_x11_fullscreen(); | |
1397 resize(); | |
1398 return VO_TRUE; | |
1399 case VOCTRL_GET_PANSCAN: | |
1400 return VO_TRUE; | |
1401 case VOCTRL_SET_PANSCAN: | |
1402 resize(); | |
1403 return VO_TRUE; | |
1404 case VOCTRL_SET_EQUALIZER: { | |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
32750
diff
changeset
|
1405 vf_equalizer_t *eq=data; |
29756 | 1406 if (image_format == IMGFMT_BGRA) |
1407 return VO_NOTIMPL; | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1408 |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
32750
diff
changeset
|
1409 return set_equalizer(eq->item, eq->value); |
29713 | 1410 } |
1411 case VOCTRL_GET_EQUALIZER: { | |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
32750
diff
changeset
|
1412 vf_equalizer_t *eq=data; |
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
32750
diff
changeset
|
1413 return get_equalizer(eq->item, &eq->value); |
29713 | 1414 } |
1415 case VOCTRL_ONTOP: | |
1416 vo_x11_ontop(); | |
1417 return VO_TRUE; | |
1418 case VOCTRL_UPDATE_SCREENINFO: | |
1419 update_xinerama_info(); | |
1420 return VO_TRUE; | |
1421 case VOCTRL_DRAW_EOSD: | |
1422 if (!data) | |
1423 return VO_FALSE; | |
1424 generate_eosd(data); | |
1425 draw_eosd(); | |
1426 return VO_TRUE; | |
1427 case VOCTRL_GET_EOSD_RES: { | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
1428 struct mp_eosd_settings *r = data; |
29713 | 1429 r->mt = r->mb = r->ml = r->mr = 0; |
30065
d5d20b8256b7
Some ugly hacks to make compiling against a newer external version of libass work.
reimar
parents:
30063
diff
changeset
|
1430 r->srcw = vid_width; r->srch = vid_height; |
29713 | 1431 if (vo_fs) { |
1432 r->w = vo_screenwidth; | |
1433 r->h = vo_screenheight; | |
1434 r->ml = r->mr = border_x; | |
1435 r->mt = r->mb = border_y; | |
1436 } else { | |
1437 r->w = vo_dwidth; | |
1438 r->h = vo_dheight; | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1439 } |
29713 | 1440 return VO_TRUE; |
1441 } | |
28582
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1442 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1443 return VO_NOTIMPL; |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1444 } |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1445 |
4d64f83e2fac
Add support for VDPAU video out, including hardware decoding.
reimar
parents:
diff
changeset
|
1446 /* @} */ |