[MPlayer-dev-eng] Release 0.60pre-2 today?

Kim Minh Kaplan kmkaplan at selfoffice.com
Fri Dec 28 19:48:01 CET 2001


Arpi writes:

>> There is a bug in synchronization of DVD subtitles.  I have a fix, but
>
> I've heard that dvd subs have sync problems, but it works well (perfect
> sync) for my 5th Element and Contact disks.

Usually the subtitles appear to early.

> What is the main point of the fix/bug ?
> (where is the problem - and how to fix)

The main problem is that it does not take into account that the PTS
that is read should come from the d_dvdsub stream, while the PTS used
for display should come from the d_video stream.

In mplayer.c, I have changed it like this (these are not real diffs,
but hand edited ones):
----------------------------------------------------------------------
   // DVD sub:
   if(vo_spudec){
     unsigned char* packet=NULL;
     int len=ds_get_packet_sub(d_dvdsub,&packet);
     current_module="spudec";
     if(len>=2){
       int len2;
       len2=(packet[0]<<8)+packet[1];
       mp_msg(MSGT_CPLAYER,MSGL_V,"\rDVD sub: %d / %d  \n",len,len2);
-      spudec_assemble(vo_spudec,packet,len,100*d_video->pts);
-    } else {
-      spudec_heartbeat(vo_spudec,100*d_video->pts);
+      spudec_assemble(vo_spudec,packet,len,100*d_dvdsub->pts);
+    } else
       if(len>=0)
 	mp_msg(MSGT_CPLAYER,MSGL_V,"invalid dvd sub\n");
-    }
+    spudec_heartbeat(vo_spudec,100*d_video->pts);
     current_module=NULL;
   }
----------------------------------------------------------------------

And in spudec.c:

----------------------------------------------------------------------
-static void spudec_decode(spudec_handle_t *this)
+static void spudec_decode(spudec_handle_t *this, int pts100)
 {
-  spudec_process_control(this);
-  spudec_process_data(this);
+  if (spudec_process_control(this, pts100) >= 0)
+    spudec_process_data(this);
 }

 void spudec_assemble(void *this, unsigned char *packet, int len, int pts100)
 {
   spudec_handle_t *spu = (spudec_handle_t*)this;
-  spudec_heartbeat(this, pts100);
   if (spu->packet_offset == 0) {
     unsigned int len2 = get_be16(packet);
     // Start new fragment
     if (spu->packet_reserve < len2) {
       if (spu->packet != NULL)
 	free(spu->packet);
       spu->packet = malloc(len2);
       spu->packet_reserve = spu->packet != NULL ? len2 : 0;
     }
     if (spu->packet != NULL) {
       spu->deinterlace_oddness = 0;
       spu->packet_size = len2;
       memcpy(spu->packet, packet, len);
       spu->packet_offset = len;
     }
   } else {
     // Continue current fragment
     if (spu->packet_size < spu->packet_offset + len){
       fprintf(stderr,"invalid fragment\n");
       spu->packet_size = spu->packet_offset = 0;
     } else {
       memcpy(spu->packet + spu->packet_offset, packet, len);
       spu->packet_offset += len;
     }
   }
   if (spu->packet_offset == spu->packet_size) {
-    spudec_decode(spu);
+    spudec_decode(spu, pts100);
     spu->packet_offset = 0;
   }
 }
----------------------------------------------------------------------

Kim Minh.



More information about the MPlayer-dev-eng mailing list