Skip to content

Commit

Permalink
avio: avio_ prefixes for get_* functions
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit b7effd4)
  • Loading branch information
elenril authored and michaelni committed Feb 22, 2011
1 parent 6a786b1 commit e63a362
Show file tree
Hide file tree
Showing 107 changed files with 1,823 additions and 1,778 deletions.
18 changes: 9 additions & 9 deletions libavformat/4xm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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]);
Expand All @@ -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:
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion libavformat/aea.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
26 changes: 13 additions & 13 deletions libavformat/aiffdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions libavformat/amr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
38 changes: 19 additions & 19 deletions libavformat/anm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand All @@ -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;

Expand All @@ -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 */
Expand Down Expand Up @@ -211,7 +211,7 @@ static int read_packet(AVFormatContext *s,
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 */
Expand Down
14 changes: 7 additions & 7 deletions libavformat/apc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 +
Expand All @@ -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;
Expand Down
Loading

0 comments on commit e63a362

Please sign in to comment.