changeset 491:2313c6ea006f

YV12 is working again
author arpi_esp
date Tue, 17 Apr 2001 21:00:46 +0000
parents caf5ddb0d19a
children 888a85621f50
files libvo/vo_md5.c libvo/vo_pgm.c
diffstat 2 files changed, 63 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_md5.c	Tue Apr 17 20:51:58 2001 +0000
+++ b/libvo/vo_md5.c	Tue Apr 17 21:00:46 2001 +0000
@@ -1,5 +1,3 @@
-#define DISP
-
 /* 
  * video_out_pgm.c, pgm interface
  *
@@ -34,9 +32,9 @@
 };
 
 extern vo_functions_t video_out_pgm;
+extern char vo_pgm_filename[24];
 
 static FILE * md5_file;
-static int framenum = -2;
 
 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)
@@ -53,54 +51,47 @@
 
 static void flip_page (void)
 {
+    char buf2[100];
+    FILE * f;
+    int i;
+
+    video_out_pgm.flip_page();
+
+    sprintf (buf2, "md5sum %s", vo_pgm_filename);
+    f = popen (buf2, "r");
+    i = fread (buf2, 1, sizeof(buf2), f);
+    pclose (f);
+    fwrite (buf2, 1, i, md5_file);
+
+    remove (vo_pgm_filename);
+    
 }
 
 //static uint32_t draw_slice(uint8_t * src[], uint32_t slice_num)
 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
 {
-    return 0;
+    return video_out_pgm.draw_slice(image,stride,w,h,x,y);
 }
 
-extern uint32_t output_pgm_frame (char * fname, uint8_t * src[]);
+//extern uint32_t output_pgm_frame (char * fname, uint8_t * src[]);
 
 static uint32_t draw_frame(uint8_t * src[])
 {
-    char buf[100];
-    char buf2[100];
-    FILE * f;
-    int i;
-
-    if (++framenum < 0)
-	return 0;
-
-    sprintf (buf, "%d.pgm", framenum);
-    output_pgm_frame (buf, src);
-
-    sprintf (buf2, "md5sum %s", buf);
-    f = popen (buf2, "r");
-    i = fread (buf2, 1, sizeof(buf2), f);
-    pclose (f);
-    fwrite (buf2, 1, i, md5_file);
-
-    remove (buf);
-
     return 0;
 }
 
 static uint32_t
 query_format(uint32_t format)
 {
-//    switch(format){
-//    case IMGFMT_YV12:
-//        return 1;
-//    }
-    return 0;
+    return video_out_pgm.query_format(format);
 }
 
 
 static void
 uninit(void)
 {
+    video_out_pgm.uninit();
+    fclose(md5_file);
 }
 
 
--- a/libvo/vo_pgm.c	Tue Apr 17 20:51:58 2001 +0000
+++ b/libvo/vo_pgm.c	Tue Apr 17 21:00:46 2001 +0000
@@ -1,5 +1,3 @@
-#define DISP
-
 /* 
  * video_out_pgm.c, pgm interface
  *
@@ -36,13 +34,18 @@
 static int image_width;
 static int image_height;
 static char header[1024];
-static int framenum = -2;
+static int framenum = 0;
+
+static uint8_t *image=NULL;
+
+char vo_pgm_filename[24];
 
 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)
 {
     image_height = height;
     image_width = width;
+    image=malloc(width*height*3/2);
 
     sprintf (header, "P5\n\n%d %d\n255\n", width, height*3/2);
 
@@ -57,46 +60,58 @@
 
 static void flip_page (void)
 {
-}
-
-static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
-//static uint32_t draw_slice(uint8_t * src[], uint32_t slice_num)
-{
-    return 0;
-}
-
-uint32_t output_pgm_frame (char * fname, uint8_t * src[])
-{
     FILE * f;
     int i;
 
-    f = fopen (fname, "wb");
-    if (f == NULL) return 1;
+    sprintf (vo_pgm_filename, "%08d.pgm", framenum++);
+
+    f = fopen (vo_pgm_filename, "wb");  if (f == NULL) return;
     fwrite (header, strlen (header), 1, f);
-    fwrite (src[0], image_width, image_height, f);
-    for (i = 0; i < image_height/2; i++) {
-	fwrite (src[1]+i*image_width/2, image_width/2, 1, f);
-	fwrite (src[2]+i*image_width/2, image_width/2, 1, f);
-    }
+    fwrite (image, image_width, image_height*3/2, f);
     fclose (f);
 
+    return;
+}
+
+static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y)
+{
+    int i;
+    // copy Y:
+    uint8_t *dst=image+image_width*y+x;
+    uint8_t *src=srcimg[0];
+    for(i=0;i<h;i++){
+        memcpy(dst,src,w);
+        src+=stride[0];
+        dst+=image_width;
+    }
+{
+    // copy U+V:
+    uint8_t *src1=srcimg[1];
+    uint8_t *src2=srcimg[2];
+    uint8_t *dst=image+image_width*image_height+image_width*(y/2)+(x/2);
+    for(i=0;i<h/2;i++){
+        memcpy(dst,src1,w/2);
+        memcpy(dst+image_width/2,src2,w/2);
+        src1+=stride[1];
+        src2+=stride[2];
+        dst+=image_width;
+    }
+
+}
+    
     return 0;
 }
 
+
 static uint32_t draw_frame(uint8_t * src[])
 {
-    char buf[100];
-
-    if (++framenum < 0)
-	return 0;
-
-    sprintf (buf, "%d.pgm", framenum);
-    return output_pgm_frame (buf, src);
+    return 0;
 }
 
 static uint32_t
 query_format(uint32_t format)
 {
+    if(format==IMGFMT_YV12) return 1;
 //    switch(format){
 //    case IMGFMT_YV12:
 //    case IMGFMT_RGB|24:
@@ -109,6 +124,7 @@
 static void
 uninit(void)
 {
+    if(image){ free(image);image=NULL;}
 }