10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/jxl/vardct/coeff_order.rb', line 10
def read(reader, used_orders, used_strategies)
decoder = Entropy::Decoder.read(reader, 8) unless used_orders.zero?
used_order_ids = used_strategies.map { AcStrategy[_1].order }.uniq
result = {}
ORDER_REPRESENTATIVES.each_with_index do |strategy_id, order|
next if !used_order_ids.include?(order) && used_orders[order].zero?
strategy = AcStrategy[strategy_id]
natural = strategy.natural_order
3.times do |channel|
permutation = if used_orders[order].zero?
natural
else
Entropy::Permutation.read_with_decoder(
decoder, natural.length, skip: strategy.blocks_x * strategy.blocks_y
).map { natural[_1] }
end
result[[order, channel]] = permutation if used_order_ids.include?(order)
end
end
decoder&.final_state!
result
end
|