From: Gert V. <Ger...@wx...> - 2001-08-04 12:10:10
|
The following patch adds support for AC3 audio for transportstreams. ATSC transport streams use AC3 for the audio. In tramsport streams, the AC3 audio is put in a private stream without a mysterious header like in DVD. To check if it is AC3 audio, I look if there is a AC3 syncword. I also encoded an transport stream which uses LPCM audio, I have no idea if this is supported by the DVB or ATSC standard. But, there is no way to detect from the data if it is LPCM audio, there is no header as far as I know. Maybe something like, if a transport stream packet which uses the audio PID and contains no MPEG audio or AC3 audio then we have LPCM audio. Gert --- demux_ts.c.orig Sat Aug 4 12:46:10 2001 +++ demux_ts.c Sat Aug 4 14:11:39 2001 @@ -799,9 +799,9 @@ if (nStreamID == 0xbd) { - int nTrack,nSPUID; - nTrack = p[0] & 0x0F; /* hack : ac3 track */ +#if 0 /* there are no DVD subpictures in transport streams */ + int nSPUID; if((p[0] & 0xE0) == 0x20) { nSPUID = (p[0] & 0x1f); @@ -822,14 +822,15 @@ return; } } +#endif - if (((p[0]&0xF0) == 0x80) && (nTrack == this->mnAudioChannel)) { + /* check for AC3 syncword */ + if ((p[0] == 0x0B) && (p[1] == 0x77)) { - xprintf(VERBOSE|DEMUX|AC3, "ac3 PES packet, track %02x\n",nTrack); - /* printf ( "ac3 PES packet, track %02x\n",nTrack); */ + xprintf(VERBOSE|DEMUX|AC3, "ac3 PES packet\n"); - buf->content = p+4; - buf->size = nPacketLen-4; + buf->content = p; + buf->size = nPacketLen; buf->type = BUF_AUDIO_AC3; buf->PTS = nPTS; buf->DTS = nDTS ; @@ -837,23 +838,21 @@ this->fifoAudio->put(this->fifoAudio, buf); return ; - } else if (((p[0]&0xf0) == 0xa0) || (nTrack == (this->mnAudioChannel-16))) { + } - int pcm_offset; +#if 0 +/* + how do we detect LPCM in transport streams? + There is no header, just data. +*/ + else if ( ??? ) { xprintf(VERBOSE|DEMUX,"LPCMacket, len : %d %02x\n",nPacketLen-4, p[0]); /* printf ("PCM!!!!!!!!!!!!!!!!!!!!!!!\n"); */ - for( pcm_offset=0; ++pcm_offset < nPacketLen-1 ; ){ - if ( p[pcm_offset] == 0x01 && p[pcm_offset+1] == 0x80 ) { /* START */ - pcm_offset += 2; - break; - } - } - - buf->content = p+pcm_offset; - buf->size = nPacketLen-pcm_offset; + buf->content = p; + buf->size = nPacketLen; buf->type = BUF_AUDIO_LPCM; buf->PTS = nPTS; buf->DTS = nDTS ; @@ -862,6 +861,7 @@ this->fifoAudio->put(this->fifoAudio, buf); return ; } +#endif } else if ((nStreamID >= 0xbc) && ((nStreamID & 0xf0) == 0xe0)) { |