This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: desc_t2_delivery: properly handle cell and subcell tables
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Wed May 3 10:11:00 2017 -0300

The logic there is not handling all centre frequencies found
at the T2 table: right now, it gets only the ones from the first
cell ID, and, if a subcell table is present, it won't do the right
thing, as the frequencies there should have 32 bits instead of
16.

Fix it by adding everything inside the center_frequency table,
as this is enough for DVB scan to do all it is needed.

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 lib/include/libdvbv5/desc_t2_delivery.h     | 11 +++-
 lib/libdvbv5/descriptors/desc_t2_delivery.c | 91 ++++++++++++++++-------------
 2 files changed, 59 insertions(+), 43 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=8630ff35148157835542c7f4c676f45ed45f0c18
diff --git a/lib/include/libdvbv5/desc_t2_delivery.h 
b/lib/include/libdvbv5/desc_t2_delivery.h
index 3a985ab7c237..6213bbda114f 100644
--- a/lib/include/libdvbv5/desc_t2_delivery.h
+++ b/lib/include/libdvbv5/desc_t2_delivery.h
@@ -45,10 +45,14 @@
  *
  * @param cell_id_extension    cell id extension
  * @param transposer_frequency transposer frequency
+ *
+ * NOTE: This struct is deprecated and will never be filled. All
+ * subcell transposer frequencies will be added to
+ * dvb_desc_t2_delivery::centre_frequency array.
  */
 struct dvb_desc_t2_delivery_subcell {
        uint8_t cell_id_extension;
-       uint16_t transposer_frequency;
+       uint16_t transposer_frequency;          // Should be 32 bits, instead
 } __attribute__((packed));
 
 /**
@@ -65,7 +69,8 @@ struct dvb_desc_t2_delivery_subcell {
  * @param other_frequency_flag other frequency flag
  * @param tfs_flag             tfs flag
  *
- * @param centre_frequency     centre frequency vector
+ * @param centre_frequency     centre frequency vector, for all cell and
+ *                             subcel ID's
  * @param frequency_loop_length        size of the 
dvb_desc_t2_delivery::centre_frequency
  *                             vector
  *
@@ -93,6 +98,8 @@ struct dvb_desc_t2_delivery {
 
        uint32_t *centre_frequency;
        uint8_t frequency_loop_length;
+
+       /* Unused, as the definitions here are incomplete */
        uint8_t subcel_info_loop_length;
        struct dvb_desc_t2_delivery_subcell *subcell;
 } __attribute__((packed));
diff --git a/lib/libdvbv5/descriptors/desc_t2_delivery.c 
b/lib/libdvbv5/descriptors/desc_t2_delivery.c
index c6ce2585d5b9..7fb4d83a9f1b 100644
--- a/lib/libdvbv5/descriptors/desc_t2_delivery.c
+++ b/lib/libdvbv5/descriptors/desc_t2_delivery.c
@@ -30,7 +30,7 @@ int dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
        struct dvb_desc_t2_delivery *d = desc;
        unsigned char *p = (unsigned char *) buf;
        size_t desc_len = ext->length - 1, len, len2;
-       int i;
+       int i, n, pos = 0, subcel_length;
 
        len = offsetof(struct dvb_desc_t2_delivery, bitfield);
        len2 = offsetof(struct dvb_desc_t2_delivery, centre_frequency);
@@ -55,44 +55,58 @@ int dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
        bswap16(d->bitfield);
        p += len2;
 
-       if (desc_len - (p - buf) < sizeof(uint16_t)) {
-               dvb_logwarn("T2 delivery descriptor is truncated");
-               return -2;
-       }
-       p += sizeof(uint16_t);
-
-       if (d->tfs_flag) {
-               d->frequency_loop_length = *p;
+       while (desc_len - (p - buf)) {
+               if (desc_len - (p - buf) < sizeof(uint16_t)) {
+                       dvb_logwarn("T2 delivery descriptor is truncated");
+                       return -2;
+               }
+
+
+               /* Discard cell ID */
+               p += sizeof(uint16_t);
+
+               if (d->tfs_flag) {
+                       n = *p;
+                       p++;
+               }
+               else
+                       n = 1;
+
+               d->frequency_loop_length += n;
+               d->centre_frequency = realloc(d->centre_frequency,
+                                             d->frequency_loop_length * 
sizeof(*d->centre_frequency));
+               if (!d->centre_frequency) {
+                       dvb_logerr("%s: out of memory", __func__);
+                       return -3;
+               }
+
+               memcpy(&d->centre_frequency[pos], p, 
sizeof(*d->centre_frequency) * n);
+               p += sizeof(*d->centre_frequency) * n;
+
+               for (i = 0; i < n; i++) {
+                       bswap32(d->centre_frequency[pos]);
+                       pos++;
+               }
+
+               /* Handle subcel frequency table */
+               subcel_length = *p;
                p++;
+               for (i = 0; i < subcel_length; i++) {
+                       if (desc_len - (p - buf) < sizeof(uint8_t) + 
sizeof(uint32_t)) {
+                               dvb_logwarn("T2 delivery descriptor is 
truncated");
+                               return -2;
+                       }
+                       p++;    // Ignore subcell ID
+
+                       // Add transposer_frequency at centre_frequency table
+                       memcpy(&d->centre_frequency[pos], p, 
sizeof(*d->centre_frequency));
+                       bswap32(d->centre_frequency[pos]);
+                       pos++;
+
+                       p += sizeof(*d->centre_frequency);
+               }
        }
-       else
-               d->frequency_loop_length = 1;
-
-       d->centre_frequency = calloc(d->frequency_loop_length,
-                                    sizeof(*d->centre_frequency));
-       if (!d->centre_frequency) {
-               dvb_logerr("%s: out of memory", __func__);
-               return -3;
-       }
-
-       memcpy(d->centre_frequency, p, sizeof(*d->centre_frequency) * 
d->frequency_loop_length);
-       p += sizeof(*d->centre_frequency) * d->frequency_loop_length;
-
-       for (i = 0; i < d->frequency_loop_length; i++)
-               bswap32(d->centre_frequency[i]);
-
-       d->subcel_info_loop_length = *p;
-       p++;
-
-       d->subcell = calloc(d->subcel_info_loop_length, sizeof(*d->subcell));
-       if (!d->subcell) {
-               dvb_logerr("%s: out of memory", __func__);
-               return -4;
-       }
-       memcpy(d->subcell, p, sizeof(*d->subcell) * d->subcel_info_loop_length);
 
-       for (i = 0; i < d->subcel_info_loop_length; i++)
-               bswap16(d->subcell[i].transposer_frequency);
        return 0;
 }
 
@@ -119,11 +133,6 @@ void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms 
*parms,
 
        for (i = 0; i < d->frequency_loop_length; i++)
                dvb_loginfo("|           centre frequency[%d]   %d", i, 
d->centre_frequency[i]);
-
-       for (i = 0; i < d->subcel_info_loop_length; i++) {
-               dvb_loginfo("|           cell_id_extension[%d]  %d", i, 
d->subcell[i].cell_id_extension);
-               dvb_loginfo("|           transposer frequency   %d", 
d->subcell[i].transposer_frequency);
-       }
 }
 
 void dvb_desc_t2_delivery_free(const void *desc)

_______________________________________________
linuxtv-commits mailing list
[email protected]
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to