BitDecoderChannel.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2007-2011 Siemens AG
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published
  6. * by the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*******************************************************************
  19. *
  20. * @author Daniel.Peintner.EXT@siemens.com
  21. * @version 2011-12-02
  22. * @contact Joerg.Heuer@siemens.com
  23. *
  24. * <p>Code generated by EXIdizer</p>
  25. ********************************************************************/
  26. #include "DecoderChannel.h"
  27. #include "BitInputStream.h"
  28. #include "EXITypes.h"
  29. #ifndef BIT_DECODER_CHANNEL_C
  30. #define BIT_DECODER_CHANNEL_C
  31. #if EXI_ALIGNMENT == BIT_PACKED
  32. int decode(bitstream_t* stream, uint8_t* b) {
  33. uint32_t bb;
  34. int errn = readBits(stream, 8, &bb);
  35. if (errn < 0) {
  36. return errn;
  37. }
  38. if (bb > 256) {
  39. return EXI_ERROR_UNEXPECTED_BYTE_VALUE;
  40. } else {
  41. *b = (uint8_t)bb;
  42. }
  43. return errn;
  44. }
  45. int decodeBoolean(bitstream_t* stream, int* b) {
  46. uint32_t ub;
  47. int errn = readBits(stream, 1, &ub);
  48. *b = (ub == 0) ? 0 : 1;
  49. return errn;
  50. }
  51. int decodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t* uint32) {
  52. if (nbits == 0) {
  53. *uint32 = 0;
  54. return 0;
  55. } else {
  56. return readBits(stream, nbits, uint32);
  57. }
  58. }
  59. #endif
  60. #endif