Merge branch 'master' into next
[paraslash.git] / fecdec_filter.c
index 30ac818c360873f6aedadd19e55ca7e0f6209550..1f57dd123eb86d906740f347a58a6d8ab27c28cf 100644 (file)
@@ -28,7 +28,7 @@
 #define NUM_FEC_GROUPS 3
 
 /** Default size of the output buffer of the fecdec filter. */
-#define FECDEC_DEFAULT_OUTBUF_SIZE (16 * 1024)
+#define FECDEC_DEFAULT_OUTBUF_SIZE (3 * 1024)
 /** Maximal size of the output buffer of the fecdec filter. */
 #define FECDEC_MAX_OUTBUF_SIZE (1024 * 1024)
 
@@ -119,10 +119,15 @@ static int find_group(struct fec_header *h,
        FOR_EACH_FECDEC_GROUP(fg, pfd) {
                if (fg->h.group_num != h->group_num)
                        continue;
+               if (fg->num_received_slices == 0)
+                       goto success;
                if (fg->h.slices_per_group != h->slices_per_group)
-                       continue;
+                       return -E_BAD_FEC_HEADER;
                if (fg->h.data_slices_per_group != h->data_slices_per_group)
-                       continue;
+                       return -E_BAD_FEC_HEADER;
+               if (fg->h.group_bytes != h->group_bytes)
+                       return -E_BAD_FEC_HEADER;
+success:
                *result = fg;
                return 1;
        }
@@ -163,8 +168,8 @@ static struct fecdec_group *free_oldest_group(struct private_fecdec_data *pfd)
        }
        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);
+                       "(contains %d slices)\n", oldest->h.group_num,
+                       oldest->num_received_slices);
        clear_group(oldest);
        return oldest;
 }