Commit b7effd4e authored by Anton Khirnov's avatar Anton Khirnov Committed by Ronald S. Bultje

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: default avatarRonald S. Bultje <rsbultje@gmail.com>
parent f8bed30d
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
#define strk_SIZE 0x28 #define strk_SIZE 0x28
#define GET_LIST_HEADER() \ #define GET_LIST_HEADER() \
fourcc_tag = get_le32(pb); \ fourcc_tag = avio_rl32(pb); \
size = get_le32(pb); \ size = avio_rl32(pb); \
if (fourcc_tag != LIST_TAG) \ if (fourcc_tag != LIST_TAG) \
return AVERROR_INVALIDDATA; \ return AVERROR_INVALIDDATA; \
fourcc_tag = get_le32(pb); fourcc_tag = avio_rl32(pb);
typedef struct AudioTrack { typedef struct AudioTrack {
int sample_rate; int sample_rate;
...@@ -118,7 +118,7 @@ static int fourxm_read_header(AVFormatContext *s, ...@@ -118,7 +118,7 @@ static int fourxm_read_header(AVFormatContext *s,
header = av_malloc(header_size); header = av_malloc(header_size);
if (!header) if (!header)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (get_buffer(pb, header, header_size) != header_size){ if (avio_read(pb, header, header_size) != header_size){
av_free(header); av_free(header);
return AVERROR(EIO); return AVERROR(EIO);
} }
...@@ -255,7 +255,7 @@ static int fourxm_read_packet(AVFormatContext *s, ...@@ -255,7 +255,7 @@ static int fourxm_read_packet(AVFormatContext *s,
while (!packet_read) { while (!packet_read) {
if ((ret = get_buffer(s->pb, header, 8)) < 0) if ((ret = avio_read(s->pb, header, 8)) < 0)
return ret; return ret;
fourcc_tag = AV_RL32(&header[0]); fourcc_tag = AV_RL32(&header[0]);
size = AV_RL32(&header[4]); size = AV_RL32(&header[4]);
...@@ -268,7 +268,7 @@ static int fourxm_read_packet(AVFormatContext *s, ...@@ -268,7 +268,7 @@ static int fourxm_read_packet(AVFormatContext *s,
fourxm->video_pts ++; fourxm->video_pts ++;
/* skip the LIST-* tag and move on to the next fourcc */ /* skip the LIST-* tag and move on to the next fourcc */
get_le32(pb); avio_rl32(pb);
break; break;
case ifrm_TAG: case ifrm_TAG:
...@@ -285,7 +285,7 @@ static int fourxm_read_packet(AVFormatContext *s, ...@@ -285,7 +285,7 @@ static int fourxm_read_packet(AVFormatContext *s,
pkt->pts = fourxm->video_pts; pkt->pts = fourxm->video_pts;
pkt->pos = url_ftell(s->pb); pkt->pos = url_ftell(s->pb);
memcpy(pkt->data, header, 8); 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){ if (ret < 0){
av_free_packet(pkt); av_free_packet(pkt);
...@@ -294,8 +294,8 @@ static int fourxm_read_packet(AVFormatContext *s, ...@@ -294,8 +294,8 @@ static int fourxm_read_packet(AVFormatContext *s,
break; break;
case snd__TAG: case snd__TAG:
track_number = get_le32(pb); track_number = avio_rl32(pb);
out_size= get_le32(pb); out_size= avio_rl32(pb);
size-=8; size-=8;
if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) { if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) {
......
...@@ -63,7 +63,7 @@ static int aea_read_header(AVFormatContext *s, ...@@ -63,7 +63,7 @@ static int aea_read_header(AVFormatContext *s,
/* Parse the amount of channels and skip to pos 2048(0x800) */ /* Parse the amount of channels and skip to pos 2048(0x800) */
url_fskip(s->pb, 264); url_fskip(s->pb, 264);
st->codec->channels = get_byte(s->pb); st->codec->channels = avio_r8(s->pb);
url_fskip(s->pb, 1783); url_fskip(s->pb, 1783);
......
...@@ -54,8 +54,8 @@ static int get_tag(AVIOContext *pb, uint32_t * tag) ...@@ -54,8 +54,8 @@ static int get_tag(AVIOContext *pb, uint32_t * tag)
if (url_feof(pb)) if (url_feof(pb))
return AVERROR(EIO); return AVERROR(EIO);
*tag = get_le32(pb); *tag = avio_rl32(pb);
size = get_be32(pb); size = avio_rb32(pb);
if (size < 0) if (size < 0)
size = 0x7fffffff; size = 0x7fffffff;
...@@ -74,7 +74,7 @@ static void get_meta(AVFormatContext *s, const char *key, int size) ...@@ -74,7 +74,7 @@ static void get_meta(AVFormatContext *s, const char *key, int size)
return; return;
} }
res = get_buffer(s->pb, str, size); res = avio_read(s->pb, str, size);
if (res < 0) if (res < 0)
return; return;
...@@ -93,18 +93,18 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, ...@@ -93,18 +93,18 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec,
if (size & 1) if (size & 1)
size++; size++;
codec->codec_type = AVMEDIA_TYPE_AUDIO; codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->channels = get_be16(pb); codec->channels = avio_rb16(pb);
num_frames = get_be32(pb); num_frames = avio_rb32(pb);
codec->bits_per_coded_sample = get_be16(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 */ sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */
codec->sample_rate = sample_rate; codec->sample_rate = sample_rate;
size -= 18; size -= 18;
/* Got an AIFF-C? */ /* Got an AIFF-C? */
if (version == AIFF_C_VERSION1) { 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); codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
switch (codec->codec_id) { switch (codec->codec_id) {
...@@ -187,7 +187,7 @@ static int aiff_read_header(AVFormatContext *s, ...@@ -187,7 +187,7 @@ static int aiff_read_header(AVFormatContext *s,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
/* AIFF data type */ /* AIFF data type */
tag = get_le32(pb); tag = avio_rl32(pb);
if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */ if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */
version = AIFF; version = AIFF;
else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */ else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */
...@@ -217,7 +217,7 @@ static int aiff_read_header(AVFormatContext *s, ...@@ -217,7 +217,7 @@ static int aiff_read_header(AVFormatContext *s,
goto got_sound; goto got_sound;
break; break;
case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */ case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */
version = get_be32(pb); version = avio_rb32(pb);
break; break;
case MKTAG('N', 'A', 'M', 'E'): /* Sample name chunk */ case MKTAG('N', 'A', 'M', 'E'): /* Sample name chunk */
get_meta(s, "title" , size); get_meta(s, "title" , size);
...@@ -233,8 +233,8 @@ static int aiff_read_header(AVFormatContext *s, ...@@ -233,8 +233,8 @@ static int aiff_read_header(AVFormatContext *s,
break; break;
case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */ case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
aiff->data_end = url_ftell(pb) + size; aiff->data_end = url_ftell(pb) + size;
offset = get_be32(pb); /* Offset of sound data */ offset = avio_rb32(pb); /* Offset of sound data */
get_be32(pb); /* BlockSize... don't care */ avio_rb32(pb); /* BlockSize... don't care */
offset += url_ftell(pb); /* Compute absolute data offset */ offset += url_ftell(pb); /* Compute absolute data offset */
if (st->codec->block_align) /* Assume COMM already parsed */ if (st->codec->block_align) /* Assume COMM already parsed */
goto got_sound; goto got_sound;
...@@ -251,7 +251,7 @@ static int aiff_read_header(AVFormatContext *s, ...@@ -251,7 +251,7 @@ static int aiff_read_header(AVFormatContext *s,
if (!st->codec->extradata) if (!st->codec->extradata)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
st->codec->extradata_size = size; st->codec->extradata_size = size;
get_buffer(pb, st->codec->extradata, size); avio_read(pb, st->codec->extradata, size);
break; break;
default: /* Jump */ default: /* Jump */
if (size & 1) /* Always even aligned */ if (size & 1) /* Always even aligned */
......
...@@ -82,7 +82,7 @@ static int amr_read_header(AVFormatContext *s, ...@@ -82,7 +82,7 @@ static int amr_read_header(AVFormatContext *s,
AVStream *st; AVStream *st;
uint8_t header[9]; uint8_t header[9];
get_buffer(pb, header, 6); avio_read(pb, header, 6);
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
...@@ -91,7 +91,7 @@ static int amr_read_header(AVFormatContext *s, ...@@ -91,7 +91,7 @@ static int amr_read_header(AVFormatContext *s,
} }
if(memcmp(header,AMR_header,6)!=0) 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) if(memcmp(header,AMRWB_header,9)!=0)
{ {
return -1; return -1;
...@@ -128,7 +128,7 @@ static int amr_read_packet(AVFormatContext *s, ...@@ -128,7 +128,7 @@ static int amr_read_packet(AVFormatContext *s,
} }
//FIXME this is wrong, this should rather be in a AVParset //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; mode = (toc >> 3) & 0x0F;
if (enc->codec_id == CODEC_ID_AMR_NB) if (enc->codec_id == CODEC_ID_AMR_NB)
...@@ -157,7 +157,7 @@ static int amr_read_packet(AVFormatContext *s, ...@@ -157,7 +157,7 @@ static int amr_read_packet(AVFormatContext *s,
pkt->pos= url_ftell(s->pb); pkt->pos= url_ftell(s->pb);
pkt->data[0]=toc; pkt->data[0]=toc;
pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320; 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) if (read != size-1)
{ {
......
...@@ -84,16 +84,16 @@ static int read_header(AVFormatContext *s, ...@@ -84,16 +84,16 @@ static int read_header(AVFormatContext *s,
int i, ret; int i, ret;
url_fskip(pb, 4); /* magic number */ 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"); av_log_ask_for_sample(s, "max_pages != " AV_STRINGIFY(MAX_PAGES) "\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
anm->nb_pages = get_le16(pb); anm->nb_pages = avio_rl16(pb);
anm->nb_records = get_le32(pb); anm->nb_records = avio_rl32(pb);
url_fskip(pb, 2); /* max records per page */ url_fskip(pb, 2); /* max records per page */
anm->page_table_offset = get_le16(pb); anm->page_table_offset = avio_rl16(pb);
if (get_le32(pb) != ANIM_TAG) if (avio_rl32(pb) != ANIM_TAG)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
/* video stream */ /* video stream */
...@@ -103,32 +103,32 @@ static int read_header(AVFormatContext *s, ...@@ -103,32 +103,32 @@ static int read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ANM; st->codec->codec_id = CODEC_ID_ANM;
st->codec->codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = get_le16(pb); st->codec->width = avio_rl16(pb);
st->codec->height = get_le16(pb); st->codec->height = avio_rl16(pb);
if (get_byte(pb) != 0) if (avio_r8(pb) != 0)
goto invalid; goto invalid;
url_fskip(pb, 1); /* frame rate multiplier info */ url_fskip(pb, 1); /* frame rate multiplier info */
/* ignore last delta record (used for looping) */ /* 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); anm->nb_records = FFMAX(anm->nb_records - 1, 0);
url_fskip(pb, 1); /* last_delta_valid */ url_fskip(pb, 1); /* last_delta_valid */
if (get_byte(pb) != 0) if (avio_r8(pb) != 0)
goto invalid; goto invalid;
if (get_byte(pb) != 1) if (avio_r8(pb) != 1)
goto invalid; goto invalid;
url_fskip(pb, 1); /* other recs per frame */ url_fskip(pb, 1); /* other recs per frame */
if (get_byte(pb) != 1) if (avio_r8(pb) != 1)
goto invalid; goto invalid;
url_fskip(pb, 32); /* record_types */ url_fskip(pb, 32); /* record_types */
st->nb_frames = get_le32(pb); st->nb_frames = avio_rl32(pb);
av_set_pts_info(st, 64, 1, get_le16(pb)); av_set_pts_info(st, 64, 1, avio_rl16(pb));
url_fskip(pb, 58); url_fskip(pb, 58);
/* color cycling and palette data */ /* color cycling and palette data */
...@@ -138,7 +138,7 @@ static int read_header(AVFormatContext *s, ...@@ -138,7 +138,7 @@ static int read_header(AVFormatContext *s,
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto close_and_return; 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) if (ret < 0)
goto close_and_return; goto close_and_return;
...@@ -149,9 +149,9 @@ static int read_header(AVFormatContext *s, ...@@ -149,9 +149,9 @@ static int read_header(AVFormatContext *s,
for (i = 0; i < MAX_PAGES; i++) { for (i = 0; i < MAX_PAGES; i++) {
Page *p = &anm->pt[i]; Page *p = &anm->pt[i];
p->base_record = get_le16(pb); p->base_record = avio_rl16(pb);
p->nb_records = get_le16(pb); p->nb_records = avio_rl16(pb);
p->size = get_le16(pb); p->size = avio_rl16(pb);
} }
/* find page of first frame */ /* find page of first frame */
...@@ -211,7 +211,7 @@ repeat: ...@@ -211,7 +211,7 @@ repeat:
tmp = url_ftell(pb); tmp = url_ftell(pb);
url_fseek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) + url_fseek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) +
8 + anm->record * 2, SEEK_SET); 8 + anm->record * 2, SEEK_SET);
record_size = get_le16(pb); record_size = avio_rl16(pb);
url_fseek(pb, tmp, SEEK_SET); url_fseek(pb, tmp, SEEK_SET);
/* fetch record */ /* fetch record */
......
...@@ -35,9 +35,9 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -35,9 +35,9 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
AVStream *st; AVStream *st;
get_le32(pb); /* CRYO */ avio_rl32(pb); /* CRYO */
get_le32(pb); /* _APC */ avio_rl32(pb); /* _APC */
get_le32(pb); /* 1.20 */ avio_rl32(pb); /* 1.20 */
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
...@@ -46,8 +46,8 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -46,8 +46,8 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS; st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
get_le32(pb); /* number of samples */ avio_rl32(pb); /* number of samples */
st->codec->sample_rate = get_le32(pb); st->codec->sample_rate = avio_rl32(pb);
st->codec->extradata_size = 2 * 4; st->codec->extradata_size = 2 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size + st->codec->extradata = av_malloc(st->codec->extradata_size +
...@@ -56,10 +56,10 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -56,10 +56,10 @@ static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
/* initial predictor values for adpcm decoder */ /* 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; st->codec->channels = 1;
if (get_le32(pb)) if (avio_rl32(pb))
st->codec->channels = 2; st->codec->channels = 2;
st->codec->bits_per_coded_sample = 4; st->codec->bits_per_coded_sample = 4;
......
...@@ -162,11 +162,11 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) ...@@ -162,11 +162,11 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
/* TODO: Skip any leading junk such as id3v2 tags */ /* TODO: Skip any leading junk such as id3v2 tags */
ape->junklength = 0; ape->junklength = 0;
tag = get_le32(pb); tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' ')) if (tag != MKTAG('M', 'A', 'C', ' '))
return -1; return -1;
ape->fileversion = get_le16(pb); ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) { 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); 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) ...@@ -174,15 +174,15 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
} }
if (ape->fileversion >= 3980) { if (ape->fileversion >= 3980) {
ape->padding1 = get_le16(pb); ape->padding1 = avio_rl16(pb);
ape->descriptorlength = get_le32(pb); ape->descriptorlength = avio_rl32(pb);
ape->headerlength = get_le32(pb); ape->headerlength = avio_rl32(pb);
ape->seektablelength = get_le32(pb); ape->seektablelength = avio_rl32(pb);
ape->wavheaderlength = get_le32(pb); ape->wavheaderlength = avio_rl32(pb);
ape->audiodatalength = get_le32(pb); ape->audiodatalength = avio_rl32(pb);
ape->audiodatalength_high = get_le32(pb); ape->audiodatalength_high = avio_rl32(pb);
ape->wavtaillength = get_le32(pb); ape->wavtaillength = avio_rl32(pb);
get_buffer(pb, ape->md5, 16); avio_read(pb, ape->md5, 16);
/* Skip any unknown bytes at the end of the descriptor. /* Skip any unknown bytes at the end of the descriptor.
This is for future compatibility */ This is for future compatibility */
...@@ -190,26 +190,26 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) ...@@ -190,26 +190,26 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
url_fseek(pb, ape->descriptorlength - 52, SEEK_CUR); url_fseek(pb, ape->descriptorlength - 52, SEEK_CUR);
/* Read header data */ /* Read header data */
ape->compressiontype = get_le16(pb); ape->compressiontype = avio_rl16(pb);
ape->formatflags = get_le16(pb); ape->formatflags = avio_rl16(pb);
ape->blocksperframe = get_le32(pb); ape->blocksperframe = avio_rl32(pb);
ape->finalframeblocks = get_le32(pb); ape->finalframeblocks = avio_rl32(pb);
ape->totalframes = get_le32(pb); ape->totalframes = avio_rl32(pb);
ape->bps = get_le16(pb); ape->bps = avio_rl16(pb);
ape->channels = get_le16(pb); ape->channels = avio_rl16(pb);
ape->samplerate = get_le32(pb); ape->samplerate = avio_rl32(pb);
} else { } else {
ape->descriptorlength = 0; ape->descriptorlength = 0;
ape->headerlength = 32; ape->headerlength = 32;
ape->compressiontype = get_le16(pb); ape->compressiontype = avio_rl16(pb);
ape->formatflags = get_le16(pb); ape->formatflags = avio_rl16(pb);
ape->channels = get_le16(pb); ape->channels = avio_rl16(pb);
ape->samplerate = get_le32(pb); ape->samplerate = avio_rl32(pb);
ape->wavheaderlength = get_le32(pb); ape->wavheaderlength = avio_rl32(pb);
ape->wavtaillength = get_le32(pb); ape->wavtaillength = avio_rl32(pb);
ape->totalframes = get_le32(pb); ape->totalframes = avio_rl32(pb);
ape->finalframeblocks = get_le32(pb); ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) { if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
url_fseek(pb, 4, SEEK_CUR); /* Skip the 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) ...@@ -217,7 +217,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
} }
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) { if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
ape->seektablelength = get_le32(pb); ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4; ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t); ape->seektablelength *= sizeof(int32_t);
} else } else
...@@ -260,7 +260,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) ...@@ -260,7 +260,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
if (ape->seektablelength > 0) { if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength); ape->seektable = av_malloc(ape->seektablelength);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++) 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; ape->frames[0].pos = ape->firstframe;
...@@ -355,7 +355,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt) ...@@ -355,7 +355,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
AV_WL32(pkt->data , nblocks); AV_WL32(pkt->data , nblocks);
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip); 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->pts = ape->frames[ape->currentframe].pts;
pkt->stream_index = 0; pkt->stream_index = 0;
......
...@@ -38,10 +38,10 @@ static int ape_tag_read_field(AVFormatContext *s) ...@@ -38,10 +38,10 @@ static int ape_tag_read_field(AVFormatContext *s)
uint32_t size, flags; uint32_t size, flags;
int i, c; int i, c;
size = get_le32(pb); /* field size */ size = avio_rl32(pb); /* field size */
flags = get_le32(pb); /* field flags */ flags = avio_rl32(pb); /* field flags */
for (i = 0; i < sizeof(key) - 1; i++) { for (i = 0; i < sizeof(key) - 1; i++) {
c = get_byte(pb); c = avio_r8(pb);
if (c < 0x20 || c > 0x7E) if (c < 0x20 || c > 0x7E)
break; break;
else else
...@@ -57,7 +57,7 @@ static int ape_tag_read_field(AVFormatContext *s) ...@@ -57,7 +57,7 @@ static int ape_tag_read_field(AVFormatContext *s)
value = av_malloc(size+1); value = av_malloc(size+1);
if (!value) if (!value)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
get_buffer(pb, value, size); avio_read(pb, value, size);
value[size] = 0; value[size] = 0;
av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL); av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
return 0; return 0;
...@@ -76,30 +76,30 @@ void ff_ape_parse_tag(AVFormatContext *s) ...@@ -76,30 +76,30 @@ void ff_ape_parse_tag(AVFormatContext *s)
url_fseek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET); 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)) { if (strncmp(buf, "APETAGEX", 8)) {
return; return;
} }
val = get_le32(pb); /* APE tag version */ val = avio_rl32(pb); /* APE tag version */
if (val > APE_TAG_VERSION) { if (val > APE_TAG_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION); av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION);
return; 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)) { if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) {
av_log(s, AV_LOG_ERROR, "Tag size is way too big\n"); av_log(s, AV_LOG_ERROR, "Tag size is way too big\n");
return; return;
} }
fields = get_le32(pb); /* number of fields */ fields = avio_rl32(pb); /* number of fields */
if (fields > 65536) { if (fields > 65536) {
av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields); av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields);
return; return;
} }
val = get_le32(pb); /* flags */ val = avio_rl32(pb); /* flags */
if (val & APE_TAG_FLAG_IS_HEADER) { if (val & APE_TAG_FLAG_IS_HEADER) {
av_log(s, AV_LOG_ERROR, "APE Tag is a header\n"); av_log(s, AV_LOG_ERROR, "APE Tag is a header\n");
return; return;
......