[FFmpeg-devel] [PATCH] timestamp discontinuity in subtitles is OK

Wolfram Gloger wmglo
Sun Oct 5 14:36:23 CEST 2008


> Date: Sun, 5 Oct 2008 02:27:48 +0200
> From: Michael Niedermayer <michaelni at gmx.at>
> On Sun, Oct 05, 2008 at 02:17:19AM +0200, Michael Niedermayer wrote:
> > On Sun, Oct 05, 2008 at 01:38:01AM +0200, Aurelien Jacobs wrote:
> > > Hi,
> > >=20
> > > ffmpeg.c contains some code to fix pts/dts when detecting timestamp
> > > discontinuity. This is nice, but it really shouldn't care about
> > > discontinuity in subtitle tracks, for obvious reason.
> > > Attached patch disable discontinuity detection for subtitle tracks.
> >=20
> > rejected

To also elaborate, I had proposed the _exact same_ patch as Aurelien
in issue 356 in February.  Please see the discussion there.

> to elaborate before someone asks
> 
> subtitles have AVPacket.duration=3D0 that means unknown duration
> and the discontinuity detection should test
> last packet time + last packet duration vs. current paket time
> thus if any of the 3 is unknown then the discontinuity detection
> shouldnt even run.

Ah, progress!  What about the appended patch then, which does exactly
this.  Aurelien, does this work for you?

Yes, this patch means _more_ special casing, but as a followup patch,
the code dealing with next_pts could be completely factored out of the
"switch(ist->st->codec->codec_type)", assuming that pkt->duration is
set correctly also for the audio and video case (this would have to be
tested first, which I haven't yet done).

Regards,
Wolfram.

--- trunk/ffmpeg.c	2008-09-29 11:41:56.000000000 +0200
+++ ffmpeg-wg/ffmpeg.c	2008-10-05 14:15:05.000000000 +0200
@@ -1256,6 +1290,10 @@
                 }
                 subtitle_to_free = &subtitle;
                 len = 0;
+                if (pkt->duration != 0)
+                    ist->next_pts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
+                else
+                    ist->next_pts = AV_NOPTS_VALUE;
                 break;
             default:
                 goto fail_decode;
@@ -1273,6 +1311,12 @@
                         ist->st->codec->time_base.den;
                 }
                 break;
+            case CODEC_TYPE_SUBTITLE:
+                if (pkt->duration != 0)
+                    ist->next_pts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
+                else
+                    ist->next_pts = AV_NOPTS_VALUE;
+                break;
             }
             data_buf = ptr;
             data_size = len;




More information about the ffmpeg-devel mailing list