Module: JXL::Filter::EPF
- Defined in:
- lib/jxl/filter/epf.rb
Constant Summary collapse
- INV_SIGMA_NUM =
-1.17157287525381
- MIN_SIGMA =
-3.9052429175127
- PLUS =
[[0, 0], [-1, 0], [0, -1], [1, 0], [0, 1]].freeze
- CROSS =
[[-1, 0], [0, -1], [0, 1], [1, 0]].freeze
- WIDE =
[[-2, 0], [-1, -1], [-1, 0], [-1, 1], [0, -2], [0, -1], [0, 1], [0, 2], [1, -1], [1, 0], [1, 1], [2, 0]].freeze
Class Method Summary collapse
- .apply(channels, loop_filter, global, lf_group) ⇒ Object
- .apply_modular(channels, loop_filter) ⇒ Object
- .sigma_map(loop_filter, global, lf_group) ⇒ Object
Class Method Details
.apply(channels, loop_filter, global, lf_group) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/jxl/filter/epf.rb', line 15 def apply(channels, loop_filter, global, lf_group) return channels if loop_filter.epf_iterations.zero? sigma = sigma_map(loop_filter, global, lf_group) apply_filter(channels, sigma, loop_filter) end |
.apply_modular(channels, loop_filter) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/jxl/filter/epf.rb', line 22 def apply_modular(channels, loop_filter) return channels if loop_filter.epf_iterations.zero? sigma = Plane.new(Num.ceil_div(channels.first.width, 8), Num.ceil_div(channels.first.height, 8), INV_SIGMA_NUM / loop_filter.epf_sigma_for_modular) apply_filter(channels, sigma, loop_filter) end |
.sigma_map(loop_filter, global, lf_group) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jxl/filter/epf.rb', line 42 def sigma_map(loop_filter, global, lf_group) width = lf_group.quant_field.width height = lf_group.quant_field.height output = Plane.new(width, height) height.times do |y| width.times do |x| index = (y * width) + x next unless lf_group.strategy_first[index] strategy = lf_group.strategies[index] quant = lf_group.quant_field[x, y] base = loop_filter.epf_quant_mul / (global.quantizer.scale * quant * INV_SIGMA_NUM) strategy.blocks_y.times do |dy| strategy.blocks_x.times do |dx| sharpness = lf_group.sharpness[x + dx, y + dy] value = [base * loop_filter.epf_sharpness[sharpness], -1e-4].min output[x + dx, y + dy] = 1.0 / value end end end end output end |