Revision 684f44d9 libav/mov.c

View differences:

libav/mov.c
169 169
 0: continue to parse next atom
170 170
 -1: error occured, exit
171 171
 */
172
typedef int (*mov_parse_function)(struct MOVParseTableEntry *parse_table,
172
typedef int (*mov_parse_function)(const struct MOVParseTableEntry *parse_table,
173 173
                                  ByteIOContext *pb,
174 174
                                  UINT32 atom_type,
175 175
                                  INT64 atom_offset, /* after the size and type field (and eventually the extended size) */
......
182 182
    mov_parse_function func;
183 183
} MOVParseTableEntry;
184 184

  
185
static int parse_leaf(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
185
static int parse_leaf(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
186 186
{
187 187
#ifdef DEBUG
188 188
    print_atom("leaf", atom_type, atom_offset, atom_size);
......
194 194
}
195 195

  
196 196

  
197
static int parse_default(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
197
static int parse_default(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
198 198
{
199 199
    UINT32 type, foo=0;
200 200
    UINT64 offset, size;
......
233 233
        for(i=0; parse_table[i].type != 0L && parse_table[i].type != type; i++);
234 234
        
235 235
//        printf(" i=%ld\n", i);
236
        if(parse_table[i].type == NULL) { /* skip leaf atoms data */
236
	if (parse_table[i].type == 0) { /* skip leaf atoms data */
237 237
//            url_seek(pb, atom_offset+atom_size, SEEK_SET);
238 238
#ifdef DEBUG
239 239
            print_atom("unknown", type, offset, size);
......
252 252
    return err;
253 253
}
254 254

  
255
static int parse_mvhd(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
255
static int parse_mvhd(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
256 256
{
257 257
    MOVContext *c;
258 258
#ifdef DEBUG
......
287 287
}
288 288

  
289 289
/* this atom should contain all header atoms */
290
static int parse_moov(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
290
static int parse_moov(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
291 291
{
292 292
    int err;
293 293
    MOVContext *c;
......
306 306
}
307 307

  
308 308
/* this atom contains actual media data */
309
static int parse_mdat(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
309
static int parse_mdat(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
310 310
{
311
    int err;
312 311
    MOVContext *c;
313 312
#ifdef DEBUG
314 313
    print_atom("mdat", atom_type, atom_offset, atom_size);
......
326 325
    return 0; /* now go for moov */
327 326
}
328 327

  
329
static int parse_trak(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
328
static int parse_trak(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
330 329
{
331 330
    MOVContext *c;
332 331
    AVStream *st;
......
347 346
    return parse_default(parse_table, pb, atom_type, atom_offset, atom_size, param);
348 347
}
349 348

  
350
static int parse_tkhd(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
349
static int parse_tkhd(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
351 350
{
352 351
    MOVContext *c;
353 352
    AVStream *st;
......
391 390
    return 0;
392 391
}
393 392

  
394
static int parse_hdlr(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
393
static int parse_hdlr(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
395 394
{
396 395
    MOVContext *c;
397 396
    int len;
......
413 412
    type = get_le32(pb); /* component subtype */
414 413

  
415 414
#ifdef DEBUG
416
    printf("ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], ctype);
415
    printf("ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype);
417 416
    printf("stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);
418 417
#endif
419 418
#ifdef DEBUG
......
458 457
#ifdef DEBUG
459 458
        puts("MP4!!!");
460 459
#endif
461
        while(ch=get_byte(pb));
460
	while ((ch = get_byte(pb)));
462 461
    } else {
463 462
        len = get_byte(pb);
464 463
        if(len) {
......
475 474
    return 0;
476 475
}
477 476

  
478
static int parse_stsd(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
477
static int parse_stsd(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
479 478
{
480 479
    MOVContext *c;
481 480
    int entries, size, samp_sz, frames_per_sample;
482
    char *buf;
483 481
    UINT32 format;
484 482
    AVStream *st;
485 483
#ifdef DEBUG
......
518 516
            get_be32(pb); /* data size, always 0 */
519 517
            frames_per_sample = get_be16(pb); /* frame per samples */
520 518
#ifdef DEBUG
521
            printf("frames/samples = %ld\n", frames_per_sample);
519
	    printf("frames/samples = %d\n", frames_per_sample);
522 520
#endif
523 521
            url_fskip(pb, 32); /* codec name */
524 522

  
......
590 588
    return 0;
591 589
}
592 590

  
593
static int parse_stco(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
591
static int parse_stco(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
594 592
{
595 593
    MOVContext *c;
596 594
    int entries, i;
......
624 622
    return 0;
625 623
}
626 624

  
627
static int parse_stsc(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
625
static int parse_stsc(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
628 626
{
629 627
    MOVContext *c;
630 628
    int entries, i;
......
654 652
    return 0;
655 653
}
656 654

  
657
static int parse_stsz(MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
655
static int parse_stsz(const MOVParseTableEntry *parse_table, ByteIOContext *pb, UINT32 atom_type, INT64 atom_offset, INT64 atom_size, void *param)
658 656
{
659 657
    MOVContext *c;
660 658
    int entries, i;
......
771 769
{
772 770
    MOVContext *mov;
773 771
    ByteIOContext *pb = &s->pb;
774
    UINT32 tag, tag1;
775
    int i, j, nb, bps, err;
772
    int i, j, nb, err;
776 773
    INT64 size;
777
    AVStream *st;
778 774

  
779 775
    mov = malloc(sizeof(MOVContext));
780 776
    if (!mov)
......
791 787
        size = 0x7FFFFFFFFFFFFFFF;
792 788

  
793 789
#ifdef DEBUG
794
    printf("filesz=%ld\n", size);
790
    printf("filesz=%Ld\n", size);
795 791
#endif
796 792

  
797 793
    /* check MOV header */
......
801 797
        exit(1);
802 798
    }
803 799
#ifdef DEBUG
804
    printf("on_parse_exit_offset=%ld\n", url_ftell(pb));
800
    printf("on_parse_exit_offset=%d\n", (int) url_ftell(pb));
805 801
#endif
806 802
    /* some cleanup : make sure we are on the mdat atom */
807 803
    if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset))
......
810 806
    mov->next_chunk_offset = mov->mdat_offset; /* initialise reading */
811 807

  
812 808
#ifdef DEBUG
813
    printf("mdat_reset_offset=%ld\n", url_ftell(pb));
809
    printf("mdat_reset_offset=%d\n", (int) url_ftell(pb));
814 810
#endif
815 811

  
816 812
#ifdef DEBUG
817
    printf("streams= %ld\n", s->nb_streams);
813
    printf("streams= %d\n", s->nb_streams);
818 814
#endif
819 815
    mov->total_streams = nb = s->nb_streams;
820 816
    
......
836 832
    }
837 833
#endif
838 834
#ifdef DEBUG
839
    printf("real streams= %ld\n", s->nb_streams);
835
    printf("real streams= %d\n", s->nb_streams);
840 836
#endif
841 837
    return 0;
842 838
}
......
847 843
{
848 844
    MOVContext *mov = s->priv_data;
849 845
    INT64 offset = 0x0FFFFFFFFFFFFFFF;
850
    int i, j;
846
    int i;
851 847
    int st_id = 0, size;
852 848
    size = 0x0FFFFFFF;
853 849
    

Also available in: Unified diff