Revision 177e5460 libavformat/nut.c

View differences:

libavformat/nut.c
462 462
static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size, int calculate_checksum)
463 463
{
464 464
    put_flush_packet(bc);
465
    nut->packet_start[2]+= nut->written_packet_size;
466
    assert(url_ftell(bc) - 8 == nut->packet_start[2]);
465
    nut->packet_start[2]= url_ftell(bc) - 8;
467 466
    nut->written_packet_size = max_size;
468 467
    
469 468
    if(calculate_checksum)
......
475 474
    return 0;
476 475
}
477 476

  
477
/**
478
 *
479
 * must not be called more then once per packet
480
 */
478 481
static int update_packetheader(NUTContext *nut, ByteIOContext *bc, int additional_size, int calculate_checksum){
479 482
    int64_t start= nut->packet_start[2];
480 483
    int64_t cur= url_ftell(bc);
481
    int size= cur - start + additional_size;
484
    int size= cur - start - get_length(nut->written_packet_size)/7 - 8;
482 485
    
483 486
    if(calculate_checksum)
484 487
        size += 4;
......
1276 1279
        case INDEX_STARTCODE:
1277 1280
            get_packetheader(nut, bc, 0);
1278 1281
            assert(nut->packet_start[2] == pos);
1279
            url_fseek(bc, nut->written_packet_size + nut->packet_start[2], SEEK_SET);
1282
            url_fseek(bc, nut->written_packet_size, SEEK_CUR);
1280 1283
            break;
1281 1284
        case INFO_STARTCODE:
1282 1285
            if(decode_info_header(nut)<0)
......
1357 1360
        case INFO_STARTCODE:
1358 1361
            get_packetheader(nut, bc, 0);
1359 1362
            assert(nut->packet_start[2]==pos);
1360
            url_fseek(bc, nut->written_packet_size + pos, SEEK_SET);
1363
            url_fseek(bc, nut->written_packet_size, SEEK_CUR);
1361 1364
            break;
1362 1365
        case KEYFRAME_STARTCODE:
1363 1366
            frame_type=2;

Also available in: Unified diff