annotate libvo/vo_png.c @ 2315:c3c73ba53f0e

streaming fixed
author arpi
date Sat, 20 Oct 2001 20:35:12 +0000
parents d40f2b686846
children ae79207a3055
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
1 #define DISP
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
2
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
3 /*
530
670d47b4ce10 changed copyroght message to correct stuff :)
atmosfear
parents: 527
diff changeset
4 * vo_png.c, Portable Network Graphics Renderer for Mplayer
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
5 *
530
670d47b4ce10 changed copyroght message to correct stuff :)
atmosfear
parents: 527
diff changeset
6 * Copyright 2001 by Felix Buenemann <atmosfear@users.sourceforge.net>
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
7 *
530
670d47b4ce10 changed copyroght message to correct stuff :)
atmosfear
parents: 527
diff changeset
8 * Uses libpng (which uses zlib), so see according licenses.
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
9 *
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
10 */
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
11
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
12 #include <stdio.h>
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
13 #include <stdlib.h>
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
14 #include <string.h>
612
77e0094f0cce some warnings killed
szabii
parents: 530
diff changeset
15 #include <errno.h>
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
16
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
17 #include <png.h>
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
18 //#include "/usr/include/png.h"
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
19
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
20
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
21 #include "config.h"
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
22 #include "video_out.h"
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
23 #include "video_out_internal.h"
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
24
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
25 #include "yuv2rgb.h"
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
26
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
27 LIBVO_EXTERN (png)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
28
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
29 static vo_info_t vo_info =
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
30 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
31 "PNG file",
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
32 "png",
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
33 "Felix Buenemann <atmosfear@users.sourceforge.net>",
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
34 ""
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
35 };
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
36
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
37 #define RGB 0
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
38 #define BGR 1
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
39
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
40 extern int verbose;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
41 int z_compression = Z_NO_COMPRESSION;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
42 static int image_width;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
43 static int image_height;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
44 static int image_format;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
45 static uint8_t *image_data=NULL;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
46 //static char *image_data;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
47
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
48 static int bpp = 24;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
49 static int cspace = RGB;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
50 static int framenum = 0;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
51
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
52 struct pngdata {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
53 FILE * fp;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
54 png_structp png_ptr;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
55 png_infop info_ptr;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
56 enum {OK,ERROR} status;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
57 };
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
58
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
59 static uint32_t
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
60 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
61 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
62 image_height = height;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
63 image_width = width;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
64 image_format = format;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
65
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
66 //printf("Verbose level is %i\n", verbose);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
67
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
68 switch(format) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
69 case IMGFMT_BGR24:
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
70 bpp = 24;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
71 cspace = BGR;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
72 break;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
73 case IMGFMT_RGB24:
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
74 bpp = 24;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
75 cspace = RGB;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
76 break;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
77 case IMGFMT_YV12:
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
78 bpp = 24;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
79 cspace = RGB;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
80 yuv2rgb_init(bpp,MODE_BGR);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
81 image_data = malloc(image_width*image_height*3);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
82 break;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
83 default:
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
84 return 1;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
85 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
86
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
87 if((z_compression < 0) || (z_compression < 9)) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
88 if(z_compression == 0) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
89 printf("PNG Warning: compression level set to 0, compression disabled!\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
90 printf("PNG Info: Use the -z <n> switch to set compression level from 0 to 9.\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
91 printf("PNG Info: (0 = no compression, 1 = fastest, lowest - 9 best, slowest compression)\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
92 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
93 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
94 else {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
95 printf("PNG Warning: compression level out of range setting to 1!\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
96 printf("PNG Info: Use the -z <n> switch to set compression level from 0 to 9.\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
97 printf("PNG Info: (0 = no compression, 1 = fastest, lowest - 9 best, slowest compression)\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
98 z_compression = Z_BEST_SPEED;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
99 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
100
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
101 if(verbose) printf("PNG Compression level %i\n", z_compression);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
102
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
103 return 0;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
104 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
105
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
106 static const vo_info_t*
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
107 get_info(void)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
108 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
109 return &vo_info;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
110 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
111
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
112
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
113 struct pngdata create_png (char * fname)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
114 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
115 struct pngdata png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
116
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
117 /*png_structp png_ptr = png_create_write_struct
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
118 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
119 user_error_fn, user_warning_fn);*/
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
120 //png_byte *row_pointers[image_height];
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
121 png.png_ptr = png_create_write_struct
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
122 (PNG_LIBPNG_VER_STRING, NULL,
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
123 NULL, NULL);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
124 png.info_ptr = png_create_info_struct(png.png_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
125
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
126 if (!png.png_ptr) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
127 if(verbose > 1) printf("PNG Failed to init png pointer\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
128 png.status = ERROR;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
129 return png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
130 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
131
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
132 if (!png.info_ptr) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
133 if(verbose > 1) printf("PNG Failed to init png infopointer\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
134 png_destroy_write_struct(&png.png_ptr,
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
135 (png_infopp)NULL);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
136 png.status = ERROR;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
137 return png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
138 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
139
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
140 if (setjmp(png.png_ptr->jmpbuf)) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
141 if(verbose > 1) printf("PNG Internal error!\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
142 png_destroy_write_struct(&png.png_ptr, &png.info_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
143 fclose(png.fp);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
144 png.status = ERROR;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
145 return png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
146 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
147
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
148 png.fp = fopen (fname, "wb");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
149 if (png.fp == NULL) {
612
77e0094f0cce some warnings killed
szabii
parents: 530
diff changeset
150 printf("\nPNG Error opening %s for writing!\n", strerror(errno));
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
151 png.status = ERROR;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
152 return png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
153 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
154
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
155 if(verbose > 1) printf("PNG Init IO\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
156 png_init_io(png.png_ptr, png.fp);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
157
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
158 /* set the zlib compression level */
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
159 png_set_compression_level(png.png_ptr, z_compression);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
160
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
161
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
162 /*png_set_IHDR(png_ptr, info_ptr, width, height,
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
163 bit_depth, color_type, interlace_type,
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
164 compression_type, filter_type)*/
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
165 png_set_IHDR(png.png_ptr, png.info_ptr, image_width, image_height,
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
166 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
167 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
168
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
169 if(verbose > 1) printf("PNG Write Info\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
170 png_write_info(png.png_ptr, png.info_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
171
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
172 if(cspace) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
173 if(verbose > 1) printf("PNG Set BGR Conversion\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
174 png_set_bgr(png.png_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
175 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
176
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
177 png.status = OK;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
178 return png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
179
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
180 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
181
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
182 static uint8_t destroy_png(struct pngdata png) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
183
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
184 if(verbose > 1) printf("PNG Write End\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
185 png_write_end(png.png_ptr, png.info_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
186
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
187 if(verbose > 1) printf("PNG Destroy Write Struct\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
188 png_destroy_write_struct(&png.png_ptr, &png.info_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
189
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
190 fclose (png.fp);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
191
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
192 return 0;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
193 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
194
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
195 static uint32_t draw_frame(uint8_t * src[])
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
196 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
197 char buf[100];
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
198 int k, bppmul = bpp/8;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
199 struct pngdata png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
200 png_byte *row_pointers[image_height];
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
201
1078
874ba7049c1a sprintf possible buffer overflow fixes
al3x
parents: 612
diff changeset
202 snprintf (buf, 100, "%08d.png", ++framenum);
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
203
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
204 png = create_png(buf);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
205
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
206 if(png.status){
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
207 printf("PNG Error in create_png\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
208 return 1;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
209 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
210
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
211 if(verbose > 1) printf("PNG Creating Row Pointers\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
212 for ( k = 0; k < image_height; k++ ) row_pointers[k] = &src[0][image_width*k*bppmul];
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
213
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
214 //png_write_flush(png.png_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
215 //png_set_flush(png.png_ptr, nrows);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
216
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
217 if(verbose > 1) printf("PNG Writing Image Data\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
218 png_write_image(png.png_ptr, row_pointers);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
219
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
220 return destroy_png(png);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
221
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
222 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
223
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1078
diff changeset
224 static void draw_osd(void)
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1078
diff changeset
225 {
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1078
diff changeset
226 }
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1078
diff changeset
227
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
228 static void flip_page (void)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
229 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
230 char buf[100];
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
231 int k, bppmul = bpp/8;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
232 struct pngdata png;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
233 png_byte *row_pointers[image_height];
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
234
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
235 if(image_format == IMGFMT_YV12) {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
236
1078
874ba7049c1a sprintf possible buffer overflow fixes
al3x
parents: 612
diff changeset
237 snprintf (buf, 100, "%08d.png", ++framenum);
527
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
238
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
239 png = create_png(buf);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
240
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
241 if(png.status){
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
242 printf("PNG Error in create_png\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
243 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
244
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
245 if(verbose > 1) printf("PNG Creating Row Pointers\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
246 for ( k = 0; k < image_height; k++ ) row_pointers[k] = &image_data[image_width*k*bppmul];
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
247
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
248 //png_write_flush(png.png_ptr);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
249 //png_set_flush(png.png_ptr, nrows);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
250
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
251 if(verbose > 1) printf("PNG Writing Image Data\n");
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
252 png_write_image(png.png_ptr, row_pointers);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
253
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
254 destroy_png(png);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
255 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
256 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
257
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
258 static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
259 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
260 uint8_t *dst;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
261
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
262 dst = image_data + (image_width * y + x) * (bpp/8);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
263 yuv2rgb(dst,src[0],src[1],src[2],w,h,image_width*(bpp/8),stride[0],stride[1]);
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
264
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
265 return 0;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
266 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
267
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
268 static uint32_t
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
269 query_format(uint32_t format)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
270 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
271 switch(format){
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
272 case IMGFMT_YV12:
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
273 case IMGFMT_RGB|24:
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
274 case IMGFMT_BGR|24:
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
275 return 1;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
276 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
277 return 0;
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
278 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
279
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
280 static void
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
281 uninit(void)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
282 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
283 if(image_data){ free(image_data);image_data=NULL;}
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
284 }
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
285
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
286
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
287 static void check_events(void)
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
288 {
a38decaa04ec png video out renderer initial release
atmosfear
parents:
diff changeset
289 }