[sane-devel] constrain value related query
viresh_shirol at yahoo.co.uk
Wed Jul 17 00:46:33 UTC 2013
During my backend testing efforts with tstbackend.c frontend that is available in the distribution ,I observed an issue in the sanei_constrain_value function.
The details are as below.
1)I believe the specifications for SANE_Range are simple enough and there are no further rules on the values for min,max and quant members.
2)assuming #1 above is correct, my observation is that the constrain_value function returns values that are greater than the max specified for the range.
3)I am assuming that #2 item is either unknown or known but not fixed/valid scenario.
the issue happens for constraint type RANGE when following condition is satisfied
value to be set >=max
Cause:Due to rounding done using quant/2 value,the final value put in array[i] overshoots the max value by at the max quant/2 units.
5>Why this is an issue for me
for few reasons
a)I blindly believed the value returned by constrain_value is actually constrained to the max. By this assumption,I did not have to check the values everywhere for their constraint-wise-correctness.
b)the machine that I am writing the backend for seems to take tl br values in mm and seems to do some kind of validation using which it decides the actual scan size.So offset of value/s for tl br options would lead to heavy offsets when large resolution scan is done.
c)the issue is very dominant,I believe,when the range type is SANE_Fixed. Note that in this case the quant value is sufficiently large leading to larger offsets.
a)temporary fix can just check whether the adjusted value is larger than Max for the range and set it to either max or one quant level lesser.
Also,I can temporarily fix it in a local function.
b)not very sure but If the rounding via quant/2 is removed we can safely say that the value is always safe. I think it's a subjective item and can not discuss further but I think flooring isn't that bad.
7)My test values(sorry to put them at the end)
quant=SANE_FIX(0.01);//tried .1,1.0 too
value to be set (actually the issue was found when testing with tstbkend.c fronted) is 431.8. (or more ...as constrain value reduces it to max in that case)
Query:how do I proceed with this?My main question is "am I doing something wrong??"
this is my first post.I wanna thank you all and especially the ones who have authored the tstbackend frontend.Also,please note that I may ve wrong in using fractional quant values etc but i think there was no limitation w.r.t. in the spec. I apologize in advance if anyone feels any sentence in this post seems to show impoliteness in any way. ...I am newbie/noob u knw!!!!
Thanks and regards,
Sent from my iPhone
More information about the sane-devel