<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 3, 2015 at 9:25 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 decoding and generating the IBP descriptor (0x12),<br>
as specified in ISO/IEC 13818-1 10/2014.<br></blockquote><div><br></div><div>Same here, please split of dvbinfo changes from the rest of the patch.<br><br></div><div>Kind regards,<br><br></div><div>Jean-Paul Saman.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
 examples/dvbinfo/libdvbpsi.c | 13 +++++++<br>
 src/Makefile.am              |  2 +<br>
 src/descriptors/dr.h         |  1 +<br>
 src/descriptors/dr_12.c      | 88 ++++++++++++++++++++++++++++++++++++++++++++<br>
 src/descriptors/dr_12.h      | 77 ++++++++++++++++++++++++++++++++++++++<br>
 5 files changed, 181 insertions(+)<br>
 create mode 100644 src/descriptors/dr_12.c<br>
 create mode 100644 src/descriptors/dr_12.h<br>
<br>
diff --git a/examples/dvbinfo/libdvbpsi.c b/examples/dvbinfo/libdvbpsi.c<br>
index ae976e9..b1b8fbf 100644<br>
--- a/examples/dvbinfo/libdvbpsi.c<br>
+++ b/examples/dvbinfo/libdvbpsi.c<br>
@@ -961,6 +961,16 @@ static void DumpSmoothingBufferDescriptor(dvbpsi_smoothing_buffer_dr_t *smoothin<br>
 }<br>
<br>
 /*****************************************************************************<br>
+ * DumpIBPDescriptor<br>
+ *****************************************************************************/<br>
+static void DumpIBPDescriptor(dvbpsi_ibp_dr_t *ibp_descriptor)<br>
+{<br>
+    printf("Closed GOP flag: %d \n", ibp_descriptor->b_closed_gop_flag);<br>
+    printf("Identical GOP flag: %d \n", ibp_descriptor->b_identical_gop_flag);<br>
+    printf("Max GOP length: %" PRIu16 " \n", ibp_descriptor->i_max_gop_length);<br>
+}<br>
+<br>
+/*****************************************************************************<br>
  * DumpSystemClockDescriptor<br>
  *****************************************************************************/<br>
 static void DumpSystemClockDescriptor(dvbpsi_system_clock_dr_t* p_clock_descriptor)<br>
@@ -1520,6 +1530,9 @@ static void DumpDescriptors(const char* str, dvbpsi_descriptor_t* p_descriptor)<br>
             case 0x10:<br>
                 DumpSmoothingBufferDescriptor(dvbpsi_DecodeSmoothingBufferDr(p_descriptor));<br>
                 break;<br>
+            case 0x12:<br>
+                DumpIBPDescriptor(dvbpsi_DecodeIBPDr(p_descriptor));<br>
+                break;<br>
             case 0x4c:<br>
                 DumpTimeShiftedServiceDescriptor(dvbpsi_DecodeTimeShiftedServiceDr(p_descriptor));<br>
                 break;<br>
diff --git a/src/Makefile.am b/src/Makefile.am<br>
index b6432ee..139fbda 100644<br>
--- a/src/Makefile.am<br>
+++ b/src/Makefile.am<br>
@@ -35,6 +35,7 @@ pkginclude_HEADERS = dvbpsi.h psi.h descriptor.h demux.h \<br>
                      descriptors/dr_0e.h \<br>
                      descriptors/dr_0f.h \<br>
                      descriptors/dr_10.h \<br>
+                     descriptors/dr_12.h \<br>
                      descriptors/dr_13.h \<br>
                      descriptors/dr_14.h \<br>
                     descriptors/dr_40.h \<br>
@@ -90,6 +91,7 @@ descriptors_src = descriptors/dr_02.c \<br>
                   descriptors/dr_0e.c \<br>
                   descriptors/dr_0f.c \<br>
                   descriptors/dr_10.c \<br>
+                  descriptors/dr_12.c \<br>
                   descriptors/dr_13.c \<br>
                   descriptors/dr_14.c \<br>
                  descriptors/dr_40.c \<br>
diff --git a/src/descriptors/dr.h b/src/descriptors/dr.h<br>
index 2ef0e9c..5031398 100644<br>
--- a/src/descriptors/dr.h<br>
+++ b/src/descriptors/dr.h<br>
@@ -46,6 +46,7 @@<br>
 #include "dr_0e.h"<br>
 #include "dr_0f.h"<br>
 #include "dr_10.h"<br>
+#include "dr_12.h"<br>
 #include "dr_13.h"<br>
 #include "dr_14.h"<br>
 #include "dr_40.h"<br>
diff --git a/src/descriptors/dr_12.c b/src/descriptors/dr_12.c<br>
new file mode 100644<br>
index 0000000..9292630<br>
--- /dev/null<br>
+++ b/src/descriptors/dr_12.c<br>
@@ -0,0 +1,88 @@<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_12.h"<br>
+<br>
+dvbpsi_ibp_dr_t* dvbpsi_DecodeIBPDr(dvbpsi_descriptor_t * p_descriptor)<br>
+{<br>
+    dvbpsi_ibp_dr_t * p_decoded;<br>
+<br>
+    /* check the tag. */<br>
+    if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x12))<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 2 bytes of payload. */<br>
+    if (p_descriptor->i_length != 2)<br>
+        return NULL;<br>
+<br>
+    p_decoded = (dvbpsi_ibp_dr_t*)malloc(sizeof(*p_decoded));<br>
+    if (!p_decoded)<br>
+        return NULL;<br>
+<br>
+    p_decoded->b_closed_gop_flag = p_descriptor->p_data[0] & 0x80;<br>
+    p_decoded->b_identical_gop_flag = p_descriptor->p_data[0] & 0x40;<br>
+    p_decoded->i_max_gop_length =<br>
+        (((uint16_t)p_descriptor->p_data[0] & 0x3f) << 8)<br>
+        | p_descriptor->p_data[1];<br>
+<br>
+    /* a value of 0 is forbidden for max_gop_length. */<br>
+    if(p_decoded->i_max_gop_length == 0)<br>
+    {<br>
+        free(p_decoded);<br>
+        return NULL;<br>
+    }<br>
+<br>
+    p_descriptor->p_decoded = (void*)p_decoded;<br>
+<br>
+    return p_decoded;<br>
+}<br>
+<br>
+dvbpsi_descriptor_t * dvbpsi_GenIBPDr(dvbpsi_ibp_dr_t * p_decoded)<br>
+{<br>
+    dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x12, 2, NULL);<br>
+    if (!p_descriptor)<br>
+        return NULL;<br>
+<br>
+    /* encode the data. */<br>
+    p_descriptor->p_data[0]  = p_decoded->b_closed_gop_flag << 7;<br>
+    p_descriptor->p_data[0] |= p_decoded->b_identical_gop_flag << 6;<br>
+    p_descriptor->p_data[0] |= p_decoded->i_max_gop_length >> 8;<br>
+<br>
+    p_descriptor->p_data[1] = p_decoded->i_max_gop_length;<br>
+<br>
+    return p_descriptor;<br>
+}<br>
diff --git a/src/descriptors/dr_12.h b/src/descriptors/dr_12.h<br>
new file mode 100644<br>
index 0000000..ac7303f<br>
--- /dev/null<br>
+++ b/src/descriptors/dr_12.h<br>
@@ -0,0 +1,77 @@<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_12.h><br>
+ * \author Daniel Kamil Kozar <<a href="mailto:dkk089@gmail.com">dkk089@gmail.com</a>><br>
+ * \brief Application interface for the MPEG-2 IBP descriptor decoder and<br>
+ * generator.<br>
+ *<br>
+ * Application interface for the MPEG-2 IBP descriptor decoder and generator.<br>
+ * This descriptor's definition can be found in ISO/IEC 13818-1 revision 2014/10<br>
+ * section 2.6.34.<br>
+ */<br>
+<br>
+#ifndef _DVBPSI_DR_12_H_<br>
+#define _DVBPSI_DR_12_H_<br>
+<br>
+#ifdef __cplusplus<br>
+extern "C" {<br>
+#endif<br>
+<br>
+/*!<br>
+ * \struct dvbpsi_ibp_dr_s<br>
+ * \brief IBP descriptor structure.<br>
+ *<br>
+ * This structure is used to store a decoded IBP descriptor. (ISO/IEC 13818-1<br>
+ * section 2.6.34).<br>
+ */<br>
+<br>
+/*!<br>
+ * \typedef struct dvbpsi_ibp_dr_s dvbpsi_ibp_dr_t<br>
+ * \brief dvbpsi_ibp_dr_s type definition.<br>
+ */<br>
+typedef struct dvbpsi_ibp_dr_s<br>
+{<br>
+  bool          b_closed_gop_flag; /*!< closed_gop_flag */<br>
+  bool          b_identical_gop_flag; /*!< identical_gop_flag */<br>
+  uint16_t      i_max_gop_length; /*!< max_gop_length */<br>
+} dvbpsi_ibp_dr_t;<br>
+<br>
+/*!<br>
+ * \brief IBP descriptor decoder.<br>
+ * \param p_descriptor pointer to the descriptor structure<br>
+ * \return A pointer to a new IBP descriptor structure which contains the<br>
+ * decoded data.<br>
+ */<br>
+dvbpsi_ibp_dr_t* dvbpsi_DecodeIBPDr(dvbpsi_descriptor_t * p_descriptor);<br>
+<br>
+/*!<br>
+ * \brief IBP descriptor generator.<br>
+ * \param p_decoded pointer to a decoded IBP descriptor structure.<br>
+ * \return a pointer to a new descriptor structure which contains encoded data.<br>
+ */<br>
+dvbpsi_descriptor_t * dvbpsi_GenIBPDr(dvbpsi_ibp_dr_t * p_decoded);<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
+#else<br>
+#error "Multiple inclusions of dr_12.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></div>