1
From b772a757dd5e58ce94b56daee0deba78ab2e205e Mon Sep 17 00:00:00 2001
2
From: Jindrich Makovicka <makovick@gmail.com>
3
Date: Thu, 30 Jun 2011 09:03:15 +0000
4
Subject: [PATCH 17/70] mpegts: fix Continuity Counter error detection
6
According to MPEG-TS specs, the continuity_counter shall not be
7
incremented when the adaptation_field_control of the packet
10
Signed-off-by: Jindrich Makovicka <jindrich.makovicka@nangu.tv>
11
Signed-off-by: Anton Khirnov <anton@khirnov.net>
12
(cherry picked from commit 8923cfa328e8eb565aebcfe8672b276fd1c19bf7)
14
Signed-off-by: Anton Khirnov <anton@khirnov.net>
16
libavformat/mpegts.c | 5 +++--
17
1 files changed, 3 insertions(+), 2 deletions(-)
19
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
20
index e9b8b35..608cbe7 100644
21
--- a/libavformat/mpegts.c
22
+++ b/libavformat/mpegts.c
23
@@ -1247,7 +1247,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
25
AVFormatContext *s = ts->stream;
27
- int len, pid, cc, cc_ok, afc, is_start;
28
+ int len, pid, cc, expected_cc, cc_ok, afc, is_start;
29
const uint8_t *p, *p_end;
32
@@ -1265,7 +1265,8 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
34
/* continuity check (currently not used) */
35
cc = (packet[3] & 0xf);
36
- cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
37
+ expected_cc = (packet[3] & 0x10) ? (tss->last_cc + 1) & 0x0f : tss->last_cc;
38
+ cc_ok = (tss->last_cc < 0) || (expected_cc == cc);
41
/* skip adaptation field */