Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: third_party/qcms/src/transform_util.c

Issue 2825623002: [qcms] Fix integer overflow in lut_inverse_interp16 (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/qcms/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // qcms 1 // qcms
2 // Copyright (C) 2009 Mozilla Foundation 2 // Copyright (C) 2009 Mozilla Foundation
3 // 3 //
4 // Permission is hereby granted, free of charge, to any person obtaining 4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the "Software"), 5 // a copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation 6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the Softwar e 8 // and/or sell copies of the Software, and to permit persons to whom the Softwar e
9 // is furnished to do so, subject to the following conditions: 9 // is furnished to do so, subject to the following conditions:
10 // 10 //
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 // There are no zeros at the beginning and we are trying to find a zero, so 334 // There are no zeros at the beginning and we are trying to find a zero, so
335 // return anything. It seems zero would be the less destructive choice 335 // return anything. It seems zero would be the less destructive choice
336 /* I'm not sure that this makes sense, but oh well... */ 336 /* I'm not sure that this makes sense, but oh well... */
337 if (NumZeroes == 0 && Value == 0) 337 if (NumZeroes == 0 && Value == 0)
338 return 0; 338 return 0;
339 339
340 // Does the curve belong to this case? 340 // Does the curve belong to this case?
341 if (NumZeroes > 1 || NumPoles > 1) 341 if (NumZeroes > 1 || NumPoles > 1)
342 { 342 {
343 int a, b, sample; 343 float a, b;
344 int sample;
344 345
345 // Identify if value fall downto 0 or FFFF zone 346 // Identify if value fall downto 0 or FFFF zone
346 if (Value == 0) return 0; 347 if (Value == 0) return 0;
347 // if (Value == 0xFFFF) return 0xFFFF; 348 // if (Value == 0xFFFF) return 0xFFFF;
348 sample = (length-1) * ((double) Value * (1./65535.)); 349 sample = (length-1) * ((double) Value * (1./65535.));
349 if (LutTable[sample] == 0xffff) 350 if (LutTable[sample] == 0xffff)
350 return 0xffff; 351 return 0xffff;
351 352
352 // else restrict to valid zone 353 // else restrict to valid zone
353 354
354 a = ((NumZeroes-1) * 0xFFFF) / (length-1); 355 a = ((NumZeroes-1) * 65535.f) / (length-1);
355 b = ((length-1 - NumPoles) * 0xFFFF) / (length-1); 356 b = ((length-1 - NumPoles) * 65535.f) / (length-1);
356 357
357 l = a - 1; 358 l = ((int)a) - 1;
358 r = b + 1; 359 r = ((int)b) + 1;
359 360
360 // Ensure a valid binary search range 361 // Ensure a valid binary search range
361 362
362 if (l < 1) 363 if (l < 1)
363 l = 1; 364 l = 1;
364 if (r > 0x10000) 365 if (r > 0x10000)
365 r = 0x10000; 366 r = 0x10000;
366 367
367 // If the search range is inverted due to degeneracy, 368 // If the search range is inverted due to degeneracy,
368 // deem LutTable non-invertible in this search range. 369 // deem LutTable non-invertible in this search range.
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 if (!curve || curve->type != PARAMETRIC_CURVE_TYPE) 671 if (!curve || curve->type != PARAMETRIC_CURVE_TYPE)
671 return 0; 672 return 0;
672 673
673 size = COUNT_TO_LENGTH[curve->count]; 674 size = COUNT_TO_LENGTH[curve->count];
674 675
675 if (data) 676 if (data)
676 memcpy(data, curve->parameter, size * sizeof(float)); 677 memcpy(data, curve->parameter, size * sizeof(float));
677 678
678 return size; 679 return size;
679 } 680 }
OLDNEW
« no previous file with comments | « third_party/qcms/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698