From 67a5bb95eee9598a8bfdc2e93163251e4f5fb625 Mon Sep 17 00:00:00 2001 From: cehoyos Date: Thu, 3 Jun 2010 08:17:10 +0000 Subject: [PATCH 1/7] Raise LIBASS_VERSION, forgotten in r31293. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31308 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libass/ass.h b/libass/ass.h index 03b690c063..c1053b4e7c 100644 --- a/libass/ass.h +++ b/libass/ass.h @@ -25,7 +25,7 @@ #include #include "ass_types.h" -#define LIBASS_VERSION 0x00908000 +#define LIBASS_VERSION 0x00910000 /* * A linked list of images produced by an ass renderer. From de6a0324d8eb70b70968d4129d4aee8e536dd68f Mon Sep 17 00:00:00 2001 From: cehoyos Date: Thu, 3 Jun 2010 08:17:51 +0000 Subject: [PATCH 2/7] Simplify libass version check. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31309 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mplayer.c b/mplayer.c index 10c4dc3aad..a0a4c19f20 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2581,7 +2581,7 @@ static int seek(MPContext *mpctx, double amount, int style) vobsub_seek(vo_vobsub, mpctx->sh_video->pts); } -#if defined(CONFIG_ASS_INTERNAL) || defined(LIBASS_VERSION) && LIBASS_VERSION > 0x00909000 +#if defined(LIBASS_VERSION) && LIBASS_VERSION >= 0x00910000 if (ass_enabled && mpctx->d_sub->sh && ((sh_sub_t *)mpctx->d_sub->sh)->ass_track) ass_flush_events(((sh_sub_t *)mpctx->d_sub->sh)->ass_track); #endif From d6d87593a7bb372ad34b3c8f1901b95b86e38e1f Mon Sep 17 00:00:00 2001 From: siretart Date: Thu, 3 Jun 2010 17:37:58 +0000 Subject: [PATCH 3/7] vo_yuv4mpeg: disable RGB support when compiling against a shared libswscale This avoids using swscale internals when compiling against a shared libswscale. Patch inspired by Uoti Urpala's work in his git branch: http://repo.or.cz/w/mplayer.git/commitdiff/cd4e8dc1fa2863dcce62a44dd9ea105f9f9288f4 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31310 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_yuv4mpeg.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libvo/vo_yuv4mpeg.c b/libvo/vo_yuv4mpeg.c index f4cbfb1639..d06e79903d 100644 --- a/libvo/vo_yuv4mpeg.c +++ b/libvo/vo_yuv4mpeg.c @@ -56,7 +56,9 @@ #include "fastmemcpy.h" #include "libswscale/swscale.h" +#ifdef CONFIG_LIBSWSCALE_A #include "libswscale/rgb2rgb.h" +#endif #include "libmpcodecs/vf_scale.h" #include "libavutil/rational.h" @@ -228,6 +230,7 @@ static void draw_osd(void) vo_draw_text(image_width, image_height, draw_alpha); } +#ifdef CONFIG_LIBSWSCALE_A static void deinterleave_fields(uint8_t *ptr, const int stride, const int img_height) { @@ -258,6 +261,7 @@ static void deinterleave_fields(uint8_t *ptr, const int stride, } free(line_state); } +#endif static void vo_y4m_write(const void *ptr, const size_t num_bytes) { @@ -318,14 +322,15 @@ static int write_last_frame(void) static void flip_page (void) { - uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower; - int rgb_stride, uv_stride, field_height; - unsigned int i, low_ofs; - fprintf(yuv_out, "FRAME\n"); +#ifdef CONFIG_LIBSWSCALE_A if (using_format != IMGFMT_YV12) { + uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower; + int rgb_stride, uv_stride, field_height; + unsigned int i, low_ofs; + rgb_stride = image_width * 3; uv_stride = image_width / 2; @@ -374,6 +379,7 @@ static void flip_page (void) image_width, image_height, image_width, uv_stride, rgb_stride); } +#endif /* Write progressive frame */ vo_y4m_write(image, write_bytes); From 9343d1cb2d6b01e5c08a6a82f5b2c43d251c868e Mon Sep 17 00:00:00 2001 From: reimar Date: Thu, 3 Jun 2010 20:39:41 +0000 Subject: [PATCH 4/7] If an invalid pts value is detected, try to to make up some if it seems reasonable. This avoids completely losing A-V sync e.g. when pts was not reordered correctly. This was tested with http://samples.mplayerhq.hu/V-codecs/h264/PAFF/tv_cut.mkv for this sample proper pts reordering is the correct solution, but more resilient handling of the error case is still useful. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31311 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mplayer.c b/mplayer.c index a0a4c19f20..97fa6aae91 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2401,8 +2401,14 @@ static double update_video(int *blit_frame) if (sh_video->last_pts == MP_NOPTS_VALUE) sh_video->last_pts= sh_video->pts; else if (sh_video->last_pts > sh_video->pts) { - sh_video->last_pts = sh_video->pts; - mp_msg(MSGT_CPLAYER, MSGL_INFO, "pts value < previous\n"); + // make a guess whether this is some kind of discontinuity + // we should jump along with or some wron timestamps we + // should replace instead + if (sh_video->pts < sh_video->last_pts - 20 * sh_video->frametime) + sh_video->last_pts = sh_video->pts; + else + sh_video->pts = sh_video->last_pts + sh_video->frametime; + mp_msg(MSGT_CPLAYER, MSGL_V, "pts value < previous\n"); } frame_time = sh_video->pts - sh_video->last_pts; sh_video->last_pts = sh_video->pts; From 82aabb77d39ab0c2042da61bcc67c7735841f2bc Mon Sep 17 00:00:00 2001 From: reimar Date: Thu, 3 Jun 2010 20:59:40 +0000 Subject: [PATCH 5/7] Limit buffered PTS only when we actually got a frame from the decoder. This avoids some issues with H.264 PAFF due to dropping PTS values too early because only every second packet actually produced output. Just keeping up to one additional pts value would have avoided this particular issue as well, but this is more generic. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31312 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/dec_video.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c index 51da1adf7b..1dd6e42313 100644 --- a/libmpcodecs/dec_video.c +++ b/libmpcodecs/dec_video.c @@ -394,20 +394,6 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size, double tt; if (correct_pts && pts != MP_NOPTS_VALUE) { - int delay = get_current_video_decoder_lag(sh_video); - if (delay >= 0) { - if (delay > sh_video->num_buffered_pts) -#if 0 - // this is disabled because vd_ffmpeg reports the same lag - // after seek even when there are no buffered frames, - // leading to incorrect error messages - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n"); -#else - ; -#endif - else - sh_video->num_buffered_pts = delay; - } if (sh_video->num_buffered_pts == sizeof(sh_video->buffered_pts) / sizeof(double)) mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n"); @@ -451,6 +437,7 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size, mpi->fields &= ~MP_IMGFIELD_TOP_FIRST; if (correct_pts) { + int delay = get_current_video_decoder_lag(sh_video); if (sh_video->num_buffered_pts) { sh_video->num_buffered_pts--; sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts]; @@ -459,6 +446,22 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size, "No pts value from demuxer to " "use for frame!\n"); sh_video->pts = MP_NOPTS_VALUE; } + if (delay >= 0) { + // limit buffered pts only afterwards so we do not get confused + // by packets that produce no output (e.g. a single field of a + // H.264 frame). + if (delay > sh_video->num_buffered_pts) +#if 0 + // this is disabled because vd_ffmpeg reports the same lag + // after seek even when there are no buffered frames, + // leading to incorrect error messages + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n"); +#else + ; +#endif + else + sh_video->num_buffered_pts = delay; + } } return mpi; } From 637edc7a27d5438c9c55be30f548b3fbf4543f05 Mon Sep 17 00:00:00 2001 From: reimar Date: Thu, 3 Jun 2010 21:01:37 +0000 Subject: [PATCH 6/7] Try always enabling correct pts again for lavf demuxer, since the know issue with PAFF seems solved to me, and disabled correct-pts causes flickering with -ass (which of course should be fixed as well though). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31313 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_lavf.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index dad7208c3d..72363ef520 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -672,10 +672,6 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg) switch (cmd) { case DEMUXER_CTRL_CORRECT_PTS: - if (!strcmp("matroska", priv->avif->name) || - !strcmp("mpeg", priv->avif->name) || - !strcmp("mpegts", priv->avif->name)) - return DEMUXER_CTRL_NOTIMPL; return DEMUXER_CTRL_OK; case DEMUXER_CTRL_GET_TIME_LENGTH: if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE) From 9e2e3a1cb8daea51ea691b540c4b6feee074217b Mon Sep 17 00:00:00 2001 From: siretart Date: Thu, 3 Jun 2010 21:50:08 +0000 Subject: [PATCH 7/7] apply missing bits from http://repo.or.cz/w/mplayer.git/commitdiff/cd4e8dc1fa2863dcce62a44dd9ea105f9f9288f4 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31314 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_yuv4mpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libvo/vo_yuv4mpeg.c b/libvo/vo_yuv4mpeg.c index d06e79903d..01bfa8164b 100644 --- a/libvo/vo_yuv4mpeg.c +++ b/libvo/vo_yuv4mpeg.c @@ -149,6 +149,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, return -1; } +#ifdef CONFIG_LIBSWSCALE_A if(using_format != IMGFMT_YV12) { sws_rgb2rgb_init(get_sws_cpuflags()); @@ -160,6 +161,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, return -1; } } +#endif write_bytes = image_width * image_height * 3 / 2; image = malloc(write_bytes); @@ -464,9 +466,11 @@ static int query_format(uint32_t format) { case IMGFMT_YV12: return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#ifdef CONFIG_LIBSWSCALE_A case IMGFMT_BGR|24: case IMGFMT_RGB|24: return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#endif } } else @@ -476,9 +480,11 @@ static int query_format(uint32_t format) { case IMGFMT_YV12: return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#ifdef CONFIG_LIBSWSCALE_A case IMGFMT_BGR|24: case IMGFMT_RGB|24: return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#endif } } return 0;