From b87ce8bc96657c0b2d9b7fc51ed4bc1661d53270 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 14 Oct 2009 04:12:10 +0300 Subject: vo_vdpau: Modify frame buffering code Clean up code related to frame buffering and generate pts information also for the next frame in the output queue. The timing information will be used in a following framedrop patch. This commit adds one frame of buffering delay in vo_vdpau and increases the number of buffered vdpau video surfaces from 3 to 4. The delay increase makes it more important to fix remaining code in MPlayer that doesn't deal well with filter/VO delay; OTOH it should help any decoding/filtering parallelism in the underlying VDPAU implementation as now filtering a frame for display can happen while the next one is being decoded. --- libvo/video_out.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libvo/video_out.h') diff --git a/libvo/video_out.h b/libvo/video_out.h index 9bbfd3dc41..9e6de0842e 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -30,6 +30,8 @@ #include "libmpcodecs/img_format.h" //#include "vidix/vidix.h" +#define MP_NOPTS_VALUE (-1LL<<63) + #define VO_EVENT_EXPOSE 1 #define VO_EVENT_RESIZE 2 #define VO_EVENT_KEYPRESS 4 @@ -231,6 +233,7 @@ struct vo { bool frame_loaded; // Is there a next frame the VO could flip to? double next_pts; // pts value of the next frame if any + double next_pts2; // optional pts of frame after that const struct vo_driver *driver; void *priv; -- cgit v1.2.3 From 201bef7ee150f9d852996b379c926ba0c47320d5 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 15 Nov 2009 04:39:22 +0200 Subject: Implement vsync-aware frame timing for VDPAU Main things added are custom frame dropping for VDPAU to work around the display FPS limit, frame timing adjustment to avoid jitter when video frame times keep falling near vsyncs, and use of VDPAU's timing feature to keep one future frame queued in advance. NVIDIA's VDPAU implementation refuses to change the displayed frame more than once per vsync. This set a limit on how much video could be sped up, and caused problems for nearly all videos on low-FPS video projectors (playing 24 FPS video on a 24 FPS projector would not work reliably as MPlayer may need to slightly speed up the video for AV sync). This commit adds a framedrop mechanism that drops some frames so that no more than one is sent for display per vsync. The code tries to select the dropped frames smartly, selecting the best one to show for each vsync. Because of the timing features needed the drop functionality currently does not work if the correct-pts option is disabled. The code also adjusts frame timing slightly to avoid jitter. If you for example play 24 FPS video content on a 72 FPS display then normally a frame would be shown for 3 vsyncs, but if the frame times happen to fall near vsyncs and change between just before and just after then there could be frames alternating between 2 and 4 vsyncs. The code changes frame timing by up to one quarter vsync interval to avoid this. The above functionality depends on having reliable vsync timing information available. The display refresh rate is not directly provided by the VDPAU API. The current code uses information from the XF86VidMode extension if available; I'm not sure how common cases where that is inaccurate are. The refresh rate can be specified manually if necessary. After the changes in this commit MPlayer now always tries to keep one frame queued for future display using VDPAU's internal timing mechanism (however no more than 50 ms to the future). This should make video playback somewhat more robust against timing inaccuracies caused by system load. --- libvo/video_out.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libvo/video_out.h') diff --git a/libvo/video_out.h b/libvo/video_out.h index 9e6de0842e..50602e83a4 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -200,6 +200,7 @@ struct vo_driver { * Blit/Flip buffer to the screen. Must be called after each frame! */ void (*flip_page)(struct vo *vo); + void (*flip_page_timed)(struct vo *vo, unsigned int pts_us, int duration); /* * This func is called after every frames to handle keyboard and @@ -277,7 +278,7 @@ int vo_get_buffered_frame(struct vo *vo, bool eof); int vo_draw_frame(struct vo *vo, uint8_t *src[]); int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y); void vo_draw_osd(struct vo *vo, struct osd_state *osd); -void vo_flip_page(struct vo *vo); +void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration); void vo_check_events(struct vo *vo); void vo_seek_reset(struct vo *vo); void vo_destroy(struct vo *vo); -- cgit v1.2.3 From 98ee8dd15976501157c894ec385c4c551c6614ad Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 15 Nov 2009 15:21:40 +0200 Subject: Add yuv_colorspace property, implemented in vo_vdpau and vo_xv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a property to select YUV colorspace. Currently implemented only in vo_vdpau and vo_xv. Allows switching between BT.601, BT.709 and SMPTE-240M (vdpau only). The xv support uses the "XV_ITURBT_709" attribute. At least my NVIDIA card supports that; I don't know whether other xv implementations do. Bind the colorspace switch to the 'c' key by default. 'c' is currently used by vo_sdl for some fullscreen mode change thing, but at the moment that does not conflict and if it will in the future then vo_sdl can change. VDPAU part based on a patch from Lauri Mylläri --- libvo/video_out.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libvo/video_out.h') diff --git a/libvo/video_out.h b/libvo/video_out.h index 50602e83a4..17c387a320 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -88,6 +88,9 @@ typedef struct { #define VOCTRL_UPDATE_SCREENINFO 32 +#define VOCTRL_SET_YUV_COLORSPACE 33 +#define VOCTRL_GET_YUV_COLORSPACE 34 + // Vo can be used by xover #define VOCTRL_XOVERLAY_SUPPORT 22 -- cgit v1.2.3