Jindřich Makovička <[email protected]> writes:

> According to MPEG-TS specs, the continuity_counter shall not be
> incremented when the adaptation_field_control of the packet
> equals '00' or '10'.
>
> Example mpeg-ts stream at http://www.datafilehost.com/download-16ab1765.html
>
> -- 
> Jindrich Makovicka
>
> From 6e13b0248eb936df756e0207f206adbed0292193 Mon Sep 17 00:00:00 2001
> From: Jindrich Makovicka <[email protected]>
> Date: Thu, 30 Jun 2011 12:00:56 +0200
> Subject: [PATCH] mpegts: fix Continuity Counter error detection
>
> According to MPEG-TS specs, the continuity_counter shall not be
> incremented when the adaptation_field_control of the packet
> equals '00' or '10'.
>
> Signed-off-by: Jindrich Makovicka <[email protected]>
> ---
>  libavformat/mpegts.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index f2ae567..1ab104e 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -1247,7 +1247,7 @@ static int handle_packet(MpegTSContext *ts, const 
> uint8_t *packet)
>  {
>      AVFormatContext *s = ts->stream;
>      MpegTSFilter *tss;
> -    int len, pid, cc, cc_ok, afc, is_start;
> +    int len, pid, cc, expected_cc, cc_ok, afc, is_start;
>      const uint8_t *p, *p_end;
>      int64_t pos;
>
> @@ -1265,7 +1265,8 @@ static int handle_packet(MpegTSContext *ts, const 
> uint8_t *packet)
>
>      /* continuity check (currently not used) */
>      cc = (packet[3] & 0xf);
> -    cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
> +    expected_cc = (packet[3] & 0x10) ? (tss->last_cc + 1) & 0x0f : 
> tss->last_cc;
> +    cc_ok = (tss->last_cc < 0) || (expected_cc == cc);
>      tss->last_cc = cc;

Looks OK, although I'd drop a few parens here and there.

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to