[Mplayer-cvslog] CVS: main/libvo vo_mpegpes.c,1.1,1.2

Arpi of Ize arpi at mplayer.dev.hu
Sun Sep 9 01:27:53 CEST 2001


Update of /cvsroot/mplayer/main/libvo
In directory mplayer:/var/tmp.root/cvs-serv4910

Modified Files:
	vo_mpegpes.c 
Log Message:
file writer implemented

Index: vo_mpegpes.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_mpegpes.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vo_mpegpes.c	8 Sep 2001 20:48:02 -0000	1.1
+++ vo_mpegpes.c	8 Sep 2001 23:27:51 -0000	1.2
@@ -9,6 +9,8 @@
 
 LIBVO_EXTERN (mpegpes)
 
+int vo_mpegpes_fd=-1;
+
 static vo_info_t vo_info = 
 {
 	"Mpeg-PES file",
@@ -20,7 +22,11 @@
 static uint32_t
 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
 {
-
+    vo_mpegpes_fd=open("grab.mpg","ab");
+    if(vo_mpegpes_fd<0){	
+	perror("vo_mpegpes");
+	return -1;
+    }
     return 0;
 }
 
@@ -43,10 +49,41 @@
     return 0;
 }
 
+static void my_write(unsigned char* data,int len){
+    while(len>0){
+	int ret=write(vo_mpegpes_fd,data,len);
+	if(ret<=0) break; // error
+	len-=ret; data+=ret;
+    }
+}
 
 static uint32_t draw_frame(uint8_t * src[])
 {
+    vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
+    int payload_size=p->size+5;
+    int x;
+    unsigned char pes_header[4+2+5];
+
+    // construct PES header:
+	      // startcode:
+	      pes_header[0]=pes_header[1]=0;
+	      pes_header[2]=p->id>>8; pes_header[3]=p->id&255;
+	      // packetsize:
+	      pes_header[4]=payload_size>>8;
+	      pes_header[5]=payload_size&255;
+	      // stuffing:
+	      // presentation time stamp:
+	      x=(0x02 << 4) | (((p->timestamp >> 30) & 0x07) << 1) | 1;
+	      pes_header[6]=x;
+	      x=((((p->timestamp >> 15) & 0x7fff) << 1) | 1);
+	      pes_header[7]=x>>8; pes_header[8]=x&255;
+	      x=((((p->timestamp) & 0x7fff) << 1) | 1);
+	      pes_header[9]=x>>8; pes_header[10]=x&255;
+    my_write(pes_header,4+2+5);
+    // data:
+    my_write(p->data,p->size);
 
+//    printf("PES: draw frame!  pts=%d   size=%d  \n",p->timestamp,p->size);
 
     return 0;
 }
@@ -61,6 +98,8 @@
 static void
 uninit(void)
 {
+    close(vo_mpegpes_fd);
+    vo_mpegpes_fd=-1;
 }
 
 




More information about the MPlayer-cvslog mailing list