diff options
author | James Almer <jamrial@gmail.com> | 2017-03-21 17:02:30 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-03-21 17:02:30 -0300 |
commit | 4de591e6fb7361bd417dcd9563672ed0ad8b361b (patch) | |
tree | ff6b5c51a4891b49f61d53b88bdfb27cc6a89579 | |
parent | 423375d4f06ae7103e575a31c23e62e3ba440845 (diff) | |
parent | 83548fe894cdb455cc127f754d09905b6d23c173 (diff) | |
download | ffmpeg-4de591e6fb7361bd417dcd9563672ed0ad8b361b.tar.gz |
Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'
* commit '83548fe894cdb455cc127f754d09905b6d23c173':
lavf: fix usage of AVIOContext.seekable
Merged-by: James Almer <jamrial@gmail.com>
65 files changed, 134 insertions, 130 deletions
diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index fecb1e381d..5ab5197e33 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -89,7 +89,7 @@ static int adts_aac_read_header(AVFormatContext *s) st->need_parsing = AVSTREAM_PARSE_FULL_RAW; ff_id3v1_read(s); - if (s->pb->seekable && + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) { int64_t cur = avio_tell(s->pb); ff_ape_parse_tag(s); diff --git a/libavformat/adp.c b/libavformat/adp.c index 9ab2ec4566..735550307e 100644 --- a/libavformat/adp.c +++ b/libavformat/adp.c @@ -59,7 +59,7 @@ static int adp_read_header(AVFormatContext *s) st->codecpar->channels = 2; st->codecpar->sample_rate = 48000; st->start_time = 0; - if (s->pb->seekable) + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) st->duration = av_get_audio_frame_duration2(st->codecpar, avio_size(s->pb)); avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 3bbe4a07bd..7dcc85f1ed 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -288,9 +288,9 @@ static int aiff_read_header(AVFormatContext *s) offset = avio_rb32(pb); /* Offset of sound data */ avio_rb32(pb); /* BlockSize... don't care */ offset += avio_tell(pb); /* Compute absolute data offset */ - if (st->codecpar->block_align && !pb->seekable) /* Assume COMM already parsed */ + if (st->codecpar->block_align && !(pb->seekable & AVIO_SEEKABLE_NORMAL)) /* Assume COMM already parsed */ goto got_sound; - if (!pb->seekable) { + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(s, AV_LOG_ERROR, "file is not seekable\n"); return -1; } diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 74b778bbcb..fcadf149a0 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -49,7 +49,7 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff) AVIOContext *pb = s->pb; AVPacketList *pict_list = aiff->pict_list; - if (!pb->seekable) + if (!pb->seekable & AVIO_SEEKABLE_NORMAL) return 0; if (!s->metadata && !aiff->pict_list) @@ -267,7 +267,7 @@ static int aiff_write_trailer(AVFormatContext *s) end_size++; } - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { /* Number of sample frames */ avio_seek(pb, aiff->frames, SEEK_SET); avio_wb32(pb, (file_size - aiff->ssnd - 12) / par->block_align); diff --git a/libavformat/ape.c b/libavformat/ape.c index 061f32866f..50a1aa13c1 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -374,7 +374,7 @@ static int ape_read_header(AVFormatContext * s) } /* try to read APE tags */ - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { ff_ape_parse_tag(s); avio_seek(pb, 0, SEEK_SET); } diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c index 0c40be297f..378a9b3b36 100644 --- a/libavformat/apngenc.c +++ b/libavformat/apngenc.c @@ -258,7 +258,7 @@ static int apng_write_trailer(AVFormatContext *format_context) apng_write_chunk(io_context, MKBETAG('I', 'E', 'N', 'D'), NULL, 0); - if (apng->acTL_offset && io_context->seekable) { + if (apng->acTL_offset && (io_context->seekable & AVIO_SEEKABLE_NORMAL)) { avio_seek(io_context, apng->acTL_offset, SEEK_SET); AV_WB32(buf, apng->frame_number); diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c index 56f8446b5f..f7000b0413 100644 --- a/libavformat/asfdec_o.c +++ b/libavformat/asfdec_o.c @@ -960,7 +960,7 @@ static int asf_read_data(AVFormatContext *s, const GUIDParseTable *g) size, asf->nb_packets); avio_skip(pb, 2); // skip reserved field asf->first_packet_offset = avio_tell(pb); - if (pb->seekable && !(asf->b_flags & ASF_FLAG_BROADCAST)) + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !(asf->b_flags & ASF_FLAG_BROADCAST)) align_position(pb, asf->offset, asf->data_size); return 0; @@ -1738,7 +1738,9 @@ static int asf_read_header(AVFormatContext *s) size = avio_rl64(pb); align_position(pb, asf->offset, size); } - if (asf->data_reached && (!pb->seekable || (asf->b_flags & ASF_FLAG_BROADCAST))) + if (asf->data_reached && + (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || + (asf->b_flags & ASF_FLAG_BROADCAST))) break; } @@ -1747,7 +1749,7 @@ static int asf_read_header(AVFormatContext *s) ret = AVERROR_INVALIDDATA; goto failed; } - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) avio_seek(pb, asf->first_packet_offset, SEEK_SET); for (i = 0; i < asf->nb_streams; i++) { diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 19dee3d528..1b67143afd 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -473,7 +473,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, avio_wl64(pb, duration); /* end time stamp (in 100ns units) */ avio_wl64(pb, asf->duration); /* duration (in 100ns units) */ avio_wl64(pb, PREROLL_TIME); /* start time stamp */ - avio_wl32(pb, (asf->is_streamed || !pb->seekable) ? 3 : 2); /* ??? */ + avio_wl32(pb, (asf->is_streamed || !(pb->seekable & AVIO_SEEKABLE_NORMAL)) ? 3 : 2); /* ??? */ avio_wl32(pb, s->packet_size); /* packet size */ avio_wl32(pb, s->packet_size); /* packet size */ avio_wl32(pb, bit_rate ? bit_rate : -1); /* Maximum data rate in bps */ @@ -530,7 +530,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, avio_wl32(pb, 5000); /* maximum buffer size ms */ avio_wl32(pb, 0); /* max initial buffer fullness */ avio_wl32(pb, 0); /* max object size */ - avio_wl32(pb, (!asf->is_streamed && pb->seekable) << 1); /* flags - seekable */ + avio_wl32(pb, (!asf->is_streamed && (pb->seekable & AVIO_SEEKABLE_NORMAL)) << 1); /* flags - seekable */ avio_wl16(pb, n + 1); /* stream number */ avio_wl16(pb, asf->streams[n].stream_language_index); /* language id index */ avio_wl64(pb, 0); /* avg time per frame */ @@ -1135,7 +1135,7 @@ static int asf_write_trailer(AVFormatContext *s) } avio_flush(s->pb); - if (asf->is_streamed || !s->pb->seekable) { + if (asf->is_streamed || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { put_chunk(s, 0x4524, 0, 0); /* end of stream */ } else { /* rewrite an updated header */ diff --git a/libavformat/astenc.c b/libavformat/astenc.c index 11f8717495..578e658891 100644 --- a/libavformat/astenc.c +++ b/libavformat/astenc.c @@ -139,7 +139,7 @@ static int ast_write_trailer(AVFormatContext *s) av_log(s, AV_LOG_DEBUG, "total samples: %"PRId64"\n", samples); - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { /* Number of samples */ avio_seek(pb, ast->samples, SEEK_SET); avio_wb32(pb, samples); diff --git a/libavformat/au.c b/libavformat/au.c index f70f827201..520824fc12 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -321,7 +321,7 @@ static int au_write_trailer(AVFormatContext *s) AUContext *au = s->priv_data; int64_t file_size = avio_tell(pb); - if (s->pb->seekable && file_size < INT32_MAX) { + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && file_size < INT32_MAX) { /* update file size */ avio_seek(pb, 8, SEEK_SET); avio_wb32(pb, (uint32_t)(file_size - au->header_size)); diff --git a/libavformat/avidec.c b/libavformat/avidec.c index abe8c988f1..e2527a1e31 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -948,7 +948,7 @@ FF_ENABLE_DEPRECATION_WARNINGS break; case MKTAG('i', 'n', 'd', 'x'): pos = avio_tell(pb); - if (pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) && + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !(s->flags & AVFMT_FLAG_IGNIDX) && avi->use_odml && read_odml_index(s, 0) < 0 && (s->error_recognition & AV_EF_EXPLODE)) @@ -1022,7 +1022,7 @@ fail: return AVERROR_INVALIDDATA; } - if (!avi->index_loaded && pb->seekable) + if (!avi->index_loaded && (pb->seekable & AVIO_SEEKABLE_NORMAL)) avi_load_index(s); calculate_bitrate(s); avi->index_loaded |= 1; diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 4b042a92ad..91b8c40e32 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -332,7 +332,7 @@ static int avi_write_header(AVFormatContext *s) avio_wl32(pb, 0); avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */ avio_wl32(pb, 0); /* padding */ - if (!pb->seekable) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */ else avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */ @@ -414,7 +414,7 @@ static int avi_write_header(AVFormatContext *s) avio_wl32(pb, 0); /* start */ /* remember this offset to fill later */ avist->frames_hdr_strm = avio_tell(pb); - if (!pb->seekable) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) /* FIXME: this may be broken, but who cares */ avio_wl32(pb, AVI_MAX_RIFF_SIZE); else @@ -493,7 +493,7 @@ static int avi_write_header(AVFormatContext *s) } } - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { write_odml_master(s, i); } @@ -534,7 +534,7 @@ static int avi_write_header(AVFormatContext *s) ff_end_tag(pb, list2); } - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { /* AVI could become an OpenDML one, if it grows beyond 2Gb range */ avi->odml_list = ff_start_tag(pb, "JUNK"); ffio_wfourcc(pb, "odml"); @@ -611,7 +611,7 @@ static int avi_write_ix(AVFormatContext *s) char ix_tag[] = "ix00"; int i, j; - av_assert0(pb->seekable); + av_assert0(pb->seekable & AVIO_SEEKABLE_NORMAL); for (i = 0; i < s->nb_streams; i++) { AVIStream *avist = s->streams[i]->priv_data; @@ -669,7 +669,7 @@ static int avi_write_idx1(AVFormatContext *s) int i; char tag[5]; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { AVIStream *avist; AVIIentry *ie = 0, *tie; int empty, stream_id = -1; @@ -783,7 +783,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) av_assert0(par->bits_per_coded_sample >= 0 && par->bits_per_coded_sample <= 8); - if (pb->seekable && avist->pal_offset) { + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && avist->pal_offset) { int64_t cur_offset = avio_tell(pb); avio_seek(pb, avist->pal_offset, SEEK_SET); for (i = 0; i < pal_size; i++) { @@ -798,7 +798,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) unsigned char tag[5]; avi_stream2fourcc(tag, stream_index, par->codec_type); tag[2] = 'p'; tag[3] = 'c'; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { if (avist->strh_flags_offset) { int64_t cur_offset = avio_tell(pb); avio_seek(pb, avist->strh_flags_offset, SEEK_SET); @@ -854,7 +854,7 @@ static int avi_write_packet_internal(AVFormatContext *s, AVPacket *pkt) avist->packet_count++; // Make sure to put an OpenDML chunk when the file size exceeds the limits - if (pb->seekable && + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && (avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) { avi_write_ix(s); ff_end_tag(pb, avi->movi_list); @@ -872,7 +872,7 @@ static int avi_write_packet_internal(AVFormatContext *s, AVPacket *pkt) if (par->codec_type == AVMEDIA_TYPE_AUDIO) avist->audio_strm_length += size; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { int ret; ret = avi_add_ientry(s, stream_index, NULL, flags, size); if (ret < 0) @@ -901,7 +901,7 @@ static int avi_write_trailer(AVFormatContext *s) write_skip_frames(s, i, avist->last_dts); } - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { if (avi->riff_id == 1) { ff_end_tag(pb, avi->movi_list); res = avi_write_idx1(s); @@ -950,7 +950,7 @@ static int avi_write_trailer(AVFormatContext *s) av_freep(&avist->indexes.cluster[j]); av_freep(&avist->indexes.cluster); avist->indexes.ents_allocated = avist->indexes.entry = 0; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { avio_seek(pb, avist->frames_hdr_strm + 4, SEEK_SET); avio_wl32(pb, avist->max_size); } diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 4ade4d0d7e..5f58ab064b 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -269,7 +269,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) offset1 >= 0 && offset1 <= buffer_size - s->write_flag) { /* can do the seek inside the buffer */ s->buf_ptr = s->buffer + offset1; - } else if ((!s->seekable || + } else if ((!(s->seekable & AVIO_SEEKABLE_NORMAL) || offset1 <= buffer_size + short_seek) && !s->write_flag && offset1 >= 0 && (!s->direct || !s->seek) && diff --git a/libavformat/bink.c b/libavformat/bink.c index e6f0cb78ed..20dba677db 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -292,7 +292,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in BinkDemuxContext *bink = s->priv_data; AVStream *vst = s->streams[0]; - if (!s->pb->seekable) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) return -1; /* seek to the first frame */ diff --git a/libavformat/bintext.c b/libavformat/bintext.c index a264fd1b5f..12e3bfde4d 100644 --- a/libavformat/bintext.c +++ b/libavformat/bintext.c @@ -141,7 +141,7 @@ static int bintext_read_header(AVFormatContext *s) st->codecpar->extradata[0] = 16; st->codecpar->extradata[1] = 0; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { int got_width = 0; bin->fsize = avio_size(pb); if (ff_sauce_read(s, &bin->fsize, &got_width, 0) < 0) @@ -199,7 +199,7 @@ static int xbin_read_header(AVFormatContext *s) if (avio_read(pb, st->codecpar->extradata + 2, st->codecpar->extradata_size - 2) < 0) return AVERROR(EIO); - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { bin->fsize = avio_size(pb) - 9 - st->codecpar->extradata_size; ff_sauce_read(s, &bin->fsize, NULL, 0); avio_seek(pb, 9 + st->codecpar->extradata_size, SEEK_SET); @@ -237,7 +237,7 @@ static int adf_read_header(AVFormatContext *s) if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0) return AVERROR(EIO); - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { int got_width = 0; bin->fsize = avio_size(pb) - 1 - 192 - 4096; st->codecpar->width = 80<<3; @@ -271,7 +271,7 @@ static int idf_read_header(AVFormatContext *s) AVStream *st; int got_width = 0; - if (!pb->seekable) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) return AVERROR(EIO); st = init_stream(s); diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 0e6179a56a..fc85fd9799 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -257,7 +257,7 @@ static int read_header(AVFormatContext *s) /* stop at data chunk if seeking is not supported or data chunk size is unknown */ - if (found_data && (caf->data_size < 0 || !pb->seekable)) + if (found_data && (caf->data_size < 0 || !(pb->seekable & AVIO_SEEKABLE_NORMAL))) break; tag = avio_rb32(pb); @@ -271,7 +271,7 @@ static int read_header(AVFormatContext *s) avio_skip(pb, 4); /* edit count */ caf->data_start = avio_tell(pb); caf->data_size = size < 0 ? -1 : size - 4; - if (caf->data_size > 0 && pb->seekable) + if (caf->data_size > 0 && (pb->seekable & AVIO_SEEKABLE_NORMAL)) avio_skip(pb, caf->data_size); found_data = 1; break; diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index 5ea8e69cc8..7aa9e8cee1 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -126,7 +126,7 @@ static int caf_write_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } - if (!par->block_align && !pb->seekable) { + if (!par->block_align && !(pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(s, AV_LOG_ERROR, "Muxing variable packet size not supported on non seekable output\n"); return AVERROR_INVALIDDATA; } @@ -236,7 +236,7 @@ static int caf_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; AVCodecParameters *par = s->streams[0]->codecpar; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t file_size = avio_tell(pb); avio_seek(pb, caf->data, SEEK_SET); diff --git a/libavformat/cinedec.c b/libavformat/cinedec.c index 32cccf566b..763b93ba2e 100644 --- a/libavformat/cinedec.c +++ b/libavformat/cinedec.c @@ -307,7 +307,7 @@ static int cine_read_seek(AVFormatContext *avctx, int stream_index, int64_t time if ((flags & AVSEEK_FLAG_FRAME) || (flags & AVSEEK_FLAG_BYTE)) return AVERROR(ENOSYS); - if (!avctx->pb->seekable) + if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL)) return AVERROR(EIO); cine->pts = timestamp; diff --git a/libavformat/dsfdec.c b/libavformat/dsfdec.c index f16b397df2..49ca336427 100644 --- a/libavformat/dsfdec.c +++ b/libavformat/dsfdec.c @@ -77,7 +77,7 @@ static int dsf_read_header(AVFormatContext *s) avio_skip(pb, 8); id3pos = avio_rl64(pb); - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { read_id3(s, id3pos); avio_seek(pb, 28, SEEK_SET); } diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c index f5f040773b..1bd403c843 100644 --- a/libavformat/dtshddec.c +++ b/libavformat/dtshddec.c @@ -89,7 +89,7 @@ static int dtshd_read_header(AVFormatContext *s) dtshd->data_end = data_start + chunk_size; if (dtshd->data_end <= chunk_size) return AVERROR_INVALIDDATA; - if (!pb->seekable) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) goto break_loop; goto skip; break; diff --git a/libavformat/dv.c b/libavformat/dv.c index 89a9e10c14..06de04485c 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -534,7 +534,7 @@ static int dv_read_header(AVFormatContext *s) (AVRational) { 8, 1 }, c->dv_demux->sys->time_base); - if (s->pb->seekable) + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) dv_read_timecode(s); return 0; diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index f863bf7818..de6ac27252 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -300,7 +300,7 @@ static int ffm2_read_header(AVFormatContext *s) ffm->write_index = avio_rb64(pb); /* get also filesize */ - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { ffm->file_size = avio_size(pb); if (ffm->write_index && 0) adjust_write_index(s); @@ -559,7 +559,7 @@ static int ffm_read_header(AVFormatContext *s) } ffm->write_index = avio_rb64(pb); /* get also filesize */ - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { ffm->file_size = avio_size(pb); if (ffm->write_index && 0) adjust_write_index(s); diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c index 0aeb5947b0..0bf5a80830 100644 --- a/libavformat/filmstripdec.c +++ b/libavformat/filmstripdec.c @@ -41,7 +41,7 @@ static int read_header(AVFormatContext *s) AVIOContext *pb = s->pb; AVStream *st; - if (!s->pb->seekable) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) return AVERROR(EIO); avio_seek(pb, avio_size(pb) - 36, SEEK_SET); diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index 89b21e9e23..b894f9ef61 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -147,7 +147,7 @@ static int flac_write_trailer(struct AVFormatContext *s) if (!c->write_header || !streaminfo) return 0; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { /* rewrite the STREAMINFO header block data */ file_size = avio_tell(pb); avio_seek(pb, 8, SEEK_SET); diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 3959a3665a..cdcfb9c5a0 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -484,7 +484,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, break; case AMF_DATA_TYPE_OBJECT: if (key && - ioc->seekable && + (ioc->seekable & AVIO_SEEKABLE_NORMAL) && !strcmp(KEYFRAMES_TAG, key) && depth == 1) if (parse_keyframes_index(s, ioc, max_pos) < 0) @@ -1040,7 +1040,7 @@ skip: } av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard); - if (s->pb->seekable && + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || stream_type == FLV_STREAM_TYPE_AUDIO)) av_add_index_entry(st, pos, dts, size, 0, AVINDEX_KEYFRAME); @@ -1056,7 +1056,8 @@ skip: // if not streamed and no duration from metadata then seek to end to find // the duration from the timestamps - if (s->pb->seekable && (!s->duration || s->duration == AV_NOPTS_VALUE) && + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && + (!s->duration || s->duration == AV_NOPTS_VALUE) && !flv->searched_for_end) { int size; const int64_t pos = avio_tell(s->pb); diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 79951b59af..0e0772b744 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -709,7 +709,7 @@ static int gxf_write_header(AVFormatContext *s) int ret; AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); - if (!pb->seekable) { + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome\n"); return -1; } diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c index a7ada19fcd..e641f7bdc7 100644 --- a/libavformat/icoenc.c +++ b/libavformat/icoenc.c @@ -82,7 +82,7 @@ static int ico_write_header(AVFormatContext *s) int ret; int i; - if (!pb->seekable) { + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(s, AV_LOG_ERROR, "Output is not seekable\n"); return AVERROR(EINVAL); } diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c index 218ed73f81..19be42121d 100644 --- a/libavformat/id3v1.c +++ b/libavformat/id3v1.c @@ -238,7 +238,7 @@ void ff_id3v1_read(AVFormatContext *s) uint8_t buf[ID3v1_TAG_SIZE]; int64_t filesize, position = avio_tell(s->pb); - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { /* XXX: change that */ filesize = avio_size(s->pb); if (filesize > 128) { diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c index f3ae4dca66..fdc0ee03e1 100644 --- a/libavformat/ivfenc.c +++ b/libavformat/ivfenc.c @@ -75,7 +75,7 @@ static int ivf_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; IVFEncContext *ctx = s->priv_data; - if (pb->seekable && ctx->frame_cnt > 1) { + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && ctx->frame_cnt > 1) { size_t end = avio_tell(pb); avio_seek(pb, 24, SEEK_SET); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index bad034b770..2e3c9bf197 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1616,7 +1616,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) int i; // we should not do any seeking in the streaming case - if (!matroska->ctx->pb->seekable) + if (!(matroska->ctx->pb->seekable & AVIO_SEEKABLE_NORMAL)) return; for (i = 0; i < seekhead_list->nb_elem; i++) { diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index df77313675..af941ceb8f 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -333,7 +333,7 @@ static int start_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, Matros if ((ret = avio_open_dyn_buf(dyn_cp)) < 0) return ret; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { *master = start_ebml_master(pb, elementid, expectedsize); if (mkv->write_crc && mkv->mode != MODE_WEBM) put_ebml_void(*dyn_cp, 6); /* Reserve space for CRC32 so position/size calculations using avio_tell() take it into account */ @@ -349,7 +349,7 @@ static void end_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, Matrosk uint8_t *buf, crc[4]; int size, skip = 0; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { size = avio_close_dyn_buf(*dyn_cp, &buf); if (mkv->write_crc && mkv->mode != MODE_WEBM) { skip = 6; /* Skip reserved 6-byte long void element from the dynamic buffer. */ @@ -373,7 +373,7 @@ static void end_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, Matrosk static void end_ebml_master_crc32_preliminary(AVIOContext *pb, AVIOContext **dyn_cp, MatroskaMuxContext *mkv, ebml_master master) { - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { uint8_t *buf; int size = avio_get_dyn_buf(*dyn_cp, &buf); @@ -1419,7 +1419,7 @@ static int mkv_write_tracks(AVFormatContext *s) return ret; } - if (pb->seekable && !mkv->is_live) + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) end_ebml_master_crc32_preliminary(pb, &mkv->tracks_bc, mkv, mkv->tracks_master); else end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, mkv->tracks_master); @@ -1614,7 +1614,7 @@ static int mkv_write_tags(AVFormatContext *s) if (ret < 0) return ret; } - if (s->pb->seekable && !mkv->is_live) { + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) { for (i = 0; i < s->nb_streams; i++) { AVIOContext *pb; AVStream *st = s->streams[i]; @@ -1664,7 +1664,7 @@ static int mkv_write_tags(AVFormatContext *s) } if (mkv->tags.pos) { - if (s->pb->seekable && !mkv->is_live) + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) end_ebml_master_crc32_preliminary(s->pb, &mkv->tags_bc, mkv, mkv->tags); else end_ebml_master_crc32(s->pb, &mkv->tags_bc, mkv, mkv->tags); @@ -1921,7 +1921,7 @@ static int mkv_write_header(AVFormatContext *s) put_ebml_void(pb, 11); // assumes double-precision float to be written } } - if (s->pb->seekable && !mkv->is_live) + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) end_ebml_master_crc32_preliminary(s->pb, &mkv->info_bc, mkv, mkv->info); else end_ebml_master_crc32(s->pb, &mkv->info_bc, mkv, mkv->info); @@ -1952,7 +1952,7 @@ static int mkv_write_header(AVFormatContext *s) goto fail; } - if (!s->pb->seekable && !mkv->is_live) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) mkv_write_seekhead(pb, mkv); mkv->cues = mkv_start_cues(mkv->segment_offset); @@ -1960,7 +1960,7 @@ static int mkv_write_header(AVFormatContext *s) ret = AVERROR(ENOMEM); goto fail; } - if (pb->seekable && mkv->reserve_cues_space) { + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && mkv->reserve_cues_space) { mkv->cues_pos = avio_tell(pb); put_ebml_void(pb, mkv->reserve_cues_space); } @@ -1973,7 +1973,7 @@ static int mkv_write_header(AVFormatContext *s) // start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or // after 4k and on a keyframe - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { if (mkv->cluster_time_limit < 0) mkv->cluster_time_limit = 5000; if (mkv->cluster_size_limit < 0) @@ -2198,7 +2198,7 @@ static void mkv_start_new_cluster(AVFormatContext *s, AVPacket *pkt) end_ebml_master_crc32(s->pb, &mkv->dyn_bc, mkv, mkv->cluster); mkv->cluster_pos = -1; - if (s->pb->seekable) + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64 " bytes, " "pts %" PRIu64 "dts %" PRIu64 "\n", @@ -2223,7 +2223,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt) switch (par->codec_id) { case AV_CODEC_ID_FLAC: - if (side_data_size && s->pb->seekable) { + if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { AVCodecParameters *codecpriv_par; int64_t curpos; if (side_data_size != par->extradata_size) { @@ -2296,7 +2296,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ if (par->codec_type != AVMEDIA_TYPE_SUBTITLE) { mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe); - if (s->pb->seekable && (par->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) { + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && (par->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) { ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, dash_tracknum, ts, mkv->cluster_pos, relative_packet_pos, -1); if (ret < 0) return ret; } @@ -2321,7 +2321,7 @@ FF_ENABLE_DEPRECATION_WARNINGS end_ebml_master(pb, blockgroup); } - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, dash_tracknum, ts, mkv->cluster_pos, relative_packet_pos, duration); if (ret < 0) @@ -2421,7 +2421,7 @@ static int mkv_write_flush_packet(AVFormatContext *s, AVPacket *pkt) if (mkv->cluster_pos != -1) { end_ebml_master_crc32(s->pb, &mkv->dyn_bc, mkv, mkv->cluster); mkv->cluster_pos = -1; - if (s->pb->seekable) + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) av_log(s, AV_LOG_DEBUG, "Flushing cluster at offset %" PRIu64 " bytes\n", avio_tell(s->pb)); @@ -2462,7 +2462,7 @@ static int mkv_write_trailer(AVFormatContext *s) return ret; } - if (pb->seekable && !mkv->is_live) { + if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) { if (mkv->cues->num_entries) { if (mkv->reserve_cues_space) { int64_t cues_end; diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c index 665b28d4f8..90c3779e44 100644 --- a/libavformat/mlvdec.c +++ b/libavformat/mlvdec.c @@ -449,7 +449,7 @@ static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp if ((flags & AVSEEK_FLAG_FRAME) || (flags & AVSEEK_FLAG_BYTE)) return AVERROR(ENOSYS); - if (!avctx->pb->seekable) + if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL)) return AVERROR(EIO); mlv->pts = timestamp; diff --git a/libavformat/mmf.c b/libavformat/mmf.c index b8a9cad32e..1393627d8a 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -147,7 +147,7 @@ static int mmf_write_trailer(AVFormatContext *s) int64_t pos, size; int gatetime; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { /* Fill in length fields */ end_tag_be(pb, mmf->awapos); end_tag_be(pb, mmf->atrpos); diff --git a/libavformat/mov.c b/libavformat/mov.c index f7dd2502c5..3754346f9e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1166,7 +1166,7 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) { if (!c->has_looked_for_mfra && c->use_mfra_for > 0) { c->has_looked_for_mfra = 1; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { int ret; av_log(c->fc, AV_LOG_VERBOSE, "stream has moof boxes, will look " "for a mfra\n"); @@ -5421,9 +5421,9 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) return err; } if (c->found_moov && c->found_mdat && - ((!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX || c->fragment_index_complete) || + ((!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX || c->fragment_index_complete) || start_pos + a.size == avio_size(pb))) { - if (!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX || c->fragment_index_complete) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX || c->fragment_index_complete) c->next_root_atom = start_pos + a.size; c->atom_depth --; return 0; @@ -5935,7 +5935,7 @@ static int mov_read_header(AVFormatContext *s) mov->fc = s; mov->trak_index = -1; /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) atom.size = avio_size(pb); else atom.size = INT64_MAX; @@ -5949,7 +5949,7 @@ static int mov_read_header(AVFormatContext *s) mov_read_close(s); return err; } - } while (pb->seekable && !mov->found_moov && !mov->moov_retry++); + } while ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !mov->found_moov && !mov->moov_retry++); if (!mov->found_moov) { av_log(s, AV_LOG_ERROR, "moov atom not found\n"); mov_read_close(s); @@ -5957,7 +5957,7 @@ static int mov_read_header(AVFormatContext *s) } av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb)); - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { if (mov->nb_chapter_tracks > 0 && !mov->ignore_chapters) mov_read_chapters(s); for (i = 0; i < s->nb_streams; i++) @@ -6118,8 +6118,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample]; int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale); av_log(s, AV_LOG_TRACE, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts); - if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) || - (s->pb->seekable && + if (!sample || (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && current_sample->pos < sample->pos) || + ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) { diff --git a/libavformat/movenc.c b/libavformat/movenc.c index a28621080d..11b26708ae 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5616,7 +5616,7 @@ static int mov_init(AVFormatContext *s) /* Non-seekable output is ok if using fragmentation. If ism_lookahead * is enabled, we don't support non-seekable output at all. */ - if (!s->pb->seekable && + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && (!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return AVERROR(EINVAL); diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index b45a066686..0924a57843 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -370,7 +370,7 @@ static int mp3_read_header(AVFormatContext *s) if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) ff_id3v1_read(s); - if(s->pb->seekable) + if(s->pb->seekable & AVIO_SEEKABLE_NORMAL) mp3->filesize = avio_size(s->pb); if (mp3_parse_vbr_tags(s, st, off) < 0) diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 49f3742dc4..034862261a 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -144,7 +144,7 @@ static int mp3_write_xing(AVFormatContext *s) int ver = 0; int bytes_needed; - if (!s->pb->seekable || !mp3->write_xing) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) || !mp3->write_xing) return 0; for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) { diff --git a/libavformat/mpc.c b/libavformat/mpc.c index 4bd1f5018b..af333746e3 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -104,7 +104,7 @@ static int mpc_read_header(AVFormatContext *s) st->duration = c->fcount; /* try to read APE tags */ - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t pos = avio_tell(s->pb); ff_ape_parse_tag(s); if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index 05d0c1ae86..180c554c00 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -264,7 +264,7 @@ static int mpc8_read_header(AVFormatContext *s) if (size > 0) avio_skip(pb, size); - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t pos = avio_tell(s->pb); c->apetag_start = ff_ape_parse_tag(s); avio_seek(s->pb, pos, SEEK_SET); diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index a651cb3eb6..68a848a6f6 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -451,7 +451,7 @@ redo: int i; for (i = 0; i < s->nb_streams; i++) { if (startcode == s->streams[i]->id && - s->pb->seekable /* index useless on streams anyway */) { + (s->pb->seekable & AVIO_SEEKABLE_NORMAL) /* index useless on streams anyway */) { ff_reduce_index(s, i); av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 590abb04f1..3eff1522bd 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2605,7 +2605,7 @@ static void seek_back(AVFormatContext *s, AVIOContext *pb, int64_t pos) { * probe buffer usually is big enough. Only warn if the seek failed * on files where the seek should work. */ if (avio_seek(pb, pos, SEEK_SET) < 0) - av_log(s, pb->seekable ? AV_LOG_ERROR : AV_LOG_INFO, "Unable to seek back to the start\n"); + av_log(s, (pb->seekable & AVIO_SEEKABLE_NORMAL) ? AV_LOG_ERROR : AV_LOG_INFO, "Unable to seek back to the start\n"); } static int mpegts_read_header(AVFormatContext *s) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index f0a29ebe57..0e12c8c6c1 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -421,7 +421,7 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt) if (index->pos > pos) avio_skip(pb, index->pos - pos); else if (index->pos < pos) { - if (!pb->seekable) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) return AVERROR(EIO); ret = avio_seek(pb, index->pos, SEEK_SET); if (ret < 0) @@ -463,7 +463,7 @@ static int mv_read_seek(AVFormatContext *avctx, int stream_index, if ((flags & AVSEEK_FLAG_FRAME) || (flags & AVSEEK_FLAG_BYTE)) return AVERROR(ENOSYS); - if (!avctx->pb->seekable) + if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL)) return AVERROR(EIO); frame = av_index_search_timestamp(st, timestamp, flags); diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 2ad0c288f8..f8d0f9e057 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2590,7 +2590,7 @@ static int mxf_parse_handle_essence(MXFContext *mxf) /* remember where we were so we don't end up seeking further back than this */ mxf->last_forward_tell = avio_tell(pb); - if (!pb->seekable) { + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(mxf->fc, AV_LOG_INFO, "file is not seekable - not parsing FooterPartition\n"); return -1; } @@ -2777,7 +2777,7 @@ static void mxf_read_random_index_pack(AVFormatContext *s) int64_t file_size, max_rip_length, min_rip_length; KLVPacket klv; - if (!s->pb->seekable) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) return; file_size = avio_size(s->pb); diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index afea117d5a..12fc9abbc6 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2549,7 +2549,7 @@ static int mxf_write_footer(AVFormatContext *s) mxf_write_klv_fill(s); mxf_write_random_index_pack(s); - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { if (s->oformat == &ff_mxf_opatom_muxer){ /* rewrite body partition to update lengths */ avio_seek(pb, mxf->body_partition_offset[0], SEEK_SET); diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 2e309bcad7..ca34e35f74 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -876,7 +876,7 @@ static int nut_read_header(AVFormatContext *s) s->internal->data_offset = pos - 8; - if (bc->seekable) { + if (bc->seekable & AVIO_SEEKABLE_NORMAL) { int64_t orig_pos = avio_tell(bc); find_and_decode_index(nut); avio_seek(bc, orig_pos, SEEK_SET); diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index edeae2ba83..97ad1a27d1 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -209,7 +209,7 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int nsegs) const struct ogg_codec *codec; int i = 0; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { uint8_t magic[8]; int64_t pos = avio_tell(s->pb); avio_skip(s->pb, nsegs); @@ -355,7 +355,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid) sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S') break; - if(!i && bc->seekable && ogg->page_pos > 0) { + if(!i && (bc->seekable & AVIO_SEEKABLE_NORMAL) && ogg->page_pos > 0) { memset(sync, 0, 4); avio_seek(bc, ogg->page_pos+4, SEEK_SET); ogg->page_pos = -1; @@ -613,7 +613,7 @@ static int ogg_get_length(AVFormatContext *s) int64_t size, end; int streams_left=0; - if (!s->pb->seekable) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) return 0; // already set diff --git a/libavformat/r3d.c b/libavformat/r3d.c index b609488839..1f53d847e9 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -186,7 +186,7 @@ static int r3d_read_header(AVFormatContext *s) s->internal->data_offset = avio_tell(s->pb); av_log(s, AV_LOG_TRACE, "data offset %#"PRIx64"\n", s->internal->data_offset); - if (!s->pb->seekable) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) return 0; // find REOB/REOF/REOS to load index avio_seek(s->pb, avio_size(s->pb)-48-8, SEEK_SET); diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index 0edcd1cf99..26baa850e1 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -65,7 +65,7 @@ static int adx_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; AVCodecParameters *par = s->streams[0]->codecpar; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t file_size = avio_tell(pb); uint64_t sample_count = (file_size - 36) / par->channels / 18 * 32; if (sample_count <= UINT32_MAX) { diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 222c43378c..e6a1fe8842 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -651,7 +651,8 @@ static int rm_read_header(AVFormatContext *s) if (!data_off) data_off = avio_tell(pb) - 18; - if (indx_off && pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) && + if (indx_off && (pb->seekable & AVIO_SEEKABLE_NORMAL) && + !(s->flags & AVFMT_FLAG_IGNIDX) && avio_seek(pb, indx_off, SEEK_SET) >= 0) { rm_read_index(s); avio_seek(pb, data_off + 18, SEEK_SET); diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c index 0bc5bfd92b..f9821d1875 100644 --- a/libavformat/rmenc.c +++ b/libavformat/rmenc.c @@ -123,7 +123,7 @@ static int rv10_write_header(AVFormatContext *ctx, avio_wb32(s, 0); /* data offset : will be patched after */ avio_wb16(s, ctx->nb_streams); /* num streams */ flags = 1 | 2; /* save allowed & perfect play */ - if (!s->seekable) + if (!(s->seekable & AVIO_SEEKABLE_NORMAL)) flags |= 4; /* live broadcast */ avio_wb16(s, flags); @@ -175,7 +175,7 @@ static int rv10_write_header(AVFormatContext *ctx, avio_wb32(s, 0); /* start time */ avio_wb32(s, BUFFER_DURATION); /* preroll */ /* duration */ - if (!s->seekable || !stream->total_frames) + if (!(s->seekable & AVIO_SEEKABLE_NORMAL) || !stream->total_frames) avio_wb32(s, (int)(3600 * 1000)); else avio_wb32(s, av_rescale_q_rnd(stream->total_frames, (AVRational){1000, 1}, stream->frame_rate, AV_ROUND_ZERO)); @@ -444,7 +444,7 @@ static int rm_write_trailer(AVFormatContext *s) int data_size, index_pos, i; AVIOContext *pb = s->pb; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { /* end of file: finish to write header */ index_pos = avio_tell(pb); data_size = index_pos - rm->data_pos; diff --git a/libavformat/rsd.c b/libavformat/rsd.c index 5a56e72bb3..27a3d73981 100644 --- a/libavformat/rsd.c +++ b/libavformat/rsd.c @@ -106,12 +106,12 @@ static int rsd_read_header(AVFormatContext *s) break; case AV_CODEC_ID_ADPCM_PSX: par->block_align = 16 * par->channels; - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); break; case AV_CODEC_ID_ADPCM_IMA_RAD: par->block_align = 20 * par->channels; - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); break; case AV_CODEC_ID_ADPCM_IMA_WAV: @@ -120,7 +120,7 @@ static int rsd_read_header(AVFormatContext *s) par->bits_per_coded_sample = 4; par->block_align = 36 * par->channels; - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); break; case AV_CODEC_ID_ADPCM_THP_LE: @@ -131,7 +131,7 @@ static int rsd_read_header(AVFormatContext *s) if ((ret = ff_get_extradata(s, par, s->pb, 32)) < 0) return ret; - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); break; case AV_CODEC_ID_ADPCM_THP: @@ -145,7 +145,7 @@ static int rsd_read_header(AVFormatContext *s) avio_read(s->pb, st->codecpar->extradata + 32 * i, 32); avio_skip(s->pb, 8); } - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) st->duration = (avio_size(pb) - start) / (8 * par->channels) * 14; break; case AV_CODEC_ID_PCM_S16LE: @@ -153,7 +153,7 @@ static int rsd_read_header(AVFormatContext *s) if (version != 4) start = avio_rl32(pb); - if (pb->seekable) + if (pb->seekable & AVIO_SEEKABLE_NORMAL) st->duration = (avio_size(pb) - start) / 2 / par->channels; break; } diff --git a/libavformat/rsoenc.c b/libavformat/rsoenc.c index 3c5c1180f5..60ebac8ebd 100644 --- a/libavformat/rsoenc.c +++ b/libavformat/rsoenc.c @@ -38,7 +38,7 @@ static int rso_write_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } - if (!s->pb->seekable) { + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return AVERROR_INVALIDDATA; } diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c index 314593a5c9..68a128647e 100644 --- a/libavformat/smjpegenc.c +++ b/libavformat/smjpegenc.c @@ -121,7 +121,7 @@ static int smjpeg_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; int64_t currentpos; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { currentpos = avio_tell(pb); avio_seek(pb, 12, SEEK_SET); avio_wb32(pb, smc->duration); diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index b307157856..7b37bd4848 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -91,7 +91,7 @@ static int sox_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; AVCodecParameters *par = s->streams[0]->codecpar; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { /* update number of samples */ int64_t file_size = avio_tell(pb); int64_t num_samples = (file_size - sox->header_size - 4LL) >> 2LL; diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index 3733a0442c..cada45ef9a 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -500,7 +500,7 @@ static int swf_write_trailer(AVFormatContext *s) put_swf_end_tag(s); /* patch file size and number of frames if not streamed */ - if (s->pb->seekable && video_par) { + if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && video_par) { file_size = avio_tell(pb); avio_seek(pb, 4, SEEK_SET); avio_wl32(pb, file_size); diff --git a/libavformat/takdec.c b/libavformat/takdec.c index a8fb363b34..1535bec64f 100644 --- a/libavformat/takdec.c +++ b/libavformat/takdec.c @@ -128,7 +128,7 @@ static int tak_read_header(AVFormatContext *s) case TAK_METADATA_END: { int64_t curpos = avio_tell(pb); - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { ff_ape_parse_tag(s); avio_seek(pb, curpos, SEEK_SET); } diff --git a/libavformat/tta.c b/libavformat/tta.c index 1447effcd8..ae90a85544 100644 --- a/libavformat/tta.c +++ b/libavformat/tta.c @@ -136,7 +136,7 @@ static int tta_read_header(AVFormatContext *s) st->codecpar->sample_rate = samplerate; st->codecpar->bits_per_coded_sample = bps; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t pos = avio_tell(s->pb); ff_ape_parse_tag(s); avio_seek(s->pb, pos, SEEK_SET); diff --git a/libavformat/tty.c b/libavformat/tty.c index b407645ee4..8d48f2c45c 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -94,7 +94,7 @@ static int read_header(AVFormatContext *avctx) /* simulate tty display speed */ s->chars_per_frame = FFMAX(av_q2d(st->time_base)*s->chars_per_frame, 1); - if (avctx->pb->seekable) { + if (avctx->pb->seekable & AVIO_SEEKABLE_NORMAL) { s->fsize = avio_size(avctx->pb); st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame; diff --git a/libavformat/utils.c b/libavformat/utils.c index 8227d1bbe1..a059046a2c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2857,7 +2857,7 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset) if ((!strcmp(ic->iformat->name, "mpeg") || !strcmp(ic->iformat->name, "mpegts")) && - file_size && ic->pb->seekable) { + file_size && (ic->pb->seekable & AVIO_SEEKABLE_NORMAL)) { /* get accurate estimate from the PTSes */ estimate_timings_from_pts(ic, old_offset); ic->duration_estimation_method = AVFMT_DURATION_FROM_PTS; diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c index 60fb894a97..cf95d1d80d 100644 --- a/libavformat/vc1testenc.c +++ b/libavformat/vc1testenc.c @@ -73,7 +73,7 @@ static int vc1test_write_trailer(AVFormatContext *s) RCVContext *ctx = s->priv_data; AVIOContext *pb = s->pb; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { avio_seek(pb, 0, SEEK_SET); avio_wl24(pb, ctx->frames); avio_flush(pb); diff --git a/libavformat/voc_packet.c b/libavformat/voc_packet.c index 4f60467ac4..1e2e19e1c3 100644 --- a/libavformat/voc_packet.c +++ b/libavformat/voc_packet.c @@ -49,7 +49,7 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) return AVERROR_EOF; voc->remaining_size = avio_rl24(pb); if (!voc->remaining_size) { - if (!s->pb->seekable) + if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) return AVERROR(EIO); voc->remaining_size = avio_size(pb) - avio_tell(pb); } diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 0ca1ef42f8..a3cd4ffa06 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -410,7 +410,7 @@ static int wav_read_header(AVFormatContext *s) got_xma2 = 1; break; case MKTAG('d', 'a', 't', 'a'): - if (!pb->seekable && !got_fmt && !got_xma2) { + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) && !got_fmt && !got_xma2) { av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n"); return AVERROR_INVALIDDATA; @@ -433,7 +433,7 @@ static int wav_read_header(AVFormatContext *s) /* don't look for footer metadata if we can't seek or if we don't * know where the data tag ends */ - if (!pb->seekable || (!rf64 && !size)) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || (!rf64 && !size)) goto break_loop; break; case MKTAG('f', 'a', 'c', 't'): @@ -821,7 +821,7 @@ static int w64_read_header(AVFormatContext *s) wav->data_end = avio_tell(pb) + size - 24; data_ofs = avio_tell(pb); - if (!pb->seekable) + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) break; avio_skip(pb, size - 24); diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c index a21d4c547e..7f3059e99a 100644 --- a/libavformat/wavenc.c +++ b/libavformat/wavenc.c @@ -344,7 +344,7 @@ static int wav_write_header(AVFormatContext *s) } if (s->streams[0]->codecpar->codec_tag != 0x01 /* hence for all other than PCM */ - && s->pb->seekable) { + && (s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { wav->fact_pos = ff_start_tag(pb, "fact"); avio_wl32(pb, 0); ff_end_tag(pb, wav->fact_pos); @@ -425,7 +425,7 @@ static int wav_write_trailer(AVFormatContext *s) avio_flush(pb); - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { if (wav->write_peak != 2 && avio_tell(pb) - wav->data < UINT32_MAX) { ff_end_tag(pb, wav->data); avio_flush(pb); @@ -584,7 +584,7 @@ static int w64_write_header(AVFormatContext *s) end_guid(pb, start); if (s->streams[0]->codecpar->codec_tag != 0x01 /* hence for all other than PCM */ - && s->pb->seekable) { + && (s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { start_guid(pb, ff_w64_guid_fact, &wav->fact_pos); avio_wl64(pb, 0); end_guid(pb, wav->fact_pos); @@ -601,7 +601,7 @@ static int w64_write_trailer(AVFormatContext *s) WAVMuxContext *wav = s->priv_data; int64_t file_size; - if (pb->seekable) { + if (pb->seekable & AVIO_SEEKABLE_NORMAL) { end_guid(pb, wav->data); file_size = avio_tell(pb); diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c index 1ec52f689d..261fcaf35e 100644 --- a/libavformat/wvdec.c +++ b/libavformat/wvdec.c @@ -119,7 +119,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb) } if ((rate == -1 || !chan) && !wc->block_parsed) { int64_t block_end = avio_tell(pb) + wc->header.blocksize; - if (!pb->seekable) { + if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(ctx, AV_LOG_ERROR, "Cannot determine additional parameters\n"); return AVERROR_INVALIDDATA; @@ -241,7 +241,7 @@ static int wv_read_header(AVFormatContext *s) if (wc->header.total_samples != 0xFFFFFFFFu) st->duration = wc->header.total_samples; - if (s->pb->seekable) { + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t cur = avio_tell(s->pb); wc->apetag_start = ff_ape_parse_tag(s); if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) diff --git a/libavformat/wvenc.c b/libavformat/wvenc.c index 48e371aa13..8743739e8d 100644 --- a/libavformat/wvenc.c +++ b/libavformat/wvenc.c @@ -64,7 +64,7 @@ static av_cold int wv_write_trailer(AVFormatContext *ctx) WvMuxContext *s = ctx->priv_data; /* update total number of samples in the first block */ - if (ctx->pb->seekable && s->samples && + if ((ctx->pb->seekable & AVIO_SEEKABLE_NORMAL) && s->samples && s->samples < UINT32_MAX) { int64_t pos = avio_tell(ctx->pb); avio_seek(ctx->pb, 12, SEEK_SET); |