From 1ae391a4fc704b5bfcad0a5d1da3f46e9aeb7a90 Mon Sep 17 00:00:00 2001 From: Christophe Massiot Date: Sun, 8 Sep 2013 23:35:28 +0200 Subject: [PATCH] new functions to detect sync header changes --- mpeg/aac.h | 9 +++++++++ mpeg/mpga.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/mpeg/aac.h b/mpeg/aac.h index cbed5ef..767efc7 100644 --- a/mpeg/aac.h +++ b/mpeg/aac.h @@ -188,6 +188,15 @@ static inline bool adts_sync_compare(const uint8_t *p_adts1, const uint8_t *p_ad (p_adts1[3] & 0xfc) == (p_adts2[3] & 0xfc); } +/* same but only takes into account meaningful fields */ +static inline bool adts_sync_compare_formats(const uint8_t *p_adts1, const uint8_t *p_adts2) +{ + return p_adts1[0] == p_adts2[0] && + (p_adts1[1] & 0xfe) == (p_adts2[1] & 0xfe) && + p_adts1[2] == p_adts2[2] && + (p_adts1[3] & 0xc0) == (p_adts2[3] & 0xc0); +} + #ifdef __cplusplus } #endif diff --git a/mpeg/mpga.h b/mpeg/mpga.h index 17f1c98..04acdee 100644 --- a/mpeg/mpga.h +++ b/mpeg/mpga.h @@ -211,6 +211,15 @@ static inline bool mpga_sync_compare(const uint8_t *p_mpga1, const uint8_t *p_mp p_mpga1[3] == p_mpga2[3]; } +/* same but only takes into account meaningful fields */ +static inline bool mpga_sync_compare_formats(const uint8_t *p_mpga1, const uint8_t *p_mpga2) +{ + return p_mpga1[0] == p_mpga2[0] && + (p_mpga1[1] & 0xfe) == (p_mpga2[1] & 0xfe) && + (p_mpga1[2] & 0xfc) == (p_mpga2[2] & 0xfc) && + (p_mpga1[3] & 0xf0) == (p_mpga2[3] & 0xf0); +} + #ifdef __cplusplus } #endif