dx50 = DX50
[mplayer/glamo.git] / libvo / vo_pgm.c
blob16fc5789d3fcb8423fadc57c69be03f32e454186
1 /*
2 * video_out_pgm.c, pgm interface
5 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved.
7 * Hacked into mpeg2dec by
8 *
9 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
11 * 15 & 16 bpp support added by Franck Sicard <Franck.Sicard@solsoft.fr>
13 * Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <errno.h>
21 #include "config.h"
22 #include "video_out.h"
23 #include "video_out_internal.h"
25 static vo_info_t info =
27 "PGM file",
28 "pgm",
29 "walken",
33 LIBVO_EXTERN (pgm)
35 static int image_width;
36 static int image_height;
37 static char header[1024];
38 static int framenum = 0;
40 static uint8_t *image=NULL;
42 char vo_pgm_filename[24];
44 static uint32_t
45 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
47 image_height = height;
48 image_width = width;
49 image=malloc(width*height*3/2);
51 snprintf (header, 1024, "P5\n\n%d %d\n255\n", width, height*3/2);
53 return 0;
56 static void draw_osd(void)
60 static void flip_page (void)
62 FILE * f;
64 snprintf (vo_pgm_filename, 24, "%08d.pgm", framenum++);
66 f = fopen (vo_pgm_filename, "wb"); if (f == NULL) return;
67 fwrite (header, strlen (header), 1, f);
68 fwrite (image, image_width, image_height*3/2, f);
69 fclose (f);
71 return;
74 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y)
76 int i;
77 // copy Y:
78 uint8_t *dst=image+image_width*y+x;
79 uint8_t *src=srcimg[0];
80 for(i=0;i<h;i++){
81 memcpy(dst,src,w);
82 src+=stride[0];
83 dst+=image_width;
86 // copy U+V:
87 uint8_t *src1=srcimg[1];
88 uint8_t *src2=srcimg[2];
89 uint8_t *dst=image+image_width*image_height+image_width*(y/2)+(x/2);
90 for(i=0;i<h/2;i++){
91 memcpy(dst,src1,w/2);
92 memcpy(dst+image_width/2,src2,w/2);
93 src1+=stride[1];
94 src2+=stride[2];
95 dst+=image_width;
100 return 0;
104 static uint32_t draw_frame(uint8_t * src[])
106 return 0;
109 static uint32_t
110 query_format(uint32_t format)
112 if(format==IMGFMT_YV12) return 1;
113 // switch(format){
114 // case IMGFMT_YV12:
115 // case IMGFMT_RGB|24:
116 // case IMGFMT_BGR|24:
117 // return 1;
118 // }
119 return 0;
122 static void
123 uninit(void)
125 if(image){ free(image);image=NULL;}
129 static void check_events(void)
133 static uint32_t preinit(const char *arg)
135 if(arg)
137 printf("vo_pgm: Unknown subdevice: %s\n",arg);
138 return ENOSYS;
140 return 0;
143 static uint32_t control(uint32_t request, void *data, ...)
145 switch (request) {
146 case VOCTRL_QUERY_FORMAT:
147 return query_format(*((uint32_t*)data));
149 return VO_NOTIMPL;