depix 1.0.5 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/DPX_HEADER_STRUCTURE.txt +1 -1
- data/History.txt +10 -0
- data/Manifest.txt +4 -1
- data/README.txt +1 -1
- data/lib/depix.rb +1 -1
- data/lib/depix/dict.rb +32 -4
- data/lib/depix/editor.rb +31 -9
- data/lib/depix/reader.rb +7 -7
- data/lib/depix/structs.rb +1 -1
- data/test/.DS_Store +0 -0
- data/test/samples/.DS_Store +0 -0
- data/test/samples/026_FROM_HERO_TAPE_5-3-1_MOV.0029.dpx +0 -0
- data/test/test_depix.rb +3 -2
- data/test/test_dict.rb +1 -1
- metadata +12 -7
- data/depix.gemspec +0 -35
data/.DS_Store
ADDED
Binary file
|
data/DPX_HEADER_STRUCTURE.txt
CHANGED
@@ -18,7 +18,7 @@ DPX metadata gets returned as a Depix::DPX object with nested properties.
|
|
18
18
|
* <tt>filename</tt> (String) Original filename
|
19
19
|
* <tt>timestamp</tt> (String) Creation timestamp
|
20
20
|
* <tt>creator</tt> (String) Creator application
|
21
|
-
* <tt>
|
21
|
+
* <tt>project</tt> (String) Project name
|
22
22
|
* <tt>copyright</tt> (String) Copyright
|
23
23
|
* <tt>encrypt_key</tt> Encryption key
|
24
24
|
* <tt>reserve</tt> (String)
|
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 1.0.8 / 2009-11-14
|
2
|
+
|
3
|
+
* Fix the version tag check so that it allows all versions but is still included, and so that the tests run
|
4
|
+
|
5
|
+
=== 1.0.7 / 2009-05-21
|
6
|
+
|
7
|
+
* Do not bail out on headers newer than V1.0
|
8
|
+
* Allow access to headers directly in Depix::Editor
|
9
|
+
* Fix project field name
|
10
|
+
|
1
11
|
=== 1.0.5 / 2009-01-18
|
2
12
|
|
3
13
|
* Switch project to guerilla-di
|
data/Manifest.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
+
.DS_Store
|
1
2
|
DPX_HEADER_STRUCTURE.txt
|
2
3
|
History.txt
|
3
4
|
Manifest.txt
|
4
5
|
README.txt
|
5
6
|
Rakefile
|
6
7
|
bin/depix-describe
|
7
|
-
depix.gemspec
|
8
8
|
lib/depix.rb
|
9
9
|
lib/depix/benchmark.rb
|
10
10
|
lib/depix/compact_structs.rb
|
@@ -14,6 +14,9 @@ lib/depix/enums.rb
|
|
14
14
|
lib/depix/reader.rb
|
15
15
|
lib/depix/struct_explainer.rb
|
16
16
|
lib/depix/structs.rb
|
17
|
+
test/.DS_Store
|
18
|
+
test/samples/.DS_Store
|
19
|
+
test/samples/026_FROM_HERO_TAPE_5-3-1_MOV.0029.dpx
|
17
20
|
test/samples/E012_P001_L000002_lin.0001.dpx
|
18
21
|
test/samples/E012_P001_L000002_lin.0002.dpx
|
19
22
|
test/samples/E012_P001_L000002_log.0001.dpx
|
data/README.txt
CHANGED
data/lib/depix.rb
CHANGED
data/lib/depix/dict.rb
CHANGED
@@ -1,8 +1,34 @@
|
|
1
1
|
module Depix
|
2
2
|
|
3
3
|
#:stopdoc:
|
4
|
+
|
5
|
+
=begin
|
6
|
+
A basic C structs library (only works by value).
|
7
|
+
Here's the basic mode of operation:
|
8
|
+
1) You define a struct, with a number of fields in it
|
9
|
+
3) Each field knows how big it is and how to produce a pattern to get it's value from the byte stream
|
10
|
+
by using Ruby's "pack/unpack". Each field thus provides an unpack pattern, and patterns are ordered
|
11
|
+
into a stack, starting with the first unpack pattern
|
12
|
+
4) When you parse some bytes using the struct, heres what will happen:
|
13
|
+
- An unpack pattern will be compiled from all of the fields composing the struct,
|
14
|
+
and it will be a single string. The string gets applied to the bytes passed to parse()
|
15
|
+
- An array of unpacked values returned by unpack is then passed to the struct's consumption engine,
|
16
|
+
which lets each field take as many items off the stack as it needs. A field might happily produce
|
17
|
+
4 items for unpacking and then take the same 4 items off the stack of parsed values. Or not.
|
18
|
+
- A new structure gets created and for every named field it defines an attr_accessor. When consuming,
|
19
|
+
the values returned by Field objects get set using the accessors (so accessors can be overridden too!)
|
20
|
+
5) When you save out the struct roughly the same happens but in reverse (readers are called per field,
|
21
|
+
then it's checked whether the data can be packed and fits into the alloted number of bytes, and then
|
22
|
+
one big array of values is composed and passed on to Array#pack)
|
23
|
+
=end
|
24
|
+
|
4
25
|
class Field
|
5
|
-
attr_accessor :name,
|
26
|
+
attr_accessor :name, # Field name
|
27
|
+
:length, # Field length in bytes, including any possible padding
|
28
|
+
:pattern, # The unpack pattern that defines the field
|
29
|
+
:req, # Is the field required?
|
30
|
+
:desc, # Field description
|
31
|
+
:rtype # To which Ruby type this has to be cast (and which type is accepted as value)
|
6
32
|
alias_method :req?, :req
|
7
33
|
|
8
34
|
# Hash init
|
@@ -36,17 +62,19 @@ module Depix
|
|
36
62
|
R32Field.new(o)
|
37
63
|
end
|
38
64
|
|
39
|
-
# Return a cleaned value
|
65
|
+
# Return a cleaned value (like a null-terminated string truncated up to null)
|
40
66
|
def clean(v)
|
41
67
|
v
|
42
68
|
end
|
43
69
|
|
70
|
+
# Show a nice textual explanation of the field
|
44
71
|
def explain
|
45
72
|
[rtype ? ("(%s)" % rtype) : nil, desc, (req? ? "- required" : nil)].compact.join(' ')
|
46
73
|
end
|
47
74
|
|
48
75
|
# Return the actual values from the stack. The stack will begin on the element we need,
|
49
|
-
# so the default consumption is shift
|
76
|
+
# so the default consumption is shift. Normally all fields shift the stack
|
77
|
+
# as they go, and if they contain nested substructs they will pop the stack as well
|
50
78
|
def consume!(stack)
|
51
79
|
clean(stack.shift)
|
52
80
|
end
|
@@ -193,7 +221,7 @@ module Depix
|
|
193
221
|
|
194
222
|
BLANKING_VALUES = [0x00.chr, 0xFF.chr]
|
195
223
|
BLANKING_PATTERNS = BLANKING_VALUES.inject([]) do | p, char |
|
196
|
-
p << /^(#{char}+)/ << /(#{char}+)$/
|
224
|
+
p << /^([#{char}]+)/ << /([#{char}]+)$/mu
|
197
225
|
end
|
198
226
|
|
199
227
|
def pattern
|
data/lib/depix/editor.rb
CHANGED
@@ -1,32 +1,54 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
1
3
|
module Depix
|
2
4
|
# Used to edit DPX headers. Create an Editor object and pass the path to the file to it. Change the headers variable to contain the edited
|
3
|
-
# DPX headers and call commit!. Note that the DPX header will be overwritten in place - if you want to save another version you need to manage
|
4
|
-
|
5
|
+
# DPX headers and call commit!. Note that the DPX header will be overwritten in place - if you want to save another version you need to manage
|
6
|
+
# it yourself.
|
7
|
+
#
|
8
|
+
# dpx = Depix::Editor.new("/RAID/scans/1374470_adjusted.dpx")
|
9
|
+
# dpx.file.copyright = "Copyleft"
|
10
|
+
# dpx.file.reserve = "FileReserve"
|
11
|
+
# dpx.orientation.reserve = "OrientReserve"
|
12
|
+
# dpx.orientation.device = "Chainik"
|
13
|
+
# dpx.orientation.serial = "43"
|
14
|
+
# dpx.film.reserve = "FilmRezerve"
|
15
|
+
# dpx.file.project = "Mastermind"
|
16
|
+
#
|
17
|
+
# dpx.commit! # will write out the headers
|
18
|
+
class Editor < Delegator
|
5
19
|
|
6
20
|
# Stores the path to file
|
7
21
|
attr_reader :path
|
8
22
|
|
9
|
-
# Stores the Depix::DPX object with headers
|
10
|
-
attr_accessor :headers
|
11
|
-
|
12
23
|
# Create a new editor for the file at path
|
13
24
|
def initialize(file_path)
|
14
25
|
@path = file_path
|
15
|
-
@
|
26
|
+
@dpx = Depix.from_file(@path)
|
16
27
|
end
|
17
28
|
|
18
29
|
# Save the headers to file at path, overwriting the old ones
|
19
30
|
def commit!
|
20
|
-
raise "No headers" unless @
|
21
|
-
raise "Cannot pack LE headers" if @
|
22
|
-
packed = @
|
31
|
+
raise "No headers" unless @dpx
|
32
|
+
raise "Cannot pack LE headers yet" if @dpx.le?
|
33
|
+
packed = @dpx.class.pack(@dpx)
|
23
34
|
|
24
35
|
# Validate that we can unpack first - what if something went wrong?
|
25
36
|
Depix::Reader.new.parse(packed, false)
|
26
37
|
|
38
|
+
# Use in-place writing into DPX file (this is what + does)
|
27
39
|
File.open(@path, 'rb+') do | f |
|
28
40
|
f.seek(0, IO::SEEK_SET); f.write(packed)
|
29
41
|
end
|
30
42
|
end
|
43
|
+
|
44
|
+
# DEPRECATED
|
45
|
+
def headers
|
46
|
+
STDERR.puts "Depix::Editor#headers is deprecated, use the Editor itself instead"
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
def __getobj__
|
51
|
+
@dpx # return object we are delegating to, required
|
52
|
+
end
|
31
53
|
end
|
32
54
|
end
|
data/lib/depix/reader.rb
CHANGED
@@ -26,14 +26,14 @@ module Depix
|
|
26
26
|
# The hear of Depix
|
27
27
|
def parse(data, compact)
|
28
28
|
magic = data[0..3]
|
29
|
-
|
29
|
+
|
30
30
|
raise InvalidHeader, "No magic bytes found at start" unless %w( SDPX XPDS).include?(magic)
|
31
|
-
|
31
|
+
|
32
32
|
struct = compact ? CompactDPX : DPX
|
33
|
-
|
33
|
+
|
34
34
|
is_be = (magic == "SDPX")
|
35
35
|
version_check = FileInfo.only(:magic, :version)
|
36
|
-
|
36
|
+
|
37
37
|
result = begin
|
38
38
|
if is_be
|
39
39
|
version_check.consume!(data.unpack(version_check.pattern))
|
@@ -43,9 +43,9 @@ module Depix
|
|
43
43
|
rescue ArgumentError
|
44
44
|
raise InvalidHeader
|
45
45
|
end
|
46
|
-
|
47
|
-
raise InvalidHeader, "Unknown version tag #{result.version}" unless result.version
|
48
|
-
|
46
|
+
|
47
|
+
raise InvalidHeader, "Unknown version tag #{result.version}" unless result.version =~ /V(\d)\.(\d+)/
|
48
|
+
|
49
49
|
template = is_be ? DPX.pattern : make_le(DPX.pattern)
|
50
50
|
struct.consume!(data.unpack(struct.pattern))
|
51
51
|
end
|
data/lib/depix/structs.rb
CHANGED
@@ -17,7 +17,7 @@ module Depix
|
|
17
17
|
char :filename, 100, :desc => 'Original filename'
|
18
18
|
char :timestamp, 24, :desc => 'Creation timestamp'
|
19
19
|
char :creator, 100, :desc => 'Creator application'
|
20
|
-
char :
|
20
|
+
char :project, 200, :desc => 'Project name'
|
21
21
|
char :copyright, 200, :desc => 'Copyright'
|
22
22
|
|
23
23
|
u32 :encrypt_key, :desc => 'Encryption key'
|
data/test/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
data/test/test_depix.rb
CHANGED
@@ -119,7 +119,8 @@ class EditorTest < Test::Unit::TestCase
|
|
119
119
|
e = Depix::Editor.new(SAMPLE_DPX)
|
120
120
|
assert_not_nil e
|
121
121
|
assert_equal SAMPLE_DPX, e.path
|
122
|
-
|
122
|
+
assert_respond_to e, :flame_reel
|
123
|
+
assert_equal "E012", e.flame_reel
|
123
124
|
end
|
124
125
|
|
125
126
|
def test_commit
|
@@ -127,7 +128,7 @@ class EditorTest < Test::Unit::TestCase
|
|
127
128
|
begin
|
128
129
|
FileUtils.cp(SAMPLE_DPX, temp_path)
|
129
130
|
e = Depix::Editor.new(temp_path)
|
130
|
-
e.
|
131
|
+
e.flame_reel = "E013"
|
131
132
|
|
132
133
|
assert_nothing_raised { e.commit! }
|
133
134
|
|
data/test/test_dict.rb
CHANGED
@@ -147,7 +147,7 @@ end
|
|
147
147
|
class TestArrayField < Test::Unit::TestCase
|
148
148
|
include FieldConformity
|
149
149
|
|
150
|
-
def
|
150
|
+
def test_array_field_conforms_to_field_and_has_extra_methods
|
151
151
|
f = ArrayField.new
|
152
152
|
conform_field!(f)
|
153
153
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-14 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.3.3
|
34
34
|
version:
|
35
35
|
description: Read and write DPX file metadata
|
36
36
|
email:
|
@@ -45,13 +45,13 @@ extra_rdoc_files:
|
|
45
45
|
- Manifest.txt
|
46
46
|
- README.txt
|
47
47
|
files:
|
48
|
+
- .DS_Store
|
48
49
|
- DPX_HEADER_STRUCTURE.txt
|
49
50
|
- History.txt
|
50
51
|
- Manifest.txt
|
51
52
|
- README.txt
|
52
53
|
- Rakefile
|
53
54
|
- bin/depix-describe
|
54
|
-
- depix.gemspec
|
55
55
|
- lib/depix.rb
|
56
56
|
- lib/depix/benchmark.rb
|
57
57
|
- lib/depix/compact_structs.rb
|
@@ -61,6 +61,9 @@ files:
|
|
61
61
|
- lib/depix/reader.rb
|
62
62
|
- lib/depix/struct_explainer.rb
|
63
63
|
- lib/depix/structs.rb
|
64
|
+
- test/.DS_Store
|
65
|
+
- test/samples/.DS_Store
|
66
|
+
- test/samples/026_FROM_HERO_TAPE_5-3-1_MOV.0029.dpx
|
64
67
|
- test/samples/E012_P001_L000002_lin.0001.dpx
|
65
68
|
- test/samples/E012_P001_L000002_lin.0002.dpx
|
66
69
|
- test/samples/E012_P001_L000002_log.0001.dpx
|
@@ -68,7 +71,9 @@ files:
|
|
68
71
|
- test/test_depix.rb
|
69
72
|
- test/test_dict.rb
|
70
73
|
has_rdoc: true
|
71
|
-
homepage: http://
|
74
|
+
homepage: http://guerilla-di.org/depix
|
75
|
+
licenses: []
|
76
|
+
|
72
77
|
post_install_message:
|
73
78
|
rdoc_options:
|
74
79
|
- --main
|
@@ -90,9 +95,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
95
|
requirements: []
|
91
96
|
|
92
97
|
rubyforge_project: guerilla-di
|
93
|
-
rubygems_version: 1.3.
|
98
|
+
rubygems_version: 1.3.5
|
94
99
|
signing_key:
|
95
|
-
specification_version:
|
100
|
+
specification_version: 3
|
96
101
|
summary: Read and write DPX file metadata
|
97
102
|
test_files:
|
98
103
|
- test/test_depix.rb
|
data/depix.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = %q{depix}
|
3
|
-
s.version = "1.0.5"
|
4
|
-
|
5
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
-
s.authors = ["Julik Tarkhanov"]
|
7
|
-
s.date = %q{2008-12-26}
|
8
|
-
s.default_executable = %q{depix-describe}
|
9
|
-
s.description = %q{Read DPX file metadata}
|
10
|
-
s.email = ["me@julik.nl"]
|
11
|
-
s.executables = ["depix-describe"]
|
12
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt", "DPX_HEADER_STRUCTURE.txt"]
|
13
|
-
s.files = ["History.txt", "Manifest.txt", "README.txt", "DPX_HEADER_STRUCTURE.txt", "Rakefile", "bin/depix-describe", "lib/depix.rb", "lib/depix/struct_explainer.rb", "lib/depix/structs.rb", "lib/depix/benchmark.rb", "lib/depix/compact_structs.rb", "lib/depix/enums.rb", "lib/depix/dict.rb", "lib/depix/reader.rb", "lib/depix/editor.rb", "test/test_dict.rb", "test/test_depix.rb", "test/samples/E012_P001_L000002_lin.0001.dpx", "test/samples/E012_P001_L000002_lin.0002.dpx", "test/samples/E012_P001_L000002_log.0001.dpx", "test/samples/E012_P001_L000002_log.0002.dpx"]
|
14
|
-
s.has_rdoc = true
|
15
|
-
s.homepage = %q{http://guerilla-di.rubyforge.org/depix}
|
16
|
-
s.rdoc_options = ["--main", "README.txt"]
|
17
|
-
s.require_paths = ["lib"]
|
18
|
-
s.rubyforge_project = %q{guerilla-di}
|
19
|
-
s.rubygems_version = %q{1.3.1}
|
20
|
-
s.summary = %q{Read DPX file metadata}
|
21
|
-
s.test_files = ["test/test_depix.rb", "test/test_dict.rb"]
|
22
|
-
|
23
|
-
if s.respond_to? :specification_version then
|
24
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
-
s.specification_version = 2
|
26
|
-
|
27
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
|
29
|
-
else
|
30
|
-
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
31
|
-
end
|
32
|
-
else
|
33
|
-
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
34
|
-
end
|
35
|
-
end
|