Revision 9ed83b0a libavformat/mov.c

View differences:

libavformat/mov.c
50 50
 */
51 51

  
52 52
//#define DEBUG
53
#ifdef DEBUG
54
#include <stdio.h>
55
#include <fcntl.h>
56
#endif
53 57

  
54 58
/* allows chunk splitting - should work now... */
55 59
/* in case you can't read a file, try commenting */
......
302 306

  
303 307
    a.offset = atom.offset;
304 308

  
305
    if(atom.size < 0)
306
        atom.size = 0x0FFFFFFFFFFFFFFF;
309
    if (atom.size < 0)
310
	atom.size = 0x7fffffffffffffffLL;
307 311
    while(((total_size + 8) < atom.size) && !url_feof(pb) && !err) {
308 312
	a.size = atom.size;
309 313
	a.type=0L;
......
447 451
        while(get_byte(pb) && (++len < (atom.size - 24)));
448 452
    } else {
449 453
        /* .mov: PASCAL string */
454
#ifdef DEBUG
455
        char* buf;
456
#endif
450 457
        len = get_byte(pb);
451 458
#ifdef DEBUG
452 459
	buf = (uint8_t*) av_malloc(len+1);
......
631 638
    return 0;
632 639
}
633 640

  
641
static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
642
{
643
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
644

  
645
    // currently SVQ3 decoder expect full STSD header - so let's fake it
646
    // this should be fixed and just SMI header should be passed
647
    av_free(st->codec.extradata);
648
    st->codec.extradata_size = 0x5a + atom.size;
649
    st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size);
650

  
651
    if (st->codec.extradata) {
652
        int i;
653
	strcpy(st->codec.extradata, "SVQ3"); // fake
654
	get_buffer(pb, st->codec.extradata + 0x5a, atom.size);
655
	//printf("Reading SMI %Ld  %s\n", atom.size, (char*)st->codec.extradata + 0x5a);
656
    } else
657
	url_fskip(pb, atom.size);
658

  
659
    return 0;
660
}
634 661

  
635 662
static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
636 663
{
......
1092 1119
    atom.type = MKTAG( 'm', 'o', 'o', 'v' );
1093 1120
    atom.offset = 0;
1094 1121
    atom.size = moov_len;
1122
#ifdef DEBUG
1123
    { int fd = open("/tmp/uncompheader.mov", O_WRONLY | O_CREAT); write(fd, moov_data, moov_len); close(fd); }
1124
#endif
1095 1125
    ret = mov_read_default(c, &ctx, atom);
1096 1126
    av_free(moov_data);
1097 1127
    av_free(cmov_data);
1128

  
1098 1129
    return ret;
1099 1130
}
1100 1131
#endif
......
1130 1161
{ MKTAG( 's', 'd', 'h', 'd' ), mov_read_default },
1131 1162
{ MKTAG( 's', 'k', 'i', 'p' ), mov_read_default },
1132 1163
{ MKTAG( 's', 'm', 'h', 'd' ), mov_read_leaf }, /* sound media info header */
1164
{ MKTAG( 'S', 'M', 'I', ' ' ), mov_read_smi }, /* Sorrenson extension ??? */
1133 1165
{ MKTAG( 's', 't', 'b', 'l' ), mov_read_default },
1134 1166
{ MKTAG( 's', 't', 'c', 'o' ), mov_read_stco },
1135 1167
{ MKTAG( 's', 't', 'd', 'p' ), mov_read_default },
......
1248 1280
    if(!url_is_streamed(pb)) /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */
1249 1281
	atom.size = url_filesize(url_fileno(pb));
1250 1282
    else
1251
        atom.size = 0x7FFFFFFFFFFFFFFF;
1283
	atom.size = 0x7FFFFFFFFFFFFFFFLL;
1252 1284

  
1253 1285
#ifdef DEBUG
1254 1286
    printf("filesz=%Ld\n", atom.size);
......
1307 1339
{
1308 1340
    MOVContext *mov = (MOVContext *) s->priv_data;
1309 1341
    MOVStreamContext *sc;
1310
    int64_t offset = 0x0FFFFFFFFFFFFFFF;
1342
    int64_t offset = 0x0FFFFFFFFFFFFFFFLL;
1311 1343
    int i;
1312 1344
    int size;
1313 1345
    size = 0x0FFFFFFF;
......
1347 1379
	    //printf("SELETED  %Ld  i:%d\n", offset, i);
1348 1380
        }
1349 1381
    }
1350
    if (!sc || offset==0x0FFFFFFFFFFFFFFF)
1382
    if (!sc || offset==0x0FFFFFFFFFFFFFFFLL)
1351 1383
	return -1;
1352 1384

  
1353 1385
    sc->next_chunk++;
......
1361 1393
    if(!sc->is_ff_stream) {
1362 1394
        url_fskip(&s->pb, (offset - mov->next_chunk_offset));
1363 1395
        mov->next_chunk_offset = offset;
1364
        offset = 0x0FFFFFFFFFFFFFFF;
1396
	offset = 0x0FFFFFFFFFFFFFFFLL;
1365 1397
        goto again;
1366 1398
    }
1367 1399

  

Also available in: Unified diff