mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avio: avio_ prefix for url_fsize
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
This commit is contained in:
parent
e51975392d
commit
76aa876e69
4
ffmpeg.c
4
ffmpeg.c
@ -1350,8 +1350,8 @@ static void print_report(AVFormatContext **output_files,
|
||||
|
||||
oc = output_files[0];
|
||||
|
||||
total_size = url_fsize(oc->pb);
|
||||
if(total_size<0) // FIXME improve url_fsize() so it works with non seekable output too
|
||||
total_size = avio_size(oc->pb);
|
||||
if(total_size<0) // FIXME improve avio_size() so it works with non seekable output too
|
||||
total_size= avio_tell(oc->pb);
|
||||
|
||||
buf[0] = '\0';
|
||||
|
2
ffplay.c
2
ffplay.c
@ -2838,7 +2838,7 @@ static void event_loop(void)
|
||||
}
|
||||
if (cur_stream) {
|
||||
if(seek_by_bytes || cur_stream->ic->duration<=0){
|
||||
uint64_t size= url_fsize(cur_stream->ic->pb);
|
||||
uint64_t size= avio_size(cur_stream->ic->pb);
|
||||
stream_seek(cur_stream, size*x/cur_stream->width, 0, 1);
|
||||
}else{
|
||||
int64_t ts;
|
||||
|
@ -66,7 +66,7 @@ static int ape_tag_read_field(AVFormatContext *s)
|
||||
void ff_ape_parse_tag(AVFormatContext *s)
|
||||
{
|
||||
AVIOContext *pb = s->pb;
|
||||
int file_size = url_fsize(pb);
|
||||
int file_size = avio_size(pb);
|
||||
uint32_t val, fields, tag_bytes;
|
||||
uint8_t buf[8];
|
||||
int i;
|
||||
|
@ -138,7 +138,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
|
||||
AVIStream *ast;
|
||||
int i;
|
||||
int64_t last_pos= -1;
|
||||
int64_t filesize= url_fsize(s->pb);
|
||||
int64_t filesize= avio_size(s->pb);
|
||||
|
||||
#ifdef DEBUG_SEEK
|
||||
av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n",
|
||||
@ -351,7 +351,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
if (get_riff(s, pb) < 0)
|
||||
return -1;
|
||||
|
||||
avi->fsize = url_fsize(pb);
|
||||
avi->fsize = avio_size(pb);
|
||||
if(avi->fsize<=0)
|
||||
avi->fsize= avi->riff_end == 8 ? INT64_MAX : avi->riff_end;
|
||||
|
||||
@ -378,7 +378,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
|
||||
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);
|
||||
else avi->movi_end = avio_size(pb);
|
||||
av_dlog(NULL, "movi end=%"PRIx64"\n", avi->movi_end);
|
||||
goto end_of_header;
|
||||
}
|
||||
@ -705,7 +705,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
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 = avio_tell(pb) - 4;
|
||||
avi->movi_end = url_fsize(pb);
|
||||
avi->movi_end = avio_size(pb);
|
||||
goto end_of_header;
|
||||
}
|
||||
/* skip tag */
|
||||
|
@ -426,6 +426,7 @@ 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);
|
||||
attribute_deprecated int64_t url_fsize(AVIOContext *s);
|
||||
#define URL_EOF (-1)
|
||||
attribute_deprecated int url_fgetc(AVIOContext *s);
|
||||
/**
|
||||
@ -491,7 +492,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
|
||||
* Get the filesize.
|
||||
* @return filesize or AVERROR
|
||||
*/
|
||||
int64_t url_fsize(AVIOContext *s);
|
||||
int64_t avio_size(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* feof() equivalent for AVIOContext.
|
||||
|
@ -246,7 +246,7 @@ int64_t url_ftell(AVIOContext *s)
|
||||
}
|
||||
#endif
|
||||
|
||||
int64_t url_fsize(AVIOContext *s)
|
||||
int64_t avio_size(AVIOContext *s)
|
||||
{
|
||||
int64_t size;
|
||||
|
||||
@ -371,6 +371,10 @@ int64_t url_fseek(AVIOContext *s, int64_t offset, int whence)
|
||||
{
|
||||
return avio_seek(s, offset, whence);
|
||||
}
|
||||
int64_t url_fsize(AVIOContext *s)
|
||||
{
|
||||
return avio_size(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
int avio_put_str(AVIOContext *s, const char *str)
|
||||
|
@ -284,7 +284,7 @@ static int read_header(AVFormatContext *s,
|
||||
"block size or frame size are variable.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
s->file_size = url_fsize(pb);
|
||||
s->file_size = avio_size(pb);
|
||||
s->file_size = FFMAX(0, s->file_size);
|
||||
|
||||
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
|
||||
|
@ -38,7 +38,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
/// 75 sectors/sec * 4 packets/sector = 300 packets/sec
|
||||
av_set_pts_info(vst, 32, 1, 300);
|
||||
|
||||
ret = url_fsize(s->pb);
|
||||
ret = avio_size(s->pb);
|
||||
if (ret > 0)
|
||||
vst->duration = (ret * vst->time_base.den) / (CDG_PACKET_SIZE * 300);
|
||||
|
||||
|
@ -370,7 +370,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
|
||||
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
|
||||
const DVprofile* sys = ff_dv_codec_profile(c->vst->codec);
|
||||
int64_t offset;
|
||||
int64_t size = url_fsize(s->pb) - s->data_offset;
|
||||
int64_t size = avio_size(s->pb) - s->data_offset;
|
||||
int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size;
|
||||
|
||||
offset = sys->frame_size * timestamp;
|
||||
|
@ -282,7 +282,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
ffm->write_index = avio_rb64(pb);
|
||||
/* get also filesize */
|
||||
if (!url_is_streamed(pb)) {
|
||||
ffm->file_size = url_fsize(pb);
|
||||
ffm->file_size = avio_size(pb);
|
||||
if (ffm->write_index)
|
||||
adjust_write_index(s);
|
||||
} else {
|
||||
|
@ -43,7 +43,7 @@ static int read_header(AVFormatContext *s,
|
||||
if (url_is_streamed(s->pb))
|
||||
return AVERROR(EIO);
|
||||
|
||||
avio_seek(pb, url_fsize(pb) - 36, SEEK_SET);
|
||||
avio_seek(pb, avio_size(pb) - 36, SEEK_SET);
|
||||
if (avio_rb32(pb) != RAND_TAG) {
|
||||
av_log(s, AV_LOG_ERROR, "magic number not found");
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
@ -373,7 +373,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if(!url_is_streamed(s->pb) && (!s->duration || s->duration==AV_NOPTS_VALUE)){
|
||||
int size;
|
||||
const int64_t pos= avio_tell(s->pb);
|
||||
const int64_t fsize= url_fsize(s->pb);
|
||||
const int64_t fsize= avio_size(s->pb);
|
||||
avio_seek(s->pb, fsize-4, SEEK_SET);
|
||||
size= avio_rb32(s->pb);
|
||||
avio_seek(s->pb, fsize-3-size, SEEK_SET);
|
||||
|
@ -310,7 +310,7 @@ static int gxf_write_material_data_section(AVFormatContext *s)
|
||||
/* estimated size */
|
||||
avio_w8(pb, MAT_SIZE);
|
||||
avio_w8(pb, 4);
|
||||
avio_wb32(pb, url_fsize(pb) / 1024);
|
||||
avio_wb32(pb, avio_size(pb) / 1024);
|
||||
|
||||
return updateSize(pb, pos);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ void ff_id3v1_read(AVFormatContext *s)
|
||||
|
||||
if (!url_is_streamed(s->pb)) {
|
||||
/* XXX: change that */
|
||||
filesize = url_fsize(s->pb);
|
||||
filesize = avio_size(s->pb);
|
||||
if (filesize > 128) {
|
||||
avio_seek(s->pb, filesize - 128, SEEK_SET);
|
||||
ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE);
|
||||
|
@ -276,7 +276,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
|
||||
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
size[i]= url_fsize(f[i]);
|
||||
size[i]= avio_size(f[i]);
|
||||
|
||||
if(codec->codec_id != CODEC_ID_RAWVIDEO)
|
||||
break;
|
||||
|
@ -179,7 +179,7 @@ static size_t av_read(void * h, size_t len, uint8_t * buf) {
|
||||
static off_t av_seek(void * h, long long pos, int whence) {
|
||||
AVIOContext * bc = h;
|
||||
if (whence == SEEK_END) {
|
||||
pos = url_fsize(bc) + pos;
|
||||
pos = avio_size(bc) + pos;
|
||||
whence = SEEK_SET;
|
||||
}
|
||||
return avio_seek(bc, pos, whence);
|
||||
|
@ -304,7 +304,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (c->found_moov && c->found_mdat &&
|
||||
(url_is_streamed(pb) || start_pos + a.size == url_fsize(pb)))
|
||||
(url_is_streamed(pb) || start_pos + a.size == avio_size(pb)))
|
||||
return 0;
|
||||
left = a.size - avio_tell(pb) + start_pos;
|
||||
if (left > 0) /* skip garbage at atom end */
|
||||
@ -2351,7 +2351,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
mov->fc = s;
|
||||
/* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */
|
||||
if(!url_is_streamed(pb))
|
||||
atom.size = url_fsize(pb);
|
||||
atom.size = avio_size(pb);
|
||||
else
|
||||
atom.size = INT64_MAX;
|
||||
|
||||
|
@ -508,7 +508,7 @@ static int find_and_decode_index(NUTContext *nut){
|
||||
AVIOContext *bc = s->pb;
|
||||
uint64_t tmp, end;
|
||||
int i, j, syncpoint_count;
|
||||
int64_t filesize= url_fsize(bc);
|
||||
int64_t filesize= avio_size(bc);
|
||||
int64_t *syncpoints;
|
||||
int8_t *has_keyframe;
|
||||
int ret= -1;
|
||||
|
@ -462,7 +462,7 @@ ogg_get_length (AVFormatContext * s)
|
||||
if (s->duration != AV_NOPTS_VALUE)
|
||||
return 0;
|
||||
|
||||
size = url_fsize(s->pb);
|
||||
size = avio_size(s->pb);
|
||||
if(size < 0)
|
||||
return 0;
|
||||
end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: 0;
|
||||
|
@ -180,7 +180,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
if (url_is_streamed(s->pb))
|
||||
return 0;
|
||||
// find REOB/REOF/REOS to load index
|
||||
avio_seek(s->pb, url_fsize(s->pb)-48-8, SEEK_SET);
|
||||
avio_seek(s->pb, avio_size(s->pb)-48-8, SEEK_SET);
|
||||
if (read_atom(s, &atom) < 0)
|
||||
av_log(s, AV_LOG_ERROR, "error reading end atom\n");
|
||||
|
||||
|
@ -33,7 +33,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
|
||||
AVIOContext *pb = avctx->pb;
|
||||
char buf[36];
|
||||
int datatype, filetype, t1, t2, nb_comments, flags;
|
||||
uint64_t start_pos = url_fsize(pb) - 128;
|
||||
uint64_t start_pos = avio_size(pb) - 128;
|
||||
|
||||
avio_seek(pb, start_pos, SEEK_SET);
|
||||
if (avio_read(pb, buf, 7) != 7)
|
||||
|
@ -89,7 +89,7 @@ static int read_header(AVFormatContext *avctx,
|
||||
s->chars_per_frame = FFMAX(av_q2d(st->time_base) * (ap->sample_rate ? ap->sample_rate : LINE_RATE), 1);
|
||||
|
||||
if (!url_is_streamed(avctx->pb)) {
|
||||
s->fsize = url_fsize(avctx->pb);
|
||||
s->fsize = avio_size(avctx->pb);
|
||||
st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame;
|
||||
|
||||
if (ff_sauce_read(avctx, &s->fsize, 0, 0) < 0)
|
||||
|
@ -1557,7 +1557,7 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i
|
||||
|
||||
if(ts_max == AV_NOPTS_VALUE){
|
||||
int step= 1024;
|
||||
filesize = url_fsize(s->pb);
|
||||
filesize = avio_size(s->pb);
|
||||
pos_max = filesize - 1;
|
||||
do{
|
||||
pos_max -= step;
|
||||
@ -1666,7 +1666,7 @@ static int av_seek_frame_byte(AVFormatContext *s, int stream_index, int64_t pos,
|
||||
#endif
|
||||
|
||||
pos_min = s->data_offset;
|
||||
pos_max = url_fsize(s->pb) - 1;
|
||||
pos_max = avio_size(s->pb) - 1;
|
||||
|
||||
if (pos < pos_min) pos= pos_min;
|
||||
else if(pos > pos_max) pos= pos_max;
|
||||
@ -2007,7 +2007,7 @@ static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset)
|
||||
if (ic->iformat->flags & AVFMT_NOFILE) {
|
||||
file_size = 0;
|
||||
} else {
|
||||
file_size = url_fsize(ic->pb);
|
||||
file_size = avio_size(ic->pb);
|
||||
if (file_size < 0)
|
||||
file_size = 0;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
|
||||
if (!voc->remaining_size) {
|
||||
if (url_is_streamed(s->pb))
|
||||
return AVERROR(EIO);
|
||||
voc->remaining_size = url_fsize(pb) - avio_tell(pb);
|
||||
voc->remaining_size = avio_size(pb) - avio_tell(pb);
|
||||
}
|
||||
max_size -= 4;
|
||||
|
||||
|
@ -190,7 +190,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index,
|
||||
return -1;
|
||||
|
||||
pos_min = s->data_offset;
|
||||
pos_max = url_fsize(s->pb) - yop->frame_size;
|
||||
pos_max = avio_size(s->pb) - yop->frame_size;
|
||||
frame_count = (pos_max - pos_min) / yop->frame_size;
|
||||
|
||||
timestamp = FFMAX(0, FFMIN(frame_count, timestamp));
|
||||
|
Loading…
Reference in New Issue
Block a user