~ubuntu-branches/ubuntu/edgy/gstreamer0.10-ffmpeg/edgy

« back to all changes in this revision

Viewing changes to gst-libs/ext/ffmpeg/libavformat/img2.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-04-01 16:13:43 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20060401161343-n621cgjlujio0otg
Tags: upstream-0.10.1
Import upstream version 0.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 * You should have received a copy of the GNU Lesser General Public
17
17
 * License along with this library; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
19
 */
20
20
#include "avformat.h"
21
21
 
51
51
    { CODEC_ID_MPEG4     , "mpg4-img"},
52
52
    { CODEC_ID_FFV1      , "ffv1-img"},
53
53
    { CODEC_ID_RAWVIDEO  , "y"},
 
54
    { CODEC_ID_BMP       , "bmp"},
54
55
    {0, NULL}
55
56
};
56
57
 
98
99
}
99
100
 
100
101
/* return -1 if no image found */
101
 
static int find_image_range(int *pfirst_index, int *plast_index, 
 
102
static int find_image_range(int *pfirst_index, int *plast_index,
102
103
                            const char *path)
103
104
{
104
105
    char buf[1024];
107
108
    /* find the first image */
108
109
    for(first_index = 0; first_index < 5; first_index++) {
109
110
        if (get_frame_filename(buf, sizeof(buf), path, first_index) < 0){
110
 
            *pfirst_index = 
 
111
            *pfirst_index =
111
112
            *plast_index = 1;
112
113
            return 0;
113
114
        }
116
117
    }
117
118
    if (first_index == 5)
118
119
        goto fail;
119
 
    
 
120
 
120
121
    /* find the last image */
121
122
    last_index = first_index;
122
123
    for(;;) {
126
127
                range1 = 1;
127
128
            else
128
129
                range1 = 2 * range;
129
 
            if (get_frame_filename(buf, sizeof(buf), path, 
 
130
            if (get_frame_filename(buf, sizeof(buf), path,
130
131
                                   last_index + range1) < 0)
131
132
                goto fail;
132
133
            if (!url_exist(buf))
177
178
    pstrcpy(s->path, sizeof(s->path), s1->filename);
178
179
    s->img_number = 0;
179
180
    s->img_count = 0;
180
 
    
 
181
 
181
182
    /* find format */
182
183
    if (s1->iformat->flags & AVFMT_NOFILE)
183
184
        s->is_pipe = 0;
185
186
        s->is_pipe = 1;
186
187
        st->need_parsing= 1;
187
188
    }
188
 
        
 
189
 
189
190
    if (!ap || !ap->time_base.num) {
190
191
        av_set_pts_info(st, 60, 1, 25);
191
192
    } else {
192
193
        av_set_pts_info(st, 60, ap->time_base.num, ap->time_base.den);
193
194
    }
194
 
    
 
195
 
195
196
    if(ap && ap->width && ap->height){
196
197
        st->codec->width = ap->width;
197
198
        st->codec->height= ap->height;
198
199
    }
199
 
    
 
200
 
200
201
    if (!s->is_pipe) {
201
202
        if (find_image_range(&first_index, &last_index, s->path) < 0)
202
203
            return AVERROR_IO;
207
208
        st->start_time = 0;
208
209
        st->duration = last_index - first_index + 1;
209
210
    }
210
 
    
 
211
 
211
212
    if(ap->video_codec_id){
212
213
        st->codec->codec_type = CODEC_TYPE_VIDEO;
213
214
        st->codec->codec_id = ap->video_codec_id;
245
246
            if (url_fopen(f[i], filename, URL_RDONLY) < 0)
246
247
                return AVERROR_IO;
247
248
            size[i]= url_fsize(f[i]);
248
 
            
 
249
 
249
250
            if(codec->codec_id != CODEC_ID_RAWVIDEO)
250
251
                break;
251
252
            filename[ strlen(filename) - 1 ]= 'U' + i;
252
253
        }
253
 
        
 
254
 
254
255
        if(codec->codec_id == CODEC_ID_RAWVIDEO && !codec->width)
255
256
            infer_size(&codec->width, &codec->height, size[0]);
256
257
    } else {
290
291
    return 0;
291
292
}
292
293
 
 
294
#ifdef CONFIG_MUXERS
293
295
/******************************************************/
294
296
/* image output */
295
297
 
305
307
        img->is_pipe = 0;
306
308
    else
307
309
        img->is_pipe = 1;
308
 
        
 
310
 
309
311
    return 0;
310
312
}
311
313
 
318
320
    int i;
319
321
 
320
322
    if (!img->is_pipe) {
321
 
        if (get_frame_filename(filename, sizeof(filename), 
 
323
        if (get_frame_filename(filename, sizeof(filename),
322
324
                               img->path, img->img_number) < 0 && img->img_number>1)
323
325
            return AVERROR_IO;
324
326
        for(i=0; i<3; i++){
325
327
            if (url_fopen(pb[i], filename, URL_WRONLY) < 0)
326
328
                return AVERROR_IO;
327
 
        
 
329
 
328
330
            if(codec->codec_id != CODEC_ID_RAWVIDEO)
329
331
                break;
330
332
            filename[ strlen(filename) - 1 ]= 'U' + i;
332
334
    } else {
333
335
        pb[0] = &s->pb;
334
336
    }
335
 
    
 
337
 
336
338
    if(codec->codec_id == CODEC_ID_RAWVIDEO){
337
339
        int ysize = codec->width * codec->height;
338
340
        put_buffer(pb[0], pkt->data        , ysize);
359
361
    return 0;
360
362
}
361
363
 
 
364
#endif /* CONFIG_MUXERS */
 
365
 
362
366
/* input */
363
367
 
364
368
static AVInputFormat image2_iformat = {
386
390
};
387
391
 
388
392
 
 
393
#ifdef CONFIG_MUXERS
389
394
/* output */
390
395
 
391
396
static AVOutputFormat image2_oformat = {
414
419
    img_write_packet,
415
420
    img_write_trailer,
416
421
};
 
422
#endif /* CONFIG_MUXERS */
417
423
 
418
424
int img2_init(void)
419
425
{
420
426
    av_register_input_format(&image2_iformat);
 
427
    av_register_input_format(&image2pipe_iformat);
 
428
 
 
429
#ifdef CONFIG_MUXERS
421
430
    av_register_output_format(&image2_oformat);
422
 
 
423
 
    av_register_input_format(&image2pipe_iformat);
424
431
    av_register_output_format(&image2pipe_oformat);
425
 
    
 
432
#endif
 
433
 
426
434
    return 0;
427
435
}