Mercurial > mplayer.hg
annotate libvo/vo_pgm.c @ 5715:71843ef1a085
video filter layer documentation begun (maybe audio layer should be
moved out from sound.html too? But that's SGML matter..)
author | gabucino |
---|---|
date | Sat, 20 Apr 2002 05:58:21 +0000 |
parents | 32e1f5042f65 |
children | eca7dbad0166 |
rev | line source |
---|---|
1 | 1 /* |
2 * video_out_pgm.c, pgm interface | |
3 * | |
4 * | |
5 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. | |
6 * | |
7 * Hacked into mpeg2dec by | |
8 * | |
9 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca> | |
10 * | |
11 * 15 & 16 bpp support added by Franck Sicard <Franck.Sicard@solsoft.fr> | |
12 * | |
13 * Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de> | |
14 */ | |
15 | |
16 #include <stdio.h> | |
17 #include <stdlib.h> | |
18 #include <string.h> | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
19 #include <errno.h> |
1 | 20 |
21 #include "config.h" | |
22 #include "video_out.h" | |
23 #include "video_out_internal.h" | |
24 | |
25 LIBVO_EXTERN (pgm) | |
26 | |
27 static vo_info_t vo_info = | |
28 { | |
29 "PGM file", | |
30 "pgm", | |
31 "walken", | |
32 "" | |
33 }; | |
34 | |
35 static int image_width; | |
36 static int image_height; | |
37 static char header[1024]; | |
491 | 38 static int framenum = 0; |
39 | |
40 static uint8_t *image=NULL; | |
41 | |
42 char vo_pgm_filename[24]; | |
1 | 43 |
44 static uint32_t | |
4433 | 45 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info) |
1 | 46 { |
47 image_height = height; | |
48 image_width = width; | |
491 | 49 image=malloc(width*height*3/2); |
1 | 50 |
1094 | 51 snprintf (header, 1024, "P5\n\n%d %d\n255\n", width, height*3/2); |
1 | 52 |
53 return 0; | |
54 } | |
55 | |
56 static const vo_info_t* | |
57 get_info(void) | |
58 { | |
59 return &vo_info; | |
60 } | |
61 | |
1502 | 62 static void draw_osd(void) |
63 { | |
64 } | |
65 | |
1 | 66 static void flip_page (void) |
67 { | |
68 FILE * f; | |
69 | |
1094 | 70 snprintf (vo_pgm_filename, 24, "%08d.pgm", framenum++); |
491 | 71 |
72 f = fopen (vo_pgm_filename, "wb"); if (f == NULL) return; | |
1 | 73 fwrite (header, strlen (header), 1, f); |
491 | 74 fwrite (image, image_width, image_height*3/2, f); |
1 | 75 fclose (f); |
76 | |
491 | 77 return; |
78 } | |
79 | |
80 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y) | |
81 { | |
82 int i; | |
83 // copy Y: | |
84 uint8_t *dst=image+image_width*y+x; | |
85 uint8_t *src=srcimg[0]; | |
86 for(i=0;i<h;i++){ | |
87 memcpy(dst,src,w); | |
88 src+=stride[0]; | |
89 dst+=image_width; | |
90 } | |
91 { | |
92 // copy U+V: | |
93 uint8_t *src1=srcimg[1]; | |
94 uint8_t *src2=srcimg[2]; | |
95 uint8_t *dst=image+image_width*image_height+image_width*(y/2)+(x/2); | |
96 for(i=0;i<h/2;i++){ | |
97 memcpy(dst,src1,w/2); | |
98 memcpy(dst+image_width/2,src2,w/2); | |
99 src1+=stride[1]; | |
100 src2+=stride[2]; | |
101 dst+=image_width; | |
102 } | |
103 | |
104 } | |
105 | |
1 | 106 return 0; |
107 } | |
108 | |
491 | 109 |
1 | 110 static uint32_t draw_frame(uint8_t * src[]) |
111 { | |
491 | 112 return 0; |
1 | 113 } |
114 | |
115 static uint32_t | |
116 query_format(uint32_t format) | |
117 { | |
491 | 118 if(format==IMGFMT_YV12) return 1; |
15 | 119 // switch(format){ |
120 // case IMGFMT_YV12: | |
1 | 121 // case IMGFMT_RGB|24: |
122 // case IMGFMT_BGR|24: | |
15 | 123 // return 1; |
124 // } | |
1 | 125 return 0; |
126 } | |
127 | |
128 static void | |
129 uninit(void) | |
130 { | |
491 | 131 if(image){ free(image);image=NULL;} |
1 | 132 } |
133 | |
134 | |
31 | 135 static void check_events(void) |
136 { | |
137 } | |
1 | 138 |
4352 | 139 static uint32_t preinit(const char *arg) |
140 { | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
141 if(arg) |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
142 { |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
143 printf("vo_pgm: Unknown subdevice: %s\n",arg); |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
144 return ENOSYS; |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
145 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
146 return 0; |
4352 | 147 } |
31 | 148 |
4596 | 149 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 150 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
151 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
152 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
153 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
154 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
155 return VO_NOTIMPL; |
4352 | 156 } |