Revision ec23a472 libavformat/mpegts.c

View differences:

libavformat/mpegts.c
387 387
        case STREAM_TYPE_AUDIO_MPEG2:
388 388
        case STREAM_TYPE_VIDEO_MPEG1:
389 389
        case STREAM_TYPE_VIDEO_MPEG2:
390
        case STREAM_TYPE_AUDIO_AC3:
390 391
            add_pes_stream(ts->stream, pid);
391 392
            break;
392 393
        default:
......
613 614
                if (pes->header[0] == 0x00 && pes->header[1] == 0x00 &&
614 615
                    pes->header[2] == 0x01) {
615 616
                    /* it must be an mpeg2 PES stream */
616
                    /* XXX: add AC3 support */
617 617
                    code = pes->header[3] | 0x100;
618 618
                    if (!((code >= 0x1c0 && code <= 0x1df) ||
619
                          (code >= 0x1e0 && code <= 0x1ef)))
619
                          (code >= 0x1e0 && code <= 0x1ef) ||
620
                          (code == 0x1bd)))
620 621
                        goto skip;
621 622
                    if (!pes->st) {
622 623
                        /* allocate stream */
623 624
                        if (code >= 0x1c0 && code <= 0x1df) {
624 625
                            codec_type = CODEC_TYPE_AUDIO;
625 626
                            codec_id = CODEC_ID_MP2;
627
                        } else if (code == 0x1bd) {
628
                            codec_type = CODEC_TYPE_AUDIO;
629
                            codec_id = CODEC_ID_AC3;
626 630
                        } else {
627 631
                            codec_type = CODEC_TYPE_VIDEO;
628 632
                            codec_id = CODEC_ID_MPEG1VIDEO;
......
805 809
    ByteIOContext *pb = &s->pb;
806 810
    uint8_t packet[TS_FEC_PACKET_SIZE];
807 811
    int packet_num, len;
812
    int i, found = 0;
813
    int64_t pos;
808 814

  
809 815
    ts->stop_parse = 0;
810 816
    packet_num = 0;
......
814 820
        packet_num++;
815 821
        if (nb_packets != 0 && packet_num >= nb_packets)
816 822
            break;
823
        pos = url_ftell(pb);
817 824
        len = get_buffer(pb, packet, ts->raw_packet_size);
818 825
        if (len != ts->raw_packet_size)
819 826
            return AVERROR_IO;
820 827
        /* check paquet sync byte */
821
        /* XXX: accept to resync ? */
822 828
        if (packet[0] != 0x47)
823
            return AVERROR_INVALIDDATA;
829
        {
830
           //printf("bad packet: 0x%x\n", packet[0]);
831
           found = 0;
832
           for (i = 0; i < ts->raw_packet_size; i++)
833
           {
834
               if (packet[i] == 0x47)
835
               {
836
                   found = 1;
837
                   //printf("packet start at: %d\n", i);
838
                   break;
839
               }
840
           }
841
           
842
           if (found)
843
           {
844
               url_fseek(pb, pos + i, SEEK_SET);
845
               continue;
846
           }
847
           return AVERROR_INVALIDDATA;
848
        }
824 849
        handle_packet(s, packet);
825 850
    }
826 851
    return 0;

Also available in: Unified diff