Mercurial > mplayer.hg
comparison libvo/vo_vdpau.c @ 36205:c922d2550d20
VDPAU: fix RGBA output to use a surface of correct size and to redraw on resize.
author | reimar |
---|---|
date | Thu, 06 Jun 2013 13:03:50 +0000 |
parents | a3aaf74a68a1 |
children | 7227ed885f0c |
comparison
equal
deleted
inserted
replaced
36204:88c5a06d1db9 | 36205:c922d2550d20 |
---|---|
145 static VdpPreemptionCallbackRegister *vdp_preemption_callback_register; | 145 static VdpPreemptionCallbackRegister *vdp_preemption_callback_register; |
146 | 146 |
147 /* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */ | 147 /* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */ |
148 #define osd_surface output_surfaces[NUM_OUTPUT_SURFACES] | 148 #define osd_surface output_surfaces[NUM_OUTPUT_SURFACES] |
149 static VdpOutputSurface output_surfaces[NUM_OUTPUT_SURFACES + 1]; | 149 static VdpOutputSurface output_surfaces[NUM_OUTPUT_SURFACES + 1]; |
150 static VdpOutputSurface rgba_surface; | |
150 static VdpVideoSurface deint_surfaces[3]; | 151 static VdpVideoSurface deint_surfaces[3]; |
151 static mp_image_t *deint_mpi[2]; | 152 static mp_image_t *deint_mpi[2]; |
152 static int output_surface_width, output_surface_height; | 153 static int output_surface_width, output_surface_height; |
153 | 154 |
154 static VdpVideoMixer video_mixer; | 155 static VdpVideoMixer video_mixer; |
223 deint_surfaces[2] = deint_surfaces[1]; | 224 deint_surfaces[2] = deint_surfaces[1]; |
224 deint_surfaces[1] = deint_surfaces[0]; | 225 deint_surfaces[1] = deint_surfaces[0]; |
225 deint_surfaces[0] = surface; | 226 deint_surfaces[0] = surface; |
226 } | 227 } |
227 | 228 |
229 static const uint32_t rotate_flags[4] = { | |
230 VDP_OUTPUT_SURFACE_RENDER_ROTATE_0, | |
231 VDP_OUTPUT_SURFACE_RENDER_ROTATE_90, | |
232 VDP_OUTPUT_SURFACE_RENDER_ROTATE_180, | |
233 VDP_OUTPUT_SURFACE_RENDER_ROTATE_270 | |
234 }; | |
235 | |
228 static void video_to_output_surface(void) | 236 static void video_to_output_surface(void) |
229 { | 237 { |
230 VdpTime dummy; | 238 VdpTime dummy; |
231 VdpStatus vdp_st; | 239 VdpStatus vdp_st; |
232 int i; | 240 int i; |
241 if (image_format == IMGFMT_BGRA) { | |
242 vdp_st = vdp_output_surface_render_output_surface(output_surfaces[surface_num], | |
243 &out_rect_vid, | |
244 rgba_surface, | |
245 &src_rect_vid, NULL, NULL, | |
246 rotate_flags[vo_rotate & 3]); | |
247 CHECK_ST_WARNING("Error when calling vdp_output_surface_render_output_surface") | |
248 return; | |
249 } | |
233 if (vid_surface_num < 0) | 250 if (vid_surface_num < 0) |
234 return; | 251 return; |
235 | 252 |
236 if (deint < 2 || deint_surfaces[0] == VDP_INVALID_HANDLE) | 253 if (deint < 2 || deint_surfaces[0] == VDP_INVALID_HANDLE) |
237 push_deint_surface(surface_render[vid_surface_num].surface); | 254 push_deint_surface(surface_render[vid_surface_num].surface); |
263 NULL, &out_rect_vid, 0, NULL); | 280 NULL, &out_rect_vid, 0, NULL); |
264 CHECK_ST_WARNING("Error when calling vdp_video_mixer_render") | 281 CHECK_ST_WARNING("Error when calling vdp_video_mixer_render") |
265 push_deint_surface(surface_render[vid_surface_num].surface); | 282 push_deint_surface(surface_render[vid_surface_num].surface); |
266 } | 283 } |
267 } | 284 } |
268 | |
269 static const uint32_t rotate_flags[4] = { | |
270 VDP_OUTPUT_SURFACE_RENDER_ROTATE_0, | |
271 VDP_OUTPUT_SURFACE_RENDER_ROTATE_90, | |
272 VDP_OUTPUT_SURFACE_RENDER_ROTATE_180, | |
273 VDP_OUTPUT_SURFACE_RENDER_ROTATE_270 | |
274 }; | |
275 | 285 |
276 static void resize(void) | 286 static void resize(void) |
277 { | 287 { |
278 VdpStatus vdp_st; | 288 VdpStatus vdp_st; |
279 int i; | 289 int i; |
315 &output_surfaces[i]); | 325 &output_surfaces[i]); |
316 CHECK_ST_WARNING("Error when calling vdp_output_surface_create") | 326 CHECK_ST_WARNING("Error when calling vdp_output_surface_create") |
317 mp_msg(MSGT_VO, MSGL_DBG2, "OUT CREATE: %u\n", output_surfaces[i]); | 327 mp_msg(MSGT_VO, MSGL_DBG2, "OUT CREATE: %u\n", output_surfaces[i]); |
318 } | 328 } |
319 } | 329 } |
320 if (image_format == IMGFMT_BGRA) { | 330 video_to_output_surface(); |
321 vdp_st = vdp_output_surface_render_output_surface(output_surfaces[surface_num], | |
322 NULL, VDP_INVALID_HANDLE, | |
323 NULL, NULL, NULL, | |
324 rotate_flags[vo_rotate & 3]); | |
325 CHECK_ST_WARNING("Error when calling vdp_output_surface_render_output_surface") | |
326 vdp_st = vdp_output_surface_render_output_surface(output_surfaces[1 - surface_num], | |
327 NULL, VDP_INVALID_HANDLE, | |
328 NULL, NULL, NULL, | |
329 rotate_flags[vo_rotate & 3]); | |
330 CHECK_ST_WARNING("Error when calling vdp_output_surface_render_output_surface") | |
331 } else | |
332 video_to_output_surface(); | |
333 if (visible_buf) | 331 if (visible_buf) |
334 flip_page(); | 332 flip_page(); |
335 } | 333 } |
336 | 334 |
337 static void preemption_callback(VdpDevice device, void *context) | 335 static void preemption_callback(VdpDevice device, void *context) |
536 int i; | 534 int i; |
537 | 535 |
538 decoder = VDP_INVALID_HANDLE; | 536 decoder = VDP_INVALID_HANDLE; |
539 video_mixer = VDP_INVALID_HANDLE; | 537 video_mixer = VDP_INVALID_HANDLE; |
540 | 538 |
539 rgba_surface = VDP_INVALID_HANDLE; | |
540 | |
541 for (i = 0; i < 3; i++) | 541 for (i = 0; i < 3; i++) |
542 deint_surfaces[i] = VDP_INVALID_HANDLE; | 542 deint_surfaces[i] = VDP_INVALID_HANDLE; |
543 | 543 |
544 for (i = 0; i < 2; i++) | 544 for (i = 0; i < 2; i++) |
545 if (deint_mpi[i]) { | 545 if (deint_mpi[i]) { |
555 VdpStatus vdp_st; | 555 VdpStatus vdp_st; |
556 | 556 |
557 if (decoder != VDP_INVALID_HANDLE) | 557 if (decoder != VDP_INVALID_HANDLE) |
558 vdp_decoder_destroy(decoder); | 558 vdp_decoder_destroy(decoder); |
559 decoder_max_refs = -1; | 559 decoder_max_refs = -1; |
560 | |
561 if (rgba_surface != VDP_INVALID_HANDLE) { | |
562 vdp_st = vdp_output_surface_destroy(rgba_surface); | |
563 CHECK_ST_WARNING("Error destroying RGBA surface") | |
564 } | |
560 | 565 |
561 for (i = 0; i < MAX_VIDEO_SURFACES; i++) { | 566 for (i = 0; i < MAX_VIDEO_SURFACES; i++) { |
562 if (surface_render[i].surface != VDP_INVALID_HANDLE) { | 567 if (surface_render[i].surface != VDP_INVALID_HANDLE) { |
563 vdp_st = vdp_video_surface_destroy(surface_render[i].surface); | 568 vdp_st = vdp_video_surface_destroy(surface_render[i].surface); |
564 CHECK_ST_WARNING("Error when calling vdp_video_surface_destroy") | 569 CHECK_ST_WARNING("Error when calling vdp_video_surface_destroy") |
660 */ | 665 */ |
661 static int config(uint32_t width, uint32_t height, uint32_t d_width, | 666 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
662 uint32_t d_height, uint32_t flags, char *title, | 667 uint32_t d_height, uint32_t flags, char *title, |
663 uint32_t format) | 668 uint32_t format) |
664 { | 669 { |
670 VdpStatus vdp_st; | |
665 XVisualInfo vinfo; | 671 XVisualInfo vinfo; |
666 XSetWindowAttributes xswa; | 672 XSetWindowAttributes xswa; |
667 XWindowAttributes attribs; | 673 XWindowAttributes attribs; |
668 unsigned long xswamask; | 674 unsigned long xswamask; |
669 int depth; | 675 int depth; |
739 vdp_chroma_type = VDP_CHROMA_TYPE_422; | 745 vdp_chroma_type = VDP_CHROMA_TYPE_422; |
740 break; | 746 break; |
741 case IMGFMT_UYVY: | 747 case IMGFMT_UYVY: |
742 vdp_pixel_format = VDP_YCBCR_FORMAT_UYVY; | 748 vdp_pixel_format = VDP_YCBCR_FORMAT_UYVY; |
743 vdp_chroma_type = VDP_CHROMA_TYPE_422; | 749 vdp_chroma_type = VDP_CHROMA_TYPE_422; |
750 break; | |
751 case IMGFMT_BGRA: | |
752 vdp_st = vdp_output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, | |
753 vid_width, vid_height, | |
754 &rgba_surface); | |
755 CHECK_ST_ERROR("Error creating RGBA surface") | |
756 break; | |
744 } | 757 } |
745 if (create_vdp_mixer(vdp_chroma_type)) | 758 if (create_vdp_mixer(vdp_chroma_type)) |
746 return -1; | 759 return -1; |
747 | 760 |
748 surface_num = 0; | 761 surface_num = 0; |
1038 deint_mpi[1] = deint_mpi[0]; | 1051 deint_mpi[1] = deint_mpi[0]; |
1039 deint_mpi[0] = mpi; | 1052 deint_mpi[0] = mpi; |
1040 } else if (image_format == IMGFMT_BGRA) { | 1053 } else if (image_format == IMGFMT_BGRA) { |
1041 VdpStatus vdp_st; | 1054 VdpStatus vdp_st; |
1042 VdpRect r = {0, 0, vid_width, vid_height}; | 1055 VdpRect r = {0, 0, vid_width, vid_height}; |
1043 vdp_st = vdp_output_surface_put_bits_native(output_surfaces[2], | 1056 vdp_st = vdp_output_surface_put_bits_native(rgba_surface, |
1044 (void const*const*)mpi->planes, | 1057 (void const*const*)mpi->planes, |
1045 mpi->stride, &r); | 1058 mpi->stride, &r); |
1046 CHECK_ST_ERROR("Error when calling vdp_output_surface_put_bits_native") | 1059 CHECK_ST_ERROR("Error when calling vdp_output_surface_put_bits_native") |
1047 vdp_st = vdp_output_surface_render_output_surface(output_surfaces[surface_num], | |
1048 &out_rect_vid, | |
1049 output_surfaces[2], | |
1050 &src_rect_vid, NULL, NULL, | |
1051 rotate_flags[vo_rotate & 3]); | |
1052 CHECK_ST_ERROR("Error when calling vdp_output_surface_render_output_surface") | |
1053 } else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) { | 1060 } else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) { |
1054 VdpStatus vdp_st; | 1061 VdpStatus vdp_st; |
1055 void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]}; | 1062 void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]}; |
1056 struct vdpau_render_state *rndr = get_surface(deint_counter); | 1063 struct vdpau_render_state *rndr = get_surface(deint_counter); |
1057 deint_counter = (deint_counter + 1) % 3; | 1064 deint_counter = (deint_counter + 1) % 3; |
1268 video_mixer = VDP_INVALID_HANDLE; | 1275 video_mixer = VDP_INVALID_HANDLE; |
1269 for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) | 1276 for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) |
1270 output_surfaces[i] = VDP_INVALID_HANDLE; | 1277 output_surfaces[i] = VDP_INVALID_HANDLE; |
1271 vdp_flip_queue = VDP_INVALID_HANDLE; | 1278 vdp_flip_queue = VDP_INVALID_HANDLE; |
1272 output_surface_width = output_surface_height = -1; | 1279 output_surface_width = output_surface_height = -1; |
1280 rgba_surface = VDP_INVALID_HANDLE; | |
1273 | 1281 |
1274 // full grayscale palette. | 1282 // full grayscale palette. |
1275 for (i = 0; i < PALETTE_SIZE; ++i) | 1283 for (i = 0; i < PALETTE_SIZE; ++i) |
1276 palette[i] = (i << 16) | (i << 8) | i; | 1284 palette[i] = (i << 16) | (i << 8) | i; |
1277 index_data = NULL; | 1285 index_data = NULL; |