<div dir="ltr"><div><div>Patch applied, thanks for contributing.<br><br></div>Kind regards,<br><br></div>Jean-Paul Saman<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 1, 2015 at 9:46 PM, Daniel Kamil Kozar <span dir="ltr"><<a href="mailto:dkk089@gmail.com" target="_blank">dkk089@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch adds support for the smoothing buffer descriptor, as described in<br>
the latest (10/2014) ISO/IEC 13818-1 specification.<br>
Comments welcome.<br>
---<br>
src/Makefile.am | 2 ++<br>
src/descriptors/dr_10.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++<br>
src/descriptors/dr_10.h | 81 ++++++++++++++++++++++++++++++++++++++++++++<br>
3 files changed, 172 insertions(+)<br>
create mode 100644 src/descriptors/dr_10.c<br>
create mode 100644 src/descriptors/dr_10.h<br>
<br>
diff --git a/src/Makefile.am b/src/Makefile.am<br>
index 43011bc..ab4751f 100644<br>
--- a/src/Makefile.am<br>
+++ b/src/Makefile.am<br>
@@ -34,6 +34,7 @@ pkginclude_HEADERS = dvbpsi.h psi.h descriptor.h demux.h \<br>
descriptors/dr_0d.h \<br>
descriptors/dr_0e.h \<br>
descriptors/dr_0f.h \<br>
+ descriptors/dr_10.h \<br>
descriptors/dr_13.h \<br>
descriptors/dr_14.h \<br>
descriptors/dr_40.h \<br>
@@ -88,6 +89,7 @@ descriptors_src = descriptors/dr_02.c \<br>
descriptors/dr_0d.c \<br>
descriptors/dr_0e.c \<br>
descriptors/dr_0f.c \<br>
+ descriptors/dr_10.c \<br>
descriptors/dr_13.c \<br>
descriptors/dr_14.c \<br>
descriptors/dr_40.c \<br>
diff --git a/src/descriptors/dr_10.c b/src/descriptors/dr_10.c<br>
new file mode 100644<br>
index 0000000..ff83eb8<br>
--- /dev/null<br>
+++ b/src/descriptors/dr_10.c<br>
@@ -0,0 +1,89 @@<br>
+/*<br>
+Copyright (C) 2015 Daniel Kamil Kozar<br>
+<br>
+This library is free software; you can redistribute it and/or<br>
+modify it under the terms of the GNU Lesser General Public<br>
+License as published by the Free Software Foundation; either<br>
+version 2.1 of the License, or (at your option) any later version.<br>
+<br>
+This library is distributed in the hope that it will be useful,<br>
+but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
+Lesser General Public License for more details.<br>
+<br>
+You should have received a copy of the GNU Lesser General Public<br>
+License along with this library; if not, write to the Free Software<br>
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA<br>
+*/<br>
+<br>
+#include "config.h"<br>
+<br>
+#include <stdlib.h><br>
+#include <stdbool.h><br>
+<br>
+#if defined(HAVE_INTTYPES_H)<br>
+#include <inttypes.h><br>
+#elif defined(HAVE_STDINT_H)<br>
+#include <stdint.h><br>
+#endif<br>
+<br>
+#include "../dvbpsi.h"<br>
+#include "../dvbpsi_private.h"<br>
+#include "../descriptor.h"<br>
+<br>
+#include "dr_10.h"<br>
+<br>
+dvbpsi_smoothing_buffer_dr_t* dvbpsi_DecodeSmoothingBufferDr(<br>
+ dvbpsi_descriptor_t * p_descriptor)<br>
+{<br>
+ dvbpsi_smoothing_buffer_dr_t * p_decoded;<br>
+<br>
+ /* check the tag. */<br>
+ if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x10))<br>
+ return NULL;<br>
+<br>
+ /* don't decode twice. */<br>
+ if (dvbpsi_IsDescriptorDecoded(p_descriptor))<br>
+ return p_descriptor->p_decoded;<br>
+<br>
+ /* all descriptors of this type have 6 bytes of payload. */<br>
+ if (p_descriptor->i_length != 6)<br>
+ return NULL;<br>
+<br>
+ p_decoded = (dvbpsi_smoothing_buffer_dr_t*)malloc(sizeof(*p_decoded));<br>
+ if (!p_decoded)<br>
+ return NULL;<br>
+<br>
+ p_decoded->i_sb_leak_rate =<br>
+ (((uint32_t)p_descriptor->p_data[0] & 0x3f) << 16)<br>
+ | ((uint32_t)p_descriptor->p_data[1] << 8)<br>
+ | p_descriptor->p_data[2];<br>
+<br>
+ p_decoded->i_sb_size =<br>
+ (((uint32_t)p_descriptor->p_data[3] & 0x3f) << 16)<br>
+ | ((uint32_t)p_descriptor->p_data[4] << 8)<br>
+ | p_descriptor->p_data[5];<br>
+<br>
+ p_descriptor->p_decoded = (void*)p_decoded;<br>
+<br>
+ return p_decoded;<br>
+}<br>
+<br>
+dvbpsi_descriptor_t * dvbpsi_GenSmoothingBufferDr(<br>
+ dvbpsi_smoothing_buffer_dr_t * p_decoded)<br>
+{<br>
+ dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x10, 6, NULL);<br>
+ if (!p_descriptor)<br>
+ return NULL;<br>
+<br>
+ /* encode the data, making sure the reserved fields are set to all ones. */<br>
+ p_descriptor->p_data[0] = (p_decoded->i_sb_leak_rate >> 16) | 0xc0;<br>
+ p_descriptor->p_data[1] = p_decoded->i_sb_leak_rate >> 8;<br>
+ p_descriptor->p_data[2] = p_decoded->i_sb_leak_rate;<br>
+<br>
+ p_descriptor->p_data[3] = (p_decoded->i_sb_size >> 16) | 0xc0;<br>
+ p_descriptor->p_data[4] = p_decoded->i_sb_size >> 8;<br>
+ p_descriptor->p_data[5] = p_decoded->i_sb_size;<br>
+<br>
+ return p_descriptor;<br>
+}<br>
diff --git a/src/descriptors/dr_10.h b/src/descriptors/dr_10.h<br>
new file mode 100644<br>
index 0000000..d2a4f22<br>
--- /dev/null<br>
+++ b/src/descriptors/dr_10.h<br>
@@ -0,0 +1,81 @@<br>
+/*<br>
+Copyright (C) 2015 Daniel Kamil Kozar<br>
+<br>
+This library is free software; you can redistribute it and/or<br>
+modify it under the terms of the GNU Lesser General Public<br>
+License as published by the Free Software Foundation; either<br>
+version 2.1 of the License, or (at your option) any later version.<br>
+<br>
+This library is distributed in the hope that it will be useful,<br>
+but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
+Lesser General Public License for more details.<br>
+<br>
+You should have received a copy of the GNU Lesser General Public<br>
+License along with this library; if not, write to the Free Software<br>
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA<br>
+*/<br>
+<br>
+/*!<br>
+ * \file <dr_10.h><br>
+ * \author Daniel Kamil Kozar <<a href="mailto:dkk089@gmail.com">dkk089@gmail.com</a>><br>
+ * \brief Application interface for the MPEG-2 smoothing buffer descriptor<br>
+ * decoder and generator.<br>
+ *<br>
+ * Application interface for the MPEG-2 smoothing buffer descriptor decoder and<br>
+ * generator. This descriptor's definition can be found in ISO/IEC 13818-1<br>
+ * revision 2014/10 section 2.6.30.<br>
+ */<br>
+<br>
+#ifndef _DVBPSI_DR_10_H_<br>
+#define _DVBPSI_DR_10_H_<br>
+<br>
+#ifdef __cplusplus<br>
+extern "C" {<br>
+#endif<br>
+<br>
+/*!<br>
+ * \struct dvbpsi_smoothing_buffer_dr_s<br>
+ * \brief Smoothing buffer descriptor structure.<br>
+ *<br>
+ * This structure is used to store a decoded smoothing buffer descriptor.<br>
+ * (ISO/IEC 13818-1 section 2.6.30).<br>
+ */<br>
+<br>
+/*!<br>
+ * \typedef struct dvbpsi_smoothing_buffer_dr_s dvbpsi_smoothing_buffer_dr_t<br>
+ * \brief dvbpsi_smoothing_buffer_dr_t type definition.<br>
+ */<br>
+typedef struct dvbpsi_smoothing_buffer_dr_s<br>
+{<br>
+ /*! Value of the leak rate out of the SBn buffer, in units of 400 bits/s. */<br>
+ uint32_t i_sb_leak_rate;<br>
+<br>
+ /*! Value of the size of the multiplexing buffer smoothing buffer SBn. */<br>
+ uint32_t i_sb_size;<br>
+} dvbpsi_smoothing_buffer_dr_t;<br>
+<br>
+/*!<br>
+ * \brief Smoothing buffer descriptor decoder.<br>
+ * \param p_descriptor pointer to the descriptor structure<br>
+ * \return A pointer to a new smoothing buffer descriptor structure which<br>
+ * contains the decoded data.<br>
+ */<br>
+dvbpsi_smoothing_buffer_dr_t* dvbpsi_DecodeSmoothingBufferDr(<br>
+ dvbpsi_descriptor_t * p_descriptor);<br>
+<br>
+/*!<br>
+ * \brief Smoothing buffer descriptor generator.<br>
+ * \param p_decoded pointer to a decoded smoothing buffer descriptor structure.<br>
+ * \return a pointer to a new descriptor structure which contains encoded data.<br>
+ */<br>
+dvbpsi_descriptor_t * dvbpsi_GenSmoothingBufferDr(<br>
+ dvbpsi_smoothing_buffer_dr_t * p_decoded);<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
+#else<br>
+#error "Multiple inclusions of dr_10.h"<br>
+#endif<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.3.1<br>
<br>
_______________________________________________<br>
libdvbpsi-devel mailing list<br>
<a href="mailto:libdvbpsi-devel@videolan.org">libdvbpsi-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/libdvbpsi-devel" target="_blank">https://mailman.videolan.org/listinfo/libdvbpsi-devel</a><br>
</font></span></blockquote></div><br></div>