aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-02-21 16:43:01 +0100
committerRonald S. Bultje <rsbultje@gmail.com>2011-02-21 11:23:22 -0500
commitb7effd4e8338f6ed5bda630ad7ed0809bf458648 (patch)
tree53c878f6dd48c313a9bcde1855c2b4e009822c9e
parentf8bed30d8b176fa030f6737765338bb4a2bcabc9 (diff)
downloadffmpeg-b7effd4e8338f6ed5bda630ad7ed0809bf458648.tar.gz
avio: avio_ prefixes for get_* functions
In the name of consistency: get_byte -> avio_r8 get_<type> -> avio_r<type> get_buffer -> avio_read get_partial_buffer will be made private later get_strz is left out becase I want to change it later to return something useful. Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
-rw-r--r--libavformat/4xm.c18
-rw-r--r--libavformat/aea.c2
-rw-r--r--libavformat/aiffdec.c26
-rw-r--r--libavformat/amr.c8
-rw-r--r--libavformat/anm.c38
-rw-r--r--libavformat/apc.c14
-rw-r--r--libavformat/ape.c60
-rw-r--r--libavformat/apetag.c18
-rw-r--r--libavformat/asfdec.c254
-rw-r--r--libavformat/au.c12
-rw-r--r--libavformat/avidec.c158
-rw-r--r--libavformat/avio.h39
-rw-r--r--libavformat/aviobuf.c88
-rw-r--r--libavformat/avs.c24
-rw-r--r--libavformat/bethsoftvid.c30
-rw-r--r--libavformat/bfi.c32
-rw-r--r--libavformat/bink.c30
-rw-r--r--libavformat/c93.c18
-rw-r--r--libavformat/cafdec.c36
-rw-r--r--libavformat/daud.c4
-rw-r--r--libavformat/dsicin.c30
-rw-r--r--libavformat/dv.c10
-rw-r--r--libavformat/dxa.c30
-rw-r--r--libavformat/eacdata.c4
-rw-r--r--libavformat/electronicarts.c44
-rw-r--r--libavformat/ffmdec.c144
-rw-r--r--libavformat/ffmetadec.c4
-rw-r--r--libavformat/filmstripdec.c14
-rw-r--r--libavformat/flacdec.c6
-rw-r--r--libavformat/flic.c10
-rw-r--r--libavformat/flvdec.c52
-rw-r--r--libavformat/gxf.c70
-rw-r--r--libavformat/id3v1.c2
-rw-r--r--libavformat/id3v2.c30
-rw-r--r--libavformat/idcin.c18
-rw-r--r--libavformat/idroqdec.c10
-rw-r--r--libavformat/iff.c30
-rw-r--r--libavformat/img2.c2
-rw-r--r--libavformat/ingenientdec.c14
-rw-r--r--libavformat/ipmovie.c22
-rw-r--r--libavformat/isom.c16
-rw-r--r--libavformat/iss.c4
-rw-r--r--libavformat/iv8.c12
-rw-r--r--libavformat/ivfdec.c22
-rw-r--r--libavformat/libnut.c2
-rw-r--r--libavformat/lmlm4.c6
-rw-r--r--libavformat/lxfdec.c10
-rw-r--r--libavformat/matroskadec.c26
-rw-r--r--libavformat/mm.c18
-rw-r--r--libavformat/mmf.c26
-rw-r--r--libavformat/mov.c474
-rw-r--r--libavformat/mp3dec.c18
-rw-r--r--libavformat/mpc.c14
-rw-r--r--libavformat/mpc8.c10
-rw-r--r--libavformat/mpeg.c78
-rw-r--r--libavformat/mpegts.c30
-rw-r--r--libavformat/msnwc_tcp.c8
-rw-r--r--libavformat/mtv.c20
-rw-r--r--libavformat/mvi.c30
-rw-r--r--libavformat/mxfdec.c122
-rw-r--r--libavformat/mxg.c2
-rw-r--r--libavformat/ncdec.c6
-rw-r--r--libavformat/nsvdec.c54
-rw-r--r--libavformat/nutdec.c32
-rw-r--r--libavformat/nuv.c52
-rw-r--r--libavformat/oggdec.c14
-rw-r--r--libavformat/oma.c2
-rw-r--r--libavformat/psxstr.c4
-rw-r--r--libavformat/pva.c26
-rw-r--r--libavformat/qcp.c28
-rw-r--r--libavformat/r3d.c78
-rw-r--r--libavformat/rdt.c12
-rw-r--r--libavformat/riff.c44
-rw-r--r--libavformat/rl2.c26
-rw-r--r--libavformat/rmdec.c206
-rw-r--r--libavformat/rpl.c6
-rw-r--r--libavformat/rsodec.c8
-rw-r--r--libavformat/rtpdec_asf.c4
-rw-r--r--libavformat/rtpdec_qt.c8
-rw-r--r--libavformat/rtsp.c2
-rw-r--r--libavformat/sauce.c20
-rw-r--r--libavformat/segafilm.c14
-rw-r--r--libavformat/sierravmd.c10
-rw-r--r--libavformat/siff.c40
-rw-r--r--libavformat/smacker.c50
-rw-r--r--libavformat/sol.c12
-rw-r--r--libavformat/soxdec.c20
-rw-r--r--libavformat/spdifdec.c8
-rw-r--r--libavformat/swfdec.c44
-rw-r--r--libavformat/thp.c46
-rw-r--r--libavformat/tiertexseq.c14
-rw-r--r--libavformat/tmv.c14
-rw-r--r--libavformat/tta.c16
-rw-r--r--libavformat/tty.c6
-rw-r--r--libavformat/txd.c6
-rw-r--r--libavformat/utils.c6
-rw-r--r--libavformat/vc1test.c20
-rw-r--r--libavformat/vocdec.c24
-rw-r--r--libavformat/vqf.c16
-rw-r--r--libavformat/wav.c32
-rw-r--r--libavformat/wc3movie.c20
-rw-r--r--libavformat/westwood.c12
-rw-r--r--libavformat/wtv.c56
-rw-r--r--libavformat/wv.c50
-rw-r--r--libavformat/xa.c12
-rw-r--r--libavformat/yop.c14
-rw-r--r--libavformat/yuv4mpeg.c4
107 files changed, 1823 insertions, 1778 deletions
diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index 033c962fda..bf2d7384b5 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -54,11 +54,11 @@
#define strk_SIZE 0x28
#define GET_LIST_HEADER() \
- fourcc_tag = get_le32(pb); \
- size = get_le32(pb); \
+ fourcc_tag = avio_rl32(pb); \
+ size = avio_rl32(pb); \
if (fourcc_tag != LIST_TAG) \
return AVERROR_INVALIDDATA; \
- fourcc_tag = get_le32(pb);
+ fourcc_tag = avio_rl32(pb);
typedef struct AudioTrack {
int sample_rate;
@@ -118,7 +118,7 @@ static int fourxm_read_header(AVFormatContext *s,
header = av_malloc(header_size);
if (!header)
return AVERROR(ENOMEM);
- if (get_buffer(pb, header, header_size) != header_size){
+ if (avio_read(pb, header, header_size) != header_size){
av_free(header);
return AVERROR(EIO);
}
@@ -255,7 +255,7 @@ static int fourxm_read_packet(AVFormatContext *s,
while (!packet_read) {
- if ((ret = get_buffer(s->pb, header, 8)) < 0)
+ if ((ret = avio_read(s->pb, header, 8)) < 0)
return ret;
fourcc_tag = AV_RL32(&header[0]);
size = AV_RL32(&header[4]);
@@ -268,7 +268,7 @@ static int fourxm_read_packet(AVFormatContext *s,
fourxm->video_pts ++;
/* skip the LIST-* tag and move on to the next fourcc */
- get_le32(pb);
+ avio_rl32(pb);
break;
case ifrm_TAG:
@@ -285,7 +285,7 @@ static int fourxm_read_packet(AVFormatContext *s,
pkt->pts = fourxm->video_pts;
pkt->pos = url_ftell(s->pb);
memcpy(pkt->data, header, 8);
- ret = get_buffer(s->pb, &pkt->data[8], size);
+ ret = avio_read(s->pb, &pkt->data[8], size);
if (ret < 0){
av_free_packet(pkt);
@@ -294,8 +294,8 @@ static int fourxm_read_packet(AVFormatContext *s,
break;
case snd__TAG:
- track_number = get_le32(pb);
- out_size= get_le32(pb);
+ track_number = avio_rl32(pb);
+ out_size= avio_rl32(pb);
size-=8;
if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) {
diff --git a/libavformat/aea.c b/libavformat/aea.c
index 16a11c86af..8316a7e162 100644
--- a/libavformat/aea.c
+++ b/libavformat/aea.c
@@ -63,7 +63,7 @@ static int aea_read_header(AVFormatContext *s,
/* Parse the amount of channels and skip to pos 2048(0x800) */
url_fskip(s->pb, 264);
- st->codec->channels = get_byte(s->pb);
+ st->codec->channels = avio_r8(s->pb);
url_fskip(s->pb, 1783);
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 712f85cda3..7b3d1e7297 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -54,8 +54,8 @@ static int get_tag(AVIOContext *pb, uint32_t * tag)
if (url_feof(pb))
return AVERROR(EIO);
- *tag = get_le32(pb);
- size = get_be32(pb);
+ *tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if (size < 0)
size = 0x7fffffff;
@@ -74,7 +74,7 @@ static void get_meta(AVFormatContext *s, const char *key, int size)
return;
}
- res = get_buffer(s->pb, str, size);
+ res = avio_read(s->pb, str, size);
if (res < 0)
return;
@@ -93,18 +93,18 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec,
if (size & 1)
size++;
codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->channels = get_be16(pb);
- num_frames = get_be32(pb);
- codec->bits_per_coded_sample = get_be16(pb);
+ codec->channels = avio_rb16(pb);
+ num_frames = avio_rb32(pb);
+ codec->bits_per_coded_sample = avio_rb16(pb);
- get_buffer(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
+ avio_read(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */
codec->sample_rate = sample_rate;
size -= 18;
/* Got an AIFF-C? */
if (version == AIFF_C_VERSION1) {
- codec->codec_tag = get_le32(pb);
+ codec->codec_tag = avio_rl32(pb);
codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
switch (codec->codec_id) {
@@ -187,7 +187,7 @@ static int aiff_read_header(AVFormatContext *s,
return AVERROR_INVALIDDATA;
/* AIFF data type */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */
version = AIFF;
else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */
@@ -217,7 +217,7 @@ static int aiff_read_header(AVFormatContext *s,
goto got_sound;
break;
case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */
- version = get_be32(pb);
+ version = avio_rb32(pb);
break;
case MKTAG('N', 'A', 'M', 'E'): /* Sample name chunk */
get_meta(s, "title" , size);
@@ -233,8 +233,8 @@ static int aiff_read_header(AVFormatContext *s,
break;
case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
aiff->data_end = url_ftell(pb) + size;
- offset = get_be32(pb); /* Offset of sound data */
- get_be32(pb); /* BlockSize... don't care */
+ offset = avio_rb32(pb); /* Offset of sound data */
+ avio_rb32(pb); /* BlockSize... don't care */
offset += url_ftell(pb); /* Compute absolute data offset */
if (st->codec->block_align) /* Assume COMM already parsed */
goto got_sound;
@@ -251,7 +251,7 @@ static int aiff_read_header(AVFormatContext *s,
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
- get_buffer(pb, st->codec->extradata, size);
+ avio_read(pb, st->codec->extradata, size);
break;
default: /* Jump */
if (size & 1) /* Always even aligned */
diff --git a/libavformat/amr.c b/libavformat/amr.c
index 6ab8b3c668..9c64d35716 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -82,7 +82,7 @@ static int amr_read_header(AVFormatContext *s,
AVStream *st;
uint8_t header[9];
- get_buffer(pb, header, 6);
+ avio_read(pb, header, 6);
st = av_new_stream(s, 0);
if (!st)
@@ -91,7 +91,7 @@ static int amr_read_header(AVFormatContext *s,
}
if(memcmp(header,AMR_header,6)!=0)
{
- get_buffer(pb, header+6, 3);
+ avio_read(pb, header+6, 3);
if(memcmp(header,AMRWB_header,9)!=0)
{
return -1;
@@ -128,7 +128,7 @@ static int amr_read_packet(AVFormatContext *s,
}
//FIXME this is wrong, this should rather be in a AVParset
- toc=get_byte(s->pb);
+ toc=avio_r8(s->pb);
mode = (toc >> 3) & 0x0F;
if (enc->codec_id == CODEC_ID_AMR_NB)
@@ -157,7 +157,7 @@ static int amr_read_packet(AVFormatContext *s,
pkt->pos= url_ftell(s->pb);
pkt->data[0]=toc;
pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
- read = get_buffer(s->pb, pkt->data+1, size-1);
+ read = avio_read(s->pb, pkt->data+1, size-1);
if (read != size-1)
{
diff --git a/libavformat/anm.c b/libavformat/anm.c
index b754518113..6bcb90db1a 100644
--- a/libavformat/anm.c
+++ b/libavformat/anm.c
@@ -84,16 +84,16 @@ static int read_header(AVFormatContext *s,
int i, ret;
url_fskip(pb, 4); /* magic number */
- if (get_le16(pb) != MAX_PAGES) {
+ if (avio_rl16(pb) != MAX_PAGES) {
av_log_ask_for_sample(s, "max_pages != " AV_STRINGIFY(MAX_PAGES) "\n");
return AVERROR_INVALIDDATA;
}
- anm->nb_pages = get_le16(pb);
- anm->nb_records = get_le32(pb);
+ anm->nb_pages = avio_rl16(pb);
+ anm->nb_records = avio_rl32(pb);
url_fskip(pb, 2); /* max records per page */
- anm->page_table_offset = get_le16(pb);
- if (get_le32(pb) != ANIM_TAG)
+ anm->page_table_offset = avio_rl16(pb);
+ if (avio_rl32(pb) != ANIM_TAG)
return AVERROR_INVALIDDATA;
/* video stream */
@@ -103,32 +103,32 @@ static int read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ANM;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_le16(pb);
- st->codec->height = get_le16(pb);
- if (get_byte(pb) != 0)
+ st->codec->width = avio_rl16(pb);
+ st->codec->height = avio_rl16(pb);
+ if (avio_r8(pb) != 0)
goto invalid;
url_fskip(pb, 1); /* frame rate multiplier info */
/* ignore last delta record (used for looping) */
- if (get_byte(pb)) /* has_last_delta */
+ if (avio_r8(pb)) /* has_last_delta */
anm->nb_records = FFMAX(anm->nb_records - 1, 0);
url_fskip(pb, 1); /* last_delta_valid */
- if (get_byte(pb) != 0)
+ if (avio_r8(pb) != 0)
goto invalid;
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
goto invalid;
url_fskip(pb, 1); /* other recs per frame */
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
goto invalid;
url_fskip(pb, 32); /* record_types */
- st->nb_frames = get_le32(pb);
- av_set_pts_info(st, 64, 1, get_le16(pb));
+ st->nb_frames = avio_rl32(pb);
+ av_set_pts_info(st, 64, 1, avio_rl16(pb));
url_fskip(pb, 58);
/* color cycling and palette data */
@@ -138,7 +138,7 @@ static int read_header(AVFormatContext *s,
ret = AVERROR(ENOMEM);
goto close_and_return;
}
- ret = get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size);
if (ret < 0)
goto close_and_return;
@@ -149,9 +149,9 @@ static int read_header(AVFormatContext *s,
for (i = 0; i < MAX_PAGES; i++) {
Page *p = &anm->pt[i];
- p->base_record = get_le16(pb);
- p->nb_records = get_le16(pb);
- p->size = get_le16(pb);
+ p->base_record = avio_rl16(pb);
+ p->nb_records = avio_rl16(pb);
+ p->size = avio_rl16(pb);
}
/* find page of first frame */
@@ -211,7 +211,7 @@ repeat:
tmp = url_ftell(pb);
url_fseek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) +
8 + anm->record * 2, SEEK_SET);
- record_size = get_le16(pb);
+ record_size = avio_rl16(pb);
url_fseek(pb, tmp, SEEK_SET);
/* fetch record */
diff --git a/libavformat/apc.c b/libavformat/apc.c
index 7641d9f0d1..bf93fc1522 100644
--- a/libavformat/apc.c
+++ b/libavformat/apc.c
@@ -35,9 +35,9 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVIOContext *pb = s->pb;
AVStream *st;
- get_le32(pb); /* CRYO */
- get_le32(pb); /* _APC */
- get_le32(pb); /* 1.20 */
+ avio_rl32(pb); /* CRYO */
+ avio_rl32(pb); /* _APC */
+ avio_rl32(pb); /* 1.20 */
st = av_new_stream(s, 0);
if (!st)
@@ -46,8 +46,8 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
- get_le32(pb); /* number of samples */
- st->codec->sample_rate = get_le32(pb);
+ avio_rl32(pb); /* number of samples */
+ st->codec->sample_rate = avio_rl32(pb);
st->codec->extradata_size = 2 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size +
@@ -56,10 +56,10 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(ENOMEM);
/* initial predictor values for adpcm decoder */
- get_buffer(pb, st->codec->extradata, 2 * 4);
+ avio_read(pb, st->codec->extradata, 2 * 4);
st->codec->channels = 1;
- if (get_le32(pb))
+ if (avio_rl32(pb))
st->codec->channels = 2;
st->codec->bits_per_coded_sample = 4;
diff --git a/libavformat/ape.c b/libavformat/ape.c
index 53b609fe4d..862ac1a482 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -162,11 +162,11 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
/* TODO: Skip any leading junk such as id3v2 tags */
ape->junklength = 0;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' '))
return -1;
- ape->fileversion = get_le16(pb);
+ ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
@@ -174,15 +174,15 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
}
if (ape->fileversion >= 3980) {
- ape->padding1 = get_le16(pb);
- ape->descriptorlength = get_le32(pb);
- ape->headerlength = get_le32(pb);
- ape->seektablelength = get_le32(pb);
- ape->wavheaderlength = get_le32(pb);
- ape->audiodatalength = get_le32(pb);
- ape->audiodatalength_high = get_le32(pb);
- ape->wavtaillength = get_le32(pb);
- get_buffer(pb, ape->md5, 16);
+ ape->padding1 = avio_rl16(pb);
+ ape->descriptorlength = avio_rl32(pb);
+ ape->headerlength = avio_rl32(pb);
+ ape->seektablelength = avio_rl32(pb);
+ ape->wavheaderlength = avio_rl32(pb);
+ ape->audiodatalength = avio_rl32(pb);
+ ape->audiodatalength_high = avio_rl32(pb);
+ ape->wavtaillength = avio_rl32(pb);
+ avio_read(pb, ape->md5, 16);
/* Skip any unknown bytes at the end of the descriptor.
This is for future compatibility */
@@ -190,26 +190,26 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
url_fseek(pb, ape->descriptorlength - 52, SEEK_CUR);
/* Read header data */
- ape->compressiontype = get_le16(pb);
- ape->formatflags = get_le16(pb);
- ape->blocksperframe = get_le32(pb);
- ape->finalframeblocks = get_le32(pb);
- ape->totalframes = get_le32(pb);
- ape->bps = get_le16(pb);
- ape->channels = get_le16(pb);
- ape->samplerate = get_le32(pb);
+ ape->compressiontype = avio_rl16(pb);
+ ape->formatflags = avio_rl16(pb);
+ ape->blocksperframe = avio_rl32(pb);
+ ape->finalframeblocks = avio_rl32(pb);
+ ape->totalframes = avio_rl32(pb);
+ ape->bps = avio_rl16(pb);
+ ape->channels = avio_rl16(pb);
+ ape->samplerate = avio_rl32(pb);
} else {
ape->descriptorlength = 0;
ape->headerlength = 32;
- ape->compressiontype = get_le16(pb);
- ape->formatflags = get_le16(pb);
- ape->channels = get_le16(pb);
- ape->samplerate = get_le32(pb);
- ape->wavheaderlength = get_le32(pb);
- ape->wavtaillength = get_le32(pb);
- ape->totalframes = get_le32(pb);
- ape->finalframeblocks = get_le32(pb);
+ ape->compressiontype = avio_rl16(pb);
+ ape->formatflags = avio_rl16(pb);
+ ape->channels = avio_rl16(pb);
+ ape->samplerate = avio_rl32(pb);
+ ape->wavheaderlength = avio_rl32(pb);
+ ape->wavtaillength = avio_rl32(pb);
+ ape->totalframes = avio_rl32(pb);
+ ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
url_fseek(pb, 4, SEEK_CUR); /* Skip the peak level */
@@ -217,7 +217,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
}
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
- ape->seektablelength = get_le32(pb);
+ ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t);
} else
@@ -260,7 +260,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
- ape->seektable[i] = get_le32(pb);
+ ape->seektable[i] = avio_rl32(pb);
}
ape->frames[0].pos = ape->firstframe;
@@ -355,7 +355,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
AV_WL32(pkt->data , nblocks);
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
- ret = get_buffer(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
+ ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
pkt->pts = ape->frames[ape->currentframe].pts;
pkt->stream_index = 0;
diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 3265646f78..7252fd2b2c 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -38,10 +38,10 @@ static int ape_tag_read_field(AVFormatContext *s)
uint32_t size, flags;
int i, c;
- size = get_le32(pb); /* field size */
- flags = get_le32(pb); /* field flags */
+ size = avio_rl32(pb); /* field size */
+ flags = avio_rl32(pb); /* field flags */
for (i = 0; i < sizeof(key) - 1; i++) {
- c = get_byte(pb);
+ c = avio_r8(pb);
if (c < 0x20 || c > 0x7E)
break;
else
@@ -57,7 +57,7 @@ static int ape_tag_read_field(AVFormatContext *s)
value = av_malloc(size+1);
if (!value)
return AVERROR(ENOMEM);
- get_buffer(pb, value, size);
+ avio_read(pb, value, size);
value[size] = 0;
av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
return 0;
@@ -76,30 +76,30 @@ void ff_ape_parse_tag(AVFormatContext *s)
url_fseek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET);
- get_buffer(pb, buf, 8); /* APETAGEX */
+ avio_read(pb, buf, 8); /* APETAGEX */
if (strncmp(buf, "APETAGEX", 8)) {
return;
}
- val = get_le32(pb); /* APE tag version */
+ val = avio_rl32(pb); /* APE tag version */
if (val > APE_TAG_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION);
return;
}
- tag_bytes = get_le32(pb); /* tag size */
+ tag_bytes = avio_rl32(pb); /* tag size */
if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) {
av_log(s, AV_LOG_ERROR, "Tag size is way too big\n");
return;
}
- fields = get_le32(pb); /* number of fields */
+ fields = avio_rl32(pb); /* number of fields */
if (fields > 65536) {
av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields);
return;
}
- val = get_le32(pb); /* flags */
+ val = avio_rl32(pb); /* flags */
if (val & APE_TAG_FLAG_IS_HEADER) {
av_log(s, AV_LOG_ERROR, "APE Tag is a header\n");
return;
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index f5f439a2df..242f81cd6b 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -135,7 +135,7 @@ static void print_guid(const ff_asf_guid *g)
void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
assert(sizeof(*g) == 16);
- get_buffer(s, *g, sizeof(*g));
+ avio_read(s, *g, sizeof(*g));
}
static int asf_probe(AVProbeData *pd)
@@ -149,10 +149,10 @@ static int asf_probe(AVProbeData *pd)
static int get_value(AVIOContext *pb, int type){
switch(type){
- case 2: return get_le32(pb);
- case 3: return get_le32(pb);
- case 4: return get_le64(pb);
- case 5: return get_le16(pb);
+ case 2: return avio_rl32(pb);
+ case 3: return avio_rl32(pb);
+ case 4: return avio_rl64(pb);
+ case 5: return avio_rl16(pb);
default:return INT_MIN;
}
}
@@ -191,17 +191,17 @@ static int asf_read_file_properties(AVFormatContext *s, int64_t size)
AVIOContext *pb = s->pb;
ff_get_guid(pb, &asf->hdr.guid);
- asf->hdr.file_size = get_le64(pb);
- asf->hdr.create_time = get_le64(pb);
- get_le64(pb); /* number of packets */
- asf->hdr.play_time = get_le64(pb);
- asf->hdr.send_time = get_le64(pb);
- asf->hdr.preroll = get_le32(pb);
- asf->hdr.ignore = get_le32(pb);
- asf->hdr.flags = get_le32(pb);
- asf->hdr.min_pktsize = get_le32(pb);
- asf->hdr.max_pktsize = get_le32(pb);
- asf->hdr.max_bitrate = get_le32(pb);
+ asf->hdr.file_size = avio_rl64(pb);
+ asf->hdr.create_time = avio_rl64(pb);
+ avio_rl64(pb); /* number of packets */
+ asf->hdr.play_time = avio_rl64(pb);
+ asf->hdr.send_time = avio_rl64(pb);
+ asf->hdr.preroll = avio_rl32(pb);
+ asf->hdr.ignore = avio_rl32(pb);
+ asf->hdr.flags = avio_rl32(pb);
+ asf->hdr.min_pktsize = avio_rl32(pb);
+ asf->hdr.max_pktsize = avio_rl32(pb);
+ asf->hdr.max_bitrate = avio_rl32(pb);
s->packet_size = asf->hdr.max_pktsize;
return 0;
@@ -263,14 +263,14 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
return -1;
}
ff_get_guid(pb, &g);
- total_size = get_le64(pb);
- type_specific_size = get_le32(pb);
- get_le32(pb);
- st->id = get_le16(pb) & 0x7f; /* stream id */
+ total_size = avio_rl64(pb);
+ type_specific_size = avio_rl32(pb);
+ avio_rl32(pb);
+ st->id = avio_rl16(pb) & 0x7f; /* stream id */
// mapping of asf ID to AV stream ID;
asf->asfid2avid[st->id] = s->nb_streams - 1;
- get_le32(pb);
+ avio_rl32(pb);
if (test_for_ext_stream_audio) {
ff_get_guid(pb, &g);
@@ -278,11 +278,11 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
type = AVMEDIA_TYPE_AUDIO;
is_dvr_ms_audio=1;
ff_get_guid(pb, &g);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
ff_get_guid(pb, &g);
- get_le32(pb);
+ avio_rl32(pb);
}
}
@@ -303,11 +303,11 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
/* We have to init the frame size at some point .... */
pos2 = url_ftell(pb);
if (size >= (pos2 + 8 - pos1 + 24)) {
- asf_st->ds_span = get_byte(pb);
- asf_st->ds_packet_size = get_le16(pb);
- asf_st->ds_chunk_size = get_le16(pb);
- get_le16(pb); //ds_data_size
- get_byte(pb); //ds_silence_data
+ asf_st->ds_span = avio_r8(pb);
+ asf_st->ds_packet_size = avio_rl16(pb);
+ asf_st->ds_chunk_size = avio_rl16(pb);
+ avio_rl16(pb); //ds_data_size
+ avio_r8(pb); //ds_silence_data
}
//printf("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d\n",
// asf_st->ds_packet_size, asf_st->ds_chunk_size,
@@ -339,23 +339,23 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
}
} else if (type == AVMEDIA_TYPE_VIDEO &&
size - (url_ftell(pb) - pos1 + 24) >= 51) {
- get_le32(pb);
- get_le32(pb);
- get_byte(pb);
- get_le16(pb); /* size */
- sizeX= get_le32(pb); /* size */
- st->codec->width = get_le32(pb);
- st->codec->height = get_le32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_r8(pb);
+ avio_rl16(pb); /* size */
+ sizeX= avio_rl32(pb); /* size */
+ st->codec->width = avio_rl32(pb);
+ st->codec->height = avio_rl32(pb);
/* not available for asf */
- get_le16(pb); /* panes */
- st->codec->bits_per_coded_sample = get_le16(pb); /* depth */
- tag1 = get_le32(pb);
+ avio_rl16(pb); /* panes */
+ st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
+ tag1 = avio_rl32(pb);
url_fskip(pb, 20);
// av_log(s, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
if (sizeX > 40) {
st->codec->extradata_size = sizeX - 40;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
}
/* Extract palette from extradata if bpp <= 8 */
@@ -402,39 +402,39 @@ static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size)
uint32_t ext_d, leak_rate, stream_num;
unsigned int stream_languageid_index;
- get_le64(pb); // starttime
- get_le64(pb); // endtime
- leak_rate = get_le32(pb); // leak-datarate
- get_le32(pb); // bucket-datasize
- get_le32(pb); // init-bucket-fullness
- get_le32(pb); // alt-leak-datarate
- get_le32(pb); // alt-bucket-datasize
- get_le32(pb); // alt-init-bucket-fullness
- get_le32(pb); // max-object-size
- get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
- stream_num = get_le16(pb); // stream-num
-
- stream_languageid_index = get_le16(pb); // stream-language-id-index
+ avio_rl64(pb); // starttime
+ avio_rl64(pb); // endtime
+ leak_rate = avio_rl32(pb); // leak-datarate
+ avio_rl32(pb); // bucket-datasize
+ avio_rl32(pb); // init-bucket-fullness
+ avio_rl32(pb); // alt-leak-datarate
+ avio_rl32(pb); // alt-bucket-datasize
+ avio_rl32(pb); // alt-init-bucket-fullness
+ avio_rl32(pb); // max-object-size
+ avio_rl32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
+ stream_num = avio_rl16(pb); // stream-num
+
+ stream_languageid_index = avio_rl16(pb); // stream-language-id-index
if (stream_num < 128)
asf->streams[stream_num].stream_language_index = stream_languageid_index;
- get_le64(pb); // avg frametime in 100ns units
- stream_ct = get_le16(pb); //stream-name-count
- payload_ext_ct = get_le16(pb); //payload-extension-system-count
+ avio_rl64(pb); // avg frametime in 100ns units
+ stream_ct = avio_rl16(pb); //stream-name-count
+ payload_ext_ct = avio_rl16(pb); //payload-extension-system-count
if (stream_num < 128)
asf->stream_bitrates[stream_num] = leak_rate;
for (i=0; i<stream_ct; i++){
- get_le16(pb);
- ext_len = get_le16(pb);
+ avio_rl16(pb);
+ ext_len = avio_rl16(pb);
url_fseek(pb, ext_len, SEEK_CUR);
}
for (i=0; i<payload_ext_ct; i++){
ff_get_guid(pb, &g);
- ext_d=get_le16(pb);
- ext_len=get_le32(pb);
+ ext_d=avio_rl16(pb);
+ ext_len=avio_rl32(pb);
url_fseek(pb, ext_len, SEEK_CUR);
}
@@ -446,11 +446,11 @@ static int asf_read_content_desc(AVFormatContext *s, int64_t size)
AVIOContext *pb = s->pb;
int len1, len2, len3, len4, len5;
- len1 = get_le16(pb);
- len2 = get_le16(pb);
- len3 = get_le16(pb);
- len4 = get_le16(pb);
- len5 = get_le16(pb);
+ len1 = avio_rl16(pb);
+ len2 = avio_rl16(pb);
+ len3 = avio_rl16(pb);
+ len4 = avio_rl16(pb);
+ len5 = avio_rl16(pb);
get_tag(s, "title" , 0, len1);
get_tag(s, "author" , 0, len2);
get_tag(s, "copyright", 0, len3);
@@ -466,18 +466,18 @@ static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size)
ASFContext *asf = s->priv_data;
int desc_count, i, ret;
- desc_count = get_le16(pb);
+ desc_count = avio_rl16(pb);
for(i=0;i<desc_count;i++) {
int name_len,value_type,value_len;
char name[1024];
- name_len = get_le16(pb);
+ name_len = avio_rl16(pb);
if (name_len%2) // must be even, broken lavf versions wrote len-1
name_len += 1;
if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len)
url_fskip(pb, name_len - ret);
- value_type = get_le16(pb);
- value_len = get_le16(pb);
+ value_type = avio_rl16(pb);
+ value_len = avio_rl16(pb);
if (!value_type && value_len%2)
value_len += 1;
/**
@@ -500,10 +500,10 @@ static int asf_read_language_list(AVFormatContext *s, int64_t size)
AVIOContext *pb = s->pb;
ASFContext *asf = s->priv_data;
int j, ret;
- int stream_count = get_le16(pb);
+ int stream_count = avio_rl16(pb);
for(j = 0; j < stream_count; j++) {
char lang[6];
- unsigned int lang_len = get_byte(pb);
+ unsigned int lang_len = avio_r8(pb);
if ((ret = avio_get_str16le(pb, lang_len, lang, sizeof(lang))) < lang_len)
url_fskip(pb, lang_len - ret);
if (j < 128)
@@ -519,21 +519,21 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size)
ASFContext *asf = s->priv_data;
int n, stream_num, name_len, value_len, value_type, value_num;
int ret, i;
- n = get_le16(pb);
+ n = avio_rl16(pb);
for(i=0;i<n;i++) {
char name[1024];
- get_le16(pb); //lang_list_index
- stream_num= get_le16(pb);
- name_len= get_le16(pb);
- value_type= get_le16(pb);
- value_len= get_le32(pb);
+ avio_rl16(pb); //lang_list_index
+ stream_num= avio_rl16(pb);
+ name_len= avio_rl16(pb);
+ value_type= avio_rl16(pb);
+ value_len= avio_rl32(pb);
if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len)
url_fskip(pb, name_len - ret);
//av_log(s, AV_LOG_ERROR, "%d %d %d %d %d <%s>\n", i, stream_num, name_len, value_type, value_len, name);
- value_num= get_le16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
+ value_num= avio_rl16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
url_fskip(pb, value_len - 2);
if(stream_num<128){
@@ -551,25 +551,25 @@ static int asf_read_marker(AVFormatContext *s, int64_t size)
int i, count, name_len, ret;
char name[1024];
- get_le64(pb); // reserved 16 bytes
- get_le64(pb); // ...
- count = get_le32(pb); // markers count
- get_le16(pb); // reserved 2 bytes
- name_len = get_le16(pb); // name length
+ avio_rl64(pb); // reserved 16 bytes
+ avio_rl64(pb); // ...
+ count = avio_rl32(pb); // markers count
+ avio_rl16(pb); // reserved 2 bytes
+ name_len = avio_rl16(pb); // name length
for(i=0;i<name_len;i++){
- get_byte(pb); // skip the name
+ avio_r8(pb); // skip the name
}
for(i=0;i<count;i++){
int64_t pres_time;
int name_len;
- get_le64(pb); // offset, 8 bytes
- pres_time = get_le64(pb); // presentation time
- get_le16(pb); // entry length
- get_le32(pb); // send time
- get_le32(pb); // flags
- name_len = get_le32(pb); // name length
+ avio_rl64(pb); // offset, 8 bytes
+ pres_time = avio_rl64(pb); // presentation time
+ avio_rl16(pb); // entry length
+ avio_rl32(pb); // send time
+ avio_rl32(pb); // flags
+ name_len = avio_rl32(pb); // name length
if ((ret = avio_get_str16le(pb, name_len * 2, name, sizeof(name))) < name_len)
url_fskip(pb, name_len - ret);
ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name );
@@ -589,15 +589,15 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_get_guid(pb, &g);
if (ff_guidcmp(&g, &ff_asf_header))
return -1;
- get_le64(pb);
- get_le32(pb);
- get_byte(pb);
- get_byte(pb);
+ avio_rl64(pb);
+ avio_rl32(pb);
+ avio_r8(pb);
+ avio_r8(pb);
memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
for(;;) {
uint64_t gpos= url_ftell(pb);
ff_get_guid(pb, &g);
- gsize = get_le64(pb);
+ gsize = avio_rl64(pb);
av_dlog(s, "%08"PRIx64": ", gpos);
print_guid(&g);
av_dlog(s, " size=0x%"PRIx64"\n", gsize);
@@ -634,8 +634,8 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
} else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) {
int v1, v2;
ff_get_guid(pb, &g);
- v1 = get_le32(pb);
- v2 = get_le16(pb);
+ v1 = avio_rl32(pb);
+ v2 = avio_rl16(pb);
continue;
} else if (!ff_guidcmp(&g, &ff_asf_marker_header)) {
asf_read_marker(s, gsize);
@@ -657,9 +657,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fseek(pb, gpos + gsize, SEEK_SET);
}
ff_get_guid(pb, &g);
- get_le64(pb);
- get_byte(pb);
- get_byte(pb);
+ avio_rl64(pb);
+ avio_r8(pb);
+ avio_r8(pb);
if (url_feof(pb))
return -1;
asf->data_offset = url_ftell(pb);
@@ -704,9 +704,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
#define DO_2BITS(bits, var, defval) \
switch (bits & 3) \
{ \
- case 3: var = get_le32(pb); rsize += 4; break; \
- case 2: var = get_le16(pb); rsize += 2; break; \
- case 1: var = get_byte(pb); rsize++; break; \
+ case 3: var = avio_rl32(pb); rsize += 4; break; \
+ case 2: var = avio_rl16(pb); rsize += 2; break; \
+ case 1: var = avio_r8(pb); rsize++; break; \
default: var = defval; break; \
}
@@ -731,7 +731,7 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
c=d=e=-1;
while(off-- > 0){
c=d; d=e;
- e= get_byte(pb);
+ e= avio_r8(pb);
if(c == 0x82 && !d && !e)
break;
}
@@ -754,8 +754,8 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -1;
}
- c= get_byte(pb);
- d= get_byte(pb);
+ c= avio_r8(pb);
+ d= avio_r8(pb);
rsize+=3;
}else{
url_fseek(pb, -1, SEEK_CUR); //FIXME
@@ -778,12 +778,12 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
return -1;
}
- asf->packet_timestamp = get_le32(pb);
- get_le16(pb); /* duration */
+ asf->packet_timestamp = avio_rl32(pb);
+ avio_rl16(pb); /* duration */
// rsize has at least 11 bytes which have to be present
if (asf->packet_flags & 0x01) {
- asf->packet_segsizetype = get_byte(pb); rsize++;
+ asf->packet_segsizetype = avio_r8(pb); rsize++;
asf->packet_segments = asf->packet_segsizetype & 0x3f;
} else {
asf->packet_segments = 1;
@@ -804,7 +804,7 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
ASFContext *asf = s->priv_data;
int rsize = 1;
- int num = get_byte(pb);
+ int num = avio_r8(pb);
int64_t ts0, ts1;
asf->packet_segments--;
@@ -816,21 +816,21 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
//printf("key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, //asf->packet_frag_offset, asf->packet_replic_size);
if (asf->packet_replic_size >= 8) {
- asf->packet_obj_size = get_le32(pb);
+ asf->packet_obj_size = avio_rl32(pb);
if(asf->packet_obj_size >= (1<<24) || asf->packet_obj_size <= 0){
av_log(s, AV_LOG_ERROR, "packet_obj_size invalid\n");
return -1;
}
- asf->packet_frag_timestamp = get_le32(pb); // timestamp
+ asf->packet_frag_timestamp = avio_rl32(pb); // timestamp
if(asf->packet_replic_size >= 8+38+4){
// for(i=0; i<asf->packet_replic_size-8; i++)
-// av_log(s, AV_LOG_DEBUG, "%02X ",get_byte(pb));
+// av_log(s, AV_LOG_DEBUG, "%02X ",avio_r8(pb));
// av_log(s, AV_LOG_DEBUG, "\n");
url_fskip(pb, 10);
- ts0= get_le64(pb);
- ts1= get_le64(pb);
+ ts0= avio_rl64(pb);
+ ts1= avio_rl64(pb);
url_fskip(pb, 12);
- get_le32(pb);
+ avio_rl32(pb);
url_fskip(pb, asf->packet_replic_size - 8 - 38 - 4);
if(ts0!= -1) asf->packet_frag_timestamp= ts0/10000;
else asf->packet_frag_timestamp= AV_NOPTS_VALUE;
@@ -843,7 +843,7 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
asf->packet_frag_offset = 0;
asf->packet_frag_timestamp = asf->packet_timestamp;
- asf->packet_time_delta = get_byte(pb);
+ asf->packet_time_delta = avio_r8(pb);
rsize++;
}else if(asf->packet_replic_size!=0){
av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", asf->packet_replic_size);
@@ -928,7 +928,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk
// frag_offset is here used as the beginning timestamp
asf->packet_frag_timestamp = asf->packet_time_start;
asf->packet_time_start += asf->packet_time_delta;
- asf->packet_obj_size = asf->packet_frag_size = get_byte(pb);
+ asf->packet_obj_size = asf->packet_frag_size = avio_r8(pb);
asf->packet_size_left--;
asf->packet_multi_size--;
if (asf->packet_multi_size < asf->packet_obj_size)
@@ -988,7 +988,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk
continue;
}
- ret = get_buffer(pb, asf_st->pkt.data + asf->packet_frag_offset,
+ ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset,
asf->packet_frag_size);
if (ret != asf->packet_frag_size) {
if (ret < 0 || asf->packet_frag_offset + ret == 0)
@@ -1194,7 +1194,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
/* the data object can be followed by other top-level objects,
skip them until the simple index object is reached */
while (ff_guidcmp(&g, &index_guid)) {
- int64_t gsize= get_le64(s->pb);
+ int64_t gsize= avio_rl64(s->pb);
if (gsize < 24 || url_feof(s->pb)) {
url_fseek(s->pb, current_pos, SEEK_SET);
return;
@@ -1206,16 +1206,16 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
{
int64_t itime, last_pos=-1;
int pct, ict;
- int64_t av_unused gsize= get_le64(s->pb);
+ int64_t av_unused gsize= avio_rl64(s->pb);
ff_get_guid(s->pb, &g);
- itime=get_le64(s->pb);
- pct=get_le32(s->pb);
- ict=get_le32(s->pb);
+ itime=avio_rl64(s->pb);
+ pct=avio_rl32(s->pb);
+ ict=avio_rl32(s->pb);
av_log(s, AV_LOG_DEBUG, "itime:0x%"PRIx64", pct:%d, ict:%d\n",itime,pct,ict);
for (i=0;i<ict;i++){
- int pktnum=get_le32(s->pb);
- int pktct =get_le16(s->pb);
+ int pktnum=avio_rl32(s->pb);
+ int pktct =avio_rl16(s->pb);
int64_t pos = s->data_offset + s->packet_size*(int64_t)pktnum;
int64_t index_pts= av_rescale(itime, i, 10000);
diff --git a/libavformat/au.c b/libavformat/au.c
index fbcbc5ba07..16d53fec9d 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -127,15 +127,15 @@ static int au_read_header(AVFormatContext *s,
AVStream *st;
/* check ".snd" header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
- size = get_be32(pb); /* header size */
- get_be32(pb); /* data size */
+ size = avio_rb32(pb); /* header size */
+ avio_rb32(pb); /* data size */
- id = get_be32(pb);
- rate = get_be32(pb);
- channels = get_be32(pb);
+ id = avio_rb32(pb);
+ rate = avio_rb32(pb);
+ channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id);
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 7eda500422..b2db2dc36d 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -107,10 +107,10 @@ static int get_riff(AVFormatContext *s, AVIOContext *pb)
int i;
/* check RIFF header */
- get_buffer(pb, header, 4);
- avi->riff_end = get_le32(pb); /* RIFF chunk size */
+ avio_read(pb, header, 4);
+ avi->riff_end = avio_rl32(pb); /* RIFF chunk size */
avi->riff_end += url_ftell(pb); /* RIFF chunk end */
- get_buffer(pb, header+4, 4);
+ avio_read(pb, header+4, 4);
for(i=0; avi_headers[i][0]; i++)
if(!memcmp(header, avi_headers[i], 8))
@@ -127,12 +127,12 @@ static int get_riff(AVFormatContext *s, AVIOContext *pb)
static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
- int longs_pre_entry= get_le16(pb);
- int index_sub_type = get_byte(pb);
- int index_type = get_byte(pb);
- int entries_in_use = get_le32(pb);
- int chunk_id = get_le32(pb);
- int64_t base = get_le64(pb);
+ int longs_pre_entry= avio_rl16(pb);
+ int index_sub_type = avio_r8(pb);
+ int index_type = avio_r8(pb);
+ int entries_in_use = avio_rl32(pb);
+ int chunk_id = avio_rl32(pb);
+ int64_t base = avio_rl64(pb);
int stream_id= 10*((chunk_id&0xFF) - '0') + (((chunk_id>>8)&0xFF) - '0');
AVStream *st;
AVIStream *ast;
@@ -153,7 +153,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
if(index_sub_type)
return -1;
- get_le32(pb);
+ avio_rl32(pb);
if(index_type && longs_pre_entry != 2)
return -1;
@@ -170,8 +170,8 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
for(i=0; i<entries_in_use; i++){
if(index_type){
- int64_t pos= get_le32(pb) + base - 8;
- int len = get_le32(pb);
+ int64_t pos= avio_rl32(pb) + base - 8;
+ int len = avio_rl32(pb);
int key= len >= 0;
len &= 0x7FFFFFFF;
@@ -191,9 +191,9 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
}else{
int64_t offset, pos;
int duration;
- offset = get_le64(pb);
- get_le32(pb); /* size */
- duration = get_le32(pb);
+ offset = avio_rl64(pb);
+ avio_rl32(pb); /* size */
+ duration = avio_rl32(pb);
if(url_feof(pb))
return -1;
@@ -256,7 +256,7 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
value = av_malloc(size+1);
if (!value)
return -1;
- get_buffer(pb, value, size);
+ avio_read(pb, value, size);
value[size]=0;
AV_WL32(key, tag);
@@ -268,8 +268,8 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
static void avi_read_info(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
- uint32_t tag = get_le32(s->pb);
- uint32_t size = get_le32(s->pb);
+ uint32_t tag = avio_rl32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
avi_read_tag(s, NULL, tag, size);
}
}
@@ -299,17 +299,17 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
static void avi_read_nikon(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
- uint32_t tag = get_le32(s->pb);
- uint32_t size = get_le32(s->pb);
+ uint32_t tag = avio_rl32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
switch (tag) {
case MKTAG('n', 'c', 't', 'g'): { /* Nikon Tags */
uint64_t tag_end = url_ftell(s->pb) + size;
while (url_ftell(s->pb) < tag_end) {
- uint16_t tag = get_le16(s->pb);
- uint16_t size = get_le16(s->pb);
+ uint16_t tag = avio_rl16(s->pb);
+ uint16_t size = avio_rl16(s->pb);
const char *name = NULL;
char buffer[64] = {0};
- size -= get_buffer(s->pb, buffer,
+ size -= avio_read(s->pb, buffer,
FFMIN(size, sizeof(buffer)-1));
switch (tag) {
case 0x03: name = "maker"; break;
@@ -362,8 +362,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
for(;;) {
if (url_feof(pb))
goto fail;
- tag = get_le32(pb);
- size = get_le32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rl32(pb);
print_tag("tag", tag, size);
@@ -371,7 +371,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
case MKTAG('L', 'I', 'S', 'T'):
list_end = url_ftell(pb) + size;
/* Ignored, except at start of video packets. */
- tag1 = get_le32(pb);
+ tag1 = avio_rl32(pb);
print_tag("list", tag1, 0);
@@ -391,7 +391,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
case MKTAG('I', 'D', 'I', 'T'): {
unsigned char date[64] = {0};
size += (size & 1);
- size -= get_buffer(pb, date, FFMIN(size, sizeof(date)-1));
+ size -= avio_read(pb, date, FFMIN(size, sizeof(date)-1));
url_fskip(pb, size);
avi_metadata_creation_time(&s->metadata, date);
break;
@@ -405,24 +405,24 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
case MKTAG('a', 'v', 'i', 'h'):
/* AVI header */
/* using frame_period is bad idea */
- frame_period = get_le32(pb);
- bit_rate = get_le32(pb) * 8;
- get_le32(pb);
- avi->non_interleaved |= get_le32(pb) & AVIF_MUSTUSEINDEX;
+ frame_period = avio_rl32(pb);
+ bit_rate = avio_rl32(pb) * 8;
+ avio_rl32(pb);
+ avi->non_interleaved |= avio_rl32(pb) & AVIF_MUSTUSEINDEX;
url_fskip(pb, 2 * 4);
- get_le32(pb);
- get_le32(pb);
- avih_width=get_le32(pb);
- avih_height=get_le32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avih_width=avio_rl32(pb);
+ avih_height=avio_rl32(pb);
url_fskip(pb, size - 10 * 4);
break;
case MKTAG('s', 't', 'r', 'h'):
/* stream header */
- tag1 = get_le32(pb);
- handler = get_le32(pb); /* codec tag */
+ tag1 = avio_rl32(pb);
+ handler = avio_rl32(pb); /* codec tag */
if(tag1 == MKTAG('p', 'a', 'd', 's')){
url_fskip(pb, size - 8);
@@ -470,11 +470,11 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
s->streams[0]->priv_data = ast;
url_fskip(pb, 3 * 4);
- ast->scale = get_le32(pb);
- ast->rate = get_le32(pb);
+ ast->scale = avio_rl32(pb);
+ ast->rate = avio_rl32(pb);
url_fskip(pb, 4); /* start time */
- dv_dur = get_le32(pb);
+ dv_dur = avio_rl32(pb);
if (ast->scale > 0 && ast->rate > 0 && dv_dur > 0) {
dv_dur *= AV_TIME_BASE;
s->duration = av_rescale(dv_dur, ast->scale, ast->rate);
@@ -492,12 +492,12 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
assert(stream_index < s->nb_streams);
st->codec->stream_codec_tag= handler;
- get_le32(pb); /* flags */
- get_le16(pb); /* priority */
- get_le16(pb); /* language */
- get_le32(pb); /* initial frame */
- ast->scale = get_le32(pb);
- ast->rate = get_le32(pb);
+ avio_rl32(pb); /* flags */
+ avio_rl16(pb); /* priority */
+ avio_rl16(pb); /* language */
+ avio_rl32(pb); /* initial frame */
+ ast->scale = avio_rl32(pb);
+ ast->rate = avio_rl32(pb);
if(!(ast->scale && ast->rate)){
av_log(s, AV_LOG_WARNING, "scale/rate is %u/%u which is invalid. (This file has been generated by broken software.)\n", ast->scale, ast->rate);
if(frame_period){
@@ -510,13 +510,13 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
av_set_pts_info(st, 64, ast->scale, ast->rate);
- ast->cum_len=get_le32(pb); /* start */
- st->nb_frames = get_le32(pb);
+ ast->cum_len=avio_rl32(pb); /* start */
+ st->nb_frames = avio_rl32(pb);
st->start_time = 0;
- get_le32(pb); /* buffer size */
- get_le32(pb); /* quality */
- ast->sample_size = get_le32(pb); /* sample ssize */
+ avio_rl32(pb); /* buffer size */
+ avio_rl32(pb); /* quality */
+ ast->sample_size = avio_rl32(pb); /* sample ssize */
ast->cum_len *= FFMAX(1, ast->sample_size);
// av_log(s, AV_LOG_DEBUG, "%d %d %d %d\n", ast->rate, ast->scale, ast->start, ast->sample_size);
@@ -579,11 +579,11 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size= 0;
return AVERROR(ENOMEM);
}
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
}
if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
- get_byte(pb);
+ avio_r8(pb);
/* Extract palette from extradata if bpp <= 8. */
/* This code assumes that extradata contains only palette. */
@@ -675,17 +675,17 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVRational active, active_aspect;
st = s->streams[stream_index];
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
-
- active_aspect.den= get_le16(pb);
- active_aspect.num= get_le16(pb);
- active.num = get_le32(pb);
- active.den = get_le32(pb);
- get_le32(pb); //nbFieldsPerFrame
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+
+ active_aspect.den= avio_rl16(pb);
+ active_aspect.num= avio_rl16(pb);
+ active.num = avio_rl32(pb);
+ active.den = avio_rl32(pb);
+ avio_rl32(pb); //nbFieldsPerFrame
if(active_aspect.num && active_aspect.den && active.num && active.den){
st->sample_aspect_ratio= av_div_q(active_aspect, active);
@@ -756,7 +756,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
pkt->size - 7,
0, NULL, NULL, NULL, NULL);
AVProbeData pd;
- unsigned int desc_len = get_le32(pb);
+ unsigned int desc_len = avio_rl32(pb);
if (desc_len > pb->buf_end - pb->buf_ptr)
goto error;
@@ -766,8 +766,8 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
if (*desc)
av_metadata_set2(&st->metadata, "title", desc, 0);
- get_le16(pb); /* flags? */
- get_le32(pb); /* data size */
+ avio_rl16(pb); /* flags? */
+ avio_rl32(pb); /* data size */
pd = (AVProbeData) { .buf = pb->buf_ptr, .buf_size = pb->buf_end - pb->buf_ptr };
if (!(sub_demuxer = av_probe_input_format2(&pd, 1, &score)))
@@ -994,7 +994,7 @@ resync:
for(j=0; j<7; j++)
d[j]= d[j+1];
- d[7]= get_byte(pb);
+ d[7]= avio_r8(pb);
size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
@@ -1065,13 +1065,13 @@ resync:
}
if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) {
- int k = get_byte(pb);
- int last = (k + get_byte(pb) - 1) & 0xFF;
+ int k = avio_r8(pb);
+ int last = (k + avio_r8(pb) - 1) & 0xFF;
- get_le16(pb); //flags
+ avio_rl16(pb); //flags
for (; k <= last; k++)
- ast->pal[k] = get_be32(pb)>>8;// b + (g << 8) + (r << 16);
+ ast->pal[k] = avio_rb32(pb)>>8;// b + (g << 8) + (r << 16);
ast->has_pal= 1;
goto resync;
} else if( ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) ||
@@ -1123,10 +1123,10 @@ static int avi_read_idx1(AVFormatContext *s, int size)
/* Read the entries and sort them in each stream component. */
for(i = 0; i < nb_index_entries; i++) {
- tag = get_le32(pb);
- flags = get_le32(pb);
- pos = get_le32(pb);
- len = get_le32(pb);
+ tag = avio_rl32(pb);
+ flags = avio_rl32(pb);
+ pos = avio_rl32(pb);
+ len = avio_rl32(pb);
#if defined(DEBUG_SEEK)
av_log(s, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
i, tag, flags, pos, len);
@@ -1175,7 +1175,7 @@ static int guess_ni_flag(AVFormatContext *s){
if(n >= 2){
int64_t pos= st->index_entries[0].pos;
url_fseek(s->pb, pos + 4, SEEK_SET);
- size= get_le32(s->pb);
+ size= avio_rl32(s->pb);
if(pos + size > st->index_entries[1].pos)
last_start= INT64_MAX;
}
@@ -1205,8 +1205,8 @@ static int avi_load_index(AVFormatContext *s)
for(;;) {
if (url_feof(pb))
break;
- tag = get_le32(pb);
- size = get_le32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rl32(pb);
#ifdef DEBUG_SEEK
printf("tag=%c%c%c%c size=0x%x\n",
tag & 0xff,
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 4fb701696e..fa71d20d59 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -378,6 +378,25 @@ attribute_deprecated AVIOContext *av_alloc_put_byte(
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));
+
+/**
+ * @defgroup old_avio_funcs Old put_/get_*() functions
+ * @deprecated use the avio_ -prefixed functions instead.
+ * @{
+ */
+attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size);
+attribute_deprecated int get_byte(AVIOContext *s);
+attribute_deprecated unsigned int get_le16(AVIOContext *s);
+attribute_deprecated unsigned int get_le24(AVIOContext *s);
+attribute_deprecated unsigned int get_le32(AVIOContext *s);
+attribute_deprecated uint64_t get_le64(AVIOContext *s);
+attribute_deprecated unsigned int get_be16(AVIOContext *s);
+attribute_deprecated unsigned int get_be24(AVIOContext *s);
+attribute_deprecated unsigned int get_be32(AVIOContext *s);
+attribute_deprecated uint64_t get_be64(AVIOContext *s);
+/**
+ * @}
+ */
#endif
AVIOContext *avio_alloc_context(
@@ -477,7 +496,7 @@ void put_flush_packet(AVIOContext *s);
* Read size bytes from AVIOContext into buf.
* @return number of bytes read or AVERROR
*/
-int get_buffer(AVIOContext *s, unsigned char *buf, int size);
+int avio_read(AVIOContext *s, unsigned char *buf, int size);
/**
* Read size bytes from AVIOContext into buf.
@@ -489,11 +508,11 @@ int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
/** @note return 0 if EOF, so you cannot use it if EOF handling is
necessary */
-int get_byte(AVIOContext *s);
-unsigned int get_le24(AVIOContext *s);
-unsigned int get_le32(AVIOContext *s);
-uint64_t get_le64(AVIOContext *s);
-unsigned int get_le16(AVIOContext *s);
+int avio_r8 (AVIOContext *s);
+unsigned int avio_rl16(AVIOContext *s);
+unsigned int avio_rl24(AVIOContext *s);
+unsigned int avio_rl32(AVIOContext *s);
+uint64_t avio_rl64(AVIOContext *s);
/**
* Read a UTF-16 string from pb and convert it to UTF-8.
@@ -505,10 +524,10 @@ int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
char *get_strz(AVIOContext *s, char *buf, int maxlen);
-unsigned int get_be16(AVIOContext *s);
-unsigned int get_be24(AVIOContext *s);
-unsigned int get_be32(AVIOContext *s);
-uint64_t get_be64(AVIOContext *s);
+unsigned int avio_rb16(AVIOContext *s);
+unsigned int avio_rb24(AVIOContext *s);
+unsigned int avio_rb32(AVIOContext *s);
+uint64_t avio_rb64(AVIOContext *s);
uint64_t ff_get_v(AVIOContext *bc);
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index c3d69a185e..28825506d5 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -298,6 +298,32 @@ void put_strz(AVIOContext *s, const char *str)
{
avio_put_str(s, str);
}
+
+#define GET(name, type) \
+ type get_be ##name(AVIOContext *s) \
+{\
+ return avio_rb ##name(s);\
+}\
+ type get_le ##name(AVIOContext *s) \
+{\
+ return avio_rl ##name(s);\
+}
+
+GET(16, unsigned int)
+GET(24, unsigned int)
+GET(32, unsigned int)
+GET(64, uint64_t)
+
+#undef GET
+
+int get_byte(AVIOContext *s)
+{
+ return avio_r8(s);
+}
+int get_buffer(AVIOContext *s, unsigned char *buf, int size)
+{
+ return avio_read(s, buf, size);
+}
#endif
int avio_put_str(AVIOContext *s, const char *str)
@@ -457,7 +483,7 @@ void init_checksum(AVIOContext *s,
}
/* XXX: put an inline version */
-int get_byte(AVIOContext *s)
+int avio_r8(AVIOContext *s)
{
if (s->buf_ptr >= s->buf_end)
fill_buffer(s);
@@ -475,7 +501,7 @@ int url_fgetc(AVIOContext *s)
return URL_EOF;
}
-int get_buffer(AVIOContext *s, unsigned char *buf, int size)
+int avio_read(AVIOContext *s, unsigned char *buf, int size)
{
int len, size1;
@@ -545,58 +571,58 @@ int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size)
return len;
}
-unsigned int get_le16(AVIOContext *s)
+unsigned int avio_rl16(AVIOContext *s)
{
unsigned int val;
- val = get_byte(s);
- val |= get_byte(s) << 8;
+ val = avio_r8(s);
+ val |= avio_r8(s) << 8;
return val;
}
-unsigned int get_le24(AVIOContext *s)
+unsigned int avio_rl24(AVIOContext *s)
{
unsigned int val;
- val = get_le16(s);
- val |= get_byte(s) << 16;
+ val = avio_rl16(s);
+ val |= avio_r8(s) << 16;
return val;
}
-unsigned int get_le32(AVIOContext *s)
+unsigned int avio_rl32(AVIOContext *s)
{
unsigned int val;
- val = get_le16(s);
- val |= get_le16(s) << 16;
+ val = avio_rl16(s);
+ val |= avio_rl16(s) << 16;
return val;
}
-uint64_t get_le64(AVIOContext *s)
+uint64_t avio_rl64(AVIOContext *s)
{
uint64_t val;
- val = (uint64_t)get_le32(s);
- val |= (uint64_t)get_le32(s) << 32;
+ val = (uint64_t)avio_rl32(s);
+ val |= (uint64_t)avio_rl32(s) << 32;
return val;
}
-unsigned int get_be16(AVIOContext *s)
+unsigned int avio_rb16(AVIOContext *s)
{
unsigned int val;
- val = get_byte(s) << 8;
- val |= get_byte(s);
+ val = avio_r8(s) << 8;
+ val |= avio_r8(s);
return val;
}
-unsigned int get_be24(AVIOContext *s)
+unsigned int avio_rb24(AVIOContext *s)
{
unsigned int val;
- val = get_be16(s) << 8;
- val |= get_byte(s);
+ val = avio_rb16(s) << 8;
+ val |= avio_r8(s);
return val;
}
-unsigned int get_be32(AVIOContext *s)
+unsigned int avio_rb32(AVIOContext *s)
{
unsigned int val;
- val = get_be16(s) << 16;
- val |= get_be16(s);
+ val = avio_rb16(s) << 16;
+ val |= avio_rb16(s);
return val;
}
@@ -605,7 +631,7 @@ char *get_strz(AVIOContext *s, char *buf, int maxlen)
int i = 0;
char c;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if (i < maxlen-1)
buf[i++] = c;
}
@@ -621,7 +647,7 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
char c;
do {
- c = get_byte(s);
+ c = avio_r8(s);
if (c && i < maxlen-1)
buf[i++] = c;
} while (c != '\n' && c);
@@ -647,16 +673,16 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
return ret;\
}\
-GET_STR16(le, get_le16)
-GET_STR16(be, get_be16)
+GET_STR16(le, avio_rl16)
+GET_STR16(be, avio_rb16)
#undef GET_STR16
-uint64_t get_be64(AVIOContext *s)
+uint64_t avio_rb64(AVIOContext *s)
{
uint64_t val;
- val = (uint64_t)get_be32(s) << 32;
- val |= (uint64_t)get_be32(s);
+ val = (uint64_t)avio_rb32(s) << 32;
+ val |= (uint64_t)avio_rb32(s);
return val;
}
@@ -665,7 +691,7 @@ uint64_t ff_get_v(AVIOContext *bc){
int tmp;
do{
- tmp = get_byte(bc);
+ tmp = avio_r8(bc);
val= (val<<7) + (tmp&127);
}while(tmp&128);
return val;
diff --git a/libavformat/avs.c b/libavformat/avs.c
index 2e1b22439c..0ba5cebfdf 100644
--- a/libavformat/avs.c
+++ b/libavformat/avs.c
@@ -62,11 +62,11 @@ static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap)
s->ctx_flags |= AVFMTCTX_NOHEADER;
url_fskip(s->pb, 4);
- avs->width = get_le16(s->pb);
- avs->height = get_le16(s->pb);
- avs->bits_per_sample = get_le16(s->pb);
- avs->fps = get_le16(s->pb);
- avs->nb_frames = get_le32(s->pb);
+ avs->width = avio_rl16(s->pb);
+ avs->height = avio_rl16(s->pb);
+ avs->bits_per_sample = avio_rl16(s->pb);
+ avs->fps = avio_rl16(s->pb);
+ avs->nb_frames = avio_rl32(s->pb);
avs->remaining_frame_size = 0;
avs->remaining_audio_size = 0;
@@ -104,7 +104,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
pkt->data[palette_size + 1] = type;
pkt->data[palette_size + 2] = size & 0xFF;
pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
- ret = get_buffer(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
+ ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
if (ret < size) {
av_free_packet(pkt);
return AVERROR(EIO);
@@ -154,20 +154,20 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
while (1) {
if (avs->remaining_frame_size <= 0) {
- if (!get_le16(s->pb)) /* found EOF */
+ if (!avio_rl16(s->pb)) /* found EOF */
return AVERROR(EIO);
- avs->remaining_frame_size = get_le16(s->pb) - 4;
+ avs->remaining_frame_size = avio_rl16(s->pb) - 4;
}
while (avs->remaining_frame_size > 0) {
- sub_type = get_byte(s->pb);
- type = get_byte(s->pb);
- size = get_le16(s->pb);
+ sub_type = avio_r8(s->pb);
+ type = avio_r8(s->pb);
+ size = avio_rl16(s->pb);
avs->remaining_frame_size -= size;
switch (type) {
case AVS_PALETTE:
- ret = get_buffer(s->pb, palette, size - 4);
+ ret = avio_read(s->pb, palette, size - 4);
if (ret < size - 4)
return AVERROR(EIO);
palette_size = size;
diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index 017a8a6050..40d0e6296a 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -68,7 +68,7 @@ static int vid_read_header(AVFormatContext *s,
* int16s: always_512, nframes, width, height, delay, always_14
*/
url_fseek(pb, 5, SEEK_CUR);
- vid->nframes = get_le16(pb);
+ vid->nframes = avio_rl16(pb);
stream = av_new_stream(s, 0);
if (!stream)
@@ -76,11 +76,11 @@ static int vid_read_header(AVFormatContext *s,
av_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps
stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
stream->codec->codec_id = CODEC_ID_BETHSOFTVID;
- stream->codec->width = get_le16(pb);
- stream->codec->height = get_le16(pb);
+ stream->codec->width = avio_rl16(pb);
+ stream->codec->height = avio_rl16(pb);
stream->codec->pix_fmt = PIX_FMT_PAL8;
- vid->bethsoft_global_delay = get_le16(pb);
- get_le16(pb);
+ vid->bethsoft_global_delay = avio_rl16(pb);
+ avio_rl16(pb);
// done with video codec, set up audio codec
stream = av_new_stream(s, 0);
@@ -117,11 +117,11 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
vidbuf_start[vidbuf_nbytes++] = block_type;
// get the video delay (next int16), and set the presentation time
- vid->video_pts += vid->bethsoft_global_delay + get_le16(pb);
+ vid->video_pts += vid->bethsoft_global_delay + avio_rl16(pb);
// set the y offset if it exists (decoder header data should be in data section)
if(block_type == VIDEO_YOFF_P_FRAME){
- if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
+ if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
goto fail;
vidbuf_nbytes += 2;
}
@@ -131,21 +131,21 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
if(!vidbuf_start)
return AVERROR(ENOMEM);
- code = get_byte(pb);
+ code = avio_r8(pb);
vidbuf_start[vidbuf_nbytes++] = code;
if(code >= 0x80){ // rle sequence
if(block_type == VIDEO_I_FRAME)
- vidbuf_start[vidbuf_nbytes++] = get_byte(pb);
+ vidbuf_start[vidbuf_nbytes++] = avio_r8(pb);
} else if(code){ // plain sequence
- if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
+ if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
goto fail;
vidbuf_nbytes += code;
}
bytes_copied += code & 0x7F;
if(bytes_copied == npixels){ // sometimes no stop character is given, need to keep track of bytes copied
// may contain a 0 byte even if read all pixels
- if(get_byte(pb))
+ if(avio_r8(pb))
url_fseek(pb, -1, SEEK_CUR);
break;
}
@@ -182,7 +182,7 @@ static int vid_read_packet(AVFormatContext *s,
if(vid->is_finished || url_feof(pb))
return AVERROR(EIO);
- block_type = get_byte(pb);
+ block_type = avio_r8(pb);
switch(block_type){
case PALETTE_BLOCK:
url_fseek(pb, -1, SEEK_CUR); // include block type
@@ -195,12 +195,12 @@ static int vid_read_packet(AVFormatContext *s,
return ret_value;
case FIRST_AUDIO_BLOCK:
- get_le16(pb);
+ avio_rl16(pb);
// soundblaster DAC used for sample rate, as on specification page (link above)
- s->streams[1]->codec->sample_rate = 1000000 / (256 - get_byte(pb));
+ s->streams[1]->codec->sample_rate = 1000000 / (256 - avio_r8(pb));
s->streams[1]->codec->bit_rate = s->streams[1]->codec->channels * s->streams[1]->codec->sample_rate * s->streams[1]->codec->bits_per_coded_sample;
case AUDIO_BLOCK:
- audio_length = get_le16(pb);
+ audio_length = avio_rl16(pb);
ret_value = av_get_packet(pb, pkt, audio_length);
pkt->stream_index = 1;
return ret_value != audio_length ? AVERROR(EIO) : ret_value;
diff --git a/libavformat/bfi.c b/libavformat/bfi.c
index 40724b336d..7313e7b337 100644
--- a/libavformat/bfi.c
+++ b/libavformat/bfi.c
@@ -66,24 +66,24 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
/* Set the total number of frames. */
url_fskip(pb, 8);
- chunk_header = get_le32(pb);
- bfi->nframes = get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- fps = get_le32(pb);
+ chunk_header = avio_rl32(pb);
+ bfi->nframes = avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ fps = avio_rl32(pb);
url_fskip(pb, 12);
- vstream->codec->width = get_le32(pb);
- vstream->codec->height = get_le32(pb);
+ vstream->codec->width = avio_rl32(pb);
+ vstream->codec->height = avio_rl32(pb);
/*Load the palette to extradata */
url_fskip(pb, 8);
vstream->codec->extradata = av_malloc(768);
vstream->codec->extradata_size = 768;
- get_buffer(pb, vstream->codec->extradata,
+ avio_read(pb, vstream->codec->extradata,
vstream->codec->extradata_size);
- astream->codec->sample_rate = get_le32(pb);
+ astream->codec->sample_rate = avio_rl32(pb);
/* Set up the video codec... */
av_set_pts_info(vstream, 32, 1, fps);
@@ -119,14 +119,14 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
while(state != MKTAG('S','A','V','I')){
if (url_feof(pb))
return AVERROR(EIO);
- state = 256*state + get_byte(pb);
+ state = 256*state + avio_r8(pb);
}
/* Now that the chunk's location is confirmed, we proceed... */
- chunk_size = get_le32(pb);
- get_le32(pb);
- audio_offset = get_le32(pb);
- get_le32(pb);
- video_offset = get_le32(pb);
+ chunk_size = avio_rl32(pb);
+ avio_rl32(pb);
+ audio_offset = avio_rl32(pb);
+ avio_rl32(pb);
+ video_offset = avio_rl32(pb);
audio_size = video_offset - audio_offset;
bfi->video_size = chunk_size - video_offset;
diff --git a/libavformat/bink.c b/libavformat/bink.c
index f19229faf7..0087320ab5 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -82,17 +82,17 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!vst)
return AVERROR(ENOMEM);
- vst->codec->codec_tag = get_le32(pb);
+ vst->codec->codec_tag = avio_rl32(pb);
- bink->file_size = get_le32(pb) + 8;
- vst->duration = get_le32(pb);
+ bink->file_size = avio_rl32(pb) + 8;
+ vst->duration = avio_rl32(pb);
if (vst->duration > 1000000) {
av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n");
return AVERROR(EIO);
}
- if (get_le32(pb) > bink->file_size) {
+ if (avio_rl32(pb) > bink->file_size) {
av_log(s, AV_LOG_ERROR,
"invalid header: largest frame size greater than file size\n");
return AVERROR(EIO);
@@ -100,11 +100,11 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(pb, 4);
- vst->codec->width = get_le32(pb);
- vst->codec->height = get_le32(pb);
+ vst->codec->width = avio_rl32(pb);
+ vst->codec->height = avio_rl32(pb);
- fps_num = get_le32(pb);
- fps_den = get_le32(pb);
+ fps_num = avio_rl32(pb);
+ fps_den = avio_rl32(pb);
if (fps_num == 0 || fps_den == 0) {
av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den);
return AVERROR(EIO);
@@ -115,9 +115,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->codec_id = CODEC_ID_BINKVIDEO;
vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
vst->codec->extradata_size = 4;
- get_buffer(pb, vst->codec->extradata, 4);
+ avio_read(pb, vst->codec->extradata, 4);
- bink->num_audio_tracks = get_le32(pb);
+ bink->num_audio_tracks = avio_rl32(pb);
if (bink->num_audio_tracks > BINK_MAX_AUDIO_TRACKS) {
av_log(s, AV_LOG_ERROR,
@@ -135,9 +135,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_tag = 0;
- ast->codec->sample_rate = get_le16(pb);
+ ast->codec->sample_rate = avio_rl16(pb);
av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
- flags = get_le16(pb);
+ flags = avio_rl16(pb);
ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT;
ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1;
@@ -147,14 +147,14 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
}
/* frame index table */
- next_pos = get_le32(pb);
+ next_pos = avio_rl32(pb);
for (i = 0; i < vst->duration; i++) {
pos = next_pos;
if (i == vst->duration - 1) {
next_pos = bink->file_size;
keyframe = 0;
} else {
- next_pos = get_le32(pb);
+ next_pos = avio_rl32(pb);
keyframe = pos & 1;
}
pos &= ~1;
@@ -201,7 +201,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
while (bink->current_track < bink->num_audio_tracks) {
- uint32_t audio_size = get_le32(pb);
+ uint32_t audio_size = avio_rl32(pb);
if (audio_size > bink->remain_packet_size - 4) {
av_log(s, AV_LOG_ERROR,
"frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n",
diff --git a/libavformat/c93.c b/libavformat/c93.c
index 2beaebc356..3e3cd9cb0f 100644
--- a/libavformat/c93.c
+++ b/libavformat/c93.c
@@ -66,9 +66,9 @@ static int read_header(AVFormatContext *s,
int framecount = 0;
for (i = 0; i < 512; i++) {
- c93->block_records[i].index = get_le16(pb);
- c93->block_records[i].length = get_byte(pb);
- c93->block_records[i].frames = get_byte(pb);
+ c93->block_records[i].index = avio_rl16(pb);
+ c93->block_records[i].length = avio_r8(pb);
+ c93->block_records[i].frames = avio_r8(pb);
if (c93->block_records[i].frames > 32) {
av_log(s, AV_LOG_ERROR, "too many frames in block\n");
return AVERROR_INVALIDDATA;
@@ -114,7 +114,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if (c93->next_pkt_is_audio) {
c93->current_frame++;
c93->next_pkt_is_audio = 0;
- datasize = get_le16(pb);
+ datasize = avio_rl16(pb);
if (datasize > 42) {
if (!c93->audio) {
c93->audio = av_new_stream(s, 1);
@@ -142,13 +142,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if (c93->current_frame == 0) {
url_fseek(pb, br->index * 2048, SEEK_SET);
for (i = 0; i < 32; i++) {
- c93->frame_offsets[i] = get_le32(pb);
+ c93->frame_offsets[i] = avio_rl32(pb);
}
}
url_fseek(pb,br->index * 2048 +
c93->frame_offsets[c93->current_frame], SEEK_SET);
- datasize = get_le16(pb); /* video frame size */
+ datasize = avio_rl16(pb); /* video frame size */
ret = av_new_packet(pkt, datasize + 768 + 1);
if (ret < 0)
@@ -156,13 +156,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = 0;
pkt->size = datasize + 1;
- ret = get_buffer(pb, pkt->data + 1, datasize);
+ ret = avio_read(pb, pkt->data + 1, datasize);
if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
}
- datasize = get_le16(pb); /* palette size */
+ datasize = avio_rl16(pb); /* palette size */
if (datasize) {
if (datasize != 768) {
av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize);
@@ -170,7 +170,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
goto fail;
}
pkt->data[0] |= C93_HAS_PALETTE;
- ret = get_buffer(pb, pkt->data + pkt->size, datasize);
+ ret = avio_read(pb, pkt->data + pkt->size, datasize);
if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 27e29a2ea8..86f1005fdc 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -65,14 +65,14 @@ static int read_desc_chunk(AVFormatContext *s)
/* parse format description */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->sample_rate = av_int2dbl(get_be64(pb));
- st->codec->codec_tag = get_be32(pb);
- flags = get_be32(pb);
- caf->bytes_per_packet = get_be32(pb);
+ st->codec->sample_rate = av_int2dbl(avio_rb64(pb));
+ st->codec->codec_tag = avio_rb32(pb);
+ flags = avio_rb32(pb);
+ caf->bytes_per_packet = avio_rb32(pb);
st->codec->block_align = caf->bytes_per_packet;
- caf->frames_per_packet = get_be32(pb);
- st->codec->channels = get_be32(pb);
- st->codec->bits_per_coded_sample = get_be32(pb);
+ caf->frames_per_packet = avio_rb32(pb);
+ st->codec->channels = avio_rb32(pb);
+ st->codec->bits_per_coded_sample = avio_rb32(pb);
/* calculate bit rate for constant size packets */
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
@@ -127,14 +127,14 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, ALAC_HEADER);
+ avio_read(pb, st->codec->extradata, ALAC_HEADER);
st->codec->extradata_size = ALAC_HEADER;
url_fskip(pb, size - ALAC_PREAMBLE - ALAC_HEADER);
} else {
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, size);
+ avio_read(pb, st->codec->extradata, size);
st->codec->extradata_size = size;
}
@@ -152,13 +152,13 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
ccount = url_ftell(pb);
- num_packets = get_be64(pb);
+ num_packets = avio_rb64(pb);
if (num_packets < 0 || INT32_MAX / sizeof(AVIndexEntry) < num_packets)
return AVERROR_INVALIDDATA;
- st->nb_frames = get_be64(pb); /* valid frames */
- st->nb_frames += get_be32(pb); /* priming frames */
- st->nb_frames += get_be32(pb); /* remainder frames */
+ st->nb_frames = avio_rb64(pb); /* valid frames */
+ st->nb_frames += avio_rb32(pb); /* priming frames */
+ st->nb_frames += avio_rb32(pb); /* remainder frames */
st->duration = 0;
for (i = 0; i < num_packets; i++) {
@@ -181,7 +181,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
{
AVIOContext *pb = s->pb;
unsigned int i;
- unsigned int nb_entries = get_be32(pb);
+ unsigned int nb_entries = avio_rb32(pb);
for (i = 0; i < nb_entries; i++) {
char key[32];
char value[1024];
@@ -204,11 +204,11 @@ static int read_header(AVFormatContext *s,
url_fskip(pb, 8); /* magic, version, file flags */
/* audio description chunk */
- if (get_be32(pb) != MKBETAG('d','e','s','c')) {
+ if (avio_rb32(pb) != MKBETAG('d','e','s','c')) {
av_log(s, AV_LOG_ERROR, "desc chunk not present\n");
return AVERROR_INVALIDDATA;
}
- size = get_be64(pb);
+ size = avio_rb64(pb);
if (size != 32)
return AVERROR_INVALIDDATA;
@@ -226,8 +226,8 @@ static int read_header(AVFormatContext *s,
if (found_data && (caf->data_size < 0 || url_is_streamed(pb)))
break;
- tag = get_be32(pb);
- size = get_be64(pb);
+ tag = avio_rb32(pb);
+ size = avio_rb64(pb);
if (url_feof(pb))
break;
diff --git a/libavformat/daud.c b/libavformat/daud.c
index b59fad98e0..c4931961ec 100644
--- a/libavformat/daud.c
+++ b/libavformat/daud.c
@@ -40,8 +40,8 @@ static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
int ret, size;
if (url_feof(pb))
return AVERROR(EIO);
- size = get_be16(pb);
- get_be16(pb); // unknown
+ size = avio_rb16(pb);
+ avio_rb16(pb); // unknown
ret = av_get_packet(pb, pkt, size);
pkt->stream_index = 0;
return ret;
diff --git a/libavformat/dsicin.c b/libavformat/dsicin.c
index 17807fb6d0..328f901463 100644
--- a/libavformat/dsicin.c
+++ b/libavformat/dsicin.c
@@ -73,16 +73,16 @@ static int cin_probe(AVProbeData *p)
static int cin_read_file_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFileHeader *hdr = &cin->file_header;
- if (get_le32(pb) != 0x55AA0000)
+ if (avio_rl32(pb) != 0x55AA0000)
return AVERROR_INVALIDDATA;
- hdr->video_frame_size = get_le32(pb);
- hdr->video_frame_width = get_le16(pb);
- hdr->video_frame_height = get_le16(pb);
- hdr->audio_frequency = get_le32(pb);
- hdr->audio_bits = get_byte(pb);
- hdr->audio_stereo = get_byte(pb);
- hdr->audio_frame_size = get_le16(pb);
+ hdr->video_frame_size = avio_rl32(pb);
+ hdr->video_frame_width = avio_rl16(pb);
+ hdr->video_frame_height = avio_rl16(pb);
+ hdr->audio_frequency = avio_rl32(pb);
+ hdr->audio_bits = avio_r8(pb);
+ hdr->audio_stereo = avio_r8(pb);
+ hdr->audio_frame_size = avio_rl16(pb);
if (hdr->audio_frequency != 22050 || hdr->audio_bits != 16 || hdr->audio_stereo != 0)
return AVERROR_INVALIDDATA;
@@ -141,16 +141,16 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFrameHeader *hdr = &cin->frame_header;
- hdr->video_frame_type = get_byte(pb);
- hdr->audio_frame_type = get_byte(pb);
- hdr->pal_colors_count = get_le16(pb);
- hdr->video_frame_size = get_le32(pb);
- hdr->audio_frame_size = get_le32(pb);
+ hdr->video_frame_type = avio_r8(pb);
+ hdr->audio_frame_type = avio_r8(pb);
+ hdr->pal_colors_count = avio_rl16(pb);
+ hdr->video_frame_size = avio_rl32(pb);
+ hdr->audio_frame_size = avio_rl32(pb);
if (url_feof(pb) || url_ferror(pb))
return AVERROR(EIO);
- if (get_le32(pb) != 0xAA55AA55)
+ if (avio_rl32(pb) != 0xAA55AA55)
return AVERROR_INVALIDDATA;
return 0;
@@ -191,7 +191,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[2] = hdr->pal_colors_count >> 8;
pkt->data[3] = hdr->video_frame_type;
- ret = get_buffer(pb, &pkt->data[4], pkt_size);
+ ret = avio_read(pb, &pkt->data[4], pkt_size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
diff --git a/libavformat/dv.c b/libavformat/dv.c
index 1f05eb2d44..0598607ff4 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -410,7 +410,7 @@ static int dv_read_header(AVFormatContext *s,
if (!c->dv_demux)
return -1;
- state = get_be32(s->pb);
+ state = avio_rb32(s->pb);
while ((state & 0xffffff7f) != 0x1f07003f) {
if (url_feof(s->pb)) {
av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
@@ -420,14 +420,14 @@ static int dv_read_header(AVFormatContext *s,
marker_pos = url_ftell(s->pb);
if (state == 0xff3f0701 && url_ftell(s->pb) - marker_pos == 80) {
url_fseek(s->pb, -163, SEEK_CUR);
- state = get_be32(s->pb);
+ state = avio_rb32(s->pb);
break;
}
- state = (state << 8) | get_byte(s->pb);
+ state = (state << 8) | avio_r8(s->pb);
}
AV_WB32(c->buf, state);
- if (get_buffer(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 ||
+ if (avio_read(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 ||
url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
return AVERROR(EIO);
@@ -455,7 +455,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!c->dv_demux->sys)
return AVERROR(EIO);
size = c->dv_demux->sys->frame_size;
- if (get_buffer(s->pb, c->buf, size) <= 0)
+ if (avio_read(s->pb, c->buf, size) <= 0)
return AVERROR(EIO);
size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);
diff --git a/libavformat/dxa.c b/libavformat/dxa.c
index a10ece8c8b..188fc29d63 100644
--- a/libavformat/dxa.c
+++ b/libavformat/dxa.c
@@ -61,17 +61,17 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
int num, den;
int flags;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('D', 'E', 'X', 'A'))
return -1;
- flags = get_byte(pb);
- c->frames = get_be16(pb);
+ flags = avio_r8(pb);
+ c->frames = avio_rb16(pb);
if(!c->frames){
av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
return -1;
}
- fps = get_be32(pb);
+ fps = avio_rb32(pb);
if(fps > 0){
den = 1000;
num = fps;
@@ -82,8 +82,8 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
den = 10;
num = 1;
}
- w = get_be16(pb);
- h = get_be16(pb);
+ w = avio_rb16(pb);
+ h = avio_rb16(pb);
c->has_sound = 0;
st = av_new_stream(s, 0);
@@ -91,13 +91,13 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
// Parse WAV data header
- if(get_le32(pb) == MKTAG('W', 'A', 'V', 'E')){
+ if(avio_rl32(pb) == MKTAG('W', 'A', 'V', 'E')){
uint32_t size, fsize;
c->has_sound = 1;
- size = get_be32(pb);
+ size = avio_rb32(pb);
c->vidpos = url_ftell(pb) + size;
url_fskip(pb, 16);
- fsize = get_le32(pb);
+ fsize = avio_rl32(pb);
ast = av_new_stream(s, 0);
if (!ast)
@@ -105,8 +105,8 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_get_wav_header(pb, ast->codec, fsize);
// find 'data' chunk
while(url_ftell(pb) < c->vidpos && !url_feof(pb)){
- tag = get_le32(pb);
- fsize = get_le32(pb);
+ tag = avio_rl32(pb);
+ fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break;
url_fskip(pb, fsize);
}
@@ -163,7 +163,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
}
url_fseek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){
- get_buffer(s->pb, buf, 4);
+ avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(pkt, 4 + pal_size) < 0)
@@ -178,10 +178,10 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
case MKTAG('C', 'M', 'A', 'P'):
pal_size = 768+4;
memcpy(pal, buf, 4);
- get_buffer(s->pb, pal + 4, 768);
+ avio_read(s->pb, pal + 4, 768);
break;
case MKTAG('F', 'R', 'A', 'M'):
- get_buffer(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
+ avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
size = AV_RB32(buf + 5);
if(size > 0xFFFFFF){
av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
@@ -190,7 +190,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
- ret = get_buffer(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
+ ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){
av_free_packet(pkt);
return AVERROR(EIO);
diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c
index 93ccf8acb2..6f3564e397 100644
--- a/libavformat/eacdata.c
+++ b/libavformat/eacdata.c
@@ -51,7 +51,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap)
unsigned int sample_rate, header;
AVStream *st;
- header = get_be16(pb);
+ header = avio_rb16(pb);
switch (header) {
case 0x0400: cdata->channels = 1; break;
case 0x0404: cdata->channels = 2; break;
@@ -61,7 +61,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
};
- sample_rate = get_be16(pb);
+ sample_rate = avio_rb16(pb);
url_fskip(pb, 12);
st = av_new_stream(s, 0);
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index 0f4843d4e9..6179d22e60 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -82,11 +82,11 @@ static uint32_t read_arbitary(AVIOContext *pb) {
int i;
uint32_t word;
- size = get_byte(pb);
+ size = avio_r8(pb);
word = 0;
for (i = 0; i < size; i++) {
- byte = get_byte(pb);
+ byte = avio_r8(pb);
word <<= 8;
word |= byte;
}
@@ -112,7 +112,7 @@ static int process_audio_header_elements(AVFormatContext *s)
while (!url_feof(pb) && inHeader) {
int inSubheader;
uint8_t byte;
- byte = get_byte(pb);
+ byte = avio_r8(pb);
switch (byte) {
case 0xFD:
@@ -120,7 +120,7 @@ static int process_audio_header_elements(AVFormatContext *s)
inSubheader = 1;
while (!url_feof(pb) && inSubheader) {
uint8_t subbyte;
- subbyte = get_byte(pb);
+ subbyte = avio_r8(pb);
switch (subbyte) {
case 0x80:
@@ -218,10 +218,10 @@ static int process_audio_header_eacs(AVFormatContext *s)
AVIOContext *pb = s->pb;
int compression_type;
- ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb);
- ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */
- ea->num_channels = get_byte(pb);
- compression_type = get_byte(pb);
+ ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
+ ea->bytes = avio_r8(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = avio_r8(pb);
+ compression_type = avio_r8(pb);
url_fskip(pb, 13);
switch (compression_type) {
@@ -249,9 +249,9 @@ static int process_audio_header_sead(AVFormatContext *s)
EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb;
- ea->sample_rate = get_le32(pb);
- ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */
- ea->num_channels = get_le32(pb);
+ ea->sample_rate = avio_rl32(pb);
+ ea->bytes = avio_rl32(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = avio_rl32(pb);
ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD;
return 1;
@@ -262,8 +262,8 @@ static int process_video_header_mdec(AVFormatContext *s)
EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb;
url_fskip(pb, 4);
- ea->width = get_le16(pb);
- ea->height = get_le16(pb);
+ ea->width = avio_rl16(pb);
+ ea->height = avio_rl16(pb);
ea->time_base = (AVRational){1,15};
ea->video_codec = CODEC_ID_MDEC;
return 1;
@@ -275,8 +275,8 @@ static int process_video_header_vp6(AVFormatContext *s)
AVIOContext *pb = s->pb;
url_fskip(pb, 16);
- ea->time_base.den = get_le32(pb);
- ea->time_base.num = get_le32(pb);
+ ea->time_base.den = avio_rl32(pb);
+ ea->time_base.num = avio_rl32(pb);
ea->video_codec = CODEC_ID_VP6;
return 1;
@@ -296,8 +296,8 @@ static int process_ea_header(AVFormatContext *s) {
unsigned int startpos = url_ftell(pb);
int err = 0;
- blockid = get_le32(pb);
- size = get_le32(pb);
+ blockid = avio_rl32(pb);
+ size = avio_rl32(pb);
if (i == 0)
ea->big_endian = size > 0x000FFFFF;
if (ea->big_endian)
@@ -305,7 +305,7 @@ static int process_ea_header(AVFormatContext *s) {
switch (blockid) {
case ISNh_TAG:
- if (get_le32(pb) != EACS_TAG) {
+ if (avio_rl32(pb) != EACS_TAG) {
av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n");
return 0;
}
@@ -314,7 +314,7 @@ static int process_ea_header(AVFormatContext *s) {
case SCHl_TAG :
case SHEN_TAG :
- blockid = get_le32(pb);
+ blockid = avio_rl32(pb);
if (blockid == GSTR_TAG) {
url_fskip(pb, 4);
} else if ((blockid & 0xFFFF)!=PT00_TAG) {
@@ -467,8 +467,8 @@ static int ea_read_packet(AVFormatContext *s,
int av_uninit(num_samples);
while (!packet_read) {
- chunk_type = get_le32(pb);
- chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8;
+ chunk_type = avio_rl32(pb);
+ chunk_size = (ea->big_endian ? avio_rb32(pb) : avio_rl32(pb)) - 8;
switch (chunk_type) {
/* audio data */
@@ -485,7 +485,7 @@ static int ea_read_packet(AVFormatContext *s,
break;
} else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR ||
ea->audio_codec == CODEC_ID_MP3) {
- num_samples = get_le32(pb);
+ num_samples = avio_rl32(pb);
url_fskip(pb, 8);
chunk_size -= 12;
}
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 771209056b..1ae1422ea2 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -95,7 +95,7 @@ static int ffm_resync(AVFormatContext *s, int state)
av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
return -1;
}
- state = (state << 8) | get_byte(s->pb);
+ state = (state << 8) | avio_r8(s->pb);
}
return 0;
}
@@ -120,14 +120,14 @@ static int ffm_read_data(AVFormatContext *s,
if (url_ftell(pb) == ffm->file_size)
url_fseek(pb, ffm->packet_size, SEEK_SET);
retry_read:
- id = get_be16(pb); /* PACKET_ID */
+ id = avio_rb16(pb); /* PACKET_ID */
if (id != PACKET_ID)
if (ffm_resync(s, id) < 0)
return -1;
- fill_size = get_be16(pb);
- ffm->dts = get_be64(pb);
- frame_offset = get_be16(pb);
- get_buffer(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
+ fill_size = avio_rb16(pb);
+ ffm->dts = avio_rb64(pb);
+ frame_offset = avio_rb16(pb);
+ avio_read(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);
if (ffm->packet_end < ffm->packet || frame_offset < 0)
return -1;
@@ -188,7 +188,7 @@ static int64_t get_dts(AVFormatContext *s, int64_t pos)
ffm_seek1(s, pos);
url_fskip(pb, 4);
- dts = get_be64(pb);
+ dts = avio_rb64(pb);
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0);
#endif
@@ -273,13 +273,13 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
uint32_t tag;
/* header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('F', 'F', 'M', '1'))
goto fail;
- ffm->packet_size = get_be32(pb);
+ ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE)
goto fail;
- ffm->write_index = get_be64(pb);
+ ffm->write_index = avio_rb64(pb);
/* get also filesize */
if (!url_is_streamed(pb)) {
ffm->file_size = url_fsize(pb);
@@ -289,8 +289,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
ffm->file_size = (UINT64_C(1) << 63) - 1;
}
- nb_streams = get_be32(pb);
- get_be32(pb); /* total bitrate */
+ nb_streams = avio_rb32(pb);
+ avio_rb32(pb); /* total bitrate */
/* read each stream */
for(i=0;i<nb_streams;i++) {
char rc_eq_buf[128];
@@ -303,85 +303,85 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec = st->codec;
/* generic info */
- codec->codec_id = get_be32(pb);
- codec->codec_type = get_byte(pb); /* codec_type */
- codec->bit_rate = get_be32(pb);
- st->quality = get_be32(pb);
- codec->flags = get_be32(pb);
- codec->flags2 = get_be32(pb);
- codec->debug = get_be32(pb);
+ codec->codec_id = avio_rb32(pb);
+ codec->codec_type = avio_r8(pb); /* codec_type */
+ codec->bit_rate = avio_rb32(pb);
+ st->quality = avio_rb32(pb);
+ codec->flags = avio_rb32(pb);
+ codec->flags2 = avio_rb32(pb);
+ codec->debug = avio_rb32(pb);
/* specific info */
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- codec->time_base.num = get_be32(pb);
- codec->time_base.den = get_be32(pb);
- codec->width = get_be16(pb);
- codec->height = get_be16(pb);
- codec->gop_size = get_be16(pb);
- codec->pix_fmt = get_be32(pb);
- codec->qmin = get_byte(pb);
- codec->qmax = get_byte(pb);
- codec->max_qdiff = get_byte(pb);
- codec->qcompress = get_be16(pb) / 10000.0;
- codec->qblur = get_be16(pb) / 10000.0;
- codec->bit_rate_tolerance = get_be32(pb);
+ codec->time_base.num = avio_rb32(pb);
+ codec->time_base.den = avio_rb32(pb);
+ codec->width = avio_rb16(pb);
+ codec->height = avio_rb16(pb);
+ codec->gop_size = avio_rb16(pb);
+ codec->pix_fmt = avio_rb32(pb);
+ codec->qmin = avio_r8(pb);
+ codec->qmax = avio_r8(pb);
+ codec->max_qdiff = avio_r8(pb);
+ codec->qcompress = avio_rb16(pb) / 10000.0;
+ codec->qblur = avio_rb16(pb) / 10000.0;
+ codec->bit_rate_tolerance = avio_rb32(pb);
codec->rc_eq = av_strdup(get_strz(pb, rc_eq_buf, sizeof(rc_eq_buf)));
- codec->rc_max_rate = get_be32(pb);
- codec->rc_min_rate = get_be32(pb);
- codec->rc_buffer_size = get_be32(pb);
- codec->i_quant_factor = av_int2dbl(get_be64(pb));
- codec->b_quant_factor = av_int2dbl(get_be64(pb));
- codec->i_quant_offset = av_int2dbl(get_be64(pb));
- codec->b_quant_offset = av_int2dbl(get_be64(pb));
- codec->dct_algo = get_be32(pb);
- codec->strict_std_compliance = get_be32(pb);
- codec->max_b_frames = get_be32(pb);
- codec->luma_elim_threshold = get_be32(pb);
- codec->chroma_elim_threshold = get_be32(pb);
- codec->mpeg_quant = get_be32(pb);
- codec->intra_dc_precision = get_be32(pb);
- codec->me_method = get_be32(pb);
- codec->mb_decision = get_be32(pb);
- codec->nsse_weight = get_be32(pb);
- codec->frame_skip_cmp = get_be32(pb);
- codec->rc_buffer_aggressivity = av_int2dbl(get_be64(pb));
- codec->codec_tag = get_be32(pb);
- codec->thread_count = get_byte(pb);
- codec->coder_type = get_be32(pb);
- codec->me_cmp = get_be32(pb);
- codec->partitions = get_be32(pb);
- codec->me_subpel_quality = get_be32(pb);
- codec->me_range = get_be32(pb);
- codec->keyint_min = get_be32(pb);
- codec->scenechange_threshold = get_be32(pb);
- codec->b_frame_strategy = get_be32(pb);
- codec->qcompress = av_int2dbl(get_be64(pb));
- codec->qblur = av_int2dbl(get_be64(pb));
- codec->max_qdiff = get_be32(pb);
- codec->refs = get_be32(pb);
- codec->directpred = get_be32(pb);
+ codec->rc_max_rate = avio_rb32(pb);
+ codec->rc_min_rate = avio_rb32(pb);
+ codec->rc_buffer_size = avio_rb32(pb);
+ codec->i_quant_factor = av_int2dbl(avio_rb64(pb));
+ codec->b_quant_factor = av_int2dbl(avio_rb64(pb));
+ codec->i_quant_offset = av_int2dbl(avio_rb64(pb));
+ codec->b_quant_offset = av_int2dbl(avio_rb64(pb));
+ codec->dct_algo = avio_rb32(pb);
+ codec->strict_std_compliance = avio_rb32(pb);
+ codec->max_b_frames = avio_rb32(pb);
+ codec->luma_elim_threshold = avio_rb32(pb);
+ codec->chroma_elim_threshold = avio_rb32(pb);
+ codec->mpeg_quant = avio_rb32(pb);
+ codec->intra_dc_precision = avio_rb32(pb);
+ codec->me_method = avio_rb32(pb);
+ codec->mb_decision = avio_rb32(pb);
+ codec->nsse_weight = avio_rb32(pb);
+ codec->frame_skip_cmp = avio_rb32(pb);
+ codec->rc_buffer_aggressivity = av_int2dbl(avio_rb64(pb));
+ codec->codec_tag = avio_rb32(pb);
+ codec->thread_count = avio_r8(pb);
+ codec->coder_type = avio_rb32(pb);
+ codec->me_cmp = avio_rb32(pb);
+ codec->partitions = avio_rb32(pb);
+ codec->me_subpel_quality = avio_rb32(pb);
+ codec->me_range = avio_rb32(pb);
+ codec->keyint_min = avio_rb32(pb);
+ codec->scenechange_threshold = avio_rb32(pb);
+ codec->b_frame_strategy = avio_rb32(pb);
+ codec->qcompress = av_int2dbl(avio_rb64(pb));
+ codec->qblur = av_int2dbl(avio_rb64(pb));
+ codec->max_qdiff = avio_rb32(pb);
+ codec->refs = avio_rb32(pb);
+ codec->directpred = avio_rb32(pb);
break;
case AVMEDIA_TYPE_AUDIO:
- codec->sample_rate = get_be32(pb);
- codec->channels = get_le16(pb);
- codec->frame_size = get_le16(pb);
- codec->sample_fmt = (int16_t) get_le16(pb);
+ codec->sample_rate = avio_rb32(pb);
+ codec->channels = avio_rl16(pb);
+ codec->frame_size = avio_rl16(pb);
+ codec->sample_fmt = (int16_t) avio_rl16(pb);
break;
default:
goto fail;
}
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
- codec->extradata_size = get_be32(pb);
+ codec->extradata_size = avio_rb32(pb);
codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_read(pb, codec->extradata, codec->extradata_size);
}
}
/* get until end of block reached */
while ((url_ftell(pb) % ffm->packet_size) != 0)
- get_byte(pb);
+ avio_r8(pb);
/* init packet demux */
ffm->packet_ptr = ffm->packet;
diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c
index a7ae72f632..cc7e1da48f 100644
--- a/libavformat/ffmetadec.c
+++ b/libavformat/ffmetadec.c
@@ -36,11 +36,11 @@ static void get_line(AVIOContext *s, uint8_t *buf, int size)
uint8_t c;
int i = 0;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if (c == '\\') {
if (i < size - 1)
buf[i++] = c;
- c = get_byte(s);
+ c = avio_r8(s);
} else if (c == '\n')
break;
diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c
index 262bb23390..87219c83ff 100644
--- a/libavformat/filmstripdec.c
+++ b/libavformat/filmstripdec.c
@@ -44,7 +44,7 @@ static int read_header(AVFormatContext *s,
return AVERROR(EIO);
url_fseek(pb, url_fsize(pb) - 36, SEEK_SET);
- if (get_be32(pb) != RAND_TAG) {
+ if (avio_rb32(pb) != RAND_TAG) {
av_log(s, AV_LOG_ERROR, "magic number not found");
return AVERROR_INVALIDDATA;
}
@@ -53,8 +53,8 @@ static int read_header(AVFormatContext *s,
if (!st)
return AVERROR(ENOMEM);
- st->nb_frames = get_be32(pb);
- if (get_be16(pb) != 0) {
+ st->nb_frames = avio_rb32(pb);
+ if (avio_rb16(pb) != 0) {
av_log_ask_for_sample(s, "unsupported packing method\n");
return AVERROR_INVALIDDATA;
}
@@ -64,10 +64,10 @@ static int read_header(AVFormatContext *s,
st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = PIX_FMT_RGBA;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
- film->leading = get_be16(pb);
- av_set_pts_info(st, 64, 1, get_be16(pb));
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
+ film->leading = avio_rb16(pb);
+ av_set_pts_info(st, 64, 1, avio_rb16(pb));
url_fseek(pb, 0, SEEK_SET);
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index f971d0997c..bed9863f9a 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -40,14 +40,14 @@ static int flac_read_header(AVFormatContext *s,
/* the parameters will be extracted from the compressed bitstream */
/* if fLaC marker is not found, assume there is no header */
- if (get_le32(s->pb) != MKTAG('f','L','a','C')) {
+ if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) {
url_fseek(s->pb, -4, SEEK_CUR);
return 0;
}
/* process metadata blocks */
while (!url_feof(s->pb) && !metadata_last) {
- get_buffer(s->pb, header, 4);
+ avio_read(s->pb, header, 4);
ff_flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size);
switch (metadata_type) {
@@ -58,7 +58,7 @@ static int flac_read_header(AVFormatContext *s,
if (!buffer) {
return AVERROR(ENOMEM);
}
- if (get_buffer(s->pb, buffer, metadata_size) != metadata_size) {
+ if (avio_read(s->pb, buffer, metadata_size) != metadata_size) {
av_freep(&buffer);
return AVERROR(EIO);
}
diff --git a/libavformat/flic.c b/libavformat/flic.c
index fca395b595..2f6e218357 100644
--- a/libavformat/flic.c
+++ b/libavformat/flic.c
@@ -96,7 +96,7 @@ static int flic_read_header(AVFormatContext *s,
flic->frame_number = 0;
/* load the whole header and pull out the width and height */
- if (get_buffer(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
+ if (avio_read(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
return AVERROR(EIO);
magic_number = AV_RL16(&header[4]);
@@ -130,7 +130,7 @@ static int flic_read_header(AVFormatContext *s,
memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
- if (get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
+ if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n");
return AVERROR(EIO);
}
@@ -207,7 +207,7 @@ static int flic_read_packet(AVFormatContext *s,
while (!packet_read) {
- if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
+ if ((ret = avio_read(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
FLIC_PREAMBLE_SIZE) {
ret = AVERROR(EIO);
break;
@@ -225,7 +225,7 @@ static int flic_read_packet(AVFormatContext *s,
pkt->pts = flic->frame_number++;
pkt->pos = url_ftell(pb);
memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);
- ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE,
+ ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
size - FLIC_PREAMBLE_SIZE);
if (ret != size - FLIC_PREAMBLE_SIZE) {
av_free_packet(pkt);
@@ -243,7 +243,7 @@ static int flic_read_packet(AVFormatContext *s,
pkt->stream_index = flic->audio_stream_index;
pkt->pos = url_ftell(pb);
- ret = get_buffer(pb, pkt->data, size);
+ ret = avio_read(pb, pkt->data, size);
if (ret != size) {
av_free_packet(pkt);
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index ce743b1bcf..e42598d98e 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -97,7 +97,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
- vcodec->extradata[0] = get_byte(s->pb);
+ vcodec->extradata[0] = avio_r8(s->pb);
return 1; // 1 byte body size adjustment for flv_read_packet()
case FLV_CODECID_H264:
vcodec->codec_id = CODEC_ID_H264;
@@ -111,13 +111,13 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
}
static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize) {
- int length = get_be16(ioc);
+ int length = avio_rb16(ioc);
if(length >= buffsize) {
url_fskip(ioc, length);
return -1;
}
- get_buffer(ioc, buffer, length);
+ avio_read(ioc, buffer, length);
buffer[length] = '\0';
@@ -134,13 +134,13 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
num_val = 0;
ioc = s->pb;
- amf_type = get_byte(ioc);
+ amf_type = avio_r8(ioc);
switch(amf_type) {
case AMF_DATA_TYPE_NUMBER:
- num_val = av_int2dbl(get_be64(ioc)); break;
+ num_val = av_int2dbl(avio_rb64(ioc)); break;
case AMF_DATA_TYPE_BOOL:
- num_val = get_byte(ioc); break;
+ num_val = avio_r8(ioc); break;
case AMF_DATA_TYPE_STRING:
if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
@@ -148,12 +148,12 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen;
- while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
+ while(url_ftell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) {
url_fskip(ioc, keylen); //skip key string
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
}
- if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ if(avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
}
break;
@@ -168,13 +168,13 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
return -1;
}
- if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ if(avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY: {
unsigned int arraylen, i;
- arraylen = get_be32(ioc);
+ arraylen = avio_rb32(ioc);
for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
@@ -222,7 +222,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) {
ioc = s->pb;
//first object needs to be "onMetaData" string
- type = get_byte(ioc);
+ type = avio_r8(ioc);
if(type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0 || strcmp(buffer, "onMetaData"))
return -1;
@@ -255,7 +255,7 @@ static int flv_read_header(AVFormatContext *s,
int offset, flags;
url_fskip(s->pb, 4);
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
/* old flvtool cleared this field */
/* FIXME: better fix needed */
if (!flags) {
@@ -276,7 +276,7 @@ static int flv_read_header(AVFormatContext *s,
return AVERROR(ENOMEM);
}
- offset = get_be32(s->pb);
+ offset = avio_rb32(s->pb);
url_fseek(s->pb, offset, SEEK_SET);
url_fskip(s->pb, 4);
@@ -292,7 +292,7 @@ static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
- get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}
@@ -306,10 +306,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
for(;;url_fskip(s->pb, 4)){ /* pkt size is repeated at end. skip it */
pos = url_ftell(s->pb);
- type = get_byte(s->pb);
- size = get_be24(s->pb);
- dts = get_be24(s->pb);
- dts |= get_byte(s->pb) << 24;
+ type = avio_r8(s->pb);
+ size = avio_rb24(s->pb);
+ 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))
return AVERROR_EOF;
@@ -323,11 +323,11 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (type == FLV_TAG_TYPE_AUDIO) {
is_audio=1;
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
size--;
} else if (type == FLV_TAG_TYPE_VIDEO) {
is_audio=0;
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
size--;
if ((flags & 0xf0) == 0x50) /* video info / command frame */
goto skip;
@@ -375,11 +375,11 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
const int64_t pos= url_ftell(s->pb);
const int64_t fsize= url_fsize(s->pb);
url_fseek(s->pb, fsize-4, SEEK_SET);
- size= get_be32(s->pb);
+ size= avio_rb32(s->pb);
url_fseek(s->pb, fsize-3-size, SEEK_SET);
- if(size == get_be24(s->pb) + 11){
- uint32_t ts = get_be24(s->pb);
- ts |= get_byte(s->pb) << 24;
+ if(size == avio_rb24(s->pb) + 11){
+ uint32_t ts = avio_rb24(s->pb);
+ ts |= avio_r8(s->pb) << 24;
s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
}
url_fseek(s->pb, pos, SEEK_SET);
@@ -400,10 +400,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (st->codec->codec_id == CODEC_ID_AAC ||
st->codec->codec_id == CODEC_ID_H264) {
- int type = get_byte(s->pb);
+ int type = avio_r8(s->pb);
size--;
if (st->codec->codec_id == CODEC_ID_H264) {
- int32_t cts = (get_be24(s->pb)+0xff800000)^0xff800000; // sign extension
+ int32_t cts = (avio_rb24(s->pb)+0xff800000)^0xff800000; // sign extension
pts = dts + cts;
if (cts < 0) { // dts are wrong
flv->wrong_dts = 1;
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 3859630100..5b8b33c5f2 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -39,20 +39,20 @@ struct gxf_stream_info {
* \return 0 if header not found or contains invalid data, 1 otherwise
*/
static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) {
- if (get_be32(pb))
+ if (avio_rb32(pb))
return 0;
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
return 0;
- *type = get_byte(pb);
- *length = get_be32(pb);
+ *type = avio_r8(pb);
+ *length = avio_rb32(pb);
if ((*length >> 24) || *length < 16)
return 0;
*length -= 16;
- if (get_be32(pb))
+ if (avio_rb32(pb))
return 0;
- if (get_byte(pb) != 0xe1)
+ if (avio_r8(pb) != 0xe1)
return 0;
- if (get_byte(pb) != 0xe2)
+ if (avio_r8(pb) != 0xe2)
return 0;
return 1;
}
@@ -161,14 +161,14 @@ static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info
si->first_field = AV_NOPTS_VALUE;
si->last_field = AV_NOPTS_VALUE;
while (*len >= 2) {
- GXFMatTag tag = get_byte(pb);
- int tlen = get_byte(pb);
+ GXFMatTag tag = avio_r8(pb);
+ int tlen = avio_r8(pb);
*len -= 2;
if (tlen > *len)
return;
*len -= tlen;
if (tlen == 4) {
- uint32_t value = get_be32(pb);
+ uint32_t value = avio_rb32(pb);
if (tag == MAT_FIRST_FIELD)
si->first_field = value;
else if (tag == MAT_LAST_FIELD)
@@ -210,14 +210,14 @@ static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si
si->frames_per_second = (AVRational){0, 0};
si->fields_per_frame = 0;
while (*len >= 2) {
- GXFTrackTag tag = get_byte(pb);
- int tlen = get_byte(pb);
+ GXFTrackTag tag = avio_r8(pb);
+ int tlen = avio_r8(pb);
*len -= 2;
if (tlen > *len)
return;
*len -= tlen;
if (tlen == 4) {
- uint32_t value = get_be32(pb);
+ uint32_t value = avio_rb32(pb);
if (tag == TRACK_FPS)
si->frames_per_second = fps_tag2avr(value);
else if (tag == TRACK_FPF && (value == 1 || value == 2))
@@ -233,8 +233,8 @@ static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si
static void gxf_read_index(AVFormatContext *s, int pkt_len) {
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
- uint32_t fields_per_map = get_le32(pb);
- uint32_t map_cnt = get_le32(pb);
+ uint32_t fields_per_map = avio_rl32(pb);
+ uint32_t map_cnt = avio_rl32(pb);
int i;
pkt_len -= 8;
if (s->flags & AVFMT_FLAG_IGNIDX) {
@@ -253,7 +253,7 @@ static void gxf_read_index(AVFormatContext *s, int pkt_len) {
pkt_len -= 4 * map_cnt;
av_add_index_entry(st, 0, 0, 0, 0, 0);
for (i = 0; i < map_cnt; i++)
- av_add_index_entry(st, (uint64_t)get_le32(pb) * 1024,
+ av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,
i * (uint64_t)fields_per_map + 1, 0, 0, 0);
url_fskip(pb, pkt_len);
}
@@ -271,12 +271,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
return 0;
}
map_len -= 2;
- if (get_byte(pb) != 0x0e0 || get_byte(pb) != 0xff) {
+ if (avio_r8(pb) != 0x0e0 || avio_r8(pb) != 0xff) {
av_log(s, AV_LOG_ERROR, "unknown version or invalid map preamble\n");
return 0;
}
map_len -= 2;
- len = get_be16(pb); // length of material data section
+ len = avio_rb16(pb); // length of material data section
if (len > map_len) {
av_log(s, AV_LOG_ERROR, "material data longer than map data\n");
return 0;
@@ -285,7 +285,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
gxf_material_tags(pb, &len, &si);
url_fskip(pb, len);
map_len -= 2;
- len = get_be16(pb); // length of track description
+ len = avio_rb16(pb); // length of track description
if (len > map_len) {
av_log(s, AV_LOG_ERROR, "track description longer than map data\n");
return 0;
@@ -296,9 +296,9 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
AVStream *st;
int idx;
len -= 4;
- track_type = get_byte(pb);
- track_id = get_byte(pb);
- track_len = get_be16(pb);
+ track_type = avio_r8(pb);
+ track_id = avio_r8(pb);
+ track_len = avio_rb16(pb);
len -= track_len;
gxf_track_tags(pb, &track_len, &si);
url_fskip(pb, track_len);
@@ -344,7 +344,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
len -= 0x39;
url_fskip(pb, 5); // preamble
url_fskip(pb, 0x30); // payload description
- fps = fps_umf2avr(get_le32(pb));
+ fps = fps_umf2avr(avio_rl32(pb));
if (!main_timebase.num || !main_timebase.den) {
// this may not always be correct, but simply the best we can get
main_timebase.num = fps.den;
@@ -370,7 +370,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
{ \
if (!max_interval-- || url_feof(pb)) \
goto out; \
- tmp = tmp << 8 | get_byte(pb); \
+ tmp = tmp << 8 | avio_r8(pb); \
}
/**
@@ -389,7 +389,7 @@ static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int t
int len;
AVIOContext *pb = s->pb;
GXFPktType type;
- tmp = get_be32(pb);
+ tmp = avio_rb32(pb);
start:
while (tmp)
READ_ONE();
@@ -404,9 +404,9 @@ start:
goto out;
goto start;
}
- get_byte(pb);
- cur_track = get_byte(pb);
- cur_timestamp = get_be32(pb);
+ avio_r8(pb);
+ cur_track = avio_r8(pb);
+ cur_timestamp = avio_rb32(pb);
last_found_pos = url_ftell(pb) - 16 - 6;
if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
if (url_fseek(pb, last_pos, SEEK_SET) >= 0)
@@ -445,17 +445,17 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
continue;
}
pkt_len -= 16;
- track_type = get_byte(pb);
- track_id = get_byte(pb);
+ track_type = avio_r8(pb);
+ track_id = avio_r8(pb);
stream_index = get_sindex(s, track_id, track_type);
if (stream_index < 0)
return stream_index;
st = s->streams[stream_index];
- field_nr = get_be32(pb);
- field_info = get_be32(pb);
- get_be32(pb); // "timeline" field number
- get_byte(pb); // flags
- get_byte(pb); // reserved
+ field_nr = avio_rb32(pb);
+ field_info = avio_rb32(pb);
+ avio_rb32(pb); // "timeline" field number
+ avio_r8(pb); // flags
+ avio_r8(pb); // reserved
if (st->codec->codec_id == CODEC_ID_PCM_S24LE ||
st->codec->codec_id == CODEC_ID_PCM_S16LE) {
int first = field_info >> 16;
diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c
index 481db9735e..35199d89f8 100644
--- a/libavformat/id3v1.c
+++ b/libavformat/id3v1.c
@@ -233,7 +233,7 @@ void ff_id3v1_read(AVFormatContext *s)
filesize = url_fsize(s->pb);
if (filesize > 128) {
url_fseek(s->pb, filesize - 128, SEEK_SET);
- ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE);
+ ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE);
if (ret == ID3v1_TAG_SIZE) {
parse_tag(s, buf);
}
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index f886b68288..a3e51407e9 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -55,7 +55,7 @@ static unsigned int get_size(AVIOContext *s, int len)
{
int v = 0;
while (len--)
- v = (v << 7) + (get_byte(s) & 0x7F);
+ v = (v << 7) + (avio_r8(s) & 0x7F);
return v;
}
@@ -65,7 +65,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
const char *val = NULL;
int len, dstlen = sizeof(dst) - 1;
unsigned genre;
- unsigned int (*get)(AVIOContext*) = get_be16;
+ unsigned int (*get)(AVIOContext*) = avio_rb16;
dst[0] = 0;
if (taglen < 1)
@@ -73,22 +73,22 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
taglen--; /* account for encoding type byte */
- switch (get_byte(pb)) { /* encoding type */
+ switch (avio_r8(pb)) { /* encoding type */
case ID3v2_ENCODING_ISO8859:
q = dst;
while (taglen-- && q - dst < dstlen - 7) {
uint8_t tmp;
- PUT_UTF8(get_byte(pb), tmp, *q++ = tmp;)
+ PUT_UTF8(avio_r8(pb), tmp, *q++ = tmp;)
}
*q = 0;
break;
case ID3v2_ENCODING_UTF16BOM:
taglen -= 2;
- switch (get_be16(pb)) {
+ switch (avio_rb16(pb)) {
case 0xfffe:
- get = get_le16;
+ get = avio_rl16;
case 0xfeff:
break;
default:
@@ -111,7 +111,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
case ID3v2_ENCODING_UTF8:
len = FFMIN(taglen, dstlen);
- get_buffer(pb, dst, len);
+ avio_read(pb, dst, len);
dst[len] = 0;
break;
default:
@@ -178,18 +178,18 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
int tunsync = 0;
if (isv34) {
- get_buffer(s->pb, tag, 4);
+ avio_read(s->pb, tag, 4);
tag[4] = 0;
if(version==3){
- tlen = get_be32(s->pb);
+ tlen = avio_rb32(s->pb);
}else
tlen = get_size(s->pb, 4);
- tflags = get_be16(s->pb);
+ tflags = avio_rb16(s->pb);
tunsync = tflags & ID3v2_FLAG_UNSYNCH;
} else {
- get_buffer(s->pb, tag, 3);
+ avio_read(s->pb, tag, 3);
tag[3] = 0;
- tlen = get_be24(s->pb);
+ tlen = avio_rb24(s->pb);
}
len -= taghdrlen + tlen;
@@ -199,7 +199,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
next = url_ftell(s->pb) + tlen;
if (tflags & ID3v2_FLAG_DATALEN) {
- get_be32(s->pb);
+ avio_rb32(s->pb);
tlen -= 4;
}
@@ -211,7 +211,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen);
for (i = 0, j = 0; i < tlen; i++, j++) {
- buffer[j] = get_byte(s->pb);
+ buffer[j] = avio_r8(s->pb);
if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) {
/* Unsynchronised byte, skip it */
j--;
@@ -259,7 +259,7 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic)
do {
/* save the current offset in case there's nothing to read/skip */
off = url_ftell(s->pb);
- ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
+ ret = avio_read(s->pb, buf, ID3v2_HEADER_SIZE);
if (ret != ID3v2_HEADER_SIZE)
break;
found_header = ff_id3v2_match(buf, magic);
diff --git a/libavformat/idcin.c b/libavformat/idcin.c
index 986714ed11..7421901a9b 100644
--- a/libavformat/idcin.c
+++ b/libavformat/idcin.c
@@ -149,11 +149,11 @@ static int idcin_read_header(AVFormatContext *s,
unsigned int sample_rate, bytes_per_sample, channels;
/* get the 5 header parameters */
- width = get_le32(pb);
- height = get_le32(pb);
- sample_rate = get_le32(pb);
- bytes_per_sample = get_le32(pb);
- channels = get_le32(pb);
+ width = avio_rl32(pb);
+ height = avio_rl32(pb);
+ sample_rate = avio_rl32(pb);
+ bytes_per_sample = avio_rl32(pb);
+ channels = avio_rl32(pb);
st = av_new_stream(s, 0);
if (!st)
@@ -169,7 +169,7 @@ static int idcin_read_header(AVFormatContext *s,
/* load up the Huffman tables into extradata */
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
- if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
+ if (avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
HUFFMAN_TABLE_SIZE)
return AVERROR(EIO);
/* save a reference in order to transport the palette */
@@ -231,13 +231,13 @@ static int idcin_read_packet(AVFormatContext *s,
return AVERROR(EIO);
if (idcin->next_chunk_is_video) {
- command = get_le32(pb);
+ command = avio_rl32(pb);
if (command == 2) {
return AVERROR(EIO);
} else if (command == 1) {
/* trigger a palette change */
idcin->palctrl.palette_changed = 1;
- if (get_buffer(pb, palette_buffer, 768) != 768)
+ if (avio_read(pb, palette_buffer, 768) != 768)
return AVERROR(EIO);
/* scale the palette as necessary */
palette_scale = 2;
@@ -255,7 +255,7 @@ static int idcin_read_packet(AVFormatContext *s,
}
}
- chunk_size = get_le32(pb);
+ chunk_size = avio_rl32(pb);
/* skip the number of decoded bytes (always equal to width * height) */
url_fseek(pb, 4, SEEK_CUR);
chunk_size -= 4;
diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c
index dc0f0a694c..5b18397532 100644
--- a/libavformat/idroqdec.c
+++ b/libavformat/idroqdec.c
@@ -74,7 +74,7 @@ static int roq_read_header(AVFormatContext *s,
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
/* get the main header */
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
framerate = AV_RL16(&preamble[6]);
@@ -115,7 +115,7 @@ static int roq_read_packet(AVFormatContext *s,
return AVERROR(EIO);
/* get the next chunk preamble */
- if ((ret = get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
+ if ((ret = avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
@@ -129,7 +129,7 @@ static int roq_read_packet(AVFormatContext *s,
case RoQ_INFO:
if (!roq->width || !roq->height) {
AVStream *st = s->streams[roq->video_stream_index];
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
st->codec->width = roq->width = AV_RL16(preamble);
st->codec->height = roq->height = AV_RL16(preamble + 2);
@@ -144,7 +144,7 @@ static int roq_read_packet(AVFormatContext *s,
codebook_offset = url_ftell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
codebook_size = chunk_size;
url_fseek(pb, codebook_size, SEEK_CUR);
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
@@ -198,7 +198,7 @@ static int roq_read_packet(AVFormatContext *s,
}
pkt->pos= url_ftell(pb);
- ret = get_buffer(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
+ ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
chunk_size);
if (ret != chunk_size)
ret = AVERROR(EIO);
diff --git a/libavformat/iff.c b/libavformat/iff.c
index 8e3ddf11ab..15327c2421 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -101,7 +101,7 @@ static int get_metadata(AVFormatContext *s,
if (!buf)
return AVERROR(ENOMEM);
- if (get_buffer(s->pb, buf, data_size) < 0) {
+ if (avio_read(s->pb, buf, data_size) < 0) {
av_free(buf);
return AVERROR(EIO);
}
@@ -136,14 +136,14 @@ static int iff_read_header(AVFormatContext *s,
st->codec->channels = 1;
url_fskip(pb, 8);
// codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
- st->codec->codec_tag = get_le32(pb);
+ st->codec->codec_tag = avio_rl32(pb);
while(!url_feof(pb)) {
uint64_t orig_pos;
int res;
const char *metadata_tag = NULL;
- chunk_id = get_le32(pb);
- data_size = get_be32(pb);
+ chunk_id = avio_rl32(pb);
+ data_size = avio_rb32(pb);
orig_pos = url_ftell(pb);
switch(chunk_id) {
@@ -153,10 +153,10 @@ static int iff_read_header(AVFormatContext *s,
if (data_size < 14)
return AVERROR_INVALIDDATA;
url_fskip(pb, 12);
- st->codec->sample_rate = get_be16(pb);
+ st->codec->sample_rate = avio_rb16(pb);
if (data_size >= 16) {
url_fskip(pb, 1);
- compression = get_byte(pb);
+ compression = avio_r8(pb);
}
break;
@@ -168,7 +168,7 @@ static int iff_read_header(AVFormatContext *s,
case ID_CHAN:
if (data_size < 4)
return AVERROR_INVALIDDATA;
- st->codec->channels = (get_be32(pb) < 6) ? 1 : 2;
+ st->codec->channels = (avio_rb32(pb) < 6) ? 1 : 2;
break;
case ID_CMAP:
@@ -176,7 +176,7 @@ static int iff_read_header(AVFormatContext *s,
st->codec->extradata = av_malloc(data_size);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- if (get_buffer(pb, st->codec->extradata, data_size) < 0)
+ if (avio_read(pb, st->codec->extradata, data_size) < 0)
return AVERROR(EIO);
break;
@@ -184,18 +184,18 @@ static int iff_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
if (data_size <= 8)
return AVERROR_INVALIDDATA;
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
url_fskip(pb, 4); // x, y offset
- st->codec->bits_per_coded_sample = get_byte(pb);
+ st->codec->bits_per_coded_sample = avio_r8(pb);
if (data_size >= 11) {
url_fskip(pb, 1); // masking
- compression = get_byte(pb);
+ compression = avio_r8(pb);
}
if (data_size >= 16) {
url_fskip(pb, 3); // paddding, transparent
- st->sample_aspect_ratio.num = get_byte(pb);
- st->sample_aspect_ratio.den = get_byte(pb);
+ st->sample_aspect_ratio.num = avio_r8(pb);
+ st->sample_aspect_ratio.den = avio_r8(pb);
}
break;
@@ -286,7 +286,7 @@ static int iff_read_packet(AVFormatContext *s,
if(st->codec->channels == 2) {
uint8_t sample_buffer[PACKET_SIZE];
- ret = get_buffer(pb, sample_buffer, PACKET_SIZE);
+ ret = avio_read(pb, sample_buffer, PACKET_SIZE);
if(av_new_packet(pkt, PACKET_SIZE) < 0) {
av_log(s, AV_LOG_ERROR, "cannot allocate packet\n");
return AVERROR(ENOMEM);
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 95848053d2..f2d40d16de 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -298,7 +298,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
pkt->size= 0;
for(i=0; i<3; i++){
if(size[i]){
- ret[i]= get_buffer(f[i], pkt->data + pkt->size, size[i]);
+ ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]);
if (!s->is_pipe)
url_fclose(f[i]);
if(ret[i]>0)
diff --git a/libavformat/ingenientdec.c b/libavformat/ingenientdec.c
index 79587b5192..dbb3f3bfd2 100644
--- a/libavformat/ingenientdec.c
+++ b/libavformat/ingenientdec.c
@@ -27,18 +27,18 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size, w, h, unk1, unk2;
- if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
+ if (avio_rl32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
return AVERROR(EIO); // FIXME
- size = get_le32(s->pb);
+ size = avio_rl32(s->pb);
- w = get_le16(s->pb);
- h = get_le16(s->pb);
+ w = avio_rl16(s->pb);
+ h = avio_rl16(s->pb);
url_fskip(s->pb, 8); // zero + size (padded?)
url_fskip(s->pb, 2);
- unk1 = get_le16(s->pb);
- unk2 = get_le16(s->pb);
+ unk1 = avio_rl16(s->pb);
+ unk2 = avio_rl16(s->pb);
url_fskip(s->pb, 22); // ASCII timestamp
av_log(s, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
@@ -49,7 +49,7 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = url_ftell(s->pb);
pkt->stream_index = 0;
- ret = get_buffer(s->pb, pkt->data, size);
+ ret = avio_read(s->pb, pkt->data, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index 6015b99b3b..6514397a1e 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -166,7 +166,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET);
s->decode_map_chunk_offset = 0;
- if (get_buffer(pb, pkt->data, s->decode_map_chunk_size) !=
+ if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
s->decode_map_chunk_size) {
av_free_packet(pkt);
return CHUNK_EOF;
@@ -175,7 +175,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
url_fseek(pb, s->video_chunk_offset, SEEK_SET);
s->video_chunk_offset = 0;
- if (get_buffer(pb, pkt->data + s->decode_map_chunk_size,
+ if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
s->video_chunk_size) != s->video_chunk_size) {
av_free_packet(pkt);
return CHUNK_EOF;
@@ -227,7 +227,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
/* read the next chunk, wherever the file happens to be pointing */
if (url_feof(pb))
return CHUNK_EOF;
- if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return CHUNK_BAD;
chunk_size = AV_RL16(&chunk_preamble[0]);
@@ -275,7 +275,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_EOF;
break;
}
- if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE) {
chunk_type = CHUNK_BAD;
break;
@@ -314,7 +314,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
@@ -331,7 +331,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
@@ -369,7 +369,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
@@ -434,7 +434,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) != opcode_size) {
+ if (avio_read(pb, scratch, opcode_size) != opcode_size) {
chunk_type = CHUNK_BAD;
break;
}
@@ -528,10 +528,10 @@ static int ipmovie_read_header(AVFormatContext *s,
int chunk_type;
uint8_t signature_buffer[sizeof(signature)];
- get_buffer(pb, signature_buffer, sizeof(signature_buffer));
+ avio_read(pb, signature_buffer, sizeof(signature_buffer));
while (memcmp(signature_buffer, signature, sizeof(signature))) {
memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
- signature_buffer[sizeof(signature_buffer) - 1] = get_byte(pb);
+ signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
if (url_feof(pb))
return AVERROR_EOF;
}
@@ -549,7 +549,7 @@ static int ipmovie_read_header(AVFormatContext *s,
/* peek ahead to the next chunk-- if it is an init audio chunk, process
* it; if it is the first video chunk, this is a silent file */
- if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_type = AV_RL16(&chunk_preamble[2]);
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6b1be10f25..8534cb8898 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -346,7 +346,7 @@ int ff_mp4_read_descr_len(AVIOContext *pb)
int len = 0;
int count = 4;
while (count--) {
- int c = get_byte(pb);
+ int c = avio_r8(pb);
len = (len << 7) | (c & 0x7f);
if (!(c & 0x80))
break;
@@ -357,7 +357,7 @@ int ff_mp4_read_descr_len(AVIOContext *pb)
int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
{
int len;
- *tag = get_byte(pb);
+ *tag = avio_r8(pb);
len = ff_mp4_read_descr_len(pb);
av_dlog(fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
return len;
@@ -375,11 +375,11 @@ static const AVCodecTag mp4_audio_types[] = {
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
{
int len, tag;
- int object_type_id = get_byte(pb);
- get_byte(pb); /* stream type */
- get_be24(pb); /* buffer size db */
- get_be32(pb); /* max bitrate */
- get_be32(pb); /* avg bitrate */
+ int object_type_id = avio_r8(pb);
+ avio_r8(pb); /* stream type */
+ avio_rb24(pb); /* buffer size db */
+ avio_rb32(pb); /* max bitrate */
+ avio_rb32(pb); /* avg bitrate */
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
av_dlog(fc, "esds object type id 0x%02x\n", object_type_id);
@@ -392,7 +392,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, len);
+ avio_read(pb, st->codec->extradata, len);
st->codec->extradata_size = len;
if (st->codec->codec_id == CODEC_ID_AAC) {
MPEG4AudioConfig cfg;
diff --git a/libavformat/iss.c b/libavformat/iss.c
index 85b7e5fbdc..04bb1c52d4 100644
--- a/libavformat/iss.c
+++ b/libavformat/iss.c
@@ -44,7 +44,7 @@ static void get_token(AVIOContext *s, char *buf, int maxlen)
int i = 0;
char c;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if(c == ' ')
break;
if (i < maxlen-1)
@@ -52,7 +52,7 @@ static void get_token(AVIOContext *s, char *buf, int maxlen)
}
if(!c)
- get_byte(s);
+ avio_r8(s);
buf[i] = 0; /* Ensure null terminated, but may be truncated */
}
diff --git a/libavformat/iv8.c b/libavformat/iv8.c
index 07659cf8f5..d463350c5f 100644
--- a/libavformat/iv8.c
+++ b/libavformat/iv8.c
@@ -57,13 +57,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size, pts, type;
retry:
- type= get_be16(s->pb); // 257 or 258
- size= get_be16(s->pb);
+ type= avio_rb16(s->pb); // 257 or 258
+ size= avio_rb16(s->pb);
- get_be16(s->pb); //some flags, 0x80 indicates end of frame
- get_be16(s->pb); //packet number
- pts=get_be32(s->pb);
- get_be32(s->pb); //6A 13 E3 88
+ avio_rb16(s->pb); //some flags, 0x80 indicates end of frame
+ avio_rb16(s->pb); //packet number
+ pts=avio_rb32(s->pb);
+ avio_rb32(s->pb); //6A 13 E3 88
size -= 12;
if(size<1)
diff --git a/libavformat/ivfdec.c b/libavformat/ivfdec.c
index 94b8b82a41..af3fe19e22 100644
--- a/libavformat/ivfdec.c
+++ b/libavformat/ivfdec.c
@@ -36,9 +36,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st;
AVRational time_base;
- get_le32(s->pb); // DKIF
- get_le16(s->pb); // version
- get_le16(s->pb); // header size
+ avio_rl32(s->pb); // DKIF
+ avio_rl16(s->pb); // version
+ avio_rl16(s->pb); // header size
st = av_new_stream(s, 0);
if (!st)
@@ -46,13 +46,13 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = get_le32(s->pb);
+ st->codec->codec_tag = avio_rl32(s->pb);
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
- st->codec->width = get_le16(s->pb);
- st->codec->height = get_le16(s->pb);
- time_base.den = get_le32(s->pb);
- time_base.num = get_le32(s->pb);
- st->duration = get_le64(s->pb);
+ st->codec->width = avio_rl16(s->pb);
+ st->codec->height = avio_rl16(s->pb);
+ time_base.den = avio_rl32(s->pb);
+ time_base.num = avio_rl32(s->pb);
+ st->duration = avio_rl64(s->pb);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
@@ -68,8 +68,8 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
- int ret, size = get_le32(s->pb);
- int64_t pts = get_le64(s->pb);
+ int ret, size = avio_rl32(s->pb);
+ int64_t pts = avio_rl64(s->pb);
ret = av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0;
diff --git a/libavformat/libnut.c b/libavformat/libnut.c
index 7c4378b6c0..30ada1bf2f 100644
--- a/libavformat/libnut.c
+++ b/libavformat/libnut.c
@@ -173,7 +173,7 @@ static int nut_probe(AVProbeData *p) {
static size_t av_read(void * h, size_t len, uint8_t * buf) {
AVIOContext * bc = h;
- return get_buffer(bc, buf, len);
+ return avio_read(bc, buf, len);
}
static off_t av_seek(void * h, long long pos, int whence) {
diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c
index 7539e1f4ab..2991b30710 100644
--- a/libavformat/lmlm4.c
+++ b/libavformat/lmlm4.c
@@ -82,9 +82,9 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt) {
int ret;
unsigned int frame_type, packet_size, padding, frame_size;
- get_be16(pb); /* channel number */
- frame_type = get_be16(pb);
- packet_size = get_be32(pb);
+ avio_rb16(pb); /* channel number */
+ frame_type = avio_rb16(pb);
+ packet_size = avio_rb32(pb);
padding = -packet_size & 511;
frame_size = packet_size - 8;
diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
index a4dc6d9c65..8692e628e5 100644
--- a/libavformat/lxfdec.c
+++ b/libavformat/lxfdec.c
@@ -86,7 +86,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
uint8_t buf[LXF_IDENT_LENGTH];
int ret;
- if ((ret = get_buffer(s->pb, buf, LXF_IDENT_LENGTH)) != LXF_IDENT_LENGTH)
+ if ((ret = avio_read(s->pb, buf, LXF_IDENT_LENGTH)) != LXF_IDENT_LENGTH)
return ret < 0 ? ret : AVERROR_EOF;
while (memcmp(buf, LXF_IDENT, LXF_IDENT_LENGTH)) {
@@ -94,7 +94,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
return AVERROR_EOF;
memmove(buf, &buf[1], LXF_IDENT_LENGTH-1);
- buf[LXF_IDENT_LENGTH-1] = get_byte(s->pb);
+ buf[LXF_IDENT_LENGTH-1] = avio_r8(s->pb);
}
memcpy(header, LXF_IDENT, LXF_IDENT_LENGTH);
@@ -120,7 +120,7 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form
return ret;
//read the rest of the packet header
- if ((ret = get_buffer(pb, header + LXF_IDENT_LENGTH,
+ if ((ret = avio_read(pb, header + LXF_IDENT_LENGTH,
LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH)) !=
LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH) {
return ret < 0 ? ret : AVERROR_EOF;
@@ -214,7 +214,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR_INVALIDDATA;
}
- if ((ret = get_buffer(pb, header_data, LXF_HEADER_DATA_SIZE)) != LXF_HEADER_DATA_SIZE)
+ if ((ret = avio_read(pb, header_data, LXF_HEADER_DATA_SIZE)) != LXF_HEADER_DATA_SIZE)
return ret < 0 ? ret : AVERROR_EOF;
if (!(st = av_new_stream(s, 0)))
@@ -315,7 +315,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
//read non-20-bit audio data into lxf->temp so we can deplanarize it
buf = ast && ast->codec->codec_id != CODEC_ID_PCM_LXF ? lxf->temp : pkt->data;
- if ((ret2 = get_buffer(pb, buf, ret)) != ret) {
+ if ((ret2 = avio_read(pb, buf, ret)) != ret) {
av_free_packet(pkt);
return ret2 < 0 ? ret2 : AVERROR_EOF;
}
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 69f08c3142..545c93895f 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -543,10 +543,10 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
int read = 1, n = 1;
uint64_t total = 0;
- /* The first byte tells us the length in bytes - get_byte() can normally
+ /* The first byte tells us the length in bytes - avio_r8() can normally
* return 0, but since that's not a valid first ebmlID byte, we can
* use it safely here to catch EOS. */
- if (!(total = get_byte(pb))) {
+ if (!(total = avio_r8(pb))) {
/* we might encounter EOS here */
if (!url_feof(pb)) {
int64_t pos = url_ftell(pb);
@@ -570,7 +570,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
/* read out length */
total ^= 1 << ff_log2_tab[total];
while (n++ < read)
- total = (total << 8) | get_byte(pb);
+ total = (total << 8) | avio_r8(pb);
*number = total;
@@ -605,7 +605,7 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
/* big-endian ordering; build up number */
*num = 0;
while (n++ < size)
- *num = (*num << 8) | get_byte(pb);
+ *num = (*num << 8) | avio_r8(pb);
return 0;
}
@@ -619,9 +619,9 @@ static int ebml_read_float(AVIOContext *pb, int size, double *num)
if (size == 0) {
*num = 0;
} else if (size == 4) {
- *num= av_int2flt(get_be32(pb));
+ *num= av_int2flt(avio_rb32(pb));
} else if(size==8){
- *num= av_int2dbl(get_be64(pb));
+ *num= av_int2dbl(avio_rb64(pb));
} else
return AVERROR_INVALIDDATA;
@@ -639,7 +639,7 @@ static int ebml_read_ascii(AVIOContext *pb, int size, char **str)
* byte more, read the string and NULL-terminate it ourselves. */
if (!(*str = av_malloc(size + 1)))
return AVERROR(ENOMEM);
- if (get_buffer(pb, (uint8_t *) *str, size) != size) {
+ if (avio_read(pb, (uint8_t *) *str, size) != size) {
av_freep(str);
return AVERROR(EIO);
}
@@ -660,7 +660,7 @@ static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin)
bin->size = length;
bin->pos = url_ftell(pb);
- if (get_buffer(pb, bin->data, length) != length) {
+ if (avio_read(pb, bin->data, length) != length) {
av_freep(&bin->data);
return AVERROR(EIO);
}
@@ -1394,12 +1394,12 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
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);
- track->audio.coded_framesize = get_be32(&b);
+ flavor = avio_rb16(&b);
+ track->audio.coded_framesize = avio_rb32(&b);
url_fskip(&b, 12);
- track->audio.sub_packet_h = get_be16(&b);
- track->audio.frame_size = get_be16(&b);
- track->audio.sub_packet_size = get_be16(&b);
+ track->audio.sub_packet_h = avio_rb16(&b);
+ track->audio.frame_size = avio_rb16(&b);
+ track->audio.sub_packet_size = avio_rb16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
diff --git a/libavformat/mm.c b/libavformat/mm.c
index 53c3b49705..2c0d215abf 100644
--- a/libavformat/mm.c
+++ b/libavformat/mm.c
@@ -90,18 +90,18 @@ static int read_header(AVFormatContext *s,
unsigned int type, length;
unsigned int frame_rate, width, height;
- type = get_le16(pb);
- length = get_le32(pb);
+ type = avio_rl16(pb);
+ length = avio_rl32(pb);
if (type != MM_TYPE_HEADER)
return AVERROR_INVALIDDATA;
/* read header */
- get_le16(pb); /* total number of chunks */
- frame_rate = get_le16(pb);
- get_le16(pb); /* ibm-pc video bios mode */
- width = get_le16(pb);
- height = get_le16(pb);
+ avio_rl16(pb); /* total number of chunks */
+ frame_rate = avio_rl16(pb);
+ avio_rl16(pb); /* ibm-pc video bios mode */
+ width = avio_rl16(pb);
+ height = avio_rl16(pb);
url_fseek(pb, length - 10, SEEK_CUR); /* unknown data */
/* video stream */
@@ -143,7 +143,7 @@ static int read_packet(AVFormatContext *s,
while(1) {
- if (get_buffer(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
+ if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
return AVERROR(EIO);
}
@@ -162,7 +162,7 @@ static int read_packet(AVFormatContext *s,
if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
- if (get_buffer(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
+ if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
return AVERROR(EIO);
pkt->size = length + MM_PREAMBLE_SIZE;
pkt->stream_index = 0;
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index bf855cba8b..1a00908eba 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -188,15 +188,15 @@ static int mmf_read_header(AVFormatContext *s,
int64_t file_size, size;
int rate, params;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('M', 'M', 'M', 'D'))
return -1;
- file_size = get_be32(pb);
+ file_size = avio_rb32(pb);
/* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) {
- tag = get_le32(pb);
- size = get_be32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if(tag == MKTAG('C','N','T','I')) continue;
if(tag == MKTAG('O','P','D','A')) continue;
break;
@@ -212,22 +212,22 @@ static int mmf_read_header(AVFormatContext *s,
return -1;
}
- get_byte(pb); /* format type */
- get_byte(pb); /* sequence type */
- params = get_byte(pb); /* (channel << 7) | (format << 4) | rate */
+ avio_r8(pb); /* format type */
+ avio_r8(pb); /* sequence type */
+ params = avio_r8(pb); /* (channel << 7) | (format << 4) | rate */
rate = mmf_rate(params & 0x0f);
if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
return -1;
}
- get_byte(pb); /* wave base bit */
- get_byte(pb); /* time base d */
- get_byte(pb); /* time base g */
+ avio_r8(pb); /* wave base bit */
+ avio_r8(pb); /* time base d */
+ avio_r8(pb); /* time base g */
/* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) {
- tag = get_le32(pb);
- size = get_be32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if(tag == MKTAG('A','t','s','q')) continue;
if(tag == MKTAG('A','s','p','I')) continue;
break;
@@ -280,7 +280,7 @@ static int mmf_read_packet(AVFormatContext *s,
return AVERROR(EIO);
pkt->stream_index = 0;
- ret = get_buffer(s->pb, pkt->data, pkt->size);
+ ret = avio_read(s->pb, pkt->data, pkt->size);
if (ret < 0)
av_free_packet(pkt);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2c314e3a39..eadb8f8988 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -83,11 +83,11 @@ static int mov_metadata_trkn(MOVContext *c, AVIOContext *pb, unsigned len)
{
char buf[16];
- get_be16(pb); // unknown
- snprintf(buf, sizeof(buf), "%d", get_be16(pb));
+ avio_rb16(pb); // unknown
+ snprintf(buf, sizeof(buf), "%d", avio_rb16(pb));
av_metadata_set2(&c->fc->metadata, "track", buf, 0);
- get_be16(pb); // total tracks
+ avio_rb16(pb); // total tracks
return 0;
}
@@ -119,7 +119,7 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len,
int i;
for (i = 0; i < len; i++) {
- uint8_t t, c = get_byte(pb);
+ uint8_t t, c = avio_r8(pb);
if (c < 0x80 && p < end)
*p++ = c;
else
@@ -165,17 +165,17 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
}
if (c->itunes_metadata && atom.size > 8) {
- int data_size = get_be32(pb);
- int tag = get_le32(pb);
+ int data_size = avio_rb32(pb);
+ int tag = avio_rl32(pb);
if (tag == MKTAG('d','a','t','a')) {
- data_type = get_be32(pb); // type
- get_be32(pb); // unknown
+ data_type = avio_rb32(pb); // type
+ avio_rb32(pb); // unknown
str_size = data_size - 16;
atom.size -= 16;
} else return 0;
} else if (atom.size > 4 && key && !c->itunes_metadata) {
- str_size = get_be16(pb); // string length
- langcode = get_be16(pb);
+ str_size = avio_rb16(pb); // string length
+ langcode = avio_rb16(pb);
ff_mov_lang_to_iso639(langcode, language);
atom.size -= 4;
} else
@@ -201,7 +201,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded
mov_read_mac_string(c, pb, str_size, str, sizeof(str));
} else {
- get_buffer(pb, str, str_size);
+ avio_read(pb, str, str_size);
str[str_size] = 0;
}
av_metadata_set2(&c->fc->metadata, key, str, 0);
@@ -228,23 +228,23 @@ static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if ((atom.size -= 5) < 0)
return 0;
- version = get_byte(pb);
- get_be24(pb);
+ version = avio_r8(pb);
+ avio_rb24(pb);
if (version)
- get_be32(pb); // ???
- nb_chapters = get_byte(pb);
+ avio_rb32(pb); // ???
+ nb_chapters = avio_r8(pb);
for (i = 0; i < nb_chapters; i++) {
if (atom.size < 9)
return 0;
- start = get_be64(pb);
- str_len = get_byte(pb);
+ start = avio_rb64(pb);
+ str_len = avio_r8(pb);
if ((atom.size -= 9+str_len) < 0)
return 0;
- get_buffer(pb, str, str_len);
+ avio_read(pb, str, str_len);
str[str_len] = 0;
ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str);
}
@@ -264,14 +264,14 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
a.size = atom.size;
a.type=0;
if(atom.size >= 8) {
- a.size = get_be32(pb);
- a.type = get_le32(pb);
+ a.size = avio_rb32(pb);
+ a.type = avio_rl32(pb);
}
av_dlog(c->fc, "type: %08x '%.4s' parent:'%.4s' sz: %"PRId64" %"PRId64" %"PRId64"\n",
a.type, (char*)&a.type, (char*)&atom.type, a.size, total_size, atom.size);
total_size += 8;
if (a.size == 1) { /* 64 bit extended size */
- a.size = get_be64(pb) - 8;
+ a.size = avio_rb64(pb) - 8;
total_size += 8;
}
if (a.size == 0) {
@@ -331,8 +331,8 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_be32(pb); // version + flags
- entries = get_be32(pb);
+ avio_rb32(pb); // version + flags
+ entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->drefs))
return -1;
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
@@ -342,14 +342,14 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
for (i = 0; i < sc->drefs_count; i++) {
MOVDref *dref = &sc->drefs[i];
- uint32_t size = get_be32(pb);
+ uint32_t size = avio_rb32(pb);
int64_t next = url_ftell(pb) + size - 4;
if (size < 12)
return -1;
- dref->type = get_le32(pb);
- get_be32(pb); // version + flags
+ dref->type = avio_rl32(pb);
+ avio_rb32(pb); // version + flags
av_dlog(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);
if (dref->type == MKTAG('a','l','i','s') && size > 150) {
@@ -359,33 +359,33 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
url_fskip(pb, 10);
- volume_len = get_byte(pb);
+ volume_len = avio_r8(pb);
volume_len = FFMIN(volume_len, 27);
- get_buffer(pb, dref->volume, 27);
+ avio_read(pb, dref->volume, 27);
dref->volume[volume_len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", dref->volume, volume_len);
url_fskip(pb, 12);
- len = get_byte(pb);
+ len = avio_r8(pb);
len = FFMIN(len, 63);
- get_buffer(pb, dref->filename, 63);
+ avio_read(pb, dref->filename, 63);
dref->filename[len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "filename %s, len %d\n", dref->filename, len);
url_fskip(pb, 16);
/* read next level up_from_alias/down_to_target */
- dref->nlvl_from = get_be16(pb);
- dref->nlvl_to = get_be16(pb);
+ dref->nlvl_from = avio_rb16(pb);
+ dref->nlvl_to = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "nlvl from %d, nlvl to %d\n",
dref->nlvl_from, dref->nlvl_to);
url_fskip(pb, 16);
for (type = 0; type != -1 && url_ftell(pb) < next; ) {
- type = get_be16(pb);
- len = get_be16(pb);
+ type = avio_rb16(pb);
+ len = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
if (len&1)
len += 1;
@@ -394,7 +394,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
dref->path = av_mallocz(len+1);
if (!dref->path)
return AVERROR(ENOMEM);
- get_buffer(pb, dref->path, len);
+ avio_read(pb, dref->path, len);
if (len > volume_len && !strncmp(dref->path, dref->volume, volume_len)) {
len -= volume_len;
memmove(dref->path, dref->path+volume_len, len);
@@ -409,7 +409,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
dref->dir = av_malloc(len+1);
if (!dref->dir)
return AVERROR(ENOMEM);
- get_buffer(pb, dref->dir, len);
+ avio_read(pb, dref->dir, len);
dref->dir[len] = 0;
for (j = 0; j < len; j++)
if (dref->dir[j] == ':')
@@ -435,12 +435,12 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
/* component type */
- ctype = get_le32(pb);
- type = get_le32(pb); /* component subtype */
+ ctype = avio_rl32(pb);
+ type = avio_rl32(pb); /* component subtype */
av_dlog(c->fc, "ctype= %.4s (0x%08x)\n", (char*)&ctype, ctype);
av_dlog(c->fc, "stype= %.4s\n", (char*)&type);
@@ -454,9 +454,9 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
else if(type == MKTAG('s','u','b','p'))
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- get_be32(pb); /* component manufacture */
- get_be32(pb); /* component flags */
- get_be32(pb); /* component flags mask */
+ avio_rb32(pb); /* component manufacture */
+ avio_rb32(pb); /* component flags */
+ avio_rb32(pb); /* component flags mask */
return 0;
}
@@ -470,13 +470,13 @@ int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom)
return 0;
st = fc->streams[fc->nb_streams-1];
- get_be32(pb); /* version + flags */
+ avio_rb32(pb); /* version + flags */
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
- get_be16(pb); /* ID */
- get_byte(pb); /* priority */
+ avio_rb16(pb); /* ID */
+ avio_r8(pb); /* priority */
} else
- get_be16(pb); /* ID */
+ avio_rb16(pb); /* ID */
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag)
@@ -498,7 +498,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- ac3info = get_be24(pb);
+ ac3info = avio_rb24(pb);
acmod = (ac3info >> 11) & 0x7;
lfeon = (ac3info >> 10) & 0x1;
st->codec->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
@@ -508,8 +508,8 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
- const int num = get_be32(pb);
- const int den = get_be32(pb);
+ const int num = avio_rb32(pb);
+ const int den = avio_rb32(pb);
AVStream *st;
if (c->fc->nb_streams < 1)
@@ -547,12 +547,12 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
char* comp_brands_str;
uint8_t type[5] = {0};
- get_buffer(pb, type, 4);
+ avio_read(pb, type, 4);
if (strcmp(type, "qt "))
c->isom = 1;
av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
av_metadata_set2(&c->fc->metadata, "major_brand", type, 0);
- minor_ver = get_be32(pb); /* minor version */
+ minor_ver = avio_rb32(pb); /* minor version */
snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
@@ -562,7 +562,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */
if (!comp_brands_str)
return AVERROR(ENOMEM);
- get_buffer(pb, comp_brands_str, comp_brand_size);
+ avio_read(pb, comp_brands_str, comp_brand_size);
comp_brands_str[comp_brand_size] = 0;
av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_freep(&comp_brands_str);
@@ -615,27 +615,27 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- version = get_byte(pb);
+ version = avio_r8(pb);
if (version > 1)
return -1; /* unsupported */
- get_be24(pb); /* flags */
+ avio_rb24(pb); /* flags */
if (version == 1) {
- creation_time = get_be64(pb);
- get_be64(pb);
+ creation_time = avio_rb64(pb);
+ avio_rb64(pb);
} else {
- creation_time = get_be32(pb);
- get_be32(pb); /* modification time */
+ creation_time = avio_rb32(pb);
+ avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&st->metadata, creation_time);
- sc->time_scale = get_be32(pb);
- st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
+ sc->time_scale = avio_rb32(pb);
+ st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
- lang = get_be16(pb); /* language */
+ lang = avio_rb16(pb); /* language */
if (ff_mov_lang_to_iso639(lang, language))
av_metadata_set2(&st->metadata, "language", language, 0);
- get_be16(pb); /* quality */
+ avio_rb16(pb); /* quality */
return 0;
}
@@ -643,37 +643,37 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
time_t creation_time;
- int version = get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ int version = avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
if (version == 1) {
- creation_time = get_be64(pb);
- get_be64(pb);
+ creation_time = avio_rb64(pb);
+ avio_rb64(pb);
} else {
- creation_time = get_be32(pb);
- get_be32(pb); /* modification time */
+ creation_time = avio_rb32(pb);
+ avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&c->fc->metadata, creation_time);
- c->time_scale = get_be32(pb); /* time scale */
+ c->time_scale = avio_rb32(pb); /* time scale */
av_dlog(c->fc, "time scale = %i\n", c->time_scale);
- c->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
- get_be32(pb); /* preferred scale */
+ c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
+ avio_rb32(pb); /* preferred scale */
- get_be16(pb); /* preferred volume */
+ avio_rb16(pb); /* preferred volume */
url_fskip(pb, 10); /* reserved */
url_fskip(pb, 36); /* display matrix */
- get_be32(pb); /* preview time */
- get_be32(pb); /* preview duration */
- get_be32(pb); /* poster time */
- get_be32(pb); /* selection time */
- get_be32(pb); /* selection duration */
- get_be32(pb); /* current time */
- get_be32(pb); /* next track ID */
+ avio_rb32(pb); /* preview time */
+ avio_rb32(pb); /* preview duration */
+ avio_rb32(pb); /* poster time */
+ avio_rb32(pb); /* selection time */
+ avio_rb32(pb); /* selection duration */
+ avio_rb32(pb); /* current time */
+ avio_rb32(pb); /* next track ID */
return 0;
}
@@ -697,7 +697,7 @@ static int mov_read_smi(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
st->codec->extradata_size = 0x5a + atom.size;
memcpy(st->codec->extradata, "SVQ3", 4); // fake
- get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
+ avio_read(pb, st->codec->extradata + 0x5a, atom.size);
av_dlog(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
return 0;
}
@@ -711,7 +711,7 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- little_endian = get_be16(pb);
+ little_endian = avio_rb16(pb);
av_dlog(c->fc, "enda %d\n", little_endian);
if (little_endian == 1) {
switch (st->codec->codec_id) {
@@ -755,7 +755,7 @@ static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE;
AV_WB32( buf , atom.size + 8);
AV_WL32( buf + 4, atom.type);
- get_buffer(pb, buf + 8, atom.size);
+ avio_read(pb, buf + 8, atom.size);
return 0;
}
@@ -777,7 +777,7 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
- get_buffer(pb, st->codec->extradata, atom.size);
+ avio_read(pb, st->codec->extradata, atom.size);
} else if (atom.size > 8) { /* to read frma, esds atoms */
if (mov_read_default(c, pb, atom) < 0)
return -1;
@@ -806,7 +806,7 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
- get_buffer(pb, st->codec->extradata, atom.size);
+ avio_read(pb, st->codec->extradata, atom.size);
return 0;
}
@@ -834,7 +834,7 @@ static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 40;
url_fskip(pb, 40);
- get_buffer(pb, st->codec->extradata, atom.size - 40);
+ avio_read(pb, st->codec->extradata, atom.size - 40);
return 0;
}
@@ -849,10 +849,10 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
if(entries >= UINT_MAX/sizeof(int64_t))
return -1;
@@ -864,10 +864,10 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (atom.type == MKTAG('s','t','c','o'))
for(i=0; i<entries; i++)
- sc->chunk_offsets[i] = get_be32(pb);
+ sc->chunk_offsets[i] = avio_rb32(pb);
else if (atom.type == MKTAG('c','o','6','4'))
for(i=0; i<entries; i++)
- sc->chunk_offsets[i] = get_be64(pb);
+ sc->chunk_offsets[i] = avio_rb64(pb);
else
return -1;
@@ -926,13 +926,13 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
int dref_id = 1;
MOVAtom a = { AV_RL32("stsd") };
int64_t start_pos = url_ftell(pb);
- int size = get_be32(pb); /* size */
- uint32_t format = get_le32(pb); /* data format */
+ int size = avio_rb32(pb); /* size */
+ uint32_t format = avio_rl32(pb); /* data format */
if (size >= 16) {
- get_be32(pb); /* reserved */
- get_be16(pb); /* reserved */
- dref_id = get_be16(pb);
+ avio_rb32(pb); /* reserved */
+ avio_rb16(pb); /* reserved */
+ dref_id = avio_rb16(pb);
}
if (st->codec->codec_tag &&
@@ -984,21 +984,21 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
int color_greyscale;
st->codec->codec_id = id;
- get_be16(pb); /* version */
- get_be16(pb); /* revision level */
- get_be32(pb); /* vendor */
- get_be32(pb); /* temporal quality */
- get_be32(pb); /* spatial quality */
+ avio_rb16(pb); /* version */
+ avio_rb16(pb); /* revision level */
+ avio_rb32(pb); /* vendor */
+ avio_rb32(pb); /* temporal quality */
+ avio_rb32(pb); /* spatial quality */
- st->codec->width = get_be16(pb); /* width */
- st->codec->height = get_be16(pb); /* height */
+ st->codec->width = avio_rb16(pb); /* width */
+ st->codec->height = avio_rb16(pb); /* height */
- get_be32(pb); /* horiz resolution */
- get_be32(pb); /* vert resolution */
- get_be32(pb); /* data size, always 0 */
- get_be16(pb); /* frames per samples */
+ avio_rb32(pb); /* horiz resolution */
+ avio_rb32(pb); /* vert resolution */
+ avio_rb32(pb); /* data size, always 0 */
+ avio_rb16(pb); /* frames per samples */
- len = get_byte(pb); /* codec name, pascal string */
+ len = avio_r8(pb); /* codec name, pascal string */
if (len > 31)
len = 31;
mov_read_mac_string(c, pb, len, st->codec->codec_name, 32);
@@ -1008,8 +1008,8 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
if (!memcmp(st->codec->codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25))
st->codec->codec_tag=MKTAG('I', '4', '2', '0');
- st->codec->bits_per_coded_sample = get_be16(pb); /* depth */
- st->codec->color_table_id = get_be16(pb); /* colortable id */
+ st->codec->bits_per_coded_sample = avio_rb16(pb); /* depth */
+ st->codec->color_table_id = avio_rb16(pb); /* colortable id */
av_dlog(c->fc, "depth %d, ctab id %d\n",
st->codec->bits_per_coded_sample, st->codec->color_table_id);
/* figure out the palette situation */
@@ -1059,23 +1059,23 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
}
} else {
/* load the palette from the file */
- color_start = get_be32(pb);
- color_count = get_be16(pb);
- color_end = get_be16(pb);
+ color_start = avio_rb32(pb);
+ color_count = avio_rb16(pb);
+ color_end = avio_rb16(pb);
if ((color_start <= 255) &&
(color_end <= 255)) {
for (j = color_start; j <= color_end; j++) {
/* each R, G, or B component is 16 bits;
* only use the top 8 bits; skip alpha bytes
* up front */
- get_byte(pb);
- get_byte(pb);
- r = get_byte(pb);
- get_byte(pb);
- g = get_byte(pb);
- get_byte(pb);
- b = get_byte(pb);
- get_byte(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ r = avio_r8(pb);
+ avio_r8(pb);
+ g = avio_r8(pb);
+ avio_r8(pb);
+ b = avio_r8(pb);
+ avio_r8(pb);
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
}
@@ -1085,38 +1085,38 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
}
} else if(st->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
int bits_per_sample, flags;
- uint16_t version = get_be16(pb);
+ uint16_t version = avio_rb16(pb);
st->codec->codec_id = id;
- get_be16(pb); /* revision level */
- get_be32(pb); /* vendor */
+ avio_rb16(pb); /* revision level */
+ avio_rb32(pb); /* vendor */
- st->codec->channels = get_be16(pb); /* channel count */
+ st->codec->channels = avio_rb16(pb); /* channel count */
av_dlog(c->fc, "audio channels %d\n", st->codec->channels);
- st->codec->bits_per_coded_sample = get_be16(pb); /* sample size */
+ st->codec->bits_per_coded_sample = avio_rb16(pb); /* sample size */
- sc->audio_cid = get_be16(pb);
- get_be16(pb); /* packet size = 0 */
+ sc->audio_cid = avio_rb16(pb);
+ avio_rb16(pb); /* packet size = 0 */
- st->codec->sample_rate = ((get_be32(pb) >> 16));
+ st->codec->sample_rate = ((avio_rb32(pb) >> 16));
//Read QT version 1 fields. In version 0 these do not exist.
av_dlog(c->fc, "version =%d, isom =%d\n",version,c->isom);
if(!c->isom) {
if(version==1) {
- sc->samples_per_frame = get_be32(pb);
- get_be32(pb); /* bytes per packet */
- sc->bytes_per_frame = get_be32(pb);
- get_be32(pb); /* bytes per sample */
+ sc->samples_per_frame = avio_rb32(pb);
+ avio_rb32(pb); /* bytes per packet */
+ sc->bytes_per_frame = avio_rb32(pb);
+ avio_rb32(pb); /* bytes per sample */
} else if(version==2) {
- get_be32(pb); /* sizeof struct only */
- st->codec->sample_rate = av_int2dbl(get_be64(pb)); /* float 64 */
- st->codec->channels = get_be32(pb);
- get_be32(pb); /* always 0x7F000000 */
- st->codec->bits_per_coded_sample = get_be32(pb); /* bits per channel if sound is uncompressed */
- flags = get_be32(pb); /* lpcm format specific flag */
- sc->bytes_per_frame = get_be32(pb); /* bytes per audio packet if constant */
- sc->samples_per_frame = get_be32(pb); /* lpcm frames per audio packet if constant */
+ avio_rb32(pb); /* sizeof struct only */
+ st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); /* float 64 */
+ st->codec->channels = avio_rb32(pb);
+ avio_rb32(pb); /* always 0x7F000000 */
+ st->codec->bits_per_coded_sample = avio_rb32(pb); /* bits per channel if sound is uncompressed */
+ flags = avio_rb32(pb); /* lpcm format specific flag */
+ sc->bytes_per_frame = avio_rb32(pb); /* bytes per audio packet if constant */
+ sc->samples_per_frame = avio_rb32(pb); /* lpcm frames per audio packet if constant */
if (format == MKTAG('l','p','c','m'))
st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
}
@@ -1249,9 +1249,9 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int entries;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
return ff_mov_read_stsd_entries(c, pb, entries);
}
@@ -1267,10 +1267,10 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
@@ -1282,9 +1282,9 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc->stsc_count = entries;
for(i=0; i<entries; i++) {
- sc->stsc_data[i].first = get_be32(pb);
- sc->stsc_data[i].count = get_be32(pb);
- sc->stsc_data[i].id = get_be32(pb);
+ sc->stsc_data[i].first = avio_rb32(pb);
+ sc->stsc_data[i].count = avio_rb32(pb);
+ sc->stsc_data[i].id = avio_rb32(pb);
}
return 0;
}
@@ -1300,9 +1300,9 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_be32(pb); // version + flags
+ avio_rb32(pb); // version + flags
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->stps_data))
return -1;
sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data));
@@ -1311,7 +1311,7 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc->stps_count = entries;
for (i = 0; i < entries; i++) {
- sc->stps_data[i] = get_be32(pb);
+ sc->stps_data[i] = avio_rb32(pb);
//av_dlog(c->fc, "stps %d\n", sc->stps_data[i]);
}
@@ -1329,10 +1329,10 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "keyframe_count = %d\n", entries);
@@ -1344,7 +1344,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc->keyframe_count = entries;
for(i=0; i<entries; i++) {
- sc->keyframes[i] = get_be32(pb);
+ sc->keyframes[i] = avio_rb32(pb);
//av_dlog(c->fc, "keyframes[]=%d\n", sc->keyframes[i]);
}
return 0;
@@ -1363,20 +1363,20 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
if (atom.type == MKTAG('s','t','s','z')) {
- sample_size = get_be32(pb);
+ sample_size = avio_rb32(pb);
if (!sc->sample_size) /* do not overwrite value computed in stsd */
sc->sample_size = sample_size;
field_size = 32;
} else {
sample_size = 0;
- get_be24(pb); /* reserved */
- field_size = get_byte(pb);
+ avio_rb24(pb); /* reserved */
+ field_size = avio_r8(pb);
}
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
@@ -1403,7 +1403,7 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
}
- if (get_buffer(pb, buf, num_bytes) < num_bytes) {
+ if (avio_read(pb, buf, num_bytes) < num_bytes) {
av_freep(&sc->sample_sizes);
av_free(buf);
return -1;
@@ -1431,9 +1431,9 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries);
@@ -1448,8 +1448,8 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int sample_duration;
int sample_count;
- sample_count=get_be32(pb);
- sample_duration = get_be32(pb);
+ sample_count=avio_rb32(pb);
+ sample_duration = avio_rb32(pb);
sc->stts_data[i].count= sample_count;
sc->stts_data[i].duration= sample_duration;
@@ -1476,9 +1476,9 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
@@ -1490,8 +1490,8 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc->ctts_count = entries;
for(i=0; i<entries; i++) {
- int count =get_be32(pb);
- int duration =get_be32(pb);
+ int count =avio_rb32(pb);
+ int duration =avio_rb32(pb);
sc->ctts_data[i].count = count;
sc->ctts_data[i].duration= duration;
@@ -1837,7 +1837,7 @@ static int mov_read_ilst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
while (atom.size > 8) {
- uint32_t tag = get_le32(pb);
+ uint32_t tag = avio_rl32(pb);
atom.size -= 4;
if (tag == MKTAG('h','d','l','r')) {
url_fseek(pb, -8, SEEK_CUR);
@@ -1864,8 +1864,8 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- version = get_byte(pb);
- get_be24(pb); /* flags */
+ version = avio_r8(pb);
+ avio_rb24(pb); /* flags */
/*
MOV_TRACK_ENABLED 0x0001
MOV_TRACK_IN_MOVIE 0x0002
@@ -1874,36 +1874,36 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
*/
if (version == 1) {
- get_be64(pb);
- get_be64(pb);
+ avio_rb64(pb);
+ avio_rb64(pb);
} else {
- get_be32(pb); /* creation time */
- get_be32(pb); /* modification time */
+ avio_rb32(pb); /* creation time */
+ avio_rb32(pb); /* modification time */
}
- st->id = (int)get_be32(pb); /* track id (NOT 0 !)*/
- get_be32(pb); /* reserved */
+ st->id = (int)avio_rb32(pb); /* track id (NOT 0 !)*/
+ avio_rb32(pb); /* reserved */
/* highlevel (considering edits) duration in movie timebase */
- (version == 1) ? get_be64(pb) : get_be32(pb);
- get_be32(pb); /* reserved */
- get_be32(pb); /* reserved */
+ (version == 1) ? avio_rb64(pb) : avio_rb32(pb);
+ avio_rb32(pb); /* reserved */
+ avio_rb32(pb); /* reserved */
- get_be16(pb); /* layer */
- get_be16(pb); /* alternate group */
- get_be16(pb); /* volume */
- get_be16(pb); /* reserved */
+ avio_rb16(pb); /* layer */
+ avio_rb16(pb); /* alternate group */
+ avio_rb16(pb); /* volume */
+ avio_rb16(pb); /* reserved */
//read in the display matrix (outlined in ISO 14496-12, Section 6.2.2)
// they're kept in fixed point format through all calculations
// ignore u,v,z b/c we don't need the scale factor to calc aspect ratio
for (i = 0; i < 3; i++) {
- display_matrix[i][0] = get_be32(pb); // 16.16 fixed point
- display_matrix[i][1] = get_be32(pb); // 16.16 fixed point
- get_be32(pb); // 2.30 fixed point (not used)
+ display_matrix[i][0] = avio_rb32(pb); // 16.16 fixed point
+ display_matrix[i][1] = avio_rb32(pb); // 16.16 fixed point
+ avio_rb32(pb); // 2.30 fixed point (not used)
}
- width = get_be32(pb); // 16.16 fixed point track width
- height = get_be32(pb); // 16.16 fixed point track height
+ width = avio_rb32(pb); // 16.16 fixed point track width
+ height = avio_rb32(pb); // 16.16 fixed point track height
sc->width = width >> 16;
sc->height = height >> 16;
@@ -1937,10 +1937,10 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
MOVTrackExt *trex = NULL;
int flags, track_id, i;
- get_byte(pb); /* version */
- flags = get_be24(pb);
+ avio_r8(pb); /* version */
+ flags = avio_rb24(pb);
- track_id = get_be32(pb);
+ track_id = avio_rb32(pb);
if (!track_id)
return -1;
frag->track_id = track_id;
@@ -1954,21 +1954,21 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return -1;
}
- if (flags & 0x01) frag->base_data_offset = get_be64(pb);
+ if (flags & 0x01) frag->base_data_offset = avio_rb64(pb);
else frag->base_data_offset = frag->moof_offset;
- if (flags & 0x02) frag->stsd_id = get_be32(pb);
+ if (flags & 0x02) frag->stsd_id = avio_rb32(pb);
else frag->stsd_id = trex->stsd_id;
- frag->duration = flags & 0x08 ? get_be32(pb) : trex->duration;
- frag->size = flags & 0x10 ? get_be32(pb) : trex->size;
- frag->flags = flags & 0x20 ? get_be32(pb) : trex->flags;
+ frag->duration = flags & 0x08 ? avio_rb32(pb) : trex->duration;
+ frag->size = flags & 0x10 ? avio_rb32(pb) : trex->size;
+ frag->flags = flags & 0x20 ? avio_rb32(pb) : trex->flags;
av_dlog(c->fc, "frag flags 0x%x\n", frag->flags);
return 0;
}
static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
- c->chapter_track = get_be32(pb);
+ c->chapter_track = avio_rb32(pb);
return 0;
}
@@ -1983,13 +1983,13 @@ static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
c->trex_data = trex;
trex = &c->trex_data[c->trex_count++];
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- trex->track_id = get_be32(pb);
- trex->stsd_id = get_be32(pb);
- trex->duration = get_be32(pb);
- trex->size = get_be32(pb);
- trex->flags = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ trex->track_id = avio_rb32(pb);
+ trex->stsd_id = avio_rb32(pb);
+ trex->duration = avio_rb32(pb);
+ trex->size = avio_rb32(pb);
+ trex->flags = avio_rb32(pb);
return 0;
}
@@ -2017,12 +2017,12 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc = st->priv_data;
if (sc->pseudo_stream_id+1 != frag->stsd_id)
return 0;
- get_byte(pb); /* version */
- flags = get_be24(pb);
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ flags = avio_rb24(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "flags 0x%x entries %d\n", flags, entries);
- if (flags & 0x001) data_offset = get_be32(pb);
- if (flags & 0x004) first_sample_flags = get_be32(pb);
+ if (flags & 0x001) data_offset = avio_rb32(pb);
+ if (flags & 0x004) first_sample_flags = avio_rb32(pb);
if (flags & 0x800) {
MOVStts *ctts_data;
if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))
@@ -2043,12 +2043,12 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned sample_duration = frag->duration;
int keyframe;
- if (flags & 0x100) sample_duration = get_be32(pb);
- if (flags & 0x200) sample_size = get_be32(pb);
- if (flags & 0x400) sample_flags = get_be32(pb);
+ if (flags & 0x100) sample_duration = avio_rb32(pb);
+ if (flags & 0x200) sample_size = avio_rb32(pb);
+ if (flags & 0x400) sample_flags = avio_rb32(pb);
if (flags & 0x800) {
sc->ctts_data[sc->ctts_count].count = 1;
- sc->ctts_data[sc->ctts_count].duration = get_be32(pb);
+ sc->ctts_data[sc->ctts_count].duration = avio_rb32(pb);
sc->ctts_count++;
}
if ((keyframe = st->codec->codec_type == AVMEDIA_TYPE_AUDIO ||
@@ -2077,11 +2077,11 @@ static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (atom.size < 8)
return 0; /* continue */
- if (get_be32(pb) != 0) { /* 0 sized mdat atom... use the 'wide' atom size */
+ if (avio_rb32(pb) != 0) { /* 0 sized mdat atom... use the 'wide' atom size */
url_fskip(pb, atom.size - 4);
return 0;
}
- atom.type = get_le32(pb);
+ atom.type = avio_rl32(pb);
atom.size -= 8;
if (atom.type != MKTAG('m','d','a','t')) {
url_fskip(pb, atom.size);
@@ -2100,17 +2100,17 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
long cmov_len, moov_len;
int ret = -1;
- get_be32(pb); /* dcom atom */
- if (get_le32(pb) != MKTAG('d','c','o','m'))
+ avio_rb32(pb); /* dcom atom */
+ if (avio_rl32(pb) != MKTAG('d','c','o','m'))
return -1;
- if (get_le32(pb) != MKTAG('z','l','i','b')) {
+ if (avio_rl32(pb) != MKTAG('z','l','i','b')) {
av_log(c->fc, AV_LOG_ERROR, "unknown compression for cmov atom !");
return -1;
}
- get_be32(pb); /* cmvd atom */
- if (get_le32(pb) != MKTAG('c','m','v','d'))
+ avio_rb32(pb); /* cmvd atom */
+ if (avio_rl32(pb) != MKTAG('c','m','v','d'))
return -1;
- moov_len = get_be32(pb); /* uncompressed size */
+ moov_len = avio_rb32(pb); /* uncompressed size */
cmov_len = atom.size - 6 * 4;
cmov_data = av_malloc(cmov_len);
@@ -2121,7 +2121,7 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_free(cmov_data);
return AVERROR(ENOMEM);
}
- get_buffer(pb, cmov_data, cmov_len);
+ avio_read(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(ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
@@ -2152,18 +2152,18 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
sc = c->fc->streams[c->fc->nb_streams-1]->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- edit_count = get_be32(pb); /* entries */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ edit_count = avio_rb32(pb); /* entries */
if((uint64_t)edit_count*12+8 > atom.size)
return -1;
for(i=0; i<edit_count; i++){
int time;
- int duration = get_be32(pb); /* Track duration */
- time = get_be32(pb); /* Media time */
- get_be32(pb); /* Media rate */
+ int duration = avio_rb32(pb); /* Track duration */
+ time = avio_rb32(pb); /* Media time */
+ avio_rb32(pb); /* Media rate */
if (i == 0 && time >= -1) {
sc->time_offset = time != -1 ? time : -duration;
}
@@ -2314,7 +2314,7 @@ static void mov_read_chapters(AVFormatContext *s)
}
// the first two bytes are the length of the title
- len = get_be16(sc->pb);
+ len = avio_rb16(sc->pb);
if (len > sample->size-2)
continue;
title_len = 2*len + 1;
@@ -2324,7 +2324,7 @@ static void mov_read_chapters(AVFormatContext *s)
// The samples could theoretically be in any encoding if there's an encd
// atom following, but in practice are only utf-8 or utf-16, distinguished
// instead by the presence of a BOM
- ch = get_be16(sc->pb);
+ ch = avio_rb16(sc->pb);
if (ch == 0xfeff)
avio_get_str16be(sc->pb, len, title, title_len);
else if (ch == 0xfffe)
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 5bc4ce64dc..a71638ee13 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -80,7 +80,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
MPADecodeHeader c;
int vbrtag_size = 0;
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(ff_mpa_check_header(v) < 0)
return -1;
@@ -91,25 +91,25 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
/* Check for Xing / Info tag */
url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) {
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(v & 0x1)
- frames = get_be32(s->pb);
+ frames = avio_rb32(s->pb);
if(v & 0x2)
- size = get_be32(s->pb);
+ size = avio_rb32(s->pb);
}
/* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
url_fseek(s->pb, base + 4 + 32, SEEK_SET);
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(v == MKBETAG('V', 'B', 'R', 'I')) {
/* Check tag version */
- if(get_be16(s->pb) == 1) {
+ if(avio_rb16(s->pb) == 1) {
/* skip delay and quality */
url_fseek(s->pb, 4, SEEK_CUR);
- frames = get_be32(s->pb);
- size = get_be32(s->pb);
+ frames = avio_rb32(s->pb);
+ size = avio_rb32(s->pb);
}
}
diff --git a/libavformat/mpc.c b/libavformat/mpc.c
index aa0572603f..73217a31ea 100644
--- a/libavformat/mpc.c
+++ b/libavformat/mpc.c
@@ -55,16 +55,16 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
MPCContext *c = s->priv_data;
AVStream *st;
- if(get_le24(s->pb) != MKTAG('M', 'P', '+', 0)){
+ if(avio_rl24(s->pb) != MKTAG('M', 'P', '+', 0)){
av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
return -1;
}
- c->ver = get_byte(s->pb);
+ c->ver = avio_r8(s->pb);
if(c->ver != 0x07 && c->ver != 0x17){
av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver);
return -1;
}
- c->fcount = get_le32(s->pb);
+ c->fcount = avio_rl32(s->pb);
if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){
av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n");
return -1;
@@ -85,7 +85,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = 16;
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(s->pb, st->codec->extradata, 16);
+ avio_read(s->pb, st->codec->extradata, 16);
st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3];
av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate);
/* scan for seekpoints */
@@ -121,11 +121,11 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
c->curframe++;
curbits = c->curbits;
pos = url_ftell(s->pb);
- tmp = get_le32(s->pb);
+ tmp = avio_rl32(s->pb);
if(curbits <= 12){
size2 = (tmp >> (12 - curbits)) & 0xFFFFF;
}else{
- tmp = (tmp << 32) | get_le32(s->pb);
+ tmp = (tmp << 32) | avio_rl32(s->pb);
size2 = (tmp >> (44 - curbits)) & 0xFFFFF;
}
curbits += 20;
@@ -151,7 +151,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = 0;
pkt->pts = cur;
- ret = get_buffer(s->pb, pkt->data + 4, size);
+ ret = avio_read(s->pb, pkt->data + 4, size);
if(c->curbits)
url_fseek(s->pb, -4, SEEK_CUR);
if(ret < size){
diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c
index d40a602e83..22439f94a0 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -121,7 +121,7 @@ static void mpc8_get_chunk_header(AVIOContext *pb, int *tag, int64_t *size)
{
int64_t pos;
pos = url_ftell(pb);
- *tag = get_le16(pb);
+ *tag = avio_rl16(pb);
*size = ff_get_v(pb);
*size -= url_ftell(pb) - pos;
}
@@ -143,7 +143,7 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
}
if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE)))
return;
- get_buffer(s->pb, buf, size);
+ avio_read(s->pb, buf, size);
init_get_bits(&gb, buf, size * 8);
size = gb_get_v(&gb);
if(size > UINT_MAX/4 || size > c->samples/1152){
@@ -195,7 +195,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
int64_t size, pos;
c->header_pos = url_ftell(pb);
- if(get_le32(pb) != TAG_MPCK){
+ if(avio_rl32(pb) != TAG_MPCK){
av_log(s, AV_LOG_ERROR, "Not a Musepack8 file\n");
return -1;
}
@@ -213,7 +213,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
pos = url_ftell(pb);
url_fskip(pb, 4); //CRC
- c->ver = get_byte(pb);
+ c->ver = avio_r8(pb);
if(c->ver != 8){
av_log(s, AV_LOG_ERROR, "Unknown stream version %d\n", c->ver);
return -1;
@@ -230,7 +230,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = 2;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
st->codec->channels = (st->codec->extradata[1] >> 4) + 1;
st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5];
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 66e967c022..c5b6bfc727 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -113,7 +113,7 @@ static int mpegps_read_header(AVFormatContext *s,
m->sofdec = -1;
do {
- v = get_byte(s->pb);
+ v = avio_r8(s->pb);
m->header_state = m->header_state << 8 | v;
m->sofdec++;
} while (v == sofdec[i] && i++ < 6);
@@ -128,8 +128,8 @@ static int64_t get_pts(AVIOContext *pb, int c)
{
uint8_t buf[5];
- buf[0] = c<0 ? get_byte(pb) : c;
- get_buffer(pb, buf+1, 4);
+ buf[0] = c<0 ? avio_r8(pb) : c;
+ avio_read(pb, buf+1, 4);
return ff_parse_pes_pts(buf);
}
@@ -145,7 +145,7 @@ static int find_next_start_code(AVIOContext *pb, int *size_ptr,
while (n > 0) {
if (url_feof(pb))
break;
- v = get_byte(pb);
+ v = avio_r8(pb);
n--;
if (state == 0x000001) {
state = ((state << 8) | v) & 0xffffff;
@@ -176,7 +176,7 @@ static int find_prev_start_code(AVIOContext *pb, int *size_ptr)
if (pos < 0)
pos = 0;
url_fseek(pb, pos, SEEK_SET);
- get_byte(pb);
+ avio_r8(pb);
pos = pos_start;
for(;;) {
@@ -186,7 +186,7 @@ static int find_prev_start_code(AVIOContext *pb, int *size_ptr)
goto the_end;
}
url_fseek(pb, pos, SEEK_SET);
- start_code = get_be32(pb);
+ start_code = avio_rb32(pb);
if ((start_code & 0xffffff00) == 0x100)
break;
}
@@ -206,27 +206,27 @@ static long mpegps_psm_parse(MpegDemuxContext *m, AVIOContext *pb)
{
int psm_length, ps_info_length, es_map_length;
- psm_length = get_be16(pb);
- get_byte(pb);
- get_byte(pb);
- ps_info_length = get_be16(pb);
+ psm_length = avio_rb16(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ ps_info_length = avio_rb16(pb);
/* skip program_stream_info */
url_fskip(pb, ps_info_length);
- es_map_length = get_be16(pb);
+ es_map_length = avio_rb16(pb);
/* at least one es available? */
while (es_map_length >= 4){
- unsigned char type = get_byte(pb);
- unsigned char es_id = get_byte(pb);
- uint16_t es_info_length = get_be16(pb);
+ unsigned char type = avio_r8(pb);
+ unsigned char es_id = avio_r8(pb);
+ uint16_t es_info_length = avio_rb16(pb);
/* remember mapping from stream id to stream type */
m->psm_es_type[es_id] = type;
/* skip program_stream_info */
url_fskip(pb, es_info_length);
es_map_length -= 4 + es_info_length;
}
- get_be32(pb); /* crc32 */
+ avio_rb32(pb); /* crc32 */
return 2 + psm_length;
}
@@ -264,16 +264,16 @@ static int mpegps_read_pes_header(AVFormatContext *s,
if (startcode == SYSTEM_HEADER_START_CODE)
goto redo;
if (startcode == PADDING_STREAM) {
- url_fskip(s->pb, get_be16(s->pb));
+ url_fskip(s->pb, avio_rb16(s->pb));
goto redo;
}
if (startcode == PRIVATE_STREAM_2) {
- len = get_be16(s->pb);
+ len = avio_rb16(s->pb);
if (!m->sofdec) {
while (len-- >= 6) {
- if (get_byte(s->pb) == 'S') {
+ if (avio_r8(s->pb) == 'S') {
uint8_t buf[5];
- get_buffer(s->pb, buf, sizeof(buf));
+ avio_read(s->pb, buf, sizeof(buf));
m->sofdec = !memcmp(buf, "ofdec", 5);
len -= sizeof(buf);
break;
@@ -297,14 +297,14 @@ static int mpegps_read_pes_header(AVFormatContext *s,
if (ppos) {
*ppos = url_ftell(s->pb) - 4;
}
- len = get_be16(s->pb);
+ len = avio_rb16(s->pb);
pts =
dts = AV_NOPTS_VALUE;
/* stuffing */
for(;;) {
if (len < 1)
goto error_redo;
- c = get_byte(s->pb);
+ c = avio_r8(s->pb);
len--;
/* XXX: for mpeg1, should test only bit 7 */
if (c != 0xff)
@@ -312,8 +312,8 @@ static int mpegps_read_pes_header(AVFormatContext *s,
}
if ((c & 0xc0) == 0x40) {
/* buffer scale & size */
- get_byte(s->pb);
- c = get_byte(s->pb);
+ avio_r8(s->pb);
+ c = avio_r8(s->pb);
len -= 2;
}
if ((c & 0xe0) == 0x20) {
@@ -331,8 +331,8 @@ static int mpegps_read_pes_header(AVFormatContext *s,
goto redo;
}
#endif
- flags = get_byte(s->pb);
- header_len = get_byte(s->pb);
+ flags = avio_r8(s->pb);
+ header_len = avio_r8(s->pb);
len -= 2;
if (header_len > len)
goto error_redo;
@@ -350,7 +350,7 @@ static int mpegps_read_pes_header(AVFormatContext *s,
av_log(s, AV_LOG_WARNING, "Further flags set but no bytes left\n");
}
if (flags & 0x01) { /* PES extension */
- pes_ext = get_byte(s->pb);
+ pes_ext = avio_r8(s->pb);
header_len--;
/* Skip PES private data, program packet sequence counter and P-STD buffer */
skip = (pes_ext >> 4) & 0xb;
@@ -363,10 +363,10 @@ static int mpegps_read_pes_header(AVFormatContext *s,
header_len -= skip;
if (pes_ext & 0x01) { /* PES extension 2 */
- ext2_len = get_byte(s->pb);
+ ext2_len = avio_r8(s->pb);
header_len--;
if ((ext2_len & 0x7f) > 0) {
- id_ext = get_byte(s->pb);
+ id_ext = avio_r8(s->pb);
if ((id_ext & 0x80) == 0)
startcode = ((startcode & 0xff) << 8) | id_ext;
header_len--;
@@ -381,17 +381,17 @@ static int mpegps_read_pes_header(AVFormatContext *s,
goto redo;
if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
- startcode = get_byte(s->pb);
+ startcode = avio_r8(s->pb);
len--;
if (startcode >= 0x80 && startcode <= 0xcf) {
/* audio: skip header */
- get_byte(s->pb);
- get_byte(s->pb);
- get_byte(s->pb);
+ avio_r8(s->pb);
+ avio_r8(s->pb);
+ avio_r8(s->pb);
len -= 3;
if (startcode >= 0xb0 && startcode <= 0xbf) {
/* MLP/TrueHD audio has a 4-byte header */
- get_byte(s->pb);
+ avio_r8(s->pb);
len--;
}
}
@@ -432,7 +432,7 @@ static int mpegps_read_packet(AVFormatContext *s,
return len;
if(startcode == 0x1bd) {
- dvdaudio_substream_type = get_byte(s->pb);
+ dvdaudio_substream_type = avio_r8(s->pb);
url_fskip(s->pb, 3);
len -= 4;
}
@@ -474,7 +474,7 @@ static int mpegps_read_packet(AVFormatContext *s,
} else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
unsigned char buf[8];
- get_buffer(s->pb, buf, 8);
+ avio_read(s->pb, buf, 8);
url_fseek(s->pb, -8, SEEK_CUR);
if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
codec_id = CODEC_ID_CAVS;
@@ -547,9 +547,9 @@ static int mpegps_read_packet(AVFormatContext *s,
audio data */
if (len <= 3)
goto skip;
- get_byte(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
- b1 = get_byte(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
- get_byte(s->pb); /* dynamic range control (0x80 = off) */
+ avio_r8(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
+ b1 = avio_r8(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
+ avio_r8(s->pb); /* dynamic range control (0x80 = off) */
len -= 3;
freq = (b1 >> 4) & 3;
st->codec->sample_rate = lpcm_freq_tab[freq];
@@ -564,7 +564,7 @@ static int mpegps_read_packet(AVFormatContext *s,
return AVERROR(EINVAL);
}
av_new_packet(pkt, len);
- get_buffer(s->pb, pkt->data, pkt->size);
+ avio_read(s->pb, pkt->data, pkt->size);
pkt->pts = pts;
pkt->dts = dts;
pkt->pos = dummy_pos;
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index fb45e60844..3307685b41 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -860,24 +860,24 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size,
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4IODescrTag) {
- get_be16(&pb); // ID
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
+ avio_rb16(&pb); // ID
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4ESDescrTag) {
- *es_id = get_be16(&pb); /* ES_ID */
+ *es_id = avio_rb16(&pb); /* ES_ID */
av_dlog(s, "ES_ID %#x\n", *es_id);
- get_byte(&pb); /* priority */
+ avio_r8(&pb); /* priority */
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4DecConfigDescrTag) {
*dec_config_descr = av_malloc(len);
if (!*dec_config_descr)
return AVERROR(ENOMEM);
*dec_config_descr_size = len;
- get_buffer(&pb, *dec_config_descr, len);
+ avio_read(&pb, *dec_config_descr, len);
}
}
}
@@ -1332,7 +1332,7 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size)
int skip, len;
for(;;) {
- len = get_buffer(pb, buf, TS_PACKET_SIZE);
+ len = avio_read(pb, buf, TS_PACKET_SIZE);
if (len != TS_PACKET_SIZE)
return AVERROR(EIO);
/* check paquet sync byte */
@@ -1455,7 +1455,7 @@ static int mpegts_read_header(AVFormatContext *s,
/* read the first 1024 bytes to get packet size */
pos = url_ftell(pb);
- len = get_buffer(pb, buf, sizeof(buf));
+ len = avio_read(pb, buf, sizeof(buf));
if (len != sizeof(buf))
goto fail;
ts->raw_packet_size = get_packet_size(buf, sizeof(buf));
@@ -1565,7 +1565,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s,
pos = url_ftell(s->pb);
for(i = 0; i < MAX_PACKET_READAHEAD; i++) {
url_fseek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
- get_buffer(s->pb, pcr_buf, 12);
+ avio_read(s->pb, pcr_buf, 12);
if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
/* XXX: not precise enough */
ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) /
@@ -1650,7 +1650,7 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
if (find_next) {
for(;;) {
url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return AV_NOPTS_VALUE;
if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
parse_pcr(&timestamp, &pcr_l, buf) == 0) {
@@ -1664,7 +1664,7 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
if (pos < 0)
return AV_NOPTS_VALUE;
url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return AV_NOPTS_VALUE;
if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
parse_pcr(&timestamp, &pcr_l, buf) == 0) {
@@ -1775,7 +1775,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, in
for(;;) {
url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return -1;
// pid = AV_RB16(buf + 1) & 0x1fff;
if(buf[1] & 0x40) break;
diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c
index 4408c18601..3033c23a91 100644
--- a/libavformat/msnwc_tcp.c
+++ b/libavformat/msnwc_tcp.c
@@ -88,7 +88,7 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap)
/* Some files start with "connected\r\n\r\n".
* So skip until we find the first byte of struct size */
- while(get_byte(pb) != HEADER_SIZE && !url_feof(pb));
+ while(avio_r8(pb) != HEADER_SIZE && !url_feof(pb));
if(url_feof(pb)) {
av_log(ctx, AV_LOG_ERROR, "Could not find valid start.");
@@ -107,11 +107,11 @@ static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt)
url_fskip(pb, 1); /* one byte has been read ahead */
url_fskip(pb, 2);
url_fskip(pb, 2);
- keyframe = get_le16(pb);
- size = get_le32(pb);
+ keyframe = avio_rl16(pb);
+ size = avio_rl32(pb);
url_fskip(pb, 4);
url_fskip(pb, 4);
- timestamp = get_le32(pb);
+ timestamp = avio_rl32(pb);
if(!size || av_get_packet(pb, pkt, size) != size)
return -1;
diff --git a/libavformat/mtv.c b/libavformat/mtv.c
index d6f8a2018b..94d8aff548 100644
--- a/libavformat/mtv.c
+++ b/libavformat/mtv.c
@@ -84,16 +84,16 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
unsigned int audio_subsegments;
url_fskip(pb, 3);
- mtv->file_size = get_le32(pb);
- mtv->segments = get_le32(pb);
+ mtv->file_size = avio_rl32(pb);
+ mtv->segments = avio_rl32(pb);
url_fskip(pb, 32);
- mtv->audio_identifier = get_le24(pb);
- mtv->audio_br = get_le16(pb);
- mtv->img_colorfmt = get_le24(pb);
- mtv->img_bpp = get_byte(pb);
- mtv->img_width = get_le16(pb);
- mtv->img_height = get_le16(pb);
- mtv->img_segment_size = get_le16(pb);
+ mtv->audio_identifier = avio_rl24(pb);
+ mtv->audio_br = avio_rl16(pb);
+ mtv->img_colorfmt = avio_rl24(pb);
+ mtv->img_bpp = avio_r8(pb);
+ mtv->img_width = avio_rl16(pb);
+ mtv->img_height = avio_rl16(pb);
+ mtv->img_segment_size = avio_rl16(pb);
/* Calculate width and height if missing from header */
@@ -106,7 +106,7 @@ static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
/ mtv->img_width;
url_fskip(pb, 4);
- audio_subsegments = get_le16(pb);
+ audio_subsegments = avio_rl16(pb);
mtv->full_segment_size =
audio_subsegments * (MTV_AUDIO_PADDING_SIZE + MTV_ASUBCHUNK_DATA_SIZE) +
mtv->img_segment_size;
diff --git a/libavformat/mvi.c b/libavformat/mvi.c
index 053de15a5a..4784efae0d 100644
--- a/libavformat/mvi.c
+++ b/libavformat/mvi.c
@@ -53,20 +53,20 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->extradata_size = 2;
vst->codec->extradata = av_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE);
- version = get_byte(pb);
- vst->codec->extradata[0] = get_byte(pb);
- vst->codec->extradata[1] = get_byte(pb);
- frames_count = get_le32(pb);
- msecs_per_frame = get_le32(pb);
- vst->codec->width = get_le16(pb);
- vst->codec->height = get_le16(pb);
- get_byte(pb);
- ast->codec->sample_rate = get_le16(pb);
- mvi->audio_data_size = get_le32(pb);
- get_byte(pb);
- player_version = get_le32(pb);
- get_le16(pb);
- get_byte(pb);
+ version = avio_r8(pb);
+ vst->codec->extradata[0] = avio_r8(pb);
+ vst->codec->extradata[1] = avio_r8(pb);
+ frames_count = avio_rl32(pb);
+ msecs_per_frame = avio_rl32(pb);
+ vst->codec->width = avio_rl16(pb);
+ vst->codec->height = avio_rl16(pb);
+ avio_r8(pb);
+ ast->codec->sample_rate = avio_rl16(pb);
+ mvi->audio_data_size = avio_rl32(pb);
+ avio_r8(pb);
+ player_version = avio_rl32(pb);
+ avio_rl16(pb);
+ avio_r8(pb);
if (frames_count == 0 || mvi->audio_data_size == 0)
return AVERROR_INVALIDDATA;
@@ -87,7 +87,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = CODEC_ID_MOTIONPIXELS;
- mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? get_le16 : get_le24;
+ mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? avio_rl16 : avio_rl24;
mvi->audio_frame_size = ((uint64_t)mvi->audio_data_size << MVI_FRAC_BITS) / frames_count;
mvi->audio_size_counter = (ast->codec->sample_rate * 830 / mvi->audio_frame_size - 1) * mvi->audio_frame_size;
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 6246fca0aa..9f694e30ff 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -163,7 +163,7 @@ static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x
static int64_t klv_decode_ber_length(AVIOContext *pb)
{
- uint64_t size = get_byte(pb);
+ uint64_t size = avio_r8(pb);
if (size & 0x80) { /* long form */
int bytes_num = size & 0x7f;
/* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
@@ -171,7 +171,7 @@ static int64_t klv_decode_ber_length(AVIOContext *pb)
return -1;
size = 0;
while (bytes_num--)
- size = size << 8 | get_byte(pb);
+ size = size << 8 | avio_r8(pb);
}
return size;
}
@@ -180,7 +180,7 @@ static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size)
{
int i, b;
for (i = 0; i < size && !url_feof(pb); i++) {
- b = get_byte(pb);
+ b = avio_r8(pb);
if (b == key[0])
i = 0;
else if (b != key[i])
@@ -195,7 +195,7 @@ static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
return -1;
klv->offset = url_ftell(pb) - 4;
memcpy(klv->key, mxf_klv_key, 4);
- get_buffer(pb, klv->key + 4, 12);
+ avio_read(pb, klv->key + 4, 12);
klv->length = klv_decode_ber_length(pb);
return klv->length == -1 ? -1 : 0;
}
@@ -224,7 +224,7 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt,
if (length > 61444) /* worst case PAL 1920 samples 8 channels */
return -1;
av_new_packet(pkt, length);
- get_buffer(pb, pkt->data, length);
+ avio_read(pb, pkt->data, length);
data_ptr = pkt->data;
end_ptr = pkt->data + length;
buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
@@ -265,10 +265,10 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
url_fskip(pb, klv_decode_ber_length(pb));
// plaintext offset
klv_decode_ber_length(pb);
- plaintext_size = get_be64(pb);
+ plaintext_size = avio_rb64(pb);
// source klv key
klv_decode_ber_length(pb);
- get_buffer(pb, klv->key, 16);
+ avio_read(pb, klv->key, 16);
if (!IS_KLV_KEY(klv, mxf_essence_element_key))
return -1;
index = mxf_get_stream_index(s, klv);
@@ -276,15 +276,15 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
return -1;
// source size
klv_decode_ber_length(pb);
- orig_size = get_be64(pb);
+ orig_size = avio_rb64(pb);
if (orig_size < plaintext_size)
return -1;
// enc. code
size = klv_decode_ber_length(pb);
if (size < 32 || size - 32 < orig_size)
return -1;
- get_buffer(pb, ivec, 16);
- get_buffer(pb, tmpbuf, 16);
+ avio_read(pb, ivec, 16);
+ avio_read(pb, tmpbuf, 16);
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
if (memcmp(tmpbuf, checkv, 16))
@@ -347,8 +347,8 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFContext *mxf = arg;
- int item_num = get_be32(pb);
- int item_len = get_be32(pb);
+ int item_num = avio_rb32(pb);
+ int item_len = avio_rb32(pb);
if (item_len != 18) {
av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n");
@@ -360,7 +360,7 @@ static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, U
mxf->local_tags = av_malloc(item_num*item_len);
if (!mxf->local_tags)
return -1;
- get_buffer(pb, mxf->local_tags, item_num*item_len);
+ avio_read(pb, mxf->local_tags, item_num*item_len);
return 0;
}
@@ -382,7 +382,7 @@ static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, i
if (size != 16)
return -1;
if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul))
- get_buffer(pb, cryptocontext->source_container_ul, 16);
+ avio_read(pb, cryptocontext->source_container_ul, 16);
return 0;
}
@@ -391,14 +391,14 @@ static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int siz
MXFContext *mxf = arg;
switch (tag) {
case 0x1901:
- mxf->packages_count = get_be32(pb);
+ mxf->packages_count = avio_rb32(pb);
if (mxf->packages_count >= UINT_MAX / sizeof(UID))
return -1;
mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID));
if (!mxf->packages_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
break;
}
return 0;
@@ -409,18 +409,18 @@ static int mxf_read_source_clip(void *arg, AVIOContext *pb, int tag, int size, U
MXFStructuralComponent *source_clip = arg;
switch(tag) {
case 0x0202:
- source_clip->duration = get_be64(pb);
+ source_clip->duration = avio_rb64(pb);
break;
case 0x1201:
- source_clip->start_position = get_be64(pb);
+ source_clip->start_position = avio_rb64(pb);
break;
case 0x1101:
/* UMID, only get last 16 bytes */
url_fskip(pb, 16);
- get_buffer(pb, source_clip->source_package_uid, 16);
+ avio_read(pb, source_clip->source_package_uid, 16);
break;
case 0x1102:
- source_clip->source_track_id = get_be32(pb);
+ source_clip->source_track_id = avio_rb32(pb);
break;
}
return 0;
@@ -431,14 +431,14 @@ static int mxf_read_material_package(void *arg, AVIOContext *pb, int tag, int si
MXFPackage *package = arg;
switch(tag) {
case 0x4403:
- package->tracks_count = get_be32(pb);
+ package->tracks_count = avio_rb32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
}
return 0;
@@ -449,17 +449,17 @@ static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid
MXFTrack *track = arg;
switch(tag) {
case 0x4801:
- track->track_id = get_be32(pb);
+ track->track_id = avio_rb32(pb);
break;
case 0x4804:
- get_buffer(pb, track->track_number, 4);
+ avio_read(pb, track->track_number, 4);
break;
case 0x4B01:
- track->edit_rate.den = get_be32(pb);
- track->edit_rate.num = get_be32(pb);
+ track->edit_rate.den = avio_rb32(pb);
+ track->edit_rate.num = avio_rb32(pb);
break;
case 0x4803:
- get_buffer(pb, track->sequence_ref, 16);
+ avio_read(pb, track->sequence_ref, 16);
break;
}
return 0;
@@ -470,20 +470,20 @@ static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID
MXFSequence *sequence = arg;
switch(tag) {
case 0x0202:
- sequence->duration = get_be64(pb);
+ sequence->duration = avio_rb64(pb);
break;
case 0x0201:
- get_buffer(pb, sequence->data_definition_ul, 16);
+ avio_read(pb, sequence->data_definition_ul, 16);
break;
case 0x1001:
- sequence->structural_components_count = get_be32(pb);
+ sequence->structural_components_count = avio_rb32(pb);
if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
return -1;
sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
if (!sequence->structural_components_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
break;
}
return 0;
@@ -494,22 +494,22 @@ static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size
MXFPackage *package = arg;
switch(tag) {
case 0x4403:
- package->tracks_count = get_be32(pb);
+ package->tracks_count = avio_rb32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
case 0x4401:
/* UMID, only get last 16 bytes */
url_fskip(pb, 16);
- get_buffer(pb, package->package_uid, 16);
+ avio_read(pb, package->package_uid, 16);
break;
case 0x4701:
- get_buffer(pb, package->descriptor_ref, 16);
+ avio_read(pb, package->descriptor_ref, 16);
break;
}
return 0;
@@ -518,12 +518,12 @@ static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size
static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
switch(tag) {
- case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break;
- case 0x3F06: av_dlog(NULL, "IndexSID %d\n", get_be32(pb)); break;
- case 0x3F07: av_dlog(NULL, "BodySID %d\n", get_be32(pb)); break;
- case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", get_be32(pb), get_be32(pb)); break;
- case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", get_be64(pb)); break;
- case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", get_be64(pb)); break;
+ case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", avio_rb32(pb)); break;
+ case 0x3F06: av_dlog(NULL, "IndexSID %d\n", avio_rb32(pb)); break;
+ case 0x3F07: av_dlog(NULL, "BodySID %d\n", avio_rb32(pb)); break;
+ case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", avio_rb32(pb), avio_rb32(pb)); break;
+ case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", avio_rb64(pb)); break;
+ case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", avio_rb64(pb)); break;
}
return 0;
}
@@ -534,8 +534,8 @@ static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
char layout[16] = {0};
do {
- code = get_byte(pb);
- value = get_byte(pb);
+ code = avio_r8(pb);
+ value = avio_r8(pb);
av_dlog(NULL, "pixel layout: code %#x\n", code);
if (ofs < 16) {
@@ -552,46 +552,46 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
MXFDescriptor *descriptor = arg;
switch(tag) {
case 0x3F01:
- descriptor->sub_descriptors_count = get_be32(pb);
+ descriptor->sub_descriptors_count = avio_rb32(pb);
if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
return -1;
descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
if (!descriptor->sub_descriptors_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
break;
case 0x3004:
- get_buffer(pb, descriptor->essence_container_ul, 16);
+ avio_read(pb, descriptor->essence_container_ul, 16);
break;
case 0x3006:
- descriptor->linked_track_id = get_be32(pb);
+ descriptor->linked_track_id = avio_rb32(pb);
break;
case 0x3201: /* PictureEssenceCoding */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
+ avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3203:
- descriptor->width = get_be32(pb);
+ descriptor->width = avio_rb32(pb);
break;
case 0x3202:
- descriptor->height = get_be32(pb);
+ descriptor->height = avio_rb32(pb);
break;
case 0x320E:
- descriptor->aspect_ratio.num = get_be32(pb);
- descriptor->aspect_ratio.den = get_be32(pb);
+ descriptor->aspect_ratio.num = avio_rb32(pb);
+ descriptor->aspect_ratio.den = avio_rb32(pb);
break;
case 0x3D03:
- descriptor->sample_rate.num = get_be32(pb);
- descriptor->sample_rate.den = get_be32(pb);
+ descriptor->sample_rate.num = avio_rb32(pb);
+ descriptor->sample_rate.den = avio_rb32(pb);
break;
case 0x3D06: /* SoundEssenceCompression */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
+ avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3D07:
- descriptor->channels = get_be32(pb);
+ descriptor->channels = avio_rb32(pb);
break;
case 0x3D01:
- descriptor->bits_per_sample = get_be32(pb);
+ descriptor->bits_per_sample = avio_rb32(pb);
break;
case 0x3401:
mxf_read_pixel_layout(pb, descriptor);
@@ -603,7 +603,7 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
if (!descriptor->extradata)
return -1;
descriptor->extradata_size = size;
- get_buffer(pb, descriptor->extradata, size);
+ avio_read(pb, descriptor->extradata, size);
}
break;
}
@@ -871,8 +871,8 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF
if (!ctx)
return -1;
while (url_ftell(pb) + 4 < klv_end) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
+ int tag = avio_rb16(pb);
+ int size = avio_rb16(pb); /* KLV specified by 0x53 */
uint64_t next = url_ftell(pb) + size;
UID uid = {0};
@@ -893,7 +893,7 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF
}
}
if (ctx_size && tag == 0x3C0A)
- get_buffer(pb, ctx->uid, 16);
+ avio_read(pb, ctx->uid, 16);
else if (read_child(ctx, pb, tag, size, uid) < 0)
return -1;
diff --git a/libavformat/mxg.c b/libavformat/mxg.c
index 9be97d0d58..81ffec6971 100644
--- a/libavformat/mxg.c
+++ b/libavformat/mxg.c
@@ -115,7 +115,7 @@ static int mxg_update_cache(AVFormatContext *s, unsigned int cache_size)
if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + soi_pos;
/* get data */
- ret = get_buffer(s->pb, mxg->buffer_ptr + mxg->cache_size,
+ ret = avio_read(s->pb, mxg->buffer_ptr + mxg->cache_size,
cache_size - mxg->cache_size);
if (ret < 0)
return ret;
diff --git a/libavformat/ncdec.c b/libavformat/ncdec.c
index 1472d15ca4..9f62f22ffb 100644
--- a/libavformat/ncdec.c
+++ b/libavformat/ncdec.c
@@ -68,11 +68,11 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt)
while (state != NC_VIDEO_FLAG) {
if (url_feof(s->pb))
return AVERROR(EIO);
- state = (state<<8) + get_byte(s->pb);
+ state = (state<<8) + avio_r8(s->pb);
}
- get_byte(s->pb);
- size = get_le16(s->pb);
+ avio_r8(s->pb);
+ size = avio_rl16(s->pb);
url_fskip(s->pb, 9);
if (size == 0) {
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index 53e3186a25..6ac8866144 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -236,7 +236,7 @@ static int nsv_resync(AVFormatContext *s)
return -1;
}
v <<= 8;
- v |= get_byte(pb);
+ v |= avio_r8(pb);
if (i < 8) {
av_dlog(s, "NSV resync: [%d] = %02x\n", i, v & 0x0FF);
}
@@ -277,23 +277,23 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
nsv->state = NSV_UNSYNC; /* in case we fail */
- size = get_le32(pb);
+ size = avio_rl32(pb);
if (size < 28)
return -1;
nsv->NSVf_end = size;
- //s->file_size = (uint32_t)get_le32(pb);
- file_size = (uint32_t)get_le32(pb);
+ //s->file_size = (uint32_t)avio_rl32(pb);
+ file_size = (uint32_t)avio_rl32(pb);
av_dlog(s, "NSV NSVf chunk_size %u\n", size);
av_dlog(s, "NSV NSVf file_size %u\n", file_size);
- nsv->duration = duration = get_le32(pb); /* in ms */
+ nsv->duration = duration = avio_rl32(pb); /* in ms */
av_dlog(s, "NSV NSVf duration %"PRId64" ms\n", duration);
// XXX: store it in AVStreams
- strings_size = get_le32(pb);
- table_entries = get_le32(pb);
- table_entries_used = get_le32(pb);
+ strings_size = avio_rl32(pb);
+ table_entries = avio_rl32(pb);
+ table_entries_used = avio_rl32(pb);
av_dlog(s, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
strings_size, table_entries, table_entries_used);
if (url_feof(pb))
@@ -309,7 +309,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
p = strings = av_mallocz(strings_size + 1);
endp = strings + strings_size;
- get_buffer(pb, strings, strings_size);
+ avio_read(pb, strings, strings_size);
while (p < endp) {
while (*p == ' ')
p++; /* strip out spaces */
@@ -344,13 +344,13 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t));
for(i=0;i<table_entries_used;i++)
- nsv->nsvs_file_offset[i] = get_le32(pb) + size;
+ nsv->nsvs_file_offset[i] = avio_rl32(pb) + size;
if(table_entries > table_entries_used &&
- get_le32(pb) == MKTAG('T','O','C','2')) {
+ avio_rl32(pb) == MKTAG('T','O','C','2')) {
nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t));
for(i=0;i<table_entries_used;i++) {
- nsv->nsvs_timestamps[i] = get_le32(pb);
+ nsv->nsvs_timestamps[i] = avio_rl32(pb);
}
}
}
@@ -365,7 +365,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
for (i = 0; i < table_entries; i++) {
unsigned char b[8];
url_fseek(pb, size + nsv->nsvs_file_offset[i], SEEK_SET);
- get_buffer(pb, b, 8);
+ avio_read(pb, b, 8);
av_dlog(s, "NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x"
"%c%c%c%c%c%c%c%c\n",
nsv->nsvs_file_offset[i], size + nsv->nsvs_file_offset[i],
@@ -396,11 +396,11 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
NSVStream *nst;
av_dlog(s, "%s()\n", __FUNCTION__);
- vtag = get_le32(pb);
- atag = get_le32(pb);
- vwidth = get_le16(pb);
- vheight = get_le16(pb);
- i = get_byte(pb);
+ vtag = avio_rl32(pb);
+ atag = avio_rl32(pb);
+ vwidth = avio_rl16(pb);
+ vheight = avio_rl16(pb);
+ i = avio_r8(pb);
av_dlog(s, "NSV NSVs framerate code %2x\n", i);
if(i&0x80) { /* odd way of giving native framerates from docs */
@@ -420,7 +420,7 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
else
framerate= (AVRational){i, 1};
- nsv->avsync = get_le16(pb);
+ nsv->avsync = avio_rl16(pb);
nsv->framerate = framerate;
print_tag("NSV NSVs vtag", vtag, 0);
@@ -568,16 +568,16 @@ null_chunk_retry:
if (nsv->state != NSV_HAS_READ_NSVS && nsv->state != NSV_FOUND_BEEF)
return -1;
- auxcount = get_byte(pb);
- vsize = get_le16(pb);
- asize = get_le16(pb);
+ auxcount = avio_r8(pb);
+ vsize = avio_rl16(pb);
+ asize = avio_rl16(pb);
vsize = (vsize << 4) | (auxcount >> 4);
auxcount &= 0x0f;
av_dlog(s, "NSV CHUNK %d aux, %u bytes video, %d bytes audio\n", auxcount, vsize, asize);
/* skip aux stuff */
for (i = 0; i < auxcount; i++) {
- auxsize = get_le16(pb);
- auxtag = get_le32(pb);
+ auxsize = avio_rl16(pb);
+ auxtag = avio_rl32(pb);
av_dlog(s, "NSV aux data: '%c%c%c%c', %d bytes\n",
(auxtag & 0x0ff),
((auxtag >> 8) & 0x0ff),
@@ -623,9 +623,9 @@ null_chunk_retry:
uint8_t bps;
uint8_t channels;
uint16_t samplerate;
- bps = get_byte(pb);
- channels = get_byte(pb);
- samplerate = get_le16(pb);
+ bps = avio_r8(pb);
+ channels = avio_r8(pb);
+ samplerate = avio_rl16(pb);
asize-=4;
av_dlog(s, "NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
if (fill_header) {
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 86ad9af9f9..a2e6ec17f1 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -39,9 +39,9 @@ static int get_str(AVIOContext *bc, char *string, unsigned int maxlen){
unsigned int len= ff_get_v(bc);
if(len && maxlen)
- get_buffer(bc, string, FFMIN(len, maxlen));
+ avio_read(bc, string, FFMIN(len, maxlen));
while(len > maxlen){
- get_byte(bc);
+ avio_r8(bc);
len--;
}
@@ -64,8 +64,8 @@ static int64_t get_s(AVIOContext *bc){
static uint64_t get_fourcc(AVIOContext *bc){
unsigned int len= ff_get_v(bc);
- if (len==2) return get_le16(bc);
- else if(len==4) return get_le32(bc);
+ if (len==2) return avio_rl16(bc);
+ else if(len==4) return avio_rl32(bc);
else return -1;
}
@@ -106,7 +106,7 @@ static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_chec
init_checksum(bc, ff_crc04C11DB7_update, startcode);
size= ff_get_v(bc);
if(size > 4096)
- get_be32(bc);
+ avio_rb32(bc);
if(get_checksum(bc) && size > 4096)
return -1;
@@ -122,7 +122,7 @@ static uint64_t find_any_startcode(AVIOContext *bc, int64_t pos){
url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we currently are
while(!url_feof(bc)){
- state= (state<<8) | get_byte(bc);
+ state= (state<<8) | avio_r8(bc);
if((state>>56) != 'N')
continue;
switch(state){
@@ -182,7 +182,7 @@ static int skip_reserved(AVIOContext *bc, int64_t pos){
return -1;
}else{
while(pos--)
- get_byte(bc);
+ avio_r8(bc);
return 0;
}
}
@@ -279,7 +279,7 @@ static int decode_main_header(NUTContext *nut){
return AVERROR_INVALIDDATA;
}
nut->header[i]= av_malloc(nut->header_len[i]);
- get_buffer(bc, nut->header[i], nut->header_len[i]);
+ avio_read(bc, nut->header[i], nut->header_len[i]);
}
assert(nut->header_len[0]==0);
}
@@ -355,7 +355,7 @@ static int decode_stream_header(NUTContext *nut){
GET_V(st->codec->extradata_size, tmp < (1<<30));
if(st->codec->extradata_size){
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(bc, st->codec->extradata, st->codec->extradata_size);
+ avio_read(bc, st->codec->extradata, st->codec->extradata_size);
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
@@ -514,8 +514,8 @@ static int find_and_decode_index(NUTContext *nut){
int ret= -1;
url_fseek(bc, filesize-12, SEEK_SET);
- url_fseek(bc, filesize-get_be64(bc), SEEK_SET);
- if(get_be64(bc) != INDEX_STARTCODE){
+ url_fseek(bc, filesize-avio_rb64(bc), SEEK_SET);
+ if(avio_rb64(bc) != INDEX_STARTCODE){
av_log(s, AV_LOG_ERROR, "no index at the end\n");
return -1;
}
@@ -722,7 +722,7 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, ui
size -= nut->header_len[*header_idx];
if(flags&FLAG_CHECKSUM){
- get_be32(bc); //FIXME check this
+ avio_rb32(bc); //FIXME check this
}else if(size > 2*nut->max_distance || FFABS(stc->last_pts - *pts) > stc->max_pts_distance){
av_log(s, AV_LOG_ERROR, "frame size > 2max_distance and no checksum\n");
return AVERROR_INVALIDDATA;
@@ -764,7 +764,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
av_new_packet(pkt, size + nut->header_len[header_idx]);
memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
pkt->pos= url_ftell(bc); //FIXME
- get_buffer(bc, pkt->data + nut->header_len[header_idx], size);
+ avio_read(bc, pkt->data + nut->header_len[header_idx], size);
pkt->stream_index = stream_id;
if (stc->last_flags & FLAG_KEY)
@@ -789,13 +789,13 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
if(tmp){
pos-=8;
}else{
- frame_code = get_byte(bc);
+ frame_code = avio_r8(bc);
if(url_feof(bc))
return -1;
if(frame_code == 'N'){
tmp= frame_code;
for(i=1; i<8; i++)
- tmp = (tmp<<8) + get_byte(bc);
+ tmp = (tmp<<8) + avio_r8(bc);
}
}
switch(tmp){
@@ -812,7 +812,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
case SYNCPOINT_STARTCODE:
if(decode_syncpoint(nut, &ts, &back_ptr)<0)
goto resync;
- frame_code = get_byte(bc);
+ frame_code = avio_r8(bc);
case 0:
ret= decode_frame(nut, pkt, frame_code);
if(ret==0)
diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index 055a6dce60..e360a64cfb 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -62,16 +62,16 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
return 1; // no codec data needed
while (!url_feof(pb)) {
int size, subtype;
- frametype = get_byte(pb);
+ frametype = avio_r8(pb);
switch (frametype) {
case NUV_EXTRADATA:
- subtype = get_byte(pb);
+ subtype = avio_r8(pb);
url_fskip(pb, 6);
- size = PKTSIZE(get_le32(pb));
+ size = PKTSIZE(avio_rl32(pb));
if (vst && subtype == 'R') {
vst->codec->extradata_size = size;
vst->codec->extradata = av_malloc(size);
- get_buffer(pb, vst->codec->extradata, size);
+ avio_read(pb, vst->codec->extradata, size);
size = 0;
if (!myth)
return 1;
@@ -79,12 +79,12 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
break;
case NUV_MYTHEXT:
url_fskip(pb, 7);
- size = PKTSIZE(get_le32(pb));
+ size = PKTSIZE(avio_rl32(pb));
if (size != 128 * 4)
break;
- get_le32(pb); // version
+ avio_rl32(pb); // version
if (vst) {
- vst->codec->codec_tag = get_le32(pb);
+ vst->codec->codec_tag = avio_rl32(pb);
vst->codec->codec_id =
ff_codec_get_id(ff_codec_bmp_tags, vst->codec->codec_tag);
if (vst->codec->codec_tag == MKTAG('R', 'J', 'P', 'G'))
@@ -93,10 +93,10 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
url_fskip(pb, 4);
if (ast) {
- ast->codec->codec_tag = get_le32(pb);
- ast->codec->sample_rate = get_le32(pb);
- ast->codec->bits_per_coded_sample = get_le32(pb);
- ast->codec->channels = get_le32(pb);
+ ast->codec->codec_tag = avio_rl32(pb);
+ ast->codec->sample_rate = avio_rl32(pb);
+ ast->codec->bits_per_coded_sample = avio_rl32(pb);
+ ast->codec->channels = avio_rl32(pb);
ast->codec->codec_id =
ff_wav_codec_get_id(ast->codec->codec_tag,
ast->codec->bits_per_coded_sample);
@@ -112,7 +112,7 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
break;
default:
url_fskip(pb, 7);
- size = PKTSIZE(get_le32(pb));
+ size = PKTSIZE(avio_rl32(pb));
break;
}
url_fskip(pb, size);
@@ -128,27 +128,27 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
int is_mythtv, width, height, v_packs, a_packs;
int stream_nr = 0;
AVStream *vst = NULL, *ast = NULL;
- get_buffer(pb, id_string, 12);
+ avio_read(pb, id_string, 12);
is_mythtv = !memcmp(id_string, "MythTVVideo", 12);
url_fskip(pb, 5); // version string
url_fskip(pb, 3); // padding
- width = get_le32(pb);
- height = get_le32(pb);
- get_le32(pb); // unused, "desiredwidth"
- get_le32(pb); // unused, "desiredheight"
- get_byte(pb); // 'P' == progressive, 'I' == interlaced
+ width = avio_rl32(pb);
+ height = avio_rl32(pb);
+ avio_rl32(pb); // unused, "desiredwidth"
+ avio_rl32(pb); // unused, "desiredheight"
+ avio_r8(pb); // 'P' == progressive, 'I' == interlaced
url_fskip(pb, 3); // padding
- aspect = av_int2dbl(get_le64(pb));
+ aspect = av_int2dbl(avio_rl64(pb));
if (aspect > 0.9999 && aspect < 1.0001)
aspect = 4.0 / 3.0;
- fps = av_int2dbl(get_le64(pb));
+ fps = av_int2dbl(avio_rl64(pb));
// number of packets per stream type, -1 means unknown, e.g. streaming
- v_packs = get_le32(pb);
- a_packs = get_le32(pb);
- get_le32(pb); // text
+ v_packs = avio_rl32(pb);
+ a_packs = avio_rl32(pb);
+ avio_rl32(pb); // text
- get_le32(pb); // keyframe distance (?)
+ avio_rl32(pb); // keyframe distance (?)
if (v_packs) {
ctx->v_id = stream_nr++;
@@ -198,7 +198,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
while (!url_feof(pb)) {
int copyhdrsize = ctx->rtjpg_video ? HDRSIZE : 0;
uint64_t pos = url_ftell(pb);
- ret = get_buffer(pb, hdr, HDRSIZE);
+ ret = avio_read(pb, hdr, HDRSIZE);
if (ret < HDRSIZE)
return ret < 0 ? ret : AVERROR(EIO);
frametype = hdr[0];
@@ -225,7 +225,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
pkt->pts = AV_RL32(&hdr[4]);
pkt->stream_index = ctx->v_id;
memcpy(pkt->data, hdr, copyhdrsize);
- ret = get_buffer(pb, pkt->data + copyhdrsize, size);
+ ret = avio_read(pb, pkt->data + copyhdrsize, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index d508fe32d2..a79cd3ef9d 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -207,7 +207,7 @@ ogg_read_page (AVFormatContext * s, int *str)
uint8_t sync[4];
int sp = 0;
- if (get_buffer (bc, sync, 4) < 4)
+ if (avio_read (bc, sync, 4) < 4)
return -1;
do{
@@ -233,10 +233,10 @@ ogg_read_page (AVFormatContext * s, int *str)
return -1;
flags = url_fgetc (bc);
- gp = get_le64 (bc);
- serial = get_le32 (bc);
- seq = get_le32 (bc);
- crc = get_le32 (bc);
+ gp = avio_rl64 (bc);
+ serial = avio_rl32 (bc);
+ seq = avio_rl32 (bc);
+ crc = avio_rl32 (bc);
nsegs = url_fgetc (bc);
idx = ogg_find_stream (ogg, serial);
@@ -252,7 +252,7 @@ ogg_read_page (AVFormatContext * s, int *str)
if(os->psize > 0)
ogg_new_buf(ogg, idx);
- if (get_buffer (bc, os->segments, nsegs) < nsegs)
+ if (avio_read (bc, os->segments, nsegs) < nsegs)
return -1;
os->nsegs = nsegs;
@@ -284,7 +284,7 @@ ogg_read_page (AVFormatContext * s, int *str)
os->buf = nb;
}
- if (get_buffer (bc, os->buf + os->bufpos, size) < size)
+ if (avio_read (bc, os->buf + os->bufpos, size) < size)
return -1;
os->bufpos += size;
diff --git a/libavformat/oma.c b/libavformat/oma.c
index 158ed117c3..03dc1e9d8b 100644
--- a/libavformat/oma.c
+++ b/libavformat/oma.c
@@ -79,7 +79,7 @@ static int oma_read_header(AVFormatContext *s,
AVStream *st;
ff_id3v2_read(s, ID3v2_EA3_MAGIC);
- ret = get_buffer(s->pb, buf, EA3_HEADER_SIZE);
+ ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}),3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n");
diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c
index bffb72c4d4..69013c5f58 100644
--- a/libavformat/psxstr.c
+++ b/libavformat/psxstr.c
@@ -105,7 +105,7 @@ static int str_read_header(AVFormatContext *s,
int i;
/* skip over any RIFF header */
- if (get_buffer(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
+ if (avio_read(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
return AVERROR(EIO);
if (AV_RL32(&sector[0]) == RIFF_TAG)
start = RIFF_HEADER_SIZE;
@@ -136,7 +136,7 @@ static int str_read_packet(AVFormatContext *s,
while (1) {
- if (get_buffer(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE)
+ if (avio_read(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE)
return AVERROR(EIO);
channel = sector[0x11];
diff --git a/libavformat/pva.c b/libavformat/pva.c
index 9b370cea4d..ea7db47c76 100644
--- a/libavformat/pva.c
+++ b/libavformat/pva.c
@@ -75,12 +75,12 @@ static int read_part_of_packet(AVFormatContext *s, int64_t *pts,
recover:
startpos = url_ftell(pb);
- syncword = get_be16(pb);
- streamid = get_byte(pb);
- get_byte(pb); /* counter not used */
- reserved = get_byte(pb);
- flags = get_byte(pb);
- length = get_be16(pb);
+ syncword = avio_rb16(pb);
+ streamid = avio_r8(pb);
+ avio_r8(pb); /* counter not used */
+ reserved = avio_r8(pb);
+ flags = avio_r8(pb);
+ length = avio_rb16(pb);
pts_flag = flags & 0x10;
@@ -101,7 +101,7 @@ recover:
}
if (streamid == PVA_VIDEO_PAYLOAD && pts_flag) {
- pva_pts = get_be32(pb);
+ pva_pts = avio_rb32(pb);
length -= 4;
} else if (streamid == PVA_AUDIO_PAYLOAD) {
/* PVA Audio Packets either start with a signaled PES packet or
@@ -113,11 +113,11 @@ recover:
pes_flags;
unsigned char pes_header_data[256];
- pes_signal = get_be24(pb);
- get_byte(pb);
- pes_packet_length = get_be16(pb);
- pes_flags = get_be16(pb);
- pes_header_data_length = get_byte(pb);
+ pes_signal = avio_rb24(pb);
+ avio_r8(pb);
+ pes_packet_length = avio_rb16(pb);
+ pes_flags = avio_rb16(pb);
+ pes_header_data_length = avio_r8(pb);
if (pes_signal != 1) {
pva_log(s, AV_LOG_WARNING, "expected signaled PES packet, "
@@ -128,7 +128,7 @@ recover:
goto recover;
}
- get_buffer(pb, pes_header_data, pes_header_data_length);
+ avio_read(pb, pes_header_data, pes_header_data_length);
length -= 9 + pes_header_data_length;
pes_packet_length -= 3 + pes_header_data_length;
diff --git a/libavformat/qcp.c b/libavformat/qcp.c
index 48b5d64c2d..2c1fa3c635 100644
--- a/libavformat/qcp.c
+++ b/libavformat/qcp.c
@@ -91,13 +91,13 @@ static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!st)
return AVERROR(ENOMEM);
- get_be32(pb); // "RIFF"
- s->file_size = get_le32(pb) + 8;
+ avio_rb32(pb); // "RIFF"
+ s->file_size = avio_rl32(pb) + 8;
url_fskip(pb, 8 + 4 + 1 + 1); // "QLCMfmt " + chunk-size + major-version + minor-version
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channels = 1;
- get_buffer(pb, buf, 16);
+ avio_read(pb, buf, 16);
if (is_qcelp_13k_guid(buf)) {
st->codec->codec_id = CODEC_ID_QCELP;
} else if (!memcmp(buf, guid_evrc, 16)) {
@@ -111,19 +111,19 @@ static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR_INVALIDDATA;
}
url_fskip(pb, 2 + 80); // codec-version + codec-name
- st->codec->bit_rate = get_le16(pb);
+ st->codec->bit_rate = avio_rl16(pb);
- s->packet_size = get_le16(pb);
+ s->packet_size = avio_rl16(pb);
url_fskip(pb, 2); // block-size
- st->codec->sample_rate = get_le16(pb);
+ st->codec->sample_rate = avio_rl16(pb);
url_fskip(pb, 2); // sample-size
memset(c->rates_per_mode, -1, sizeof(c->rates_per_mode));
- nb_rates = get_le32(pb);
+ nb_rates = avio_rl32(pb);
nb_rates = FFMIN(nb_rates, 8);
for (i=0; i<nb_rates; i++) {
- int size = get_byte(pb);
- int mode = get_byte(pb);
+ int size = avio_r8(pb);
+ int mode = avio_r8(pb);
if (mode > QCP_MAX_MODE) {
av_log(s, AV_LOG_WARNING, "Unknown entry %d=>%d in rate-map-table.\n ", mode, size);
} else
@@ -142,7 +142,7 @@ static int qcp_read_packet(AVFormatContext *s, AVPacket *pkt)
while(!url_feof(pb)) {
if (c->data_size) {
- int pkt_size, ret, mode = get_byte(pb);
+ int pkt_size, ret, mode = avio_r8(pb);
if (s->packet_size) {
pkt_size = s->packet_size - 1;
@@ -165,14 +165,14 @@ static int qcp_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret;
}
- if (url_ftell(pb) & 1 && get_byte(pb))
+ if (url_ftell(pb) & 1 && avio_r8(pb))
av_log(s, AV_LOG_WARNING, "Padding should be 0.\n");
- tag = get_le32(pb);
- chunk_size = get_le32(pb);
+ tag = avio_rl32(pb);
+ chunk_size = avio_rl32(pb);
switch (tag) {
case MKTAG('v', 'r', 'a', 't'):
- if (get_le32(pb)) // var-rate-flag
+ if (avio_rl32(pb)) // var-rate-flag
s->packet_size = 0;
url_fskip(pb, 4); // size-in-packets
break;
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 9c9fa1bbcb..bb39e03e50 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -39,10 +39,10 @@ typedef struct {
static int read_atom(AVFormatContext *s, Atom *atom)
{
atom->offset = url_ftell(s->pb);
- atom->size = get_be32(s->pb);
+ atom->size = avio_rb32(s->pb);
if (atom->size < 8)
return -1;
- atom->tag = get_le32(s->pb);
+ atom->tag = avio_rl32(s->pb);
av_dlog(s, "atom %d %.4s offset %#llx\n",
atom->size, (char*)&atom->tag, atom->offset);
return atom->size;
@@ -59,31 +59,31 @@ static int r3d_read_red1(AVFormatContext *s)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_JPEG2000;
- tmp = get_byte(s->pb); // major version
- tmp2 = get_byte(s->pb); // minor version
+ tmp = avio_r8(s->pb); // major version
+ tmp2 = avio_r8(s->pb); // minor version
av_dlog(s, "version %d.%d\n", tmp, tmp2);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown1 %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_set_pts_info(st, 32, 1, tmp);
- tmp = get_be32(s->pb); // filenum
+ tmp = avio_rb32(s->pb); // filenum
av_dlog(s, "filenum %d\n", tmp);
url_fskip(s->pb, 32); // unknown
- st->codec->width = get_be32(s->pb);
- st->codec->height = get_be32(s->pb);
+ st->codec->width = avio_rb32(s->pb);
+ st->codec->height = avio_rb32(s->pb);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown2 %d\n", tmp);
- st->codec->time_base.den = get_be16(s->pb);
- st->codec->time_base.num = get_be16(s->pb);
+ st->codec->time_base.den = avio_rb16(s->pb);
+ st->codec->time_base.num = avio_rb16(s->pb);
- tmp = get_byte(s->pb); // audio channels
+ tmp = avio_r8(s->pb); // audio channels
av_dlog(s, "audio channels %d\n", tmp);
if (tmp > 0) {
AVStream *ast = av_new_stream(s, 1);
@@ -95,7 +95,7 @@ static int r3d_read_red1(AVFormatContext *s)
av_set_pts_info(ast, 32, 1, st->time_base.den);
}
- get_buffer(s->pb, filename, 257);
+ avio_read(s->pb, filename, 257);
filename[sizeof(filename)-1] = 0;
av_metadata_set2(&st->metadata, "filename", filename, 0);
@@ -120,7 +120,7 @@ static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
return AVERROR(ENOMEM);
for (i = 0; i < r3d->video_offsets_count; i++) {
- r3d->video_offsets[i] = get_be32(s->pb);
+ r3d->video_offsets[i] = avio_rb32(s->pb);
if (!r3d->video_offsets[i]) {
r3d->video_offsets_count = i;
break;
@@ -141,15 +141,15 @@ static void r3d_read_reos(AVFormatContext *s)
R3DContext *r3d = s->priv_data;
int tmp;
- r3d->rdvo_offset = get_be32(s->pb);
- get_be32(s->pb); // rdvs offset
- get_be32(s->pb); // rdao offset
- get_be32(s->pb); // rdas offset
+ r3d->rdvo_offset = avio_rb32(s->pb);
+ avio_rb32(s->pb); // rdvs offset
+ avio_rb32(s->pb); // rdao offset
+ avio_rb32(s->pb); // rdas offset
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "num video chunks %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "num audio chunks %d\n", tmp);
url_fskip(s->pb, 6*4);
@@ -214,31 +214,31 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
unsigned dts;
int ret;
- dts = get_be32(s->pb);
+ dts = avio_rb32(s->pb);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "frame num %d\n", tmp);
- tmp = get_byte(s->pb); // major version
- tmp2 = get_byte(s->pb); // minor version
+ tmp = avio_r8(s->pb); // major version
+ tmp2 = avio_r8(s->pb); // minor version
av_dlog(s, "version %d.%d\n", tmp, tmp2);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
if (tmp > 4) {
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
- tmp = get_be16(s->pb); // unknown
+ tmp = avio_rb16(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "width %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "height %d\n", tmp);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "metadata len %d\n", tmp);
}
tmp = atom->size - 8 - (url_ftell(s->pb) - pos);
@@ -268,23 +268,23 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
unsigned dts;
int ret;
- dts = get_be32(s->pb);
+ dts = avio_rb32(s->pb);
- st->codec->sample_rate = get_be32(s->pb);
+ st->codec->sample_rate = avio_rb32(s->pb);
- samples = get_be32(s->pb);
+ samples = avio_rb32(s->pb);
- tmp = get_be32(s->pb);
+ tmp = avio_rb32(s->pb);
av_dlog(s, "packet num %d\n", tmp);
- tmp = get_be16(s->pb); // unkown
+ tmp = avio_rb16(s->pb); // unkown
av_dlog(s, "unknown %d\n", tmp);
- tmp = get_byte(s->pb); // major version
- tmp2 = get_byte(s->pb); // minor version
+ tmp = avio_r8(s->pb); // major version
+ tmp2 = avio_r8(s->pb); // minor version
av_dlog(s, "version %d.%d\n", tmp, tmp2);
- tmp = get_be32(s->pb); // unknown
+ tmp = avio_rb32(s->pb); // unknown
av_dlog(s, "unknown %d\n", tmp);
size = atom->size - 8 - (url_ftell(s->pb) - pos);
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index d846533724..ad84a6cbe5 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -153,25 +153,25 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
return -1;
ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
NULL, NULL, NULL, NULL);
- tag = get_le32(&pb);
+ tag = avio_rl32(&pb);
if (tag == MKTAG('M', 'L', 'T', 'I')) {
int num, chunk_nr;
/* read index of MDPR chunk numbers */
- num = get_be16(&pb);
+ num = avio_rb16(&pb);
if (rule_nr < 0 || rule_nr >= num)
return -1;
url_fskip(&pb, rule_nr * 2);
- chunk_nr = get_be16(&pb);
+ chunk_nr = avio_rb16(&pb);
url_fskip(&pb, (num - 1 - rule_nr) * 2);
/* read MDPR chunks */
- num = get_be16(&pb);
+ num = avio_rb16(&pb);
if (chunk_nr >= num)
return -1;
while (chunk_nr--)
- url_fskip(&pb, get_be32(&pb));
- size = get_be32(&pb);
+ url_fskip(&pb, avio_rb32(&pb));
+ size = avio_rb32(&pb);
} else {
size = rdt->mlti_data_size;
url_fseek(&pb, 0, SEEK_SET);
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 9f7d949dce..7111487f8c 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -481,25 +481,25 @@ void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
{
int id;
- id = get_le16(pb);
+ id = avio_rl16(pb);
codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->codec_tag = id;
- codec->channels = get_le16(pb);
- codec->sample_rate = get_le32(pb);
- codec->bit_rate = get_le32(pb) * 8;
- codec->block_align = get_le16(pb);
+ codec->channels = avio_rl16(pb);
+ codec->sample_rate = avio_rl32(pb);
+ codec->bit_rate = avio_rl32(pb) * 8;
+ codec->block_align = avio_rl16(pb);
if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */
codec->bits_per_coded_sample = 8;
}else
- codec->bits_per_coded_sample = get_le16(pb);
+ codec->bits_per_coded_sample = avio_rl16(pb);
if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */
- int cbSize = get_le16(pb); /* cbSize */
+ int cbSize = avio_rl16(pb); /* cbSize */
size -= 18;
cbSize = FFMIN(size, cbSize);
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
- codec->bits_per_coded_sample = get_le16(pb);
- codec->channel_layout = get_le32(pb); /* dwChannelMask */
- id = get_le32(pb); /* 4 first bytes of GUID */
+ codec->bits_per_coded_sample = avio_rl16(pb);
+ codec->channel_layout = avio_rl32(pb); /* dwChannelMask */
+ id = avio_rl32(pb); /* 4 first bytes of GUID */
url_fskip(pb, 12); /* skip end of GUID */
cbSize -= 22;
size -= 22;
@@ -507,7 +507,7 @@ void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
codec->extradata_size = cbSize;
if (cbSize > 0) {
codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_read(pb, codec->extradata, codec->extradata_size);
size -= cbSize;
}
@@ -547,17 +547,17 @@ enum CodecID ff_wav_codec_get_id(unsigned int tag, int bps)
int ff_get_bmp_header(AVIOContext *pb, AVStream *st)
{
int tag1;
- get_le32(pb); /* size */
- st->codec->width = get_le32(pb);
- st->codec->height = (int32_t)get_le32(pb);
- get_le16(pb); /* planes */
- st->codec->bits_per_coded_sample= get_le16(pb); /* depth */
- tag1 = get_le32(pb);
- get_le32(pb); /* ImageSize */
- get_le32(pb); /* XPelsPerMeter */
- get_le32(pb); /* YPelsPerMeter */
- get_le32(pb); /* ClrUsed */
- get_le32(pb); /* ClrImportant */
+ avio_rl32(pb); /* size */
+ st->codec->width = avio_rl32(pb);
+ st->codec->height = (int32_t)avio_rl32(pb);
+ avio_rl16(pb); /* planes */
+ st->codec->bits_per_coded_sample= avio_rl16(pb); /* depth */
+ tag1 = avio_rl32(pb);
+ avio_rl32(pb); /* ImageSize */
+ avio_rl32(pb); /* XPelsPerMeter */
+ avio_rl32(pb); /* YPelsPerMeter */
+ avio_rl32(pb); /* ClrUsed */
+ avio_rl32(pb); /* ClrImportant */
return tag1;
}
#endif // CONFIG_DEMUXERS
diff --git a/libavformat/rl2.c b/libavformat/rl2.c
index d655d3e9f5..16e029f679 100644
--- a/libavformat/rl2.c
+++ b/libavformat/rl2.c
@@ -96,20 +96,20 @@ static av_cold int rl2_read_header(AVFormatContext *s,
int ret = 0;
url_fskip(pb,4); /* skip FORM tag */
- back_size = get_le32(pb); /**< get size of the background frame */
- signature = get_be32(pb);
- data_size = get_be32(pb);
- frame_count = get_le32(pb);
+ back_size = avio_rl32(pb); /**< get size of the background frame */
+ signature = avio_rb32(pb);
+ data_size = avio_rb32(pb);
+ frame_count = avio_rl32(pb);
/* disallow back_sizes and frame_counts that may lead to overflows later */
if(back_size > INT_MAX/2 || frame_count > INT_MAX / sizeof(uint32_t))
return AVERROR_INVALIDDATA;
- encoding_method = get_le16(pb);
- sound_rate = get_le16(pb);
- rate = get_le16(pb);
- channels = get_le16(pb);
- def_sound_size = get_le16(pb);
+ encoding_method = avio_rl16(pb);
+ sound_rate = avio_rl16(pb);
+ rate = avio_rl16(pb);
+ channels = avio_rl16(pb);
+ def_sound_size = avio_rl16(pb);
/** setup video stream */
st = av_new_stream(s, 0);
@@ -133,7 +133,7 @@ static av_cold int rl2_read_header(AVFormatContext *s,
if(!st->codec->extradata)
return AVERROR(ENOMEM);
- if(get_buffer(pb,st->codec->extradata,st->codec->extradata_size) !=
+ if(avio_read(pb,st->codec->extradata,st->codec->extradata_size) !=
st->codec->extradata_size)
return AVERROR(EIO);
@@ -173,11 +173,11 @@ static av_cold int rl2_read_header(AVFormatContext *s,
/** read offset and size tables */
for(i=0; i < frame_count;i++)
- chunk_size[i] = get_le32(pb);
+ chunk_size[i] = avio_rl32(pb);
for(i=0; i < frame_count;i++)
- chunk_offset[i] = get_le32(pb);
+ chunk_offset[i] = avio_rl32(pb);
for(i=0; i < frame_count;i++)
- audio_size[i] = get_le32(pb) & 0xFFFF;
+ audio_size[i] = avio_rl32(pb) & 0xFFFF;
/** build the sample index */
for(i=0;i<frame_count;i++){
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 7f94442aa7..c34d128e40 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -71,7 +71,7 @@ static inline void get_strl(AVIOContext *pb, char *buf, int buf_size, int len)
q = buf;
for(i=0;i<len;i++) {
- r = get_byte(pb);
+ r = avio_r8(pb);
if (i < buf_size - 1)
*q++ = r;
}
@@ -80,7 +80,7 @@ static inline void get_strl(AVIOContext *pb, char *buf, int buf_size, int len)
static void get_str8(AVIOContext *pb, char *buf, int buf_size)
{
- get_strl(pb, buf, buf_size, get_byte(pb));
+ get_strl(pb, buf, buf_size, avio_r8(pb));
}
static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size)
@@ -90,7 +90,7 @@ static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned si
avctx->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
return AVERROR(ENOMEM);
- avctx->extradata_size = get_buffer(pb, avctx->extradata, size);
+ avctx->extradata_size = avio_read(pb, avctx->extradata, size);
memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
if (avctx->extradata_size != size)
return AVERROR(EIO);
@@ -102,7 +102,7 @@ static void rm_read_metadata(AVFormatContext *s, int wide)
char buf[1024];
int i;
for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
- int len = wide ? get_be16(s->pb) : get_byte(s->pb);
+ int len = wide ? avio_rb16(s->pb) : avio_r8(s->pb);
get_strl(s->pb, buf, sizeof(buf), len);
av_metadata_set2(&s->metadata, ff_rm_metadata[i], buf, 0);
}
@@ -128,15 +128,15 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
int ret;
/* ra type header */
- version = get_be16(pb); /* version */
+ version = avio_rb16(pb); /* version */
if (version == 3) {
- int header_size = get_be16(pb);
+ int header_size = avio_rb16(pb);
int64_t startpos = url_ftell(pb);
url_fskip(pb, 14);
rm_read_metadata(s, 0);
if ((startpos + header_size) >= url_ftell(pb) + 2) {
// fourcc (should always be "lpcJ")
- get_byte(pb);
+ avio_r8(pb);
get_str8(pb, buf, sizeof(buf));
}
// Skip extra header crap (this should never happen)
@@ -151,28 +151,28 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
int codecdata_length;
/* old version (4) */
url_fskip(pb, 2); /* unused */
- get_be32(pb); /* .ra4 */
- get_be32(pb); /* data size */
- get_be16(pb); /* version2 */
- get_be32(pb); /* header size */
- flavor= get_be16(pb); /* add codec info / flavor */
- ast->coded_framesize = coded_framesize = get_be32(pb); /* coded frame size */
- get_be32(pb); /* ??? */
- get_be32(pb); /* ??? */
- get_be32(pb); /* ??? */
- ast->sub_packet_h = sub_packet_h = get_be16(pb); /* 1 */
- st->codec->block_align= get_be16(pb); /* frame size */
- ast->sub_packet_size = sub_packet_size = get_be16(pb); /* sub packet size */
- get_be16(pb); /* ??? */
+ avio_rb32(pb); /* .ra4 */
+ avio_rb32(pb); /* data size */
+ avio_rb16(pb); /* version2 */
+ avio_rb32(pb); /* header size */
+ flavor= avio_rb16(pb); /* add codec info / flavor */
+ ast->coded_framesize = coded_framesize = avio_rb32(pb); /* coded frame size */
+ avio_rb32(pb); /* ??? */
+ avio_rb32(pb); /* ??? */
+ avio_rb32(pb); /* ??? */
+ ast->sub_packet_h = sub_packet_h = avio_rb16(pb); /* 1 */
+ st->codec->block_align= avio_rb16(pb); /* frame size */
+ ast->sub_packet_size = sub_packet_size = avio_rb16(pb); /* sub packet size */
+ avio_rb16(pb); /* ??? */
if (version == 5) {
- get_be16(pb); get_be16(pb); get_be16(pb);
+ avio_rb16(pb); avio_rb16(pb); avio_rb16(pb);
}
- st->codec->sample_rate = get_be16(pb);
- get_be32(pb);
- st->codec->channels = get_be16(pb);
+ st->codec->sample_rate = avio_rb16(pb);
+ avio_rb32(pb);
+ st->codec->channels = avio_rb16(pb);
if (version == 5) {
- get_be32(pb);
- get_buffer(pb, buf, 4);
+ avio_rb32(pb);
+ avio_read(pb, buf, 4);
buf[4] = 0;
} else {
get_str8(pb, buf, sizeof(buf)); /* desc */
@@ -201,10 +201,10 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
case CODEC_ID_COOK:
case CODEC_ID_ATRAC3:
case CODEC_ID_SIPR:
- get_be16(pb); get_byte(pb);
+ avio_rb16(pb); avio_r8(pb);
if (version == 5)
- get_byte(pb);
- codecdata_length = get_be32(pb);
+ avio_r8(pb);
+ codecdata_length = avio_rb32(pb);
if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
return -1;
@@ -236,16 +236,16 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h);
break;
case CODEC_ID_AAC:
- get_be16(pb); get_byte(pb);
+ avio_rb16(pb); avio_r8(pb);
if (version == 5)
- get_byte(pb);
- codecdata_length = get_be32(pb);
+ avio_r8(pb);
+ codecdata_length = avio_rb32(pb);
if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
return -1;
}
if (codecdata_length >= 1) {
- get_byte(pb);
+ avio_r8(pb);
if ((ret = rm_read_extradata(pb, st->codec, codecdata_length - 1)) < 0)
return ret;
}
@@ -254,9 +254,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
av_strlcpy(st->codec->codec_name, buf, sizeof(st->codec->codec_name));
}
if (read_all) {
- get_byte(pb);
- get_byte(pb);
- get_byte(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ avio_r8(pb);
rm_read_metadata(s, 0);
}
}
@@ -274,32 +274,32 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb,
av_set_pts_info(st, 64, 1, 1000);
codec_pos = url_ftell(pb);
- v = get_be32(pb);
+ v = avio_rb32(pb);
if (v == MKTAG(0xfd, 'a', 'r', '.')) {
/* ra type header */
if (rm_read_audio_stream_info(s, pb, st, rst, 0))
return -1;
} else {
int fps, fps2;
- if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
+ if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) {
fail1:
av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
goto skip;
}
- st->codec->codec_tag = get_le32(pb);
+ st->codec->codec_tag = avio_rl32(pb);
st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags,
st->codec->codec_tag);
// av_log(s, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
if (st->codec->codec_id == CODEC_ID_NONE)
goto fail1;
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
st->codec->time_base.num= 1;
- fps= get_be16(pb);
+ fps= avio_rb16(pb);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- get_be32(pb);
- fps2= get_be16(pb);
- get_be16(pb);
+ avio_rb32(pb);
+ fps2= avio_rb16(pb);
+ avio_rb16(pb);
if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (url_ftell(pb) - codec_pos))) < 0)
return ret;
@@ -335,15 +335,15 @@ static int rm_read_index(AVFormatContext *s)
AVStream *st;
do {
- if (get_le32(pb) != MKTAG('I','N','D','X'))
+ if (avio_rl32(pb) != MKTAG('I','N','D','X'))
return -1;
- size = get_be32(pb);
+ size = avio_rb32(pb);
if (size < 20)
return -1;
url_fskip(pb, 2);
- n_pkts = get_be32(pb);
- str_id = get_be16(pb);
- next_off = get_be32(pb);
+ n_pkts = avio_rb32(pb);
+ str_id = avio_rb16(pb);
+ next_off = avio_rb32(pb);
for (n = 0; n < s->nb_streams; n++)
if (s->streams[n]->id == str_id) {
st = s->streams[n];
@@ -354,8 +354,8 @@ static int rm_read_index(AVFormatContext *s)
for (n = 0; n < n_pkts; n++) {
url_fskip(pb, 2);
- pts = get_be32(pb);
- pos = get_be32(pb);
+ pts = avio_rb32(pb);
+ pos = avio_rb32(pb);
url_fskip(pb, 4); /* packet no. */
av_add_index_entry(st, pos, pts, 0, 0, AVINDEX_KEYFRAME);
@@ -395,7 +395,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
char buf[128];
int flags = 0;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag == MKTAG('.', 'r', 'a', 0xfd)) {
/* very old .ra format */
return rm_read_header_old(s, ap);
@@ -403,17 +403,17 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(EIO);
}
- get_be32(pb); /* header size */
- get_be16(pb);
- get_be32(pb);
- get_be32(pb); /* number of headers */
+ avio_rb32(pb); /* header size */
+ avio_rb16(pb);
+ avio_rb32(pb);
+ avio_rb32(pb); /* number of headers */
for(;;) {
if (url_feof(pb))
return -1;
- tag = get_le32(pb);
- tag_size = get_be32(pb);
- get_be16(pb);
+ tag = avio_rl32(pb);
+ tag_size = avio_rb32(pb);
+ avio_rb16(pb);
#if 0
printf("tag=%c%c%c%c (%08x) size=%d\n",
(tag) & 0xff,
@@ -428,17 +428,17 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
switch(tag) {
case MKTAG('P', 'R', 'O', 'P'):
/* file header */
- get_be32(pb); /* max bit rate */
- get_be32(pb); /* avg bit rate */
- get_be32(pb); /* max packet size */
- get_be32(pb); /* avg packet size */
- get_be32(pb); /* nb packets */
- get_be32(pb); /* duration */
- get_be32(pb); /* preroll */
- indx_off = get_be32(pb); /* index offset */
- data_off = get_be32(pb); /* data offset */
- get_be16(pb); /* nb streams */
- flags = get_be16(pb); /* flags */
+ avio_rb32(pb); /* max bit rate */
+ avio_rb32(pb); /* avg bit rate */
+ avio_rb32(pb); /* max packet size */
+ avio_rb32(pb); /* avg packet size */
+ avio_rb32(pb); /* nb packets */
+ avio_rb32(pb); /* duration */
+ avio_rb32(pb); /* preroll */
+ indx_off = avio_rb32(pb); /* index offset */
+ data_off = avio_rb32(pb); /* data offset */
+ avio_rb16(pb); /* nb streams */
+ flags = avio_rb16(pb); /* flags */
break;
case MKTAG('C', 'O', 'N', 'T'):
rm_read_metadata(s, 1);
@@ -447,14 +447,14 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
- st->id = get_be16(pb);
- get_be32(pb); /* max bit rate */
- st->codec->bit_rate = get_be32(pb); /* bit rate */
- get_be32(pb); /* max packet size */
- get_be32(pb); /* avg packet size */
- start_time = get_be32(pb); /* start time */
- get_be32(pb); /* preroll */
- duration = get_be32(pb); /* duration */
+ st->id = avio_rb16(pb);
+ avio_rb32(pb); /* max bit rate */
+ st->codec->bit_rate = avio_rb32(pb); /* bit rate */
+ avio_rb32(pb); /* max packet size */
+ avio_rb32(pb); /* avg packet size */
+ start_time = avio_rb32(pb); /* start time */
+ avio_rb32(pb); /* preroll */
+ duration = avio_rb32(pb); /* duration */
st->start_time = start_time;
st->duration = duration;
get_str8(pb, buf, sizeof(buf)); /* desc */
@@ -462,7 +462,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->priv_data = ff_rm_alloc_rmstream();
if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data,
- get_be32(pb)) < 0)
+ avio_rb32(pb)) < 0)
return -1;
break;
case MKTAG('D', 'A', 'T', 'A'):
@@ -474,10 +474,10 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
}
header_end:
- rm->nb_packets = get_be32(pb); /* number of packets */
+ rm->nb_packets = avio_rb32(pb); /* number of packets */
if (!rm->nb_packets && (flags & 4))
rm->nb_packets = 3600 * 25;
- get_be32(pb); /* next data header */
+ avio_rb32(pb); /* next data header */
if (!data_off)
data_off = url_ftell(pb) - 18;
@@ -494,13 +494,13 @@ static int get_num(AVIOContext *pb, int *len)
{
int n, n1;
- n = get_be16(pb);
+ n = avio_rb16(pb);
(*len)-=2;
n &= 0x7FFF;
if (n >= 0x4000) {
return n - 0x4000;
} else {
- n1 = get_be16(pb);
+ n1 = avio_rb16(pb);
(*len)-=2;
return (n << 16) | n1;
}
@@ -524,13 +524,13 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
*timestamp = AV_NOPTS_VALUE;
*flags= 0;
}else{
- state= (state<<8) + get_byte(pb);
+ state= (state<<8) + avio_r8(pb);
if(state == MKBETAG('I', 'N', 'D', 'X')){
int n_pkts, expected_len;
- len = get_be32(pb);
+ len = avio_rb32(pb);
url_fskip(pb, 2);
- n_pkts = get_be32(pb);
+ n_pkts = avio_rb32(pb);
expected_len = 20 + n_pkts * 14;
if (len == 20)
/* some files don't add index entries to chunk size... */
@@ -553,10 +553,10 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
len=state - 12;
state= 0xFFFFFFFF;
- num = get_be16(pb);
- *timestamp = get_be32(pb);
- get_byte(pb); /* reserved */
- *flags = get_byte(pb); /* flags */
+ num = avio_rb16(pb);
+ *timestamp = avio_rb32(pb);
+ avio_r8(pb); /* reserved */
+ *flags = avio_r8(pb); /* flags */
}
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
@@ -584,16 +584,16 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
int hdr, seq, pic_num, len2, pos;
int type;
- hdr = get_byte(pb); len--;
+ hdr = avio_r8(pb); len--;
type = hdr >> 6;
if(type != 3){ // not frame as a part of packet
- seq = get_byte(pb); len--;
+ seq = avio_r8(pb); len--;
}
if(type != 1){ // not whole frame
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
- pic_num = get_byte(pb); len--;
+ pic_num = avio_r8(pb); len--;
}
if(len<0)
return -1;
@@ -609,7 +609,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
- get_buffer(pb, pkt->data + 9, len);
+ avio_read(pb, pkt->data + 9, len);
return 0;
}
//now we have to deal with single slice
@@ -635,7 +635,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1);
if(vst->videobufpos + len > vst->videobufsize)
return 1;
- if (get_buffer(pb, vst->pkt.data + vst->videobufpos, len) != len)
+ if (avio_read(pb, vst->pkt.data + vst->videobufpos, len) != len)
return AVERROR(EIO);
vst->videobufpos += len;
rm->remaining_len-= len;
@@ -730,15 +730,15 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
switch(st->codec->codec_id) {
case CODEC_ID_RA_288:
for (x = 0; x < h/2; x++)
- get_buffer(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
+ avio_read(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
break;
case CODEC_ID_ATRAC3:
case CODEC_ID_COOK:
for (x = 0; x < w/sps; x++)
- get_buffer(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
+ avio_read(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
break;
case CODEC_ID_SIPR:
- get_buffer(pb, ast->pkt.data + y * w, w);
+ avio_read(pb, ast->pkt.data + y * w, w);
break;
}
@@ -753,10 +753,10 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
} else if (st->codec->codec_id == CODEC_ID_AAC) {
int x;
rm->audio_stream_num = st->index;
- ast->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4;
+ ast->sub_packet_cnt = (avio_rb16(pb) & 0xf0) >> 4;
if (ast->sub_packet_cnt) {
for (x = 0; x < ast->sub_packet_cnt; x++)
- ast->sub_packet_lengths[x] = get_be16(pb);
+ ast->sub_packet_lengths[x] = avio_rb16(pb);
rm->audio_pkt_cnt = ast->sub_packet_cnt;
ast->audiotimestamp = timestamp;
} else
@@ -916,9 +916,9 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
st = s->streams[stream_index2];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- h= get_byte(s->pb); len--;
+ h= avio_r8(s->pb); len--;
if(!(h & 0x40)){
- seq = get_byte(s->pb); len--;
+ seq = avio_r8(s->pb); len--;
}
}
diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index a8af5c8d07..5c0a21fe90 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -51,7 +51,7 @@ static int read_line(AVIOContext * pb, char* line, int bufsize)
{
int i;
for (i = 0; i < bufsize - 1; i++) {
- int b = get_byte(pb);
+ int b = avio_r8(pb);
if (b == 0)
break;
if (b == '\n') {
@@ -301,8 +301,8 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
// multiple frames per chunk in Escape 124 samples.
uint32_t frame_size, frame_flags;
- frame_flags = get_le32(pb);
- frame_size = get_le32(pb);
+ frame_flags = avio_rl32(pb);
+ frame_size = avio_rl32(pb);
if (url_fseek(pb, -8, SEEK_CUR) < 0)
return AVERROR(EIO);
diff --git a/libavformat/rsodec.c b/libavformat/rsodec.c
index da17cba8b8..a34be80c9d 100644
--- a/libavformat/rsodec.c
+++ b/libavformat/rsodec.c
@@ -35,10 +35,10 @@ static int rso_read_header(AVFormatContext *s, AVFormatParameters *ap)
enum CodecID codec;
AVStream *st;
- id = get_be16(pb);
- size = get_be16(pb);
- rate = get_be16(pb);
- get_be16(pb); /* play mode ? (0x0000 = don't loop) */
+ id = avio_rb16(pb);
+ size = avio_rb16(pb);
+ rate = avio_rb16(pb);
+ avio_rb16(pb); /* play mode ? (0x0000 = don't loop) */
codec = ff_codec_get_id(ff_codec_rso_tags, id);
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
index 9708e906aa..0f2393f5de 100644
--- a/libavformat/rtpdec_asf.c
+++ b/libavformat/rtpdec_asf.c
@@ -182,10 +182,10 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
while (url_ftell(pb) + 4 < len) {
int start_off = url_ftell(pb);
- mflags = get_byte(pb);
+ mflags = avio_r8(pb);
if (mflags & 0x80)
flags |= RTP_FLAG_KEY;
- len_off = get_be24(pb);
+ len_off = avio_rb24(pb);
if (mflags & 0x20) /**< relative timestamp */
url_fskip(pb, 4);
if (mflags & 0x10) /**< has duration */
diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c
index 781e5fff23..24052a2357 100644
--- a/libavformat/rtpdec_qt.c
+++ b/libavformat/rtpdec_qt.c
@@ -104,20 +104,20 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
data_len = get_bits(&gb, 16);
url_fseek(&pb, pos + 4, SEEK_SET);
- tag = get_le32(&pb);
+ tag = avio_rl32(&pb);
if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
tag != MKTAG('v','i','d','e')) ||
(st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
tag != MKTAG('s','o','u','n')))
return AVERROR_INVALIDDATA;
- av_set_pts_info(st, 32, 1, get_be32(&pb));
+ av_set_pts_info(st, 32, 1, avio_rb32(&pb));
if (pos + data_len > len)
return AVERROR_INVALIDDATA;
/* TLVs */
while (url_ftell(&pb) + 4 < pos + data_len) {
- int tlv_len = get_be16(&pb);
- tag = get_le16(&pb);
+ int tlv_len = avio_rb16(&pb);
+ tag = avio_rl16(&pb);
if (url_ftell(&pb) + tlv_len > pos + data_len)
return AVERROR_INVALIDDATA;
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d09123a06f..bc8cd67c81 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1784,7 +1784,7 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* read the whole sdp file */
/* XXX: better loading */
content = av_malloc(SDP_MAX_SIZE);
- size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1);
+ size = avio_read(s->pb, content, SDP_MAX_SIZE - 1);
if (size <= 0) {
av_free(content);
return AVERROR_INVALIDDATA;
diff --git a/libavformat/sauce.c b/libavformat/sauce.c
index 32c026cd34..e861b14e16 100644
--- a/libavformat/sauce.c
+++ b/libavformat/sauce.c
@@ -36,13 +36,13 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
uint64_t start_pos = url_fsize(pb) - 128;
url_fseek(pb, start_pos, SEEK_SET);
- if (get_buffer(pb, buf, 7) != 7)
+ if (avio_read(pb, buf, 7) != 7)
return -1;
if (memcmp(buf, "SAUCE00", 7))
return -1;
#define GET_SAUCE_META(name,size) \
- if (get_buffer(pb, buf, size) == size && buf[0]) { \
+ if (avio_read(pb, buf, size) == size && buf[0]) { \
buf[size] = 0; \
av_metadata_set2(&avctx->metadata, name, buf, 0); \
}
@@ -52,12 +52,12 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
GET_SAUCE_META("publisher", 20)
GET_SAUCE_META("date", 8)
url_fskip(pb, 4);
- datatype = get_byte(pb);
- filetype = get_byte(pb);
- t1 = get_le16(pb);
- t2 = get_le16(pb);
- nb_comments = get_byte(pb);
- flags = get_byte(pb);
+ datatype = avio_r8(pb);
+ filetype = avio_r8(pb);
+ t1 = avio_rl16(pb);
+ t2 = avio_rl16(pb);
+ nb_comments = avio_r8(pb);
+ flags = avio_r8(pb);
url_fskip(pb, 4);
GET_SAUCE_META("encoder", 22);
@@ -83,14 +83,14 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
if (nb_comments > 0) {
url_fseek(pb, start_pos - 64*nb_comments - 5, SEEK_SET);
- if (get_buffer(pb, buf, 5) == 5 && !memcmp(buf, "COMNT", 5)) {
+ if (avio_read(pb, buf, 5) == 5 && !memcmp(buf, "COMNT", 5)) {
int i;
char *str = av_malloc(65*nb_comments + 1);
*fsize -= 64*nb_comments + 5;
if (!str)
return 0;
for (i = 0; i < nb_comments; i++) {
- if (get_buffer(pb, str + 65*i, 64) != 64)
+ if (avio_read(pb, str + 65*i, 64) != 64)
break;
str[65*i + 64] = '\n';
}
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index ba75d43e1b..906cb915ad 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -89,7 +89,7 @@ static int film_read_header(AVFormatContext *s,
film->stereo_buffer_size = 0;
/* load the main FILM header */
- if (get_buffer(pb, scratch, 16) != 16)
+ if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
data_offset = AV_RB32(&scratch[4]);
film->version = AV_RB32(&scratch[8]);
@@ -97,7 +97,7 @@ static int film_read_header(AVFormatContext *s,
/* load the FDSC chunk */
if (film->version == 0) {
/* special case for Lemmings .film files; 20-byte header */
- if (get_buffer(pb, scratch, 20) != 20)
+ if (avio_read(pb, scratch, 20) != 20)
return AVERROR(EIO);
/* make some assumptions about the audio parameters */
film->audio_type = CODEC_ID_PCM_S8;
@@ -106,7 +106,7 @@ static int film_read_header(AVFormatContext *s,
film->audio_bits = 8;
} else {
/* normal Saturn .cpk files; 32-byte header */
- if (get_buffer(pb, scratch, 32) != 32)
+ if (avio_read(pb, scratch, 32) != 32)
return AVERROR(EIO);
film->audio_samplerate = AV_RB16(&scratch[24]);
film->audio_channels = scratch[21];
@@ -158,7 +158,7 @@ static int film_read_header(AVFormatContext *s,
}
/* load the sample table */
- if (get_buffer(pb, scratch, 16) != 16)
+ if (avio_read(pb, scratch, 16) != 16)
return AVERROR(EIO);
if (AV_RB32(&scratch[0]) != STAB_TAG)
return AVERROR_INVALIDDATA;
@@ -174,7 +174,7 @@ static int film_read_header(AVFormatContext *s,
audio_frame_counter = 0;
for (i = 0; i < film->sample_count; i++) {
/* load the next sample record and transfer it to an internal struct */
- if (get_buffer(pb, scratch, 16) != 16) {
+ if (avio_read(pb, scratch, 16) != 16) {
av_free(film->sample_table);
return AVERROR(EIO);
}
@@ -225,7 +225,7 @@ static int film_read_packet(AVFormatContext *s,
pkt->pos= url_ftell(pb);
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
- get_buffer(pb, pkt->data, sample->sample_size);
+ avio_read(pb, pkt->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
(film->audio_channels == 2)) {
/* stereo PCM needs to be interleaved */
@@ -241,7 +241,7 @@ static int film_read_packet(AVFormatContext *s,
}
pkt->pos= url_ftell(pb);
- ret = get_buffer(pb, film->stereo_buffer, sample->sample_size);
+ ret = avio_read(pb, film->stereo_buffer, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c
index e30d42deb6..323938639c 100644
--- a/libavformat/sierravmd.c
+++ b/libavformat/sierravmd.c
@@ -96,7 +96,7 @@ static int vmd_read_header(AVFormatContext *s,
/* fetch the main header, including the 2 header length bytes */
url_fseek(pb, 0, SEEK_SET);
- if (get_buffer(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
+ if (avio_read(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
return AVERROR(EIO);
if(vmd->vmd_header[16] == 'i' && vmd->vmd_header[17] == 'v' && vmd->vmd_header[18] == '3')
@@ -172,7 +172,7 @@ static int vmd_read_header(AVFormatContext *s,
av_free(vmd->frame_table);
return AVERROR(ENOMEM);
}
- if (get_buffer(pb, raw_frame_table, raw_frame_table_size) !=
+ if (avio_read(pb, raw_frame_table, raw_frame_table_size) !=
raw_frame_table_size) {
av_free(raw_frame_table);
av_free(vmd->frame_table);
@@ -189,7 +189,7 @@ static int vmd_read_header(AVFormatContext *s,
int type;
uint32_t size;
- get_buffer(pb, chunk, BYTES_PER_FRAME_RECORD);
+ avio_read(pb, chunk, BYTES_PER_FRAME_RECORD);
type = chunk[0];
size = AV_RL32(&chunk[2]);
if(!size && type != 1)
@@ -250,9 +250,9 @@ static int vmd_read_packet(AVFormatContext *s,
pkt->pos= url_ftell(pb);
memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
if(vmd->is_indeo3)
- ret = get_buffer(pb, pkt->data, frame->frame_size);
+ ret = avio_read(pb, pkt->data, frame->frame_size);
else
- ret = get_buffer(pb, pkt->data + BYTES_PER_FRAME_RECORD,
+ ret = avio_read(pb, pkt->data + BYTES_PER_FRAME_RECORD,
frame->frame_size);
if (ret != frame->frame_size) {
diff --git a/libavformat/siff.c b/libavformat/siff.c
index 21ccf2dcd1..1d24c6a504 100644
--- a/libavformat/siff.c
+++ b/libavformat/siff.c
@@ -89,28 +89,28 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
AVStream *st;
int width, height;
- if (get_le32(pb) != TAG_VBHD){
+ if (avio_rl32(pb) != TAG_VBHD){
av_log(s, AV_LOG_ERROR, "Header chunk is missing\n");
return -1;
}
- if(get_be32(pb) != 32){
+ if(avio_rb32(pb) != 32){
av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n");
return -1;
}
- if(get_le16(pb) != 1){
+ if(avio_rl16(pb) != 1){
av_log(s, AV_LOG_ERROR, "Incorrect header version\n");
return -1;
}
- width = get_le16(pb);
- height = get_le16(pb);
+ width = avio_rl16(pb);
+ height = avio_rl16(pb);
url_fskip(pb, 4);
- c->frames = get_le16(pb);
+ c->frames = avio_rl16(pb);
if(!c->frames){
av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
return -1;
}
- c->bits = get_le16(pb);
- c->rate = get_le16(pb);
+ c->bits = avio_rl16(pb);
+ c->rate = avio_rl16(pb);
c->block_align = c->rate * (c->bits >> 3);
url_fskip(pb, 16); //zeroes
@@ -137,17 +137,17 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
{
- if (get_le32(pb) != TAG_SHDR){
+ if (avio_rl32(pb) != TAG_SHDR){
av_log(s, AV_LOG_ERROR, "Header chunk is missing\n");
return -1;
}
- if(get_be32(pb) != 8){
+ if(avio_rb32(pb) != 8){
av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n");
return -1;
}
url_fskip(pb, 4); //unknown value
- c->rate = get_le16(pb);
- c->bits = get_le16(pb);
+ c->rate = avio_rl16(pb);
+ c->bits = avio_rl16(pb);
c->block_align = c->rate * (c->bits >> 3);
return create_audio_stream(s, c);
}
@@ -158,10 +158,10 @@ static int siff_read_header(AVFormatContext *s, AVFormatParameters *ap)
SIFFContext *c = s->priv_data;
uint32_t tag;
- if (get_le32(pb) != TAG_SIFF)
+ if (avio_rl32(pb) != TAG_SIFF)
return -1;
url_fskip(pb, 4); //ignore size
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != TAG_VBV1 && tag != TAG_SOUN){
av_log(s, AV_LOG_ERROR, "Not a VBV file\n");
@@ -172,7 +172,7 @@ static int siff_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
if (tag == TAG_SOUN && siff_parse_soun(s, c, pb) < 0)
return -1;
- if (get_le32(pb) != MKTAG('B', 'O', 'D', 'Y')){
+ if (avio_rl32(pb) != MKTAG('B', 'O', 'D', 'Y')){
av_log(s, AV_LOG_ERROR, "'BODY' chunk is missing\n");
return -1;
}
@@ -190,12 +190,12 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (c->cur_frame >= c->frames)
return AVERROR(EIO);
if (c->curstrm == -1){
- c->pktsize = get_le32(s->pb) - 4;
- c->flags = get_le16(s->pb);
+ c->pktsize = avio_rl32(s->pb) - 4;
+ c->flags = avio_rl16(s->pb);
c->gmcsize = (c->flags & VB_HAS_GMC) ? 4 : 0;
if (c->gmcsize)
- get_buffer(s->pb, c->gmc, c->gmcsize);
- c->sndsize = (c->flags & VB_HAS_AUDIO) ? get_le32(s->pb): 0;
+ avio_read(s->pb, c->gmc, c->gmcsize);
+ c->sndsize = (c->flags & VB_HAS_AUDIO) ? avio_rl32(s->pb): 0;
c->curstrm = !!(c->flags & VB_HAS_AUDIO);
}
@@ -206,7 +206,7 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
AV_WL16(pkt->data, c->flags);
if (c->gmcsize)
memcpy(pkt->data + 2, c->gmc, c->gmcsize);
- get_buffer(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2);
+ avio_read(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2);
pkt->stream_index = 0;
c->curstrm = -1;
}else{
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index 8b375cf5d6..42d3672d79 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -105,19 +105,19 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
int tbase;
/* read and check header */
- smk->magic = get_le32(pb);
+ smk->magic = avio_rl32(pb);
if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
return -1;
- smk->width = get_le32(pb);
- smk->height = get_le32(pb);
- smk->frames = get_le32(pb);
- smk->pts_inc = (int32_t)get_le32(pb);
- smk->flags = get_le32(pb);
+ smk->width = avio_rl32(pb);
+ smk->height = avio_rl32(pb);
+ smk->frames = avio_rl32(pb);
+ smk->pts_inc = (int32_t)avio_rl32(pb);
+ smk->flags = avio_rl32(pb);
if(smk->flags & SMACKER_FLAG_RING_FRAME)
smk->frames++;
for(i = 0; i < 7; i++)
- smk->audio[i] = get_le32(pb);
- smk->treesize = get_le32(pb);
+ smk->audio[i] = avio_rl32(pb);
+ smk->treesize = avio_rl32(pb);
if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (this check is probably redundant)
av_log(s, AV_LOG_ERROR, "treesize too large\n");
@@ -125,13 +125,13 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
//FIXME remove extradata "rebuilding"
- smk->mmap_size = get_le32(pb);
- smk->mclr_size = get_le32(pb);
- smk->full_size = get_le32(pb);
- smk->type_size = get_le32(pb);
+ smk->mmap_size = avio_rl32(pb);
+ smk->mclr_size = avio_rl32(pb);
+ smk->full_size = avio_rl32(pb);
+ smk->type_size = avio_rl32(pb);
for(i = 0; i < 7; i++)
- smk->rates[i] = get_le32(pb);
- smk->pad = get_le32(pb);
+ smk->rates[i] = avio_rl32(pb);
+ smk->pad = avio_rl32(pb);
/* setup data */
if(smk->frames > 0xFFFFFF) {
av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
@@ -144,10 +144,10 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* read frame info */
for(i = 0; i < smk->frames; i++) {
- smk->frm_size[i] = get_le32(pb);
+ smk->frm_size[i] = avio_rl32(pb);
}
for(i = 0; i < smk->frames; i++) {
- smk->frm_flags[i] = get_byte(pb);
+ smk->frm_flags[i] = avio_r8(pb);
}
/* init video codec */
@@ -207,7 +207,7 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_free(smk->frm_flags);
return -1;
}
- ret = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
+ ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
if(ret != st->codec->extradata_size - 16){
av_free(smk->frm_size);
av_free(smk->frm_flags);
@@ -251,19 +251,19 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
uint8_t oldpal[768];
memcpy(oldpal, pal, 768);
- size = get_byte(s->pb);
+ size = avio_r8(s->pb);
size = size * 4 - 1;
frame_size -= size;
frame_size--;
sz = 0;
pos = url_ftell(s->pb) + size;
while(sz < 256){
- t = get_byte(s->pb);
+ t = avio_r8(s->pb);
if(t & 0x80){ /* skip palette entries */
sz += (t & 0x7F) + 1;
pal += ((t & 0x7F) + 1) * 3;
} else if(t & 0x40){ /* copy with offset */
- off = get_byte(s->pb) * 3;
+ off = avio_r8(s->pb) * 3;
j = (t & 0x3F) + 1;
while(j-- && sz < 256) {
*pal++ = oldpal[off + 0];
@@ -274,8 +274,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
}
} else { /* new entries */
*pal++ = smk_pal[t];
- *pal++ = smk_pal[get_byte(s->pb) & 0x3F];
- *pal++ = smk_pal[get_byte(s->pb) & 0x3F];
+ *pal++ = smk_pal[avio_r8(s->pb) & 0x3F];
+ *pal++ = smk_pal[avio_r8(s->pb) & 0x3F];
sz++;
}
}
@@ -288,13 +288,13 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
for(i = 0; i < 7; i++) {
if(flags & 1) {
int size;
- size = get_le32(s->pb) - 4;
+ size = avio_rl32(s->pb) - 4;
frame_size -= size;
frame_size -= 4;
smk->curstream++;
smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size);
smk->buf_sizes[smk->curstream] = size;
- ret = get_buffer(s->pb, smk->bufs[smk->curstream], size);
+ ret = avio_read(s->pb, smk->bufs[smk->curstream], size);
if(ret != size)
return AVERROR(EIO);
smk->stream_id[smk->curstream] = smk->indexes[i];
@@ -307,7 +307,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
palchange |= 2;
pkt->data[0] = palchange;
memcpy(pkt->data + 1, smk->pal, 768);
- ret = get_buffer(s->pb, pkt->data + 769, frame_size);
+ ret = avio_read(s->pb, pkt->data + 769, frame_size);
if(ret != frame_size)
return AVERROR(EIO);
pkt->stream_index = smk->videoindex;
diff --git a/libavformat/sol.c b/libavformat/sol.c
index d688fde8b2..7ad894e304 100644
--- a/libavformat/sol.c
+++ b/libavformat/sol.c
@@ -93,15 +93,15 @@ static int sol_read_header(AVFormatContext *s,
AVStream *st;
/* check ".snd" header */
- magic = get_le16(pb);
- tag = get_le32(pb);
+ magic = avio_rl16(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('S', 'O', 'L', 0))
return -1;
- rate = get_le16(pb);
- type = get_byte(pb);
- size = get_le32(pb);
+ rate = avio_rl16(pb);
+ type = avio_r8(pb);
+ size = avio_rl32(pb);
if (magic != 0x0B8D)
- get_byte(pb); /* newer SOLs contain padding byte */
+ avio_r8(pb); /* newer SOLs contain padding byte */
codec = sol_codec_id(magic, type);
channels = sol_channels(magic, type);
diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c
index ca48b4370f..b66883441b 100644
--- a/libavformat/soxdec.c
+++ b/libavformat/soxdec.c
@@ -55,20 +55,20 @@ static int sox_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- if (get_le32(pb) == SOX_TAG) {
+ if (avio_rl32(pb) == SOX_TAG) {
st->codec->codec_id = CODEC_ID_PCM_S32LE;
- header_size = get_le32(pb);
+ header_size = avio_rl32(pb);
url_fskip(pb, 8); /* sample count */
- sample_rate = av_int2dbl(get_le64(pb));
- st->codec->channels = get_le32(pb);
- comment_size = get_le32(pb);
+ sample_rate = av_int2dbl(avio_rl64(pb));
+ st->codec->channels = avio_rl32(pb);
+ comment_size = avio_rl32(pb);
} else {
st->codec->codec_id = CODEC_ID_PCM_S32BE;
- header_size = get_be32(pb);
+ header_size = avio_rb32(pb);
url_fskip(pb, 8); /* sample count */
- sample_rate = av_int2dbl(get_be64(pb));
- st->codec->channels = get_be32(pb);
- comment_size = get_be32(pb);
+ sample_rate = av_int2dbl(avio_rb64(pb));
+ st->codec->channels = avio_rb32(pb);
+ comment_size = avio_rb32(pb);
}
if (comment_size > 0xFFFFFFFFU - SOX_FIXED_HDR - 4U) {
@@ -95,7 +95,7 @@ static int sox_read_header(AVFormatContext *s,
if (comment_size && comment_size < UINT_MAX) {
char *comment = av_malloc(comment_size+1);
- if (get_buffer(pb, comment, comment_size) != comment_size) {
+ if (avio_read(pb, comment, comment_size) != comment_size) {
av_freep(&comment);
return AVERROR(EIO);
}
diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
index a1a62a116c..2fc567277f 100644
--- a/libavformat/spdifdec.c
+++ b/libavformat/spdifdec.c
@@ -170,13 +170,13 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
int pkt_size_bits, offset, ret;
while (state != (AV_BSWAP16C(SYNCWORD1) << 16 | AV_BSWAP16C(SYNCWORD2))) {
- state = (state << 8) | get_byte(pb);
+ state = (state << 8) | avio_r8(pb);
if (url_feof(pb))
return AVERROR_EOF;
}
- data_type = get_le16(pb);
- pkt_size_bits = get_le16(pb);
+ data_type = avio_rl16(pb);
+ pkt_size_bits = avio_rl16(pb);
if (pkt_size_bits % 16)
av_log_ask_for_sample(s, "Packet does not end to a 16-bit boundary.");
@@ -187,7 +187,7 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = url_ftell(pb) - BURST_HEADER_SIZE;
- if (get_buffer(pb, pkt->data, pkt->size) < pkt->size) {
+ if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
av_free_packet(pkt);
return AVERROR_EOF;
}
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 002e15fab1..c567f264f1 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -30,11 +30,11 @@ static int get_swf_tag(AVIOContext *pb, int *len_ptr)
if (url_feof(pb))
return -1;
- tag = get_le16(pb);
+ tag = avio_rl16(pb);
len = tag & 0x3f;
tag = tag >> 6;
if (len == 0x3f) {
- len = get_le32(pb);
+ len = avio_rl32(pb);
}
// av_log(NULL, AV_LOG_DEBUG, "Tag: %d - Len: %d\n", tag, len);
*len_ptr = len;
@@ -58,7 +58,7 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVIOContext *pb = s->pb;
int nbits, len, tag;
- tag = get_be32(pb) & 0xffffff00;
+ tag = avio_rb32(pb) & 0xffffff00;
if (tag == MKBETAG('C', 'W', 'S', 0)) {
av_log(s, AV_LOG_ERROR, "Compressed SWF format not supported\n");
@@ -66,13 +66,13 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
if (tag != MKBETAG('F', 'W', 'S', 0))
return AVERROR(EIO);
- get_le32(pb);
+ avio_rl32(pb);
/* skip rectangle size */
- nbits = get_byte(pb) >> 3;
+ nbits = avio_r8(pb) >> 3;
len = (4 * nbits - 3 + 7) / 8;
url_fskip(pb, len);
- swf->frame_rate = get_le16(pb); /* 8.8 fixed */
- get_le16(pb); /* frame count */
+ swf->frame_rate = avio_rl16(pb); /* 8.8 fixed */
+ avio_rl16(pb); /* frame count */
swf->samples_per_frame = 0;
s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -92,7 +92,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
if (tag < 0)
return AVERROR(EIO);
if (tag == TAG_VIDEOSTREAM) {
- int ch_id = get_le16(pb);
+ int ch_id = avio_rl16(pb);
len -= 2;
for (i=0; i<s->nb_streams; i++) {
@@ -101,16 +101,16 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
goto skip;
}
- get_le16(pb);
- get_le16(pb);
- get_le16(pb);
- get_byte(pb);
+ avio_rl16(pb);
+ avio_rl16(pb);
+ avio_rl16(pb);
+ avio_r8(pb);
/* Check for FLV1 */
vst = av_new_stream(s, ch_id);
if (!vst)
return -1;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, get_byte(pb));
+ vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb));
av_set_pts_info(vst, 16, 256, swf->frame_rate);
vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
len -= 8;
@@ -124,9 +124,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
goto skip;
}
- get_byte(pb);
- v = get_byte(pb);
- swf->samples_per_frame = get_le16(pb);
+ avio_r8(pb);
+ v = avio_r8(pb);
+ swf->samples_per_frame = avio_rl16(pb);
ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */
if (!ast)
return -1;
@@ -141,12 +141,12 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
len -= 4;
} else if (tag == TAG_VIDEOFRAME) {
- int ch_id = get_le16(pb);
+ int ch_id = avio_rl16(pb);
len -= 2;
for(i=0; i<s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
- frame = get_le16(pb);
+ frame = avio_rl16(pb);
av_get_packet(pb, pkt, len-2);
pkt->pos = pos;
pkt->pts = frame;
@@ -185,17 +185,17 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
st = vst;
}
- get_le16(pb); /* BITMAP_ID */
+ avio_rl16(pb); /* BITMAP_ID */
av_new_packet(pkt, len-2);
- get_buffer(pb, pkt->data, 4);
+ avio_read(pb, pkt->data, 4);
if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
AV_RB32(pkt->data) == 0xffd9ffd8) {
/* old SWF files containing SOI/EOI as data start */
/* files created by swink have reversed tag */
pkt->size -= 4;
- get_buffer(pb, pkt->data, pkt->size);
+ avio_read(pb, pkt->data, pkt->size);
} else {
- get_buffer(pb, pkt->data + 4, pkt->size - 4);
+ avio_read(pb, pkt->data + 4, pkt->size - 4);
}
pkt->pos = pos;
pkt->stream_index = st->index;
diff --git a/libavformat/thp.c b/libavformat/thp.c
index b6e7ae2f4a..39a8bc2c35 100644
--- a/libavformat/thp.c
+++ b/libavformat/thp.c
@@ -61,31 +61,31 @@ static int thp_read_header(AVFormatContext *s,
int i;
/* Read the file header. */
- get_be32(pb); /* Skip Magic. */
- thp->version = get_be32(pb);
+ avio_rb32(pb); /* Skip Magic. */
+ thp->version = avio_rb32(pb);
- get_be32(pb); /* Max buf size. */
- get_be32(pb); /* Max samples. */
+ avio_rb32(pb); /* Max buf size. */
+ avio_rb32(pb); /* Max samples. */
- thp->fps = av_d2q(av_int2flt(get_be32(pb)), INT_MAX);
- thp->framecnt = get_be32(pb);
- thp->first_framesz = get_be32(pb);
- get_be32(pb); /* Data size. */
+ thp->fps = av_d2q(av_int2flt(avio_rb32(pb)), INT_MAX);
+ thp->framecnt = avio_rb32(pb);
+ thp->first_framesz = avio_rb32(pb);
+ avio_rb32(pb); /* Data size. */
- thp->compoff = get_be32(pb);
- get_be32(pb); /* offsetDataOffset. */
- thp->first_frame = get_be32(pb);
- thp->last_frame = get_be32(pb);
+ thp->compoff = avio_rb32(pb);
+ avio_rb32(pb); /* offsetDataOffset. */
+ thp->first_frame = avio_rb32(pb);
+ thp->last_frame = avio_rb32(pb);
thp->next_framesz = thp->first_framesz;
thp->next_frame = thp->first_frame;
/* Read the component structure. */
url_fseek (pb, thp->compoff, SEEK_SET);
- thp->compcount = get_be32(pb);
+ thp->compcount = avio_rb32(pb);
/* Read the list of component types. */
- get_buffer(pb, thp->components, 16);
+ avio_read(pb, thp->components, 16);
for (i = 0; i < thp->compcount; i++) {
if (thp->components[i] == 0) {
@@ -103,14 +103,14 @@ static int thp_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_THP;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_be32(pb);
- st->codec->height = get_be32(pb);
+ st->codec->width = avio_rb32(pb);
+ st->codec->height = avio_rb32(pb);
st->codec->sample_rate = av_q2d(thp->fps);
thp->vst = st;
thp->video_stream_index = st->index;
if (thp->version == 0x11000)
- get_be32(pb); /* Unknown. */
+ avio_rb32(pb); /* Unknown. */
} else if (thp->components[i] == 1) {
if (thp->has_audio != 0)
break;
@@ -123,8 +123,8 @@ static int thp_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_THP;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->channels = get_be32(pb); /* numChannels. */
- st->codec->sample_rate = get_be32(pb); /* Frequency. */
+ st->codec->channels = avio_rb32(pb); /* numChannels. */
+ st->codec->sample_rate = avio_rb32(pb); /* Frequency. */
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
@@ -153,15 +153,15 @@ static int thp_read_packet(AVFormatContext *s,
/* Locate the next frame and read out its size. */
thp->next_frame += thp->next_framesz;
- thp->next_framesz = get_be32(pb);
+ thp->next_framesz = avio_rb32(pb);
- get_be32(pb); /* Previous total size. */
- size = get_be32(pb); /* Total size of this frame. */
+ avio_rb32(pb); /* Previous total size. */
+ size = avio_rb32(pb); /* Total size of this frame. */
/* Store the audiosize so the next time this function is called,
the audio can be read. */
if (thp->has_audio)
- thp->audiosize = get_be32(pb); /* Audio size. */
+ thp->audiosize = avio_rb32(pb); /* Audio size. */
else
thp->frame++;
diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c
index f85f99b8ba..e368b17959 100644
--- a/libavformat/tiertexseq.c
+++ b/libavformat/tiertexseq.c
@@ -86,7 +86,7 @@ static int seq_init_frame_buffers(SeqDemuxContext *seq, AVIOContext *pb)
url_fseek(pb, 256, SEEK_SET);
for (i = 0; i < SEQ_NUM_FRAME_BUFFERS; i++) {
- sz = get_le16(pb);
+ sz = avio_rl16(pb);
if (sz == 0)
break;
else {
@@ -114,7 +114,7 @@ static int seq_fill_buffer(SeqDemuxContext *seq, AVIOContext *pb, int buffer_num
return AVERROR_INVALIDDATA;
url_fseek(pb, seq->current_frame_offs + data_offs, SEEK_SET);
- if (get_buffer(pb, seq_buffer->data + seq_buffer->fill_size, data_size) != data_size)
+ if (avio_read(pb, seq_buffer->data + seq_buffer->fill_size, data_size) != data_size)
return AVERROR(EIO);
seq_buffer->fill_size += data_size;
@@ -131,7 +131,7 @@ static int seq_parse_frame_data(SeqDemuxContext *seq, AVIOContext *pb)
url_fseek(pb, seq->current_frame_offs, SEEK_SET);
/* sound data */
- seq->current_audio_data_offs = get_le16(pb);
+ seq->current_audio_data_offs = avio_rl16(pb);
if (seq->current_audio_data_offs) {
seq->current_audio_data_size = SEQ_AUDIO_BUFFER_SIZE * 2;
} else {
@@ -139,7 +139,7 @@ static int seq_parse_frame_data(SeqDemuxContext *seq, AVIOContext *pb)
}
/* palette data */
- seq->current_pal_data_offs = get_le16(pb);
+ seq->current_pal_data_offs = avio_rl16(pb);
if (seq->current_pal_data_offs) {
seq->current_pal_data_size = 768;
} else {
@@ -148,10 +148,10 @@ static int seq_parse_frame_data(SeqDemuxContext *seq, AVIOContext *pb)
/* video data */
for (i = 0; i < 4; i++)
- buffer_num[i] = get_byte(pb);
+ buffer_num[i] = avio_r8(pb);
for (i = 0; i < 4; i++)
- offset_table[i] = get_le16(pb);
+ offset_table[i] = avio_rl16(pb);
for (i = 0; i < 3; i++) {
if (offset_table[i]) {
@@ -257,7 +257,7 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
if (seq->current_pal_data_size) {
pkt->data[0] |= 1;
url_fseek(pb, seq->current_frame_offs + seq->current_pal_data_offs, SEEK_SET);
- if (get_buffer(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size)
+ if (avio_read(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size)
return AVERROR(EIO);
}
if (seq->current_video_data_size) {
diff --git a/libavformat/tmv.c b/libavformat/tmv.c
index 14450a2c51..3fe9e65dcc 100644
--- a/libavformat/tmv.c
+++ b/libavformat/tmv.c
@@ -70,7 +70,7 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVRational fps;
unsigned comp_method, char_cols, char_rows, features;
- if (get_le32(pb) != TMV_TAG)
+ if (avio_rl32(pb) != TMV_TAG)
return -1;
if (!(vst = av_new_stream(s, 0)))
@@ -79,30 +79,30 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!(ast = av_new_stream(s, 0)))
return AVERROR(ENOMEM);
- ast->codec->sample_rate = get_le16(pb);
+ ast->codec->sample_rate = avio_rl16(pb);
if (!ast->codec->sample_rate) {
av_log(s, AV_LOG_ERROR, "invalid sample rate\n");
return -1;
}
- tmv->audio_chunk_size = get_le16(pb);
+ tmv->audio_chunk_size = avio_rl16(pb);
if (!tmv->audio_chunk_size) {
av_log(s, AV_LOG_ERROR, "invalid audio chunk size\n");
return -1;
}
- comp_method = get_byte(pb);
+ comp_method = avio_r8(pb);
if (comp_method) {
av_log(s, AV_LOG_ERROR, "unsupported compression method %d\n",
comp_method);
return -1;
}
- char_cols = get_byte(pb);
- char_rows = get_byte(pb);
+ char_cols = avio_r8(pb);
+ char_rows = avio_r8(pb);
tmv->video_chunk_size = char_cols * char_rows * 2;
- features = get_byte(pb);
+ features = avio_r8(pb);
if (features & ~(TMV_PADDING | TMV_STEREO)) {
av_log(s, AV_LOG_ERROR, "unsupported features 0x%02x\n",
features & ~(TMV_PADDING | TMV_STEREO));
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 21b7538d26..61a41df90b 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -47,19 +47,19 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_id3v1_read(s);
start_offset = url_ftell(s->pb);
- if (get_le32(s->pb) != AV_RL32("TTA1"))
+ if (avio_rl32(s->pb) != AV_RL32("TTA1"))
return -1; // not tta file
url_fskip(s->pb, 2); // FIXME: flags
- channels = get_le16(s->pb);
- bps = get_le16(s->pb);
- samplerate = get_le32(s->pb);
+ channels = avio_rl16(s->pb);
+ bps = avio_rl16(s->pb);
+ samplerate = avio_rl32(s->pb);
if(samplerate <= 0 || samplerate > 1000000){
av_log(s, AV_LOG_ERROR, "nonsense samplerate\n");
return -1;
}
- datalen = get_le32(s->pb);
+ datalen = avio_rl32(s->pb);
if(datalen < 0){
av_log(s, AV_LOG_ERROR, "nonsense datalen\n");
return -1;
@@ -87,7 +87,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
framepos = url_ftell(s->pb) + 4*c->totalframes + 4;
for (i = 0; i < c->totalframes; i++) {
- uint32_t size = get_le32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
av_add_index_entry(st, framepos, i*framelen, size, 0, AVINDEX_KEYFRAME);
framepos += size;
}
@@ -101,13 +101,13 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = url_ftell(s->pb) - start_offset;
if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
- //this check is redundant as get_buffer should fail
+ //this check is redundant as avio_read should fail
av_log(s, AV_LOG_ERROR, "extradata_size too large\n");
return -1;
}
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
url_fseek(s->pb, start_offset, SEEK_SET);
- get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}
diff --git a/libavformat/tty.c b/libavformat/tty.c
index d576fd4338..767006b5a3 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -47,14 +47,14 @@ static int efi_read(AVFormatContext *avctx, uint64_t start_pos)
int len;
url_fseek(pb, start_pos, SEEK_SET);
- if (get_byte(pb) != 0x1A)
+ if (avio_r8(pb) != 0x1A)
return -1;
#define GET_EFI_META(name,size) \
- len = get_byte(pb); \
+ len = avio_r8(pb); \
if (len < 1 || len > size) \
return -1; \
- if (get_buffer(pb, buf, size) == size) { \
+ if (avio_read(pb, buf, size) == size) { \
buf[len] = 0; \
av_metadata_set2(&avctx->metadata, name, buf, 0); \
}
diff --git a/libavformat/txd.c b/libavformat/txd.c
index 76d68a8190..92a0c094aa 100644
--- a/libavformat/txd.c
+++ b/libavformat/txd.c
@@ -57,9 +57,9 @@ static int txd_read_packet(AVFormatContext *s, AVPacket *pkt) {
int ret;
next_chunk:
- id = get_le32(pb);
- chunk_size = get_le32(pb);
- marker = get_le32(pb);
+ id = avio_rl32(pb);
+ chunk_size = avio_rl32(pb);
+ marker = avio_rl32(pb);
if (url_feof(s->pb))
return AVERROR_EOF;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3cf914a748..f5d60a3bfc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -332,7 +332,7 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
pkt->pos= url_ftell(s);
- ret= get_buffer(s, pkt->data, size);
+ ret= avio_read(s, pkt->data, size);
if(ret<=0)
av_free_packet(pkt);
else
@@ -351,7 +351,7 @@ int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
ret = av_grow_packet(pkt, size);
if (ret < 0)
return ret;
- ret = get_buffer(s, pkt->data + old_size, size);
+ ret = avio_read(s, pkt->data + old_size, size);
av_shrink_packet(pkt, old_size + FFMAX(ret, 0));
return ret;
}
@@ -555,7 +555,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
/* read probe data */
buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);
- if ((ret = get_buffer(pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
+ if ((ret = avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
/* fail if error was not end of file, otherwise, lower score */
if (ret != AVERROR_EOF) {
av_free(buf);
diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c
index 0be6ec3325..838dd43b5f 100644
--- a/libavformat/vc1test.c
+++ b/libavformat/vc1test.c
@@ -49,8 +49,8 @@ static int vc1t_read_header(AVFormatContext *s,
int frames;
uint32_t fps;
- frames = get_le24(pb);
- if(get_byte(pb) != 0xC5 || get_le32(pb) != 4)
+ frames = avio_rl24(pb);
+ if(avio_r8(pb) != 0xC5 || avio_rl32(pb) != 4)
return -1;
/* init video codec */
@@ -63,13 +63,13 @@ static int vc1t_read_header(AVFormatContext *s,
st->codec->extradata = av_malloc(VC1_EXTRADATA_SIZE);
st->codec->extradata_size = VC1_EXTRADATA_SIZE;
- get_buffer(pb, st->codec->extradata, VC1_EXTRADATA_SIZE);
- st->codec->height = get_le32(pb);
- st->codec->width = get_le32(pb);
- if(get_le32(pb) != 0xC)
+ avio_read(pb, st->codec->extradata, VC1_EXTRADATA_SIZE);
+ st->codec->height = avio_rl32(pb);
+ st->codec->width = avio_rl32(pb);
+ if(avio_rl32(pb) != 0xC)
return -1;
url_fskip(pb, 8);
- fps = get_le32(pb);
+ fps = avio_rl32(pb);
if(fps == 0xFFFFFFFF)
av_set_pts_info(st, 32, 1, 1000);
else{
@@ -95,10 +95,10 @@ static int vc1t_read_packet(AVFormatContext *s,
if(url_feof(pb))
return AVERROR(EIO);
- frame_size = get_le24(pb);
- if(get_byte(pb) & 0x80)
+ frame_size = avio_rl24(pb);
+ if(avio_r8(pb) & 0x80)
keyframe = 1;
- pts = get_le32(pb);
+ pts = avio_rl32(pb);
if(av_get_packet(pb, pkt, frame_size) < 0)
return AVERROR(EIO);
if(s->streams[0]->time_base.den == 1000)
diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c
index 056a657ec2..01bbdb2c62 100644
--- a/libavformat/vocdec.c
+++ b/libavformat/vocdec.c
@@ -46,7 +46,7 @@ static int voc_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st;
url_fskip(pb, 20);
- header_size = get_le16(pb) - 22;
+ header_size = avio_rl16(pb) - 22;
if (header_size != 4) {
av_log(s, AV_LOG_ERROR, "unknown header size: %d\n", header_size);
return AVERROR(ENOSYS);
@@ -73,10 +73,10 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
int channels = 1;
while (!voc->remaining_size) {
- type = get_byte(pb);
+ type = avio_r8(pb);
if (type == VOC_TYPE_EOF)
return AVERROR(EIO);
- voc->remaining_size = get_le24(pb);
+ voc->remaining_size = avio_rl24(pb);
if (!voc->remaining_size) {
if (url_is_streamed(s->pb))
return AVERROR(EIO);
@@ -86,11 +86,11 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
switch (type) {
case VOC_TYPE_VOICE_DATA:
- dec->sample_rate = 1000000 / (256 - get_byte(pb));
+ dec->sample_rate = 1000000 / (256 - avio_r8(pb));
if (sample_rate)
dec->sample_rate = sample_rate;
dec->channels = channels;
- tmp_codec = get_byte(pb);
+ tmp_codec = avio_r8(pb);
dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
voc->remaining_size -= 2;
max_size -= 2;
@@ -101,19 +101,19 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
break;
case VOC_TYPE_EXTENDED:
- sample_rate = get_le16(pb);
- get_byte(pb);
- channels = get_byte(pb) + 1;
+ sample_rate = avio_rl16(pb);
+ avio_r8(pb);
+ channels = avio_r8(pb) + 1;
sample_rate = 256000000 / (channels * (65536 - sample_rate));
voc->remaining_size = 0;
max_size -= 4;
break;
case VOC_TYPE_NEW_VOICE_DATA:
- dec->sample_rate = get_le32(pb);
- dec->bits_per_coded_sample = get_byte(pb);
- dec->channels = get_byte(pb);
- tmp_codec = get_le16(pb);
+ dec->sample_rate = avio_rl32(pb);
+ dec->bits_per_coded_sample = avio_r8(pb);
+ dec->channels = avio_r8(pb);
+ tmp_codec = avio_rl16(pb);
url_fskip(pb, 4);
voc->remaining_size -= 12;
max_size -= 12;
diff --git a/libavformat/vqf.c b/libavformat/vqf.c
index 9cf0c3a6ad..8a3d170574 100644
--- a/libavformat/vqf.c
+++ b/libavformat/vqf.c
@@ -54,7 +54,7 @@ static void add_metadata(AVFormatContext *s, const char *tag,
buf = av_malloc(len+1);
if (!buf)
return;
- get_buffer(s->pb, buf, len);
+ avio_read(s->pb, buf, len);
buf[len] = 0;
av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL);
}
@@ -74,7 +74,7 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(s->pb, 12);
- header_size = get_be32(s->pb);
+ header_size = avio_rb32(s->pb);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_TWINVQ;
@@ -82,12 +82,12 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
do {
int len;
- chunk_tag = get_le32(s->pb);
+ chunk_tag = avio_rl32(s->pb);
if (chunk_tag == MKTAG('D','A','T','A'))
break;
- len = get_be32(s->pb);
+ len = avio_rb32(s->pb);
if ((unsigned) len > INT_MAX/2) {
av_log(s, AV_LOG_ERROR, "Malformed header\n");
@@ -98,9 +98,9 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
switch(chunk_tag){
case MKTAG('C','O','M','M'):
- st->codec->channels = get_be32(s->pb) + 1;
- read_bitrate = get_be32(s->pb);
- rate_flag = get_be32(s->pb);
+ st->codec->channels = avio_rb32(s->pb) + 1;
+ read_bitrate = avio_rb32(s->pb);
+ rate_flag = avio_rb32(s->pb);
url_fskip(s->pb, len-12);
st->codec->bit_rate = read_bitrate*1000;
@@ -208,7 +208,7 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = 8 - c->remaining_bits; // Number of bits to skip
pkt->data[1] = c->last_frame_bits;
- ret = get_buffer(s->pb, pkt->data+2, size);
+ ret = avio_read(s->pb, pkt->data+2, size);
if (ret<=0) {
av_free_packet(pkt);
diff --git a/libavformat/wav.c b/libavformat/wav.c
index 47f0c2e37d..9a6e7619b6 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -143,8 +143,8 @@ AVOutputFormat ff_wav_muxer = {
static int64_t next_tag(AVIOContext *pb, unsigned int *tag)
{
- *tag = get_le32(pb);
- return get_le32(pb);
+ *tag = avio_rl32(pb);
+ return avio_rl32(pb);
}
/* return the size of the found tag */
@@ -197,25 +197,25 @@ static int wav_read_header(AVFormatContext *s,
WAVContext *wav = s->priv_data;
/* check RIFF header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
rf64 = tag == MKTAG('R', 'F', '6', '4');
if (!rf64 && tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
- get_le32(pb); /* file size */
- tag = get_le32(pb);
+ avio_rl32(pb); /* file size */
+ tag = avio_rl32(pb);
if (tag != MKTAG('W', 'A', 'V', 'E'))
return -1;
if (rf64) {
- if (get_le32(pb) != MKTAG('d', 's', '6', '4'))
+ if (avio_rl32(pb) != MKTAG('d', 's', '6', '4'))
return -1;
- size = get_le32(pb);
+ size = avio_rl32(pb);
if (size < 16)
return -1;
- get_le64(pb); /* RIFF size */
- data_size = get_le64(pb);
- sample_count = get_le64(pb);
+ avio_rl64(pb); /* RIFF size */
+ data_size = avio_rl64(pb);
+ sample_count = avio_rl64(pb);
url_fskip(pb, size - 16); /* skip rest of ds64 chunk */
}
@@ -239,7 +239,7 @@ static int wav_read_header(AVFormatContext *s,
if (tag == MKTAG('d', 'a', 't', 'a')){
break;
}else if (tag == MKTAG('f','a','c','t') && !sample_count){
- sample_count = get_le32(pb);
+ sample_count = avio_rl32(pb);
size -= 4;
}
url_fseek(pb, size, SEEK_CUR);
@@ -269,8 +269,8 @@ static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
int64_t size;
while (!url_feof(pb)) {
- get_buffer(pb, guid, 16);
- size = get_le64(pb);
+ avio_read(pb, guid, 16);
+ size = avio_rl64(pb);
if (size <= 24)
return -1;
if (!memcmp(guid, guid1, 16))
@@ -384,14 +384,14 @@ static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st;
uint8_t guid[16];
- get_buffer(pb, guid, 16);
+ avio_read(pb, guid, 16);
if (memcmp(guid, guid_riff, 16))
return -1;
- if (get_le64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
+ if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
return -1;
- get_buffer(pb, guid, 16);
+ avio_read(pb, guid, 16);
if (memcmp(guid, guid_wave, 16)) {
av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
return -1;
diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c
index 4d9ab28e3b..478b46f913 100644
--- a/libavformat/wc3movie.c
+++ b/libavformat/wc3movie.c
@@ -105,8 +105,8 @@ static int wc3_read_header(AVFormatContext *s,
/* traverse through the chunks and load the header information before
* the first BRCH tag */
- fourcc_tag = get_le32(pb);
- size = (get_be32(pb) + 1) & (~1);
+ fourcc_tag = avio_rl32(pb);
+ size = (avio_rb32(pb) + 1) & (~1);
do {
switch (fourcc_tag) {
@@ -127,7 +127,7 @@ static int wc3_read_header(AVFormatContext *s,
buffer = av_malloc(size+1);
if (!buffer)
return AVERROR(ENOMEM);
- if ((ret = get_buffer(pb, buffer, size)) != size)
+ if ((ret = avio_read(pb, buffer, size)) != size)
return AVERROR(EIO);
buffer[size] = 0;
av_metadata_set2(&s->metadata, "title", buffer,
@@ -136,8 +136,8 @@ static int wc3_read_header(AVFormatContext *s,
case SIZE_TAG:
/* video resolution override */
- wc3->width = get_le32(pb);
- wc3->height = get_le32(pb);
+ wc3->width = avio_rl32(pb);
+ wc3->height = avio_rl32(pb);
break;
case PALT_TAG:
@@ -154,9 +154,9 @@ static int wc3_read_header(AVFormatContext *s,
break;
}
- fourcc_tag = get_le32(pb);
+ fourcc_tag = avio_rl32(pb);
/* chunk sizes are 16-bit aligned */
- size = (get_be32(pb) + 1) & (~1);
+ size = (avio_rb32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
@@ -205,9 +205,9 @@ static int wc3_read_packet(AVFormatContext *s,
while (!packet_read) {
- fourcc_tag = get_le32(pb);
+ fourcc_tag = avio_rl32(pb);
/* chunk sizes are 16-bit aligned */
- size = (get_be32(pb) + 1) & (~1);
+ size = (avio_rb32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
@@ -242,7 +242,7 @@ static int wc3_read_packet(AVFormatContext *s,
#if 0
url_fseek(pb, size, SEEK_CUR);
#else
- if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size)
+ if ((unsigned)size > sizeof(text) || (ret = avio_read(pb, text, size)) != size)
ret = AVERROR(EIO);
else {
int i = 0;
diff --git a/libavformat/westwood.c b/libavformat/westwood.c
index 7666bd80b3..b923fef79c 100644
--- a/libavformat/westwood.c
+++ b/libavformat/westwood.c
@@ -130,7 +130,7 @@ static int wsaud_read_header(AVFormatContext *s,
AVStream *st;
unsigned char header[AUD_HEADER_SIZE];
- if (get_buffer(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
+ if (avio_read(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
return AVERROR(EIO);
wsaud->audio_samplerate = AV_RL16(&header[0]);
if (header[11] == 99)
@@ -173,7 +173,7 @@ static int wsaud_read_packet(AVFormatContext *s,
unsigned int chunk_size;
int ret = 0;
- if (get_buffer(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) !=
AUD_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
@@ -237,7 +237,7 @@ static int wsvqa_read_header(AVFormatContext *s,
st->codec->extradata_size = VQA_HEADER_SIZE;
st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
header = (unsigned char *)st->codec->extradata;
- if (get_buffer(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
+ if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
VQA_HEADER_SIZE) {
av_free(st->codec->extradata);
return AVERROR(EIO);
@@ -277,7 +277,7 @@ static int wsvqa_read_header(AVFormatContext *s,
/* there are 0 or more chunks before the FINF chunk; iterate until
* FINF has been skipped and the file will be ready to be demuxed */
do {
- if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
+ if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
av_free(st->codec->extradata);
return AVERROR(EIO);
}
@@ -320,7 +320,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
unsigned int chunk_size;
int skip_byte;
- while (get_buffer(pb, preamble, VQA_PREAMBLE_SIZE) == VQA_PREAMBLE_SIZE) {
+ while (avio_read(pb, preamble, VQA_PREAMBLE_SIZE) == VQA_PREAMBLE_SIZE) {
chunk_type = AV_RB32(&preamble[0]);
chunk_size = AV_RB32(&preamble[4]);
skip_byte = chunk_size & 0x01;
@@ -329,7 +329,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
if (av_new_packet(pkt, chunk_size))
return AVERROR(EIO);
- ret = get_buffer(pb, pkt->data, chunk_size);
+ ret = avio_read(pb, pkt->data, chunk_size);
if (ret != chunk_size) {
av_free_packet(pkt);
return AVERROR(EIO);
diff --git a/libavformat/wtv.c b/libavformat/wtv.c
index e8b6268db3..0ed06aaa58 100644
--- a/libavformat/wtv.c
+++ b/libavformat/wtv.c
@@ -88,7 +88,7 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size)
int remaining_in_sector = (1 << wf->sector_bits) - (wf->position & ((1 << wf->sector_bits) - 1));
int read_request = FFMIN(buf_size - nread, remaining_in_sector);
- n = get_buffer(pb, buf, read_request);
+ n = avio_read(pb, buf, read_request);
if (n <= 0)
break;
nread += n;
@@ -140,7 +140,7 @@ static int read_ints(AVIOContext *pb, uint32_t *data, int count)
{
int i, total = 0;
for (i = 0; i < count; i++) {
- if ((data[total] = get_le32(pb)))
+ if ((data[total] = avio_rl32(pb)))
total++;
}
return total;
@@ -474,9 +474,9 @@ static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
if (strcmp(mime, "image/jpeg"))
goto done;
- get_byte(pb);
+ avio_r8(pb);
avio_get_str16le(pb, INT_MAX, description, sizeof(description));
- filesize = get_le32(pb);
+ filesize = avio_rl32(pb);
if (!filesize)
goto done;
@@ -490,7 +490,7 @@ static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
if (!st->codec->extradata)
goto done;
st->codec->extradata_size = filesize;
- get_buffer(pb, st->codec->extradata, filesize);
+ avio_read(pb, st->codec->extradata, filesize);
done:
url_fseek(pb, pos + length, SEEK_SET);
}
@@ -503,7 +503,7 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
return;
if (type == 0 && length == 4) {
- snprintf(buf, buf_size, "%"PRIi32, get_le32(pb));
+ snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb));
} else if (type == 1) {
avio_get_str16le(pb, length, buf, buf_size);
if (!strlen(buf)) {
@@ -511,9 +511,9 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
return;
}
} else if (type == 3 && length == 4) {
- strcpy(buf, get_le32(pb) ? "true" : "false");
+ strcpy(buf, avio_rl32(pb) ? "true" : "false");
} else if (type == 4 && length == 8) {
- int64_t num = get_le64(pb);
+ int64_t num = avio_rl64(pb);
if (!strcmp(key, "WM/EncodingTime") ||
!strcmp(key, "WM/MediaOriginalBroadcastDateTime"))
filetime_to_iso8601(buf, buf_size, num);
@@ -527,10 +527,10 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
else
snprintf(buf, buf_size, "%"PRIi64, num);
} else if (type == 5 && length == 2) {
- snprintf(buf, buf_size, "%"PRIi16, get_le16(pb));
+ snprintf(buf, buf_size, "%"PRIi16, avio_rl16(pb));
} else if (type == 6 && length == 16) {
ff_asf_guid guid;
- get_buffer(pb, guid, 16);
+ avio_read(pb, guid, 16);
snprintf(buf, buf_size, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));
} else if (type == 2 && !strcmp(key, "WM/Picture")) {
get_attachment(s, pb, length);
@@ -557,8 +557,8 @@ static void parse_legacy_attrib(AVFormatContext *s, AVIOContext *pb)
while(!url_feof(pb)) {
char key[1024];
ff_get_guid(pb, &guid);
- type = get_le32(pb);
- length = get_le32(pb);
+ type = avio_rl32(pb);
+ length = avio_rl32(pb);
if (!length)
break;
if (ff_guidcmp(&guid, metadata_guid)) {
@@ -775,10 +775,10 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
int len, sid, consumed;
ff_get_guid(pb, &g);
- len = get_le32(pb);
+ len = avio_rl32(pb);
if (len < 32)
break;
- sid = get_le32(pb) & 0x7FFF;
+ sid = avio_rl32(pb) & 0x7FFF;
url_fskip(pb, 8);
consumed = 32;
@@ -791,7 +791,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
ff_get_guid(pb, &subtype);
url_fskip(pb, 12);
ff_get_guid(pb, &formattype);
- size = get_le32(pb);
+ size = avio_rl32(pb);
parse_media_type(s, 0, sid, mediatype, subtype, formattype, size);
consumed += 92 + size;
}
@@ -805,7 +805,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
ff_get_guid(pb, &subtype);
url_fskip(pb, 12);
ff_get_guid(pb, &formattype);
- size = get_le32(pb);
+ size = avio_rl32(pb);
parse_media_type(s, s->streams[stream_index], sid, mediatype, subtype, formattype, size);
consumed += 76 + size;
}
@@ -831,7 +831,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
}
buf_size = FFMIN(len - consumed, sizeof(buf));
- get_buffer(pb, buf, buf_size);
+ avio_read(pb, buf, buf_size);
consumed += buf_size;
ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, 0, 0, 0, 0);
}
@@ -841,7 +841,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
AVStream *st = s->streams[stream_index];
int audio_type;
url_fskip(pb, 8);
- audio_type = get_byte(pb);
+ audio_type = avio_r8(pb);
if (audio_type == 2)
st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
else if (audio_type == 3)
@@ -852,7 +852,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
int stream_index = ff_find_stream_index(s, sid);
if (stream_index >= 0) {
url_fskip(pb, 12);
- if (get_le32(pb))
+ if (avio_rl32(pb))
av_log(s, AV_LOG_WARNING, "DVB scrambled stream detected (st:%d), decoding will likely fail\n", stream_index);
consumed += 16;
}
@@ -862,7 +862,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
AVStream *st = s->streams[stream_index];
uint8_t language[4];
url_fskip(pb, 12);
- get_buffer(pb, language, 3);
+ avio_read(pb, language, 3);
if (language[0]) {
language[3] = 0;
av_metadata_set2(&st->metadata, "language", language, 0);
@@ -875,7 +875,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
int stream_index = ff_find_stream_index(s, sid);
if (stream_index >= 0) {
url_fskip(pb, 8);
- wtv->pts = get_le64(pb);
+ wtv->pts = avio_rl64(pb);
consumed += 16;
if (wtv->pts == -1)
wtv->pts = AV_NOPTS_VALUE;
@@ -955,16 +955,16 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
/* read root directory sector */
url_fskip(s->pb, 0x30);
- root_size = get_le32(s->pb);
+ root_size = avio_rl32(s->pb);
if (root_size > sizeof(root)) {
av_log(s, AV_LOG_ERROR, "root directory size exceeds sector size\n");
return AVERROR_INVALIDDATA;
}
url_fskip(s->pb, 4);
- root_sector = get_le32(s->pb);
+ root_sector = avio_rl32(s->pb);
url_fseek(s->pb, root_sector << WTV_SECTOR_BITS, SEEK_SET);
- root_size = get_buffer(s->pb, root, root_size);
+ root_size = avio_read(s->pb, root, root_size);
if (root_size < 0)
return AVERROR_INVALIDDATA;
@@ -995,8 +995,8 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
pb = wtvfile_open(s, root, root_size, table_0_entries_time_le16);
if (pb) {
while(1) {
- uint64_t timestamp = get_le64(pb);
- uint64_t frame_nb = get_le64(pb);
+ uint64_t timestamp = avio_rl64(pb);
+ uint64_t frame_nb = avio_rl64(pb);
if (url_feof(pb))
break;
ff_add_index_entry(&wtv->index_entries, &wtv->nb_index_entries, &wtv->index_entries_allocated_size,
@@ -1009,8 +1009,8 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
if (pb) {
int i;
while (1) {
- uint64_t frame_nb = get_le64(pb);
- uint64_t position = get_le64(pb);
+ uint64_t frame_nb = avio_rl64(pb);
+ uint64_t position = avio_rl64(pb);
if (url_feof(pb))
break;
for (i = wtv->nb_index_entries - 1; i >= 0; i--) {
diff --git a/libavformat/wv.c b/libavformat/wv.c
index 3ee59970c9..fca35b818b 100644
--- a/libavformat/wv.c
+++ b/libavformat/wv.c
@@ -86,25 +86,25 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen
wc->pos = url_ftell(pb);
if(!append){
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('w', 'v', 'p', 'k'))
return -1;
- size = get_le32(pb);
+ size = avio_rl32(pb);
if(size < 24 || size > WV_BLOCK_LIMIT){
av_log(ctx, AV_LOG_ERROR, "Incorrect block size %i\n", size);
return -1;
}
wc->blksize = size;
- ver = get_le16(pb);
+ ver = avio_rl16(pb);
if(ver < 0x402 || ver > 0x410){
av_log(ctx, AV_LOG_ERROR, "Unsupported version %03X\n", ver);
return -1;
}
- get_byte(pb); // track no
- get_byte(pb); // track sub index
- wc->samples = get_le32(pb); // total samples in file
- wc->soff = get_le32(pb); // offset in samples of current block
- get_buffer(pb, wc->extra, WV_EXTRA_SIZE);
+ avio_r8(pb); // track no
+ avio_r8(pb); // track sub index
+ wc->samples = avio_rl32(pb); // total samples in file
+ wc->soff = avio_rl32(pb); // offset in samples of current block
+ avio_read(pb, wc->extra, WV_EXTRA_SIZE);
}else{
size = wc->blksize;
}
@@ -127,8 +127,8 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen
}
while(url_ftell(pb) < block_end){
int id, size;
- id = get_byte(pb);
- size = (id & 0x80) ? get_le24(pb) : get_byte(pb);
+ id = avio_r8(pb);
+ size = (id & 0x80) ? avio_rl24(pb) : avio_r8(pb);
size <<= 1;
if(id&0x40)
size--;
@@ -138,24 +138,24 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen
av_log(ctx, AV_LOG_ERROR, "Insufficient channel information\n");
return -1;
}
- chan = get_byte(pb);
+ chan = avio_r8(pb);
switch(size - 2){
case 0:
- chmask = get_byte(pb);
+ chmask = avio_r8(pb);
break;
case 1:
- chmask = get_le16(pb);
+ chmask = avio_rl16(pb);
break;
case 2:
- chmask = get_le24(pb);
+ chmask = avio_rl24(pb);
break;
case 3:
- chmask = get_le32(pb);
+ chmask = avio_rl32(pb);
break;
case 5:
url_fskip(pb, 1);
- chan |= (get_byte(pb) & 0xF) << 8;
- chmask = get_le24(pb);
+ chan |= (avio_r8(pb) & 0xF) << 8;
+ chmask = avio_rl24(pb);
break;
default:
av_log(ctx, AV_LOG_ERROR, "Invalid channel info size %d\n", size);
@@ -163,7 +163,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb, int appen
}
break;
case 0x27:
- rate = get_le24(pb);
+ rate = avio_rl24(pb);
break;
default:
url_fskip(pb, size);
@@ -254,13 +254,13 @@ static int wv_read_packet(AVFormatContext *s,
if(wc->multichannel)
AV_WL32(pkt->data, wc->blksize + WV_EXTRA_SIZE + 12);
memcpy(pkt->data + off, wc->extra, WV_EXTRA_SIZE);
- ret = get_buffer(s->pb, pkt->data + WV_EXTRA_SIZE + off, wc->blksize);
+ ret = avio_read(s->pb, pkt->data + WV_EXTRA_SIZE + off, wc->blksize);
if(ret != wc->blksize){
av_free_packet(pkt);
return AVERROR(EIO);
}
while(!(wc->flags & WV_END_BLOCK)){
- if(get_le32(s->pb) != MKTAG('w', 'v', 'p', 'k')){
+ if(avio_rl32(s->pb) != MKTAG('w', 'v', 'p', 'k')){
av_free_packet(pkt);
return -1;
}
@@ -275,16 +275,16 @@ static int wv_read_packet(AVFormatContext *s,
return -1;
}
wc->blksize = size;
- ver = get_le16(s->pb);
+ ver = avio_rl16(s->pb);
if(ver < 0x402 || ver > 0x410){
av_free_packet(pkt);
av_log(s, AV_LOG_ERROR, "Unsupported version %03X\n", ver);
return -1;
}
- get_byte(s->pb); // track no
- get_byte(s->pb); // track sub index
- wc->samples = get_le32(s->pb); // total samples in file
- wc->soff = get_le32(s->pb); // offset in samples of current block
+ avio_r8(s->pb); // track no
+ avio_r8(s->pb); // track sub index
+ wc->samples = avio_rl32(s->pb); // total samples in file
+ wc->soff = avio_rl32(s->pb); // offset in samples of current block
if((ret = av_append_packet(s->pb, pkt, WV_EXTRA_SIZE)) < 0){
av_free_packet(pkt);
return ret;
diff --git a/libavformat/xa.c b/libavformat/xa.c
index 504c9b20d6..858a74201e 100644
--- a/libavformat/xa.c
+++ b/libavformat/xa.c
@@ -77,14 +77,14 @@ static int xa_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_EA_MAXIS_XA;
url_fskip(pb, 4); /* Skip the XA ID */
- xa->out_size = get_le32(pb);
+ xa->out_size = avio_rl32(pb);
url_fskip(pb, 2); /* Skip the tag */
- st->codec->channels = get_le16(pb);
- st->codec->sample_rate = get_le32(pb);
+ st->codec->channels = avio_rl16(pb);
+ st->codec->sample_rate = avio_rl32(pb);
/* Value in file is average byte rate*/
- st->codec->bit_rate = get_le32(pb) * 8;
- st->codec->block_align = get_le16(pb);
- st->codec->bits_per_coded_sample = get_le16(pb);
+ st->codec->bit_rate = avio_rl32(pb) * 8;
+ st->codec->block_align = avio_rl16(pb);
+ st->codec->bits_per_coded_sample = avio_rl16(pb);
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
diff --git a/libavformat/yop.c b/libavformat/yop.c
index 9e7b8efe77..2e58cc660a 100644
--- a/libavformat/yop.c
+++ b/libavformat/yop.c
@@ -83,14 +83,14 @@ static int yop_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(pb, 6);
- frame_rate = get_byte(pb);
- yop->frame_size = get_byte(pb) * 2048;
- video_dec->width = get_le16(pb);
- video_dec->height = get_le16(pb);
+ frame_rate = avio_r8(pb);
+ yop->frame_size = avio_r8(pb) * 2048;
+ video_dec->width = avio_rl16(pb);
+ video_dec->height = avio_rl16(pb);
video_stream->sample_aspect_ratio = (AVRational){1, 2};
- ret = get_buffer(pb, video_dec->extradata, 8);
+ ret = avio_read(pb, video_dec->extradata, 8);
if (ret < 8)
return ret < 0 ? ret : AVERROR_EOF;
@@ -138,7 +138,7 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
yop->video_packet.pos = url_ftell(pb);
- ret = get_buffer(pb, yop->video_packet.data, yop->palette_size);
+ ret = avio_read(pb, yop->video_packet.data, yop->palette_size);
if (ret < 0) {
goto err_out;
}else if (ret < yop->palette_size) {
@@ -155,7 +155,7 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
url_fskip(pb, yop->audio_block_length - ret);
- ret = get_buffer(pb, yop->video_packet.data + yop->palette_size,
+ ret = avio_read(pb, yop->video_packet.data + yop->palette_size,
actual_video_data_size);
if (ret < 0)
goto err_out;
diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c
index ac3010e694..54b77370af 100644
--- a/libavformat/yuv4mpeg.c
+++ b/libavformat/yuv4mpeg.c
@@ -200,7 +200,7 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap)
struct frame_attributes *s1 = s->priv_data;
for (i=0; i<MAX_YUV4_HEADER; i++) {
- header[i] = get_byte(pb);
+ header[i] = avio_r8(pb);
if (header[i] == '\n') {
header[i+1] = 0x20; // Add a space after last option. Makes parsing "444" vs "444alpha" easier.
header[i+2] = 0;
@@ -352,7 +352,7 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
struct frame_attributes *s1 = s->priv_data;
for (i=0; i<MAX_FRAME_HEADER; i++) {
- header[i] = get_byte(s->pb);
+ header[i] = avio_r8(s->pb);
if (header[i] == '\n') {
header[i+1] = 0;
break;