57 uint16_t
shift, result;
59 sample = (sample < 0x800) ? sample : sample | 0xf000;
60 shift = (sample & 0xf00) >> 8;
62 if (shift < 0x2 || shift > 0xd) {
64 }
else if (shift < 0x8) {
69 result = ((sample + ((256 *
shift) + 1)) << shift) - 1;
86 offs = (80*6 + 80*16*3 + 3);
89 offs = (80*6 + 80*16*4 + 3);
92 offs = (80*5 + 48 + 5);
95 offs = (80*1 + 3 + 3);
101 return frame[offs] == t ? &frame[offs] :
NULL;
119 int size, chan, i, j, d, of, smpls, freq,
quant, half_ch;
128 smpls = as_pack[1] & 0x3f;
129 freq = (as_pack[4] >> 3) & 0x07;
130 quant = as_pack[4] & 0x07;
143 ipcm = (sys->
height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
145 if (ipcm + sys->
n_difchan > (quant == 1 ? 2 : 4)) {
151 for (chan = 0; chan < sys->
n_difchan; chan++) {
160 if (quant == 1 && i == half_ch) {
169 for (j = 0; j < 9; j++) {
170 for (d = 8; d < 80; d += 2) {
176 pcm[of*2] = frame[d+1];
177 pcm[of*2+1] = frame[d];
178 if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00)
181 lc = ((uint16_t)frame[d] << 4) |
182 ((uint16_t)frame[d+2] >> 4);
183 rc = ((uint16_t)frame[d+1] << 4) |
184 ((uint16_t)frame[d+2] & 0x0f);
192 pcm[of*2] = lc & 0xff;
193 pcm[of*2+1] = lc >> 8;
196 pcm[of*2] = rc & 0xff;
197 pcm[of*2+1] = rc >> 8;
213 int freq, stype, smpls,
quant, i, ach;
216 if (!as_pack || !c->
sys) {
221 smpls = as_pack[1] & 0x3f;
222 freq = (as_pack[4] >> 3) & 0x07;
223 stype = (as_pack[3] & 0x1f);
224 quant = as_pack[4] & 0x07;
228 "Unrecognized audio sample rate index (%d)\n", freq);
239 ach = ((
int[4]){ 1, 0, 2, 4})[stype];
240 if (ach == 1 && quant && freq == 2)
244 for (i = 0; i < ach; i++) {
286 apt = frame[4] & 0x07;
287 is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
288 (!apt && (vsc_pack[2] & 0x07) == 0x07)));
345 for (i = 0; i < c->
ach; i++) {
358 uint8_t* buf,
int buf_size, int64_t pos)
365 buf_size < c->sys->frame_size) {
372 for (i = 0; i < c->
ach; i++) {
410 int64_t timestamp,
int flags)
420 if (size >= 0 && offset > max_offset) offset = max_offset;
421 else if (offset < 0) offset = 0;
436 c->audio_pkt[0].size =
c->audio_pkt[1].size = 0;
437 c->audio_pkt[2].size =
c->audio_pkt[3].size = 0;
455 int partial_frame_size = 3 * 80;
460 ret =
avio_read(s->
pb, partial_frame, partial_frame_size);
464 if (ret < partial_frame_size) {
483 unsigned state, marker_pos = 0;
491 while ((state & 0xffffff7f) != 0x1f07003f) {
496 if (state == 0x003f0700 || state == 0xff3f0700)
498 if (state == 0xff3f0701 &&
avio_tell(s->
pb) - marker_pos == 80) {
518 c->dv_demux->sys->time_base);
549 int64_t timestamp,
int flags)
571 unsigned state, marker_pos = 0;
574 int secondary_matches = 0;
581 if ((state & 0xffffff7f) == 0x1f07003f)
585 if ((state & 0xff07ff7f) == 0x1f07003f)
587 if (state == 0x003f0700 || state == 0xff3f0700)
589 if (state == 0xff3f0701 && i - marker_pos == 80)
591 state = (state << 8) | p->
buf[i];
594 if (matches && p->
buf_size / matches < 1024*1024) {
595 if (matches > 4 || (secondary_matches >= 10 && p->
buf_size / secondary_matches < 24000))
602 #if CONFIG_DV_DEMUXER
612 .extensions =
"dv,dif",