[Mplayer-cvslog] CVS: main/libvo vo_mpegpes.c,1.13,1.14
Arpi of Ize
arpi at mplayer.dev.hu
Tue Jan 22 19:12:03 CET 2002
Update of /cvsroot/mplayer/main/libvo
In directory mplayer:/var/tmp.root/cvs-serv18191
Modified Files:
vo_mpegpes.c
Log Message:
cleanup of video packet writer, PTS sent only once
Index: vo_mpegpes.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_mpegpes.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- vo_mpegpes.c 22 Jan 2002 02:14:40 -0000 1.13
+++ vo_mpegpes.c 22 Jan 2002 18:12:00 -0000 1.14
@@ -293,21 +293,23 @@
static unsigned char pes_header[PES_MAX_SIZE];
void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
- int x;
+ int ptslen=timestamp?5:1;
+ // startcode:
pes_header[0]=pes_header[1]=0;
pes_header[2]=id>>8; pes_header[3]=id&255;
- while(1){
- int payload_size=len+5; // data + PTS
- if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6;
+ while(len>0){
+ int payload_size=len; // data + PTS
+ if(6+ptslen+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-(6+ptslen);
// construct PES header: (code from ffmpeg's libav)
- // startcode:
// packetsize:
- pes_header[4]=(payload_size)>>8;
- pes_header[5]=(payload_size)&255;
- // stuffing:
+ pes_header[4]=(ptslen+payload_size)>>8;
+ pes_header[5]=(ptslen+payload_size)&255;
+
+ if(ptslen==5){
+ int x;
// presentation time stamp:
x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
pes_header[6]=x;
@@ -315,13 +317,16 @@
pes_header[7]=x>>8; pes_header[8]=x&255;
x=((((timestamp) & 0x7fff) << 1) | 1);
pes_header[9]=x>>8; pes_header[10]=x&255;
-
- payload_size-=5;
- memcpy(&pes_header[6+5],data,payload_size);
- my_write(pes_header,6+5+payload_size);
+ } else {
+ // stuffing and header bits:
+ pes_header[6]=0x0f;
+ }
+
+ memcpy(&pes_header[6+ptslen],data,payload_size);
+ my_write(pes_header,6+ptslen+payload_size);
len-=payload_size; data+=payload_size;
- if(len<=0) break;
+ ptslen=1; // store PTS only once, at first packet!
}
// printf("PES: draw frame! pts=%d size=%d \n",timestamp,len);
@@ -332,6 +337,7 @@
int ptslen=timestamp?5:0;
+ // startcode:
pes_header[0]=pes_header[1]=0;
pes_header[2]=1; pes_header[3]=0xBD;
@@ -398,7 +404,7 @@
my_write(pes_header,6+3+ptslen+7+payload_size);
len-=payload_size; data+=payload_size;
- if(len<=0) break;
+ ptslen=0; // store PTS only once, at first packet!
}
// printf("PES: draw frame! pts=%d size=%d \n",timestamp,len);
More information about the MPlayer-cvslog
mailing list