Encoder  4.4
VC-5 Sample Encoder
bandfile.h
Go to the documentation of this file.
1 
13 #ifndef _BANDFILE_H
14 #define _BANDFILE_H
15 
22 #pragma pack(push, 1)
23 
24 typedef struct _bandfile
25 {
26  FILE *file;
27  uint32_t frame;
28  uint16_t channel;
29  uint16_t wavelet;
30  uint16_t band;
31  uint16_t type;
32  uint32_t size;
33 
34  uint16_t width;
35  uint16_t height;
36 
37  uint16_t max_band_width;
38  uint16_t max_band_height;
39 
40  uint32_t max_band_size;
41 
42  // Flags that indicate the state of the band data file
43  uint8_t file_header_flag;
47  uint8_t band_header_flag;
48 
49  uint8_t padding[3];
50 
51 } BANDFILE;
52 
53 #pragma pack(pop)
54 
58 typedef enum
59 {
60  BAND_TYPE_UINT16 = 0,
61  BAND_TYPE_SINT16,
62 
63  // Reserve a block of values for encoded bands
64  BAND_TYPE_ENCODED = 16,
65  BAND_TYPE_ENCODED_RUNLENGTHS, // Encoding method used by the codec
66 
67 } BAND_TYPE;
68 
72 //typedef enum
73 enum
74 {
75  BANDFILE_ERROR_OKAY = 0,
76  BANDFILE_ERROR_OPEN_FAILED,
77  BANDFILE_ERROR_READ_FAILED,
78  BANDFILE_ERROR_UNKNOWN_HEADER,
79  BANDFILE_ERROR_CREATE_FAILED,
80  BANDFILE_ERROR_WRITE_FAILED,
81  BANDFILE_ERROR_END_OF_DATA,
82 };
83 
84 typedef int BANDFILE_ERROR;
85 
86 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
91 int OpenBandFile(BANDFILE *bandfile, const char *pathname);
92 
93 int FindNextBand(BANDFILE *bandfile);
94 
95 int ReadFileHeader(BANDFILE *bandfile);
96 
97 int ReadFrameHeader(BANDFILE *bandfile);
98 
99 int ReadChannelHeader(BANDFILE *bandfile);
100 
101 int ReadWaveletHeader(BANDFILE *bandfile);
102 
103 int ReadBandHeader(BANDFILE *bandfile);
104 
105 int ReadBandData(BANDFILE *bandfile, void *data, size_t size);
106 
107 int CreateBandFile(BANDFILE *bandfile, const char *pathname);
108 
109 int WriteFileHeader(BANDFILE *bandfile, int max_band_width, int max_band_height);
110 
111 int WriteWaveletBand(BANDFILE *bandfile,
112  int frame,
113  int channel,
114  int wavelet,
115  int band,
116  int type,
117  int width,
118  int height,
119  void *data,
120  size_t size);
121 
122 int WriteFrameHeader(BANDFILE *bandfile, int frame);
123 
124 int WriteChannelHeader(BANDFILE *bandfile, int channel);
125 
126 int WriteWaveletHeader(BANDFILE *bandfile, int wavelet);
127 
128 int WriteBandHeader(BANDFILE *bandfile, int band, int type, int width, int height, size_t size);
129 
130 int WriteBandData(BANDFILE *bandfile, void *data, size_t size);
131 
132 int CloseBandFile(BANDFILE *bandfile);
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif
uint16_t channel
Most recent channel index.
Definition: bandfile.h:28
uint16_t max_band_height
Maximum height of a band in the band file.
Definition: bandfile.h:38
uint16_t height
Height of the most recent band.
Definition: bandfile.h:35
uint16_t type
Data type of the most recent band.
Definition: bandfile.h:31
int FindNextBand(BANDFILE *bandfile)
Find the next band in the band file.
Definition: bandfile.c:144
BAND_TYPE
Data type of the data for a band in the band file.
Definition: bandfile.h:58
uint32_t max_band_size
Maximum size of the bands in the band file.
Definition: bandfile.h:40
Declaration of the band file data structure.
Definition: bandfile.h:24
uint8_t file_header_flag
Has the file header been written?
Definition: bandfile.h:43
uint8_t band_header_flag
Has the band header been written?
Definition: bandfile.h:47
struct _bandfile BANDFILE
Declaration of the band file data structure.
int OpenBandFile(BANDFILE *bandfile, const char *pathname)
Open the band file for reading band data.
Definition: bandfile.c:122
FILE * file
Current open band file.
Definition: bandfile.h:26
uint8_t wavelet_header_flag
Has the wavelet header been written?
Definition: bandfile.h:46
int CreateBandFile(BANDFILE *bandfile, const char *pathname)
Create a band file for storing band data.
Definition: bandfile.c:320
uint32_t size
Size of the most recent band (in bytes)
Definition: bandfile.h:32
uint16_t band
Most recent band index.
Definition: bandfile.h:30
uint8_t padding[3]
Pad the structure to a multiple of four bytes.
Definition: bandfile.h:49
uint16_t width
Width of the most recent band.
Definition: bandfile.h:34
int WriteWaveletBand(BANDFILE *bandfile, int frame, int channel, int wavelet, int band, int type, int width, int height, void *data, size_t size)
Write the band data to the band file.
Definition: bandfile.c:339
int ReadBandData(BANDFILE *bandfile, void *data, size_t size)
Read the data for the next band from the band file.
Definition: bandfile.c:304
uint32_t frame
Most recent frame number.
Definition: bandfile.h:27
uint8_t frame_header_flag
Has the frame header been written?
Definition: bandfile.h:44
uint16_t wavelet
Most recent wavelet index.
Definition: bandfile.h:29
uint8_t channel_header_flag
Has the channel header been written?
Definition: bandfile.h:45
uint16_t max_band_width
Maximum width of a band in the band file.
Definition: bandfile.h:37