2 * video_out_pgm.c, pgm interface
5 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved.
7 * Hacked into mpeg2dec by
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>
22 #include "video_out.h"
23 #include "video_out_internal.h"
25 static vo_info_t info
=
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];
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
;
49 image
=malloc(width
*height
*3/2);
51 snprintf (header
, 1024, "P5\n\n%d %d\n255\n", width
, height
*3/2);
56 static void draw_osd(void)
60 static void flip_page (void)
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
);
74 static uint32_t draw_slice(uint8_t *srcimg
[], int stride
[], int w
,int h
,int x
,int y
)
78 uint8_t *dst
=image
+image_width
*y
+x
;
79 uint8_t *src
=srcimg
[0];
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);
92 memcpy(dst
+image_width
/2,src2
,w
/2);
104 static uint32_t draw_frame(uint8_t * src
[])
110 query_format(uint32_t format
)
112 if(format
==IMGFMT_YV12
) return 1;
115 // case IMGFMT_RGB|24:
116 // case IMGFMT_BGR|24:
125 if(image
){ free(image
);image
=NULL
;}
129 static void check_events(void)
133 static uint32_t preinit(const char *arg
)
137 printf("vo_pgm: Unknown subdevice: %s\n",arg
);
143 static uint32_t control(uint32_t request
, void *data
, ...)
146 case VOCTRL_QUERY_FORMAT
:
147 return query_format(*((uint32_t*)data
));