wiretap 0.1.2 → 0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -80,8 +80,8 @@ extout_prefix =
80
80
  target_prefix =
81
81
  LOCAL_LIBS =
82
82
  LIBS = -lwiretapClientAPI -lsndfile -lpthread -ldl -lobjc
83
- SRCS = audio_format.cpp format.cpp frame_io.cpp image_format.cpp image_io.cpp node.cpp nodechildren.cpp nodeframes.cpp nodemetadata.cpp server.cpp serverlist.cpp thread_worker.cpp wiretap.cpp
84
- OBJS = audio_format.o format.o frame_io.o image_format.o image_io.o node.o nodechildren.o nodeframes.o nodemetadata.o server.o serverlist.o thread_worker.o wiretap.o
83
+ SRCS = audio_format.cpp format.cpp image_format.cpp image_io.cpp node.cpp nodechildren.cpp nodeframes.cpp nodemetadata.cpp server.cpp serverlist.cpp thread_worker.cpp wiretap.cpp
84
+ OBJS = audio_format.o format.o image_format.o image_io.o node.o nodechildren.o nodeframes.o nodemetadata.o server.o serverlist.o thread_worker.o wiretap.o
85
85
  TARGET = wiretap_bin
86
86
  DLLIB = $(TARGET).bundle
87
87
  EXTSTATIC =
@@ -1,6 +1,81 @@
1
1
  #include "wiretap.h"
2
2
 
3
3
 
4
+ static int wiretap_reduce_frame_bits24(const unsigned char* frame, int byte_length, charstream& writer) {
5
+ for(int index = 0; index < byte_length; index++) {
6
+ writer.write_char(frame[index]);
7
+ }
8
+ return 0;
9
+ }
10
+
11
+
12
+ static int wiretap_reduce_frame_bits32(const unsigned char* frame, int byte_length, charstream& writer) {
13
+ for(int index = 0; index < byte_length; index += 4) {
14
+ writer.write_char(frame[0]);
15
+
16
+ writer.write_char(frame[1] << 2 | frame[2] >> 6);
17
+
18
+ writer.write_char(frame[2] << 4 | frame[3] >> 4);
19
+ frame += 4;
20
+ }
21
+ return 0;
22
+ }
23
+
24
+
25
+
26
+ static int wiretap_reduce_frame_bits36(const unsigned char* frame, int byte_length, charstream& writer) {
27
+
28
+ int orphan_index = 0;
29
+ int orphan[3*6]; //куски, которые пропускаем
30
+
31
+ int pixelnum = 0;
32
+
33
+ for(int index = 0; index < byte_length*2/9; index++) {
34
+ if (pixelnum == 6) //7й пиксель собираем и пропущеных кусков
35
+ {
36
+ writer.write_char(((orphan[4] & 0xF) << 4) + (orphan[2] & 0xF)); // R
37
+ writer.write_char(((orphan[5] & 0xF) << 4) + (orphan[3] & 0xF)); // G
38
+ writer.write_char(((orphan[10] & 0xF) << 4) + (orphan[8] & 0xF));// B
39
+
40
+ pixelnum++;
41
+ continue;
42
+ }
43
+
44
+ if (pixelnum == 7) //8й пиксель тоже собираем из пропущеных кусков
45
+ {
46
+ writer.write_char(((orphan[11] & 0xF) << 4) + (orphan[9] & 0xF)); // R
47
+ writer.write_char(((orphan[16] & 0xF) << 4) + (orphan[14] & 0xF));// G
48
+ writer.write_char(((orphan[17] & 0xF) << 4) + (orphan[15] & 0xF));// B
49
+
50
+ pixelnum = 0;
51
+ orphan_index = 0;
52
+
53
+ continue;
54
+ }
55
+
56
+ writer.write_char(*frame++); // R
57
+ orphan[orphan_index++] = *frame++;
58
+
59
+ writer.write_char(*frame++); // G
60
+ orphan[orphan_index++] = *frame++;
61
+
62
+ writer.write_char(*frame++); // B
63
+ orphan[orphan_index++] = *frame++;
64
+
65
+ pixelnum++;
66
+ }
67
+ return 0;
68
+ }
69
+
70
+ static int wiretap_reduce_frame_bits48(const unsigned char* frame, int byte_length, charstream& writer) {
71
+ for(int index = 0; index < byte_length / 6; index++) {
72
+ writer.write_char(frame[index*6 + 0]);
73
+ writer.write_char(frame[index*6 + 2]);
74
+ writer.write_char(frame[index*6 + 4]);
75
+ }
76
+ return 0;
77
+ }
78
+
4
79
  bool wiretap_write_image_frame(int width, int height, int bpp, unsigned char* frame, const char* filename) {
5
80
  WireTapClipFormat format;
6
81
  format.setWidth(width);
@@ -16,6 +91,46 @@ bool wiretap_write_image_frame(int width, int height, int bpp, unsigned char* fr
16
91
  }
17
92
 
18
93
 
94
+
95
+ int reduced_frame_length(int byte_length, int bpp) {
96
+ const int bits_in_byte = 8;
97
+ const int bytes_in_pixel = 3;
98
+ // bpp/bits_in_byte - number of bytes per pixel in income frame. Maybe 3 (in case of 24bpp) or 4.5 (in case of 36bpp)
99
+ // byte_length/bytes_per_pixel - number of pixels in income frame
100
+ // number_pixels * 3 - number of pixels in outgoing frame
101
+ // 3 * byte_length/bpp * bits_in_byte
102
+ return (bytes_in_pixel * byte_length * bits_in_byte) / bpp;
103
+ }
104
+
105
+
106
+
107
+ int wiretap_write_image_data(int width, int height, int bpp, const unsigned char* frame, charstream& writer) {
108
+ switch(bpp) {
109
+ case 24: {
110
+ wiretap_reduce_frame_bits24(frame, width*height*3, writer);
111
+ break;
112
+ }
113
+ case 30:
114
+ case 32: {
115
+ wiretap_reduce_frame_bits32(frame, width*height*4, writer);
116
+ break;
117
+ }
118
+ case 36: {
119
+ wiretap_reduce_frame_bits36(frame, width*height*9/2, writer);
120
+ break;
121
+ }
122
+ case 48: {
123
+ wiretap_reduce_frame_bits48(frame, width*height*6, writer);
124
+ break;
125
+ }
126
+ default: {
127
+ THROW("Unsupported color depth: %d", bpp);
128
+ }
129
+ }
130
+ return 0;
131
+ }
132
+
133
+
19
134
  VALUE wiretap_dump_image_data(VALUE self, VALUE width, VALUE height, VALUE bpp, VALUE raw, VALUE filename) {
20
135
  wiretap_write_image_frame(NUM2INT(width), NUM2INT(height), NUM2INT(bpp), (unsigned char* )STR(raw), CSTR(filename));
21
136
  return Qtrue;
@@ -132,14 +132,6 @@ ImageIO::~ImageIO() {
132
132
  }
133
133
 
134
134
 
135
- void ImageIO::decode_image_data(unsigned char* frame, charstream& writer) {
136
- std::auto_ptr<FrameIO> frame_io(FrameIO::decoder(frame, format.width(), format.height(), format.bitsPerPixel()));
137
- if(!frame_io.get()) {
138
- THROW("Unsupported color depth for dumping image: %d", format.bitsPerPixel());
139
- }
140
- frame_io->decode(writer);
141
- }
142
-
143
135
  /************** PPM format *****************/
144
136
 
145
137
  ImageIO_PPM::ImageIO_PPM(const char* _filename, FILE* _f, WireTapClipFormat& _format) : ImageIO(_filename, _f, _format) {
@@ -205,8 +197,9 @@ void ImageIO_SGI::read_format() {
205
197
  if(_magic != magic) {
206
198
  rb_warn("Warning: %s has a broken file format: %d", filename, _magic);
207
199
  }
208
-
209
- compressed = read_int8() ? true : false;
200
+ char cmpr = read_int8();
201
+
202
+ compressed = cmpr ? true : false;
210
203
  switch(read_int8()) { // 1 for 1 byte per channel. 24 bit picture
211
204
  case 1: format.setBitsPerPixel(24);
212
205
  break;
@@ -392,7 +385,7 @@ void ImageIO_SGI::write_data(unsigned char* frame) {
392
385
  memstream mem(buffer.get());
393
386
 
394
387
  wiretap_write_sgi_header(format.width(), format.height(), stream);
395
- decode_image_data(frame, mem);
388
+ wiretap_write_image_data(format.width(), format.height(), format.bitsPerPixel(), frame, mem);
396
389
 
397
390
  write_channel(format.width(), format.height(), 0, buffer.get(), f);
398
391
  write_channel(format.width(), format.height(), 1, buffer.get(), f);
@@ -438,7 +431,7 @@ void ImageIO_BMP::write_data(unsigned char* frame) {
438
431
  filestream_bgr stream_bgr(f);
439
432
 
440
433
  write_header();
441
- decode_image_data(frame, stream_bgr);
434
+ wiretap_write_image_data(format.width(), format.height(), format.bitsPerPixel(), frame, stream_bgr);
442
435
  }
443
436
 
444
437
 
@@ -1,9 +1,49 @@
1
1
  #ifndef _IMAGE_IO_H_
2
2
  #define _IMAGE_IO_H_
3
3
  #include <string.h>
4
- #include "charstream.h"
5
4
 
6
5
 
6
+ class charstream {
7
+ public:
8
+ charstream();
9
+ virtual void write_char(unsigned char channel);
10
+ virtual ~charstream();
11
+
12
+ void write_int32_le(int value);
13
+ void write_int32_be(int value);
14
+ void write_int16_le(short value);
15
+ void write_int16_be(short value);
16
+ void write_string(char* value);
17
+ };
18
+
19
+ class memstream : public charstream {
20
+ unsigned char* ptr;
21
+ public:
22
+ memstream(unsigned char* _ptr);
23
+ void write_char(unsigned char channel);
24
+ };
25
+
26
+ class filestream : public charstream {
27
+ FILE* f;
28
+ public:
29
+ filestream(FILE* _f);
30
+ void write_char(unsigned char channel);
31
+ };
32
+
33
+ class filestream_bgr : public charstream {
34
+ int count;
35
+ unsigned char buffer[3];
36
+ FILE* f;
37
+ public:
38
+ filestream_bgr(FILE* _f);
39
+ void write_char(unsigned char channel);
40
+ };
41
+
42
+
43
+ bool wiretap_write_frame_bmp(int width, int height, int bpp, unsigned char* frame, FILE* f);
44
+ bool wiretap_write_frame_sgi(int width, int height, int bpp, unsigned char* frame, FILE* f);
45
+
46
+ int wiretap_write_image_data(int width, int height, int bpp, const unsigned char* frame, charstream& writer);
7
47
 
8
48
 
9
49
  class ImageIO {
@@ -23,7 +63,6 @@ protected:
23
63
  int read_int32_be();
24
64
  short read_int16_be();
25
65
  unsigned char read_int8();
26
- void decode_image_data(unsigned char* frame, charstream& writer);
27
66
  };
28
67
 
29
68
  class ImageIO_SGI : public ImageIO {
@@ -14,7 +14,6 @@
14
14
  #include <stdarg.h>
15
15
  #include <memory>
16
16
 
17
- #include "frame_io.h"
18
17
  #include "image_io.h"
19
18
 
20
19
 
@@ -74,7 +74,7 @@ class TestImageConversions < Test::Unit::TestCase
74
74
  FileUtils.rm_f output
75
75
  3.times do | i |
76
76
  File.open(FIXTURES_DIR + "/raw/cube_SD_10bit_5f/%s.stoneimage" % i) do |f|
77
- Wiretap.dump_image_data(@width, @height, 32, f.read(@width*@height*4), output % i)
77
+ Wiretap.dump_image_data(@width, @height, 32, f.read(@width*@height*9/2), output % i)
78
78
  end
79
79
  end
80
80
  end
@@ -84,7 +84,7 @@ class TestImageConversions < Test::Unit::TestCase
84
84
  FileUtils.rm_f output
85
85
  3.times do | i |
86
86
  File.open(FIXTURES_DIR + "/raw/cube_SD_10bit_5f/%s.stoneimage" % i) do |f|
87
- Wiretap.dump_image_data(@width, @height, 32, f.read(@width*@height*4), output % i )
87
+ Wiretap.dump_image_data(@width, @height, 32, f.read(@width*@height*9/2), output % i )
88
88
  end
89
89
  end
90
90
  end
@@ -8,9 +8,9 @@ module TestConnectToTestHost
8
8
  assert @server.alive?, "The server should be alive to test it - maybe you have mistakenly entered a faulty IP adderss?"
9
9
 
10
10
  assert_equal @test_host, @server.hostname
11
- assert_match /(\d+)/, @server.version, "Server version has to be a String and has to contain a number"
12
- assert_match /Discreet/, @server.vendor, "The vendor should be Discreet"
13
- assert_match /IFFFS/, @server.product, "The product should be IFFS (InfernoFlintFlameSmoke)"
11
+ assert_match /(\d+)/, @server.version
12
+ assert_match /Discreet/, @server.vendor
13
+ assert_match /IFFFS/, @server.product
14
14
 
15
15
  assert @server.close!, "The connection should be closed succesfully"
16
16
 
@@ -20,8 +20,8 @@ module TestConnectToTestHost
20
20
  end
21
21
 
22
22
  def test_02a_bailing_when_opening_from_dead_server
23
- assert_raise(Wiretap::ServerDead) { nonexistent_lib = Wiretap::open("10.2.2.2/Bla") }
24
- dead_server = Wiretap::Server.new("10.2.2.2/Bla")
25
- assert !dead_server.alive?, "The dead server should respond dead"
23
+ assert_raise(Wiretap::ServerDead) do
24
+ nonexistent_lib = Wiretap::open("10.2.2.2/Bla")
25
+ end
26
26
  end
27
27
  end
metadata CHANGED
@@ -3,12 +3,12 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: wiretap
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2007-02-01 00:00:00 +01:00
6
+ version: "0.11"
7
+ date: 2007-01-31 00:00:00 +01:00
8
8
  summary: WireTap driver
9
9
  require_paths:
10
10
  - lib
11
- email: tools@hecticelectric.nl
11
+ email: max@maxidoors.ru
12
12
  homepage: http://rubyforge.org/projects/wiretap/
13
13
  rubyforge_project: wiretap
14
14
  description:
@@ -26,7 +26,7 @@ platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
28
  authors:
29
- - Max Lapshin, Julik Tarkhanov, HecticElectric BV
29
+ - Max Lapshin
30
30
  files:
31
31
  - test_new/common.rb
32
32
  - test_new/fixtures
@@ -86,11 +86,8 @@ files:
86
86
  - test_new/test_parts/simple_node_lookup_and_browsing.rb
87
87
  - lib/wiretap.rb
88
88
  - ext/audio_format.cpp
89
- - ext/charstream.h
90
89
  - ext/extconf.rb
91
90
  - ext/format.cpp
92
- - ext/frame_io.cpp
93
- - ext/frame_io.h
94
91
  - ext/image_format.cpp
95
92
  - ext/image_io.cpp
96
93
  - ext/image_io.h
@@ -1,41 +0,0 @@
1
- #ifndef _CHARSTREAM_H_
2
- #define _CHARSTREAM_H_
3
- #include <stdio.h>
4
-
5
- class charstream {
6
- public:
7
- charstream();
8
- virtual void write_char(unsigned char channel);
9
- virtual ~charstream();
10
-
11
- void write_int32_le(int value);
12
- void write_int32_be(int value);
13
- void write_int16_le(short value);
14
- void write_int16_be(short value);
15
- void write_string(char* value);
16
- };
17
-
18
- class memstream : public charstream {
19
- unsigned char* ptr;
20
- public:
21
- memstream(unsigned char* _ptr);
22
- void write_char(unsigned char channel);
23
- };
24
-
25
- class filestream : public charstream {
26
- FILE* f;
27
- public:
28
- filestream(FILE* _f);
29
- void write_char(unsigned char channel);
30
- };
31
-
32
- class filestream_bgr : public charstream {
33
- int count;
34
- unsigned char buffer[3];
35
- FILE* f;
36
- public:
37
- filestream_bgr(FILE* _f);
38
- void write_char(unsigned char channel);
39
- };
40
-
41
- #endif /* _CHARSTREAM_H_ */
@@ -1,120 +0,0 @@
1
- #include "frame_io.h"
2
-
3
- FrameIO::FrameIO(unsigned char* _frame, int _width, int _height) {
4
- frame = _frame;
5
- width = _width;
6
- height = _height;
7
- length = 0;
8
- }
9
-
10
- FrameIO::~FrameIO() {}
11
-
12
- FrameIO* FrameIO::decoder(unsigned char* frame, int width, int height, int bpp) {
13
- switch(bpp) {
14
- case 24: return new FrameIO_24(frame, width, height);
15
- case 30:
16
- case 32: return new FrameIO_32(frame, width, height);
17
- case 36: return new FrameIO_36(frame, width, height);
18
- case 48: return new FrameIO_48(frame, width, height);
19
- }
20
- return NULL;
21
- }
22
-
23
- unsigned char* FrameIO::get_frame() { return frame; }
24
-
25
-
26
- FrameIO_24::FrameIO_24(unsigned char* _frame, int _width, int _height) : FrameIO(_frame, _width, _height) {
27
- length = width*height*3;
28
- }
29
-
30
- void FrameIO_24::decode(charstream& writer, bool bit16) {
31
- for(size_t index = 0; index < length; index++) {
32
- writer.write_char(frame[index]);
33
- // TODO: Here is only bigendian encoding
34
- if(bit16) writer.write_char(0);
35
- }
36
- }
37
-
38
- FrameIO_32::FrameIO_32(unsigned char* _frame, int _width, int _height) : FrameIO(_frame, _width, _height) {
39
- length = width*height*4;
40
- }
41
-
42
- void FrameIO_32::decode(charstream& writer, bool bit16) {
43
- unsigned char* frame = get_frame();
44
- for(size_t index = 0; index < length; index += 4) {
45
- short r = (short(frame[0]) << 2) + (frame[1] >> 6);
46
- short g = (short(frame[1]) << 2) + (frame[2] >> 6);
47
- short b = (short(frame[2]) << 4) + (frame[3] >> 4);
48
- if(bit16) {
49
- writer.write_int16_be(r);
50
- writer.write_int16_be(g);
51
- writer.write_int16_be(b);
52
- } else {
53
- writer.write_char((r >> 2) & 0xFF);
54
- writer.write_char((g >> 2) & 0xFF);
55
- writer.write_char((b >> 2) & 0xFF);
56
- }
57
- frame += 4;
58
- }
59
- }
60
-
61
- FrameIO_36::FrameIO_36(unsigned char* _frame, int _width, int _height) : FrameIO(_frame, _width, _height) {
62
- length = width*height*9/2;
63
- }
64
- void FrameIO_36::decode(charstream& writer, bool bit16) {
65
- unsigned char* frame = get_frame();
66
- int orphan_index = 0;
67
- int orphan[3*6]; //куски, которые пропускаем
68
-
69
- int pixelnum = 0;
70
-
71
- for(size_t index = 0; index < length*2/9; index++) {
72
- if (pixelnum == 6) //7й пиксель собираем и пропущеных кусков
73
- {
74
- writer.write_char(((orphan[4] & 0xF) << 4) + (orphan[2] & 0xF)); // R
75
- writer.write_char(((orphan[5] & 0xF) << 4) + (orphan[3] & 0xF)); // G
76
- writer.write_char(((orphan[10] & 0xF) << 4) + (orphan[8] & 0xF));// B
77
-
78
- pixelnum++;
79
- continue;
80
- }
81
-
82
- if (pixelnum == 7) //8й пиксель тоже собираем из пропущеных кусков
83
- {
84
- writer.write_char(((orphan[11] & 0xF) << 4) + (orphan[9] & 0xF)); // R
85
- writer.write_char(((orphan[16] & 0xF) << 4) + (orphan[14] & 0xF));// G
86
- writer.write_char(((orphan[17] & 0xF) << 4) + (orphan[15] & 0xF));// B
87
-
88
- pixelnum = 0;
89
- orphan_index = 0;
90
-
91
- continue;
92
- }
93
-
94
- writer.write_char(*frame++); // R
95
- orphan[orphan_index++] = *frame++;
96
-
97
- writer.write_char(*frame++); // G
98
- orphan[orphan_index++] = *frame++;
99
-
100
- writer.write_char(*frame++); // B
101
- orphan[orphan_index++] = *frame++;
102
-
103
- pixelnum++;
104
- }
105
- }
106
-
107
- FrameIO_48::FrameIO_48(unsigned char* _frame, int _width, int _height) : FrameIO(_frame, _width, _height) {
108
- length = width*height*6;
109
- }
110
- void FrameIO_48::decode(charstream& writer, bool bit16) {
111
- for(size_t index = 0; index < length / 6; index++) {
112
- writer.write_char(frame[index*6 + 0]);
113
- if(bit16) writer.write_char(frame[index*6 + 1]);
114
- writer.write_char(frame[index*6 + 2]);
115
- if(bit16) writer.write_char(frame[index*6 + 3]);
116
- writer.write_char(frame[index*6 + 4]);
117
- if(bit16) writer.write_char(frame[index*6 + 5]);
118
- }
119
- }
120
-
@@ -1,45 +0,0 @@
1
- #ifndef _FRAME_IO_H_
2
- #define _FRAME_IO_H_
3
- #include "charstream.h"
4
- #include "wiretap.h"
5
-
6
-
7
- class FrameIO {
8
- public:
9
- FrameIO(unsigned char* _frame, int width, int height);
10
- virtual void decode(charstream& writer, bool bit16 = false) = 0;
11
- virtual ~FrameIO();
12
- static FrameIO* decoder(unsigned char* frame, int width, int height, int bpp);
13
- unsigned char* get_frame();
14
- protected:
15
- unsigned char* frame;
16
- size_t length;
17
- int width;
18
- int height;
19
- };
20
-
21
- class FrameIO_24 : public FrameIO {
22
- public:
23
- FrameIO_24(unsigned char* _frame, int width, int height);
24
- virtual void decode(charstream& writer, bool bit16 = false);
25
- };
26
-
27
- class FrameIO_32 : public FrameIO {
28
- public:
29
- FrameIO_32(unsigned char* _frame, int width, int height);
30
- virtual void decode(charstream& writer, bool bit16 = false);
31
- };
32
-
33
- class FrameIO_36 : public FrameIO {
34
- public:
35
- FrameIO_36(unsigned char* _frame, int width, int height);
36
- virtual void decode(charstream& writer, bool bit16 = false);
37
- };
38
-
39
- class FrameIO_48 : public FrameIO {
40
- public:
41
- FrameIO_48(unsigned char* _frame, int width, int height);
42
- virtual void decode(charstream& writer, bool bit16 = false);
43
- };
44
-
45
- #endif /* _FRAME_IO_H_ */