diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-02-20 11:04:13 +0100 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-02-20 08:37:31 -0500 |
commit | e731b8d8729e75bfb69f5540e6446d6118dac549 (patch) | |
tree | bfefb15c001ad3e0993d95f2752aa61182f5188a | |
parent | ae628ec1fd7f54c102bf9e667a3edd404b9b9128 (diff) | |
download | ffmpeg-e731b8d8729e75bfb69f5540e6446d6118dac549.tar.gz |
avio: move init_put_byte() to a new private header and rename it
init_put_byte should never be used outside of lavf, since
sizeof(AVIOContext) isn't part of public ABI.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
-rw-r--r-- | libavformat/asfenc.c | 5 | ||||
-rw-r--r-- | libavformat/avio.h | 4 | ||||
-rw-r--r-- | libavformat/avio_internal.h | 35 | ||||
-rw-r--r-- | libavformat/aviobuf.c | 26 | ||||
-rw-r--r-- | libavformat/id3v2.c | 3 | ||||
-rw-r--r-- | libavformat/matroskadec.c | 9 | ||||
-rw-r--r-- | libavformat/mmst.c | 3 | ||||
-rw-r--r-- | libavformat/mov.c | 3 | ||||
-rw-r--r-- | libavformat/mpegts.c | 5 | ||||
-rw-r--r-- | libavformat/rdt.c | 5 | ||||
-rw-r--r-- | libavformat/rtpdec_asf.c | 5 | ||||
-rw-r--r-- | libavformat/rtpdec_qt.c | 3 | ||||
-rw-r--r-- | libavformat/rtsp.c | 3 | ||||
-rw-r--r-- | libavformat/sapdec.c | 3 |
14 files changed, 87 insertions, 25 deletions
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 4751665a56..a529c1bbdf 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -22,6 +22,7 @@ #include "metadata.h" #include "riff.h" #include "asf.h" +#include "avio_internal.h" #undef NDEBUG #include <assert.h> @@ -578,7 +579,7 @@ static int asf_write_header(AVFormatContext *s) asf->packet_nb_payloads = 0; asf->packet_timestamp_start = -1; asf->packet_timestamp_end = -1; - init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1, + ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1, NULL, NULL, NULL, NULL); return 0; @@ -676,7 +677,7 @@ static void flush_packet(AVFormatContext *s) asf->packet_nb_payloads = 0; asf->packet_timestamp_start = -1; asf->packet_timestamp_end = -1; - init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1, + ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1, NULL, NULL, NULL, NULL); } diff --git a/libavformat/avio.h b/libavformat/avio.h index 14d371f1ed..060f06e6f2 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -361,9 +361,8 @@ typedef struct { #if FF_API_OLD_AVIO typedef attribute_deprecated AVIOContext ByteIOContext; -#endif -int init_put_byte(AVIOContext *s, +attribute_deprecated int init_put_byte(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, @@ -371,6 +370,7 @@ int init_put_byte(AVIOContext *s, int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)); +#endif AVIOContext *av_alloc_put_byte( unsigned char *buffer, int buffer_size, diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h new file mode 100644 index 0000000000..1cebcd72c8 --- /dev/null +++ b/libavformat/avio_internal.h @@ -0,0 +1,35 @@ +/* + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_AVIO_INTERNAL_H +#define AVFORMAT_AVIO_INTERNAL_H + +#include "avio.h" + +int ffio_init_context(AVIOContext *s, + unsigned char *buffer, + int buffer_size, + int write_flag, + void *opaque, + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + int64_t (*seek)(void *opaque, int64_t offset, int whence)); + + +#endif // AVFORMAT_AVIO_INTERNAL_H diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index d5f55e0e11..7b1f5ca1fd 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" #include "avio.h" +#include "avio_internal.h" #include "internal.h" #include <stdarg.h> @@ -40,7 +41,7 @@ static void fill_buffer(AVIOContext *s); static int url_resetbuf(AVIOContext *s, int flags); #endif -int init_put_byte(AVIOContext *s, +int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, @@ -73,6 +74,21 @@ int init_put_byte(AVIOContext *s, return 0; } +#if FF_API_OLD_AVIO +int init_put_byte(AVIOContext *s, + unsigned char *buffer, + int buffer_size, + int write_flag, + void *opaque, + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + int64_t (*seek)(void *opaque, int64_t offset, int whence)) +{ + return ffio_init_context(s, buffer, buffer_size, write_flag, opaque, + read_packet, write_packet, seek); +} +#endif + AVIOContext *av_alloc_put_byte( unsigned char *buffer, int buffer_size, @@ -83,7 +99,7 @@ AVIOContext *av_alloc_put_byte( int64_t (*seek)(void *opaque, int64_t offset, int whence)) { AVIOContext *s = av_mallocz(sizeof(AVIOContext)); - init_put_byte(s, buffer, buffer_size, write_flag, opaque, + ffio_init_context(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); return s; } @@ -664,7 +680,7 @@ int url_fdopen(AVIOContext **s, URLContext *h) return AVERROR(ENOMEM); } - if (init_put_byte(*s, buffer, buffer_size, + if (ffio_init_context(*s, buffer, buffer_size, (h->flags & URL_WRONLY || h->flags & URL_RDWR), h, url_read, url_write, url_seek) < 0) { av_free(buffer); @@ -865,7 +881,7 @@ int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags) *s = av_mallocz(sizeof(AVIOContext)); if(!*s) return AVERROR(ENOMEM); - ret = init_put_byte(*s, buf, buf_size, + ret = ffio_init_context(*s, buf, buf_size, (flags & URL_WRONLY || flags & URL_RDWR), NULL, NULL, NULL, NULL); if(ret != 0) @@ -964,7 +980,7 @@ static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) return AVERROR(ENOMEM); } d->io_buffer_size = io_buffer_size; - ret = init_put_byte(*s, d->io_buffer, 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); diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index a5a96e20de..f886b68288 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -24,6 +24,7 @@ #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "metadata.h" +#include "avio_internal.h" int ff_id3v2_match(const uint8_t *buf, const char * magic) { @@ -216,7 +217,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t j--; } } - init_put_byte(&pb, buffer, j, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb, buffer, j, 0, NULL, NULL, NULL, NULL); read_ttag(s, &pb, j, tag); } else { read_ttag(s, s->pb, tlen, tag); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b3797047e5..69f08c3142 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -31,6 +31,7 @@ #include <stdio.h> #include "avformat.h" #include "internal.h" +#include "avio_internal.h" /* For ff_codec_get_id(). */ #include "riff.h" #include "isom.h" @@ -698,7 +699,7 @@ static int matroska_ebmlnum_uint(MatroskaDemuxContext *matroska, uint8_t *data, uint32_t size, uint64_t *num) { AVIOContext pb; - init_put_byte(&pb, data, size, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb, data, size, 0, NULL, NULL, NULL, NULL); return ebml_read_num(matroska, &pb, FFMIN(size, 8), num); } @@ -1328,7 +1329,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) } else if (!strcmp(track->codec_id, "A_MS/ACM") && track->codec_priv.size >= 14 && track->codec_priv.data != NULL) { - init_put_byte(&b, track->codec_priv.data, track->codec_priv.size, + ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size, URL_RDONLY, NULL, NULL, NULL, NULL); ff_get_wav_header(&b, st->codec, track->codec_priv.size); codec_id = st->codec->codec_id; @@ -1373,7 +1374,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) extradata = av_mallocz(extradata_size); if (extradata == NULL) return AVERROR(ENOMEM); - init_put_byte(&b, extradata, extradata_size, 1, + ffio_init_context(&b, extradata, extradata_size, 1, NULL, NULL, NULL, NULL); put_buffer(&b, "TTA1", 4); put_le16(&b, 1); @@ -1390,7 +1391,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) } else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK || codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) { int flavor; - init_put_byte(&b, track->codec_priv.data,track->codec_priv.size, + ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size, 0, NULL, NULL, NULL, NULL); url_fskip(&b, 22); flavor = get_be16(&b); diff --git a/libavformat/mmst.c b/libavformat/mmst.c index 8d7ed059dc..e3af4bfbc6 100644 --- a/libavformat/mmst.c +++ b/libavformat/mmst.c @@ -31,6 +31,7 @@ #include "avformat.h" #include "mms.h" #include "internal.h" +#include "avio_internal.h" #include "libavutil/intreadwrite.h" #include "libavcodec/bytestream.h" #include "network.h" @@ -155,7 +156,7 @@ static void mms_put_utf16(MMSContext *mms, uint8_t *src) AVIOContext bic; int size = mms->write_out_ptr - mms->out_buffer; int len; - init_put_byte(&bic, mms->write_out_ptr, + ffio_init_context(&bic, mms->write_out_ptr, sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL); len = avio_put_str16le(&bic, src); diff --git a/libavformat/mov.c b/libavformat/mov.c index 22f84c1e72..2c314e3a39 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -29,6 +29,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" #include "avformat.h" +#include "avio_internal.h" #include "riff.h" #include "isom.h" #include "libavcodec/get_bits.h" @@ -2123,7 +2124,7 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom) get_buffer(pb, cmov_data, cmov_len); if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK) goto free_and_return; - if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) + if(ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) goto free_and_return; atom.type = MKTAG('m','o','o','v'); atom.size = moov_len; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index a97fd7a62d..fb45e60844 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -29,6 +29,7 @@ #include "avformat.h" #include "mpegts.h" #include "internal.h" +#include "avio_internal.h" #include "seek.h" #include "mpeg.h" #include "isom.h" @@ -855,7 +856,7 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size, int tag; unsigned len; - init_put_byte(&pb, buf, size, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb, buf, size, 0, NULL, NULL, NULL, NULL); len = ff_mp4_read_descr(s, &pb, &tag); if (tag == MP4IODescrTag) { @@ -914,7 +915,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type if (st->codec->codec_id == CODEC_ID_AAC_LATM && mp4_dec_config_descr_len && mp4_es_id == pid) { AVIOContext pb; - init_put_byte(&pb, mp4_dec_config_descr, + ffio_init_context(&pb, mp4_dec_config_descr, mp4_dec_config_descr_len, 0, NULL, NULL, NULL, NULL); ff_mp4_read_dec_config_descr(fc, st, &pb); if (st->codec->codec_id == CODEC_ID_AAC && diff --git a/libavformat/rdt.c b/libavformat/rdt.c index 4b0664fb44..bbc3de923b 100644 --- a/libavformat/rdt.c +++ b/libavformat/rdt.c @@ -33,6 +33,7 @@ #include "libavutil/md5.h" #include "rm.h" #include "internal.h" +#include "avio_internal.h" #include "libavcodec/get_bits.h" struct RDTDemuxContext { @@ -150,7 +151,7 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) */ if (!rdt->mlti_data) return -1; - init_put_byte(&pb, rdt->mlti_data, rdt->mlti_data_size, 0, + ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0, NULL, NULL, NULL, NULL); tag = get_le32(&pb); if (tag == MKTAG('M', 'L', 'T', 'I')) { @@ -300,7 +301,7 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st, if (rdt->audio_pkt_cnt == 0) { int pos; - init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL); flags = (flags & RTP_FLAG_KEY) ? 2 : 0; res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt, &seq, flags, *timestamp); diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index e7893b3698..9708e906aa 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -32,6 +32,7 @@ #include "rtpdec_formats.h" #include "rtsp.h" #include "asf.h" +#include "avio_internal.h" /** * From MSDN 2.2.1.4, we learn that ASF data packets over RTP should not @@ -84,7 +85,7 @@ static int packetizer_read(void *opaque, uint8_t *buf, int buf_size) static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len) { - init_put_byte(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL); + ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL); /* this "fills" the buffer with its current content */ pb->pos = len; @@ -176,7 +177,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, av_freep(&asf->buf); - init_put_byte(pb, buf, len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(pb, buf, len, 0, NULL, NULL, NULL, NULL); while (url_ftell(pb) + 4 < len) { int start_off = url_ftell(pb); diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c index 8a72cce3b5..781e5fff23 100644 --- a/libavformat/rtpdec_qt.c +++ b/libavformat/rtpdec_qt.c @@ -26,6 +26,7 @@ */ #include "avformat.h" +#include "avio_internal.h" #include "rtp.h" #include "rtpdec.h" #include "isom.h" @@ -69,7 +70,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, * http://developer.apple.com/quicktime/icefloe/dispatch026.html */ init_get_bits(&gb, buf, len << 3); - init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL); if (len < 4) return AVERROR_INVALIDDATA; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index eae7ffcdac..d09123a06f 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -25,6 +25,7 @@ #include "libavutil/parseutils.h" #include "libavutil/random_seed.h" #include "avformat.h" +#include "avio_internal.h" #include <sys/time.h> #if HAVE_POLL_H @@ -1913,7 +1914,7 @@ static int rtp_read_header(AVFormatContext *s, port, payload_type); av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); - init_put_byte(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL); s->pb = &pb; /* sdp_read_header initializes this again */ diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index ef1ecc47d7..e3cdcea6a6 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -25,6 +25,7 @@ #include "network.h" #include "os_support.h" #include "internal.h" +#include "avio_internal.h" #if HAVE_POLL_H #include <poll.h> #endif @@ -142,7 +143,7 @@ static int sap_read_header(AVFormatContext *s, } av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sap->sdp); - init_put_byte(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL, + ffio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL, NULL, NULL); infmt = av_find_input_format("sdp"); |