diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-04-04 02:15:12 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-04-04 02:15:12 +0200 |
commit | 2cae9809e2d59c7336fc2cccb97b82c7f764868a (patch) | |
tree | 823d962b7237e515e14e2679084e5981d5b808a5 /libavformat | |
parent | 3c9bfb336867ccd32a6e8490930961bcc14b3fdc (diff) | |
parent | 906fd03070c7dc39b4c937befa2c3559bccf7ba7 (diff) | |
download | ffmpeg-2cae9809e2d59c7336fc2cccb97b82c7f764868a.tar.gz |
Merge remote branch 'qatar/master'
* qatar/master:
fate: fix partial run when no samples path is specified
ARM: NEON fixed-point forward MDCT
ARM: NEON fixed-point FFT
lavf: bump minor version and add an APIChanges entry for avio changes
avio: simplify url_open_dyn_buf_internal by using avio_alloc_context()
avio: make url_fdopen internal.
avio: make url_open_dyn_packet_buf internal.
avio: avio_ prefix for url_close_dyn_buf
avio: avio_ prefix for url_open_dyn_buf
avio: introduce an AVIOContext.seekable field
ac3enc: use generic fixed-point mdct
lavfi: add fade filter
Change yadif to not use out of picture lines.
lavc: deprecate AVCodecContext.antialias_algo
lavc: mark mb_qmin/mb_qmax for removal on next major bump.
Conflicts:
doc/filters.texi
libavcodec/ac3enc_fixed.h
libavcodec/ac3enc_float.h
libavfilter/Makefile
libavfilter/allfilters.c
libavfilter/vf_fade.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
54 files changed, 221 insertions, 187 deletions
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index c43ee32adc..25a93f5fb9 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -238,7 +238,7 @@ static int aiff_read_header(AVFormatContext *s, offset += avio_tell(pb); /* Compute absolute data offset */ if (st->codec->block_align) /* Assume COMM already parsed */ goto got_sound; - if (url_is_streamed(pb)) { + if (!pb->seekable) { av_log(s, AV_LOG_ERROR, "file is not seekable\n"); return -1; } diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 6fc09aeb63..cc3cbc4762 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -124,7 +124,7 @@ static int aiff_write_trailer(AVFormatContext *s) end_size++; } - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* 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 28b80b25aa..d63b2ac40d 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -296,7 +296,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) ape_dumpinfo(s, ape); /* try to read APE tags */ - if (!url_is_streamed(pb)) { + if (pb->seekable) { ff_ape_parse_tag(s); avio_seek(pb, 0, SEEK_SET); } diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 36b9472018..fe5a67ce4b 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -234,11 +234,11 @@ static void put_str16(AVIOContext *s, const char *tag) int len; uint8_t *pb; AVIOContext *dyn_buf; - if (url_open_dyn_buf(&dyn_buf) < 0) + if (avio_open_dyn_buf(&dyn_buf) < 0) return; avio_put_str16le(dyn_buf, tag); - len = url_close_dyn_buf(dyn_buf, &pb); + len = avio_close_dyn_buf(dyn_buf, &pb); avio_wl16(s, len); avio_write(s, pb, len); av_freep(&pb); @@ -347,7 +347,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data 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 || url_is_streamed(pb)) ? 3 : 2); /* ??? */ + avio_wl32(pb, (asf->is_streamed || !pb->seekable ) ? 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 */ @@ -366,7 +366,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data uint8_t *buf; AVIOContext *dyn_buf; - if (url_open_dyn_buf(&dyn_buf) < 0) + if (avio_open_dyn_buf(&dyn_buf) < 0) return AVERROR(ENOMEM); hpos = put_header(pb, &ff_asf_comment_header); @@ -375,7 +375,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0; avio_wl16(pb, len); } - len = url_close_dyn_buf(dyn_buf, &buf); + len = avio_close_dyn_buf(dyn_buf, &buf); avio_write(pb, buf, len); av_freep(&buf); end_header(pb, hpos); @@ -497,11 +497,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data else desc = p ? p->name : enc->codec_name; - if ( url_open_dyn_buf(&dyn_buf) < 0) + if ( avio_open_dyn_buf(&dyn_buf) < 0) return AVERROR(ENOMEM); avio_put_str16le(dyn_buf, desc); - len = url_close_dyn_buf(dyn_buf, &buf); + len = avio_close_dyn_buf(dyn_buf, &buf); avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2 avio_write(pb, buf, len); @@ -866,7 +866,7 @@ static int asf_write_trailer(AVFormatContext *s) } avio_flush(s->pb); - if (asf->is_streamed || url_is_streamed(s->pb)) { + if (asf->is_streamed || !s->pb->seekable) { 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 9c674ac6f6..23365c4734 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -91,7 +91,7 @@ static int au_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; int64_t file_size; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* update file size */ file_size = avio_tell(pb); diff --git a/libavformat/avc.c b/libavformat/avc.c index a39343b1ca..ed2125b527 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -89,14 +89,14 @@ int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size) int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) { AVIOContext *pb; - int ret = url_open_dyn_buf(&pb); + int ret = avio_open_dyn_buf(&pb); if(ret < 0) return ret; ff_avc_parse_nal_units(pb, buf_in, *size); av_freep(buf); - *size = url_close_dyn_buf(pb, buf); + *size = avio_close_dyn_buf(pb, buf); return 0; } diff --git a/libavformat/avidec.c b/libavformat/avidec.c index b605c45d2b..ad0d098a12 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -665,7 +665,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) break; case MKTAG('i', 'n', 'd', 'x'): i= avio_tell(pb); - if(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX)){ + if(pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX)){ read_braindead_odml_indx(s, 0); } avio_seek(pb, i+size, SEEK_SET); @@ -721,7 +721,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) return -1; } - if(!avi->index_loaded && !url_is_streamed(pb)) + if(!avi->index_loaded && pb->seekable) avi_load_index(s); avi->index_loaded = 1; avi->non_interleaved |= guess_ni_flag(s); diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 3743abb8d7..ff74c3b492 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -197,7 +197,7 @@ static int avi_write_header(AVFormatContext *s) } avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */ avio_wl32(pb, 0); /* padding */ - if (url_is_streamed(pb)) + if (!pb->seekable) avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */ else avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */ @@ -259,7 +259,7 @@ static int avi_write_header(AVFormatContext *s) avio_wl32(pb, 0); /* start */ avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */ - if (url_is_streamed(pb)) + if (!pb->seekable) avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */ else avio_wl32(pb, 0); /* length, XXX: filled later */ @@ -303,7 +303,7 @@ static int avi_write_header(AVFormatContext *s) } } - if (!url_is_streamed(pb)) { + if (pb->seekable) { unsigned char tag[5]; int j; @@ -362,7 +362,7 @@ static int avi_write_header(AVFormatContext *s) ff_end_tag(pb, list2); } - if (!url_is_streamed(pb)) { + if (pb->seekable) { /* AVI could become an OpenDML one, if it grows beyond 2Gb range */ avi->odml_list = ff_start_tag(pb, "JUNK"); ffio_wfourcc(pb, "odml"); @@ -406,7 +406,7 @@ static int avi_write_ix(AVFormatContext *s) char ix_tag[] = "ix00"; int i, j; - assert(!url_is_streamed(pb)); + assert(pb->seekable); if (avi->riff_id > AVI_MASTER_INDEX_SIZE) return -1; @@ -464,7 +464,7 @@ static int avi_write_idx1(AVFormatContext *s) int i; char tag[5]; - if (!url_is_streamed(pb)) { + if (pb->seekable) { AVIStream *avist; AVIIentry* ie = 0, *tie; int empty, stream_id = -1; @@ -532,7 +532,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 (!url_is_streamed(pb) && + if (pb->seekable && (avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) { avi_write_ix(s); @@ -552,7 +552,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) avist->audio_strm_length += size; } - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { AVIIndex* idx = &avist->indexes; int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE; int id = idx->entry % AVI_INDEX_CLUSTER_SIZE; @@ -590,7 +590,7 @@ static int avi_write_trailer(AVFormatContext *s) int i, j, n, nb_frames; int64_t file_size; - if (!url_is_streamed(pb)){ + if (pb->seekable){ if (avi->riff_id == 1) { ff_end_tag(pb, avi->movi_list); res = avi_write_idx1(s); diff --git a/libavformat/avio.h b/libavformat/avio.h index 710246854b..19b57b2261 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -332,6 +332,8 @@ attribute_deprecated int av_register_protocol(URLProtocol *protocol); */ int av_register_protocol2(URLProtocol *protocol, int size); +#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */ + /** * Bytestream IO Context. * New fields can be added to the end with minor version bumps. @@ -351,7 +353,9 @@ typedef struct { int must_flush; /**< true if the next seek should flush */ int eof_reached; /**< true if eof reached */ int write_flag; /**< true if open for writing */ - int is_streamed; +#if FF_API_OLD_AVIO + attribute_deprecated int is_streamed; +#endif int max_packet_size; unsigned long checksum; unsigned char *checksum_ptr; @@ -360,6 +364,10 @@ typedef struct { int (*read_pause)(void *opaque, int pause); int64_t (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags); + /** + * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. + */ + int seekable; } AVIOContext; #if FF_API_OLD_AVIO @@ -439,6 +447,10 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __att attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); #endif attribute_deprecated void put_flush_packet(AVIOContext *s); +attribute_deprecated int url_open_dyn_buf(AVIOContext **s); +attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); +attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); +attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h); /** * @} */ @@ -603,23 +615,15 @@ unsigned int avio_rb24(AVIOContext *s); unsigned int avio_rb32(AVIOContext *s); uint64_t avio_rb64(AVIOContext *s); -static inline int url_is_streamed(AVIOContext *s) -{ - return s->is_streamed; -} - +#if FF_API_OLD_AVIO /** - * Create and initialize a AVIOContext for accessing the - * resource referenced by the URLContext h. - * @note When the URLContext h has been opened in read+write mode, the - * AVIOContext can be used only for writing. - * - * @param s Used to return the pointer to the created AVIOContext. - * In case of failure the pointed to value is set to NULL. - * @return 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure + * @deprecated Use AVIOContext.seekable field directly. */ -int url_fdopen(AVIOContext **s, URLContext *h); +attribute_deprecated static inline int url_is_streamed(AVIOContext *s) +{ + return !s->seekable; +} +#endif #if FF_API_URL_RESETBUF /** Reset the buffer for reading or writing. @@ -666,30 +670,18 @@ attribute_deprecated int url_close_buf(AVIOContext *s); * @param s new IO context * @return zero if no error. */ -int url_open_dyn_buf(AVIOContext **s); - -/** - * Open a write only packetized memory stream with a maximum packet - * size of 'max_packet_size'. The stream is stored in a memory buffer - * with a big endian 4 byte header giving the packet size in bytes. - * - * @param s new IO context - * @param max_packet_size maximum packet size (must be > 0) - * @return zero if no error. - */ -int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); +int avio_open_dyn_buf(AVIOContext **s); /** * Return the written size and a pointer to the buffer. The buffer - * must be freed with av_free(). If the buffer is opened with - * url_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is - * added; if opened with url_open_dyn_packet_buf, no padding is added. + * must be freed with av_free(). + * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. * * @param s IO context * @param pbuffer pointer to a byte buffer * @return the length of the byte buffer */ -int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); +int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); #if FF_API_UDP_GET_FILE int udp_get_file_handle(URLContext *h); diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 343a1185ea..bf2ddb2daf 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -81,4 +81,28 @@ unsigned long ffio_get_checksum(AVIOContext *s); unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len); +/** + * Open a write only packetized memory stream with a maximum packet + * size of 'max_packet_size'. The stream is stored in a memory buffer + * with a big endian 4 byte header giving the packet size in bytes. + * + * @param s new IO context + * @param max_packet_size maximum packet size (must be > 0) + * @return zero if no error. + */ +int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); + +/** + * Create and initialize a AVIOContext for accessing the + * resource referenced by the URLContext h. + * @note When the URLContext h has been opened in read+write mode, the + * AVIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created AVIOContext. + * In case of failure the pointed to value is set to NULL. + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int ffio_fdopen(AVIOContext **s, URLContext *h); + #endif // AVFORMAT_AVIO_INTERNAL_H diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 9ba82d3e94..5396eb1635 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -62,7 +62,10 @@ int ffio_init_context(AVIOContext *s, s->must_flush = 0; s->eof_reached = 0; s->error = 0; +#if FF_API_OLD_AVIO s->is_streamed = 0; +#endif + s->seekable = AVIO_SEEKABLE_NORMAL; s->max_packet_size = 0; s->update_checksum= NULL; if(!read_packet && !write_flag){ @@ -202,7 +205,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->is_streamed || + } else if ((!s->seekable || offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) && !s->write_flag && offset1 >= 0 && (whence != SEEK_END || force)) { @@ -425,6 +428,22 @@ unsigned long get_checksum(AVIOContext *s) { return ffio_get_checksum(s); } +int url_open_dyn_buf(AVIOContext **s) +{ + return avio_open_dyn_buf(s); +} +int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) +{ + return ffio_open_dyn_packet_buf(s, max_packet_size); +} +int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) +{ + return avio_close_dyn_buf(s, pbuffer); +} +int url_fdopen(AVIOContext **s, URLContext *h) +{ + return ffio_fdopen(s, h); +} #endif int avio_put_str(AVIOContext *s, const char *str) @@ -812,7 +831,7 @@ uint64_t ffio_read_varlen(AVIOContext *bc){ return val; } -int url_fdopen(AVIOContext **s, URLContext *h) +int ffio_fdopen(AVIOContext **s, URLContext *h) { uint8_t *buffer; int buffer_size, max_packet_size; @@ -840,7 +859,10 @@ int url_fdopen(AVIOContext **s, URLContext *h) av_freep(s); return AVERROR(EIO); } +#if FF_API_OLD_AVIO (*s)->is_streamed = h->is_streamed; +#endif + (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL; (*s)->max_packet_size = max_packet_size; if(h->prot) { (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause; @@ -934,7 +956,7 @@ int avio_open(AVIOContext **s, const char *filename, int flags) err = url_open(&h, filename, flags); if (err < 0) return err; - err = url_fdopen(s, h); + err = ffio_fdopen(s, h); if (err < 0) { url_close(h); return err; @@ -1026,7 +1048,7 @@ int64_t ffio_read_seek(AVIOContext *s, int stream_index, return ret; } -/* url_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response +/* avio_open_dyn_buf and avio_close_dyn_buf are used in rtp.c to send a response * back to the server even if CONFIG_MUXERS is false. */ #if CONFIG_MUXERS || CONFIG_NETWORK /* buffer handling */ @@ -1123,7 +1145,6 @@ static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence) static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) { DynBuffer *d; - int ret; unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024; if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size) @@ -1131,38 +1152,31 @@ static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) d = av_mallocz(sizeof(DynBuffer) + io_buffer_size); if (!d) return AVERROR(ENOMEM); - *s = av_mallocz(sizeof(AVIOContext)); + d->io_buffer_size = io_buffer_size; + *s = avio_alloc_context(d->io_buffer, d->io_buffer_size, 1, d, NULL, + max_packet_size ? dyn_packet_buf_write : dyn_buf_write, + max_packet_size ? NULL : dyn_buf_seek); if(!*s) { av_free(d); return AVERROR(ENOMEM); } - d->io_buffer_size = io_buffer_size; - ret = ffio_init_context(*s, d->io_buffer, io_buffer_size, - 1, d, NULL, - max_packet_size ? dyn_packet_buf_write : dyn_buf_write, - max_packet_size ? NULL : dyn_buf_seek); - if (ret == 0) { - (*s)->max_packet_size = max_packet_size; - } else { - av_free(d); - av_freep(s); - } - return ret; + (*s)->max_packet_size = max_packet_size; + return 0; } -int url_open_dyn_buf(AVIOContext **s) +int avio_open_dyn_buf(AVIOContext **s) { return url_open_dyn_buf_internal(s, 0); } -int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) +int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) { if (max_packet_size <= 0) return -1; return url_open_dyn_buf_internal(s, max_packet_size); } -int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) +int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { DynBuffer *d = s->opaque; int size; diff --git a/libavformat/bink.c b/libavformat/bink.c index 4622f89e5a..3bcaff3c51 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -247,7 +247,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 (url_is_streamed(s->pb)) + if (!s->pb->seekable) return -1; /* seek to the first frame */ diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 217f4db633..16c4674589 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -223,7 +223,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 || url_is_streamed(pb))) + if (found_data && (caf->data_size < 0 || !pb->seekable)) break; tag = avio_rb32(pb); @@ -236,7 +236,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 && !url_is_streamed(pb)) + if (caf->data_size > 0 && pb->seekable) avio_skip(pb, caf->data_size); found_data = 1; break; diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index a54bee059d..a42bb69679 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -281,7 +281,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; ffm->write_index = avio_rb64(pb); /* get also filesize */ - if (!url_is_streamed(pb)) { + if (pb->seekable) { ffm->file_size = avio_size(pb); if (ffm->write_index) adjust_write_index(s); diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c index 46d0635e9d..60c17819e8 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 (url_is_streamed(s->pb)) + if (!s->pb->seekable) return AVERROR(EIO); avio_seek(pb, avio_size(pb) - 36, SEEK_SET); diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index e7605f5b23..1674527816 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -98,7 +98,7 @@ static int flac_write_trailer(struct AVFormatContext *s) if (!ff_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) return -1; - if (!url_is_streamed(pb)) { + if (pb->seekable) { /* 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 ccaee9247a..a63fffdde9 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -428,7 +428,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) } // if not streamed and no duration from metadata then seek to end to find the duration from the timestamps - if(!url_is_streamed(s->pb) && (!s->duration || s->duration==AV_NOPTS_VALUE)){ + if(s->pb->seekable && (!s->duration || s->duration==AV_NOPTS_VALUE)){ int size; const int64_t pos= avio_tell(s->pb); const int64_t fsize= avio_size(s->pb); @@ -530,7 +530,7 @@ static int flv_read_seek2(AVFormatContext *s, int stream_index, if (ts - min_ts > (uint64_t)(max_ts - ts)) flags |= AVSEEK_FLAG_BACKWARD; - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { if (stream_index < 0) { stream_index = av_find_default_stream_index(s); if (stream_index < 0) diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index e6c44d6fd9..08270c8f66 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -634,7 +634,7 @@ static int gxf_write_header(AVFormatContext *s) uint8_t tracks[255] = {0}; int i, media_info = 0; - if (url_is_streamed(pb)) { + if (!pb->seekable) { 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 365c3e0fab..37d46956ef 100644 --- a/libavformat/id3v1.c +++ b/libavformat/id3v1.c @@ -229,7 +229,7 @@ void ff_id3v1_read(AVFormatContext *s) uint8_t buf[ID3v1_TAG_SIZE]; int64_t filesize, position = avio_tell(s->pb); - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* XXX: change that */ filesize = avio_size(s->pb); if (filesize > 128) { diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 3358e038f5..e69b848f78 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1120,7 +1120,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) int i; // we should not do any seeking in the streaming case - if (url_is_streamed(matroska->ctx->pb) || + if (!matroska->ctx->pb->seekable || (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)) return; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 973f31c129..732a5855ab 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -455,7 +455,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo uint8_t *codecpriv; int ret, codecpriv_size; - ret = url_open_dyn_buf(&dyn_cp); + ret = avio_open_dyn_buf(&dyn_cp); if(ret < 0) return ret; @@ -498,7 +498,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo ff_put_wav_header(dyn_cp, codec); } - codecpriv_size = url_close_dyn_buf(dyn_cp, &codecpriv); + codecpriv_size = avio_close_dyn_buf(dyn_cp, &codecpriv); if (codecpriv_size) put_ebml_binary(pb, MATROSKA_ID_CODECPRIVATE, codecpriv, codecpriv_size); av_free(codecpriv); @@ -852,7 +852,7 @@ static int mkv_write_header(AVFormatContext *s) if (ret < 0) return ret; } - if (url_is_streamed(s->pb)) + if (!s->pb->seekable) mkv_write_seekhead(pb, mkv->main_seekhead); mkv->cues = mkv_start_cues(mkv->segment_offset); @@ -1007,7 +1007,7 @@ static void mkv_flush_dynbuf(AVFormatContext *s) if (!mkv->dyn_bc) return; - bufsize = url_close_dyn_buf(mkv->dyn_bc, &dyn_buf); + bufsize = avio_close_dyn_buf(mkv->dyn_bc, &dyn_buf); avio_write(s->pb, dyn_buf, bufsize); av_free(dyn_buf); mkv->dyn_bc = NULL; @@ -1028,9 +1028,9 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt) return AVERROR(EINVAL); } - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { if (!mkv->dyn_bc) - url_open_dyn_buf(&mkv->dyn_bc); + avio_open_dyn_buf(&mkv->dyn_bc); pb = mkv->dyn_bc; } @@ -1080,16 +1080,16 @@ static int mkv_copy_packet(MatroskaMuxContext *mkv, const AVPacket *pkt) static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaMuxContext *mkv = s->priv_data; - AVIOContext *pb = url_is_streamed(s->pb) ? mkv->dyn_bc : s->pb; + AVIOContext *pb = s->pb->seekable ? s->pb : mkv->dyn_bc; AVCodecContext *codec = s->streams[pkt->stream_index]->codec; int ret, keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY); int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; - int cluster_size = avio_tell(pb) - (url_is_streamed(s->pb) ? 0 : mkv->cluster_pos); + int cluster_size = avio_tell(pb) - (s->pb->seekable ? mkv->cluster_pos : 0); // start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or // after 4k and on a keyframe if (mkv->cluster_pos && - ((url_is_streamed(s->pb) && (cluster_size > 32*1024 || ts > mkv->cluster_pts + 1000)) + ((!s->pb->seekable && (cluster_size > 32*1024 || ts > mkv->cluster_pts + 1000)) || cluster_size > 5*1024*1024 || ts > mkv->cluster_pts + 5000 || (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe && cluster_size > 4*1024))) { av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64 @@ -1143,7 +1143,7 @@ static int mkv_write_trailer(AVFormatContext *s) end_ebml_master(pb, mkv->cluster); } - if (!url_is_streamed(pb)) { + if (pb->seekable) { cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams); ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES , cuespos); diff --git a/libavformat/mmf.c b/libavformat/mmf.c index 4605bf7fbd..fc6fcc3caa 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -133,7 +133,7 @@ static int mmf_write_trailer(AVFormatContext *s) int64_t pos, size; int gatetime; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* 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 c08b07e55d..a4cd4d6b28 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -304,7 +304,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (err < 0) return err; if (c->found_moov && c->found_mdat && - (url_is_streamed(pb) || start_pos + a.size == avio_size(pb))) + (!pb->seekable || start_pos + a.size == avio_size(pb))) return 0; left = a.size - avio_tell(pb) + start_pos; if (left > 0) /* skip garbage at atom end */ @@ -2354,7 +2354,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) mov->fc = s; /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ - if(!url_is_streamed(pb)) + if(pb->seekable) atom.size = avio_size(pb); else atom.size = INT64_MAX; @@ -2370,7 +2370,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) } av_dlog(mov->fc, "on_parse_exit_offset=%lld\n", avio_tell(pb)); - if (!url_is_streamed(pb) && mov->chapter_track > 0) + if (pb->seekable && mov->chapter_track > 0) mov_read_chapters(s); return 0; @@ -2388,8 +2388,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_dlog(s, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts); - if (!sample || (url_is_streamed(s->pb) && current_sample->pos < sample->pos) || - (!url_is_streamed(s->pb) && + if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) || + (s->pb->seekable && ((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)))))) { @@ -2413,7 +2413,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sample = mov_find_next_sample(s, &st); if (!sample) { mov->found_mdat = 0; - if (!url_is_streamed(s->pb) || + if (s->pb->seekable|| mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || url_feof(s->pb)) return AVERROR_EOF; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index fe529179ee..599c913b35 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1653,7 +1653,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, return 0; } - ret = url_open_dyn_buf(&pb_buf); + ret = avio_open_dyn_buf(&pb_buf); if(ret < 0) return ret; @@ -1684,7 +1684,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, if (s->nb_chapters) mov_write_chpl_tag(pb_buf, s); - if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) { + if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) { avio_wb32(pb, size+8); ffio_wfourcc(pb, "udta"); avio_write(pb, buf, size); @@ -1948,7 +1948,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) unsigned int samplesInChunk = 0; int size= pkt->size; - if (url_is_streamed(s->pb)) return 0; /* Can't handle that */ + if (!s->pb->seekable) return 0; /* Can't handle that */ if (!size) return 0; /* Discard 0 sized packets */ if (enc->codec_id == CODEC_ID_AMR_NB) { @@ -2083,7 +2083,7 @@ static int mov_write_header(AVFormatContext *s) MOVMuxContext *mov = s->priv_data; int i, hint_track = 0; - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return -1; } diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index 21793cdd47..4e69c73407 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "internal.h" #include "rtpenc_chain.h" +#include "avio_internal.h" int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) { @@ -408,8 +409,8 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, /* Fetch the output from the RTP muxer, open a new output buffer * for next time. */ - size = url_close_dyn_buf(rtp_ctx->pb, &buf); - if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, + size = avio_close_dyn_buf(rtp_ctx->pb, &buf); + if ((ret = ffio_open_dyn_packet_buf(&rtp_ctx->pb, RTP_MAX_PACKET_SIZE)) < 0) goto done; @@ -417,14 +418,14 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, goto done; /* Open a buffer for writing the hint */ - if ((ret = url_open_dyn_buf(&hintbuf)) < 0) + if ((ret = avio_open_dyn_buf(&hintbuf)) < 0) goto done; av_init_packet(&hint_pkt); count = write_hint_packets(hintbuf, buf, size, trk, &hint_pkt.dts); av_freep(&buf); /* Write the hint data into the hint track */ - hint_pkt.size = size = url_close_dyn_buf(hintbuf, &buf); + hint_pkt.size = size = avio_close_dyn_buf(hintbuf, &buf); hint_pkt.data = buf; hint_pkt.pts = hint_pkt.dts; hint_pkt.stream_index = track_index; @@ -448,7 +449,7 @@ void ff_mov_close_hinting(MOVTrack *track) { return; if (rtp_ctx->pb) { av_write_trailer(rtp_ctx); - url_close_dyn_buf(rtp_ctx->pb, &ptr); + avio_close_dyn_buf(rtp_ctx->pb, &ptr); av_free(ptr); } avformat_free_context(rtp_ctx); diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 88b1475313..a19769bbb0 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -96,7 +96,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 uint8_t *pb; int (*put)(AVIOContext*, const char*); AVIOContext *dyn_buf; - if (url_open_dyn_buf(&dyn_buf) < 0) + if (avio_open_dyn_buf(&dyn_buf) < 0) return AVERROR(ENOMEM); /* check if the strings are ASCII-only and use UTF16 only if @@ -115,7 +115,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 put(dyn_buf, str1); if (str2) put(dyn_buf, str2); - len = url_close_dyn_buf(dyn_buf, &pb); + len = avio_close_dyn_buf(dyn_buf, &pb); avio_wb32(s->pb, tag); id3v2_put_size(s, len); diff --git a/libavformat/mpc.c b/libavformat/mpc.c index b9c5dc993e..3544cf11cf 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -93,7 +93,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) st->duration = c->fcount; /* try to read APE tags */ - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { int64_t pos = avio_tell(s->pb); ff_ape_parse_tag(s); if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 47be6d2bbe..f9f818951f 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -403,7 +403,7 @@ static int mpegps_read_pes_header(AVFormatContext *s, int i; for(i=0; i<s->nb_streams; i++){ if(startcode == s->streams[i]->id && - !url_is_streamed(s->pb) /* index useless on streams anyway */) { + s->pb->seekable /* 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/mxfenc.c b/libavformat/mxfenc.c index 8cf5d93257..c6532a3427 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1784,7 +1784,7 @@ static int mxf_write_footer(AVFormatContext *s) mxf_write_klv_fill(s); mxf_write_random_index_pack(s); - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { avio_seek(pb, 0, SEEK_SET); if (mxf->edit_unit_byte_count) { mxf_write_partition(s, 1, 2, header_closed_partition_key, 1); diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index bd77f785dc..2957a2b173 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -653,7 +653,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) s->data_offset= pos-8; - if(!url_is_streamed(bc)){ + if(bc->seekable){ int64_t orig_pos= avio_tell(bc); find_and_decode_index(nut); avio_seek(bc, orig_pos, SEEK_SET); diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 9bb9a4e502..47eaa2c81c 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -281,7 +281,7 @@ static inline void put_s_trace(AVIOContext *bc, int64_t v, char *file, char *fun //FIXME remove calculate_checksum static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, int calculate_checksum, uint64_t startcode){ uint8_t *dyn_buf=NULL; - int dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); + int dyn_size= avio_close_dyn_buf(dyn_bc, &dyn_buf); int forw_ptr= dyn_size + 4*calculate_checksum; if(forw_ptr > 4096) @@ -436,7 +436,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){ AVIOContext *dyn_bc; uint8_t *dyn_buf=NULL; int count=0, dyn_size; - int ret = url_open_dyn_buf(&dyn_bc); + int ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; @@ -450,7 +450,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){ ff_put_v(bc, count); - dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); + dyn_size= avio_close_dyn_buf(dyn_bc, &dyn_buf); avio_write(bc, dyn_buf, dyn_size); av_free(dyn_buf); return 0; @@ -462,7 +462,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){ AVIOContext *dyn_bc; uint8_t *dyn_buf=NULL; int count=0, dyn_size, i; - int ret = url_open_dyn_buf(&dyn_bc); + int ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; @@ -470,7 +470,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){ if (st->disposition & ff_nut_dispositions[i].flag) count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str); } - dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf); + dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); if (count) { ff_put_v(bc, stream_id + 1); //stream_id_plus1 @@ -495,7 +495,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) AVChapter *ch = nut->avf->chapters[id]; int ret, dyn_size, count = 0; - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if (ret < 0) return ret; @@ -509,7 +509,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, int id) ff_put_v(bc, count); - dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf); + dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); avio_write(bc, dyn_buf, dyn_size); av_freep(&dyn_buf); return 0; @@ -522,14 +522,14 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ ff_metadata_conv_ctx(avctx, ff_nut_metadata_conv, NULL); - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; write_mainheader(nut, dyn_bc); put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE); for (i=0; i < nut->avf->nb_streams; i++){ - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; if ((ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i)) < 0) @@ -537,14 +537,14 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE); } - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; write_globalinfo(nut, dyn_bc); put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); for (i = 0; i < nut->avf->nb_streams; i++) { - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; ret = write_streaminfo(nut, dyn_bc, i); @@ -554,19 +554,19 @@ static int write_headers(AVFormatContext *avctx, AVIOContext *bc){ put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); else { uint8_t* buf; - url_close_dyn_buf(dyn_bc, &buf); + avio_close_dyn_buf(dyn_bc, &buf); av_free(buf); } } for (i = 0; i < nut->avf->nb_chapters; i++) { - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if (ret < 0) return ret; ret = write_chapter(nut, dyn_bc, i); if (ret < 0) { uint8_t *buf; - url_close_dyn_buf(dyn_bc, &buf); + avio_close_dyn_buf(dyn_bc, &buf); av_freep(&buf); return ret; } @@ -728,7 +728,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){ NULL); nut->last_syncpoint_pos= avio_tell(bc); - ret = url_open_dyn_buf(&dyn_bc); + ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; put_tt(nut, nus->time_base, dyn_bc, pkt->dts); diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 379de7eac1..ddc7a1fd5c 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -455,7 +455,7 @@ ogg_get_length (AVFormatContext * s) int i; int64_t size, end; - if(url_is_streamed(s->pb)) + if(!s->pb->seekable) return 0; // already set diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index a039d689e6..f0251a6455 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -82,7 +82,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) int ret, size; uint8_t *buf; - ret = url_open_dyn_buf(&pb); + ret = avio_open_dyn_buf(&pb); if (ret < 0) return ret; ffio_init_checksum(pb, ff_crc04C11DB7_update, 0); @@ -101,7 +101,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) ogg_update_checksum(s, pb, crc_offset); avio_flush(pb); - size = url_close_dyn_buf(pb, &buf); + size = avio_close_dyn_buf(pb, &buf); if (size < 0) return size; diff --git a/libavformat/r3d.c b/libavformat/r3d.c index aad88ee9c7..5e027d158b 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -177,7 +177,7 @@ static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap) s->data_offset = avio_tell(s->pb); av_dlog(s, "data offset %#llx\n", s->data_offset); - if (url_is_streamed(s->pb)) + if (!s->pb->seekable) 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 1ffeae56ee..6fb362473e 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -481,7 +481,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) if (!data_off) data_off = avio_tell(pb) - 18; - if (indx_off && !url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX) && + if (indx_off && pb->seekable && !(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 28ee173fb8..e08b677987 100644 --- a/libavformat/rmenc.c +++ b/libavformat/rmenc.c @@ -118,7 +118,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 (url_is_streamed(s)) + if (!s->seekable) flags |= 4; /* live broadcast */ avio_wb16(s, flags); @@ -170,7 +170,7 @@ static int rv10_write_header(AVFormatContext *ctx, avio_wb32(s, 0); /* start time */ avio_wb32(s, BUFFER_DURATION); /* preroll */ /* duration */ - if (url_is_streamed(s) || !stream->total_frames) + if (!s->seekable || !stream->total_frames) avio_wb32(s, (int)(3600 * 1000)); else avio_wb32(s, (int)(stream->total_frames * 1000 / stream->frame_rate)); @@ -434,7 +434,7 @@ static int rm_write_trailer(AVFormatContext *s) int data_size, index_pos, i; AVIOContext *pb = s->pb; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* 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 58cfc798c9..ca9985b070 100644 --- a/libavformat/rsoenc.c +++ b/libavformat/rsoenc.c @@ -38,7 +38,7 @@ static int rso_write_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } - if (url_is_streamed(s->pb)) { + if (!s->pb->seekable) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return AVERROR_INVALIDDATA; } diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 438ceda810..ec266c6668 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -41,7 +41,7 @@ buffer to 'rtp_write_packet' contains all the packets for ONE frame. Each packet should have a four byte header containing the length in big endian format (same trick as - 'url_open_dyn_packet_buf') + 'ffio_open_dyn_packet_buf') */ static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = { @@ -264,7 +264,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) return -1; s->last_octet_count = s->octet_count; - if (url_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return -1; // Receiver Report @@ -321,7 +321,7 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) } avio_flush(pb); - len = url_close_dyn_buf(pb, &buf); + len = avio_close_dyn_buf(pb, &buf); if ((len > 0) && buf) { int result; av_dlog(s->ic, "sending %d bytes of RR\n", len); @@ -339,7 +339,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) int len; /* Send a small RTP packet */ - if (url_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return; avio_w8(pb, (RTP_VERSION << 6)); @@ -349,13 +349,13 @@ void rtp_send_punch_packets(URLContext* rtp_handle) avio_wb32(pb, 0); /* SSRC */ avio_flush(pb); - len = url_close_dyn_buf(pb, &buf); + len = avio_close_dyn_buf(pb, &buf); if ((len > 0) && buf) url_write(rtp_handle, buf, len); av_free(buf); /* Send a minimal RTCP RR */ - if (url_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return; avio_w8(pb, (RTP_VERSION << 6)); @@ -364,7 +364,7 @@ void rtp_send_punch_packets(URLContext* rtp_handle) avio_wb32(pb, 0); /* our own SSRC */ avio_flush(pb); - len = url_close_dyn_buf(pb, &buf); + len = avio_close_dyn_buf(pb, &buf); if ((len > 0) && buf) url_write(rtp_handle, buf, len); av_free(buf); diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 3c19ad6e5b..61bf87d37d 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -203,12 +203,12 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, */ if (asf->pktbuf && len_off != avio_tell(asf->pktbuf)) { uint8_t *p; - url_close_dyn_buf(asf->pktbuf, &p); + avio_close_dyn_buf(asf->pktbuf, &p); asf->pktbuf = NULL; av_free(p); } if (!len_off && !asf->pktbuf && - (res = url_open_dyn_buf(&asf->pktbuf)) < 0) + (res = avio_open_dyn_buf(&asf->pktbuf)) < 0) return res; if (!asf->pktbuf) return AVERROR(EIO); @@ -217,7 +217,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, avio_skip(pb, len - off); if (!(flags & RTP_FLAG_MARKER)) return -1; - out_len = url_close_dyn_buf(asf->pktbuf, &asf->buf); + out_len = avio_close_dyn_buf(asf->pktbuf, &asf->buf); asf->pktbuf = NULL; } else { /** @@ -272,7 +272,7 @@ static void asfrtp_free_context(PayloadContext *asf) { if (asf->pktbuf) { uint8_t *p = NULL; - url_close_dyn_buf(asf->pktbuf, &p); + avio_close_dyn_buf(asf->pktbuf, &p); asf->pktbuf = NULL; av_free(p); } diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index c6d865a650..6ff9fd9c99 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -43,7 +43,7 @@ static void latm_free_context(PayloadContext *data) return; if (data->dyn_buf) { uint8_t *p; - url_close_dyn_buf(data->dyn_buf, &p); + avio_close_dyn_buf(data->dyn_buf, &p); av_free(p); } av_free(data->buf); @@ -60,12 +60,12 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, if (!data->dyn_buf || data->timestamp != *timestamp) { av_freep(&data->buf); if (data->dyn_buf) - url_close_dyn_buf(data->dyn_buf, &data->buf); + avio_close_dyn_buf(data->dyn_buf, &data->buf); data->dyn_buf = NULL; av_freep(&data->buf); data->timestamp = *timestamp; - if ((ret = url_open_dyn_buf(&data->dyn_buf)) < 0) + if ((ret = avio_open_dyn_buf(&data->dyn_buf)) < 0) return ret; } avio_write(data->dyn_buf, buf, len); @@ -73,7 +73,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, if (!(flags & RTP_FLAG_MARKER)) return AVERROR(EAGAIN); av_free(data->buf); - data->len = url_close_dyn_buf(data->dyn_buf, &data->buf); + data->len = avio_close_dyn_buf(data->dyn_buf, &data->buf); data->dyn_buf = NULL; data->pos = 0; } diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c index a4fad1cc13..b3559aeb05 100644 --- a/libavformat/rtpdec_svq3.c +++ b/libavformat/rtpdec_svq3.c @@ -83,10 +83,10 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, if (sv->pktbuf) { uint8_t *tmp; - url_close_dyn_buf(sv->pktbuf, &tmp); + avio_close_dyn_buf(sv->pktbuf, &tmp); av_free(tmp); } - if ((res = url_open_dyn_buf(&sv->pktbuf)) < 0) + if ((res = avio_open_dyn_buf(&sv->pktbuf)) < 0) return res; sv->timestamp = *timestamp; } @@ -100,7 +100,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, av_init_packet(pkt); pkt->stream_index = st->index; *timestamp = sv->timestamp; - pkt->size = url_close_dyn_buf(sv->pktbuf, &pkt->data); + pkt->size = avio_close_dyn_buf(sv->pktbuf, &pkt->data); pkt->destruct = av_destruct_packet; sv->pktbuf = NULL; return 0; @@ -118,7 +118,7 @@ static void svq3_extradata_free(PayloadContext *sv) { if (sv->pktbuf) { uint8_t *buf; - url_close_dyn_buf(sv->pktbuf, &buf); + avio_close_dyn_buf(sv->pktbuf, &buf); av_free(buf); } av_free(sv); diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index 3b1ee137aa..e657ca2ad5 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -41,7 +41,7 @@ static void prepare_packet(AVPacket *pkt, PayloadContext *vp8, int stream) av_init_packet(pkt); pkt->stream_index = stream; pkt->flags = vp8->is_keyframe ? AV_PKT_FLAG_KEY : 0; - pkt->size = url_close_dyn_buf(vp8->data, &pkt->data); + pkt->size = avio_close_dyn_buf(vp8->data, &pkt->data); pkt->destruct = av_destruct_packet; vp8->data = NULL; } @@ -85,7 +85,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, // that for the next av_get_packet call ret = end_packet ? 1 : 0; } - if ((res = url_open_dyn_buf(&vp8->data)) < 0) + if ((res = avio_open_dyn_buf(&vp8->data)) < 0) return res; vp8->is_keyframe = *buf & 1; vp8->timestamp = ts; @@ -138,7 +138,7 @@ static void vp8_free_context(PayloadContext *vp8) { if (vp8->data) { uint8_t *tmp; - url_close_dyn_buf(vp8->data, &tmp); + avio_close_dyn_buf(vp8->data, &tmp); av_free(tmp); } av_free(vp8); diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c index 37e57f504f..5a9abdb787 100644 --- a/libavformat/rtpdec_xiph.c +++ b/libavformat/rtpdec_xiph.c @@ -57,7 +57,7 @@ static inline void free_fragment_if_needed(PayloadContext * data) { if (data->fragment) { uint8_t* p; - url_close_dyn_buf(data->fragment, &p); + avio_close_dyn_buf(data->fragment, &p); av_free(p); data->fragment = NULL; } @@ -176,7 +176,7 @@ static int xiph_handle_packet(AVFormatContext * ctx, // end packet has been lost somewhere, so drop buffered data free_fragment_if_needed(data); - if((res = url_open_dyn_buf(&data->fragment)) < 0) + if((res = avio_open_dyn_buf(&data->fragment)) < 0) return res; avio_write(data->fragment, buf, pkt_len); @@ -203,7 +203,7 @@ static int xiph_handle_packet(AVFormatContext * ctx, if (fragmented == 3) { // end of xiph data packet av_init_packet(pkt); - pkt->size = url_close_dyn_buf(data->fragment, &pkt->data); + pkt->size = avio_close_dyn_buf(data->fragment, &pkt->data); if (pkt->size < 0) { av_log(ctx, AV_LOG_ERROR, diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index 84611e690d..bd3d1a875d 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -20,7 +20,9 @@ */ #include "avformat.h" +#include "avio_internal.h" #include "rtpenc_chain.h" +#include "avio_internal.h" AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, URLContext *handle, int packet_size) @@ -53,9 +55,9 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, avcodec_copy_context(rtpctx->streams[0]->codec, st->codec); if (handle) { - url_fdopen(&rtpctx->pb, handle); + ffio_fdopen(&rtpctx->pb, handle); } else - url_open_dyn_packet_buf(&rtpctx->pb, packet_size); + ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); ret = av_write_header(rtpctx); if (ret) { @@ -63,7 +65,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, avio_close(rtpctx->pb); } else { uint8_t *ptr; - url_close_dyn_buf(rtpctx->pb, &ptr); + avio_close_dyn_buf(rtpctx->pb, &ptr); av_free(ptr); } avformat_free_context(rtpctx); diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index f81a604d2c..227c4ccd96 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -495,7 +495,7 @@ void ff_rtsp_undo_setup(AVFormatContext *s) av_write_trailer(rtpctx); if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) { uint8_t *ptr; - url_close_dyn_buf(rtpctx->pb, &ptr); + avio_close_dyn_buf(rtpctx->pb, &ptr); av_free(ptr); } else { avio_close(rtpctx->pb); diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index 5d76fdf0b5..7f788f6f9a 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -29,6 +29,7 @@ #include "os_support.h" #include "rtsp.h" #include "internal.h" +#include "avio_internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" @@ -135,14 +136,14 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) int size; uint8_t *interleave_header, *interleaved_packet; - size = url_close_dyn_buf(rtpctx->pb, &buf); + size = avio_close_dyn_buf(rtpctx->pb, &buf); ptr = buf; while (size > 4) { uint32_t packet_len = AV_RB32(ptr); int id; /* The interleaving header is exactly 4 bytes, which happens to be * the same size as the packet length header from - * url_open_dyn_packet_buf. So by writing the interleaving header + * ffio_open_dyn_packet_buf. So by writing the interleaving header * over these bytes, we get a consecutive interleaved packet * that can be written in one call. */ interleaved_packet = interleave_header = ptr; @@ -162,7 +163,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) size -= packet_len; } av_free(buf); - url_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); + ffio_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); return 0; } diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index 214acdd59b..c93869c691 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -96,7 +96,7 @@ static int sox_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; AVCodecContext *enc = s->streams[0]->codec; - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { /* 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 052d7205e8..f5328d0d9d 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -492,7 +492,7 @@ static int swf_write_trailer(AVFormatContext *s) avio_flush(s->pb); /* patch file size and number of frames if not streamed */ - if (!url_is_streamed(s->pb) && video_enc) { + if (s->pb->seekable && video_enc) { file_size = avio_tell(pb); avio_seek(pb, 4, SEEK_SET); avio_wl32(pb, file_size); diff --git a/libavformat/tty.c b/libavformat/tty.c index 71c00e7e0a..b288d15393 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -88,7 +88,7 @@ static int read_header(AVFormatContext *avctx, /* simulate tty display speed */ s->chars_per_frame = FFMAX(av_q2d(st->time_base) * (ap->sample_rate ? ap->sample_rate : LINE_RATE), 1); - if (!url_is_streamed(avctx->pb)) { + if (avctx->pb->seekable) { 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 87a1bdc89c..6e7fedc049 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2037,7 +2037,7 @@ static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) if ((!strcmp(ic->iformat->name, "mpeg") || !strcmp(ic->iformat->name, "mpegts")) && - file_size && !url_is_streamed(ic->pb)) { + file_size && ic->pb->seekable) { /* get accurate estimate from the PTSes */ av_estimate_timings_from_pts(ic, old_offset); } else if (av_has_duration(ic)) { diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c index 89ee9ef78c..9a77e924a1 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 (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { avio_seek(pb, 0, SEEK_SET); avio_wl24(pb, ctx->frames); avio_flush(pb); diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c index d11e68c49f..b0195e90c3 100644 --- a/libavformat/vocdec.c +++ b/libavformat/vocdec.c @@ -78,7 +78,7 @@ 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 (url_is_streamed(s->pb)) + if (!s->pb->seekable) return AVERROR(EIO); voc->remaining_size = avio_size(pb) - avio_tell(pb); } diff --git a/libavformat/wav.c b/libavformat/wav.c index afe0d0e98e..afdd70114e 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -57,7 +57,7 @@ static int wav_write_header(AVFormatContext *s) ff_end_tag(pb, fmt); if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */ - && !url_is_streamed(s->pb)) { + && s->pb->seekable) { fact = ff_start_tag(pb, "fact"); avio_wl32(pb, 0); ff_end_tag(pb, fact); @@ -97,7 +97,7 @@ static int wav_write_trailer(AVFormatContext *s) avio_flush(pb); - if (!url_is_streamed(s->pb)) { + if (s->pb->seekable) { ff_end_tag(pb, wav->data); /* update file size */ diff --git a/libavformat/wv.c b/libavformat/wv.c index 600de9317b..52ec9264a0 100644 --- a/libavformat/wv.c +++ b/libavformat/wv.c @@ -121,7 +121,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen } if((rate == -1 || !chan) && !wc->block_parsed){ int64_t block_end = avio_tell(pb) + wc->blksize - 24; - if(url_is_streamed(pb)){ + if(!pb->seekable){ av_log(ctx, AV_LOG_ERROR, "Cannot determine additional parameters\n"); return -1; } @@ -223,7 +223,7 @@ static int wv_read_header(AVFormatContext *s, st->start_time = 0; st->duration = wc->samples; - if(!url_is_streamed(s->pb)) { + if(s->pb->seekable) { int64_t cur = avio_tell(s->pb); ff_ape_parse_tag(s); if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) |