53 uint16_t shift, result;
55 sample = (sample < 0x800) ? sample : sample | 0xf000;
56 shift = (sample & 0xf00) >> 8;
58 if (shift < 0x2 || shift > 0xd) {
60 }
else if (shift < 0x8) {
62 result = (sample - (256 * shift)) << shift;
65 result = ((sample + ((256 * shift) + 1)) << shift) - 1;
82 offs = (80*6 + 80*16*3 + 3);
85 offs = (80*6 + 80*16*4 + 3);
88 offs = (80*5 + 48 + 5);
94 return frame[offs] == t ? &frame[offs] :
NULL;
108 int size, chan, i, j, d, of, smpls, freq,
quant, half_ch;
110 const uint8_t* as_pack;
117 smpls = as_pack[1] & 0x3f;
118 freq = (as_pack[4] >> 3) & 0x07;
119 quant = as_pack[4] & 0x07;
132 ipcm = (sys->
height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
135 for (chan = 0; chan < sys->
n_difchan; chan++) {
144 if (quant == 1 && i == half_ch) {
152 for (j = 0; j < 9; j++) {
153 for (d = 8; d < 80; d += 2) {
159 pcm[of*2] = frame[d+1];
160 pcm[of*2+1] = frame[d];
161 if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00)
164 lc = ((uint16_t)frame[d] << 4) |
165 ((uint16_t)frame[d+2] >> 4);
166 rc = ((uint16_t)frame[d+1] << 4) |
167 ((uint16_t)frame[d+2] & 0x0f);
175 pcm[of*2] = lc & 0xff;
176 pcm[of*2+1] = lc >> 8;
179 pcm[of*2] = rc & 0xff;
180 pcm[of*2+1] = rc >> 8;
195 const uint8_t* as_pack;
196 int freq, stype, smpls,
quant, i, ach;
199 if (!as_pack || !c->
sys) {
204 smpls = as_pack[1] & 0x3f;
205 freq = (as_pack[4] >> 3) & 0x07;
206 stype = (as_pack[3] & 0x1f);
207 quant = as_pack[4] & 0x07;
211 "Unrecognized audio sample rate index (%d)\n", freq);
222 ach = ((
int[4]){ 1, 0, 2, 4})[stype];
223 if (ach == 1 && quant && freq == 2)
227 for (i = 0; i < ach; i++) {
254 const uint8_t* vsc_pack;
273 apt = frame[4] & 0x07;
274 is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
275 (!apt && (vsc_pack[2] & 0x07) == 0x07)));
304 memset(c->
ast, 0,
sizeof(c->
ast));
322 for (i = 0; i < c->
ach; i++) {
335 uint8_t* buf,
int buf_size)
338 uint8_t *ppcm[5] = { 0 };
342 buf_size < c->sys->frame_size) {
349 for (i = 0; i < c->
ach; i++) {
385 int64_t timestamp,
int flags)
395 if (size >= 0 && offset > max_offset) offset = max_offset;
396 else if (offset < 0) offset = 0;
407 c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
408 c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
423 unsigned state, marker_pos = 0;
431 while ((state & 0xffffff7f) != 0x1f07003f) {
436 if (state == 0x003f0700 || state == 0xff3f0700)
438 if (state == 0xff3f0701 &&
avio_tell(s->
pb) - marker_pos == 80) {
458 c->dv_demux->sys->time_base);
485 int64_t timestamp,
int flags)
494 return (offset < 0) ? offset : 0;
506 unsigned state, marker_pos = 0;
509 int secondary_matches = 0;
516 if ((state & 0xffffff7f) == 0x1f07003f)
520 if ((state & 0xff07ff7f) == 0x1f07003f)
522 if (state == 0x003f0700 || state == 0xff3f0700)
524 if (state == 0xff3f0701 && i - marker_pos == 80)
526 state = (state << 8) | p->
buf[i];
529 if (matches && p->
buf_size / matches < 1024*1024) {
530 if (matches > 4 || (secondary_matches >= 10 && p->
buf_size / secondary_matches < 24000))
537 #if CONFIG_DV_DEMUXER
547 .extensions =
"dv,dif",