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.
This commit is contained in:
parent
8d1267932c
commit
83548fe894
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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++) {
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)) {
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)))))) {
|
||||
|
@ -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);
|
||||
|
@ -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++) {
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
@ -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? */);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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'):
|
||||
|
@ -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 */
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user