Class: JXL::VarDCT::PassGroup
- Inherits:
-
Data
- Object
- Data
- JXL::VarDCT::PassGroup
- Defined in:
- lib/jxl/vardct/pass_group.rb
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
Class Method Summary collapse
- .merge(groups) ⇒ Object
- .read(reader, frame, lf_global, lf_group, hf_global, pass_index: 0, group_index: 0) ⇒ Object
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks
19 20 21 |
# File 'lib/jxl/vardct/pass_group.rb', line 19 def blocks @blocks end |
Class Method Details
.merge(groups) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jxl/vardct/pass_group.rb', line 20 def self.merge(groups) return groups.first if groups.one? blocks = groups.first.blocks.each_index.map do |index| pass_blocks = groups.map { _1.blocks.fetch(index) } first = pass_blocks.first unless pass_blocks.all? { _1.x == first.x && _1.y == first.y && _1.strategy == first.strategy } raise CorruptError, "progressive AC blocks differ between passes" end coefficients = 3.times.map do |channel| first.coefficients[channel].each_index.map do |coefficient| pass_blocks.sum { _1.coefficients[channel][coefficient] } end end QuantizedBlock.new(x: first.x, y: first.y, strategy: first.strategy, coefficients:) end new(blocks:) end |
.read(reader, frame, lf_global, lf_group, hf_global, pass_index: 0, group_index: 0) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jxl/vardct/pass_group.rb', line 40 def self.read(reader, frame, lf_global, lf_group, hf_global, pass_index: 0, group_index: 0) pass = hf_global.passes.fetch(pass_index) selector_bits = (hf_global.histogram_count - 1).bit_length selector = selector_bits.zero? ? 0 : reader.read(selector_bits) raise CorruptError, "invalid AC histogram selector" if selector >= hf_global.histogram_count context_offset = selector * lf_global.block_context_map.ac_context_count decoder = pass.entropy.fork(reader, distance_multiplier: 0) blocks = decode_blocks(decoder, frame, lf_global.block_context_map, lf_group, pass.orders, context_offset, frame.passes.shifts.fetch(pass_index), group_index) decoder.final_state! if lf_global.modular_group group_dim = 128 << frame.group_size_shift groups_x = Num.ceil_div(frame.encoded_width, group_dim) dc_groups = Num.ceil_div(frame.blocks_width, group_dim) * Num.ceil_div(frame.blocks_height, group_dim) group_count = groups_x * Num.ceil_div(frame.encoded_height, group_dim) stream_id = 1 + (3 * dc_groups) + 17 + (group_count * pass_index) + group_index Modular::Decoder.decode_grouped_pass!(reader, lf_global.modular_group, frame.passes, pass_index:, group_index:, groups_x:, stream_id:) end new(blocks:) end |