[FFmpeg-cvslog] lavf: fix usage of AVIOContext.seekable
Anton Khirnov
git at videolan.org
Tue Mar 21 22:03:43 EET 2017
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Sep 27 16:26:37 2016 +0200| [83548fe894cdb455cc127f754d09905b6d23c173] | committer: Anton Khirnov
lavf: fix usage of AVIOContext.seekable
It is supposed to be a flag. The only currently defined value is
AVIO_SEEKABLE_NORMAL, but other ones may be added in the future.
However all the current lavf code treats this field as a bool (mainly
for historical reasons).
Change all those cases to properly check for AVIO_SEEKABLE_NORMAL.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83548fe894cdb455cc127f754d09905b6d23c173
---
libavformat/aiffdec.c | 2 +-
libavformat/aiffenc.c | 2 +-
libavformat/ape.c | 2 +-
libavformat/apetag.c | 2 +-
libavformat/asfdec.c | 8 +++++---
libavformat/asfenc.c | 4 ++--
libavformat/au.c | 2 +-
libavformat/avidec.c | 5 +++--
libavformat/avienc.c | 18 +++++++++---------
libavformat/aviobuf.c | 2 +-
libavformat/bink.c | 2 +-
libavformat/cafdec.c | 4 ++--
libavformat/filmstripdec.c | 2 +-
libavformat/flacenc.c | 2 +-
libavformat/flvdec.c | 3 ++-
libavformat/gxfenc.c | 2 +-
libavformat/id3v1.c | 2 +-
libavformat/matroskadec.c | 2 +-
libavformat/matroskaenc.c | 14 +++++++-------
libavformat/mmf.c | 2 +-
libavformat/mov.c | 12 ++++++------
libavformat/movenc.c | 2 +-
libavformat/mp3enc.c | 2 +-
libavformat/mpc.c | 2 +-
libavformat/mpc8.c | 2 +-
libavformat/mpeg.c | 2 +-
libavformat/mpegts.c | 3 ++-
libavformat/mvdec.c | 4 ++--
libavformat/mxfdec.c | 4 ++--
libavformat/mxfenc.c | 2 +-
libavformat/nutdec.c | 2 +-
libavformat/oggdec.c | 2 +-
libavformat/r3d.c | 2 +-
libavformat/rmdec.c | 3 ++-
libavformat/rmenc.c | 6 +++---
libavformat/rsoenc.c | 2 +-
libavformat/smjpegenc.c | 2 +-
libavformat/soxenc.c | 2 +-
libavformat/swfenc.c | 2 +-
libavformat/takdec.c | 2 +-
libavformat/tty.c | 2 +-
libavformat/utils.c | 2 +-
libavformat/vc1testenc.c | 2 +-
libavformat/voc_packet.c | 2 +-
libavformat/wavdec.c | 2 +-
libavformat/wavenc.c | 4 ++--
libavformat/wvdec.c | 4 ++--
libavformat/wvenc.c | 2 +-
48 files changed, 84 insertions(+), 78 deletions(-)
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 3c45c61..481a92d 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -251,7 +251,7 @@ static int aiff_read_header(AVFormatContext *s)
offset += avio_tell(pb); /* Compute absolute data offset */
if (st->codecpar->block_align) /* 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 6449c00..191e746 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -129,7 +129,7 @@ static int aiff_write_trailer(AVFormatContext *s)
end_size++;
}
- if (s->pb->seekable) {
+ if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
/* File length */
avio_seek(pb, aiff->form, SEEK_SET);
avio_wb32(pb, file_size - aiff->form - 4);
diff --git a/libavformat/ape.c b/libavformat/ape.c
index bcc1f7a..80e3372 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -370,7 +370,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/apetag.c b/libavformat/apetag.c
index 044bfd8..05430dd 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -182,7 +182,7 @@ int ff_ape_write_tag(AVFormatContext *s)
int64_t start, end;
int size, count = 0;
- if (!s->pb->seekable)
+ if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
return 0;
start = avio_tell(s->pb);
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 7d71789..1c50ad6 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.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 dc1dd73..a40c02d 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -433,7 +433,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
avio_wl64(pb, play_duration); /* end time stamp (in 100ns units) */
avio_wl64(pb, send_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); /* Nominal data rate in bps */
@@ -954,7 +954,7 @@ static int asf_write_trailer(AVFormatContext *s)
asf_write_index(s, asf->index_ptr, asf->maximum_packet, asf->nb_index_count);
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/au.c b/libavformat/au.c
index e303142..20c9d41 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -192,7 +192,7 @@ static int au_write_trailer(AVFormatContext *s)
AVIOContext *pb = s->pb;
int64_t file_size;
- if (s->pb->seekable) {
+ if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
/* update file size */
file_size = avio_tell(pb);
avio_seek(pb, 8, SEEK_SET);
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 3666b57..ddc7c2b 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -761,7 +761,8 @@ static int avi_read_header(AVFormatContext *s)
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) &&
read_braindead_odml_indx(s, 0) < 0 &&
(s->error_recognition & AV_EF_EXPLODE))
goto fail;
@@ -828,7 +829,7 @@ fail:
return AVERROR_INVALIDDATA;
}
- if (!avi->index_loaded && pb->seekable)
+ if (!avi->index_loaded && (pb->seekable & AVIO_SEEKABLE_NORMAL))
avi_load_index(s);
avi->index_loaded = 1;
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index d89fab1..e474398 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -189,7 +189,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 */
@@ -261,7 +261,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
@@ -306,7 +306,7 @@ static int avi_write_header(AVFormatContext *s)
}
}
- if (pb->seekable) {
+ if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
unsigned char tag[5];
int j;
@@ -366,7 +366,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");
@@ -403,7 +403,7 @@ static int avi_write_ix(AVFormatContext *s)
char ix_tag[] = "ix00";
int i, j;
- assert(pb->seekable);
+ assert(pb->seekable & AVIO_SEEKABLE_NORMAL);
if (avi->riff_id > AVI_MASTER_INDEX_SIZE)
return -1;
@@ -461,7 +461,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;
@@ -528,7 +528,7 @@ static int avi_write_packet(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);
@@ -546,7 +546,7 @@ static int avi_write_packet(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 err;
AVIIndex *idx = &avist->indexes;
int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE;
@@ -588,7 +588,7 @@ static int avi_write_trailer(AVFormatContext *s)
int i, j, n, nb_frames;
int64_t file_size;
- 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);
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 706cf5d..39a11e2 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -265,7 +265,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
/* 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 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
!s->write_flag && offset1 >= 0 &&
(whence != SEEK_END || force)) {
diff --git a/libavformat/bink.c b/libavformat/bink.c
index 377db98..8f28212 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -267,7 +267,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/cafdec.c b/libavformat/cafdec.c
index 65bdcfc..efc8c49 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -249,7 +249,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);
@@ -262,7 +262,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/filmstripdec.c b/libavformat/filmstripdec.c
index b029d80..b5dad50 100644
--- a/libavformat/filmstripdec.c
+++ b/libavformat/filmstripdec.c
@@ -40,7 +40,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 3cee668..06985cf 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -130,7 +130,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 0d9a113..b82ea33 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -837,7 +837,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 60f88fd..32714f6 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -633,7 +633,7 @@ static int gxf_write_header(AVFormatContext *s)
uint8_t tracks[255] = {0};
int i, media_info = 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");
return -1;
}
diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c
index 87930ff..9420d9e 100644
--- a/libavformat/id3v1.c
+++ b/libavformat/id3v1.c
@@ -230,7 +230,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/matroskadec.c b/libavformat/matroskadec.c
index 7ccba57..991f86b 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1394,7 +1394,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) ||
(matroska->ctx->flags & AVFMT_FLAG_IGNIDX))
return;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index dd5552c..cfced72 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1252,14 +1252,14 @@ static int mkv_write_header(AVFormatContext *s)
return ret;
}
- if (!s->pb->seekable)
+ if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
mkv_write_seekhead(pb, mkv->main_seekhead);
mkv->cues = mkv_start_cues(mkv->segment_offset);
if (!mkv->cues)
return AVERROR(ENOMEM);
- 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);
}
@@ -1271,7 +1271,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)
@@ -1547,7 +1547,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
}
ts += mkv->tracks[pkt->stream_index].ts_offset;
- if (!s->pb->seekable) {
+ if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
if (!mkv->dyn_bc) {
ret = avio_open_dyn_buf(&mkv->dyn_bc);
if (ret < 0)
@@ -1613,7 +1613,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
// after 4k and on a keyframe
- if (s->pb->seekable) {
+ if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
pb = s->pb;
cluster_size = avio_tell(pb) - mkv->cluster_pos;
} else {
@@ -1666,7 +1666,7 @@ static int mkv_write_flush_packet(AVFormatContext *s, AVPacket *pkt)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb;
- if (s->pb->seekable)
+ if (s->pb->seekable & AVIO_SEEKABLE_NORMAL)
pb = s->pb;
else
pb = mkv->dyn_bc;
@@ -1717,7 +1717,7 @@ static int mkv_write_trailer(AVFormatContext *s)
return ret;
}
- if (pb->seekable) {
+ if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
if (mkv->cues->num_entries) {
if (mkv->reserve_cues_space) {
int64_t cues_end;
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index 55aeff4..454e609 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -140,7 +140,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 ca49716..36e75d5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3270,9 +3270,9 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (err < 0)
return err;
if (c->found_moov && c->found_mdat &&
- ((!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX) ||
+ ((!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX) ||
start_pos + a.size == avio_size(pb))) {
- if (!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX)
+ if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX)
c->next_root_atom = start_pos + a.size;
return 0;
}
@@ -3463,7 +3463,7 @@ static int mov_read_header(AVFormatContext *s)
mov->fc = s;
/* .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;
@@ -3481,7 +3481,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 && mov->chapter_track > 0)
+ if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && mov->chapter_track > 0)
mov_read_chapters(s);
for (i = 0; i < s->nb_streams; i++) {
@@ -3558,8 +3558,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 31b940a..f99617a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4037,7 +4037,7 @@ static int mov_write_header(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/mp3enc.c b/libavformat/mp3enc.c
index 1e2ff1a..d87d7be 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -141,7 +141,7 @@ static void mp3_write_xing(AVFormatContext *s)
int ver = 0;
int lsf, bytes_needed;
- if (!s->pb->seekable || !mp3->write_xing)
+ if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) || !mp3->write_xing)
return;
for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
diff --git a/libavformat/mpc.c b/libavformat/mpc.c
index cf8fe1e..5be50a7 100644
--- a/libavformat/mpc.c
+++ b/libavformat/mpc.c
@@ -105,7 +105,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 2349ea5..bd17c19 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -252,7 +252,7 @@ static int mpc8_read_header(AVFormatContext *s)
st->duration = c->samples / (1152 << (st->codecpar->extradata[1]&3)*2);
size -= avio_tell(pb) - pos;
- 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 f63e79f..0898353 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -378,7 +378,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 40672ae..28b6d37 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2087,7 +2087,8 @@ static int mpegts_read_header(AVFormatContext *s)
/* normal demux */
/* first do a scan to get all the services */
- if (avio_seek(pb, pos, SEEK_SET) < 0 && pb->seekable)
+ if (avio_seek(pb, pos, SEEK_SET) < 0 &&
+ (pb->seekable & AVIO_SEEKABLE_NORMAL))
av_log(s, AV_LOG_ERROR, "Unable to seek back to the start\n");
mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
index f13359c..52c5355 100644
--- a/libavformat/mvdec.c
+++ b/libavformat/mvdec.c
@@ -403,7 +403,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)
@@ -445,7 +445,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 449af95..1c7c280 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1933,7 +1933,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 last partition\n");
return -1;
}
@@ -2080,7 +2080,7 @@ static void mxf_read_random_index_pack(AVFormatContext *s)
int64_t file_size;
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 1431fc6..eb53dbf 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1805,7 +1805,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) {
avio_seek(pb, 0, SEEK_SET);
if (mxf->edit_unit_byte_count) {
if ((err = mxf_write_partition(s, 1, 2, header_closed_partition_key, 1)) < 0)
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index b554f85..e1a9f6d 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -765,7 +765,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 9ec2497..5965a97 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -509,7 +509,7 @@ static int ogg_get_length(AVFormatContext *s)
int i, ret;
int64_t size, end;
- 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 4b28379..9369cdd 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -184,7 +184,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/rmdec.c b/libavformat/rmdec.c
index 9774194..51a5bf7 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -519,7 +519,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 59118c9..6cbe700 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, (int)(stream->total_frames * 1000 / stream->frame_rate));
@@ -433,7 +433,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/rsoenc.c b/libavformat/rsoenc.c
index dd0fbf8..4f8278c 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 2a95059..91b0939 100644
--- a/libavformat/smjpegenc.c
+++ b/libavformat/smjpegenc.c
@@ -120,7 +120,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 ea05f36..d0f7d41 100644
--- a/libavformat/soxenc.c
+++ b/libavformat/soxenc.c
@@ -98,7 +98,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 f8db3e9..345688c 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -495,7 +495,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 b28d44c..19e0e69 100644
--- a/libavformat/takdec.c
+++ b/libavformat/takdec.c
@@ -101,7 +101,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/tty.c b/libavformat/tty.c
index d4c4873..f4535bb 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -103,7 +103,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 6df1a32..0e94b15 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1827,7 +1827,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);
} else if (has_duration(ic)) {
diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c
index dc23c14..c286f66 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 ff48d50..3865075 100644
--- a/libavformat/voc_packet.c
+++ b/libavformat/voc_packet.c
@@ -37,7 +37,7 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
return AVERROR(EIO);
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 4bd2642..8c78666 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -289,7 +289,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'):
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index 32d4bc1..fc7d49e 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -118,7 +118,7 @@ static int wav_write_header(AVFormatContext *s)
ff_end_tag(pb, fmt);
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);
@@ -164,7 +164,7 @@ static int wav_write_trailer(AVFormatContext *s)
avio_flush(pb);
- if (s->pb->seekable) {
+ if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
ff_end_tag(pb, wav->data);
/* update file size */
diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c
index c78bac1..717275c 100644
--- a/libavformat/wvdec.c
+++ b/libavformat/wvdec.c
@@ -116,7 +116,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;
@@ -237,7 +237,7 @@ static int wv_read_header(AVFormatContext *s)
st->start_time = 0;
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 a753c19..63f1ea6 100644
--- a/libavformat/wvenc.c
+++ b/libavformat/wvenc.c
@@ -60,7 +60,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);
More information about the ffmpeg-cvslog
mailing list