[FFmpeg-devel] [PATCH 05/10] avio: rename init_put_byte()/av_alloc_put_byte() to avio_init/alloc_context
Anton Khirnov
anton
Sat Feb 19 12:42:49 CET 2011
New names are hopefully less confusing and more consistent with existing
functions.
---
libavformat/asfenc.c | 4 ++--
libavformat/avidec.c | 2 +-
libavformat/avio.h | 22 +++++++++++++++++++---
libavformat/aviobuf.c | 37 +++++++++++++++++++++++++++++++------
libavformat/id3v2.c | 2 +-
libavformat/matroskadec.c | 8 ++++----
libavformat/mmst.c | 2 +-
libavformat/mov.c | 2 +-
libavformat/mpegts.c | 4 ++--
libavformat/rdt.c | 6 +++---
libavformat/rtpdec_asf.c | 4 ++--
libavformat/rtpdec_qt.c | 2 +-
libavformat/rtsp.c | 2 +-
libavformat/sapdec.c | 2 +-
libavformat/wtv.c | 2 +-
15 files changed, 71 insertions(+), 30 deletions(-)
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 7fbc1cf..6be6590 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -578,7 +578,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,
+ avio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
return 0;
@@ -676,7 +676,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,
+ avio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
NULL, NULL, NULL, NULL);
}
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 6d5e695..0a02ce3 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -752,7 +752,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
AVIStream *ast = st->priv_data;
AVInputFormat *sub_demuxer;
AVRational time_base;
- AVIOContext *pb = av_alloc_put_byte(pkt->data + 7,
+ AVIOContext *pb = avio_alloc_context(pkt->data + 7,
pkt->size - 7,
0, NULL, NULL, NULL, NULL);
AVProbeData pd;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 0189f8a..43ecf89 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -363,7 +363,15 @@ typedef struct {
typedef AVIOContext ByteIOContext attribute_deprecated;
#endif
-int init_put_byte(AVIOContext *s,
+int avio_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));
+AVIOContext *avio_alloc_context(
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -371,7 +379,16 @@ 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));
-AVIOContext *av_alloc_put_byte(
+#if FF_API_OLD_AVIO
+attribute_deprecated 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));
+attribute_deprecated AVIOContext *av_alloc_put_byte(
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -380,7 +397,6 @@ AVIOContext *av_alloc_put_byte(
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
-#if FF_API_OLD_AVIO
/**
* @defgroup old_avio_funcs Old put_/get_*() functions
* @deprecated use the avio_ -prefixed functions instead.
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index fc47a0b..b882bc5 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -40,7 +40,7 @@ static void fill_buffer(AVIOContext *s);
static int url_resetbuf(AVIOContext *s, int flags);
#endif
-int init_put_byte(AVIOContext *s,
+int avio_init_context(AVIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -73,7 +73,7 @@ int init_put_byte(AVIOContext *s,
return 0;
}
-AVIOContext *av_alloc_put_byte(
+AVIOContext *avio_alloc_context(
unsigned char *buffer,
int buffer_size,
int write_flag,
@@ -83,11 +83,36 @@ 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,
+ avio_init_context(s, buffer, buffer_size, write_flag, opaque,
read_packet, write_packet, seek);
return s;
}
+#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 avio_init_context(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek);
+}
+AVIOContext *av_alloc_put_byte(
+ 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 avio_alloc_context(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek);
+}
+#endif
+
static void flush_buffer(AVIOContext *s)
{
if (s->buf_ptr > s->buffer) {
@@ -718,7 +743,7 @@ int url_fdopen(AVIOContext **s, URLContext *h)
return AVERROR(ENOMEM);
}
- if (init_put_byte(*s, buffer, buffer_size,
+ if (avio_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);
@@ -919,7 +944,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 = avio_init_context(*s, buf, buf_size,
(flags & URL_WRONLY || flags & URL_RDWR),
NULL, NULL, NULL, NULL);
if(ret != 0)
@@ -1018,7 +1043,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 = avio_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 188f0af..62e0090 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -216,7 +216,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);
+ avio_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 ee1bad4..f319087 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -698,7 +698,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);
+ avio_init_context(&pb, data, size, 0, NULL, NULL, NULL, NULL);
return ebml_read_num(matroska, &pb, FFMIN(size, 8), num);
}
@@ -1328,7 +1328,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,
+ avio_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 +1373,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,
+ avio_init_context(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
avio_put_buffer(&b, "TTA1", 4);
avio_put_le16(&b, 1);
@@ -1390,7 +1390,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,
+ avio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
url_fskip(&b, 22);
flavor = avio_get_be16(&b);
diff --git a/libavformat/mmst.c b/libavformat/mmst.c
index 8d7ed05..d2ee145 100644
--- a/libavformat/mmst.c
+++ b/libavformat/mmst.c
@@ -155,7 +155,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,
+ avio_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 70968c1..acde125 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2123,7 +2123,7 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
avio_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(avio_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 d922a06..42d54bd 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -855,7 +855,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);
+ avio_init_context(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4IODescrTag) {
@@ -914,7 +914,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,
+ avio_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 964506b..a8d0208 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -150,7 +150,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,
+ avio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
NULL, NULL, NULL, NULL);
tag = avio_get_le32(&pb);
if (tag == MKTAG('M', 'L', 'T', 'I')) {
@@ -300,7 +300,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);
+ avio_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);
@@ -310,7 +310,7 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,
if (res > 0) {
if (st->codec->codec_id == CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos);
- rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
+ rdt->rmctx->pb = avio_alloc_context (rdt->buffer, len - pos, 0,
NULL, NULL, NULL, NULL);
}
goto get_cache;
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
index f6f4887..bed22bd 100644
--- a/libavformat/rtpdec_asf.c
+++ b/libavformat/rtpdec_asf.c
@@ -84,7 +84,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);
+ avio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
/* this "fills" the buffer with its current content */
pb->pos = len;
@@ -176,7 +176,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);
+ avio_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 dbed3bb..d36f666 100644
--- a/libavformat/rtpdec_qt.c
+++ b/libavformat/rtpdec_qt.c
@@ -69,7 +69,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);
+ avio_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 8547d14..a5b3755 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1913,7 +1913,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);
+ avio_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 ef1ecc4..f199db0 100644
--- a/libavformat/sapdec.c
+++ b/libavformat/sapdec.c
@@ -142,7 +142,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,
+ avio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
NULL, NULL);
infmt = av_find_input_format("sdp");
diff --git a/libavformat/wtv.c b/libavformat/wtv.c
index acd50d4..e47149c 100644
--- a/libavformat/wtv.c
+++ b/libavformat/wtv.c
@@ -236,7 +236,7 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
return NULL;
}
- pb = av_alloc_put_byte(buffer, 1 << wf->sector_bits, 0, wf,
+ pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf,
wtvfile_read_packet, NULL, wtvfile_seek);
if (!pb) {
av_free(buffer);
--
1.7.2.3
More information about the ffmpeg-devel
mailing list