changeset 5709:bdcd3e540558 libavformat

Correctly increment continuity_counter in PCR packets. Patch by Yann Coupin, yann.coupin+ffmpeg gmail
author cehoyos
date Wed, 24 Feb 2010 10:56:13 +0000
parents f096d96c7e5c
children 85ecf46ae931
files mpegtsenc.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mpegtsenc.c	Wed Feb 24 07:34:12 2010 +0000
+++ b/mpegtsenc.c	Wed Feb 24 10:56:13 2010 +0000
@@ -89,8 +89,8 @@
             b |= 0x40;
         *q++ = b;
         *q++ = s->pid;
+        s->cc = (s->cc + 1) & 0xf;
         *q++ = 0x10 | s->cc;
-        s->cc = (s->cc + 1) & 0xf;
         if (first)
             *q++ = 0; /* 0 offset */
         len1 = TS_PACKET_SIZE - (q - packet);
@@ -399,12 +399,12 @@
     service->pmt.opaque = s;
 
     ts->pat.pid = PAT_PID;
-    ts->pat.cc = 0;
+    ts->pat.cc = 15; // Initialize at 15 so that it wraps and be equal to 0 for the first packet we write
     ts->pat.write_packet = section_write_packet;
     ts->pat.opaque = s;
 
     ts->sdt.pid = SDT_PID;
-    ts->sdt.cc = 0;
+    ts->sdt.cc = 15;
     ts->sdt.write_packet = section_write_packet;
     ts->sdt.opaque = s;
 
@@ -647,8 +647,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) {
             // add 11, pcr references the last byte of program clock reference base
             pcr = ts->cur_pcr + (4+7)*8*90000LL / ts->mux_rate;