55 uint16_t shift, result;
57 sample = (sample < 0x800) ? sample : sample | 0xf000;
58 shift = (sample & 0xf00) >> 8;
60 if (shift < 0x2 || shift > 0xd) {
62 }
else if (shift < 0x8) {
64 result = (sample - (256 * shift)) << shift;
67 result = ((sample + ((256 * shift) + 1)) << shift) - 1;
84 offs = (80 * 6 + 80 * 16 * 3 + 3);
87 offs = (80 * 6 + 80 * 16 * 4 + 3);
90 offs = (80 * 5 + 48 + 5);
96 return frame[offs] == t ? &frame[offs] :
NULL;
114 int size, chan, i, j, d, of, smpls, freq,
quant, half_ch;
123 smpls = as_pack[1] & 0x3f;
124 freq = as_pack[4] >> 3 & 0x07;
125 quant = as_pack[4] & 0x07;
138 ipcm = (sys->
height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
141 for (chan = 0; chan < sys->
n_difchan; chan++) {
150 if (quant == 1 && i == half_ch) {
158 for (j = 0; j < 9; j++) {
159 for (d = 8; d < 80; d += 2) {
168 pcm[of * 2] = frame[d + 1];
169 pcm[of * 2 + 1] = frame[d];
171 if (pcm[of * 2 + 1] == 0x80 && pcm[of * 2] == 0x00)
174 lc = ((uint16_t)frame[d] << 4) |
175 ((uint16_t)frame[d + 2] >> 4);
176 rc = ((uint16_t)frame[d + 1] << 4) |
177 ((uint16_t)frame[d + 2] & 0x0f);
188 pcm[of * 2] = lc & 0xff;
189 pcm[of * 2 + 1] = lc >> 8;
194 pcm[of * 2] = rc & 0xff;
195 pcm[of * 2 + 1] = rc >> 8;
211 int freq, stype, smpls,
quant, i, ach;
214 if (!as_pack || !c->
sys) {
219 smpls = as_pack[1] & 0x3f;
220 freq = as_pack[4] >> 3 & 0x07;
221 stype = as_pack[3] & 0x1f;
222 quant = as_pack[4] & 0x07;
226 "Unrecognized audio sample rate index (%d)\n", freq);
237 ach = ((
int[4]) { 1, 0, 2, 4 })[stype];
238 if (ach == 1 && quant && freq == 2)
242 for (i = 0; i < ach; i++) {
289 apt = frame[4] & 0x07;
290 is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
291 (!apt && (vsc_pack[2] & 0x07) == 0x07)));
331 for (i = 0; i < c->
ach; i++) {
351 buf_size < c->sys->frame_size) {
358 for (i = 0; i < c->
ach; i++) {
395 int64_t timestamp,
int flags)
405 if (size >= 0 && offset > max_offset)
420 c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
421 c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
435 unsigned state, marker_pos = 0;
443 while ((state & 0xffffff7f) != 0x1f07003f) {
448 if (state == 0x003f0700 || state == 0xff3f0700)
450 if (state == 0xff3f0701 &&
avio_tell(s->
pb) - marker_pos == 80) {
468 "Can't determine profile of DV input stream.\n");
474 c->dv_demux->sys->time_base);
500 int64_t timestamp,
int flags)
522 unsigned state, marker_pos = 0;
525 int secondary_matches = 0;
532 if ((state & 0xffffff7f) == 0x1f07003f)
536 if ((state & 0xff07ff7f) == 0x1f07003f)
538 if (state == 0x003f0700 || state == 0xff3f0700)
540 if (state == 0xff3f0701 && i - marker_pos == 80)
542 state = (state << 8) | p->
buf[i];
545 if (matches && p->
buf_size / matches < 1024 * 1024) {
547 (secondary_matches >= 10 &&
548 p->
buf_size / secondary_matches < 24000))
556 #if CONFIG_DV_DEMUXER
566 .extensions =
"dv,dif",