[dvblast-devel] [PATCH 12/17] mpeg/psi: Add support for descriptor 0x0E (Maximum bitrate).

Georgi Chorbadzhiyski gf at unixsol.org
Fri Sep 9 23:28:34 CEST 2011


---
 dvb/si_print.h |    1 +
 mpeg/psi.h     |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/dvb/si_print.h b/dvb/si_print.h
index ddccad3..aea32cc 100644
--- a/dvb/si_print.h
+++ b/dvb/si_print.h
@@ -99,6 +99,7 @@ static inline void descs_print(uint8_t *p_descs,
         CASE_DESC(0a)
         CASE_DESC(0b)
         CASE_DESC(0c)
+        CASE_DESC(0e)
         CASE_DESC_ICONV(40)
         CASE_DESC(41)
         CASE_DESC(43)
diff --git a/mpeg/psi.h b/mpeg/psi.h
index 0bd9929..20672b2 100644
--- a/mpeg/psi.h
+++ b/mpeg/psi.h
@@ -583,6 +583,48 @@ static inline void desc0c_print(const uint8_t *p_desc, f_print pf_print,
 }
 
 /*****************************************************************************
+ * Descriptor 0x0E: Maximum bitrate descriptor
+ *****************************************************************************/
+#define DESC0E_HEADER_SIZE      (DESC_HEADER_SIZE + 3)
+
+static inline void desc0e_init(uint8_t *p_desc)
+{
+    desc_set_tag(p_desc, 0x0E);
+    desc_set_length(p_desc, DESC0E_HEADER_SIZE - DESC_HEADER_SIZE);
+}
+
+static inline uint32_t desc0e_get_max_bitrate(const uint8_t *p_desc)
+{
+    return ((p_desc[2] &~ 0xc0) << 16) | (p_desc[3] << 8) | p_desc[4]; // 11xxxxxx xxxxxxxx xxxxxxxx
+}
+
+static inline void desc0e_set_max_bitrate(uint8_t *p_desc, uint32_t max_bitrate)
+{
+    p_desc[2] = ((max_bitrate & 0xff0000) >> 16) | 0xc0;
+    p_desc[3] = (max_bitrate & 0xff00) >> 8;
+    p_desc[4] = (max_bitrate & 0xff);
+}
+
+static inline bool desc0e_validate(const uint8_t *p_desc)
+{
+    return desc_get_length(p_desc) >= DESC0E_HEADER_SIZE - DESC_HEADER_SIZE;
+}
+
+static inline void desc0e_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, "<MAXIMUM_BITRATE_DESC max_bitrate=\"%u\" max_bitrate_decoded=\"%u\"/>",
+                 desc0e_get_max_bitrate(p_desc), desc0e_get_max_bitrate(p_desc) * 50);
+        break;
+    default:
+        pf_print(opaque, "    - desc 0e max_bitrate=%u max_bitrate_decoded=%u",
+                 desc0e_get_max_bitrate(p_desc), desc0e_get_max_bitrate(p_desc) * 50);
+    }
+}
+
+/*****************************************************************************
  * Descriptors list
  *****************************************************************************/
 #define DESCS_HEADER_SIZE       2
-- 
1.7.5.1



More information about the dvblast-devel mailing list