Class: MP4::Binary::Base128Size

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/mp4/binary/mp4a.rb

Instance Method Summary collapse

Instance Method Details

#getObject



6
7
8
# File 'lib/mp4/binary/mp4a.rb', line 6

def get
  size_bytes.inject(0) { |acc, byte| (acc << 7) | (byte & 0x7f) }
end

#set(v) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/mp4/binary/mp4a.rb', line 10

def set(v)
  self.size_bytes = []
  while v.positive?
    self.size_bytes.unshift((v & 0x7f) | 0x80)
    v >>= 7
  end
  self.size_bytes[-1] &= 0x7f
end