BlinkenLib v.0.5.4 (2008-01-10)
Christian Heimke

Christian Heimke commited on 2011-07-15 09:05:43
Showing 17 changed files, with 137 additions and 51 deletions.

... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -22,8 +22,8 @@ int main( int argCnt, char * * args )
22 22
 
23 23
   //print info
24 24
   printf( "BlinkenLib - BlinkenConv\n"
25
-          "version 0.5.3 date 2007-12-28\n"
26
-          "Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>\n"
25
+          "version 0.5.4 date 2008-01-10\n"
26
+          "Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>\n"
27 27
           "Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n"
28 28
           "a blinkenarea.org project\n\n" );
29 29
 
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -267,6 +267,37 @@ void BlinkenFrameSetColor( stBlinkenFrame * pFrame, int y, int x, unsigned long
267 267
                                                ) / 255);
268 268
 }
269 269
 
270
+int BlinkenFrameCompare( stBlinkenFrame * pFrame1, stBlinkenFrame * pFrame2 )
271
+//returns -1 for frame1 smaller, 0 for equal, 1 for frame2 smaller
272
+{
273
+  int y, cmp;
274
+
275
+  if( pFrame1->height < pFrame2->height )
276
+    return -1;
277
+  if( pFrame1->height > pFrame2->height )
278
+    return 1;
279
+  if( pFrame1->width < pFrame2->width )
280
+    return -1;
281
+  if( pFrame1->width > pFrame2->width )
282
+    return 1;
283
+  if( pFrame1->channels < pFrame2->channels )
284
+    return -1;
285
+  if( pFrame1->channels > pFrame2->channels )
286
+    return 1;
287
+  if( pFrame1->maxval < pFrame2->maxval )
288
+    return -1;
289
+  if( pFrame1->maxval > pFrame2->maxval )
290
+    return 1;
291
+
292
+  for( y = 0; y < pFrame1->height; y++ ) {
293
+    cmp = memcmp( pFrame1->ppData[y], pFrame2->ppData[y], pFrame1->width * pFrame2->channels );
294
+    if( cmp != 0 )
295
+      return cmp;
296
+  }
297
+
298
+  return 0;
299
+}
300
+
270 301
 void BlinkenFrameResize( stBlinkenFrame * pFrame, int height, int width, int channels, int maxval )
271 302
 {
272 303
   unsigned char * * ppData;
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -34,6 +34,9 @@ void BlinkenFrameSetPixel( stBlinkenFrame * pFrame, int y, int x, int c, unsigne
34 34
 unsigned long BlinkenFrameGetColor( stBlinkenFrame * pFrame, int y, int x );
35 35
 void BlinkenFrameSetColor( stBlinkenFrame * pFrame, int y, int x, unsigned long color );
36 36
 
37
+int BlinkenFrameCompare( stBlinkenFrame * pFrame1, stBlinkenFrame * pFrame2 );
38
+//returns -1 for frame1 smaller, 0 for equal, 1 for frame2 smaller
39
+
37 40
 void BlinkenFrameResize( stBlinkenFrame * pFrame, int height, int width, int channels, int maxval );
38 41
 void BlinkenFrameScale( stBlinkenFrame * pFrame, int height, int width );
39 42
 void BlinkenFrameColorize( stBlinkenFrame * pFrame, int channels, int mode, int step );
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -1462,18 +1462,25 @@ int BlinkenMovieSave( stBlinkenMovie * pMovie, char * pFilename )
1462 1462
   return -1;
1463 1463
 }
1464 1464
 
1465
-void BlinkenMovieSend( stBlinkenMovie * pMovie, SOCKET udpSocket, etBlinkenProto proto )
1465
+void BlinkenMovieSend( stBlinkenMovie * pMovie, SOCKET udpSocket, etBlinkenProto proto, int maxidle )
1466 1466
 //udp socket must be "connected"
1467
+//maxidle is the maximum idle time between two frames in ms (last frame is repeated after this time), use 0 to turn off this feature
1467 1468
 {
1468
-  int i, len;
1469
-  char buffer[65536]; //64kB is more tham maximum UDP size
1469
+  int i, len, duration, dur;
1470
+  char buffer[65536]; //64kB is more than maximum UDP size
1470 1471
 
1471 1472
   for( i = 0; i < pMovie->frameCnt; i++ )
1472 1473
   {
1473 1474
     len = BlinkenFrameToNetwork( pMovie->ppFrames[i], proto, buffer, sizeof( buffer ) );
1474
-    if( len > 0 )
1475
+    duration = BlinkenFrameGetDuration( pMovie->ppFrames[i] );
1476
+    if( len > 0 ) {
1477
+      while( duration > 0 ) {
1475 1478
         send( udpSocket, buffer, len, 0 );
1476
-    msleep( BlinkenFrameGetDuration( pMovie->ppFrames[i] ) );
1479
+        dur = maxidle > 0 ? mini( maxidle, duration ) : duration;
1480
+        msleep( dur );
1481
+	duration -= dur;
1482
+      }
1483
+    }
1477 1484
   }
1478 1485
 }
1479 1486
 
... ...
@@ -1543,6 +1550,14 @@ stBlinkenMovie * BlinkenMovieReceive( SOCKET udpSocket, int timeout, etBlinkenPr
1543 1550
             }
1544 1551
           }
1545 1552
 
1553
+          //ignore frame if it is equal to last one
1554
+          if( pMovie->frameCnt > 0 ) {
1555
+            if( BlinkenFrameCompare( pFrame, pMovie->ppFrames[pMovie->frameCnt - 1] ) == 0 ) {
1556
+              BlinkenFrameFree( pFrame );
1557
+              continue;
1558
+            }
1559
+          }
1560
+
1546 1561
           //append frame to movie
1547 1562
           if( BlinkenMovieAppendFrame( pMovie, pFrame ) == 0 )
1548 1563
           {
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -66,8 +66,9 @@ int BlinkenMovieSaveBml( stBlinkenMovie * pMovie, char * pFilename );
66 66
 int BlinkenMovieSaveBbm( stBlinkenMovie * pMovie, char * pFilename );
67 67
 int BlinkenMovieSave( stBlinkenMovie * pMovie, char * pFilename );
68 68
 
69
-void BlinkenMovieSend( stBlinkenMovie * pMovie, SOCKET udpSocket, etBlinkenProto proto );
69
+void BlinkenMovieSend( stBlinkenMovie * pMovie, SOCKET udpSocket, etBlinkenProto proto, int maxidle );
70 70
 //udp socket must be "connected"
71
+//maxidle is the maximum idle time between two frames in ms (last frame is repeated after this time), use 0 to turn off this feature
71 72
 
72 73
 stBlinkenMovie * BlinkenMovieReceive( SOCKET udpSocket, int timeout, etBlinkenProto * pProto );
73 74
 //udp socket must be "bound" and should be "connected"
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -409,8 +409,8 @@ int main( int argCnt, char * * args )
409 409
 
410 410
   //print info
411 411
   printf( "BlinkenLib - BlinkenOutput\n"
412
-          "version 0.5.3 date 2007-12-28\n"
413
-          "Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>\n"
412
+          "version 0.5.4 date 2008-01-10\n"
413
+          "Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>\n"
414 414
           "Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n"
415 415
           "a blinkenarea.org project\n\n" );
416 416
 
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -350,8 +350,8 @@ int main( int argCnt, char * * args )
350 350
 
351 351
   //print info
352 352
   printf( "BlinkenLib - BlinkenOutput\n"
353
-          "version 0.5.3 date 2007-12-28\n"
354
-          "Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>\n"
353
+          "version 0.5.4 date 2008-01-10\n"
354
+          "Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>\n"
355 355
           "Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n"
356 356
           "a blinkenarea.org project\n\n" );
357 357
 
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -32,8 +32,8 @@ int main( int argCnt, char * * args )
32 32
 
33 33
   //print info
34 34
   printf( "BlinkenLib - BlinkenRecv\n"
35
-          "version 0.5.3 date 2007-12-28\n"
36
-          "Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>\n"
35
+          "version 0.5.4 date 2008-01-10\n"
36
+          "Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>\n"
37 37
           "Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n"
38 38
           "a blinkenarea.org project\n\n" );
39 39
 
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -27,7 +27,7 @@ int main( int argCnt, char * * args )
27 27
   int i, connected;
28 28
   SOCKET udpSocket;
29 29
   etBlinkenProto proto;
30
-  unsigned int send_cnt, loop_cnt, loop, ui;
30
+  unsigned int maxidle, send_cnt, loop_cnt, loop, ui;
31 31
   char txt[64];
32 32
   unsigned short port;
33 33
   struct sockaddr_in addr;
... ...
@@ -35,8 +35,8 @@ int main( int argCnt, char * * args )
35 35
 
36 36
   //print info
37 37
   printf( "BlinkenLib - BlinkenSend\n"
38
-          "version 0.5.3 date 2007-12-28\n"
39
-          "Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>\n"
38
+          "version 0.5.4 date 2008-01-10\n"
39
+          "Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>\n"
40 40
           "Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n"
41 41
           "a blinkenarea.org project\n\n" );
42 42
 
... ...
@@ -52,6 +52,8 @@ int main( int argCnt, char * * args )
52 52
             "     destination addess (defaults to 127.0.0.1:2323)\n"
53 53
             "  -p [BLP|EBLP|MCUF]\n"
54 54
             "     protocol to use (defaults to MCUF)\n"
55
+            "  -t <milliseconds>\n"
56
+            "     set maximum idle time between frames (defaults to 3000, use 0 for infinite)\n"
55 57
             "  -n <number>\n"
56 58
             "     set number of times to send movies (defaults to 1)\n"
57 59
             "  -i <file>\n"
... ...
@@ -94,6 +96,7 @@ int main( int argCnt, char * * args )
94 96
     //process parameters
95 97
     connected = 0;
96 98
     proto = BlinkenProtoMcuf;
99
+    maxidle = 3000;
97 100
     send_cnt = 1;
98 101
     for( i = 1; i < argCnt; i++ )
99 102
     {
... ...
@@ -179,6 +182,21 @@ int main( int argCnt, char * * args )
179 182
           printf( "missing protocol for \"-p\"\n" );
180 183
       }
181 184
 
185
+      //maximum idle time
186
+      else if( strcmp( args[i], "-t" ) == 0 )
187
+      {
188
+        if( i + 1 < argCnt )
189
+        {
190
+          i++;
191
+          if( sscanf( args[i], "%u", &ui ) == 1 )
192
+            maxidle = ui;
193
+          else
194
+            printf( "invalid maximum idle time value \"%s\"\n", args[i] );
195
+        }
196
+        else
197
+          printf( "missing maximum idle time value for \"-t\"\n" );
198
+      }
199
+
182 200
       //number of times to send movies
183 201
       else if( strcmp( args[i], "-n" ) == 0 )
184 202
       {
... ...
@@ -194,7 +212,7 @@ int main( int argCnt, char * * args )
194 212
           printf( "missing number for \"-n\"\n" );
195 213
       }
196 214
 
197
-      //read movie and sent it
215
+      //read movie and send it
198 216
       else if( strcmp( args[i], "-i" ) == 0 )
199 217
       {
200 218
         if( i + 1 < argCnt )
... ...
@@ -223,7 +241,7 @@ int main( int argCnt, char * * args )
223 241
               for( ui = 0; ui < send_cnt; ui++ )
224 242
               {
225 243
                 printf( "sending movie \"%s\" (%u/%u)...\n", args[i], ui + 1, send_cnt );
226
-                BlinkenMovieSend( pMovie, udpSocket, proto );
244
+                BlinkenMovieSend( pMovie, udpSocket, proto, maxidle );
227 245
                 printf( "movie \"%s\" sent\n", args[i] );
228 246
               }
229 247
               BlinkenMovieFree( pMovie );
... ...
@@ -1,3 +1,11 @@
1
+0.5.4 2008-01-10
2
+----------------
3
+added BlinkenFrameCompare function
4
+added maximum idle time parameter to BlinkenMovieSend function
5
+added maximum idle time parameter to BlinkenSend tool
6
+now merging duplicate frames to one in BlinkenMovieRecv function
7
+now merging duplicate frames to one in BlinkenRecv tool
8
+
1 9
 0.5.3 2007-12-28
2 10
 ----------------
3 11
 implemented colorizer in BlinkenConv
... ...
@@ -1,6 +1,6 @@
1 1
 # BlinkenLib
2
-# version 0.5.3 date 2007-12-28
3
-# Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+# version 0.5.4 date 2008-01-10
3
+# Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
 # Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
 # a blinkenarea.org project
6 6
 
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -1,6 +1,6 @@
1 1
 /* BlinkenLib
2
- * version 0.5.3 date 2007-12-28
3
- * Copyright 2004-2007 Stefan Schuermans <stefan@schuermans.info>
2
+ * version 0.5.4 date 2008-01-10
3
+ * Copyright 2004-2008 Stefan Schuermans <stefan@schuermans.info>
4 4
  * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
5 5
  * a blinkenarea.org project
6 6
  */
... ...
@@ -8,7 +8,17 @@
8 8
 #ifndef INC_Tools
9 9
 #define INC_Tools
10 10
 
11
+#ifndef maxi
12
+#define maxi( a, b ) ((a) > (b) ? (a) : (b))
13
+#endif
14
+
15
+#ifndef mini
16
+#define mini( a, b ) ((a) < (b) ? (a) : (b))
17
+#endif
18
+
19
+#ifndef arr_cnt
11 20
 #define arr_cnt( arr ) (sizeof( (arr) ) / sizeof( (arr)[0] ))
21
+#endif
12 22
 
13 23
 void * malloc1D( int count1, int size );
14 24
 
15 25