Encoder  4.4
VC-5 Sample Encoder
bandfile.c File Reference

Enumerations

enum  BAND_HEADER_TYPE {
  BAND_HEADER_FILE = 0x66696c65, BAND_HEADER_FRAME = 0x6672616d, BAND_HEADER_CHANNEL = 0x6368616e, BAND_HEADER_WAVELET = 0x77617665,
  BAND_HEADER_DATA = 0x62616e64
}
 Four character codes for the band file headers. More...
 

Functions

int OpenBandFile (BANDFILE *bandfile, const char *pathname)
 Open the band file for reading band data.
 
int FindNextBand (BANDFILE *bandfile)
 Find the next band in the band file. More...
 
int ReadFileHeader (BANDFILE *bandfile)
 
int ReadFrameHeader (BANDFILE *bandfile)
 
int ReadChannelHeader (BANDFILE *bandfile)
 
int ReadWaveletHeader (BANDFILE *bandfile)
 
int ReadBandHeader (BANDFILE *bandfile)
 
int ReadBandData (BANDFILE *bandfile, void *data, size_t size)
 Read the data for the next band from the band file.
 
int CreateBandFile (BANDFILE *bandfile, const char *pathname)
 Create a band file for storing band data.
 
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. More...
 
int WriteFileHeader (BANDFILE *bandfile, int max_band_width, int max_band_height)
 
int WriteFrameHeader (BANDFILE *bandfile, int frame)
 
int WriteChannelHeader (BANDFILE *bandfile, int channel)
 
int WriteWaveletHeader (BANDFILE *bandfile, int wavelet)
 
int WriteBandHeader (BANDFILE *bandfile, int band, int type, int width, int height, size_t size)
 
int WriteBandData (BANDFILE *bandfile, void *data, size_t size)
 
int CloseBandFile (BANDFILE *bandfile)
 

Detailed Description

Implementation of a module that writes wavelet bands to a file

The band file is a custom file format for wavelet bands and can be used for debugging by comparing the bands computed by different versions of the codec. The decoder does not free the wavelets after decoding a sample since they can be used for decoding the next sample, so after calling DecodeSample selected wavelet bands can be written to a band file.

A band file can contain bands for multiple frames (samples), one or more channels for each decoded sample, and any combination of wavelet bands in a channel.

There is a header identified by a four character code for the start of the band file, frames, channels, wavelets, and bands. A particular type of header is not repeated if the previous header is sufficient. For example, one wavelet header will be written in the band file for all of the bands in that wavelet.

The file header contains that maximum dimensions and size of all of the bands written into the band file and can be used to allocate memory for storing bands that are read from the file.

Typical usage is to use the routine FindNextBand to find the next band in the file and then read the band data by calling the routine ReadBandData. The call to FindNextBand updates the copy of the band parameters in the band file data structure using the values in the headers that it encounters while searching for the next chunk of band data.

Todo:
Need to add a version number to the headers
(c) 2013 Society of Motion Picture & Television Engineers LLC and Woodman Labs, Inc.
All rights reserved--use subject to compliance with end user license agreement.

Enumeration Type Documentation

◆ BAND_HEADER_TYPE

Four character codes for the band file headers.

Todo:
Byte swap the four character codes so that the letters appear in the correct order on little endian machines.

Function Documentation

◆ FindNextBand()

int FindNextBand ( BANDFILE bandfile)

Find the next band in the band file.

This routine is the recommended method for reading band data from a band file. Any combination of bands can be stored in any order. This routine updates the band file data structure with the index of the next frame, channel, wavelet, and band and the type of band.

After calling this routine, the calling application should call the routine ReadBandData to read the actual band data.

◆ WriteWaveletBand()

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.

This is the recommended method for writing band data to a file. Any headers that must be written to the file will be written before the band data. For example, if the frame, channel, and wavelet numbers have not changed since the last call to this routine then the frame, channel, and wavelet headers will be be rewritten.