Revision a45b40c4 libavformat/mpegts.c

View differences:

libavformat/mpegts.c
31 31
/* maximum size in which we look for synchronisation if
32 32
   synchronisation is lost */
33 33
#define MAX_RESYNC_SIZE 4096
34
#define REGISTRATION_DESCRIPTOR 5
34 35

  
35 36
typedef struct PESContext PESContext;
36 37

  
......
478 479
    int desc_list_len, desc_len, desc_tag;
479 480
    int comp_page = 0, anc_page = 0; /* initialize to kill warnings */
480 481
    char language[4] = {0}; /* initialize to kill warnings */
482
    int has_hdmv_descr = 0;
481 483

  
482 484
#ifdef DEBUG_SI
483 485
    av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len);
......
505 507
    program_info_length = get16(&p, p_end) & 0xfff;
506 508
    if (program_info_length < 0)
507 509
        return;
510
    while(program_info_length >= 2) {
511
        uint8_t tag, len;
512
        tag = get8(&p, p_end);
513
        len = get8(&p, p_end);
514
        if(len > program_info_length - 2)
515
            //something else is broken, exit the program_descriptors_loop
516
            break;
517
        program_info_length -= len + 2;
518
        if(tag == REGISTRATION_DESCRIPTOR && len >= 4) {
519
            uint8_t bytes[4];
520
            bytes[0] = get8(&p, p_end);
521
            bytes[1] = get8(&p, p_end);
522
            bytes[2] = get8(&p, p_end);
523
            bytes[3] = get8(&p, p_end);
524
            len -= 4;
525
            if(bytes[0] == 'H' && bytes[1] == 'D' &&
526
               bytes[2] == 'M' && bytes[3] == 'V')
527
                has_hdmv_descr = 1;
528
        }
529
        p += len;
530
    }
508 531
    p += program_info_length;
509 532
    if (p >= p_end)
510 533
        return;
......
588 611
        case STREAM_TYPE_AUDIO_AAC:
589 612
        case STREAM_TYPE_AUDIO_AC3:
590 613
        case STREAM_TYPE_AUDIO_DTS:
614
        case STREAM_TYPE_AUDIO_HDMV_DTS:
591 615
        case STREAM_TYPE_SUBTITLE_DVB:
616
            if(stream_type == STREAM_TYPE_AUDIO_HDMV_DTS && !has_hdmv_descr)
617
                break;
592 618
            if(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES){
593 619
                pes= ts->pids[pid]->u.pes_filter.opaque;
594 620
                st= pes->st;
......
923 949
        codec_id = CODEC_ID_AC3;
924 950
        break;
925 951
    case STREAM_TYPE_AUDIO_DTS:
952
    case STREAM_TYPE_AUDIO_HDMV_DTS:
926 953
        codec_type = CODEC_TYPE_AUDIO;
927 954
        codec_id = CODEC_ID_DTS;
928 955
        break;

Also available in: Unified diff