Revision ffdbada6

View differences:

libavformat/mpegts.c
540 540
    }
541 541
}
542 542

  
543
static AVStream *new_pes_av_stream(PESContext *pes, uint32_t prog_reg_desc)
543
static AVStream *new_pes_av_stream(PESContext *pes, uint32_t prog_reg_desc, uint32_t code)
544 544
{
545 545
    AVStream *st = av_new_stream(pes->stream, pes->pid);
546 546

  
......
564 564
    if (st->codec->codec_id == CODEC_ID_PROBE)
565 565
        mpegts_find_stream_type(st, pes->stream_type, MISC_types);
566 566

  
567
    /* stream was not present in PMT, guess based on PES start code */
568
    if (st->codec->codec_id == CODEC_ID_PROBE) {
569
        if (code >= 0x1c0 && code <= 0x1df) {
570
            st->codec->codec_type = CODEC_TYPE_AUDIO;
571
            st->codec->codec_id = CODEC_ID_MP2;
572
        } else if (code == 0x1bd) {
573
            st->codec->codec_type = CODEC_TYPE_AUDIO;
574
            st->codec->codec_id = CODEC_ID_AC3;
575
        }
576
    }
577

  
567 578
    return st;
568 579
}
569 580

  
......
642 653
            if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably
643 654
            pes = add_pes_stream(ts, pid, pcr_pid, stream_type);
644 655
            if (pes)
645
                st = new_pes_av_stream(pes, prog_reg_desc);
656
                st = new_pes_av_stream(pes, prog_reg_desc, 0);
646 657
        }
647 658

  
648 659
        if (!st)
......
910 921
                    pes->header[2] == 0x01) {
911 922
                    /* it must be an mpeg2 PES stream */
912 923
                    code = pes->header[3] | 0x100;
913
                    if (!pes->st || pes->st->discard == AVDISCARD_ALL ||
924

  
925
                    /* stream not present in PMT */
926
                    if (!pes->st)
927
                        pes->st = new_pes_av_stream(pes, 0, code);
928
                    if (!pes->st)
929
                        return AVERROR(ENOMEM);
930

  
931
                    if (pes->st->discard == AVDISCARD_ALL ||
914 932
                        !((code >= 0x1c0 && code <= 0x1df) ||
915 933
                          (code >= 0x1e0 && code <= 0x1ef) ||
916 934
                          (code == 0x1bd) || (code == 0x1fd)))

Also available in: Unified diff