Commit a2704c97 authored by Anton Khirnov's avatar Anton Khirnov Committed by Ronald S. Bultje

avio: add avio_tell macro as a replacement for url_ftell

Signed-off-by: default avatarRonald S. Bultje <rsbultje@gmail.com>
parent e16ead07
......@@ -1352,7 +1352,7 @@ static void print_report(AVFormatContext **output_files,
total_size = url_fsize(oc->pb);
if(total_size<0) // FIXME improve url_fsize() so it works with non seekable output too
total_size= url_ftell(oc->pb);
total_size= avio_tell(oc->pb);
buf[0] = '\0';
ti1 = 1e10;
......@@ -2555,7 +2555,7 @@ static int transcode(AVFormatContext **output_files,
}
/* finish if limit size exhausted */
if (limit_filesize != 0 && limit_filesize <= url_ftell(output_files[0]->pb))
if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb))
break;
/* read a frame from it and output it in the fifo */
......
......@@ -2805,7 +2805,7 @@ static void event_loop(void)
}else if(cur_stream->audio_stream >= 0 && cur_stream->audio_pkt.pos>=0){
pos= cur_stream->audio_pkt.pos;
}else
pos = url_ftell(cur_stream->ic->pb);
pos = avio_tell(cur_stream->ic->pb);
if (cur_stream->ic->bit_rate)
incr *= cur_stream->ic->bit_rate / 8.0;
else
......
......@@ -283,7 +283,7 @@ static int fourxm_read_packet(AVFormatContext *s,
return AVERROR(EIO);
pkt->stream_index = fourxm->video_stream_index;
pkt->pts = fourxm->video_pts;
pkt->pos = url_ftell(s->pb);
pkt->pos = avio_tell(s->pb);
memcpy(pkt->data, header, 8);
ret = avio_read(s->pb, &pkt->data[8], size);
......
......@@ -232,10 +232,10 @@ static int aiff_read_header(AVFormatContext *s,
get_meta(s, "comment" , size);
break;
case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
aiff->data_end = url_ftell(pb) + size;
aiff->data_end = avio_tell(pb) + size;
offset = avio_rb32(pb); /* Offset of sound data */
avio_rb32(pb); /* BlockSize... don't care */
offset += url_ftell(pb); /* Compute absolute data offset */
offset += avio_tell(pb); /* Compute absolute data offset */
if (st->codec->block_align) /* Assume COMM already parsed */
goto got_sound;
if (url_is_streamed(pb)) {
......@@ -292,7 +292,7 @@ static int aiff_read_packet(AVFormatContext *s,
int res, size;
/* calculate size of remaining data */
max_size = aiff->data_end - url_ftell(s->pb);
max_size = aiff->data_end - avio_tell(s->pb);
if (max_size <= 0)
return AVERROR_EOF;
......
......@@ -45,7 +45,7 @@ static int aiff_write_header(AVFormatContext *s)
/* FORM AIFF header */
ffio_wfourcc(pb, "FORM");
aiff->form = url_ftell(pb);
aiff->form = avio_tell(pb);
avio_wb32(pb, 0); /* file length */
ffio_wfourcc(pb, aifc ? "AIFC" : "AIFF");
......@@ -66,7 +66,7 @@ static int aiff_write_header(AVFormatContext *s)
avio_wb32(pb, aifc ? 24 : 18); /* size */
avio_wb16(pb, enc->channels); /* Number of channels */
aiff->frames = url_ftell(pb);
aiff->frames = avio_tell(pb);
avio_wb32(pb, 0); /* Number of frames */
if (!enc->bits_per_coded_sample)
......@@ -90,7 +90,7 @@ static int aiff_write_header(AVFormatContext *s)
/* Sound data chunk */
ffio_wfourcc(pb, "SSND");
aiff->ssnd = url_ftell(pb); /* Sound chunk size */
aiff->ssnd = avio_tell(pb); /* Sound chunk size */
avio_wb32(pb, 0); /* Sound samples data size */
avio_wb32(pb, 0); /* Data offset */
avio_wb32(pb, 0); /* Block-size (block align) */
......@@ -118,7 +118,7 @@ static int aiff_write_trailer(AVFormatContext *s)
/* Chunks sizes must be even */
int64_t file_size, end_size;
end_size = file_size = url_ftell(pb);
end_size = file_size = avio_tell(pb);
if (file_size & 1) {
avio_w8(pb, 0);
end_size++;
......
......@@ -154,7 +154,7 @@ static int amr_read_packet(AVFormatContext *s,
}
pkt->stream_index = 0;
pkt->pos= url_ftell(s->pb);
pkt->pos= avio_tell(s->pb);
pkt->data[0]=toc;
pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
read = avio_read(s->pb, pkt->data+1, size-1);
......
......@@ -208,7 +208,7 @@ repeat:
}
/* fetch record size */
tmp = url_ftell(pb);
tmp = avio_tell(pb);
avio_seek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) +
8 + anm->record * 2, SEEK_SET);
record_size = avio_rl16(pb);
......
......@@ -160,7 +160,7 @@ static int get_value(AVIOContext *pb, int type){
static void get_tag(AVFormatContext *s, const char *key, int type, int len)
{
char *value;
int64_t off = url_ftell(s->pb);
int64_t off = avio_tell(s->pb);
if ((unsigned)len >= (UINT_MAX - 1)/2)
return;
......@@ -226,7 +226,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
return AVERROR(EINVAL);
}
pos1 = url_ftell(pb);
pos1 = avio_tell(pb);
st = av_new_stream(s, 0);
if (!st)
......@@ -301,7 +301,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
/* We have to init the frame size at some point .... */
pos2 = url_ftell(pb);
pos2 = avio_tell(pb);
if (size >= (pos2 + 8 - pos1 + 24)) {
asf_st->ds_span = avio_r8(pb);
asf_st->ds_packet_size = avio_rl16(pb);
......@@ -338,7 +338,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
break;
}
} else if (type == AVMEDIA_TYPE_VIDEO &&
size - (url_ftell(pb) - pos1 + 24) >= 51) {
size - (avio_tell(pb) - pos1 + 24) >= 51) {
avio_rl32(pb);
avio_rl32(pb);
avio_r8(pb);
......@@ -387,7 +387,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
if(st->codec->codec_id == CODEC_ID_H264)
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
}
pos2 = url_ftell(pb);
pos2 = avio_tell(pb);
avio_seek(pb, size - (pos2 - pos1 + 24), SEEK_CUR);
return 0;
......@@ -595,14 +595,14 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
avio_r8(pb);
memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
for(;;) {
uint64_t gpos= url_ftell(pb);
uint64_t gpos= avio_tell(pb);
ff_get_guid(pb, &g);
gsize = avio_rl64(pb);
av_dlog(s, "%08"PRIx64": ", gpos);
print_guid(&g);
av_dlog(s, " size=0x%"PRIx64"\n", gsize);
if (!ff_guidcmp(&g, &ff_asf_data_header)) {
asf->data_object_offset = url_ftell(pb);
asf->data_object_offset = avio_tell(pb);
// if not streaming, gsize is not unlimited (how?), and there is enough space in the file..
if (!(asf->hdr.flags & 0x01) && gsize >= 100) {
asf->data_object_size = gsize - 24;
......@@ -652,8 +652,8 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
}
}
if(url_ftell(pb) != gpos + gsize)
av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", url_ftell(pb)-gpos, gsize);
if(avio_tell(pb) != gpos + gsize)
av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", avio_tell(pb)-gpos, gsize);
avio_seek(pb, gpos + gsize, SEEK_SET);
}
ff_get_guid(pb, &g);
......@@ -662,7 +662,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
avio_r8(pb);
if (url_feof(pb))
return -1;
asf->data_offset = url_ftell(pb);
asf->data_offset = avio_tell(pb);
asf->packet_size_left = 0;
......@@ -726,7 +726,7 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
// if we do not know packet size, allow skipping up to 32 kB
off= 32768;
if (s->packet_size > 0)
off= (url_ftell(pb) - s->data_offset) % s->packet_size + 3;
off= (avio_tell(pb) - s->data_offset) % s->packet_size + 3;
c=d=e=-1;
while(off-- > 0){
......@@ -746,7 +746,7 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
if (url_ferror(pb) == AVERROR(EAGAIN))
return AVERROR(EAGAIN);
if (!url_feof(pb))
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, url_ftell(pb));
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
}
if ((c & 0x8f) == 0x82) {
if (d || e) {
......@@ -770,11 +770,11 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
//the following checks prevent overflows and infinite loops
if(!packet_length || packet_length >= (1U<<29)){
av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, url_ftell(pb));
av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, avio_tell(pb));
return -1;
}
if(padsize >= packet_length){
av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, url_ftell(pb));
av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, avio_tell(pb));
return -1;
}
......@@ -892,12 +892,12 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk
|| asf->packet_segments < 1) {
//asf->packet_size_left <= asf->packet_padsize) {
int ret = asf->packet_size_left + asf->packet_padsize;
//printf("PacketLeftSize:%d Pad:%d Pos:%"PRId64"\n", asf->packet_size_left, asf->packet_padsize, url_ftell(pb));
//printf("PacketLeftSize:%d Pad:%d Pos:%"PRId64"\n", asf->packet_size_left, asf->packet_padsize, avio_tell(pb));
assert(ret>=0);
/* fail safe */
avio_seek(pb, ret, SEEK_CUR);
asf->packet_pos= url_ftell(pb);
asf->packet_pos= avio_tell(pb);
if (asf->data_object_size != (uint64_t)-1 &&
(asf->packet_pos - asf->data_object_offset >= asf->data_object_size))
return AVERROR_EOF; /* Do not exceed the size of the data object */
......@@ -1185,7 +1185,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
{
ff_asf_guid g;
ASFContext *asf = s->priv_data;
int64_t current_pos= url_ftell(s->pb);
int64_t current_pos= avio_tell(s->pb);
int i;
avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
......@@ -1268,7 +1268,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
// avio_seek(s->pb, pos, SEEK_SET);
// key_pos = pos;
// for(i=0;i<16;i++){
// pos = url_ftell(s->pb);
// pos = avio_tell(s->pb);
// if (av_read_frame(s, &pkt) < 0){
// av_log(s, AV_LOG_INFO, "seek failed\n");
// return -1;
......
......@@ -248,7 +248,7 @@ static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
{
int64_t pos;
pos = url_ftell(pb);
pos = avio_tell(pb);
put_guid(pb, g);
avio_wl64(pb, 24);
return pos;
......@@ -259,7 +259,7 @@ static void end_header(AVIOContext *pb, int64_t pos)
{
int64_t pos1;
pos1 = url_ftell(pb);
pos1 = avio_tell(pb);
avio_seek(pb, pos + 16, SEEK_SET);
avio_wl64(pb, pos1 - pos);
avio_seek(pb, pos1, SEEK_SET);
......@@ -337,7 +337,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
avio_w8(pb, 2); /* ??? */
/* file header */
header_offset = url_ftell(pb);
header_offset = avio_tell(pb);
hpos = put_header(pb, &ff_asf_file_header);
put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, file_size);
......@@ -425,7 +425,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
put_guid(pb, &ff_asf_video_conceal_none);
}
avio_wl64(pb, 0); /* ??? */
es_pos = url_ftell(pb);
es_pos = avio_tell(pb);
avio_wl32(pb, extra_size); /* wav header len */
avio_wl32(pb, extra_size2); /* additional data len */
avio_wl16(pb, n + 1); /* stream number */
......@@ -442,7 +442,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
if (wavsize < 0)
return -1;
if (wavsize != extra_size) {
cur_pos = url_ftell(pb);
cur_pos = avio_tell(pb);
avio_seek(pb, es_pos, SEEK_SET);
avio_wl32(pb, wavsize); /* wav header len */
avio_seek(pb, cur_pos, SEEK_SET);
......@@ -525,7 +525,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
/* patch the header size fields */
cur_pos = url_ftell(pb);
cur_pos = avio_tell(pb);
header_size = cur_pos - header_offset;
if (asf->is_streamed) {
header_size += 8 + 30 + 50;
......@@ -605,7 +605,7 @@ static int put_payload_parsing_info(
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
int ppi_size, i;
int64_t start= url_ftell(pb);
int64_t start= avio_tell(pb);
int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
......@@ -642,7 +642,7 @@ static int put_payload_parsing_info(
if (asf->multi_payloads_present)
avio_w8(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
ppi_size = url_ftell(pb) - start;
ppi_size = avio_tell(pb) - start;
return ppi_size;
}
......@@ -860,7 +860,7 @@ static int asf_write_trailer(AVFormatContext *s)
flush_packet(s);
/* write index */
data_size = url_ftell(s->pb);
data_size = avio_tell(s->pb);
if ((!asf->is_streamed) && (asf->nb_index_count != 0)) {
asf_write_index(s, asf->index_ptr, asf->maximum_packet, asf->nb_index_count);
}
......@@ -870,7 +870,7 @@ static int asf_write_trailer(AVFormatContext *s)
put_chunk(s, 0x4524, 0, 0); /* end of stream */
} else {
/* rewrite an updated header */
file_size = url_ftell(s->pb);
file_size = avio_tell(s->pb);
avio_seek(s->pb, 0, SEEK_SET);
asf_write_header1(s, file_size, data_size - asf->data_offset);
}
......
......@@ -94,7 +94,7 @@ static int au_write_trailer(AVFormatContext *s)
if (!url_is_streamed(s->pb)) {
/* update file size */
file_size = url_ftell(pb);
file_size = avio_tell(pb);
avio_seek(pb, 8, SEEK_SET);
avio_wb32(pb, (uint32_t)(file_size - 24));
avio_seek(pb, file_size, SEEK_SET);
......
......@@ -109,7 +109,7 @@ static int get_riff(AVFormatContext *s, AVIOContext *pb)
/* check RIFF header */
avio_read(pb, header, 4);
avi->riff_end = avio_rl32(pb); /* RIFF chunk size */
avi->riff_end += url_ftell(pb); /* RIFF chunk end */
avi->riff_end += avio_tell(pb); /* RIFF chunk end */
avio_read(pb, header+4, 4);
for(i=0; avi_headers[i][0]; i++)
......@@ -198,7 +198,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
if(url_feof(pb))
return -1;
pos = url_ftell(pb);
pos = avio_tell(pb);
if(avi->odml_depth > MAX_ODML_DEPTH){
av_log(s, AV_LOG_ERROR, "Too deeply nested ODML indexes\n");
......@@ -267,7 +267,7 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
static void avi_read_info(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
while (avio_tell(s->pb) < end) {
uint32_t tag = avio_rl32(s->pb);
uint32_t size = avio_rl32(s->pb);
avi_read_tag(s, NULL, tag, size);
......@@ -298,13 +298,13 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
static void avi_read_nikon(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
while (avio_tell(s->pb) < end) {
uint32_t tag = avio_rl32(s->pb);
uint32_t size = avio_rl32(s->pb);
switch (tag) {
case MKTAG('n', 'c', 't', 'g'): { /* Nikon Tags */
uint64_t tag_end = url_ftell(s->pb) + size;
while (url_ftell(s->pb) < tag_end) {
uint64_t tag_end = avio_tell(s->pb) + size;
while (avio_tell(s->pb) < tag_end) {
uint16_t tag = avio_rl16(s->pb);
uint16_t size = avio_rl16(s->pb);
const char *name = NULL;
......@@ -369,14 +369,14 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
switch(tag) {
case MKTAG('L', 'I', 'S', 'T'):
list_end = url_ftell(pb) + size;
list_end = avio_tell(pb) + size;
/* Ignored, except at start of video packets. */
tag1 = avio_rl32(pb);
print_tag("list", tag1, 0);
if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
avi->movi_list = url_ftell(pb) - 4;
avi->movi_list = avio_tell(pb) - 4;
if(size) avi->movi_end = avi->movi_list + size + (size & 1);
else avi->movi_end = url_fsize(pb);
av_dlog(NULL, "movi end=%"PRIx64"\n", avi->movi_end);
......@@ -549,7 +549,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (stream_index >= (unsigned)s->nb_streams || avi->dv_demux) {
avio_seek(pb, size, SEEK_CUR);
} else {
uint64_t cur_pos = url_ftell(pb);
uint64_t cur_pos = avio_tell(pb);
if (cur_pos < list_end)
size = FFMIN(size, list_end - cur_pos);
st = s->streams[stream_index];
......@@ -664,7 +664,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
break;
case MKTAG('i', 'n', 'd', 'x'):
i= url_ftell(pb);
i= avio_tell(pb);
if(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX)){
read_braindead_odml_indx(s, 0);
}
......@@ -704,7 +704,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(size > 1000000){
av_log(s, AV_LOG_ERROR, "Something went wrong during header parsing, "
"I will ignore it and try to continue anyway.\n");
avi->movi_list = url_ftell(pb) - 4;
avi->movi_list = avio_tell(pb) - 4;
avi->movi_end = url_fsize(pb);
goto end_of_header;
}
......@@ -923,7 +923,7 @@ resync:
if(size > ast->remaining)
size= ast->remaining;
avi->last_pkt_pos= url_ftell(pb);
avi->last_pkt_pos= avio_tell(pb);
err= av_get_packet(pb, pkt, size);
if(err<0)
return err;
......@@ -989,7 +989,7 @@ resync:
}
memset(d, -1, sizeof(int)*8);
for(i=sync=url_ftell(pb); !url_feof(pb); i++) {
for(i=sync=avio_tell(pb); !url_feof(pb); i++) {
int j;
for(j=0; j<7; j++)
......@@ -1092,7 +1092,7 @@ resync:
ast->remaining= size;
if(size || !ast->sample_size){
uint64_t pos= url_ftell(pb) - 8;
uint64_t pos= avio_tell(pb) - 8;
if(!st->index_entries || !st->nb_index_entries || st->index_entries[st->nb_index_entries - 1].pos < pos){
av_add_index_entry(st, pos, ast->frame_offset, size, 0, AVINDEX_KEYFRAME);
}
......@@ -1162,7 +1162,7 @@ static int guess_ni_flag(AVFormatContext *s){
int i;
int64_t last_start=0;
int64_t first_end= INT64_MAX;
int64_t oldpos= url_ftell(s->pb);
int64_t oldpos= avio_tell(s->pb);
for(i=0; i<s->nb_streams; i++){
AVStream *st = s->streams[i];
......@@ -1194,7 +1194,7 @@ static int avi_load_index(AVFormatContext *s)
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
uint32_t tag, size;
int64_t pos= url_ftell(pb);
int64_t pos= avio_tell(pb);
int ret = -1;
if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0)
......
......@@ -124,7 +124,7 @@ static int avi_write_counters(AVFormatContext* s, int riff_id)
int64_t file_size;
AVCodecContext* stream;
file_size = url_ftell(pb);
file_size = avio_tell(pb);
for(n = 0; n < s->nb_streams; n++) {
AVIStream *avist= s->streams[n]->priv_data;
......@@ -201,7 +201,7 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
else
avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
avi->frames_hdr_all = url_ftell(pb); /* remember this offset to fill later */
avi->frames_hdr_all = avio_tell(pb); /* remember this offset to fill later */
avio_wl32(pb, nb_frames); /* nb frames, filled later */
avio_wl32(pb, 0); /* initial frame */
avio_wl32(pb, s->nb_streams); /* nb streams */
......@@ -258,7 +258,7 @@ static int avi_write_header(AVFormatContext *s)
av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
avio_wl32(pb, 0); /* start */
avist->frames_hdr_strm = url_ftell(pb); /* remember this offset to fill later */
avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */
if (url_is_streamed(pb))
avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
else
......@@ -419,7 +419,7 @@ static int avi_write_ix(AVFormatContext *s)
ix_tag[3] = '0' + i;
/* Writing AVI OpenDML leaf index chunk */
ix = url_ftell(pb);
ix = avio_tell(pb);
ffio_wfourcc(pb, ix_tag); /* ix?? */
avio_wl32(pb, avist->indexes.entry * 8 + 24);
/* chunk size */
......@@ -439,7 +439,7 @@ static int avi_write_ix(AVFormatContext *s)
(ie->flags & 0x10 ? 0 : 0x80000000));
}
put_flush_packet(pb);
pos = url_ftell(pb);
pos = avio_tell(pb);
/* Updating one entry in the AVI OpenDML master index */
avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
......@@ -533,7 +533,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
// Make sure to put an OpenDML chunk when the file size exceeds the limits
if (!url_is_streamed(pb) &&
(url_ftell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) {
(avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) {
avi_write_ix(s);
ff_end_tag(pb, avi->movi_list);
......@@ -567,7 +567,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
}
idx->cluster[cl][id].flags = flags;
idx->cluster[cl][id].pos = url_ftell(pb) - avi->movi_list;
idx->cluster[cl][id].pos = avio_tell(pb) - avi->movi_list;
idx->cluster[cl][id].len = size;
idx->entry++;
}
......@@ -600,7 +600,7 @@ static int avi_write_trailer(AVFormatContext *s)
ff_end_tag(pb, avi->movi_list);
ff_end_tag(pb, avi->riff_start);
file_size = url_ftell(pb);
file_size = avio_tell(pb);
avio_seek(pb, avi->odml_list - 8, SEEK_SET);
ffio_wfourcc(pb, "LIST"); /* Making this AVI OpenDML one */
avio_seek(pb, 16, SEEK_CUR);
......
......@@ -422,6 +422,7 @@ attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags)
attribute_deprecated int url_fclose(AVIOContext *s);
attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
attribute_deprecated int64_t url_ftell(AVIOContext *s);
/**
* @}
*/
......@@ -473,7 +474,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
* ftell() equivalent for AVIOContext.
* @return position or AVERROR.
*/
int64_t url_ftell(AVIOContext *s);
#define avio_tell(s) avio_seek((s), 0, SEEK_CUR)
/**
* Get the filesize.
......
......@@ -239,12 +239,12 @@ int url_fskip(AVIOContext *s, int64_t offset)
int64_t ret = avio_seek(s, offset, SEEK_CUR);
return ret < 0 ? ret : 0;
}
#endif
int64_t url_ftell(AVIOContext *s)
{
return avio_seek(s, 0, SEEK_CUR);
}
#endif
int64_t url_fsize(AVIOContext *s)
{
......
......@@ -123,9 +123,9 @@ static int avs_read_audio_packet(AVFormatContext * s, AVPacket * pkt)
AvsFormat *avs = s->priv_data;
int ret, size;
size = url_ftell(s->pb);
size = avio_tell(s->pb);
ret = voc_get_packet(s, pkt, avs->st_audio, avs->remaining_audio_size);
size = url_ftell(s->pb) - size;
size = avio_tell(s->pb) - size;
avs->remaining_audio_size -= size;
if (ret == AVERROR(EIO))
......
......@@ -112,7 +112,7 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
return AVERROR(ENOMEM);
// save the file position for the packet, include block type
position = url_ftell(pb) - 1;
position = avio_tell(pb) - 1;
vidbuf_start[vidbuf_nbytes++] = block_type;
......
......@@ -106,9 +106,9 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
int strt, skip;
MOVAtom atom;
strt = url_ftell(pb);
strt = avio_tell(pb);
ff_mov_read_esds(s, pb, atom);
skip = size - (url_ftell(pb) - strt);
skip = size - (avio_tell(pb) - strt);
if (skip < 0 || !st->codec->extradata ||
st->codec->codec_id != CODEC_ID_AAC) {
av_log(s, AV_LOG_ERROR, "invalid AAC magic cookie\n");
......@@ -150,7 +150,7 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
int64_t pos = 0, ccount;
int num_packets, i;
ccount = url_ftell(pb);
ccount = avio_tell(pb);
num_packets = avio_rb64(pb);
if (num_packets < 0 || INT32_MAX / sizeof(AVIndexEntry) < num_packets)
......@@ -167,7 +167,7 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
st->duration += caf->frames_per_packet ? caf->frames_per_packet : ff_mp4_read_descr_len(pb);
}
if (url_ftell(pb) - ccount != size) {
if (avio_tell(pb) - ccount != size) {
av_log(s, AV_LOG_ERROR, "error reading packet table\n");
return -1;
}
......@@ -234,7 +234,7 @@ static int read_header(AVFormatContext *s,
switch (tag) {
case MKBETAG('d','a','t','a'):
avio_seek(pb, 4, SEEK_CUR); /* edit count */
caf->data_start = url_ftell(pb);
caf->data_start = avio_tell(pb);
caf->data_size = size < 0 ? -1 : size - 4;
if (caf->data_size > 0 && !url_is_streamed(pb))
avio_seek(pb, caf->data_size, SEEK_CUR);
......@@ -312,7 +312,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
/* don't read past end of data chunk */
if (caf->data_size > 0) {
left = (caf->data_start + caf->data_size) - url_ftell(pb);
left = (caf->data_start + caf->data_size) - avio_tell(pb);
if (left <= 0)
return AVERROR(EIO);
}
......
......@@ -417,8 +417,8 @@ static int dv_read_header(AVFormatContext *s,
return -1;
}
if (state == 0x003f0700 || state == 0xff3f0700)
marker_pos = url_ftell(s->pb);
if (state == 0xff3f0701 && url_ftell(s->pb) - marker_pos == 80) {
marker_pos = avio_tell(s->pb);
if (state == 0xff3f0701 && avio_tell(s->pb) - marker_pos == 80) {
avio_seek(s->pb, -163, SEEK_CUR);
state = avio_rb32(s->pb);
break;
......
......@@ -95,7 +95,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
uint32_t size, fsize;
c->has_sound = 1;
size = avio_rb32(pb);
c->vidpos = url_ftell(pb) + size;
c->vidpos = avio_tell(pb) + size;
avio_seek(pb, 16, SEEK_CUR);
fsize = avio_rl32(pb);
......@@ -104,7 +104,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
ff_get_wav_header(pb, ast->codec, fsize);
// find 'data' chunk
while(url_ftell(pb) < c->vidpos && !url_feof(pb)){
while(avio_tell(pb) < c->vidpos && !url_feof(pb)){
tag = avio_rl32(pb);
fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break;
......@@ -114,7 +114,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(ast->codec->block_align)
c->bpc = ((c->bpc + ast->codec->block_align - 1) / ast->codec->block_align) * ast->codec->block_align;
c->bytes_left = fsize;
c->wavpos = url_ftell(pb);
c->wavpos = avio_tell(pb);
avio_seek(pb, c->vidpos, SEEK_SET);
}
......@@ -133,7 +133,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->height >>= 1;
}