[MPlayer-dev-eng] [PATCH] find_sub bugfix when sub switched

Ulion ulion2002 at gmail.com
Sat Oct 27 02:40:14 CEST 2007


2007/10/23, Ulion <ulion2002 at gmail.com>:
> 2007/10/21, Ulion <ulion2002 at gmail.com>:
> > 2007/10/21, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > > Hello,
> > > On Sun, Oct 21, 2007 at 01:59:31PM +0200, Reimar Döffinger wrote:
> > > > On Thu, Oct 11, 2007 at 10:08:38PM +0800, Ulion wrote:
> > > > > I found a bug of find_sub, it has two static variables
> > > > > nosub_range_start and nosub_range_end. These two variables did not be
> > > > > reset when sub stream switched, here's the fix patch and test case
> > > > > (two srt, the first sub stream will invisible until the first sub time
> > > > > of second sub stream after switched to the second substream and
> > > > > switched back.)
> > > >
> > > > Seems like a somewhat ugly way to fix it (assuming that subd pointer
> > > > changes and not just the data), but I currently have no better idea.
> > > > Anyone else?
> >
> > The original code assuming subd not changed or all subtitle streams
> > has same timestamps and the two static variables is for prevent
> > rechecking the sub datas for a time range without subtitles. This is
> > work for a fixed subtitle streams, but for multiple subtitle streams,
> > this trick not work. Current fix is to limit the trick only work for
> > the one subtitle stream last called with find_sub. About the subdata
> > change in the same subtitle stream, I think the data will not change
> > once loaded, and the original code also assuming it.
> >
>
> If there's no further suggestion/objection, I will apply this patch
> after three days.
>

Applied with a little adjustment, ignore null subdata.

@@ -58,6 +59,13 @@
     if ( !subd || subd->sub_num == 0) return;
     subs = subd->subtitles;

+    if (last_sub_data != subd) {
+        // Sub data changed, reset nosub range.
+        last_sub_data = subd;
+        nosub_range_start = -1;
+        nosub_range_end = -1;
+    }
+
     if(vo_sub){
       if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
     } else {


-- 
Ulion



More information about the MPlayer-dev-eng mailing list