]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - fecdec_filter.c
fecdec.c: Add some more sanity checks to find_group().
[paraslash.git] / fecdec_filter.c
index 6b6716a115c18c26429d12d49f38a40981314574..6aa9071e6ea1bbabcf5d874f07b67da71a06db20 100644 (file)
@@ -28,7 +28,7 @@
 #define NUM_FEC_GROUPS 3
 
 /** Size of the output buffer of the fecdec filter. */
-#define FECDEC_OUTBUF_SIZE 81920
+#define FECDEC_OUTBUF_SIZE (128 * 1024)
 
 /** Data read from the header of a slice. */
 struct fec_header {
@@ -92,10 +92,6 @@ static void clear_group(struct fecdec_group *fg)
 {
        int i;
 
-       if (!group_complete(fg) && !group_empty(fg))
-               PARA_WARNING_LOG("Clearing incomplete group %d "
-                       "(contains %d slices)\n", fg->h.group_num,
-                       fg->num_received_slices);
        for (i = 0; i < fg->num_slices; i++) {
                free(fg->data[i]);
                fg->data[i] = NULL;
@@ -116,7 +112,10 @@ static int find_group(struct fec_header *h,
        FOR_EACH_FECDEC_GROUP(fg, pfd) {
                if (fg->h.group_num != h->group_num)
                        continue;
-               /* FIXME: Add some more sanity checks here */
+               if (fg->h.slices_per_group != h->slices_per_group)
+                       continue;
+               if (fg->h.data_slices_per_group != h->data_slices_per_group)
+                       continue;
                *result = fg;
                return 1;
        }
@@ -155,6 +154,10 @@ static struct fecdec_group *free_oldest_group(struct private_fecdec_data *pfd)
                if (!oldest || oldest->h.group_num > fg->h.group_num)
                        oldest = fg;
        }
+       if (!group_complete(oldest) && !group_empty(oldest))
+               PARA_WARNING_LOG("Clearing incomplete group %d "
+                       "(contains %d slices)\n", fg->h.group_num,
+                       fg->num_received_slices);
        clear_group(oldest);
        return oldest;
 }