EXIHeaderDecoder.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2007-2010 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. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*******************************************************************
  18. *
  19. * @author Daniel.Peintner.EXT@siemens.com
  20. * @version 0.1
  21. * @contact Joerg.Heuer@siemens.com
  22. *
  23. ********************************************************************/
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include "EXIHeaderDecoder.h"
  27. #include "BitInputStream.h"
  28. #include "BitDecoderChannel.h"
  29. #ifndef EXI_HEADER_DECODER_C
  30. #define EXI_HEADER_DECODER_C
  31. int readEXIHeader(bitstream_t* stream) {
  32. uint8_t header;
  33. int errn = readBits(stream, 8, &header);
  34. if (errn < 0) {
  35. return errn;
  36. }
  37. if(header == '$') {
  38. /* we do not support "EXI Cookie" */
  39. errn = -1;
  40. } else if ( header & 0x20 ) {
  41. /* we do not support "Presence Bit for EXI Options" */
  42. errn = -2;
  43. } else {
  44. /* Yes, a *simple* header */
  45. errn = 0;
  46. }
  47. return errn;
  48. }
  49. #endif