read.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "bfc/platform/types.h"
  3. #include "avi_reader.h"
  4. namespace nsavi
  5. {
  6. class avi_reader;
  7. #pragma pack(push, 4)
  8. struct riff_chunk
  9. {
  10. uint32_t id;
  11. uint32_t size;
  12. uint32_t type; // if id is LIST or RIFF, this will be set
  13. };
  14. #pragma pack(pop)
  15. enum ParseState
  16. {
  17. NOT_READ = 0,
  18. PARSED = 1,
  19. NOT_FOUND = 2,
  20. PARSE_ERROR = 3,
  21. FOUND = 4, // we know where it is, but we havn't read it
  22. PARSE_RESYNC = 5, // read was aborted (return code < 0). need to resync inside the avi_reader
  23. };
  24. #define nsaviFOURCC( ch0, ch1, ch2, ch3 ) ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8 ) | ((uint32_t)(uint8_t)(ch2) << 16 ) | ( (uint32_t)(uint8_t)(ch3) << 24 ))
  25. // negative return codes are 'pass-thru' from the the avi_reader object
  26. // interpret accordingly (e.g. in_avi might abort a long network i/o on stop or seek)
  27. int read_riff_chunk(nsavi::avi_reader *reader, riff_chunk *chunk, uint32_t *bytes_read=0);
  28. int skip_chunk(nsavi::avi_reader *reader, const nsavi::riff_chunk *chunk, uint32_t *out_bytes_read=0);
  29. }