[libbdplus-devel] [Git][videolan/libbdplus][master] 3 commits: Reduce log spamming with broken table or mask

Petri Hintukainen (@hpi) gitlab at videolan.org
Sun Oct 10 13:02:53 UTC 2021



Petri Hintukainen pushed to branch master at VideoLAN / libbdplus


Commits:
51be0258 by anonymous at 2021-10-10T16:02:19+03:00
Reduce log spamming with broken table or mask

- - - - -
a5cc2393 by anonymous at 2021-10-10T16:02:19+03:00
segment: deactivate invalid entries

- - - - -
19057409 by anonymous at 2021-10-10T16:02:19+03:00
Add segment_close_m2ts()

- - - - -


3 changed files:

- src/libbdplus/bdplus.c
- src/libbdplus/bdsvm/segment.c
- src/libbdplus/bdsvm/segment.h


Changes:

=====================================
src/libbdplus/bdplus.c
=====================================
@@ -350,7 +350,7 @@ bdplus_st_t *bdplus_m2ts(bdplus_t *plus, uint32_t m2ts)
 
 void bdplus_m2ts_close(bdplus_st_t *st)
 {
-    free(st);
+    segment_close_m2ts(st);
 }
 
 void bdplus_mmap(bdplus_t *plus, uint32_t id, void *mem )


=====================================
src/libbdplus/bdsvm/segment.c
=====================================
@@ -753,6 +753,7 @@ int32_t segment_decrypt(conv_table_t *conv_tab, uint8_t *key, uint8_t *mask)
 
     // After decrypting the whole segment, re-parse it to remove any
     // repair descriptors that are "fakes".
+    unsigned logged_flag3 = 0, invalid_entries = 0;
     for (currentry = 0;
          currentry < segment->numEntries;
          currentry++) {
@@ -765,14 +766,18 @@ int32_t segment_decrypt(conv_table_t *conv_tab, uint8_t *key, uint8_t *mask)
         switch((entry->flags>>6) & 0x3) {
 
         case 0:
-            BD_DEBUG(DBG_BDPLUS | DBG_CRIT,"[segment] entry type 0. Don't know what to do\n");
+            /* No transform */
+            //BD_DEBUG(DBG_BDPLUS | DBG_CRIT,"[segment] entry type 0. Don't know what to do\n");
+            entry->active = 0;
             break;
 
         case 1: // Type 1, always active.
+            /* Transform */
             entry->active = 1;
             break;
 
         case 2: // Type 2, index mask[] to check if active
+            /* Forensic */
             bits = entry->flags & 0x3f; // 6 bits, 0-63
 
             // If set true, it is active, so process next..
@@ -810,7 +815,12 @@ int32_t segment_decrypt(conv_table_t *conv_tab, uint8_t *key, uint8_t *mask)
             break;
 
         case 3:
-            BD_DEBUG(DBG_BDPLUS | DBG_CRIT,"[segment] entry type 3. Don't know what to do\n");
+            /* Reserved. Table or mask is invalid ? */
+            if (logged_flag3 < 2)
+                BD_DEBUG(DBG_BDPLUS | DBG_CRIT,"[segment] entry type 3. Don't know what to do\n");
+            else
+                BD_DEBUG(DBG_BDPLUS,"[segment] entry type 3. Don't know what to do\n");
+            logged_flag3++;
             entry->active = 0;
             break;
 
@@ -820,10 +830,23 @@ int32_t segment_decrypt(conv_table_t *conv_tab, uint8_t *key, uint8_t *mask)
 
         } // switch flags
 
+        /* deactivate invalid entries */
+        if (_is_invalid_entry(entry, currentry == 0 ? NULL : entry - 1)) {
+            entry->active = 0;
+            invalid_entries++;
+        }
+
     } // for entries
 
+    if (invalid_entries) {
+        BD_DEBUG(DBG_BDPLUS | DBG_CRIT,"[segment] broken table %05d, %d (deactivated %u invalid entries, %u entries left). Mask %02x%02x0x%02x...\n",
+                 conv_tab->Tables[ conv_tab->current_table ].tableID, conv_tab->current_segment,
+                 invalid_entries, segment->numEntries - invalid_entries,
+                 segment->key[0], segment->key[1], segment->key[2]);
+    }
+
     if (removed)
-        BD_DEBUG(DBG_BDPLUS,"[segment] cleaned out %u entries.\n", removed);
+        BD_DEBUG(DBG_BDPLUS | DBG_CRIT,"[segment] cleaned out %u entries.\n", removed);
 
     return 1;
 }
@@ -1125,6 +1148,10 @@ int32_t segment_patchfile(conv_table_t *ct, uint32_t table, FILE *fd)
 }
 
 
+void segment_close_m2ts(bdplus_st_t *st)
+{
+    free(st);
+}
 
 bdplus_st_t *segment_set_m2ts(conv_table_t *ct, uint32_t m2ts)
 {


=====================================
src/libbdplus/bdsvm/segment.h
=====================================
@@ -52,6 +52,7 @@ BD_PRIVATE bdplus_st_t *segment_set_m2ts    ( conv_table_t *, uint32_t );
 BD_PRIVATE int32_t      segment_patchfile   ( conv_table_t *, uint32_t , FILE * );
 BD_PRIVATE int32_t      segment_patchseek   ( bdplus_st_t *, uint64_t );
 BD_PRIVATE int32_t      segment_patch       ( bdplus_st_t *, int32_t, uint8_t * );
+BD_PRIVATE void         segment_close_m2ts  ( bdplus_st_t * );
 
 #endif
 



View it on GitLab: https://code.videolan.org/videolan/libbdplus/-/compare/f424133fb0e0be4cead599efb4d460f5eab7f3e1...190574093c6dbde753f560199fbdc54c60965c7f

-- 
View it on GitLab: https://code.videolan.org/videolan/libbdplus/-/compare/f424133fb0e0be4cead599efb4d460f5eab7f3e1...190574093c6dbde753f560199fbdc54c60965c7f
You're receiving this email because of your account on code.videolan.org.




More information about the libbdplus-devel mailing list