| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Image format | 2  * Image format | 
| 3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | 3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | 
| 4  * Copyright (c) 2004 Michael Niedermayer | 4  * Copyright (c) 2004 Michael Niedermayer | 
| 5  * | 5  * | 
| 6  * This file is part of FFmpeg. | 6  * This file is part of FFmpeg. | 
| 7  * | 7  * | 
| 8  * FFmpeg is free software; you can redistribute it and/or | 8  * FFmpeg is free software; you can redistribute it and/or | 
| 9  * modify it under the terms of the GNU Lesser General Public | 9  * modify it under the terms of the GNU Lesser General Public | 
| 10  * License as published by the Free Software Foundation; either | 10  * License as published by the Free Software Foundation; either | 
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 164         last_index += range; | 164         last_index += range; | 
| 165     } | 165     } | 
| 166     *pfirst_index = first_index; | 166     *pfirst_index = first_index; | 
| 167     *plast_index = last_index; | 167     *plast_index = last_index; | 
| 168     return 0; | 168     return 0; | 
| 169  fail: | 169  fail: | 
| 170     return -1; | 170     return -1; | 
| 171 } | 171 } | 
| 172 | 172 | 
| 173 | 173 | 
| 174 static int image_probe(AVProbeData *p) | 174 static int read_probe(AVProbeData *p) | 
| 175 { | 175 { | 
| 176     if (p->filename && av_str2id(img_tags, p->filename)) { | 176     if (p->filename && av_str2id(img_tags, p->filename)) { | 
| 177         if (av_filename_number_test(p->filename)) | 177         if (av_filename_number_test(p->filename)) | 
| 178             return AVPROBE_SCORE_MAX; | 178             return AVPROBE_SCORE_MAX; | 
| 179         else | 179         else | 
| 180             return AVPROBE_SCORE_MAX/2; | 180             return AVPROBE_SCORE_MAX/2; | 
| 181     } | 181     } | 
| 182     return 0; | 182     return 0; | 
| 183 } | 183 } | 
| 184 | 184 | 
| 185 enum CodecID av_guess_image2_codec(const char *filename){ | 185 enum CodecID av_guess_image2_codec(const char *filename){ | 
| 186     return av_str2id(img_tags, filename); | 186     return av_str2id(img_tags, filename); | 
| 187 } | 187 } | 
| 188 | 188 | 
| 189 static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) | 189 static int read_header(AVFormatContext *s1, AVFormatParameters *ap) | 
| 190 { | 190 { | 
| 191     VideoData *s = s1->priv_data; | 191     VideoData *s = s1->priv_data; | 
| 192     int first_index, last_index; | 192     int first_index, last_index; | 
| 193     AVStream *st; | 193     AVStream *st; | 
| 194 | 194 | 
| 195     s1->ctx_flags |= AVFMTCTX_NOHEADER; | 195     s1->ctx_flags |= AVFMTCTX_NOHEADER; | 
| 196 | 196 | 
| 197     st = av_new_stream(s1, 0); | 197     st = av_new_stream(s1, 0); | 
| 198     if (!st) { | 198     if (!st) { | 
| 199         return AVERROR(ENOMEM); | 199         return AVERROR(ENOMEM); | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 242     }else{ | 242     }else{ | 
| 243         st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | 243         st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | 
| 244         st->codec->codec_id = av_str2id(img_tags, s->path); | 244         st->codec->codec_id = av_str2id(img_tags, s->path); | 
| 245     } | 245     } | 
| 246     if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NON
     E) | 246     if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NON
     E) | 
| 247         st->codec->pix_fmt = ap->pix_fmt; | 247         st->codec->pix_fmt = ap->pix_fmt; | 
| 248 | 248 | 
| 249     return 0; | 249     return 0; | 
| 250 } | 250 } | 
| 251 | 251 | 
| 252 static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) | 252 static int read_packet(AVFormatContext *s1, AVPacket *pkt) | 
| 253 { | 253 { | 
| 254     VideoData *s = s1->priv_data; | 254     VideoData *s = s1->priv_data; | 
| 255     char filename[1024]; | 255     char filename[1024]; | 
| 256     int i; | 256     int i; | 
| 257     int size[3]={0}, ret[3]={0}; | 257     int size[3]={0}, ret[3]={0}; | 
| 258     ByteIOContext *f[3]; | 258     ByteIOContext *f[3]; | 
| 259     AVCodecContext *codec= s1->streams[0]->codec; | 259     AVCodecContext *codec= s1->streams[0]->codec; | 
| 260 | 260 | 
| 261     if (!s->is_pipe) { | 261     if (!s->is_pipe) { | 
| 262         /* loop over input */ | 262         /* loop over input */ | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 313         s->img_count++; | 313         s->img_count++; | 
| 314         s->img_number++; | 314         s->img_number++; | 
| 315         return 0; | 315         return 0; | 
| 316     } | 316     } | 
| 317 } | 317 } | 
| 318 | 318 | 
| 319 #if CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER | 319 #if CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER | 
| 320 /******************************************************/ | 320 /******************************************************/ | 
| 321 /* image output */ | 321 /* image output */ | 
| 322 | 322 | 
| 323 static int img_write_header(AVFormatContext *s) | 323 static int write_header(AVFormatContext *s) | 
| 324 { | 324 { | 
| 325     VideoData *img = s->priv_data; | 325     VideoData *img = s->priv_data; | 
| 326 | 326 | 
| 327     img->img_number = 1; | 327     img->img_number = 1; | 
| 328     av_strlcpy(img->path, s->filename, sizeof(img->path)); | 328     av_strlcpy(img->path, s->filename, sizeof(img->path)); | 
| 329 | 329 | 
| 330     /* find format */ | 330     /* find format */ | 
| 331     if (s->oformat->flags & AVFMT_NOFILE) | 331     if (s->oformat->flags & AVFMT_NOFILE) | 
| 332         img->is_pipe = 0; | 332         img->is_pipe = 0; | 
| 333     else | 333     else | 
| 334         img->is_pipe = 1; | 334         img->is_pipe = 1; | 
| 335 | 335 | 
| 336     return 0; | 336     return 0; | 
| 337 } | 337 } | 
| 338 | 338 | 
| 339 static int img_write_packet(AVFormatContext *s, AVPacket *pkt) | 339 static int write_packet(AVFormatContext *s, AVPacket *pkt) | 
| 340 { | 340 { | 
| 341     VideoData *img = s->priv_data; | 341     VideoData *img = s->priv_data; | 
| 342     ByteIOContext *pb[3]; | 342     ByteIOContext *pb[3]; | 
| 343     char filename[1024]; | 343     char filename[1024]; | 
| 344     AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec; | 344     AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec; | 
| 345     int i; | 345     int i; | 
| 346 | 346 | 
| 347     if (!img->is_pipe) { | 347     if (!img->is_pipe) { | 
| 348         if (av_get_frame_filename(filename, sizeof(filename), | 348         if (av_get_frame_filename(filename, sizeof(filename), | 
| 349                                   img->path, img->img_number) < 0 && img->img_nu
     mber>1) { | 349                                   img->path, img->img_number) < 0 && img->img_nu
     mber>1) { | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 406 | 406 | 
| 407     img->img_number++; | 407     img->img_number++; | 
| 408     return 0; | 408     return 0; | 
| 409 } | 409 } | 
| 410 | 410 | 
| 411 #endif /* CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER */ | 411 #endif /* CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER */ | 
| 412 | 412 | 
| 413 /* input */ | 413 /* input */ | 
| 414 #if CONFIG_IMAGE2_DEMUXER | 414 #if CONFIG_IMAGE2_DEMUXER | 
| 415 AVInputFormat image2_demuxer = { | 415 AVInputFormat image2_demuxer = { | 
| 416     "image2", | 416     .name           = "image2", | 
| 417     NULL_IF_CONFIG_SMALL("image2 sequence"), | 417     .long_name      = NULL_IF_CONFIG_SMALL("image2 sequence"), | 
| 418     sizeof(VideoData), | 418     .priv_data_size = sizeof(VideoData), | 
| 419     image_probe, | 419     .read_probe     = read_probe, | 
| 420     img_read_header, | 420     .read_header    = read_header, | 
| 421     img_read_packet, | 421     .read_packet    = read_packet, | 
| 422     NULL, | 422     .flags          = AVFMT_NOFILE, | 
| 423     NULL, |  | 
| 424     NULL, |  | 
| 425     AVFMT_NOFILE, |  | 
| 426 }; | 423 }; | 
| 427 #endif | 424 #endif | 
| 428 #if CONFIG_IMAGE2PIPE_DEMUXER | 425 #if CONFIG_IMAGE2PIPE_DEMUXER | 
| 429 AVInputFormat image2pipe_demuxer = { | 426 AVInputFormat image2pipe_demuxer = { | 
| 430     "image2pipe", | 427     .name           = "image2pipe", | 
| 431     NULL_IF_CONFIG_SMALL("piped image2 sequence"), | 428     .long_name      = NULL_IF_CONFIG_SMALL("piped image2 sequence"), | 
| 432     sizeof(VideoData), | 429     .priv_data_size = sizeof(VideoData), | 
| 433     NULL, /* no probe */ | 430     .read_header    = read_header, | 
| 434     img_read_header, | 431     .read_packet    = read_packet, | 
| 435     img_read_packet, |  | 
| 436 }; | 432 }; | 
| 437 #endif | 433 #endif | 
| 438 | 434 | 
| 439 /* output */ | 435 /* output */ | 
| 440 #if CONFIG_IMAGE2_MUXER | 436 #if CONFIG_IMAGE2_MUXER | 
| 441 AVOutputFormat image2_muxer = { | 437 AVOutputFormat image2_muxer = { | 
| 442     "image2", | 438     .name           = "image2", | 
| 443     NULL_IF_CONFIG_SMALL("image2 sequence"), | 439     .long_name      = NULL_IF_CONFIG_SMALL("image2 sequence"), | 
| 444     "", | 440     .extensions     = "bmp,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png," | 
| 445     "bmp,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,ppm,sgi,tga,tif,tiff,jp2", | 441                       "ppm,sgi,tga,tif,tiff,jp2", | 
| 446     sizeof(VideoData), | 442     .priv_data_size = sizeof(VideoData), | 
| 447     CODEC_ID_NONE, | 443     .video_codec    = CODEC_ID_MJPEG, | 
| 448     CODEC_ID_MJPEG, | 444     .write_header   = write_header, | 
| 449     img_write_header, | 445     .write_packet   = write_packet, | 
| 450     img_write_packet, | 446     .flags          = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE | 
| 451     NULL, |  | 
| 452     .flags= AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE |  | 
| 453 }; | 447 }; | 
| 454 #endif | 448 #endif | 
| 455 #if CONFIG_IMAGE2PIPE_MUXER | 449 #if CONFIG_IMAGE2PIPE_MUXER | 
| 456 AVOutputFormat image2pipe_muxer = { | 450 AVOutputFormat image2pipe_muxer = { | 
| 457     "image2pipe", | 451     .name           = "image2pipe", | 
| 458     NULL_IF_CONFIG_SMALL("piped image2 sequence"), | 452     .long_name      = NULL_IF_CONFIG_SMALL("piped image2 sequence"), | 
| 459     "", | 453     .priv_data_size = sizeof(VideoData), | 
| 460     "", | 454     .video_codec    = CODEC_ID_MJPEG, | 
| 461     sizeof(VideoData), | 455     .write_header   = write_header, | 
| 462     CODEC_ID_NONE, | 456     .write_packet   = write_packet, | 
| 463     CODEC_ID_MJPEG, | 457     .flags          = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | 
| 464     img_write_header, |  | 
| 465     img_write_packet, |  | 
| 466     .flags= AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS |  | 
| 467 }; | 458 }; | 
| 468 #endif | 459 #endif | 
| OLD | NEW | 
|---|