Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit 76aa876e69cf78a40821e66dec0a1006e4eb23ec)
| ... | ... |
@@ -1364,8 +1364,8 @@ static void print_report(AVFormatContext **output_files, |
| 1364 | 1364 |
|
| 1365 | 1365 |
oc = output_files[0]; |
| 1366 | 1366 |
|
| 1367 |
- total_size = url_fsize(oc->pb); |
|
| 1368 |
- if(total_size<0) // FIXME improve url_fsize() so it works with non seekable output too |
|
| 1367 |
+ total_size = avio_size(oc->pb); |
|
| 1368 |
+ if(total_size<0) // FIXME improve avio_size() so it works with non seekable output too |
|
| 1369 | 1369 |
total_size= avio_tell(oc->pb); |
| 1370 | 1370 |
|
| 1371 | 1371 |
buf[0] = '\0'; |
| ... | ... |
@@ -2842,7 +2842,7 @@ static void event_loop(void) |
| 2842 | 2842 |
} |
| 2843 | 2843 |
if (cur_stream) {
|
| 2844 | 2844 |
if(seek_by_bytes || cur_stream->ic->duration<=0){
|
| 2845 |
- uint64_t size= url_fsize(cur_stream->ic->pb); |
|
| 2845 |
+ uint64_t size= avio_size(cur_stream->ic->pb); |
|
| 2846 | 2846 |
stream_seek(cur_stream, size*x/cur_stream->width, 0, 1); |
| 2847 | 2847 |
}else{
|
| 2848 | 2848 |
int64_t ts; |
| ... | ... |
@@ -66,7 +66,7 @@ static int ape_tag_read_field(AVFormatContext *s) |
| 66 | 66 |
void ff_ape_parse_tag(AVFormatContext *s) |
| 67 | 67 |
{
|
| 68 | 68 |
AVIOContext *pb = s->pb; |
| 69 |
- int file_size = url_fsize(pb); |
|
| 69 |
+ int file_size = avio_size(pb); |
|
| 70 | 70 |
uint32_t val, fields, tag_bytes; |
| 71 | 71 |
uint8_t buf[8]; |
| 72 | 72 |
int i; |
| ... | ... |
@@ -138,7 +138,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
|
| 138 | 138 |
AVIStream *ast; |
| 139 | 139 |
int i; |
| 140 | 140 |
int64_t last_pos= -1; |
| 141 |
- int64_t filesize= url_fsize(s->pb); |
|
| 141 |
+ int64_t filesize= avio_size(s->pb); |
|
| 142 | 142 |
|
| 143 | 143 |
#ifdef DEBUG_SEEK |
| 144 | 144 |
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) |
| 351 | 351 |
if (get_riff(s, pb) < 0) |
| 352 | 352 |
return -1; |
| 353 | 353 |
|
| 354 |
- avi->fsize = url_fsize(pb); |
|
| 354 |
+ avi->fsize = avio_size(pb); |
|
| 355 | 355 |
if(avi->fsize<=0) |
| 356 | 356 |
avi->fsize= avi->riff_end == 8 ? INT64_MAX : avi->riff_end; |
| 357 | 357 |
|
| ... | ... |
@@ -378,7 +378,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 378 | 378 |
if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
|
| 379 | 379 |
avi->movi_list = avio_tell(pb) - 4; |
| 380 | 380 |
if(size) avi->movi_end = avi->movi_list + size + (size & 1); |
| 381 |
- else avi->movi_end = url_fsize(pb); |
|
| 381 |
+ else avi->movi_end = avio_size(pb); |
|
| 382 | 382 |
av_dlog(NULL, "movi end=%"PRIx64"\n", avi->movi_end); |
| 383 | 383 |
goto end_of_header; |
| 384 | 384 |
} |
| ... | ... |
@@ -705,7 +705,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 705 | 705 |
av_log(s, AV_LOG_ERROR, "Something went wrong during header parsing, " |
| 706 | 706 |
"I will ignore it and try to continue anyway.\n"); |
| 707 | 707 |
avi->movi_list = avio_tell(pb) - 4; |
| 708 |
- avi->movi_end = url_fsize(pb); |
|
| 708 |
+ avi->movi_end = avio_size(pb); |
|
| 709 | 709 |
goto end_of_header; |
| 710 | 710 |
} |
| 711 | 711 |
/* skip tag */ |
| ... | ... |
@@ -426,6 +426,7 @@ attribute_deprecated int url_fclose(AVIOContext *s); |
| 426 | 426 |
attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence); |
| 427 | 427 |
attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset); |
| 428 | 428 |
attribute_deprecated int64_t url_ftell(AVIOContext *s); |
| 429 |
+attribute_deprecated int64_t url_fsize(AVIOContext *s); |
|
| 429 | 430 |
#define URL_EOF (-1) |
| 430 | 431 |
attribute_deprecated int url_fgetc(AVIOContext *s); |
| 431 | 432 |
/** |
| ... | ... |
@@ -485,7 +486,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence); |
| 485 | 485 |
* Get the filesize. |
| 486 | 486 |
* @return filesize or AVERROR |
| 487 | 487 |
*/ |
| 488 |
-int64_t url_fsize(AVIOContext *s); |
|
| 488 |
+int64_t avio_size(AVIOContext *s); |
|
| 489 | 489 |
|
| 490 | 490 |
/** |
| 491 | 491 |
* feof() equivalent for AVIOContext. |
| ... | ... |
@@ -246,7 +246,7 @@ int64_t url_ftell(AVIOContext *s) |
| 246 | 246 |
} |
| 247 | 247 |
#endif |
| 248 | 248 |
|
| 249 |
-int64_t url_fsize(AVIOContext *s) |
|
| 249 |
+int64_t avio_size(AVIOContext *s) |
|
| 250 | 250 |
{
|
| 251 | 251 |
int64_t size; |
| 252 | 252 |
|
| ... | ... |
@@ -371,6 +371,10 @@ int64_t url_fseek(AVIOContext *s, int64_t offset, int whence) |
| 371 | 371 |
{
|
| 372 | 372 |
return avio_seek(s, offset, whence); |
| 373 | 373 |
} |
| 374 |
+int64_t url_fsize(AVIOContext *s) |
|
| 375 |
+{
|
|
| 376 |
+ return avio_size(s); |
|
| 377 |
+} |
|
| 374 | 378 |
#endif |
| 375 | 379 |
|
| 376 | 380 |
int avio_put_str(AVIOContext *s, const char *str) |
| ... | ... |
@@ -284,7 +284,7 @@ static int read_header(AVFormatContext *s, |
| 284 | 284 |
"block size or frame size are variable.\n"); |
| 285 | 285 |
return AVERROR_INVALIDDATA; |
| 286 | 286 |
} |
| 287 |
- s->file_size = url_fsize(pb); |
|
| 287 |
+ s->file_size = avio_size(pb); |
|
| 288 | 288 |
s->file_size = FFMAX(0, s->file_size); |
| 289 | 289 |
|
| 290 | 290 |
av_set_pts_info(st, 64, 1, st->codec->sample_rate); |
| ... | ... |
@@ -38,7 +38,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 38 | 38 |
/// 75 sectors/sec * 4 packets/sector = 300 packets/sec |
| 39 | 39 |
av_set_pts_info(vst, 32, 1, 300); |
| 40 | 40 |
|
| 41 |
- ret = url_fsize(s->pb); |
|
| 41 |
+ ret = avio_size(s->pb); |
|
| 42 | 42 |
if (ret > 0) |
| 43 | 43 |
vst->duration = (ret * vst->time_base.den) / (CDG_PACKET_SIZE * 300); |
| 44 | 44 |
|
| ... | ... |
@@ -370,7 +370,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, |
| 370 | 370 |
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) |
| 371 | 371 |
const DVprofile* sys = ff_dv_codec_profile(c->vst->codec); |
| 372 | 372 |
int64_t offset; |
| 373 |
- int64_t size = url_fsize(s->pb) - s->data_offset; |
|
| 373 |
+ int64_t size = avio_size(s->pb) - s->data_offset; |
|
| 374 | 374 |
int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; |
| 375 | 375 |
|
| 376 | 376 |
offset = sys->frame_size * timestamp; |
| ... | ... |
@@ -282,7 +282,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 282 | 282 |
ffm->write_index = avio_rb64(pb); |
| 283 | 283 |
/* get also filesize */ |
| 284 | 284 |
if (!url_is_streamed(pb)) {
|
| 285 |
- ffm->file_size = url_fsize(pb); |
|
| 285 |
+ ffm->file_size = avio_size(pb); |
|
| 286 | 286 |
if (ffm->write_index) |
| 287 | 287 |
adjust_write_index(s); |
| 288 | 288 |
} else {
|
| ... | ... |
@@ -43,7 +43,7 @@ static int read_header(AVFormatContext *s, |
| 43 | 43 |
if (url_is_streamed(s->pb)) |
| 44 | 44 |
return AVERROR(EIO); |
| 45 | 45 |
|
| 46 |
- avio_seek(pb, url_fsize(pb) - 36, SEEK_SET); |
|
| 46 |
+ avio_seek(pb, avio_size(pb) - 36, SEEK_SET); |
|
| 47 | 47 |
if (avio_rb32(pb) != RAND_TAG) {
|
| 48 | 48 |
av_log(s, AV_LOG_ERROR, "magic number not found"); |
| 49 | 49 |
return AVERROR_INVALIDDATA; |
| ... | ... |
@@ -373,7 +373,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 373 | 373 |
if(!url_is_streamed(s->pb) && (!s->duration || s->duration==AV_NOPTS_VALUE)){
|
| 374 | 374 |
int size; |
| 375 | 375 |
const int64_t pos= avio_tell(s->pb); |
| 376 |
- const int64_t fsize= url_fsize(s->pb); |
|
| 376 |
+ const int64_t fsize= avio_size(s->pb); |
|
| 377 | 377 |
avio_seek(s->pb, fsize-4, SEEK_SET); |
| 378 | 378 |
size= avio_rb32(s->pb); |
| 379 | 379 |
avio_seek(s->pb, fsize-3-size, SEEK_SET); |
| ... | ... |
@@ -310,7 +310,7 @@ static int gxf_write_material_data_section(AVFormatContext *s) |
| 310 | 310 |
/* estimated size */ |
| 311 | 311 |
avio_w8(pb, MAT_SIZE); |
| 312 | 312 |
avio_w8(pb, 4); |
| 313 |
- avio_wb32(pb, url_fsize(pb) / 1024); |
|
| 313 |
+ avio_wb32(pb, avio_size(pb) / 1024); |
|
| 314 | 314 |
|
| 315 | 315 |
return updateSize(pb, pos); |
| 316 | 316 |
} |
| ... | ... |
@@ -231,7 +231,7 @@ void ff_id3v1_read(AVFormatContext *s) |
| 231 | 231 |
|
| 232 | 232 |
if (!url_is_streamed(s->pb)) {
|
| 233 | 233 |
/* XXX: change that */ |
| 234 |
- filesize = url_fsize(s->pb); |
|
| 234 |
+ filesize = avio_size(s->pb); |
|
| 235 | 235 |
if (filesize > 128) {
|
| 236 | 236 |
avio_seek(s->pb, filesize - 128, SEEK_SET); |
| 237 | 237 |
ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE); |
| ... | ... |
@@ -276,7 +276,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) |
| 276 | 276 |
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename); |
| 277 | 277 |
return AVERROR(EIO); |
| 278 | 278 |
} |
| 279 |
- size[i]= url_fsize(f[i]); |
|
| 279 |
+ size[i]= avio_size(f[i]); |
|
| 280 | 280 |
|
| 281 | 281 |
if(codec->codec_id != CODEC_ID_RAWVIDEO) |
| 282 | 282 |
break; |
| ... | ... |
@@ -179,7 +179,7 @@ static size_t av_read(void * h, size_t len, uint8_t * buf) {
|
| 179 | 179 |
static off_t av_seek(void * h, long long pos, int whence) {
|
| 180 | 180 |
AVIOContext * bc = h; |
| 181 | 181 |
if (whence == SEEK_END) {
|
| 182 |
- pos = url_fsize(bc) + pos; |
|
| 182 |
+ pos = avio_size(bc) + pos; |
|
| 183 | 183 |
whence = SEEK_SET; |
| 184 | 184 |
} |
| 185 | 185 |
return avio_seek(bc, pos, whence); |
| ... | ... |
@@ -304,7 +304,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
| 304 | 304 |
if (err < 0) |
| 305 | 305 |
return err; |
| 306 | 306 |
if (c->found_moov && c->found_mdat && |
| 307 |
- (url_is_streamed(pb) || start_pos + a.size == url_fsize(pb))) |
|
| 307 |
+ (url_is_streamed(pb) || start_pos + a.size == avio_size(pb))) |
|
| 308 | 308 |
return 0; |
| 309 | 309 |
left = a.size - avio_tell(pb) + start_pos; |
| 310 | 310 |
if (left > 0) /* skip garbage at atom end */ |
| ... | ... |
@@ -2351,7 +2351,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 2351 | 2351 |
mov->fc = s; |
| 2352 | 2352 |
/* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ |
| 2353 | 2353 |
if(!url_is_streamed(pb)) |
| 2354 |
- atom.size = url_fsize(pb); |
|
| 2354 |
+ atom.size = avio_size(pb); |
|
| 2355 | 2355 |
else |
| 2356 | 2356 |
atom.size = INT64_MAX; |
| 2357 | 2357 |
|
| ... | ... |
@@ -508,7 +508,7 @@ static int find_and_decode_index(NUTContext *nut){
|
| 508 | 508 |
AVIOContext *bc = s->pb; |
| 509 | 509 |
uint64_t tmp, end; |
| 510 | 510 |
int i, j, syncpoint_count; |
| 511 |
- int64_t filesize= url_fsize(bc); |
|
| 511 |
+ int64_t filesize= avio_size(bc); |
|
| 512 | 512 |
int64_t *syncpoints; |
| 513 | 513 |
int8_t *has_keyframe; |
| 514 | 514 |
int ret= -1; |
| ... | ... |
@@ -180,7 +180,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 180 | 180 |
if (url_is_streamed(s->pb)) |
| 181 | 181 |
return 0; |
| 182 | 182 |
// find REOB/REOF/REOS to load index |
| 183 |
- avio_seek(s->pb, url_fsize(s->pb)-48-8, SEEK_SET); |
|
| 183 |
+ avio_seek(s->pb, avio_size(s->pb)-48-8, SEEK_SET); |
|
| 184 | 184 |
if (read_atom(s, &atom) < 0) |
| 185 | 185 |
av_log(s, AV_LOG_ERROR, "error reading end atom\n"); |
| 186 | 186 |
|
| ... | ... |
@@ -33,7 +33,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g |
| 33 | 33 |
AVIOContext *pb = avctx->pb; |
| 34 | 34 |
char buf[36]; |
| 35 | 35 |
int datatype, filetype, t1, t2, nb_comments, flags; |
| 36 |
- uint64_t start_pos = url_fsize(pb) - 128; |
|
| 36 |
+ uint64_t start_pos = avio_size(pb) - 128; |
|
| 37 | 37 |
|
| 38 | 38 |
avio_seek(pb, start_pos, SEEK_SET); |
| 39 | 39 |
if (avio_read(pb, buf, 7) != 7) |
| ... | ... |
@@ -89,7 +89,7 @@ static int read_header(AVFormatContext *avctx, |
| 89 | 89 |
s->chars_per_frame = FFMAX(av_q2d(st->time_base) * (ap->sample_rate ? ap->sample_rate : LINE_RATE), 1); |
| 90 | 90 |
|
| 91 | 91 |
if (!url_is_streamed(avctx->pb)) {
|
| 92 |
- s->fsize = url_fsize(avctx->pb); |
|
| 92 |
+ s->fsize = avio_size(avctx->pb); |
|
| 93 | 93 |
st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame; |
| 94 | 94 |
|
| 95 | 95 |
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 |
| 1557 | 1557 |
|
| 1558 | 1558 |
if(ts_max == AV_NOPTS_VALUE){
|
| 1559 | 1559 |
int step= 1024; |
| 1560 |
- filesize = url_fsize(s->pb); |
|
| 1560 |
+ filesize = avio_size(s->pb); |
|
| 1561 | 1561 |
pos_max = filesize - 1; |
| 1562 | 1562 |
do{
|
| 1563 | 1563 |
pos_max -= step; |
| ... | ... |
@@ -1666,7 +1666,7 @@ static int av_seek_frame_byte(AVFormatContext *s, int stream_index, int64_t pos, |
| 1666 | 1666 |
#endif |
| 1667 | 1667 |
|
| 1668 | 1668 |
pos_min = s->data_offset; |
| 1669 |
- pos_max = url_fsize(s->pb) - 1; |
|
| 1669 |
+ pos_max = avio_size(s->pb) - 1; |
|
| 1670 | 1670 |
|
| 1671 | 1671 |
if (pos < pos_min) pos= pos_min; |
| 1672 | 1672 |
else if(pos > pos_max) pos= pos_max; |
| ... | ... |
@@ -2007,7 +2007,7 @@ static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) |
| 2007 | 2007 |
if (ic->iformat->flags & AVFMT_NOFILE) {
|
| 2008 | 2008 |
file_size = 0; |
| 2009 | 2009 |
} else {
|
| 2010 |
- file_size = url_fsize(ic->pb); |
|
| 2010 |
+ file_size = avio_size(ic->pb); |
|
| 2011 | 2011 |
if (file_size < 0) |
| 2012 | 2012 |
file_size = 0; |
| 2013 | 2013 |
} |
| ... | ... |
@@ -80,7 +80,7 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) |
| 80 | 80 |
if (!voc->remaining_size) {
|
| 81 | 81 |
if (url_is_streamed(s->pb)) |
| 82 | 82 |
return AVERROR(EIO); |
| 83 |
- voc->remaining_size = url_fsize(pb) - avio_tell(pb); |
|
| 83 |
+ voc->remaining_size = avio_size(pb) - avio_tell(pb); |
|
| 84 | 84 |
} |
| 85 | 85 |
max_size -= 4; |
| 86 | 86 |
|
| ... | ... |
@@ -190,7 +190,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index, |
| 190 | 190 |
return -1; |
| 191 | 191 |
|
| 192 | 192 |
pos_min = s->data_offset; |
| 193 |
- pos_max = url_fsize(s->pb) - yop->frame_size; |
|
| 193 |
+ pos_max = avio_size(s->pb) - yop->frame_size; |
|
| 194 | 194 |
frame_count = (pos_max - pos_min) / yop->frame_size; |
| 195 | 195 |
|
| 196 | 196 |
timestamp = FFMAX(0, FFMIN(frame_count, timestamp)); |