annotate libvo/vo_pgm.c @ 4159:42fec596fe7c

-endpos option, patch by Fredrik Kuivinen <freku045@student.liu.se>
author arpi
date Tue, 15 Jan 2002 00:20:50 +0000
parents ccb1f3ddb29a
children ed5b85b713a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * video_out_pgm.c, pgm interface
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * Hacked into mpeg2dec by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * 15 & 16 bpp support added by Franck Sicard <Franck.Sicard@solsoft.fr>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 LIBVO_EXTERN (pgm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 "PGM file",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 "pgm",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 "walken",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 static int image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 static int image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 static char header[1024];
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
37 static int framenum = 0;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
38
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
39 static uint8_t *image=NULL;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
40
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
41 char vo_pgm_filename[24];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 image_height = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 image_width = width;
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
48 image=malloc(width*height*3/2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
1094
7a6be90408ea possible buffer overflows fixed
al3x
parents: 491
diff changeset
50 snprintf (header, 1024, "P5\n\n%d %d\n255\n", width, height*3/2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 static const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 return &vo_info;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
1502
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
61 static void draw_osd(void)
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
62 {
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
63 }
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
64
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 static void flip_page (void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 FILE * f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68
1094
7a6be90408ea possible buffer overflows fixed
al3x
parents: 491
diff changeset
69 snprintf (vo_pgm_filename, 24, "%08d.pgm", framenum++);
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
70
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
71 f = fopen (vo_pgm_filename, "wb"); if (f == NULL) return;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 fwrite (header, strlen (header), 1, f);
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
73 fwrite (image, image_width, image_height*3/2, f);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 fclose (f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
76 return;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
77 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
78
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
79 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y)
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
80 {
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
81 int i;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
82 // copy Y:
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
83 uint8_t *dst=image+image_width*y+x;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
84 uint8_t *src=srcimg[0];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
85 for(i=0;i<h;i++){
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
86 memcpy(dst,src,w);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
87 src+=stride[0];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
88 dst+=image_width;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
89 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
90 {
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
91 // copy U+V:
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
92 uint8_t *src1=srcimg[1];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
93 uint8_t *src2=srcimg[2];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
94 uint8_t *dst=image+image_width*image_height+image_width*(y/2)+(x/2);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
95 for(i=0;i<h/2;i++){
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
96 memcpy(dst,src1,w/2);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
97 memcpy(dst+image_width/2,src2,w/2);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
98 src1+=stride[1];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
99 src2+=stride[2];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
100 dst+=image_width;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
101 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
102
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
103 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
104
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
108
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 static uint32_t draw_frame(uint8_t * src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 {
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
111 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 {
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
117 if(format==IMGFMT_YV12) return 1;
15
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
118 // switch(format){
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
119 // case IMGFMT_YV12:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 // case IMGFMT_RGB|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 // case IMGFMT_BGR|24:
15
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
122 // return 1;
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
123 // }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 {
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
130 if(image){ free(image);image=NULL;}
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
134 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
135 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
136 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
138
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
139