Commit 66e5b1df authored by Anton Khirnov's avatar Anton Khirnov Committed by Ronald S. Bultje
Browse files

avio: deprecate url_feof



AVIOContext.eof_reached should be used directly instead.
Signed-off-by: default avatarRonald S. Bultje <rsbultje@gmail.com>
parent 6a7e074e
......@@ -2568,7 +2568,7 @@ static int decode_thread(void *arg)
}
ret = av_read_frame(ic, pkt);
if (ret < 0) {
if (ret == AVERROR_EOF || url_feof(ic->pb))
if (ret == AVERROR_EOF || ic->pb->eof_reached)
eof=1;
if (url_ferror(ic->pb))
break;
......
......@@ -259,7 +259,7 @@ static int fourxm_read_packet(AVFormatContext *s,
return ret;
fourcc_tag = AV_RL32(&header[0]);
size = AV_RL32(&header[4]);
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
switch (fourcc_tag) {
......
......@@ -51,7 +51,7 @@ static int get_tag(AVIOContext *pb, uint32_t * tag)
{
int size;
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
*tag = avio_rl32(pb);
......
......@@ -122,7 +122,7 @@ static int amr_read_packet(AVFormatContext *s,
AVCodecContext *enc = s->streams[0]->codec;
int read, size = 0, toc, mode;
if (url_feof(s->pb))
if (s->pb->eof_reached)
{
return AVERROR(EIO);
}
......
......@@ -181,7 +181,7 @@ static int read_packet(AVFormatContext *s,
Page *p;
int tmp, record_size;
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);
if (anm->page < 0)
......
......@@ -337,7 +337,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
APEContext *ape = s->priv_data;
uint32_t extra_size = 8;
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);
if (ape->currentframe > ape->totalframes)
return AVERROR(EIO);
......
......@@ -224,7 +224,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
if (var)
free_segment_list(var);
c->finished = 0;
while (!url_feof(in)) {
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
......@@ -457,7 +457,7 @@ start:
if (var->pb && !var->pkt.data) {
ret = av_read_frame(var->ctx, &var->pkt);
if (ret < 0) {
if (!url_feof(var->pb))
if (!var->pb->eof_reached)
return ret;
reset_packet(&var->pkt);
}
......
......@@ -174,7 +174,7 @@ static int parse_playlist(URLContext *h, const char *url)
free_segment_list(s);
s->finished = 0;
while (!url_feof(in)) {
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
......
......@@ -639,7 +639,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
continue;
} else if (!ff_guidcmp(&g, &ff_asf_marker_header)) {
asf_read_marker(s, gsize);
} else if (url_feof(pb)) {
} else if (pb->eof_reached) {
return -1;
} else {
if (!s->keylen) {
......@@ -660,7 +660,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
avio_rl64(pb);
avio_r8(pb);
avio_r8(pb);
if (url_feof(pb))
if (pb->eof_reached)
return -1;
asf->data_offset = avio_tell(pb);
asf->packet_size_left = 0;
......@@ -745,12 +745,12 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
*/
if (url_ferror(pb) == AVERROR(EAGAIN))
return AVERROR(EAGAIN);
if (!url_feof(pb))
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
}
if ((c & 0x8f) == 0x82) {
if (d || e) {
if (!url_feof(pb))
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -1;
}
......@@ -886,7 +886,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk
ASFStream *asf_st = 0;
for (;;) {
int ret;
if(url_feof(pb))
if(pb->eof_reached)
return AVERROR_EOF;
if (asf->packet_size_left < FRAME_HEADER_SIZE
|| asf->packet_segments < 1) {
......@@ -1195,7 +1195,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
skip them until the simple index object is reached */
while (ff_guidcmp(&g, &index_guid)) {
int64_t gsize= avio_rl64(s->pb);
if (gsize < 24 || url_feof(s->pb)) {
if (gsize < 24 || s->pb->eof_reached) {
avio_seek(s->pb, current_pos, SEEK_SET);
return;
}
......
......@@ -92,7 +92,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
header_remaining= INT_MAX;
dst[0] = &st->codec->extradata;
dst[1] = &ass->event_buffer;
while(!url_feof(pb)){
while(!pb->eof_reached){
uint8_t line[MAX_LINESIZE];
len = ff_get_line(pb, line, sizeof(line));
......
......@@ -178,7 +178,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_ERROR, "pos:%"PRId64", len:%X\n", pos, len);
#endif
if(url_feof(pb))
if(pb->eof_reached)
return -1;
if(last_pos == pos || pos == base - 8)
......@@ -195,7 +195,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
avio_rl32(pb); /* size */
duration = avio_rl32(pb);
if(url_feof(pb))
if(pb->eof_reached)
return -1;
pos = avio_tell(pb);
......@@ -360,7 +360,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec_type = -1;
frame_period = 0;
for(;;) {
if (url_feof(pb))
if (pb->eof_reached)
goto fail;
tag = avio_rl32(pb);
size = avio_rl32(pb);
......@@ -989,7 +989,7 @@ resync:
}
memset(d, -1, sizeof(int)*8);
for(i=sync=avio_tell(pb); !url_feof(pb); i++) {
for(i=sync=avio_tell(pb); !pb->eof_reached; i++) {
int j;
for(j=0; j<7; j++)
......@@ -1145,7 +1145,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
#if defined(DEBUG_SEEK)
av_log(s, AV_LOG_DEBUG, "%d cum_len=%"PRId64"\n", len, ast->cum_len);
#endif
if(url_feof(pb))
if(pb->eof_reached)
return -1;
if(last_pos == pos)
......@@ -1203,7 +1203,7 @@ static int avi_load_index(AVFormatContext *s)
printf("movi_end=0x%"PRIx64"\n", avi->movi_end);
#endif
for(;;) {
if (url_feof(pb))
if (pb->eof_reached)
break;
tag = avio_rl32(pb);
size = avio_rl32(pb);
......
......@@ -432,6 +432,11 @@ attribute_deprecated int url_fgetc(AVIOContext *s);
/**
* @}
*/
/**
* @deprecated use AVIOContext.eof_reached
*/
attribute_deprecated int url_feof(AVIOContext *s);
#endif
AVIOContext *avio_alloc_context(
......@@ -494,12 +499,6 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
*/
int64_t avio_size(AVIOContext *s);
/**
* feof() equivalent for AVIOContext.
* @return non zero if and only if end of file
*/
int url_feof(AVIOContext *s);
int url_ferror(AVIOContext *s);
int av_url_read_fpause(AVIOContext *h, int pause);
......
......@@ -265,12 +265,14 @@ int64_t avio_size(AVIOContext *s)
return size;
}
#if FF_API_OLD_AVIO
int url_feof(AVIOContext *s)
{
if(!s)
return 0;
return s->eof_reached;
}
#endif
int url_ferror(AVIOContext *s)
{
......@@ -598,7 +600,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
}
if (size1 == size) {
if (url_ferror(s)) return url_ferror(s);
if (url_feof(s)) return AVERROR_EOF;
if (s->eof_reached) return AVERROR_EOF;
}
return size1 - size;
}
......@@ -621,7 +623,7 @@ int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size)
s->buf_ptr += len;
if (!len) {
if (url_ferror(s)) return url_ferror(s);
if (url_feof(s)) return AVERROR_EOF;
if (s->eof_reached) return AVERROR_EOF;
}
return len;
}
......@@ -928,11 +930,11 @@ char *url_fgets(AVIOContext *s, char *buf, int buf_size)
char *q;
c = avio_r8(s);
if (url_feof(s))
if (s->eof_reached)
return NULL;
q = buf;
for(;;) {
if (url_feof(s) || c == '\n')
if (s->eof_reached || c == '\n')
break;
if ((q - buf) < buf_size - 1)
*q++ = c;
......
......@@ -179,7 +179,7 @@ static int vid_read_packet(AVFormatContext *s,
int audio_length;
int ret_value;
if(vid->is_finished || url_feof(pb))
if(vid->is_finished || pb->eof_reached)
return AVERROR(EIO);
block_type = avio_r8(pb);
......
......@@ -109,7 +109,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
BFIContext *bfi = s->priv_data;
AVIOContext *pb = s->pb;
int ret, audio_offset, video_offset, chunk_size, audio_size = 0;
if (bfi->nframes == 0 || url_feof(pb)) {
if (bfi->nframes == 0 || pb->eof_reached) {
return AVERROR(EIO);
}
......@@ -117,7 +117,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
if (!bfi->avflag) {
uint32_t state = 0;
while(state != MKTAG('S','A','V','I')){
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
state = 256*state + avio_r8(pb);
}
......
......@@ -219,7 +219,7 @@ static int read_header(AVFormatContext *s,
/* parse each chunk */
found_data = 0;
while (!url_feof(pb)) {
while (!pb->eof_reached) {
/* stop at data chunk if seeking is not supported or
data chunk size is unknown */
......@@ -228,7 +228,7 @@ static int read_header(AVFormatContext *s,
tag = avio_rb32(pb);
size = avio_rb64(pb);
if (url_feof(pb))
if (pb->eof_reached)
break;
switch (tag) {
......@@ -307,7 +307,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
int res, pkt_size = 0, pkt_frames = 0;
int64_t left = CAF_MAX_PKT_SIZE;
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
/* don't read past end of data chunk */
......
......@@ -38,7 +38,7 @@ static int daud_header(AVFormatContext *s, AVFormatParameters *ap) {
static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
AVIOContext *pb = s->pb;
int ret, size;
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
size = avio_rb16(pb);
avio_rb16(pb); // unknown
......
......@@ -147,7 +147,7 @@ static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
hdr->video_frame_size = avio_rl32(pb);
hdr->audio_frame_size = avio_rl32(pb);
if (url_feof(pb) || url_ferror(pb))
if (pb->eof_reached || url_ferror(pb))
return AVERROR(EIO);
if (avio_rl32(pb) != 0xAA55AA55)
......
......@@ -412,7 +412,7 @@ static int dv_read_header(AVFormatContext *s,
state = avio_rb32(s->pb);
while ((state & 0xffffff7f) != 0x1f07003f) {
if (url_feof(s->pb)) {
if (s->pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
return -1;
}
......
......@@ -104,7 +104,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
ff_get_wav_header(pb, ast->codec, fsize);
// find 'data' chunk
while(avio_tell(pb) < c->vidpos && !url_feof(pb)){
while(avio_tell(pb) < c->vidpos && !pb->eof_reached){
tag = avio_rl32(pb);
fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break;
......@@ -162,7 +162,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
return 0;
}
avio_seek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){
while(!s->pb->eof_reached && c->frames){
avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
......
......@@ -109,7 +109,7 @@ static int process_audio_header_elements(AVFormatContext *s)
ea->sample_rate = -1;
ea->num_channels = 1;
while (!url_feof(pb) && inHeader) {
while (!pb->eof_reached && inHeader) {
int inSubheader;
uint8_t byte;
byte = avio_r8(pb);
......@@ -118,7 +118,7 @@ static int process_audio_header_elements(AVFormatContext *s)
case 0xFD:
av_log (s, AV_LOG_DEBUG, "entered audio subheader\n");
inSubheader = 1;
while (!url_feof(pb) && inSubheader) {
while (!pb->eof_reached && inSubheader) {
uint8_t subbyte;
subbyte = avio_r8(pb);
......
......@@ -91,7 +91,7 @@ static int ffm_resync(AVFormatContext *s, int state)
{
av_log(s, AV_LOG_ERROR, "resyncing\n");
while (state != PACKET_ID) {
if (url_feof(s->pb)) {
if (s->pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
return -1;
}
......
......@@ -48,7 +48,7 @@ static void get_line(AVIOContext *s, uint8_t *buf, int size)
buf[i++] = c;
}
buf[i] = 0;
} while (!url_feof(s) && (buf[0] == ';' || buf[0] == '#' || buf[0] == 0));
} while (!s->eof_reached && (buf[0] == ';' || buf[0] == '#' || buf[0] == 0));
}
static AVChapter *read_chapter(AVFormatContext *s)
......@@ -126,7 +126,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
AVMetadata **m = &s->metadata;
uint8_t line[1024];
while(!url_feof(s->pb)) {
while(!s->pb->eof_reached) {
get_line(s->pb, line, sizeof(line));
if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) {
......
......@@ -80,7 +80,7 @@ static int read_packet(AVFormatContext *s,
FilmstripDemuxContext *film = s->priv_data;
AVStream *st = s->streams[0];
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);
pkt->dts = avio_tell(s->pb) / (st->codec->width * (st->codec->height + film->leading) * 4);
pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height * 4);
......
......@@ -46,7 +46,7 @@ static int flac_read_header(AVFormatContext *s,
}
/* process metadata blocks */
while (!url_feof(s->pb) && !metadata_last) {
while (!s->pb->eof_reached && !metadata_last) {
avio_read(s->pb, header, 4);
ff_flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size);
......
......@@ -311,7 +311,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
dts = avio_rb24(s->pb);
dts |= avio_r8(s->pb) << 24;
// av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, dts:%d\n", type, size, dts);
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR_EOF;
avio_seek(s->pb, 3, SEEK_CUR); /* stream id, always 0 */
flags = 0;
......
......@@ -368,7 +368,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
#define READ_ONE() \
{ \
if (!max_interval-- || url_feof(pb)) \
if (!max_interval-- || pb->eof_reached) \
goto out; \
tmp = tmp << 8 | avio_r8(pb); \
}
......@@ -422,13 +422,13 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
AVIOContext *pb = s->pb;
GXFPktType pkt_type;
int pkt_len;
while (!url_feof(pb)) {
while (!pb->eof_reached) {
AVStream *st;
int track_type, track_id, ret;
int field_nr, field_info, skip = 0;
int stream_index;
if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {
if (!url_feof(pb))
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "sync lost\n");
return -1;
}
......
......@@ -227,7 +227,7 @@ static int idcin_read_packet(AVFormatContext *s,
unsigned char r, g, b;
unsigned char palette_buffer[768];
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);
if (idcin->next_chunk_is_video) {
......
......@@ -111,7 +111,7 @@ static int roq_read_packet(AVFormatContext *s,
while (!packet_read) {
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);
/* get the next chunk preamble */
......
......@@ -138,7 +138,7 @@ static int iff_read_header(AVFormatContext *s,
// codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
st->codec->codec_tag = avio_rl32(pb);
while(!url_feof(pb)) {
while(!pb->eof_reached) {
uint64_t orig_pos;
int res;
const char *metadata_tag = NULL;
......
......@@ -287,7 +287,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
infer_size(&codec->width, &codec->height, size[0]);
} else {
f[0] = s1->pb;
if (url_feof(f[0]))
if (f[0]->eof_reached)
return AVERROR(EIO);
size[0]= 4096;
}
......
......@@ -225,7 +225,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
return chunk_type;
/* read the next chunk, wherever the file happens to be pointing */
if (url_feof(pb))
if (pb->eof_reached)
return CHUNK_EOF;
if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
......@@ -271,7 +271,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
/* read the next chunk, wherever the file happens to be pointing */
if (url_feof(pb)) {
if (pb->eof_reached) {
chunk_type = CHUNK_EOF;
break;
}
......@@ -532,7 +532,7 @@ static int ipmovie_read_header(AVFormatContext *s,
while (memcmp(signature_buffer, signature, sizeof(signature))) {
memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR_EOF;
}
/* initialize private context members */
......
......@@ -90,7 +90,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
return ret < 0 ? ret : AVERROR_EOF;
while (memcmp(buf, LXF_IDENT, LXF_IDENT_LENGTH)) {
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR_EOF;
memmove(buf, &buf[1], LXF_IDENT_LENGTH-1);
......
......@@ -548,7 +548,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
* use it safely here to catch EOS. */
if (!(total = avio_r8(pb))) {
/* we might encounter EOS here */
if (!url_feof(pb)) {
if (!pb->eof_reached) {
int64_t pos = avio_tell(pb);
av_log(matroska->ctx, AV_LOG_ERROR,
"Read error at pos. %"PRIu64" (0x%"PRIx64")\n",
......
......@@ -266,7 +266,7 @@ static int mmf_read_packet(AVFormatContext *s,
AVStream *st;
int ret, size;
if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);
st = s->streams[0];
......
......@@ -259,7 +259,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (atom.size < 0)
atom.size = INT64_MAX;
while (total_size + 8 < atom.size && !url_feof(pb)) {
while (total_size + 8 < atom.size && !pb->eof_reached) {
int (*parse)(MOVContext*, AVIOContext*, MOVAtom) = NULL;
a.size = atom.size;