[Mplayer-cvslog] CVS: main mplayer.c,1.696,1.697 => breaks dvd subtitles + PATCH

Pierre Lombard p_l at gmx.fr
Mon Jun 2 11:01:23 CEST 2003


* Alex Beregszaszi <alex at fsn.hu> [2003-06-01 23:00]:
> > I did not test but it does not seem equivalent to the version before.
> Just read... with do{} while; the code gets executed first, and after
> that it check for the expressions in while().

I read it and that's why I replied prior to testing:
The previous code assumed packet != NULL and len >0 in the call to
spudec_assemble(vo_spudec,packet,len,timestamp), and this was no longer
the case in the patch.

This can happen if ds_get_packet_sub() returns such a value which must be
tested against (and this happens on one of my dvds).

> So please test! I don't say that a patch sucks without testing it...

Bah... I didn't say it sucked, just that there may have been a NULL
dereference pointer, and, because of Murphy's law, it seems to happen on
my test dvd ;)

The attached patch is tested and should work fine (and we avoid 1
extra-test for the matter of micro-optimisations + len needn't
initializing as it's done in the loop ;))

--
Best regards,
  Pierre 
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.701
diff -u -r1.701 mplayer.c
--- mplayer.c	31 May 2003 21:50:21 -0000	1.701
+++ mplayer.c	2 Jun 2003 09:26:59 -0000
@@ -3426,11 +3426,11 @@
   // DVD sub:
 if(vo_config_count && vo_spudec) {
   unsigned char* packet=NULL;
-  int len=1,timestamp;
+  int len,timestamp;
   current_module="spudec";
   spudec_heartbeat(vo_spudec,90000*sh_video->timer);
     // Get a sub packet from the dvd or a vobsub and make a timestamp relative to sh_video->timer
-  while(len>0 && packet){
+  while(1) {
     // Vobsub
     len = 0;
     if(vo_vobsub) {
@@ -3450,8 +3450,9 @@
 	mp_dbg(MSGT_CPLAYER,MSGL_V,"\rDVD sub: len=%d  v_pts=%5.3f  s_pts=%5.3f  ts=%d \n",len,sh_video->pts,d_dvdsub->pts,timestamp);
       }
     }
-      if(timestamp < 0) timestamp = 0;
-      spudec_assemble(vo_spudec,packet,len,timestamp);
+    if(!len || !packet) break;
+    if(timestamp < 0) timestamp = 0;
+    spudec_assemble(vo_spudec,packet,len,timestamp);
   }
   
   /* detect wether the sub has changed or not */


More information about the MPlayer-cvslog mailing list