reuse send_mpeg_lpcm_packet() instead of the old packetizer

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19166 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
nicodvb 2006-07-23 09:32:04 +00:00
parent 902b1a22b1
commit a6a7d56cd1
1 changed files with 1 additions and 78 deletions

View File

@ -233,84 +233,7 @@ void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
} }
void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){ void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){
send_mpeg_lpcm_packet(data, len, id, timestamp, freq_id, my_write);
int ptslen=timestamp?5:0;
// startcode:
pes_header[0]=pes_header[1]=0;
pes_header[2]=1; pes_header[3]=0xBD;
while(len>=4){
int payload_size;
payload_size=PES_MAX_SIZE-6-20; // max possible data len
if(payload_size>len) payload_size=len;
payload_size&=(~3); // align!
//if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6;
// packetsize:
pes_header[4]=(payload_size+3+ptslen+7)>>8;
pes_header[5]=(payload_size+3+ptslen+7)&255;
// stuffing:
// TTCCxxxx CC=css TT=type: 1=STD 0=mpeg1 2=vob
pes_header[6]=0x81;
// FFxxxxxx FF=pts flags=2 vs 0
pes_header[7]=ptslen ? 0x80 : 0;
// hdrlen:
pes_header[8]=ptslen;
if(ptslen){
int x;
// presentation time stamp:
x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
pes_header[9]=x;
x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
pes_header[10]=x>>8; pes_header[11]=x&255;
x=((((timestamp) & 0x7fff) << 1) | 1);
pes_header[12]=x>>8; pes_header[13]=x&255;
}
// ============ LPCM header: (7 bytes) =================
// Info by mocm@convergence.de
// ID:
pes_header[ptslen+9]=id;
// number of frames:
pes_header[ptslen+10]=0x07;
// first acces unit pointer, i.e. start of audio frame:
pes_header[ptslen+11]=0x00;
pes_header[ptslen+12]=0x04;
// audio emphasis on-off 1 bit
// audio mute on-off 1 bit
// reserved 1 bit
// audio frame number 5 bit
pes_header[ptslen+13]=0x0C;
// quantization word length 2 bit
// audio sampling frequency (48khz = 0, 96khz = 1) 2 bit
// reserved 1 bit
// number of audio channels - 1 (e.g. stereo = 1) 3 bit
pes_header[ptslen+14]=1|(freq_id<<4);
// dynamic range control (0x80 if off)
pes_header[ptslen+15]=0x80;
memcpy(&pes_header[6+3+ptslen+7],data,payload_size);
my_write(pes_header,6+3+ptslen+7+payload_size);
len-=payload_size; data+=payload_size;
ptslen=0; // store PTS only once, at first packet!
}
// printf("PES: draw frame! pts=%d size=%d \n",timestamp,len);
} }