84 fprintf(stderr,
"ERROR: file name pointer is zero\n");
88 if (wave_packet_descr == 0)
90 fprintf(stderr,
"ERROR: wave packet descriptor pointer is zero\n");
99 for (i = 0; i < 256; i++)
101 if (wave_packet_descr[i])
109 if (start_of_waveform_data_packet_record == 0)
111 if (!
compressed && (strstr(
".wdp", file_name) || strstr(
".WDP", file_name)))
113 file = fopen(file_name,
"rb");
115 else if (
compressed && (strstr(
".wdz", file_name) || strstr(
".WDZ", file_name)))
117 file = fopen(file_name,
"rb");
121 char* file_name_temp = strdup(file_name);
122 int len = strlen(file_name_temp);
123 if ((file_name_temp[len-3] ==
'L') || (file_name_temp[len-3] ==
'W'))
125 file_name_temp[len-3] =
'W';
126 file_name_temp[len-2] =
'D';
127 file_name_temp[len-1] = (
compressed ?
'Z' :
'P');
131 file_name_temp[len-3] =
'w';
132 file_name_temp[len-2] =
'd';
133 file_name_temp[len-1] = (
compressed ?
'z' :
'p');
135 file = fopen(file_name_temp,
"rb");
136 free(file_name_temp);
141 file = fopen(file_name,
"rb");
146 fprintf(stderr,
"ERROR: cannot open waveform file '%s'\n", file_name);
164 I64 position = start_of_waveform_data_packet_record + 60;
170 fprintf(stderr,
"ERROR: reading waveform descriptor cross-check\n");
174 if (strncmp(magic,
"LAStools waveform ", 18) == 0)
181 fprintf(stderr,
"ERROR: reading number of waveform descriptors\n");
184 for (i = 0; i < number; i++)
189 fprintf(stderr,
"ERROR: reading index of waveform descriptor %d\n", i);
194 fprintf(stderr,
"ERROR: cross-check - index %d of waveform descriptor %d out-of-range\n", index, i);
197 if (wave_packet_descr[index] == 0)
199 fprintf(stderr,
"WARNING: cross-check - waveform descriptor %d with index %d unknown\n", i, index);
203 fprintf(stderr,
"ERROR: cross-check - reading rest of waveform descriptor %d\n", i);
211 fprintf(stderr,
"ERROR: reading compression of waveform descriptor %d\n", i);
214 if (compression != wave_packet_descr[index]->getCompressionType())
216 fprintf(stderr,
"ERROR: cross-check - compression %d %d of waveform descriptor %d with index %d is different\n", compression, wave_packet_descr[index]->getCompressionType(), i, index);
222 fprintf(stderr,
"ERROR: reading nbits of waveform descriptor %d\n", i);
225 if (nbits != wave_packet_descr[index]->getBitsPerSample())
227 fprintf(stderr,
"ERROR: cross-check - nbits %d %d of waveform descriptor %d with index %d is different\n", nbits, wave_packet_descr[index]->getBitsPerSample(), i, index);
233 fprintf(stderr,
"ERROR: reading nsamples of waveform descriptor %d\n", i);
236 if (nsamples != wave_packet_descr[index]->getNumberOfSamples())
238 fprintf(stderr,
"ERROR: cross-check - nsamples %d %d of waveform descriptor %d with index %d is different\n", nsamples, wave_packet_descr[index]->getNumberOfSamples(), i, index);
268 fprintf(stderr,
"ERROR: waveform with %d bits per samples not supported yet\n",
nbits);
275 fprintf(stderr,
"ERROR: waveform has no samples\n");
309 fprintf(stderr,
"ERROR: cannot read %u bytes for waveform with %u samples of %u bits\n",
size,
nsamples,
nbits);
I32 decompress(I32 iPred, U32 context=0)
virtual I64 tell() const =0
BOOL init(ByteStreamIn *instream)
U8 getCompressionType() const
virtual BOOL seek(const I64 position)=0
virtual void getBytes(U8 *bytes, const U32 num_bytes)=0
U32 getNumberOfSamples() const
virtual void get32bitsLE(U8 *bytes)=0
U32 getTemporalSpacing() const
U8 getBitsPerSample() const
virtual void get16bitsLE(U8 *bytes)=0