| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#define WAVPACK_BLOCK_SIZE 4096 |
| 18 |
|
| 19 |
typedef struct { |
| 20 |
|
| 21 |
uint32_t ckSize; |
| 22 |
uint16_t version; |
| 23 |
u_char track_no; |
| 24 |
u_char index_no; |
| 25 |
uint32_t total_samples; |
| 26 |
|
| 27 |
|
| 28 |
uint32_t block_index; |
| 29 |
|
| 30 |
|
| 31 |
uint32_t block_samples; |
| 32 |
uint32_t flags; |
| 33 |
uint32_t crc; |
| 34 |
} WavpackHeader; |
| 35 |
|
| 36 |
typedef struct { |
| 37 |
unsigned short FormatTag, NumChannels; |
| 38 |
uint32_t SampleRate, BytesPerSecond; |
| 39 |
unsigned short BlockAlign, BitsPerSample; |
| 40 |
} WaveHeader3; |
| 41 |
|
| 42 |
typedef struct { |
| 43 |
|
| 44 |
int32_t ckSize; |
| 45 |
short version; |
| 46 |
short bits; |
| 47 |
short flags, shift; |
| 48 |
int32_t total_samples; |
| 49 |
|
| 50 |
} WavpackHeader3; |
| 51 |
|
| 52 |
typedef struct wvpinfo { |
| 53 |
PerlIO *infile; |
| 54 |
char *file; |
| 55 |
Buffer *buf; |
| 56 |
HV *info; |
| 57 |
off_t file_size; |
| 58 |
off_t file_offset; |
| 59 |
off_t audio_offset; |
| 60 |
|
| 61 |
WavpackHeader *header; |
| 62 |
|
| 63 |
uint8_t seeking; |
| 64 |
} wvpinfo; |
| 65 |
|
| 66 |
const int wavpack_sample_rates[] = { |
| 67 |
6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 |
| 68 |
}; |
| 69 |
|
| 70 |
#define ID_UNIQUE 0x3f |
| 71 |
#define ID_OPTIONAL_DATA 0x20 |
| 72 |
#define ID_ODD_SIZE 0x40 |
| 73 |
#define ID_LARGE 0x80 |
| 74 |
|
| 75 |
#define ID_DUMMY 0x0 |
| 76 |
#define ID_ENCODER_INFO 0x1 |
| 77 |
#define ID_DECORR_TERMS 0x2 |
| 78 |
#define ID_DECORR_WEIGHTS 0x3 |
| 79 |
#define ID_DECORR_SAMPLES 0x4 |
| 80 |
#define ID_ENTROPY_VARS 0x5 |
| 81 |
#define ID_HYBRID_PROFILE 0x6 |
| 82 |
#define ID_SHAPING_WEIGHTS 0x7 |
| 83 |
#define ID_FLOAT_INFO 0x8 |
| 84 |
#define ID_INT32_INFO 0x9 |
| 85 |
#define ID_WV_BITSTREAM 0xa |
| 86 |
#define ID_WVC_BITSTREAM 0xb |
| 87 |
#define ID_WVX_BITSTREAM 0xc |
| 88 |
#define ID_CHANNEL_INFO 0xd |
| 89 |
#define ID_DSD_BLOCK 0xe |
| 90 |
|
| 91 |
#define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1) |
| 92 |
#define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2) |
| 93 |
#define ID_ALT_HEADER (ID_OPTIONAL_DATA | 0x3) |
| 94 |
#define ID_ALT_TRAILER (ID_OPTIONAL_DATA | 0x4) |
| 95 |
#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5) |
| 96 |
#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6) |
| 97 |
#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7) |
| 98 |
#define ID_ALT_EXTENSION (ID_OPTIONAL_DATA | 0x8) |
| 99 |
#define ID_ALT_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x9) |
| 100 |
#define ID_NEW_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0xa) |
| 101 |
#define ID_BLOCK_CHECKSUM (ID_OPTIONAL_DATA | 0xf) |
| 102 |
|
| 103 |
static int get_wavpack_info(PerlIO *infile, char *file, HV *info); |
| 104 |
wvpinfo * _wavpack_parse(PerlIO *infile, char *file, HV *info, uint8_t seeking); |
| 105 |
int _wavpack_parse_block(wvpinfo *wvp); |
| 106 |
int _wavpack_parse_sample_rate(wvpinfo *wvp, uint32_t size); |
| 107 |
int _wavpack_parse_channel_info(wvpinfo *wvp, uint32_t size); |
| 108 |
int _wavpack_parse_dsd_block(wvpinfo *wvp, uint32_t size); |
| 109 |
void _wavpack_skip(wvpinfo *wvp, uint32_t size); |
| 110 |
int _wavpack_parse_old(wvpinfo *wvp); |