Revision 91d19d47

View differences:

libavformat/asf.h
82 82

  
83 83
typedef struct {
84 84
    uint32_t seqno;
85
    unsigned int packet_size;
86 85
    int is_streamed;
87 86
    int asfid2avid[128];                 ///< conversion table from asf ID 2 AVStream ID
88 87
    ASFStream streams[128];              ///< it's max number and it's not that big
libavformat/asfdec.c
221 221
            asf->hdr.min_pktsize        = get_le32(pb);
222 222
            asf->hdr.max_pktsize        = get_le32(pb);
223 223
            asf->hdr.max_bitrate        = get_le32(pb);
224
            asf->packet_size = asf->hdr.max_pktsize;
224
            s->packet_size = asf->hdr.max_pktsize;
225 225
        } else if (!guidcmp(&g, &ff_asf_stream_header)) {
226 226
            enum CodecType type;
227 227
            int type_specific_size, sizeX;
......
595 595
    int rsize = 8;
596 596
    int c, d, e, off;
597 597

  
598
    off= (url_ftell(pb) - s->data_offset) % asf->packet_size + 3;
598
    off= (url_ftell(pb) - s->data_offset) % s->packet_size + 3;
599 599

  
600 600
    c=d=e=-1;
601 601
    while(off-- > 0){
......
625 625
    asf->packet_flags    = c;
626 626
    asf->packet_property = d;
627 627

  
628
    DO_2BITS(asf->packet_flags >> 5, packet_length, asf->packet_size);
628
    DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size);
629 629
    DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence ignored
630 630
    DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding length
631 631

  
......
654 654
    if (packet_length < asf->hdr.min_pktsize)
655 655
        padsize += asf->hdr.min_pktsize - packet_length;
656 656
    asf->packet_padsize = padsize;
657
    dprintf(s, "packet: size=%d padsize=%d  left=%d\n", asf->packet_size, asf->packet_padsize, asf->packet_size_left);
657
    dprintf(s, "packet: size=%d padsize=%d  left=%d\n", s->packet_size, asf->packet_padsize, asf->packet_size_left);
658 658
    return 0;
659 659
}
660 660

  
......
835 835

  
836 836
        /* read data */
837 837
        //printf("READ PACKET s:%d  os:%d  o:%d,%d  l:%d   DATA:%p\n",
838
        //       asf->packet_size, asf_st->pkt.size, asf->packet_frag_offset,
838
        //       s->packet_size, asf_st->pkt.size, asf->packet_frag_offset,
839 839
        //       asf_st->frag_offset, asf->packet_frag_size, asf_st->pkt.data);
840 840
        asf->packet_size_left -= asf->packet_frag_size;
841 841
        if (asf->packet_size_left < 0)
......
978 978

  
979 979
static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
980 980
{
981
    ASFContext *asf = s->priv_data;
982 981
    AVPacket pkt1, *pkt = &pkt1;
983 982
    ASFStream *asf_st;
984 983
    int64_t pts;
......
990 989
        start_pos[i]= pos;
991 990
    }
992 991

  
993
    pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset;
992
    pos= (pos+s->packet_size-1-s->data_offset)/s->packet_size*s->packet_size+ s->data_offset;
994 993
    *ppos= pos;
995 994
    url_fseek(s->pb, pos, SEEK_SET);
996 995

  
......
1010 1009

  
1011 1010
            asf_st= s->streams[i]->priv_data;
1012 1011

  
1013
//            assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0);
1012
//            assert((asf_st->packet_pos - s->data_offset) % s->packet_size == 0);
1014 1013
            pos= asf_st->packet_pos;
1015 1014

  
1016 1015
            av_add_index_entry(s->streams[i], pos, pts, pkt->size, pos - start_pos[i] + 1, AVINDEX_KEYFRAME);
......
1049 1048
        for (i=0;i<ict;i++){
1050 1049
            int pktnum=get_le32(s->pb);
1051 1050
            int pktct =get_le16(s->pb);
1052
            int64_t pos      = s->data_offset + asf->packet_size*(int64_t)pktnum;
1051
            int64_t pos      = s->data_offset + s->packet_size*(int64_t)pktnum;
1053 1052
            int64_t index_pts= av_rescale(itime, i, 10000);
1054 1053

  
1055 1054
            av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d\n", pktnum, pktct);
1056
            av_add_index_entry(s->streams[stream_index], pos, index_pts, asf->packet_size, 0, AVINDEX_KEYFRAME);
1055
            av_add_index_entry(s->streams[stream_index], pos, index_pts, s->packet_size, 0, AVINDEX_KEYFRAME);
1057 1056
        }
1058 1057
        asf->index_read= 1;
1059 1058
    }
......
1067 1066
    int64_t pos;
1068 1067
    int index;
1069 1068

  
1070
    if (asf->packet_size <= 0)
1069
    if (s->packet_size <= 0)
1071 1070
        return -1;
1072 1071

  
1073 1072
    /* Try using the protocol's read_seek if available */
libavformat/asfenc.c
321 321
    put_le64(pb, asf->duration); /* duration (in 100ns units) */
322 322
    put_le64(pb, PREROLL_TIME); /* start time stamp */
323 323
    put_le32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */
324
    put_le32(pb, asf->packet_size); /* packet size */
325
    put_le32(pb, asf->packet_size); /* packet size */
324
    put_le32(pb, s->packet_size); /* packet size */
325
    put_le32(pb, s->packet_size); /* packet size */
326 326
    put_le32(pb, bit_rate); /* Nominal data rate in bps */
327 327
    end_header(pb, hpos);
328 328

  
......
514 514
{
515 515
    ASFContext *asf = s->priv_data;
516 516

  
517
    asf->packet_size = PACKET_SIZE;
517
    s->packet_size  = PACKET_SIZE;
518 518
    asf->nb_packets = 0;
519 519

  
520 520
    asf->last_indexed_pts = 0;
......
536 536
    asf->packet_nb_payloads = 0;
537 537
    asf->packet_timestamp_start = -1;
538 538
    asf->packet_timestamp_end = -1;
539
    init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1,
539
    init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
540 540
                  NULL, NULL, NULL, NULL);
541 541

  
542 542
    return 0;
......
612 612
    assert(asf->packet_timestamp_end >= asf->packet_timestamp_start);
613 613

  
614 614
    if (asf->is_streamed) {
615
        put_chunk(s, 0x4424, asf->packet_size, 0);
615
        put_chunk(s, 0x4424, s->packet_size, 0);
616 616
    }
617 617

  
618 618
    packet_hdr_size = put_payload_parsing_info(
......
627 627
    assert(packet_hdr_size <= asf->packet_size_left);
628 628
    memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
629 629

  
630
    put_buffer(s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size);
630
    put_buffer(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
631 631

  
632 632
    put_flush_packet(s->pb);
633 633
    asf->nb_packets++;
634 634
    asf->packet_nb_payloads = 0;
635 635
    asf->packet_timestamp_start = -1;
636 636
    asf->packet_timestamp_end = -1;
637
    init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1,
637
    init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1,
638 638
                  NULL, NULL, NULL, NULL);
639 639
}
640 640

  

Also available in: Unified diff