Browse code

A little proggy i wrote years ago. This simply writes burts of random data into a file. Great for testing error robustness/resilience/concealment.

Originally committed as revision 11459 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2008/01/08 09:54:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,40 @@
0
+
1
+#include <stdio.h>
2
+#include <stdlib.h>
3
+#include <time.h>
4
+#include <inttypes.h>
5
+
6
+int main(int argc, char** argv)
7
+{
8
+    FILE *f= fopen(argv[1], "rb+");
9
+    int count= atoi(argv[2]);
10
+    int maxburst= atoi(argv[3]);
11
+    int length, i;
12
+
13
+    srand (time (0));
14
+
15
+    fseek(f, 0, SEEK_END);
16
+    length= ftell(f);
17
+    fseek(f, 0, SEEK_SET);
18
+
19
+    while(count--){
20
+        int burst= 1 + random() * (uint64_t) (abs(maxburst)-1) / RAND_MAX;
21
+        int pos= random() * (uint64_t) length / RAND_MAX;
22
+        fseek(f, pos, SEEK_SET);
23
+
24
+        if(maxburst<0) burst= -maxburst;
25
+
26
+        if(pos + burst > length)
27
+            continue;
28
+
29
+        while(burst--){
30
+            int val= random() * 256ULL / RAND_MAX;
31
+
32
+            if(maxburst<0) val=0;
33
+
34
+            fwrite(&val, 1, 1, f);
35
+        }
36
+    }
37
+
38
+    return 0;
39
+}