tracksperanto 2.6.3 → 2.7.0

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.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ === 2.7.0 / 2011-13-10
2
+
3
+ * Speedup Shake script parsing by using a buffering reader
4
+
5
+ === 2.6.4 / 2011-29-08
6
+
7
+ * Use various external dependencies that we extracted
8
+ * Note that Nuke now supports import and export of camera tracker features!
9
+
1
10
  === 2.6.3 / 2011-31-07
2
11
 
3
12
  * Report progress from the parser for Flame, like it has been before
data/Manifest.txt CHANGED
@@ -51,16 +51,15 @@ lib/middleware/slipper.rb
51
51
  lib/middleware/start_trim.rb
52
52
  lib/pipeline/base.rb
53
53
  lib/tracksperanto.rb
54
- lib/tracksperanto/accumulator.rb
55
54
  lib/tracksperanto/block_init.rb
56
55
  lib/tracksperanto/buffer_io.rb
56
+ lib/tracksperanto/buffering_reader.rb
57
57
  lib/tracksperanto/casts.rb
58
58
  lib/tracksperanto/const_name.rb
59
59
  lib/tracksperanto/ext_io.rb
60
60
  lib/tracksperanto/flame_builder.rb
61
61
  lib/tracksperanto/format_detector.rb
62
62
  lib/tracksperanto/keyframe.rb
63
- lib/tracksperanto/progressive_io.rb
64
63
  lib/tracksperanto/returning.rb
65
64
  lib/tracksperanto/safety.rb
66
65
  lib/tracksperanto/simple_export.rb
@@ -94,7 +93,6 @@ test/export/test_pftrack5_export.rb
94
93
  test/export/test_pftrack_export.rb
95
94
  test/export/test_shake_export.rb
96
95
  test/export/test_syntheyes_export.rb
97
- test/fixtures/processing_log.txt
98
96
  test/helper.rb
99
97
  test/import/samples/3de_v3/3de_export_v3.txt
100
98
  test/import/samples/3de_v4/3de_export_cube.txt
@@ -135,6 +133,7 @@ test/import/samples/shake_script/stabilize_nodes_with_hermite.shk
135
133
  test/import/samples/shake_script/three_tracks_in_one_stabilizer.shk
136
134
  test/import/samples/shake_script/track.shk
137
135
  test/import/samples/shake_script/two_tracks_in_one_tracker.shk
136
+ test/import/samples/shake_text/nuke_camtracker.txt
138
137
  test/import/samples/shake_text/one_shake_tracker.txt
139
138
  test/import/samples/shake_text/one_shake_tracker_from_first.txt
140
139
  test/import/samples/shake_text/two_shake_trackers.txt
@@ -168,8 +167,8 @@ test/middleware/test_scaler_middleware.rb
168
167
  test/middleware/test_shift_middleware.rb
169
168
  test/middleware/test_slip_middleware.rb
170
169
  test/middleware/test_start_trim_middleware.rb
171
- test/test_accumulator.rb
172
170
  test/test_buffer_io.rb
171
+ test/test_bufferingreader.rb
173
172
  test/test_cli.rb
174
173
  test/test_const_name.rb
175
174
  test/test_extio.rb
@@ -177,7 +176,6 @@ test/test_flame_builder.rb
177
176
  test/test_format_detector.rb
178
177
  test/test_keyframe.rb
179
178
  test/test_pipeline.rb
180
- test/test_progressive_io.rb
181
179
  test/test_simple_export.rb
182
180
  test/test_tracker.rb
183
181
  test/test_tracksperanto.rb
data/Rakefile CHANGED
@@ -11,6 +11,8 @@ begin
11
11
  p.version = Tracksperanto::VERSION
12
12
 
13
13
  p.extra_deps = {
14
+ "obuf" => "~> 1.0",
15
+ "progressive_io" => "~> 1.0",
14
16
  "flame_channel_parser" => "2.2.1",
15
17
  "progressbar" => "~> 0.9",
16
18
  "update_hints" => "~> 1.0"
@@ -9,7 +9,7 @@ class Tracksperanto::Export::ShakeText < Tracksperanto::Export::Base
9
9
  end
10
10
 
11
11
  def self.human_name
12
- "Shake trackers in a .txt file"
12
+ "Shake trackers in a .txt file (also usable with Nuke's CameraTracker)"
13
13
  end
14
14
 
15
15
  def start_tracker_segment(tracker_name)
@@ -20,8 +20,13 @@ module Tracksperanto::ShakeGrammar
20
20
  # to the downstream lexers instantiated for nested data structures.
21
21
  # You can use the sentinel to collect data from child nodes for example.
22
22
  def initialize(with_io, sentinel = nil, limit_to_one_stmt = false, stack_depth = 0)
23
+ # We parse byte by byte, but reading byte by byte is very slow. We therefore use a buffering reader
24
+ # that will cache in chunks, and then read from there byte by byte. This yields a substantial speedup (4.9 seconds for the test
25
+ # as opposed to 7.9 without this). We do check for the proper class only once so that when we use nested lexers
26
+ # we only wrap the passed IO once, and only if necessary.
27
+ with_io = Tracksperanto::BufferingReader.new(with_io) unless with_io.respond_to?(:read_one_byte)
23
28
  @io, @stack, @buf, @sentinel, @limit_to_one_stmt, @stack_depth = with_io, [], '', sentinel, limit_to_one_stmt, stack_depth
24
- catch(STOP_TOKEN) { parse until @io.eof? }
29
+ catch(STOP_TOKEN) { parse until @io.data_exhausted? }
25
30
  @in_comment ? consume_comment! : consume_atom!
26
31
  end
27
32
 
@@ -38,7 +43,7 @@ module Tracksperanto::ShakeGrammar
38
43
 
39
44
  def parse
40
45
 
41
- c = @io.read(1)
46
+ c = @io.read_one_byte
42
47
 
43
48
  if @buf.length > MAX_BUFFER_SIZE # Wrong format and the buffer is filled up, bail
44
49
  raise WrongInputError, "Atom buffer overflow at #{MAX_BUFFER_SIZE} bytes, this is definitely not a Shake script"
@@ -2,7 +2,7 @@
2
2
  class Tracksperanto::Import::ShakeText < Tracksperanto::Import::Base
3
3
 
4
4
  def self.human_name
5
- "Shake .txt tracker file"
5
+ "Shake .txt tracker file and Nuke CameraTracker auto tracks export"
6
6
  end
7
7
 
8
8
  def each
data/lib/pipeline/base.rb CHANGED
@@ -20,7 +20,8 @@ module Tracksperanto::Pipeline
20
20
  end
21
21
  end
22
22
 
23
- # The base pipeline is the whole process of track conversion from start to finish. The pipeline object organizes the import formats, scans them,
23
+ # The base pipeline is the whole process of track conversion from start to finish.
24
+ # The pipeline object organizes the import formats, scans them,
24
25
  # applies the middlewares. Here's how a calling sequence for a pipeline looks like:
25
26
  #
26
27
  # pipe = Tracksperanto::Pipeline::Base.new
@@ -157,18 +158,17 @@ module Tracksperanto::Pipeline
157
158
 
158
159
  @ios.push(io_with_progress)
159
160
 
160
- @accumulator = Tracksperanto::Accumulator.new
161
+ @accumulator = Obuf.new
161
162
 
162
163
  begin
163
164
 
164
- # OBSOLETE - for this version we are going to permit it.
165
- if importer.respond_to?(:stream_parse)
165
+ if importer.respond_to?(:each)
166
+ importer.io = io_with_progress
167
+ importer.each {|t| @accumulator.push(t) unless t.empty? }
168
+ else # OBSOLETE - for this version we are going to permit it.
166
169
  STDERR.puts "Import::Base#stream_parse(io) is obsolete, please rewrite your importer to use each instead"
167
170
  importer.receiver = @accumulator
168
171
  importer.stream_parse(io_with_progress)
169
- else
170
- importer.io = io_with_progress
171
- importer.each {|t| @accumulator.push(t) unless t.empty? }
172
172
  end
173
173
 
174
174
  report_progress(percent_complete = 50.0, "Validating #{@accumulator.size} imported trackers")
@@ -0,0 +1,40 @@
1
+ # Shake uses this reader to parse byte by byte without having to read byte by byte.
2
+ # Reading byte by byte is very inefficient, but we want to parse byte by byte since
3
+ # this makes parser construction much easier. So what we do is cache some chunk of the
4
+ # passed buffer and read from that. Once exhausted there will be some caching again,
5
+ # and ad infinitum until the passed buffer is exhausted
6
+ class Tracksperanto::BufferingReader
7
+
8
+ # By default will read in chunks of 4K
9
+ DEFAULT_BUFFER_SIZE = 10240
10
+
11
+ def initialize(with_io, buffer_size = DEFAULT_BUFFER_SIZE)
12
+ @io = with_io
13
+ @bufsize = buffer_size
14
+ @buf = StringIO.new
15
+ end
16
+
17
+ # Will transparently read one byte off the contained IO, maintaining the internal cache.
18
+ # If the cache has been depleted it will read a big chunk from the IO and cache it and then
19
+ # return the byte
20
+ def read_one_byte
21
+ cache if @buf.pos == @buf.size
22
+
23
+ return nil if @buf.size.zero?
24
+ return @buf.read(1)
25
+ end
26
+
27
+ # Tells whether all the data has been both read from the passed buffer
28
+ # and from the internal cache buffer (checks whether there is anything that
29
+ # can be retreived using read_one_byte)
30
+ def data_exhausted?
31
+ @buf.eof? && @io.eof?
32
+ end
33
+
34
+ private
35
+
36
+ def cache
37
+ data = @io.read(@bufsize)
38
+ @buf = StringIO.new(data.to_s) # Make nil become ""
39
+ end
40
+ end
data/lib/tracksperanto.rb CHANGED
@@ -2,10 +2,12 @@ require 'stringio'
2
2
  require 'delegate'
3
3
  require 'tempfile'
4
4
  require 'flame_channel_parser'
5
+ require "obuf"
6
+ require "progressive_io"
5
7
 
6
8
  module Tracksperanto
7
9
  PATH = File.expand_path(File.dirname(__FILE__))
8
- VERSION = '2.6.3'
10
+ VERSION = '2.7.0'
9
11
 
10
12
  module Import; end
11
13
  module Export; end
@@ -70,6 +72,15 @@ module Tracksperanto
70
72
 
71
73
  raise UnknownImporterError, "Unknown importer #{name.inspect}"
72
74
  end
75
+
76
+ # DEPRECATED, will be removed in Tracksperanto 3
77
+ class Accumulator < Obuf
78
+ end
79
+
80
+ # DEPRECATED, will be removed in Tracksperanto 3
81
+ class Tracksperanto::ProgressiveIO < ProgressiveIO
82
+ end
83
+
73
84
  end
74
85
 
75
86
  %w(
@@ -83,12 +94,11 @@ end
83
94
  tracker
84
95
  format_detector
85
96
  ext_io
86
- progressive_io
87
97
  buffer_io
88
98
  simple_export
89
99
  uv_coordinates
90
100
  flame_builder
91
- accumulator
101
+ buffering_reader
92
102
  ).each do | submodule |
93
103
  require File.join(Tracksperanto::PATH, "tracksperanto", submodule)
94
104
  end
@@ -10,6 +10,6 @@ class ShakeTextExportTest < Test::Unit::TestCase
10
10
 
11
11
  def test_exporter_meta
12
12
  assert_equal "shake_trackers.txt", Tracksperanto::Export::ShakeText.desc_and_extension
13
- assert_equal "Shake trackers in a .txt file", Tracksperanto::Export::ShakeText.human_name
13
+ assert_equal "Shake trackers in a .txt file (also usable with Nuke's CameraTracker)", Tracksperanto::Export::ShakeText.human_name
14
14
  end
15
15
  end