cgv
riff.h
1 #pragma once
2 
3 #include <string>
4 #include <stdio.h>
5 #include <iostream>
6 
7 #include "lib_begin.h"
8 
9 namespace cgv {
10  namespace media {
11 
13 struct CGV_API fourcc
14 {
15  static unsigned make_id(const std::string& ascii);
17  unsigned id;
19  fourcc(unsigned _id = 0) : id(_id) {}
21  fourcc(const std::string& s) : id(make_id(s)) {}
23  std::string to_string() const;
25  bool operator == (const std::string& s) const;
27  bool operator != (const std::string& s) const;
28 };
29 
31 extern CGV_API std::ostream& operator << (std::ostream& os, const fourcc& f);
32 
34 struct CGV_API riff_handler
35 {
37  virtual bool begin_list_chunk(fourcc id, unsigned size, fourcc hdr);
39 
42  virtual bool process_chunk_header(fourcc id, unsigned size, void*& data_ptr);
44  virtual void process_chunk_data(fourcc id, unsigned size, void* data_ptr);
46  virtual void end_list_chunk(fourcc id, unsigned size, fourcc hdr);
47 };
48 
50 class CGV_API riff_reader
51 {
52 protected:
53  FILE* fp;
54  riff_handler* rh;
55  bool read_chunk_info(fourcc& f, unsigned& size);
56  bool read_chunk_list(unsigned size);
57  void close();
58 public:
62  bool read(const std::string& file_name);
63 };
64 
65  }
66 }
67 
68 #include <cgv/config/lib_end.h>
cgv::media::riff_reader
reader class for riff files such as .ani or .avi
Definition: riff.h:51
cgv::media::riff_handler
callback handler passed to riff reader
Definition: riff.h:35
cgv::media::fourcc::fourcc
fourcc(const std::string &s)
construct from string
Definition: riff.h:21
cgv::media::fourcc
represents fourcc ids as used in the riff format to identify chunks
Definition: riff.h:14
cgv::media::fourcc::id
unsigned id
store fourcc as 32 bit integer
Definition: riff.h:17
cgv::media::fourcc::fourcc
fourcc(unsigned _id=0)
construct from unsigned integer
Definition: riff.h:19
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::utils::to_string
std::string to_string(const T &v, unsigned int w=-1, unsigned int p=-1)
convert a numeric type T into string of width w and precision p
Definition: convert_string.h:18