Revision a2704c97 libavformat/matroskaenc.c

View differences:

libavformat/matroskaenc.c
203 203
 */
204 204
static void put_ebml_void(AVIOContext *pb, uint64_t size)
205 205
{
206
    int64_t currentpos = url_ftell(pb);
206
    int64_t currentpos = avio_tell(pb);
207 207

  
208 208
    assert(size >= 2);
209 209

  
......
215 215
        put_ebml_num(pb, size-1, 0);
216 216
    else
217 217
        put_ebml_num(pb, size-9, 8);
218
    while(url_ftell(pb) < currentpos + size)
218
    while(avio_tell(pb) < currentpos + size)
219 219
        avio_w8(pb, 0);
220 220
}
221 221

  
......
224 224
    int bytes = expectedsize ? ebml_num_size(expectedsize) : 8;
225 225
    put_ebml_id(pb, elementid);
226 226
    put_ebml_size_unknown(pb, bytes);
227
    return (ebml_master){ url_ftell(pb), bytes };
227
    return (ebml_master){ avio_tell(pb), bytes };
228 228
}
229 229

  
230 230
static void end_ebml_master(AVIOContext *pb, ebml_master master)
231 231
{
232
    int64_t pos = url_ftell(pb);
232
    int64_t pos = avio_tell(pb);
233 233

  
234 234
    if (avio_seek(pb, master.pos - master.sizebytes, SEEK_SET) < 0)
235 235
        return;
......
265 265
    new_seekhead->segment_offset = segment_offset;
266 266

  
267 267
    if (numelements > 0) {
268
        new_seekhead->filepos = url_ftell(pb);
268
        new_seekhead->filepos = avio_tell(pb);
269 269
        // 21 bytes max for a seek entry, 10 bytes max for the SeekHead ID
270 270
        // and size, and 3 bytes to guarantee that an EBML void element
271 271
        // will fit afterwards
......
310 310
    int64_t currentpos;
311 311
    int i;
312 312

  
313
    currentpos = url_ftell(pb);
313
    currentpos = avio_tell(pb);
314 314

  
315 315
    if (seekhead->reserved_size > 0)
316 316
        if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0)
......
332 332
    end_ebml_master(pb, metaseek);
333 333

  
334 334
    if (seekhead->reserved_size > 0) {
335
        uint64_t remaining = seekhead->filepos + seekhead->reserved_size - url_ftell(pb);
335
        uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
336 336
        put_ebml_void(pb, remaining);
337 337
        avio_seek(pb, currentpos, SEEK_SET);
338 338

  
......
379 379
    int64_t currentpos;
380 380
    int i, j;
381 381

  
382
    currentpos = url_ftell(pb);
382
    currentpos = avio_tell(pb);
383 383
    cues_element = start_ebml_master(pb, MATROSKA_ID_CUES, 0);
384 384

  
385 385
    for (i = 0; i < cues->num_entries; i++) {
......
526 526
    ebml_master tracks;
527 527
    int i, j, ret;
528 528

  
529
    ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, url_ftell(pb));
529
    ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb));
530 530
    if (ret < 0) return ret;
531 531

  
532 532
    tracks = start_ebml_master(pb, MATROSKA_ID_TRACKS, 0);
......
658 658
    if (!s->nb_chapters)
659 659
        return 0;
660 660

  
661
    ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CHAPTERS, url_ftell(pb));
661
    ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CHAPTERS, avio_tell(pb));
662 662
    if (ret < 0) return ret;
663 663

  
664 664
    chapters     = start_ebml_master(pb, MATROSKA_ID_CHAPTERS    , 0);
......
730 730
    int ret;
731 731

  
732 732
    if (!tags->pos) {
733
        ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TAGS, url_ftell(s->pb));
733
        ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TAGS, avio_tell(s->pb));
734 734
        if (ret < 0) return ret;
735 735

  
736 736
        *tags = start_ebml_master(s->pb, MATROSKA_ID_TAGS, 0);
......
813 813
    end_ebml_master(pb, ebml_header);
814 814

  
815 815
    mkv->segment = start_ebml_master(pb, MATROSKA_ID_SEGMENT, 0);
816
    mkv->segment_offset = url_ftell(pb);
816
    mkv->segment_offset = avio_tell(pb);
817 817

  
818 818
    // we write 2 seek heads - one at the end of the file to point to each
819 819
    // cluster, and one at the beginning to point to all other level one
......
824 824
    if (!mkv->main_seekhead)
825 825
        return AVERROR(ENOMEM);
826 826

  
827
    ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_INFO, url_ftell(pb));
827
    ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_INFO, avio_tell(pb));
828 828
    if (ret < 0) return ret;
829 829

  
830 830
    segment_info = start_ebml_master(pb, MATROSKA_ID_INFO, 0);
......
847 847

  
848 848
    // reserve space for the duration
849 849
    mkv->duration = 0;
850
    mkv->duration_offset = url_ftell(pb);
850
    mkv->duration_offset = avio_tell(pb);
851 851
    put_ebml_void(pb, 11);                  // assumes double-precision float to be written
852 852
    end_ebml_master(pb, segment_info);
853 853

  
......
928 928

  
929 929
        av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, "
930 930
               "pts %" PRId64 ", duration %d\n",
931
               url_ftell(pb), size, pkt->pts, duration);
931
               avio_tell(pb), size, pkt->pts, duration);
932 932
        blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(size));
933 933
        put_ebml_id(pb, MATROSKA_ID_BLOCK);
934 934
        put_ebml_num(pb, size+4, 0);
......
957 957

  
958 958
    av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, "
959 959
           "pts %" PRId64 ", dts %" PRId64 ", duration %d, flags %d\n",
960
           url_ftell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration, flags);
960
           avio_tell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration, flags);
961 961
    if (codec->codec_id == CODEC_ID_H264 && codec->extradata_size > 0 &&
962 962
        (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1))
963 963
        ff_avc_parse_nal_units_buf(pkt->data, &data, &size);
......
1045 1045
    }
1046 1046

  
1047 1047
    if (!mkv->cluster_pos) {
1048
        mkv->cluster_pos = url_ftell(s->pb);
1048
        mkv->cluster_pos = avio_tell(s->pb);
1049 1049
        mkv->cluster = start_ebml_master(pb, MATROSKA_ID_CLUSTER, 0);
1050 1050
        put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, FFMAX(0, ts));
1051 1051
        mkv->cluster_pts = FFMAX(0, ts);
......
1094 1094
    AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
1095 1095
    int ret, keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
1096 1096
    int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
1097
    int cluster_size = url_ftell(pb) - (url_is_streamed(s->pb) ? 0 : mkv->cluster_pos);
1097
    int cluster_size = avio_tell(pb) - (url_is_streamed(s->pb) ? 0 : mkv->cluster_pos);
1098 1098

  
1099 1099
    // start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
1100 1100
    // after 4k and on a keyframe
......
1103 1103
         ||                      cluster_size > 5*1024*1024 || ts > mkv->cluster_pts + 5000
1104 1104
         || (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe && cluster_size > 4*1024))) {
1105 1105
        av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64
1106
               " bytes, pts %" PRIu64 "\n", url_ftell(pb), ts);
1106
               " bytes, pts %" PRIu64 "\n", avio_tell(pb), ts);
1107 1107
        end_ebml_master(pb, mkv->cluster);
1108 1108
        mkv->cluster_pos = 0;
1109 1109
        if (mkv->dyn_bc)
......
1162 1162

  
1163 1163
        // update the duration
1164 1164
        av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\n", mkv->duration);
1165
        currentpos = url_ftell(pb);
1165
        currentpos = avio_tell(pb);
1166 1166
        avio_seek(pb, mkv->duration_offset, SEEK_SET);
1167 1167
        put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
1168 1168

  

Also available in: Unified diff