Module: Depix::Synthetics

Defined in:
lib/depix/synthetics.rb

Overview

Offers convenience access to a number of interesting fields of the DPX object already decoded into the most usable form (and pulled from a field that you won’t expect)

Constant Summary collapse

DEFAULT_DPX_FPS =
25

Instance Method Summary collapse

Instance Method Details

#aspectObject

Aspect in it’s traditional representation (1.77 for 16x9 and so on)



61
62
63
# File 'lib/depix/synthetics.rb', line 61

def aspect
  "%.2f" % (image.pixels_per_line / image.lines_per_element.to_f * pixel_aspect)
end

#colorimetricObject

Get the name of the transfer function (Linear, Logarithmic, …)



46
47
48
# File 'lib/depix/synthetics.rb', line 46

def colorimetric
  Depix::COLORIMETRIC.invert[image.image_elements[0].colorimetric]
end

#component_typeObject

Get the name of the compnent type (RGB, YCbCr, …)



51
52
53
# File 'lib/depix/synthetics.rb', line 51

def component_type
  Depix::COMPONENT_TYPE.invert[image.image_elements[0].descriptor]
end

#flame_reelObject

Return the flame reel name. The data after the first null byte is not meant to be seen and is used by Flame internally as it seems



16
17
18
19
# File 'lib/depix/synthetics.rb', line 16

def flame_reel
  return nil unless orientation.device
  orientation.device.split(0x00.chr).shift
end

#flame_reel=(new_reel) ⇒ Object

Assign reel name



22
23
24
# File 'lib/depix/synthetics.rb', line 22

def flame_reel=(new_reel)
  orientation.device = new_reel
end

#keycodeObject

Get formatted keycode as string, empty elements are omitted



9
10
11
# File 'lib/depix/synthetics.rb', line 9

def keycode
  [film.id, film.type, film.offset, film.prefix, film.count].compact.join(' ')
end

#le?Boolean

Returns:

  • (Boolean)


70
71
72
73
# File 'lib/depix/synthetics.rb', line 70

def le?
  # $stderr.puts "Depix::Synthetics.le? is deprecated, use little_endian? instead"
  little_endian?
end

#little_endian?Boolean

Is this DPX file little-endian?

Returns:

  • (Boolean)


66
67
68
# File 'lib/depix/synthetics.rb', line 66

def little_endian?
  file.magic == 'XPDS'
end

#pixel_aspectObject

Returns the pixel aspect



56
57
58
# File 'lib/depix/synthetics.rb', line 56

def pixel_aspect
  (orientation.aspect_ratio[0].to_f / orientation.aspect_ratio[1].to_f)
end

#time_codeObject

Get television.time_code as a Timecode object with a framerate. We explicitly use the television frame rate since Northlight writes different rates for television and film time code



29
30
31
32
33
34
35
36
37
38
# File 'lib/depix/synthetics.rb', line 29

def time_code
  framerates = [television.frame_rate, film.frame_rate, DEFAULT_DPX_FPS]
  framerate = framerates.find{|e| !e.nil? && !e.zero? }
  if television.time_code
    Timecode.from_uint(television.time_code, framerate)
  else
    # Assume frame position
    Timecode.new(film.frame_position, framerate)
  end
end

#time_code=(new_tc) ⇒ Object

Assign frame rate and timecode from a Timecode object



41
42
43
# File 'lib/depix/synthetics.rb', line 41

def time_code=(new_tc)
  television.time_code, television.frame_rate = new_tc.to_uint, new_tc.fps
end