depix 1.1.5 → 1.1.6
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 +4 -0
- data/Manifest.txt +2 -1
- data/lib/depix.rb +1 -1
- data/lib/depix/dict.rb +12 -0
- data/lib/depix/reader.rb +7 -20
- data/test/samples/little_endian.dpx +0 -0
- data/test/test_depix.rb +8 -3
- metadata +6 -5
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
|
@@ -19,7 +19,8 @@ test/samples/E012_P001_L000002_lin.0002.dpx
|
|
|
19
19
|
test/samples/E012_P001_L000002_log.0001.dpx
|
|
20
20
|
test/samples/E012_P001_L000002_log.0002.dpx
|
|
21
21
|
test/samples/from_nuke_no_TC_meta.dpx
|
|
22
|
-
test/samples/northlight_tc_mode_mismatch.dpx
|
|
23
22
|
test/samples/gluetools_file_header.dpx
|
|
23
|
+
test/samples/little_endian.dpx
|
|
24
|
+
test/samples/northlight_tc_mode_mismatch.dpx
|
|
24
25
|
test/test_depix.rb
|
|
25
26
|
test/test_dict.rb
|
data/lib/depix.rb
CHANGED
data/lib/depix/dict.rb
CHANGED
|
@@ -414,6 +414,12 @@ module Depix
|
|
|
414
414
|
fields.map{|f| f.pattern }.join
|
|
415
415
|
end
|
|
416
416
|
|
|
417
|
+
# Get the pattern that will be used to unpack this structure and all of it's descendants
|
|
418
|
+
# from a buffer with pieces in little-endian byte order
|
|
419
|
+
def pattern_le
|
|
420
|
+
pattern.tr("gN", "eV")
|
|
421
|
+
end
|
|
422
|
+
|
|
417
423
|
# How many bytes are needed to complete this structure
|
|
418
424
|
def length
|
|
419
425
|
fields.inject(0){|_, s| _ + s.length }
|
|
@@ -433,6 +439,12 @@ module Depix
|
|
|
433
439
|
consume!(string.unpack(pattern))
|
|
434
440
|
end
|
|
435
441
|
|
|
442
|
+
# Apply this structure to data in the string, returning an instance of this structure with fields completed
|
|
443
|
+
# assume little-endian fields
|
|
444
|
+
def apply_le!(string)
|
|
445
|
+
consume!(string.unpack(pattern_le))
|
|
446
|
+
end
|
|
447
|
+
|
|
436
448
|
# Get a class that would parse just the same, preserving only the fields passed in the array. This speeds
|
|
437
449
|
# up parsing because we only extract and conform the fields that we need
|
|
438
450
|
def only(*field_names)
|
data/lib/depix/reader.rb
CHANGED
|
@@ -26,28 +26,20 @@ module Depix
|
|
|
26
26
|
# The hear of Depix
|
|
27
27
|
def parse(data, compact)
|
|
28
28
|
magic = data[0..3]
|
|
29
|
-
|
|
30
29
|
raise InvalidHeader, "No magic bytes found at start" unless %w( SDPX XPDS).include?(magic)
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
is_le = (magic == "XPDS")
|
|
33
32
|
|
|
34
|
-
is_be = (magic == "SDPX")
|
|
35
33
|
version_check = FileInfo.only(:magic, :version)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
version_check.consume!(data.unpack(version_check.pattern))
|
|
40
|
-
else
|
|
41
|
-
version_check.consume!(data.unpack(make_le(version_check.pattern)))
|
|
42
|
-
end
|
|
34
|
+
begin
|
|
35
|
+
result = is_le ? version_check.apply_le!(data) : version_check.apply!(data)
|
|
36
|
+
raise InvalidHeader, "Unknown version tag #{result.version}" unless result.version =~ /V(\d)\.(\d+)/i
|
|
43
37
|
rescue ArgumentError
|
|
44
|
-
raise InvalidHeader
|
|
38
|
+
raise InvalidHeader, "Cannot unpack header"
|
|
45
39
|
end
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
template = is_be ? DPX.pattern : make_le(DPX.pattern)
|
|
50
|
-
struct.consume!(data.unpack(struct.pattern))
|
|
41
|
+
struct = compact ? CompactDPX : DPX
|
|
42
|
+
is_le ? struct.apply_le!(data) : struct.apply!(data)
|
|
51
43
|
end
|
|
52
44
|
|
|
53
45
|
# Describe a filled DPX structure
|
|
@@ -74,10 +66,5 @@ module Depix
|
|
|
74
66
|
end.map{|e| (' ' * pad_offset) + e }.join("\n")
|
|
75
67
|
end
|
|
76
68
|
|
|
77
|
-
# Convert an unpack pattern to LE
|
|
78
|
-
def make_le(pattern)
|
|
79
|
-
pattern.gsub(/n/, "v").gsub(/N/, "V").gsub(/g/, "f")
|
|
80
|
-
end
|
|
81
|
-
|
|
82
69
|
end
|
|
83
70
|
end
|
|
Binary file
|
data/test/test_depix.rb
CHANGED
|
@@ -108,10 +108,9 @@ class ReaderTest < Test::Unit::TestCase
|
|
|
108
108
|
|
|
109
109
|
s = "Mary had a little lamb" * 1000
|
|
110
110
|
assert_raise(Depix::InvalidHeader) { Depix.from_string(s) }
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
s = "SDPX Mary had a little lamb" * 1000
|
|
113
113
|
assert_raise(Depix::InvalidHeader) { Depix.from_string(s) }
|
|
114
|
-
|
|
115
114
|
end
|
|
116
115
|
|
|
117
116
|
def test_parsing_gluetools_file
|
|
@@ -132,7 +131,13 @@ class ReaderTest < Test::Unit::TestCase
|
|
|
132
131
|
assert_equal "05:00:59:20", dpx.time_code.to_s
|
|
133
132
|
assert_equal 25, dpx.time_code.fps
|
|
134
133
|
end
|
|
135
|
-
|
|
134
|
+
|
|
135
|
+
def test_parse_le_dpx
|
|
136
|
+
# This file is little-endian
|
|
137
|
+
dpx = Depix.from_file(File.dirname(__FILE__) + "/samples/little_endian.dpx")
|
|
138
|
+
assert_in_delta 25, dpx.film.frame_rate, 0.01
|
|
139
|
+
end
|
|
140
|
+
|
|
136
141
|
end
|
|
137
142
|
|
|
138
143
|
class EditorTest < Test::Unit::TestCase
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: depix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 31
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 1.1.
|
|
9
|
+
- 6
|
|
10
|
+
version: 1.1.6
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Julik Tarkhanov
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-
|
|
18
|
+
date: 2010-11-27 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -98,8 +98,9 @@ files:
|
|
|
98
98
|
- test/samples/E012_P001_L000002_log.0001.dpx
|
|
99
99
|
- test/samples/E012_P001_L000002_log.0002.dpx
|
|
100
100
|
- test/samples/from_nuke_no_TC_meta.dpx
|
|
101
|
-
- test/samples/northlight_tc_mode_mismatch.dpx
|
|
102
101
|
- test/samples/gluetools_file_header.dpx
|
|
102
|
+
- test/samples/little_endian.dpx
|
|
103
|
+
- test/samples/northlight_tc_mode_mismatch.dpx
|
|
103
104
|
- test/test_depix.rb
|
|
104
105
|
- test/test_dict.rb
|
|
105
106
|
has_rdoc: true
|