[Mplayer-cvslog] CVS: main/libvo vo_mpegpes.c,1.12,1.13
Arpi of Ize
arpi at mplayer.dev.hu
Tue Jan 22 03:14:43 CET 2002
Update of /cvsroot/mplayer/main/libvo
In directory mplayer:/var/tmp.root/cvs-serv6148
Modified Files:
vo_mpegpes.c
Log Message:
LPCM write code rewritten, thanks to Marcus at mocm at convergence.de
Index: vo_mpegpes.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_mpegpes.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- vo_mpegpes.c 5 Nov 2001 21:49:20 -0000 1.12
+++ vo_mpegpes.c 22 Jan 2002 02:14:40 -0000 1.13
@@ -163,7 +163,7 @@
codec_context.frame_rate=25*FRAME_RATE_BASE; // !!!!!
codec_context.gop_size=0; // I frames only
codec_context.flags=CODEC_FLAG_QSCALE;
- codec_context.quality=1; // quality! 1..31 (1=best,slowest)
+ codec_context.quality=3; // quality! 1..31 (1=best,slowest)
#if 0
codec_context.width=width;
@@ -328,8 +328,9 @@
}
-void send_lpcm_packet(unsigned char* data,int len,int id,int timestamp){
- int x;
+void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){
+
+ int ptslen=timestamp?5:0;
pes_header[0]=pes_header[1]=0;
pes_header[2]=1; pes_header[3]=0xBD;
@@ -341,19 +342,21 @@
if(payload_size>len) payload_size=len;
payload_size&=(~3); // align!
- payload_size+=20; // PTS+headers
-
//if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6;
- // construct PES header: (code from ffmpeg's libav)
- // startcode:
// packetsize:
- pes_header[4]=(payload_size)>>8;
- pes_header[5]=(payload_size)&255;
+ pes_header[4]=(payload_size+3+ptslen+7)>>8;
+ pes_header[5]=(payload_size+3+ptslen+7)&255;
+
// stuffing:
pes_header[6]=0x81;
pes_header[7]=0x80;
- pes_header[8]=10; // hdrlen
+
+ // hdrlen:
+ pes_header[8]=ptslen;
+
+ if(ptslen){
+ int x;
// presentation time stamp:
x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
pes_header[9]=x;
@@ -361,26 +364,38 @@
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;
+ }
- pes_header[14]=
- pes_header[15]=
- pes_header[16]=
- pes_header[17]=
- pes_header[18]=0xFF; // stuffing
-
- pes_header[19]=id;
-
- pes_header[20]=0x07; // dunnowhat
- pes_header[21]=0x00;
- pes_header[22]=0x04;
- pes_header[23]=0x0C;
-
- pes_header[24]=0x01; // LPCM id
- pes_header[25]=0x80;
-
- payload_size-=20;
- memcpy(&pes_header[6+20],data,payload_size);
- my_write(pes_header,6+20+payload_size);
+// ============ LPCM header: (7 bytes) =================
+// Info by mocm at 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;
if(len<=0) break;
More information about the MPlayer-cvslog
mailing list