55 static const uint32_t frequencies[4] = { 48000, 96000, 44100, 32000 };
60 if (
s->last_header == header_int)
74 s->extra_sample_count = 0;
80 "PCM DVD unsupported sample depth %i\n",
102 s->samples_per_block = 1;
111 s->samples_per_block = 4 / avctx->
channels;
112 s->groups_per_block = 1;
117 s->samples_per_block = 1;
118 s->groups_per_block = 2;
124 s->samples_per_block = 4;
132 "pcm_dvd_parse_header: %d channels, %d bits per sample, %d Hz, %"PRId64
" bit/s\n",
136 s->last_header = header_int;
142 void *dst,
int blocks)
145 int16_t *dst16 = dst;
156 dst16 += blocks *
s->block_size / 2;
160 *dst16++ = bytestream2_get_be16u(&gb);
168 for (
i = 2;
i;
i--) {
169 dst32[0] = bytestream2_get_be16u(&gb) << 16;
170 dst32[1] = bytestream2_get_be16u(&gb) << 16;
171 t = bytestream2_get_byteu(&gb);
172 *dst32++ += (t & 0xf0) << 8;
173 *dst32++ += (t & 0x0f) << 12;
178 for (
i =
s->groups_per_block;
i;
i--) {
179 dst32[0] = bytestream2_get_be16u(&gb) << 16;
180 dst32[1] = bytestream2_get_be16u(&gb) << 16;
181 dst32[2] = bytestream2_get_be16u(&gb) << 16;
182 dst32[3] = bytestream2_get_be16u(&gb) << 16;
183 t = bytestream2_get_byteu(&gb);
184 *dst32++ += (t & 0xf0) << 8;
185 *dst32++ += (t & 0x0f) << 12;
186 t = bytestream2_get_byteu(&gb);
187 *dst32++ += (t & 0xf0) << 8;
188 *dst32++ += (t & 0x0f) << 12;
196 for (
i = 2;
i;
i--) {
197 dst32[0] = bytestream2_get_be16u(&gb) << 16;
198 dst32[1] = bytestream2_get_be16u(&gb) << 16;
199 *dst32++ += bytestream2_get_byteu(&gb) << 8;
200 *dst32++ += bytestream2_get_byteu(&gb) << 8;
205 for (
i =
s->groups_per_block;
i;
i--) {
206 dst32[0] = bytestream2_get_be16u(&gb) << 16;
207 dst32[1] = bytestream2_get_be16u(&gb) << 16;
208 dst32[2] = bytestream2_get_be16u(&gb) << 16;
209 dst32[3] = bytestream2_get_be16u(&gb) << 16;
210 *dst32++ += bytestream2_get_byteu(&gb) << 8;
211 *dst32++ += bytestream2_get_byteu(&gb) << 8;
212 *dst32++ += bytestream2_get_byteu(&gb) << 8;
213 *dst32++ += bytestream2_get_byteu(&gb) << 8;
224 int *got_frame_ptr,
AVPacket *avpkt)
228 int buf_size = avpkt->
size;
241 if (
s->last_block_size &&
s->last_block_size !=
s->block_size) {
243 s->extra_sample_count = 0;
245 s->last_block_size =
s->block_size;
249 blocks = (buf_size +
s->extra_sample_count) /
s->block_size;
252 frame->nb_samples = blocks *
s->samples_per_block;
255 dst =
frame->data[0];
258 if (
s->extra_sample_count) {
259 int missing_samples =
s->block_size -
s->extra_sample_count;
260 if (buf_size >= missing_samples) {
261 memcpy(
s->extra_samples +
s->extra_sample_count,
src,
264 src += missing_samples;
265 buf_size -= missing_samples;
266 s->extra_sample_count = 0;
270 memcpy(
s->extra_samples +
s->extra_sample_count,
src, buf_size);
271 s->extra_sample_count += buf_size;
279 buf_size -= blocks *
s->block_size;
284 src += blocks *
s->block_size;
285 memcpy(
s->extra_samples,
src, buf_size);
286 s->extra_sample_count = buf_size;