[dvblast-devel] [PATCH 13/17] mpeg/psi: Add support for descriptor 0x10 (Smoothing buffer).
Georgi Chorbadzhiyski
gf at unixsol.org
Fri Sep 9 23:28:35 CEST 2011
---
dvb/si_print.h | 1 +
mpeg/psi.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/dvb/si_print.h b/dvb/si_print.h
index aea32cc..e44a73a 100644
--- a/dvb/si_print.h
+++ b/dvb/si_print.h
@@ -100,6 +100,7 @@ static inline void descs_print(uint8_t *p_descs,
CASE_DESC(0b)
CASE_DESC(0c)
CASE_DESC(0e)
+ CASE_DESC(10)
CASE_DESC_ICONV(40)
CASE_DESC(41)
CASE_DESC(43)
diff --git a/mpeg/psi.h b/mpeg/psi.h
index 20672b2..dca6ac2 100644
--- a/mpeg/psi.h
+++ b/mpeg/psi.h
@@ -625,6 +625,60 @@ static inline void desc0e_print(const uint8_t *p_desc, f_print pf_print,
}
/*****************************************************************************
+ * Descriptor 0x10: Smoothing buffer descriptor
+ *****************************************************************************/
+#define DESC10_HEADER_SIZE (DESC_HEADER_SIZE + 6)
+
+static inline void desc10_init(uint8_t *p_desc)
+{
+ desc_set_tag(p_desc, 0x10);
+ desc_set_length(p_desc, DESC10_HEADER_SIZE - DESC_HEADER_SIZE);
+}
+
+static inline uint32_t desc10_get_sb_leak_rate(const uint8_t *p_desc)
+{
+ return ((p_desc[2] &~ 0xc0) << 16) | (p_desc[3] << 8) | p_desc[4]; // 11xxxxxx xxxxxxxx xxxxxxxx;
+}
+
+static inline void desc10_set_sb_leak_rate(uint8_t *p_desc, uint32_t sb_leak_rate)
+{
+ p_desc[2] = ((sb_leak_rate & 0xff0000) >> 16) | 0xc0;
+ p_desc[3] = (sb_leak_rate & 0xff00) >> 8;
+ p_desc[4] = (sb_leak_rate & 0xff);
+}
+
+static inline uint32_t desc10_get_sb_size(const uint8_t *p_desc)
+{
+ return ((p_desc[5] &~ 0xc0) << 16) | (p_desc[6] << 8) | p_desc[7]; // 11xxxxxx xxxxxxxx xxxxxxxx;
+}
+
+static inline void desc10_set_sb_size(uint8_t *p_desc, uint32_t sb_size)
+{
+ p_desc[5] = ((sb_size & 0xff0000) >> 16) | 0xc0;
+ p_desc[6] = (sb_size & 0xff00) >> 8;
+ p_desc[7] = (sb_size & 0xff);
+}
+
+static inline bool desc10_validate(const uint8_t *p_desc)
+{
+ return desc_get_length(p_desc) >= DESC10_HEADER_SIZE - DESC_HEADER_SIZE;
+}
+
+static inline void desc10_print(const uint8_t *p_desc, f_print pf_print,
+ void *opaque, print_type_t i_print_type)
+{
+ switch (i_print_type) {
+ case PRINT_XML:
+ pf_print(opaque, "<SMOOTHING_BUFFER_DESC sb_leak_rate=\"%u\" sb_size=\"%u\"/>",
+ desc10_get_sb_leak_rate(p_desc), desc10_get_sb_size(p_desc));
+ break;
+ default:
+ pf_print(opaque, " - desc 10 sb_leak_rate=%u sb_size=%u",
+ desc10_get_sb_leak_rate(p_desc), desc10_get_sb_size(p_desc));
+ }
+}
+
+/*****************************************************************************
* Descriptors list
*****************************************************************************/
#define DESCS_HEADER_SIZE 2
--
1.7.5.1
More information about the dvblast-devel
mailing list