cgv
Loading...
Searching...
No Matches
riff.h
1#pragma once
2
3#include <string>
4#include <stdio.h>
5#include <iostream>
6
7#include "lib_begin.h"
8
9namespace cgv {
10 namespace media {
11
13struct 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
31extern CGV_API std::ostream& operator << (std::ostream& os, const fourcc& f);
32
34struct 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
50class CGV_API riff_reader
51{
52protected:
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();
58public:
62 bool read(const std::string& file_name);
63};
64
65 }
66}
67
68#include <cgv/config/lib_end.h>
reader class for riff files such as .ani or .avi
Definition riff.h:51
the cgv namespace
Definition print.h:11
represents fourcc ids as used in the riff format to identify chunks
Definition riff.h:14
fourcc(unsigned _id=0)
construct from unsigned integer
Definition riff.h:19
unsigned id
store fourcc as 32 bit integer
Definition riff.h:17
fourcc(const std::string &s)
construct from string
Definition riff.h:21
callback handler passed to riff reader
Definition riff.h:35