Mercurial > libavformat.hg
comparison mpegts.c @ 3059:f982a5a75e40 libavformat
treat stream_type==0x82 as AUDIO_DTS when the program has a REGISTRATION_DESCRIPTOR with the value HDMV; approved by Mans
author | nicodvb |
---|---|
date | Sat, 23 Feb 2008 10:57:38 +0000 |
parents | c31c50af40c5 |
children | dcde7da1d183 |
comparison
equal
deleted
inserted
replaced
3058:33ecae58665a | 3059:f982a5a75e40 |
---|---|
29 #define MAX_SCAN_PACKETS 32000 | 29 #define MAX_SCAN_PACKETS 32000 |
30 | 30 |
31 /* maximum size in which we look for synchronisation if | 31 /* maximum size in which we look for synchronisation if |
32 synchronisation is lost */ | 32 synchronisation is lost */ |
33 #define MAX_RESYNC_SIZE 4096 | 33 #define MAX_RESYNC_SIZE 4096 |
34 #define REGISTRATION_DESCRIPTOR 5 | |
34 | 35 |
35 typedef struct PESContext PESContext; | 36 typedef struct PESContext PESContext; |
36 | 37 |
37 static PESContext* add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid, int stream_type); | 38 static PESContext* add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid, int stream_type); |
38 static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code); | 39 static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code); |
476 const uint8_t *p, *p_end, *desc_list_end, *desc_end; | 477 const uint8_t *p, *p_end, *desc_list_end, *desc_end; |
477 int program_info_length, pcr_pid, pid, stream_type; | 478 int program_info_length, pcr_pid, pid, stream_type; |
478 int desc_list_len, desc_len, desc_tag; | 479 int desc_list_len, desc_len, desc_tag; |
479 int comp_page = 0, anc_page = 0; /* initialize to kill warnings */ | 480 int comp_page = 0, anc_page = 0; /* initialize to kill warnings */ |
480 char language[4] = {0}; /* initialize to kill warnings */ | 481 char language[4] = {0}; /* initialize to kill warnings */ |
482 int has_hdmv_descr = 0; | |
481 | 483 |
482 #ifdef DEBUG_SI | 484 #ifdef DEBUG_SI |
483 av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len); | 485 av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len); |
484 av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len); | 486 av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len); |
485 #endif | 487 #endif |
503 av_log(ts->stream, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid); | 505 av_log(ts->stream, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid); |
504 #endif | 506 #endif |
505 program_info_length = get16(&p, p_end) & 0xfff; | 507 program_info_length = get16(&p, p_end) & 0xfff; |
506 if (program_info_length < 0) | 508 if (program_info_length < 0) |
507 return; | 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 p += program_info_length; | 531 p += program_info_length; |
509 if (p >= p_end) | 532 if (p >= p_end) |
510 return; | 533 return; |
511 for(;;) { | 534 for(;;) { |
512 language[0] = 0; | 535 language[0] = 0; |
586 case STREAM_TYPE_VIDEO_H264: | 609 case STREAM_TYPE_VIDEO_H264: |
587 case STREAM_TYPE_VIDEO_VC1: | 610 case STREAM_TYPE_VIDEO_VC1: |
588 case STREAM_TYPE_AUDIO_AAC: | 611 case STREAM_TYPE_AUDIO_AAC: |
589 case STREAM_TYPE_AUDIO_AC3: | 612 case STREAM_TYPE_AUDIO_AC3: |
590 case STREAM_TYPE_AUDIO_DTS: | 613 case STREAM_TYPE_AUDIO_DTS: |
614 case STREAM_TYPE_AUDIO_HDMV_DTS: | |
591 case STREAM_TYPE_SUBTITLE_DVB: | 615 case STREAM_TYPE_SUBTITLE_DVB: |
616 if(stream_type == STREAM_TYPE_AUDIO_HDMV_DTS && !has_hdmv_descr) | |
617 break; | |
592 if(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES){ | 618 if(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES){ |
593 pes= ts->pids[pid]->u.pes_filter.opaque; | 619 pes= ts->pids[pid]->u.pes_filter.opaque; |
594 st= pes->st; | 620 st= pes->st; |
595 }else{ | 621 }else{ |
596 if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably | 622 if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably |
921 case STREAM_TYPE_AUDIO_AC3: | 947 case STREAM_TYPE_AUDIO_AC3: |
922 codec_type = CODEC_TYPE_AUDIO; | 948 codec_type = CODEC_TYPE_AUDIO; |
923 codec_id = CODEC_ID_AC3; | 949 codec_id = CODEC_ID_AC3; |
924 break; | 950 break; |
925 case STREAM_TYPE_AUDIO_DTS: | 951 case STREAM_TYPE_AUDIO_DTS: |
952 case STREAM_TYPE_AUDIO_HDMV_DTS: | |
926 codec_type = CODEC_TYPE_AUDIO; | 953 codec_type = CODEC_TYPE_AUDIO; |
927 codec_id = CODEC_ID_DTS; | 954 codec_id = CODEC_ID_DTS; |
928 break; | 955 break; |
929 case STREAM_TYPE_SUBTITLE_DVB: | 956 case STREAM_TYPE_SUBTITLE_DVB: |
930 codec_type = CODEC_TYPE_SUBTITLE; | 957 codec_type = CODEC_TYPE_SUBTITLE; |