[FFmpeg-devel] [PATCH] fix ts Continuity Count

Limin Wang lance.lmwang
Sun Sep 2 08:57:56 CEST 2007


Hi,

* M?ns Rullg?rd <mans at mansr.com> [2007-08-31 22:07:07 +0100]:

> Jindrich Makovicka <makovick at gmail.com> writes:
> 
> > On Fri, 31 Aug 2007 10:03:41 +0100 (BST)
> > M?ns Rullg?rd <mans at mansr.com> wrote:
> >> >> > @@ -60,8 +60,8 @@
> >> >> >              b |= 0x40;
> >> >> >          *q++ = b;
> >> >> >          *q++ = s->pid;
> >> >> > +        *q++ = 0x10 | s->cc;
> >> >> >          s->cc = (s->cc + 1) & 0xf;
> >> >> > -        *q++ = 0x10 | s->cc;
> >> >> >          if (first)
> >> >> >              *q++ = 0; /* 0 offset */
> >> >> >          len1 = TS_PACKET_SIZE - (q - packet);
> >> >>
> >> >> Why is this needed?  It only shifts the continuity counter by one.
> >> >
> >> > It'll cause the first cc start from 1 always, vlc will give warning
> >> > about it.
> >> 
> >> So fix VLC.
> >
> > Moreover, this change is wrong because the code will break if someone
> > tries to insert some dummy packets without payload, i.e. no CC
> > change. CC _must_ be incremented before being stored into the cc field,
> > not after.
> 
> Indeed.

OK, then I think another CC incremented place need be fixed. See attached patch.


> > A possible workaround would be using 0x0f as an initial CC value.
> 
> There's nothing to be worked around.  VLC is overly picky and needs to
> be fixed.  That's all there is to it.

I'll try to send a patch for vlc.


Thanks,
Limin
-------------- next part --------------
Index: libavformat/mpegtsenc.c
===================================================================
--- libavformat/mpegtsenc.c	(revision 10279)
+++ libavformat/mpegtsenc.c	(working copy)
@@ -513,8 +513,8 @@
             val |= 0x40;
         *q++ = val;
         *q++ = ts_st->pid;
+        ts_st->cc = (ts_st->cc + 1) & 0xf;
         *q++ = 0x10 | ts_st->cc | (write_pcr ? 0x20 : 0);
-        ts_st->cc = (ts_st->cc + 1) & 0xf;
         if (write_pcr) {
             *q++ = 7; /* AFC length */
             *q++ = 0x10; /* flags: PCR present */



More information about the ffmpeg-devel mailing list