comparison img.c @ 885:da1d5db0ce5c libavformat

COSMETICS: Remove all trailing whitespace.
author diego
date Sat, 17 Dec 2005 18:14:38 +0000
parents feca73904e67
children edbe5c3717f9
comparison
equal deleted inserted replaced
884:2ece9c9dd94c 885:da1d5db0ce5c
37 void *ptr; 37 void *ptr;
38 } VideoData; 38 } VideoData;
39 39
40 40
41 /* return -1 if no image found */ 41 /* return -1 if no image found */
42 static int find_image_range(int *pfirst_index, int *plast_index, 42 static int find_image_range(int *pfirst_index, int *plast_index,
43 const char *path) 43 const char *path)
44 { 44 {
45 char buf[1024]; 45 char buf[1024];
46 int range, last_index, range1, first_index; 46 int range, last_index, range1, first_index;
47 47
52 if (url_exist(buf)) 52 if (url_exist(buf))
53 break; 53 break;
54 } 54 }
55 if (first_index == 5) 55 if (first_index == 5)
56 goto fail; 56 goto fail;
57 57
58 /* find the last image */ 58 /* find the last image */
59 last_index = first_index; 59 last_index = first_index;
60 for(;;) { 60 for(;;) {
61 range = 0; 61 range = 0;
62 for(;;) { 62 for(;;) {
63 if (!range) 63 if (!range)
64 range1 = 1; 64 range1 = 1;
65 else 65 else
66 range1 = 2 * range; 66 range1 = 2 * range;
67 if (get_frame_filename(buf, sizeof(buf), path, 67 if (get_frame_filename(buf, sizeof(buf), path,
68 last_index + range1) < 0) 68 last_index + range1) < 0)
69 goto fail; 69 goto fail;
70 if (!url_exist(buf)) 70 if (!url_exist(buf))
71 break; 71 break;
72 range = range1; 72 range = range1;
124 s->img_fmt = ap->image_format; 124 s->img_fmt = ap->image_format;
125 125
126 pstrcpy(s->path, sizeof(s->path), s1->filename); 126 pstrcpy(s->path, sizeof(s->path), s1->filename);
127 s->img_number = 0; 127 s->img_number = 0;
128 s->img_count = 0; 128 s->img_count = 0;
129 129
130 /* find format */ 130 /* find format */
131 if (s1->iformat->flags & AVFMT_NOFILE) 131 if (s1->iformat->flags & AVFMT_NOFILE)
132 s->is_pipe = 0; 132 s->is_pipe = 0;
133 else 133 else
134 s->is_pipe = 1; 134 s->is_pipe = 1;
136 if (!ap || !ap->time_base.num) { 136 if (!ap || !ap->time_base.num) {
137 st->codec->time_base= (AVRational){1,25}; 137 st->codec->time_base= (AVRational){1,25};
138 } else { 138 } else {
139 st->codec->time_base= ap->time_base; 139 st->codec->time_base= ap->time_base;
140 } 140 }
141 141
142 if (!s->is_pipe) { 142 if (!s->is_pipe) {
143 if (find_image_range(&first_index, &last_index, s->path) < 0) 143 if (find_image_range(&first_index, &last_index, s->path) < 0)
144 goto fail; 144 goto fail;
145 s->img_first = first_index; 145 s->img_first = first_index;
146 s->img_last = last_index; 146 s->img_last = last_index;
153 if (url_fopen(f, buf, URL_RDONLY) < 0) 153 if (url_fopen(f, buf, URL_RDONLY) < 0)
154 goto fail; 154 goto fail;
155 } else { 155 } else {
156 f = &s1->pb; 156 f = &s1->pb;
157 } 157 }
158 158
159 ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s); 159 ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s);
160 if (ret < 0) 160 if (ret < 0)
161 goto fail1; 161 goto fail1;
162 162
163 if (!s->is_pipe) { 163 if (!s->is_pipe) {
164 url_fclose(f); 164 url_fclose(f);
165 } else { 165 } else {
166 url_fseek(f, 0, SEEK_SET); 166 url_fseek(f, 0, SEEK_SET);
167 } 167 }
168 168
169 st->codec->codec_type = CODEC_TYPE_VIDEO; 169 st->codec->codec_type = CODEC_TYPE_VIDEO;
170 st->codec->codec_id = CODEC_ID_RAWVIDEO; 170 st->codec->codec_id = CODEC_ID_RAWVIDEO;
171 st->codec->width = s->width; 171 st->codec->width = s->width;
172 st->codec->height = s->height; 172 st->codec->height = s->height;
173 st->codec->pix_fmt = s->pix_fmt; 173 st->codec->pix_fmt = s->pix_fmt;
263 if (!img_fmt) 263 if (!img_fmt)
264 return -1; 264 return -1;
265 265
266 if (s->nb_streams != 1) 266 if (s->nb_streams != 1)
267 return -1; 267 return -1;
268 268
269 st = s->streams[0]; 269 st = s->streams[0];
270 /* we select the first matching format */ 270 /* we select the first matching format */
271 for(i=0;i<PIX_FMT_NB;i++) { 271 for(i=0;i<PIX_FMT_NB;i++) {
272 if (img_fmt->supported_pixel_formats & (1 << i)) 272 if (img_fmt->supported_pixel_formats & (1 << i))
273 break; 273 break;
290 /* find format */ 290 /* find format */
291 if (s->oformat->flags & AVFMT_NOFILE) 291 if (s->oformat->flags & AVFMT_NOFILE)
292 img->is_pipe = 0; 292 img->is_pipe = 0;
293 else 293 else
294 img->is_pipe = 1; 294 img->is_pipe = 1;
295 295
296 return 0; 296 return 0;
297 } 297 }
298 298
299 static int img_write_packet(AVFormatContext *s, AVPacket *pkt) 299 static int img_write_packet(AVFormatContext *s, AVPacket *pkt)
300 { 300 {
306 char filename[1024]; 306 char filename[1024];
307 AVImageInfo info; 307 AVImageInfo info;
308 308
309 width = st->codec->width; 309 width = st->codec->width;
310 height = st->codec->height; 310 height = st->codec->height;
311 311
312 picture = (AVPicture *)pkt->data; 312 picture = (AVPicture *)pkt->data;
313 313
314 if (!img->is_pipe) { 314 if (!img->is_pipe) {
315 if (get_frame_filename(filename, sizeof(filename), 315 if (get_frame_filename(filename, sizeof(filename),
316 img->path, img->img_number) < 0) 316 img->path, img->img_number) < 0)
317 return AVERROR_IO; 317 return AVERROR_IO;
318 pb = &pb1; 318 pb = &pb1;
319 if (url_fopen(pb, filename, URL_WRONLY) < 0) 319 if (url_fopen(pb, filename, URL_WRONLY) < 0)
320 return AVERROR_IO; 320 return AVERROR_IO;
404 av_register_input_format(&image_iformat); 404 av_register_input_format(&image_iformat);
405 av_register_output_format(&image_oformat); 405 av_register_output_format(&image_oformat);
406 406
407 av_register_input_format(&imagepipe_iformat); 407 av_register_input_format(&imagepipe_iformat);
408 av_register_output_format(&imagepipe_oformat); 408 av_register_output_format(&imagepipe_oformat);
409 409
410 return 0; 410 return 0;
411 } 411 }