bch15_5.h 864 B

1234567891011121314151617181920
  1. /*Copyright (C) 2008-2009 Timothy B. Terriberry (tterribe@xiph.org)
  2. You can redistribute this library and/or modify it under the terms of the
  3. GNU Lesser General Public License as published by the Free Software
  4. Foundation; either version 2.1 of the License, or (at your option) any later
  5. version.*/
  6. #if !defined(_bch15_5_H)
  7. # define _bch15_5_H (1)
  8. /*Encodes a raw 5-bit value _x into a 15-bit BCH(15,5) code.
  9. This is capable of correcting up to 3 bit errors, and detecting as many as
  10. 5 bit errors in some cases.*/
  11. unsigned bch15_5_encode(unsigned _x);
  12. /*Corrects the received code *_y, if possible.
  13. The original data is located in the top five bits.
  14. Returns the number of errors corrected, or a negative value if decoding
  15. failed due to too many bit errors, in which case *_y is left unchanged.*/
  16. int bch15_5_correct(unsigned *_y);
  17. #endif