56 static const uint32_t frequencies[4] = { 48000, 96000, 44100, 32000 };
62 if (
s->last_header == header_int)
76 s->extra_sample_count = 0;
82 "PCM DVD unsupported sample depth %i\n",
107 s->samples_per_block = 1;
117 s->groups_per_block = 1;
122 s->samples_per_block = 1;
123 s->groups_per_block = 2;
129 s->samples_per_block = 4;
137 "pcm_dvd_parse_header: %d channels, %d bits per sample, %d Hz, %"PRId64
" bit/s\n",
141 s->last_header = header_int;
147 void *dst,
int blocks)
150 int16_t *dst16 = dst;
161 dst16 += blocks *
s->block_size / 2;
165 *dst16++ = bytestream2_get_be16u(&gb);
173 for (
i = 2;
i;
i--) {
174 dst32[0] = bytestream2_get_be16u(&gb) << 16;
175 dst32[1] = bytestream2_get_be16u(&gb) << 16;
176 t = bytestream2_get_byteu(&gb);
177 *dst32++ += (t & 0xf0) << 8;
178 *dst32++ += (t & 0x0f) << 12;
183 for (
i =
s->groups_per_block;
i;
i--) {
184 dst32[0] = bytestream2_get_be16u(&gb) << 16;
185 dst32[1] = bytestream2_get_be16u(&gb) << 16;
186 dst32[2] = bytestream2_get_be16u(&gb) << 16;
187 dst32[3] = bytestream2_get_be16u(&gb) << 16;
188 t = bytestream2_get_byteu(&gb);
189 *dst32++ += (t & 0xf0) << 8;
190 *dst32++ += (t & 0x0f) << 12;
191 t = bytestream2_get_byteu(&gb);
192 *dst32++ += (t & 0xf0) << 8;
193 *dst32++ += (t & 0x0f) << 12;
201 for (
i = 2;
i;
i--) {
202 dst32[0] = bytestream2_get_be16u(&gb) << 16;
203 dst32[1] = bytestream2_get_be16u(&gb) << 16;
204 *dst32++ += bytestream2_get_byteu(&gb) << 8;
205 *dst32++ += bytestream2_get_byteu(&gb) << 8;
210 for (
i =
s->groups_per_block;
i;
i--) {
211 dst32[0] = bytestream2_get_be16u(&gb) << 16;
212 dst32[1] = bytestream2_get_be16u(&gb) << 16;
213 dst32[2] = bytestream2_get_be16u(&gb) << 16;
214 dst32[3] = bytestream2_get_be16u(&gb) << 16;
215 *dst32++ += bytestream2_get_byteu(&gb) << 8;
216 *dst32++ += bytestream2_get_byteu(&gb) << 8;
217 *dst32++ += bytestream2_get_byteu(&gb) << 8;
218 *dst32++ += bytestream2_get_byteu(&gb) << 8;
229 int *got_frame_ptr,
AVPacket *avpkt)
231 const uint8_t *
src = avpkt->
data;
232 int buf_size = avpkt->
size;
245 if (
s->last_block_size &&
s->last_block_size !=
s->block_size) {
247 s->extra_sample_count = 0;
249 s->last_block_size =
s->block_size;
253 blocks = (buf_size +
s->extra_sample_count) /
s->block_size;
256 frame->nb_samples = blocks *
s->samples_per_block;
259 dst =
frame->data[0];
262 if (
s->extra_sample_count) {
263 int missing_samples =
s->block_size -
s->extra_sample_count;
264 if (buf_size >= missing_samples) {
265 memcpy(
s->extra_samples +
s->extra_sample_count,
src,
268 src += missing_samples;
269 buf_size -= missing_samples;
270 s->extra_sample_count = 0;
274 memcpy(
s->extra_samples +
s->extra_sample_count,
src, buf_size);
275 s->extra_sample_count += buf_size;
283 buf_size -= blocks *
s->block_size;
288 src += blocks *
s->block_size;
289 memcpy(
s->extra_samples,
src, buf_size);
290 s->extra_sample_count = buf_size;