33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/brs/option.rb', line 33
def self.get_compressor_options(options, buffer_length_names)
Validation.validate_hash options
buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults|
defaults[name] = DEFAULT_BUFFER_LENGTH
end
options = COMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options
buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }
Validation.validate_bool options[:gvl]
mode = options[:mode]
unless mode.nil?
Validation.validate_symbol mode
raise ValidateError, "invalid mode" unless MODES.include? mode
end
quality = options[:quality]
unless quality.nil?
Validation.validate_not_negative_integer quality
raise ValidateError, "invalid quality" if quality < MIN_QUALITY || quality > MAX_QUALITY
end
lgwin = options[:lgwin]
unless lgwin.nil?
Validation.validate_not_negative_integer lgwin
raise ValidateError, "invalid lgwin" if lgwin < MIN_LGWIN || lgwin > MAX_LGWIN
end
lgblock = options[:lgblock]
unless lgblock.nil?
Validation.validate_not_negative_integer lgblock
raise ValidateError, "invalid lgblock" if lgblock < MIN_LGBLOCK || lgblock > MAX_LGBLOCK
end
npostfix = options[:npostfix]
unless npostfix.nil?
Validation.validate_not_negative_integer npostfix
raise ValidateError, "invalid npostfix" if npostfix < MIN_NPOSTFIX || npostfix > MAX_NPOSTFIX
end
ndirect = options[:ndirect]
unless ndirect.nil?
Validation.validate_not_negative_integer ndirect
raise ValidateError, "invalid ndirect" if ndirect < MIN_NDIRECT || ndirect > MAX_NDIRECT
raise ValidateError, "invalid ndirect" if
!npostfix.nil? && (
(ndirect - MIN_NDIRECT) % (NDIRECT_NPOSTFIX_STEP_BASE << npostfix) != 0 ||
(ndirect - MIN_NDIRECT) > (NDIRECT_NPOSTFIX_MAX_BASE << npostfix)
)
end
disable_literal_context_modeling = options[:disable_literal_context_modeling]
Validation.validate_bool disable_literal_context_modeling unless disable_literal_context_modeling.nil?
large_window = options[:large_window]
Validation.validate_bool large_window unless large_window.nil?
options
end
|