[bTSstream-devel] [Git][videolan/bitstream][master] Add support for DVB-S2 raw BBFrames parsing.
Christophe Massiot (@cmassiot)
gitlab at videolan.org
Sat Nov 1 18:36:21 UTC 2025
Christophe Massiot pushed to branch master at VideoLAN / bitstream
Commits:
ca70d359 by Christophe Massiot at 2025-11-01T19:35:27+01:00
Add support for DVB-S2 raw BBFrames parsing.
- - - - -
3 changed files:
- NEWS
- + dvb/s2.h
- mpeg/ts.h
Changes:
=====================================
NEWS
=====================================
@@ -1,6 +1,10 @@
1.6 (TODO)
=================
- - Add EBU BISS-CA
+ - Add support for EBU BISS-CA
+ - Add support for Haivision SRT
+ - Add support for AIT
+ - Add support for DVB-S2 BBFrames
+ - Fix invalid XML characters
1.5 (6 November 2018)
=================
=====================================
dvb/s2.h
=====================================
@@ -0,0 +1,205 @@
+/*****************************************************************************
+ * s2.h: ETSI EN 302 307 DVB-S2
+ *****************************************************************************
+ * Copyright (C) 2025 VideoLAN
+ *
+ * Authors: Christophe Massiot <cmassiot at upipe.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+/*
+ * Normative references:
+ * - ETSI EN 302 307 V1.2.1 (2009-08) (DVB-S2)
+ */
+
+#ifndef __BITSTREAM_DVB_S2_H__
+#define __BITSTREAM_DVB_S2_H__
+
+#include <bitstream/common.h>
+#include <bitstream/mpeg/psi/psi.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*****************************************************************************
+ * BBFrame section
+ *****************************************************************************
+ * The only receiver of BBFrames that we have carries BBFrames in MPEG-TS,
+ * in private sections of a specific PID.
+ *****************************************************************************/
+#define S2BBFRAMES_PID 0x010e
+#define S2BBFRAMES_TABLE_ID 0x80
+#define S2BBFRAMES_HEADER_SIZE 4
+#define S2BBFRAMES_HEADER_COUNTER 0xb8
+
+static inline uint8_t s2bbframes_get_counter(const uint8_t *p)
+{
+ return p[3];
+}
+
+static inline uint8_t *s2bbframes_get_bbframe(const uint8_t *p)
+{
+ return (uint8_t *)&p[4];
+}
+
+static inline uint16_t s2bbframes_get_length(const uint8_t *p)
+{
+ return psi_get_length(p) + PSI_HEADER_SIZE - S2BBFRAMES_HEADER_SIZE;
+}
+
+static inline bool s2bbframes_validate(const uint8_t *p)
+{
+ if (psi_get_syntax(p) || psi_get_tableid(p) != S2BBFRAMES_TABLE_ID)
+ return false;
+
+ return true;
+}
+
+/*****************************************************************************
+ * BBFrame 8-bit CRC
+ *****************************************************************************/
+static const uint32_t s2bbcrc_table[256] = {
+ 0x00, 0xd5, 0x7f, 0xaa, 0xfe, 0x2b, 0x81, 0x54, 0x29, 0xfc, 0x56, 0x83,
+ 0xd7, 0x02, 0xa8, 0x7d, 0x52, 0x87, 0x2d, 0xf8, 0xac, 0x79, 0xd3, 0x06,
+ 0x7b, 0xae, 0x04, 0xd1, 0x85, 0x50, 0xfa, 0x2f, 0xa4, 0x71, 0xdb, 0x0e,
+ 0x5a, 0x8f, 0x25, 0xf0, 0x8d, 0x58, 0xf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76, 0xa3, 0xf7, 0x22, 0x88, 0x5d, 0xd6, 0x03, 0xa9, 0x7c,
+ 0x28, 0xfd, 0x57, 0x82, 0xff, 0x2a, 0x80, 0x55, 0x01, 0xd4, 0x7e, 0xab,
+ 0x84, 0x51, 0xfb, 0x2e, 0x7a, 0xaf, 0x05, 0xd0, 0xad, 0x78, 0xd2, 0x07,
+ 0x53, 0x86, 0x2c, 0xf9
+};
+
+static uint8_t s2bbcrc_check(const uint8_t *p, uint8_t size)
+{
+ uint8_t crc = 0;
+ while (size--)
+ crc = s2bbcrc_table[crc ^ *p++];
+ return crc;
+}
+
+/*****************************************************************************
+ * BBFrame header
+ *****************************************************************************/
+#define S2BBH_SIZE 10
+
+#define S2BBH_TSGS_GENERICPACKETIZED 0
+#define S2BBH_TSGS_GENERICCONTINUOUS 1
+#define S2BBH_TSGS_RESERVED 2
+#define S2BBH_TSGS_TRANSPORT 3
+
+#define S2BBH_RO_35 0
+#define S2BBH_RO_25 1
+#define S2BBH_RO_20 2
+#define S2BBH_RO_RESERVED 3
+
+#define S2BBH_DFL_MAX 58112
+
+static inline uint8_t s2bbh_get_tsgs(const uint8_t *p)
+{
+ return p[0] >> 6;
+}
+
+static inline bool s2bbh_is_sis(const uint8_t *p)
+{
+ return !!(p[0] & 0x20);
+}
+
+static inline bool s2bbh_is_ccm(const uint8_t *p)
+{
+ return !!(p[0] & 0x10);
+}
+
+static inline bool s2bbh_has_issyi(const uint8_t *p)
+{
+ return !!(p[0] & 0x8);
+}
+
+static inline bool s2bbh_has_npd(const uint8_t *p)
+{
+ return !!(p[0] & 0x4);
+}
+
+static inline uint8_t s2bbh_get_ro(const uint8_t *p)
+{
+ return p[0] & 0x3;
+}
+
+static inline uint8_t s2bbh_get_mis(const uint8_t *p)
+{
+ return p[1];
+}
+
+static inline uint16_t s2bbh_get_upl(const uint8_t *p)
+{
+ return (p[2] << 8) | p[3];
+}
+
+static inline uint16_t s2bbh_get_dfl(const uint8_t *p)
+{
+ return (p[4] << 8) | p[5];
+}
+
+static inline uint8_t s2bbh_get_sync(const uint8_t *p)
+{
+ return p[6];
+}
+
+static inline uint16_t s2bbh_get_syncd(const uint8_t *p)
+{
+ return (p[7] << 8) | p[8];
+}
+
+static inline bool s2bbh_validate(const uint8_t *p)
+{
+ if (s2bbh_get_dfl(p) > S2BBH_DFL_MAX ||
+ s2bbcrc_check(p, 10) != 0)
+ return false;
+
+ return true;
+}
+
+/*****************************************************************************
+ * BBFrame data field
+ *****************************************************************************/
+#define S2BBDF_ISSY_MAX_SIZE 3
+#define S2BBDF_NPD_SIZE 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
=====================================
mpeg/ts.h
=====================================
@@ -50,6 +50,7 @@ extern "C"
#define TS_HEADER_SIZE 4
#define TS_HEADER_SIZE_AF 6
#define TS_HEADER_SIZE_PCR 12
+#define TS_SYNC 0x47
#define TS_DECLARE(p_ts) \
uint8_t p_ts[TS_SIZE]
@@ -61,7 +62,7 @@ static inline uint8_t *ts_allocate(void)
static inline void ts_init(uint8_t *p_ts)
{
- p_ts[0] = 0x47;
+ p_ts[0] = TS_SYNC;
p_ts[1] = 0x0;
p_ts[2] = 0x0;
p_ts[3] = 0x0;
@@ -168,7 +169,7 @@ static inline uint8_t ts_get_scrambling(const uint8_t *p_ts)
static inline bool ts_validate(const uint8_t *p_ts)
{
- return p_ts[0] == 0x47;
+ return p_ts[0] == TS_SYNC;
}
/*****************************************************************************
View it on GitLab: https://code.videolan.org/videolan/bitstream/-/commit/ca70d359a3246a8cd25a06076bd8ffb818777846
--
View it on GitLab: https://code.videolan.org/videolan/bitstream/-/commit/ca70d359a3246a8cd25a06076bd8ffb818777846
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the biTStream-devel
mailing list