Class: Omnizip::Filters::Bcj2StreamData
- Inherits:
-
Object
- Object
- Omnizip::Filters::Bcj2StreamData
- Includes:
- Bcj2Constants
- Defined in:
- lib/omnizip/filters/bcj2/stream_data.rb
Overview
Model class representing the 4 BCJ2 streams.
BCJ2 splits data into:
- Main stream: Non-convertible bytes
- Call stream: CALL (E8) instruction addresses
- Jump stream: JUMP (E9) instruction addresses
- RC stream: Range coder probability data
Constant Summary
Constants included from Bcj2Constants
Omnizip::Filters::Bcj2Constants::ADDRESS_SIZE, Omnizip::Filters::Bcj2Constants::BIT_MODEL_TOTAL, Omnizip::Filters::Bcj2Constants::BIT_MODEL_TOTAL_BITS, Omnizip::Filters::Bcj2Constants::INITIAL_PROB, Omnizip::Filters::Bcj2Constants::MOVE_BITS, Omnizip::Filters::Bcj2Constants::NUM_PROBS, Omnizip::Filters::Bcj2Constants::NUM_STREAMS, Omnizip::Filters::Bcj2Constants::OPCODE_CALL, Omnizip::Filters::Bcj2Constants::OPCODE_JUMP, Omnizip::Filters::Bcj2Constants::STREAM_CALL, Omnizip::Filters::Bcj2Constants::STREAM_JUMP, Omnizip::Filters::Bcj2Constants::STREAM_MAIN, Omnizip::Filters::Bcj2Constants::STREAM_RC, Omnizip::Filters::Bcj2Constants::TOP_VALUE
Instance Attribute Summary collapse
-
#call ⇒ Object
Returns the value of attribute call.
-
#jump ⇒ Object
Returns the value of attribute jump.
-
#main ⇒ Object
Returns the value of attribute main.
-
#rc ⇒ Object
Returns the value of attribute rc.
Instance Method Summary collapse
-
#[](index) ⇒ String
Get stream by index.
-
#[]=(index, data) ⇒ String
Set stream by index.
-
#empty? ⇒ Boolean
Check if all streams are empty.
-
#initialize ⇒ Bcj2StreamData
constructor
Initialize empty streams.
-
#to_a ⇒ Array<String>
Get all streams as an array.
Constructor Details
#initialize ⇒ Bcj2StreamData
Initialize empty streams.
36 37 38 39 40 41 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 36 def initialize @main = String.new(encoding: Encoding::BINARY) @call = String.new(encoding: Encoding::BINARY) @jump = String.new(encoding: Encoding::BINARY) @rc = String.new(encoding: Encoding::BINARY) end |
Instance Attribute Details
#call ⇒ Object
Returns the value of attribute call.
31 32 33 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 31 def call @call end |
#jump ⇒ Object
Returns the value of attribute jump.
31 32 33 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 31 def jump @jump end |
#main ⇒ Object
Returns the value of attribute main.
31 32 33 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 31 def main @main end |
#rc ⇒ Object
Returns the value of attribute rc.
31 32 33 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 31 def rc @rc end |
Instance Method Details
#[](index) ⇒ String
Get stream by index.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 48 def [](index) case index when STREAM_MAIN then @main when STREAM_CALL then @call when STREAM_JUMP then @jump when STREAM_RC then @rc else raise ArgumentError, "Invalid stream index: #{index}" end end |
#[]=(index, data) ⇒ String
Set stream by index.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 65 def []=(index, data) case index when STREAM_MAIN then @main = data when STREAM_CALL then @call = data when STREAM_JUMP then @jump = data when STREAM_RC then @rc = data else raise ArgumentError, "Invalid stream index: #{index}" end end |
#empty? ⇒ Boolean
Check if all streams are empty.
86 87 88 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 86 def empty? @main.empty? && @call.empty? && @jump.empty? && @rc.empty? end |
#to_a ⇒ Array<String>
Get all streams as an array.
79 80 81 |
# File 'lib/omnizip/filters/bcj2/stream_data.rb', line 79 def to_a [@main, @call, @jump, @rc] end |