comparison mpeg.c @ 41:b892b9f97291 libavformat

added DVD LPCM decoding support
author bellard
date Fri, 31 Jan 2003 17:04:46 +0000
parents b167760cd0aa
children 3e7e13e08b27
comparison
equal deleted inserted replaced
40:721705c1f995 41:b892b9f97291
596 type = CODEC_TYPE_AUDIO; 596 type = CODEC_TYPE_AUDIO;
597 codec_id = CODEC_ID_MP2; 597 codec_id = CODEC_ID_MP2;
598 } else if (startcode >= 0x80 && startcode <= 0x9f) { 598 } else if (startcode >= 0x80 && startcode <= 0x9f) {
599 type = CODEC_TYPE_AUDIO; 599 type = CODEC_TYPE_AUDIO;
600 codec_id = CODEC_ID_AC3; 600 codec_id = CODEC_ID_AC3;
601 } else if (startcode >= 0xa0 && startcode <= 0xbf) {
602 type = CODEC_TYPE_AUDIO;
603 codec_id = CODEC_ID_PCM_S16BE;
601 } else { 604 } else {
602 skip: 605 skip:
603 /* skip packet */ 606 /* skip packet */
604 url_fskip(&s->pb, len); 607 url_fskip(&s->pb, len);
605 goto redo; 608 goto redo;
609 if (!st) 612 if (!st)
610 goto skip; 613 goto skip;
611 st->codec.codec_type = type; 614 st->codec.codec_type = type;
612 st->codec.codec_id = codec_id; 615 st->codec.codec_id = codec_id;
613 found: 616 found:
617 if (startcode >= 0xa0 && startcode <= 0xbf) {
618 int b1, freq;
619 static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
620
621 /* for LPCM, we just skip the header and consider it is raw
622 audio data */
623 if (len <= 3)
624 goto skip;
625 get_byte(&s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
626 b1 = get_byte(&s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
627 get_byte(&s->pb); /* dynamic range control (0x80 = off) */
628 len -= 3;
629 freq = (b1 >> 4) & 3;
630 st->codec.sample_rate = lpcm_freq_tab[freq];
631 st->codec.channels = 1 + (b1 & 7);
632 st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * 2;
633 }
614 av_new_packet(pkt, len); 634 av_new_packet(pkt, len);
615 //printf("\nRead Packet ID: %x PTS: %f Size: %d", startcode, 635 //printf("\nRead Packet ID: %x PTS: %f Size: %d", startcode,
616 // (float)pts/90000, len); 636 // (float)pts/90000, len);
617 get_buffer(&s->pb, pkt->data, pkt->size); 637 get_buffer(&s->pb, pkt->data, pkt->size);
618 pkt->pts = pts; 638 pkt->pts = pts;