~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to gt/gnuavi.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-25 15:47:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080225154712-qvr11ekcea4c9ry8
Tags: 1.1.6-0.1ubuntu1
* Merge from debian-multimedia (LP: #120003), Ubuntu Changes:
 - For ffmpeg-related build-deps, remove cvs from package names.
 - Standards-Version 3.7.3
 - Maintainer Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * gnuavi.c
3
 
 *
4
 
 * Copyright (C) 1998 Rasca, Berlin
5
 
 * EMail: thron@gmx.de
6
 
 *
7
 
 * This library is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU Library General Public
9
 
 * License as published by the Free Software Foundation; either
10
 
 * version 2 of the License, or (at your option) any later version.
11
 
 *
12
 
 * This library is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
 * Library General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU Library General Public
18
 
 * License along with this library; if not, write to the Free Software
19
 
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 
 */
21
 
 
22
 
#include <stdio.h>
23
 
#include <stdlib.h>
24
 
#include "gnuavi.h"
25
 
 
26
 
#ifdef DEBUG
27
 
#define printid(s,x) printf("%s=%c%c%c%c\n",s,\
28
 
                        ((char*)&x)[3],((char*)&x)[2],((char*)&x)[1],((char*)&x)[0])
29
 
#else
30
 
#define printid(s,x)
31
 
#endif
32
 
/*
33
 
 * read 4 byte chars as id into the variable 'n'
34
 
 */
35
 
int
36
 
gv_read_id(gv_u32 *n, FILE *fp)
37
 
{
38
 
        int rc;
39
 
        rc = fread (n, 1, 4, fp);
40
 
#ifdef LSB
41
 
        gv_swap4byte(*n);
42
 
#endif
43
 
        return (rc);
44
 
}
45
 
 
46
 
/*
47
 
 * read 4 byte and swap if needed
48
 
 */
49
 
int
50
 
gv_read4byte(gv_u32 *n, FILE *fp)
51
 
{
52
 
        int rc;
53
 
        rc = fread (n, 1, 4, fp);
54
 
#ifndef LSB
55
 
        gv_swap4byte(*n);
56
 
#endif
57
 
        return (rc);
58
 
}
59
 
 
60
 
/*
61
 
 * read 2 byte and swap if needed
62
 
 */
63
 
int
64
 
gv_read2byte(gv_u16 *n, FILE *fp)
65
 
{
66
 
        int rc;
67
 
        rc = fread (n, 1, 2, fp);
68
 
#ifndef LSB
69
 
        gv_swap2byte(*n);
70
 
#endif
71
 
        return (rc);
72
 
}
73
 
 
74
 
/*
75
 
 */
76
 
int
77
 
gv_read_snd_strf (gv_avi_snd_strf *strf, FILE *fp)
78
 
{
79
 
        int in = 0;
80
 
        in += gv_read_id (&strf->id, fp);
81
 
        in += gv_read4byte (&strf->size, fp);
82
 
        in += gv_read2byte (&strf->format, fp);
83
 
        in += gv_read2byte (&strf->channels, fp);
84
 
        in += gv_read4byte (&strf->rate, fp);
85
 
        in += gv_read4byte (&strf->average_bps, fp);
86
 
        in += gv_read2byte (&strf->blockalign, fp);
87
 
        in += gv_read2byte (&strf->sample_size, fp);
88
 
        printid (" strf id", strf->id);
89
 
#ifdef DEBUG
90
 
        printf (" snd format=%d channels=%d rate=%d sample_size=%d\n",
91
 
                        strf->format, strf->channels, strf->rate, strf->sample_size);
92
 
#endif
93
 
        fseek (fp, strf->size - (in-8), SEEK_CUR);
94
 
        return (strf->size+8);
95
 
}
96
 
 
97
 
/*
98
 
 */
99
 
int
100
 
gv_read_vid_strf (gv_avi_vid_strf *strf, FILE *fp)
101
 
{
102
 
        int in = 0;
103
 
        in += gv_read_id (&strf->id, fp);
104
 
        in += gv_read4byte (&strf->size, fp);
105
 
        in += gv_read4byte (&strf->q_size, fp);
106
 
        in += gv_read4byte (&strf->width, fp);
107
 
        in += gv_read4byte (&strf->height, fp);
108
 
        in += gv_read2byte (&strf->planes, fp);
109
 
        in += gv_read2byte (&strf->bit_cnt, fp);
110
 
        in += gv_read4byte (&strf->comp, fp);
111
 
        in += gv_read4byte (&strf->image_size, fp);
112
 
        in += gv_read4byte (&strf->xpels_meter, fp);
113
 
        in += gv_read4byte (&strf->ypels_meter, fp);
114
 
        in += gv_read4byte (&strf->num_colors, fp);
115
 
        in += gv_read4byte (&strf->imp_colors, fp);
116
 
        printid (" strf id", strf->id);
117
 
#ifdef DEBUG
118
 
        printf (" vid q_size=%d planes=%d bit_cnt=%d image_size=%d comp=%d\n",
119
 
                strf->q_size, strf->planes, strf->bit_cnt, strf->image_size,strf->comp);
120
 
        printf (" --- xpels=%d ypels=%d\n", strf->xpels_meter, strf->ypels_meter);
121
 
#endif
122
 
        fseek (fp, strf->size - (in-8), SEEK_CUR);
123
 
        return (strf->size+8);
124
 
}
125
 
 
126
 
/*
127
 
 */
128
 
int
129
 
gv_read_strh (gv_avi_strh *strh, FILE *fp)
130
 
{
131
 
        int in = 0;
132
 
        in += gv_read_id (&strh->id, fp);
133
 
        in += gv_read4byte (&strh->size, fp);
134
 
        in += gv_read_id (&strh->type, fp);
135
 
        in += gv_read4byte (&strh->fcc_handler, fp);
136
 
        in += gv_read4byte (&strh->priority, fp);
137
 
        in += gv_read4byte (&strh->init_fr, fp);
138
 
        in += gv_read4byte (&strh->scale, fp);
139
 
        in += gv_read4byte (&strh->rate, fp);
140
 
        in += gv_read4byte (&strh->start, fp);
141
 
        in += gv_read4byte (&strh->length, fp);
142
 
        in += gv_read4byte (&strh->buf_size, fp);
143
 
        in += gv_read4byte (&strh->quality, fp);
144
 
        in += gv_read4byte (&strh->sample_size, fp);
145
 
        printid (" strh id", strh->id);
146
 
        printid (" strh type", strh->type);
147
 
#ifdef DEBUG
148
 
        printf ("  scale=%d buf_size=%d smpl size=%d\n",
149
 
                                strh->scale, strh->buf_size, strh->sample_size);
150
 
#endif
151
 
        fseek (fp, strh->size - (in-8), SEEK_CUR);
152
 
        return (strh->size+8);
153
 
}
154
 
 
155
 
/*
156
 
 */
157
 
int
158
 
gv_read_avi_header (gv_avi_hdrl *hdrl, FILE *fp, int size)
159
 
{
160
 
        int in=0, i;
161
 
        gv_u32 streams = 0;
162
 
        gv_avi_vid_strf *vid_strf;
163
 
        gv_avi_snd_strf *snd_strf;
164
 
        gv_u32 list_id, list_size, list_type;
165
 
 
166
 
        in += gv_read_id (&hdrl->avih.id, fp);
167
 
        in += gv_read4byte (&hdrl->avih.size, fp);
168
 
        printid ("avih",hdrl->avih.id);
169
 
#ifdef DEBUG
170
 
        printf ("%d: size=%d (%d)\n",__LINE__,hdrl->avih.size, sizeof(hdrl->avih));
171
 
#endif
172
 
        in += gv_read4byte (&hdrl->avih.us_pf, fp);
173
 
        in += gv_read4byte (&hdrl->avih.bps, fp);
174
 
        in += gv_read4byte (&hdrl->avih.pad_gran, fp);
175
 
        in += gv_read4byte (&hdrl->avih.flags, fp);
176
 
        in += gv_read4byte (&hdrl->avih.frames, fp);
177
 
        in += gv_read4byte (&hdrl->avih.init_fr, fp);
178
 
        in += gv_read4byte (&hdrl->avih.streams, fp);
179
 
        in += gv_read4byte (&hdrl->avih.buf_size, fp);
180
 
        in += gv_read4byte (&hdrl->avih.width, fp);
181
 
        in += gv_read4byte (&hdrl->avih.height, fp);
182
 
        in += gv_read4byte (&hdrl->avih.scale, fp);
183
 
        in += gv_read4byte (&hdrl->avih.rate, fp);
184
 
        in += gv_read4byte (&hdrl->avih.start, fp);
185
 
        in += gv_read4byte (&hdrl->avih.length, fp);
186
 
 
187
 
        if (hdrl->avih.streams > 0) {
188
 
                streams = hdrl->avih.streams;
189
 
                hdrl->str = malloc (sizeof (gv_stream_hdr) * streams);
190
 
                if (!hdrl->str)
191
 
                        return (0);
192
 
        }
193
 
        for (i = 0; i < streams; i++) {
194
 
                in += gv_read_id (&list_id, fp);
195
 
                in += gv_read4byte (&list_size, fp);
196
 
                in += gv_read_id (&list_type, fp);
197
 
                if (list_type != GV_STRL) {
198
 
                        fseek (fp, list_size-4, SEEK_CUR);
199
 
#ifdef DEBUG
200
 
                        printf ("%s: skipping ..\n", __FILE__);
201
 
#endif
202
 
                        continue;
203
 
                }
204
 
                in += gv_read_strh (&hdrl->str[i].strh, fp);
205
 
                switch (hdrl->str[i].strh.type) {
206
 
                        case GV_VIDS:
207
 
                                vid_strf = malloc (sizeof (gv_avi_vid_strf));
208
 
                                hdrl->str[i].strf = vid_strf;
209
 
                                in += gv_read_vid_strf (vid_strf, fp);
210
 
                                break;
211
 
                        case GV_AUDS:
212
 
                                snd_strf = malloc (sizeof (gv_avi_snd_strf));
213
 
                                hdrl->str[i].strf = snd_strf;
214
 
                                in += gv_read_snd_strf (snd_strf, fp);
215
 
                                break;
216
 
                        default:
217
 
                                printf ("oops: file %s, line %d\n", __FILE__, __LINE__);
218
 
                                break;
219
 
                }
220
 
        }
221
 
        fseek (fp, size-(in+4), SEEK_CUR);
222
 
#ifdef DEBUG
223
 
        printf ("%d: size=%d in=%d pos=%ld\n", __LINE__, size, in, ftell(fp));
224
 
#endif
225
 
        return (1);
226
 
}
227
 
 
228
 
/*
229
 
 * read the avi header
230
 
 */
231
 
gv_avi *
232
 
gv_read_header (FILE *fp, FILE *fp_snd)
233
 
{
234
 
        gv_avi *avi;
235
 
        gv_u32 list_id, list_size, list_type;
236
 
 
237
 
        avi = malloc (sizeof (gv_avi));
238
 
        if (!avi)
239
 
                return (NULL);
240
 
 
241
 
        avi->fp = fp;
242
 
        avi->fp_snd = fp_snd;
243
 
        avi->d_pos = 0;
244
 
 
245
 
        gv_read_id (&avi->id, fp);
246
 
        if (avi->id != GV_RIFF)
247
 
                goto hdr_err;
248
 
        gv_read4byte (&avi->size, fp);
249
 
        gv_read_id (&avi->type, fp);
250
 
        if (avi->type != GV_AVI)
251
 
                goto hdr_err;
252
 
 
253
 
again:
254
 
        gv_read_id (&list_id, fp);
255
 
        gv_read4byte (&list_size, fp);
256
 
        gv_read_id (&list_type, fp);
257
 
        printid ("list id", list_id);
258
 
        printid ("list type", list_type);
259
 
 
260
 
        if (list_id != GV_LIST)
261
 
                goto hdr_err;
262
 
        switch (list_type) {
263
 
                case GV_hdrl:
264
 
                        gv_read_avi_header (&avi->hdrl, fp, list_size);
265
 
                        goto again;
266
 
                        break;
267
 
                case GV_movi:
268
 
                        avi->d_pos = ftell (fp);
269
 
                        fseek (fp_snd, avi->d_pos, SEEK_SET);
270
 
                        printf (" d_pos=%ld\n", avi->d_pos);
271
 
                        break;
272
 
                default:
273
 
                        if (feof(fp))
274
 
                                goto hdr_err;
275
 
                        fseek (fp, list_size, SEEK_SET);
276
 
                        break;
277
 
        }
278
 
        return (avi); 
279
 
hdr_err:
280
 
        free (avi);
281
 
        return (NULL);
282
 
}
283
 
 
284
 
 
285
 
/*
286
 
 * convert from rgb555 to rgb565
287
 
 */
288
 
int
289
 
gv_get_frame_15to16 (gv_avi *avi, gv_byte *buf, int pad)
290
 
{
291
 
        gv_u32 atom_id, atom_size;
292
 
        register int in = 0, y, x;
293
 
        register int width = avi->hdrl.avih.width;
294
 
        register int height = avi->hdrl.avih.height;
295
 
        gv_byte *ptr;
296
 
        gv_stream_hdr *str = gv_video_stream (avi, 0);
297
 
        int bytes_per_pixel = ((gv_avi_vid_strf *)str->strf)->bit_cnt;
298
 
        int out_line_size = width * 2;
299
 
        int line_size = width * 2;
300
 
        int image_size = width * height * bytes_per_pixel /8;
301
 
        gv_byte *line;
302
 
        gv_u16 *u16, *rgb;
303
 
 
304
 
m15to16:
305
 
        in  = gv_read_id (&atom_id, avi->fp);
306
 
        in += gv_read4byte (&atom_size, avi->fp);
307
 
        if (in != 8) {/* eof? */
308
 
                return (0);
309
 
        }
310
 
        switch (atom_id) {
311
 
                case GV_FRAM:
312
 
                        line = malloc (line_size);
313
 
                        for (y = 0; y < height; y++) {
314
 
                                ptr = buf+(height - y - 1)*(out_line_size + pad);
315
 
                                if (fread (line, 1, line_size, avi->fp) < line_size) {
316
 
                                        free (line);
317
 
                                        return (0);
318
 
                                }
319
 
                                rgb = (gv_u16 *)line;
320
 
                                u16 = (gv_u16 *)ptr;
321
 
                                for (x = 0; x < width; x++) {
322
 
                                        *u16++ = ((*rgb & 0xFFE0)<<1) | (*rgb & 0x001F);
323
 
                                        rgb ++;
324
 
                                }
325
 
                        }
326
 
                        free (line);
327
 
                        if (atom_size - image_size > 0)
328
 
                                fseek (avi->fp, atom_size - image_size, SEEK_CUR);
329
 
                        return (1);
330
 
                        break;
331
 
                case GV_SMPL:
332
 
                        /* skip sound sample */
333
 
                        fseek (avi->fp, atom_size, SEEK_CUR);
334
 
                        goto m15to16;
335
 
                        break;
336
 
                default:
337
 
                        printf ("oops: id=%d\n", atom_id);
338
 
                        break;
339
 
        } 
340
 
        return (0);
341
 
}
342
 
 
343
 
/*
344
 
 * convert from rgb555 to rgb888
345
 
 */
346
 
int
347
 
gv_get_frame_15to24 (gv_avi *avi, gv_byte *buf, int pad)
348
 
{
349
 
        gv_u32 atom_id, atom_size;
350
 
        register int in = 0, y, x;
351
 
        register int width = avi->hdrl.avih.width;
352
 
        register int height = avi->hdrl.avih.height;
353
 
        int out_line_size = width * 3;
354
 
        int line_size = width * 2;
355
 
        int image_size = line_size * height;
356
 
        gv_byte *line, *ptr;
357
 
        gv_u16 *rgb;
358
 
 
359
 
m15to24:
360
 
        in  = gv_read_id (&atom_id, avi->fp);
361
 
        in += gv_read4byte (&atom_size, avi->fp);
362
 
        if (in != 8) /* eof? */
363
 
                return (0);
364
 
 
365
 
        switch (atom_id) {
366
 
                case GV_FRAM:
367
 
                        line = malloc (line_size);
368
 
                        for (y = 0; y < height; y++) {
369
 
                                ptr = buf+(height - y - 1)*(out_line_size + pad);
370
 
                                if (fread (line, 1, line_size, avi->fp) < line_size) {
371
 
                                        free (line);
372
 
                                        return (0);
373
 
                                }
374
 
                                rgb = (gv_u16 *)line;
375
 
                                for (x = 0; x < width; x++) {
376
 
                                        *ptr++ = ((*rgb) & 0x001F) << 3;
377
 
                                        *ptr++ = ((*rgb) & 0x03E0) >> 2;
378
 
                                        *ptr++ = ((*rgb) & 0x7C00) >> 7;
379
 
                                        rgb++;
380
 
                                }
381
 
                        }
382
 
                        free (line);
383
 
                        if (atom_size - image_size > 0)
384
 
                                fseek (avi->fp, atom_size - image_size, SEEK_CUR);
385
 
                        return (1);
386
 
                        break;
387
 
                case GV_SMPL:
388
 
                        /* skip sound sample */
389
 
                        fseek (avi->fp, atom_size, SEEK_CUR);
390
 
                        goto m15to24;
391
 
                        break;
392
 
                default:
393
 
                        printf ("oops: id=%d\n", atom_id);
394
 
                        break;
395
 
        } 
396
 
        return (0);
397
 
}
398
 
 
399
 
/*
400
 
 * convert to rgb555 or rgb565
401
 
 */
402
 
int
403
 
gv_get_frame_24toX (gv_avi *avi, gv_byte *buf, int pad, int bits)
404
 
{
405
 
        gv_u32 atom_id, atom_size;
406
 
        register int in = 0, y, x;
407
 
        register int width = avi->hdrl.avih.width;
408
 
        register int height = avi->hdrl.avih.height;
409
 
        gv_byte *rgb, *ptr;
410
 
        gv_stream_hdr *str = gv_video_stream (avi, 0);
411
 
        int bytes_per_pixel = ((gv_avi_vid_strf *)str->strf)->bit_cnt;
412
 
        int out_line_size = width * 2;
413
 
        int line_size = width * 3;
414
 
        int image_size = width * height * bytes_per_pixel /8;
415
 
        register int gshift = 0, bshift = 0;
416
 
        gv_byte *line;
417
 
        gv_u16 *u16;
418
 
 
419
 
m24toX:
420
 
        in  = gv_read_id (&atom_id, avi->fp);
421
 
        in += gv_read4byte (&atom_size, avi->fp);
422
 
        if (in != 8) /* eof? */
423
 
                return (0);
424
 
 
425
 
        switch (atom_id) {
426
 
                case GV_FRAM:
427
 
                        line = malloc (line_size);
428
 
                        if (bits == 15) {
429
 
                                gshift = 3;
430
 
                                bshift = 10;
431
 
                        } else {
432
 
                                gshift = 2;
433
 
                                bshift = 11;
434
 
                        }
435
 
                        for (y = 0; y < height; y++) {
436
 
                                ptr = buf+(height - y - 1)*(out_line_size + pad);
437
 
                                if (fread (line, 1, line_size, avi->fp) < line_size) {
438
 
                                        free (line);
439
 
                                        return (0);
440
 
                                }
441
 
                                rgb = line;
442
 
                                u16 = (gv_u16 *)ptr;
443
 
                                for (x = 0; x < width; x++) {
444
 
                                        *u16++ = (rgb[2] >> 3) | ((rgb[1]>>gshift)<<5) |
445
 
                                                                ((rgb[0]>>3)<<bshift);
446
 
                                        rgb += 3;
447
 
                                }
448
 
                        }
449
 
                        free (line);
450
 
                        if (atom_size - image_size > 0)
451
 
                                fseek (avi->fp, atom_size - image_size, SEEK_CUR);
452
 
                        return (1);
453
 
                        break;
454
 
                case GV_SMPL:
455
 
                        /* skip sound sample */
456
 
                        fseek (avi->fp, atom_size, SEEK_CUR);
457
 
                        goto m24toX;
458
 
                        break;
459
 
                default:
460
 
                        printf ("oops: id=%d\n", atom_id);
461
 
                        break;
462
 
        } 
463
 
        return (0);
464
 
}
465
 
 
466
 
/*
467
 
 * returns image in native format
468
 
 */
469
 
int
470
 
gv_get_frame_raw (gv_avi *avi, gv_byte *buf, int pad)
471
 
{
472
 
        gv_u32 atom_id, atom_size;
473
 
        register int in = 0, y, i;
474
 
        register int width = avi->hdrl.avih.width;
475
 
        register int height = avi->hdrl.avih.height;
476
 
        gv_stream_hdr *str = gv_video_stream (avi, 0);
477
 
        int bytes_per_pixel = ((gv_avi_vid_strf *)str->strf)->bit_cnt / 8;
478
 
        int line_size = width * bytes_per_pixel;
479
 
        int image_size = width * height * bytes_per_pixel;
480
 
        gv_byte *ptr, t;
481
 
 
482
 
mraw:
483
 
        in  = gv_read_id (&atom_id, avi->fp);
484
 
        in += gv_read4byte (&atom_size, avi->fp);
485
 
        if (in != 8) /* eof? */
486
 
                return (0);
487
 
 
488
 
        switch (atom_id) {
489
 
                case GV_FRAM:
490
 
#ifdef DEBUG
491
 
                        printf ("%s: size=%d\n", __FILE__, atom_size);
492
 
#endif
493
 
                        for (y = 0; y < height; y++) {
494
 
                                ptr = buf+(height - y - 1)*(line_size + pad);
495
 
                                if (fread (ptr, 1, line_size, avi->fp) < line_size)
496
 
                                        return (0);
497
 
                                if (bytes_per_pixel == 3) {
498
 
                                        for (i = 0; i < line_size; i+=3) {
499
 
                                                t = ptr[i];
500
 
                                                ptr[i] = ptr[i+2];
501
 
                                                ptr[i+2] = t;
502
 
                                        }
503
 
                                }
504
 
                        }
505
 
                        if (atom_size - image_size > 0)
506
 
                                fseek (avi->fp, atom_size - image_size, SEEK_CUR);
507
 
                        return (1);
508
 
                        break;
509
 
                case GV_SMPL:
510
 
                        /* skip sound sample */
511
 
                        fseek (avi->fp, atom_size, SEEK_CUR);
512
 
                        goto mraw;
513
 
                        break;
514
 
                default:
515
 
                        printf ("oops: id=%d\n", atom_id);
516
 
                        break;
517
 
        } 
518
 
        return (0);
519
 
}
520
 
 
521
 
/*
522
 
 */
523
 
gv_stream_hdr *
524
 
gv_video_stream (gv_avi *avi, int num) {
525
 
        int i, vidnum = 0;
526
 
 
527
 
        for (i = 0; i < avi->hdrl.avih.streams; i++) {
528
 
                if (avi->hdrl.str[i].strh.type == GV_VIDS) {
529
 
                        if (vidnum == num)
530
 
                                return (&avi->hdrl.str[i]);
531
 
                        vidnum++;
532
 
                }
533
 
        }
534
 
        return (NULL);
535
 
}
536
 
 
537
 
/*
538
 
 */
539
 
gv_stream_hdr *
540
 
gv_sound_stream (gv_avi *avi, int num) {
541
 
        int i, sndnum = 0;
542
 
 
543
 
        for (i = 0; i < avi->hdrl.avih.streams; i++) {
544
 
                if (avi->hdrl.str[i].strh.type == GV_AUDS) {
545
 
                        if (sndnum == num)
546
 
                                return (&avi->hdrl.str[i]);
547
 
                        sndnum++;
548
 
                }
549
 
        }
550
 
        return (NULL);
551
 
}
552
 
 
553
 
/*
554
 
 */
555
 
void
556
 
gv_reset (gv_avi *avi)
557
 
{
558
 
#ifdef DEBUG
559
 
        printf ("%s: gv_reset() d_pos=%ld\n", __FILE__, avi->d_pos);
560
 
#endif
561
 
        if (avi->d_pos) {
562
 
                fseek (avi->fp, avi->d_pos, SEEK_SET);
563
 
                fseek (avi->fp_snd, avi->d_pos, SEEK_SET);
564
 
        }
565
 
}
566
 
 
567
 
/*
568
 
 */
569
 
void
570
 
gv_skip_frame (gv_avi *avi)
571
 
{
572
 
        int in = 0;
573
 
        gv_u32 atom_id, atom_size;
574
 
 
575
 
#ifdef DEBUG
576
 
        printf ("%s: gv_skip_frame()\n", __FILE__);
577
 
#endif
578
 
        while (1) {
579
 
                in  = gv_read_id (&atom_id, avi->fp);
580
 
                in += gv_read4byte (&atom_size, avi->fp);
581
 
                if (in != 8) /* eof? */
582
 
                        return;
583
 
 
584
 
                switch (atom_id) {
585
 
                        case GV_FRAM:
586
 
                                fseek (avi->fp, atom_size, SEEK_CUR);
587
 
                                return;
588
 
                                break;
589
 
                        default:
590
 
                                fseek (avi->fp, atom_size, SEEK_CUR);
591
 
                                break;
592
 
                }
593
 
        }
594
 
}
595