You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0KB

  1. /*
  2. * Bytestream functions
  3. * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef FFMPEG_BYTESTREAM_H
  22. #define FFMPEG_BYTESTREAM_H
  23. static always_inline unsigned int bytestream_get_le32(uint8_t **b)
  24. {
  25. (*b) += 4;
  26. return LE_32(*b - 4);
  27. }
  28. static always_inline unsigned int bytestream_get_le16(uint8_t **b)
  29. {
  30. (*b) += 2;
  31. return LE_16(*b - 2);
  32. }
  33. static always_inline unsigned int bytestream_get_byte(uint8_t **b)
  34. {
  35. (*b)++;
  36. return (*b)[-1];
  37. }
  38. static always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size)
  39. {
  40. memcpy(dst, *b, size);
  41. (*b) += size;
  42. return size;
  43. }
  44. static always_inline void bytestream_put_le32(uint8_t **b, const unsigned int value)
  45. {
  46. *(*b)++ = value;
  47. *(*b)++ = value >> 8;
  48. *(*b)++ = value >> 16;
  49. *(*b)++ = value >> 24;
  50. }
  51. static always_inline void bytestream_put_le16(uint8_t **b, const unsigned int value)
  52. {
  53. *(*b)++ = value;
  54. *(*b)++ = value >> 8;
  55. }
  56. static always_inline void bytestream_put_byte(uint8_t **b, const unsigned int value)
  57. {
  58. *(*b)++ = value;
  59. }
  60. static always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
  61. {
  62. memcpy(*b, src, size);
  63. (*b) += size;
  64. }
  65. #endif /* FFMPEG_BYTESTREAM_H */