Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'

* commit '83548fe894cdb455cc127f754d09905b6d23c173':
  lavf: fix usage of AVIOContext.seekable

Merged-by: James Almer <jamrial@gmail.com>
pull/244/merge
James Almer 8 years ago
commit 4de591e6fb
  1. 2
      libavformat/aacdec.c
  2. 2
      libavformat/adp.c
  3. 4
      libavformat/aiffdec.c
  4. 4
      libavformat/aiffenc.c
  5. 2
      libavformat/ape.c
  6. 2
      libavformat/apngenc.c
  7. 8
      libavformat/asfdec_o.c
  8. 6
      libavformat/asfenc.c
  9. 2
      libavformat/astenc.c
  10. 2
      libavformat/au.c
  11. 4
      libavformat/avidec.c
  12. 24
      libavformat/avienc.c
  13. 2
      libavformat/aviobuf.c
  14. 2
      libavformat/bink.c
  15. 8
      libavformat/bintext.c
  16. 4
      libavformat/cafdec.c
  17. 4
      libavformat/cafenc.c
  18. 2
      libavformat/cinedec.c
  19. 2
      libavformat/dsfdec.c
  20. 2
      libavformat/dtshddec.c
  21. 2
      libavformat/dv.c
  22. 4
      libavformat/ffmdec.c
  23. 2
      libavformat/filmstripdec.c
  24. 2
      libavformat/flacenc.c
  25. 7
      libavformat/flvdec.c
  26. 2
      libavformat/gxfenc.c
  27. 2
      libavformat/icoenc.c
  28. 2
      libavformat/id3v1.c
  29. 2
      libavformat/ivfenc.c
  30. 2
      libavformat/matroskadec.c
  31. 32
      libavformat/matroskaenc.c
  32. 2
      libavformat/mlvdec.c
  33. 2
      libavformat/mmf.c
  34. 16
      libavformat/mov.c
  35. 2
      libavformat/movenc.c
  36. 2
      libavformat/mp3dec.c
  37. 2
      libavformat/mp3enc.c
  38. 2
      libavformat/mpc.c
  39. 2
      libavformat/mpc8.c
  40. 2
      libavformat/mpeg.c
  41. 2
      libavformat/mpegts.c
  42. 4
      libavformat/mvdec.c
  43. 4
      libavformat/mxfdec.c
  44. 2
      libavformat/mxfenc.c
  45. 2
      libavformat/nutdec.c
  46. 6
      libavformat/oggdec.c
  47. 2
      libavformat/r3d.c
  48. 2
      libavformat/rawenc.c
  49. 3
      libavformat/rmdec.c
  50. 6
      libavformat/rmenc.c
  51. 12
      libavformat/rsd.c
  52. 2
      libavformat/rsoenc.c
  53. 2
      libavformat/smjpegenc.c
  54. 2
      libavformat/soxenc.c
  55. 2
      libavformat/swfenc.c
  56. 2
      libavformat/takdec.c
  57. 2
      libavformat/tta.c
  58. 2
      libavformat/tty.c
  59. 2
      libavformat/utils.c
  60. 2
      libavformat/vc1testenc.c
  61. 2
      libavformat/voc_packet.c
  62. 6
      libavformat/wavdec.c
  63. 8
      libavformat/wavenc.c
  64. 4
      libavformat/wvdec.c
  65. 2
      libavformat/wvenc.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);

@ -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);

@ -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;
}

@ -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);

@ -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);
}

@ -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);

@ -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++) {

@ -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 */

@ -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);

@ -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));

@ -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;

@ -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);
}

@ -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) &&

@ -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 */

@ -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);

@ -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;

@ -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);

@ -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;

@ -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);
}

@ -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;

@ -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;

@ -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);

@ -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);

@ -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);

@ -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);

@ -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;
}

@ -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);
}

@ -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) {

@ -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);

@ -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++) {

@ -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;

@ -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;

@ -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);

@ -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)))))) {

@ -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);

@ -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)

@ -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++) {

@ -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))

@ -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);

@ -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? */);

@ -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)

@ -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);

@ -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);

@ -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);

@ -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);

@ -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

@ -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);

@ -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) {

@ -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);

@ -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;

@ -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;
}

@ -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;
}

@ -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);

@ -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;

@ -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);

@ -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);
}

@ -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);

@ -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;

@ -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;

@ -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);

@ -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);
}

@ -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);

@ -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);

@ -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))

@ -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);

Loading…
Cancel
Save