changeset 32777:9cc2689e5cd1

Fix r32587: the previous approach to return subtitles in time broke DVB subtitles due to returning incomplete packets and even for PGS subtitles resulted in incorrect pts values for the sub packets.
author reimar
date Sun, 06 Feb 2011 13:52:05 +0000
parents 15060bd7df4c
children 9404cb19e08d
files libmpdemux/demux_ts.c
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ts.c	Sun Feb 06 13:09:09 2011 +0000
+++ b/libmpdemux/demux_ts.c	Sun Feb 06 13:52:05 2011 +0000
@@ -2985,11 +2985,6 @@
 			//IS IT TIME TO QUEUE DATA to the dp_packet?
 			if(is_start && (dp != NULL))
 			{
-				// subtitle packets _have_ to be submitted before video, otherwise
-				// they might get stuck "forever" and subtitles will be completely
-				// out of sync.
-				if (is_video)
-					fill_packet(demuxer, demuxer->sub, &priv->fifo[2].pack, &priv->fifo[2].offset, NULL);
 				retv = fill_packet(demuxer, ds, dp, dp_offset, si);
 			}
 
@@ -3130,6 +3125,9 @@
 				(*dp)->flags = 0;
 				(*dp)->pos = stream_tell(demuxer->stream);
 				(*dp)->pts = es->pts;
+				// subtitle packets must be returned immediately if possible
+				if (is_sub && !tss->payload_size)
+					retv = fill_packet(demuxer, ds, dp, dp_offset, si);
 
 				if(retv > 0)
 					return retv;
@@ -3171,7 +3169,8 @@
 			{
 				*dp_offset += sz;
 
-				if(*dp_offset >= MAX_PACK_BYTES)
+				// subtitle packets must be returned immediately if possible
+				if(*dp_offset >= MAX_PACK_BYTES || (is_sub && !tss->payload_size))
 				{
 					(*dp)->pts = tss->last_pts;
 					retv = fill_packet(demuxer, ds, dp, dp_offset, si);