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: 's 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;
......
This diff is collapsed.
...@@ -127,15 +127,15 @@ static int au_read_header(AVFormatContext *s, ...@@ -127,15 +127,15 @@ static int au_read_header(AVFormatContext *s,
AVStream *st; AVStream *st;
/* check ".snd" header */ /* check ".snd" header */
tag = get_le32(pb); tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd')) if (tag != MKTAG('.', 's', 'n', 'd'))
return -1; return -1;
size = get_be32(pb); /* header size */ size = avio_rb32(pb); /* header size */
get_be32(pb); /* data size */ avio_rb32(pb); /* data size */
id = get_be32(pb); id = avio_rb32(pb);
rate = get_be32(pb); rate = avio_rb32(pb);
channels = get_be32(pb); channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id); codec = ff_codec_get_id(codec_au_tags, id);
......
This diff is collapsed.
...@@ -378,6 +378,25 @@ attribute_deprecated AVIOContext *av_alloc_put_byte( ...@@ -378,6 +378,25 @@ attribute_deprecated AVIOContext *av_alloc_put_byte(
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_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)); 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 #endif
AVIOContext *avio_alloc_context( AVIOContext *avio_alloc_context(
...@@ -477,7 +496,7 @@ void put_flush_packet(AVIOContext *s); ...@@ -477,7 +496,7 @@ void put_flush_packet(AVIOContext *s);
* Read size bytes from AVIOContext into buf. * Read size bytes from AVIOContext into buf.
* @return number of bytes read or AVERROR * @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. * Read size bytes from AVIOContext into buf.
...@@ -489,11 +508,11 @@ int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size); ...@@ -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 /** @note return 0 if EOF, so you cannot use it if EOF handling is
necessary */ necessary */
int get_byte(AVIOContext *s); int avio_r8 (AVIOContext *s);
unsigned int get_le24(AVIOContext *s); unsigned int avio_rl16(AVIOContext *s);
unsigned int get_le32(AVIOContext *s); unsigned int avio_rl24(AVIOContext *s);
uint64_t get_le64(AVIOContext *s); unsigned int avio_rl32(AVIOContext *s);
unsigned int get_le16(AVIOContext *s); uint64_t avio_rl64(AVIOContext *s);
/** /**
* Read a UTF-16 string from pb and convert it to UTF-8. * 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); ...@@ -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); int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
char *get_strz(AVIOContext *s, char *buf, int maxlen); char *get_strz(AVIOContext *s, char *buf, int maxlen);
unsigned int get_be16(AVIOContext *s); unsigned int avio_rb16(AVIOContext *s);
unsigned int get_be24(AVIOContext *s); unsigned int avio_rb24(AVIOContext *s);
unsigned int get_be32(AVIOContext *s); unsigned int avio_rb32(AVIOContext *s);
uint64_t get_be64(AVIOContext *s); uint64_t avio_rb64(AVIOContext *s);
uint64_t ff_get_v(AVIOContext *bc); uint64_t ff_get_v(AVIOContext *bc);
......
...@@ -298,6 +298,32 @@ void put_strz(AVIOContext *s, const char *str) ...@@ -298,6 +298,32 @@ void put_strz(AVIOContext *s, const char *str)
{ {
avio_put_str(s, 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 #endif
int avio_put_str(AVIOContext *s, const char *str) int avio_put_str(AVIOContext *s, const char *str)
...@@ -457,7 +483,7 @@ void init_checksum(AVIOContext *s, ...@@ -457,7 +483,7 @@ void init_checksum(AVIOContext *s,
} }
/* XXX: put an inline version */ /* XXX: put an inline version */
int get_byte(AVIOContext *s) int avio_r8(AVIOContext *s)
{ {
if (s->buf_ptr >= s->buf_end) if (s->buf_ptr >= s->buf_end)
fill_buffer(s); fill_buffer(s);
...@@ -475,7 +501,7 @@ int url_fgetc(AVIOContext *s) ...@@ -475,7 +501,7 @@ int url_fgetc(AVIOContext *s)
return URL_EOF; 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; int len, size1;
...@@ -545,58 +571,58 @@ int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size) ...@@ -545,58 +571,58 @@ int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size)
return len; return len;
} }
unsigned int get_le16(AVIOContext *s) unsigned int avio_rl16(AVIOContext *s)
{ {
unsigned int val; unsigned int val;
val = get_byte(s); val = avio_r8(s);
val |= get_byte(s) << 8; val |= avio_r8(s) << 8;
return val; return val;
} }
unsigned int get_le24(AVIOContext *s) unsigned int avio_rl24(AVIOContext *s)
{ {
unsigned int val; unsigned int val;
val = get_le16(s); val = avio_rl16(s);
val |= get_byte(s) << 16; val |= avio_r8(s) << 16;
return val; return val;
} }
unsigned int get_le32(AVIOContext *s) unsigned int avio_rl32(AVIOContext *s)
{ {
unsigned int val; unsigned int val;
val = get_le16(s); val = avio_rl16(s);
val |= get_le16(s) << 16; val |= avio_rl16(s) << 16;
return val; return val;
} }
uint64_t get_le64(AVIOContext *s) uint64_t avio_rl64(AVIOContext *s)
{ {
uint64_t val; uint64_t val;
val = (uint64_t)get_le32(s); val = (uint64_t)avio_rl32(s);
val |= (uint64_t)get_le32(s) << 32; val |= (uint64_t)avio_rl32(s) << 32;
return val; return val;
} }
unsigned int get_be16(AVIOContext *s) unsigned int avio_rb16(AVIOContext *s)
{ {
unsigned int val; unsigned int val;
val = get_byte(s) << 8; val = avio_r8(s) << 8;
val |= get_byte(s); val |= avio_r8(s);
return val; return val;
} }
unsigned int get_be24(AVIOContext *s) unsigned int avio_rb24(AVIOContext *s)
{ {
unsigned int val; unsigned int val;
val = get_be16(s) << 8; val = avio_rb16(s) << 8;
val |= get_byte(s); val |= avio_r8(s);
return val; return val;
} }
unsigned int get_be32(AVIOContext *s) unsigned int avio_rb32(AVIOContext *s)
{ {
unsigned int val; unsigned int val;
val = get_be16(s) << 16; val = avio_rb16(s) << 16;
val |= get_be16(s); val |= avio_rb16(s);
return val; return val;
} }
...@@ -605,7 +631,7 @@ char *get_strz(AVIOContext *s, char *buf, int maxlen) ...@@ -605,7 +631,7 @@ char *get_strz(AVIOContext *s, char *buf, int maxlen)
int i = 0; int i = 0;
char c; char c;
while ((c = get_byte(s))) { while ((c = avio_r8(s))) {
if (i < maxlen-1) if (i < maxlen-1)
buf[i++] = c; buf[i++] = c;
} }
...@@ -621,7 +647,7 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen) ...@@ -621,7 +647,7 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
char c; char c;
do { do {
c = get_byte(s); c = avio_r8(s);
if (c && i < maxlen-1) if (c && i < maxlen-1)
buf[i++] = c; buf[i++] = c;
} while (c != '\n' && c); } while (c != '\n' && c);
...@@ -647,16 +673,16 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen) ...@@ -647,16 +673,16 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
return ret;\ return ret;\
}\ }\
GET_STR16(le, get_le16) GET_STR16(le, avio_rl16)
GET_STR16(be, get_be16) GET_STR16(be, avio_rb16)
#undef GET_STR16 #undef GET_STR16
uint64_t get_be64(AVIOContext *s) uint64_t avio_rb64(AVIOContext *s)
{ {
uint64_t val; uint64_t val;
val = (uint64_t)get_be32(s) << 32; val = (uint64_t)avio_rb32(s) << 32;
val |= (uint64_t)get_be32(s); val |= (uint64_t)avio_rb32(s);
return val; return val;
} }
...@@ -665,7 +691,7 @@ uint64_t ff_get_v(AVIOContext *bc){ ...@@ -665,7 +691,7 @@ uint64_t ff_get_v(AVIOContext *bc){
int tmp; int tmp;
do{ do{
tmp = get_byte(bc); tmp = avio_r8(bc);
val= (val<<7) + (tmp&127); val= (val<<7) + (tmp&127);
}while(tmp&128); }while(tmp&128);
return val; return val;
......
...@@ -62,11 +62,11 @@ static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap) ...@@ -62,11 +62,11 @@ static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap)
s->ctx_flags |= AVFMTCTX_NOHEADER; s->ctx_flags |= AVFMTCTX_NOHEADER;
url_fskip(s->pb, 4); url_fskip(s->pb, 4);
avs->width = get_le16(s->pb); avs->width = avio_rl16(s->pb);
avs->height = get_le16(s->pb); avs->height = avio_rl16(s->pb);
avs->bits_per_sample = get_le16(s->pb); avs->bits_per_sample = avio_rl16(s->pb);
avs->fps = get_le16(s->pb); avs->fps = avio_rl16(s->pb);
avs->nb_frames = get_le32(s->pb); avs->nb_frames = avio_rl32(s->pb);
avs->remaining_frame_size = 0; avs->remaining_frame_size = 0;
avs->remaining_audio_size = 0; avs->remaining_audio_size = 0;
...@@ -104,7 +104,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt, ...@@ -104,7 +104,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
pkt->data[palette_size + 1] = type; pkt->data[palette_size + 1] = type;
pkt->data[palette_size + 2] = size & 0xFF; pkt->data[palette_size + 2] = size & 0xFF;
pkt->data[palette_size + 3] = (size >> 8) & 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) { if (ret < size) {
av_free_packet(pkt); av_free_packet(pkt);
return AVERROR(EIO); return AVERROR(EIO);
...@@ -154,20 +154,20 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt) ...@@ -154,20 +154,20 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
while (1) { while (1) {
if (avs->remaining_frame_size <= 0) { if (avs->remaining_frame_size <= 0) {
if (!get_le16(s->pb)) /* found EOF */ if (!avio_rl16(s->pb)) /* found EOF */
return AVERROR(EIO); 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) { while (avs->remaining_frame_size > 0) {
sub_type = get_byte(s->pb); sub_type = avio_r8(s->pb);
type = get_byte(s->pb); type = avio_r8(s->pb);
size = get_le16(s->pb); size = avio_rl16(s->pb);
avs->remaining_frame_size -= size; avs->remaining_frame_size -= size;
switch (type) { switch (type) {
case AVS_PALETTE: case AVS_PALETTE:
ret = get_buffer(s->pb, palette, size - 4); ret = avio_read(s->pb, palette, size - 4);
if (ret < size - 4) if (ret < size - 4)
return AVERROR(EIO); return AVERROR(EIO);
palette_size = size; palette_size = size;
......
...@@ -68,7 +68,7 @@ static int vid_read_header(AVFormatContext *s, ...@@ -68,7 +68,7 @@ static int vid_read_header(AVFormatContext *s,
* int16s: always_512, nframes, width, height, delay, always_14 * int16s: always_512, nframes, width, height, delay, always_14
*/ */
url_fseek(pb, 5, SEEK_CUR); url_fseek(pb, 5, SEEK_CUR);
vid->nframes = get_le16(pb); vid->nframes = avio_rl16(pb);
stream = av_new_stream(s, 0); stream = av_new_stream(s, 0);
if (!stream) if (!stream)
...@@ -76,11 +76,11 @@ static int vid_read_header(AVFormatContext *s, ...@@ -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 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_type = AVMEDIA_TYPE_VIDEO;
stream->codec->codec_id = CODEC_ID_BETHSOFTVID; stream->codec->codec_id = CODEC_ID_BETHSOFTVID;
stream->codec->width = get_le16(pb); stream->codec->width = avio_rl16(pb);
stream->codec->height = get_le16(pb); stream->codec->height = avio_rl16(pb);
stream->codec->pix_fmt = PIX_FMT_PAL8; stream->codec->pix_fmt = PIX_FMT_PAL8;
vid->bethsoft_global_delay = get_le16(pb); vid->bethsoft_global_delay = avio_rl16(pb);
get_le16(pb); avio_rl16(pb);
// done with video codec, set up audio codec // done with video codec, set up audio codec
stream = av_new_stream(s, 0); stream = av_new_stream(s, 0);
...@@ -117,11 +117,11 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt, ...@@ -117,11 +117,11 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
vidbuf_start[vidbuf_nbytes++] = block_type; vidbuf_start[vidbuf_nbytes++] = block_type;
// get the video delay (next int16), and set the presentation time // 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) // set the y offset if it exists (decoder header data should be in data section)
if(block_type == VIDEO_YOFF_P_FRAME){ 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; goto fail;
vidbuf_nbytes += 2; vidbuf_nbytes += 2;
} }
...@@ -131,21 +131,21 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt, ...@@ -131,21 +131,21 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
if(!vidbuf_start) if(!vidbuf_start)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
code = get_byte(pb); code = avio_r8(pb);
vidbuf_start[vidbuf_nbytes++] = code; vidbuf_start[vidbuf_nbytes++] = code;
if(code >= 0x80){ // rle sequence if(code >= 0x80){ // rle sequence
if(block_type == VIDEO_I_FRAME) 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 } 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; goto fail;
vidbuf_nbytes += code; vidbuf_nbytes += code;
} }
bytes_copied += code & 0x7F; bytes_copied += code & 0x7F;
if(bytes_copied == npixels){ // sometimes no stop character is given, need to keep track of bytes copied 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 // may contain a 0 byte even if read all pixels
if(get_byte(pb)) if(avio_r8(pb))
url_fseek(pb, -1, SEEK_CUR); url_fseek(pb, -1, SEEK_CUR);
break; break;
} }
...@@ -182,7 +182,7 @@ static int vid_read_packet(AVFormatContext *s, ...@@ -182,7 +182,7 @@ static int vid_read_packet(AVFormatContext *s,
if(vid->is_finished || url_feof(pb)) if(vid->is_finished || url_feof(pb))
return AVERROR(EIO); return AVERROR(EIO);
block_type = get_byte(pb); block_type = avio_r8(pb);
switch(block_type){ switch(block_type){
case PALETTE_BLOCK: case PALETTE_BLOCK:
url_fseek(pb, -1, SEEK_CUR); // include block type url_fseek(pb, -1, SEEK_CUR); // include block type
...@@ -195,12 +195,12 @@ static int vid_read_packet(AVFormatContext *s, ...@@ -195,12 +195,12 @@ static int vid_read_packet(AVFormatContext *s,
return ret_value; return ret_value;
case FIRST_AUDIO_BLOCK: case FIRST_AUDIO_BLOCK:
get_le16(pb); avio_rl16(pb);
// soundblaster DAC used for sample rate, as on specification page (link above) // 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; 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: case AUDIO_BLOCK:
audio_length = get_le16(pb); audio_length = avio_rl16(pb);
ret_value = av_get_packet(pb, pkt, audio_length); ret_value = av_get_packet(pb, pkt, audio_length);
pkt->stream_index = 1; pkt->stream_index = 1;
return ret_value != audio_length ? AVERROR(EIO) : ret_value; return ret_value != audio_length ? AVERROR(EIO) : ret_value;
......
...@@ -66,24 +66,24 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap) ...@@ -66,24 +66,24 @@ static int bfi_read_header(AVFormatContext * s, AVFormatParameters * ap)
/* Set the total number of frames. */ /* Set the total number of frames. */
url_fskip(pb, 8); url_fskip(pb, 8);
chunk_header = get_le32(pb); chunk_header = avio_rl32(pb);
bfi->nframes = get_le32(pb); bfi->nframes = avio_rl32(pb);
get_le32(pb); avio_rl32(pb);
get_le32(pb); avio_rl32(pb);
get_le32(pb); avio_rl32(pb);
fps = get_le32(pb); fps = avio_rl32(pb);
url_fskip(pb, 12); url_fskip(pb, 12);
vstream->codec->width = get_le32(pb); vstream->codec->width = avio_rl32(pb);
vstream->codec->height = get_le32(pb); vstream->codec->height = avio_rl32(pb);
/*Load the palette to extradata */ /*Load the palette to extradata */
url_fskip(pb, 8); url_fskip(pb, 8);
vstream->codec->extradata = av_malloc(768); vstream->codec->extradata = av_malloc(768);
vstream->codec->extradata_size = 768; vstream->codec->extradata_size = 768;
get_buffer(pb, vstream->codec->extradata, avio_read(pb, vstream->codec->extradata,
vstream->codec->extradata_size); vstream->codec->extradata_size);
astream->codec->sample_rate = get_le32(pb); astream->codec->sample_rate = avio_rl32(pb);
/* Set up the video codec... */ /* Set up the video codec... */
av_set_pts_info(vstream, 32, 1, fps); av_set_pts_info(vstream, 32, 1, fps);
...@@ -119,14 +119,14 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) ...@@ -119,14 +119,14 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
while(state != MKTAG('S','A','V','I')){ while(state != MKTAG('S','A','V','I')){
if (url_feof(pb)) if (url_feof(pb))
return AVERROR(EIO); 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... */ /* Now that the chunk's location is confirmed, we proceed... */
chunk_size = get_le32(pb); chunk_size = avio_rl32(pb);
get_le32(pb); avio_rl32(pb);
audio_offset = get_le32(pb); audio_offset = avio_rl32(pb);
get_le32(pb); avio_rl32(pb);
video_offset = get_le32(pb); video_offset = avio_rl32(pb);
audio_size = video_offset - audio_offset; audio_size = video_offset - audio_offset;
bfi->video_size = chunk_size - video_offset; bfi->video_size = chunk_size - video_offset;
......
...@@ -82,17 +82,17 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -82,17 +82,17 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!vst) if (!vst)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
vst->codec->codec_tag = get_le32(pb); vst->codec->codec_tag = avio_rl32(pb);
bink->file_size = get_le32(pb) + 8; bink->file_size = avio_rl32(pb) + 8;
vst->duration = get_le32(pb); vst->duration = avio_rl32(pb);
if (vst->duration > 1000000) { if (vst->duration > 1000000) {
av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n"); av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n");
return AVERROR(EIO); return AVERROR(EIO);
} }
if (get_le32(pb) > bink->file_size) { if (avio_rl32(pb) > bink->file_size) {
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"invalid header: largest frame size greater than file size\n"); "invalid header: largest frame size greater than file size\n");
return AVERROR(EIO); return AVERROR(EIO);
...@@ -100,11 +100,11 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -100,11 +100,11 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(pb, 4); url_fskip(pb, 4);
vst->codec->width = get_le32(pb); vst->codec->width = avio_rl32(pb);
vst->codec->height = get_le32(pb); vst->codec->height = avio_rl32(pb);
fps_num = get_le32(pb); fps_num = avio_rl32(pb);
fps_den = get_le32(pb); fps_den = avio_rl32(pb);
if (fps_num == 0 || fps_den == 0) { if (fps_num == 0 || fps_den == 0) {
av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den); av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den);
return AVERROR(EIO); return AVERROR(EIO);
...@@ -115,9 +115,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -115,9 +115,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->codec_id = CODEC_ID_BINKVIDEO; vst->codec->codec_id = CODEC_ID_BINKVIDEO;
vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
vst->codec->extradata_size = 4; 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) { if (bink->num_audio_tracks > BINK_MAX_AUDIO_TRACKS) {
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
...@@ -135,9 +135,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -135,9 +135,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_tag = 0; 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); 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 ? ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT; CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT;
ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1; ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1;
...@@ -147,14 +147,14 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -147,14 +147,14 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
} }
/* frame index table */ /* frame index table */
next_pos = get_le32(pb); next_pos = avio_rl32(pb);
for (i = 0; i < vst->duration; i++) { for (i = 0; i < vst->duration; i++) {
pos = next_pos; pos = next_pos;
if (i == vst->duration - 1) { if (i == vst->duration - 1) {
next_pos = bink->file_size; next_pos = bink->file_size;
keyframe = 0; keyframe = 0;
} else { } else {
next_pos = get_le32(pb); next_pos = avio_rl32(pb);
keyframe = pos & 1; keyframe = pos & 1;
} }
pos &= ~1; pos &= ~1;
...@@ -201,7 +201,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -201,7 +201,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
} }
while (bink->current_track < bink->num_audio_tracks) { 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) { if (audio_size > bink->remain_packet_size - 4) {
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n", "frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n",
......
...@@ -66,9 +66,9 @@ static int read_header(AVFormatContext *s, ...@@ -66,9 +66,9 @@ static int read_header(AVFormatContext *s,
int framecount = 0; int framecount = 0;
for (i = 0; i < 512; i++) { for (i = 0; i < 512; i++) {
c93->block_records[i].index = get_le16(pb); c93->block_records[i].index = avio_rl16(pb);
c93->block_records[i].length = get_byte(pb); c93->block_records[i].length = avio_r8(pb);
c93->block_records[i].frames = get_byte(pb); c93->block_records[i].frames = avio_r8(pb);
if (c93->block_records[i].frames > 32) { if (c93->block_records[i].frames > 32) {
av_log(s, AV_LOG_ERROR, "too many frames in block\n"); av_log(s, AV_LOG_ERROR, "too many frames in block\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -114,7 +114,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -114,7 +114,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if (c93->next_pkt_is_audio) { if (c93->next_pkt_is_audio) {
c93->current_frame++; c93->current_frame++;
c93->next_pkt_is_audio = 0; c93->next_pkt_is_audio = 0;
datasize = get_le16(pb); datasize = avio_rl16(pb);
if (datasize > 42) { if (datasize > 42) {
if (!c93->audio) { if (!c93->audio) {
c93->audio = av_new_stream(s, 1); c93->audio = av_new_stream(s, 1);
...@@ -142,13 +142,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -142,13 +142,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if (c93->current_frame == 0) { if (c93->current_frame == 0) {
url_fseek(pb, br->index * 2048, SEEK_SET); url_fseek(pb, br->index * 2048, SEEK_SET);
for (i = 0; i < 32; i++) { 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 + url_fseek(pb,br->index * 2048 +
c93->frame_offsets[c93->current_frame], SEEK_SET); 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); ret = av_new_packet(pkt, datasize + 768 + 1);
if (ret < 0) if (ret < 0)
...@@ -156,13 +156,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -156,13 +156,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = 0; pkt->data[0] = 0;
pkt->size = datasize + 1; pkt->size = datasize + 1;
ret = get_buffer(pb, pkt->data + 1, datasize); ret = avio_read(pb, pkt->data + 1, datasize);
if (ret < datasize) { if (ret < datasize) {
ret = AVERROR(EIO); ret = AVERROR(EIO);
goto fail; goto fail;
} }
datasize = get_le16(pb); /* palette size */ datasize = avio_rl16(pb); /* palette size */
if (datasize) { if (datasize) {
if (datasize != 768) { if (datasize != 768) {
av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize); av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize);
...@@ -170,7 +170,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -170,7 +170,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
goto fail; goto fail;
} }
pkt->data[0] |= C93_HAS_PALETTE; 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) { if (ret < datasize) {
ret = AVERROR(EIO); ret = AVERROR(EIO);
goto fail; goto fail;
......
...@@ -65,14 +65,14 @@ static int read_desc_chunk(AVFormatContext *s) ...@@ -65,14 +65,14 @@ static int read_desc_chunk(AVFormatContext *s)
/* parse format description */ /* parse format description */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = av_int2dbl(get_be64(pb)); st->codec->sample_rate = av_int2dbl(avio_rb64(pb));
st->codec->codec_tag = get_be32(pb); st->codec->codec_tag = avio_rb32(pb);
flags = get_be32(pb); flags = avio_rb32(pb);
caf->bytes_per_packet = get_be32(pb); caf->bytes_per_packet = avio_rb32(pb);
st->codec->block_align = caf->bytes_per_packet; st->codec->block_align = caf->bytes_per_packet;
caf->frames_per_packet = get_be32(pb); caf->frames_per_packet = avio_rb32(pb);
st->codec->channels = get_be32(pb); st->codec->channels = avio_rb32(pb);
st->codec->bits_per_coded_sample = get_be32(pb); st->codec->bits_per_coded_sample = avio_rb32(pb);
/* calculate bit rate for constant size packets */ /* calculate bit rate for constant size packets */
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) { 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) ...@@ -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); st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) if (!st->codec->extradata)
return AVERROR(ENOMEM); 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; st->codec->extradata_size = ALAC_HEADER;
url_fskip(pb, size - ALAC_PREAMBLE - ALAC_HEADER); url_fskip(pb, size - ALAC_PREAMBLE - ALAC_HEADER);
} else { } else {
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) if (!st->codec->extradata)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
get_buffer(pb, st->codec->extradata, size); avio_read(pb, st->codec->extradata, size);
st->codec->extradata_size = size; st->codec->extradata_size = size;
} }
...@@ -152,13 +152,13 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size) ...@@ -152,13 +152,13 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
ccount = url_ftell(pb); ccount = url_ftell(pb);
num_packets = get_be64(pb); num_packets = avio_rb64(pb);
if (num_packets < 0 || INT32_MAX / sizeof(AVIndexEntry) < num_packets) if (num_packets < 0 || INT32_MAX / sizeof(AVIndexEntry) < num_packets)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
st->nb_frames = get_be64(pb); /* valid frames */ st->nb_frames = avio_rb64(pb); /* valid frames */
st->nb_frames += get_be32(pb); /* priming frames */ st->nb_frames += avio_rb32(pb); /* priming frames */
st->nb_frames += get_be32(pb); /* remainder frames */ st->nb_frames += avio_rb32(pb); /* remainder frames */
st->duration = 0; st->duration = 0;
for (i = 0; i < num_packets; i++) { for (i = 0; i < num_packets; i++) {
...@@ -181,7 +181,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size) ...@@ -181,7 +181,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
{ {
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
unsigned int i; unsigned int i;
unsigned int nb_entries = get_be32(pb); unsigned int nb_entries = avio_rb32(pb);
for (i = 0; i < nb_entries; i++) { for (i = 0; i < nb_entries; i++) {
char key[32]; char key[32];
char value[1024]; char value[1024];
...@@ -204,11 +204,11 @@ static int read_header(AVFormatContext *s, ...@@ -204,11 +204,11 @@ static int read_header(AVFormatContext *s,
url_fskip(pb, 8); /* magic, version, file flags */ url_fskip(pb, 8); /* magic, version, file flags */
/* audio description chunk */ /* 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"); av_log(s, AV_LOG_ERROR, "desc chunk not present\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
size = get_be64(pb); size = avio_rb64(pb);
if (size != 32) if (size != 32)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -226,8 +226,8 @@ static int read_header(AVFormatContext *s, ...@@ -226,8 +226,8 @@ static int read_header(AVFormatContext *s,
if (found_data && (caf->data_size < 0 || url_is_streamed(pb))) if (found_data && (caf->data_size < 0 || url_is_streamed(pb)))
break; break;
tag = get_be32(pb); tag = avio_rb32(pb);
size = get_be64(pb); size = avio_rb64(pb);
if (url_feof(pb)) if (url_feof(pb))
break; break;
......
...@@ -40,8 +40,8 @@ static int daud_packet(AVFormatContext *s, AVPacket *pkt) { ...@@ -40,8 +40,8 @@ static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
int ret, size; int ret, size;
if (url_feof(pb)) if (url_feof(pb))
return AVERROR(EIO); return AVERROR(EIO);
size = get_be16(pb); size = avio_rb16(pb);
get_be16(pb); // unknown avio_rb16(pb); // unknown
ret = av_get_packet(pb, pkt, size); ret = av_get_packet(pb, pkt, size);
pkt->stream_index = 0; pkt->stream_index = 0;
return ret; return ret;
......
...@@ -73,16 +73,16 @@ static int cin_probe(AVProbeData *p) ...@@ -73,16 +73,16 @@ static int cin_probe(AVProbeData *p)
static int cin_read_file_header(CinDemuxContext *cin, AVIOContext *pb) { static int cin_read_file_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFileHeader *hdr = &cin->file_header; CinFileHeader *hdr = &cin->file_header;
if (get_le32(pb) != 0x55AA0000) if (avio_rl32(pb) != 0x55AA0000)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
hdr->video_frame_size = get_le32(pb); hdr->video_frame_size = avio_rl32(pb);
hdr->video_frame_width = get_le16(pb); hdr->video_frame_width = avio_rl16(pb);
hdr->video_frame_height = get_le16(pb); hdr->video_frame_height = avio_rl16(pb);
hdr->audio_frequency = get_le32(pb); hdr->audio_frequency = avio_rl32(pb);
hdr->audio_bits = get_byte(pb); hdr->audio_bits = avio_r8(pb);
hdr->audio_stereo = get_byte(pb); hdr->audio_stereo = avio_r8(pb);
hdr->audio_frame_size = get_le16(pb); hdr->audio_frame_size = avio_rl16(pb);
if (hdr->audio_frequency != 22050 || hdr->audio_bits != 16 || hdr->audio_stereo != 0) if (hdr->audio_frequency != 22050 || hdr->audio_bits != 16 || hdr->audio_stereo != 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -141,16 +141,16 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -141,16 +141,16 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) { static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFrameHeader *hdr = &cin->frame_header; CinFrameHeader *hdr = &cin->frame_header;
hdr->video_frame_type = get_byte(pb); hdr->video_frame_type = avio_r8(pb);
hdr->audio_frame_type = get_byte(pb); hdr->audio_frame_type = avio_r8(pb);
hdr->pal_colors_count = get_le16(pb); hdr->pal_colors_count = avio_rl16(pb);
hdr->video_frame_size = get_le32(pb); hdr->video_frame_size = avio_rl32(pb);
hdr->audio_frame_size = get_le32(pb); hdr->audio_frame_size = avio_rl32(pb);
if (url_feof(pb) || url_ferror(pb)) if (url_feof(pb) || url_ferror(pb))
return AVERROR(EIO); return AVERROR(EIO);
if (get_le32(pb) != 0xAA55AA55) if (avio_rl32(pb) != 0xAA55AA55)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
return 0; return 0;
...@@ -191,7 +191,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -191,7 +191,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[2] = hdr->pal_colors_count >> 8; pkt->data[2] = hdr->pal_colors_count >> 8;
pkt->data[3] = hdr->video_frame_type; 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) { if (ret < 0) {
av_free_packet(pkt); av_free_packet(pkt);
return ret; return ret;
......
...@@ -410,7 +410,7 @@ static int dv_read_header(AVFormatContext *s, ...@@ -410,7 +410,7 @@ static int dv_read_header(AVFormatContext *s,
if (!c->dv_demux) if (!c->dv_demux)
return -1; return -1;
state = get_be32(s->pb); state = avio_rb32(s->pb);
while ((state & 0xffffff7f) != 0x1f07003f) { while ((state & 0xffffff7f) != 0x1f07003f) {
if (url_feof(s->pb)) { if (url_feof(s->pb)) {
av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n"); av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
...@@ -420,14 +420,14 @@ static int dv_read_header(AVFormatContext *s, ...@@ -420,14 +420,14 @@ static int dv_read_header(AVFormatContext *s,
marker_pos = url_ftell(s->pb); marker_pos = url_ftell(s->pb);
if (state == 0xff3f0701 && url_ftell(s->pb) - marker_pos == 80) { if (state == 0xff3f0701 && url_ftell(s->pb) - marker_pos == 80) {
url_fseek(s->pb, -163, SEEK_CUR); url_fseek(s->pb, -163, SEEK_CUR);
state = get_be32(s->pb); state = avio_rb32(s->pb);
break; break;
} }
state = (state << 8) | get_byte(s->pb); state = (state << 8) | avio_r8(s->pb);
} }
AV_WB32(c->buf, state); 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) url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
return AVERROR(EIO); return AVERROR(EIO);
...@@ -455,7 +455,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -455,7 +455,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!c->dv_demux->sys) if (!c->dv_demux->sys)
return AVERROR(EIO); return AVERROR(EIO);
size = c->dv_demux->sys->frame_size; 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); return AVERROR(EIO);
size = dv_produce_packet(c->dv_demux, pkt, c->buf, size); size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);
......
...@@ -61,17 +61,17 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -61,17 +61,17 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
int num, den; int num, den;
int flags; int flags;
tag = get_le32(pb); tag = avio_rl32(pb);
if (tag != MKTAG('D', 'E', 'X', 'A')) if (tag != MKTAG('D', 'E', 'X', 'A'))
return -1; return -1;
flags = get_byte(pb); flags = avio_r8(pb);
c->frames = get_be16(pb); c->frames = avio_rb16(pb);
if(!c->frames){ if(!c->frames){
av_log(s, AV_LOG_ERROR, "File contains no frames ???\n"); av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
return -1; return -1;
} }
fps = get_be32(pb); fps = avio_rb32(pb);
if(fps > 0){ if(fps > 0){
den = 1000; den = 1000;
num = fps; num = fps;
...@@ -82,8 +82,8 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -82,8 +82,8 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
den = 10; den = 10;
num = 1; num = 1;
} }
w = get_be16(pb); w = avio_rb16(pb);
h = get_be16(pb); h = avio_rb16(pb);
c->has_sound = 0; c->has_sound = 0;
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
...@@ -91,13 +91,13 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -91,13 +91,13 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1; return -1;
// Parse WAV data header // 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; uint32_t size, fsize;
c->has_sound = 1; c->has_sound = 1;
size = get_be32(pb); size = avio_rb32(pb);
c->vidpos = url_ftell(pb) + size; c->vidpos = url_ftell(pb) + size;
url_fskip(pb, 16); url_fskip(pb, 16);
fsize = get_le32(pb); fsize = avio_rl32(pb);
ast = av_new_stream(s, 0); ast = av_new_stream(s, 0);
if (!ast) if (!ast)
...@@ -105,8 +105,8 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -105,8 +105,8 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_get_wav_header(pb, ast->codec, fsize); ff_get_wav_header(pb, ast->codec, fsize);
// find 'data' chunk // find 'data' chunk
while(url_ftell(pb) < c->vidpos && !url_feof(pb)){ while(url_ftell(pb) < c->vidpos && !url_feof(pb)){
tag = get_le32(pb); tag = avio_rl32(pb);
fsize = get_le32(pb); fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break; if(tag == MKTAG('d', 'a', 't', 'a')) break;
url_fskip(pb, fsize); url_fskip(pb, fsize);
} }
...@@ -163,7 +163,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -163,7 +163,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
} }
url_fseek(s->pb, c->vidpos, SEEK_SET); url_fseek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){ while(!url_feof(s->pb) && c->frames){
get_buffer(s->pb, buf, 4); avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){ switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'): case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(pkt, 4 + pal_size) < 0) if(av_new_packet(pkt, 4 + pal_size) < 0)
...@@ -178,10 +178,10 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -178,10 +178,10 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
case MKTAG('C', 'M', 'A', 'P'): case MKTAG('C', 'M', 'A', 'P'):
pal_size = 768+4; pal_size = 768+4;
memcpy(pal, buf, 4); memcpy(pal, buf, 4);
get_buffer(s->pb, pal + 4, 768); avio_read(s->pb, pal + 4, 768);
break; break;
case MKTAG('F', 'R', 'A', 'M'): 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); size = AV_RB32(buf + 5);
if(size > 0xFFFFFF){ if(size > 0xFFFFFF){
av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size); 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) ...@@ -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) if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE); 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){ if(ret != size){
av_free_packet(pkt); av_free_packet(pkt);
return AVERROR(EIO); return AVERROR(EIO);
......
...@@ -51,7 +51,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -51,7 +51,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap)
unsigned int sample_rate, header; unsigned int sample_rate, header;
AVStream *st; AVStream *st;
header = get_be16(pb); header = avio_rb16(pb);
switch (header) { switch (header) {
case 0x0400: cdata->channels = 1; break; case 0x0400: cdata->channels = 1; break;
case 0x0404: cdata->channels = 2; break; case 0x0404: cdata->channels = 2; break;
...@@ -61,7 +61,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -61,7 +61,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1; return -1;
}; };
sample_rate = get_be16(pb); sample_rate = avio_rb16(pb);
url_fskip(pb, 12); url_fskip(pb, 12);
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
......
...@@ -82,11 +82,11 @@ static uint32_t read_arbitary(AVIOContext *pb) { ...@@ -82,11 +82,11 @@ static uint32_t read_arbitary(AVIOContext *pb) {
int i; int i;
uint32_t word; uint32_t word;
size = get_byte(pb); size = avio_r8(pb);
word = 0; word = 0;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
byte = get_byte(pb); byte = avio_r8(pb);
word <<= 8; word <<= 8;
word |= byte; word |= byte;
} }
...@@ -112,7 +112,7 @@ static int process_audio_header_elements(AVFormatContext *s) ...@@ -112,7 +112,7 @@ static int process_audio_header_elements(AVFormatContext *s)
while (!url_feof(pb) && inHeader) { while (!url_feof(pb) && inHeader) {
int inSubheader; int inSubheader;
uint8_t byte; uint8_t byte;
byte = get_byte(pb); byte = avio_r8(pb);
switch (byte) { switch (byte) {
case 0xFD: case 0xFD:
...@@ -120,7 +120,7 @@ static int process_audio_header_elements(AVFormatContext *s) ...@@ -120,7 +120,7 @@ static int process_audio_header_elements(AVFormatContext *s)
inSubheader = 1; inSubheader = 1;
while (!url_feof(pb) && inSubheader) { while (!url_feof(pb) && inSubheader) {
uint8_t subbyte; uint8_t subbyte;
subbyte = get_byte(pb); subbyte = avio_r8(pb);
switch (subbyte) { switch (subbyte) {
case 0x80: case 0x80:
...@@ -218,10 +218,10 @@ static int process_audio_header_eacs(AVFormatContext *s) ...@@ -218,10 +218,10 @@ static int process_audio_header_eacs(AVFormatContext *s)
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
int compression_type; int compression_type;
ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb); ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */ ea->bytes = avio_r8(pb); /* 1=8-bit, 2=16-bit */
ea->num_channels = get_byte(pb); ea->num_channels = avio_r8(pb);
compression_type = get_byte(pb); compression_type = avio_r8(pb);
url_fskip(pb, 13); url_fskip(pb, 13);
switch (compression_type) { switch (compression_type) {
...@@ -249,9 +249,9 @@ static int process_audio_header_sead(AVFormatContext *s) ...@@ -249,9 +249,9 @@ static int process_audio_header_sead(AVFormatContext *s)
EaDemuxContext *ea = s->priv_data; EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
ea->sample_rate = get_le32(pb); ea->sample_rate = avio_rl32(pb);
ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */ ea->bytes = avio_rl32(pb); /* 1=8-bit, 2=16-bit */
ea->num_channels = get_le32(pb); ea->num_channels = avio_rl32(pb);
ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD; ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD;
return 1; return 1;
...@@ -262,8 +262,8 @@ static int process_video_header_mdec(AVFormatContext *s) ...@@ -262,8 +262,8 @@ static int process_video_header_mdec(AVFormatContext *s)
EaDemuxContext *ea = s->priv_data; EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
url_fskip(pb, 4); url_fskip(pb, 4);
ea->width = get_le16(pb); ea->width = avio_rl16(pb);
ea->height = get_le16(pb); ea->height = avio_rl16(pb);
ea->time_base = (AVRational){1,15}; ea->time_base = (AVRational){1,15};
ea->video_codec = CODEC_ID_MDEC; ea->video_codec = CODEC_ID_MDEC;
return 1; return 1;
...@@ -275,8 +275,8 @@ static int process_video_header_vp6(AVFormatContext *s) ...@@ -275,8 +275,8 @@ static int process_video_header_vp6(AVFormatContext *s)
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
url_fskip(pb, 16); url_fskip(pb, 16);
ea->time_base.den = get_le32(pb); ea->time_base.den = avio_rl32(pb);
ea->time_base.num = get_le32(pb); ea->time_base.num = avio_rl32(pb);
ea->video_codec = CODEC_ID_VP6; ea->video_codec = CODEC_ID_VP6;
return 1; return 1;
...@@ -296,8 +296,8 @@ static int process_ea_header(AVFormatContext *s) { ...@@ -296,8 +296,8 @@ static int process_ea_header(AVFormatContext *s) {
unsigned int startpos = url_ftell(pb); unsigned int startpos = url_ftell(pb);
int err = 0; int err = 0;
blockid = get_le32(pb); blockid = avio_rl32(pb);
size = get_le32(pb); size = avio_rl32(pb);
if (i == 0) if (i == 0)
ea->big_endian = size > 0x000FFFFF; ea->big_endian = size > 0x000FFFFF;
if (ea->big_endian) if (ea->big_endian)
...@@ -305,7 +305,7 @@ static int process_ea_header(AVFormatContext *s) { ...@@ -305,7 +305,7 @@ static int process_ea_header(AVFormatContext *s) {
switch (blockid) { switch (blockid) {
case ISNh_TAG: 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"); av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n");
return 0; return 0;
} }
...@@ -314,7 +314,7 @@ static int process_ea_header(AVFormatContext *s) { ...@@ -314,7 +314,7 @@ static int process_ea_header(AVFormatContext *s) {
case SCHl_TAG : case SCHl_TAG :
case SHEN_TAG : case SHEN_TAG :
blockid = get_le32(pb); blockid = avio_rl32(pb);
if (blockid == GSTR_TAG) { if (blockid == GSTR_TAG) {
url_fskip(pb, 4); url_fskip(pb, 4);
} else if ((blockid & 0xFFFF)!=PT00_TAG) { } else if ((blockid & 0xFFFF)!=PT00_TAG) {
...@@ -467,8 +467,8 @@ static int ea_read_packet(AVFormatContext *s, ...@@ -467,8 +467,8 @@ static int ea_read_packet(AVFormatContext *s,
int av_uninit(num_samples); int av_uninit(num_samples);
while (!packet_read) { while (!packet_read) {
chunk_type = get_le32(pb); chunk_type = avio_rl32(pb);
chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8; chunk_size = (ea->big_endian ? avio_rb32(pb) : avio_rl32(pb)) - 8;
switch (chunk_type) { switch (chunk_type) {
/* audio data */ /* audio data */
...@@ -485,7 +485,7 @@ static int ea_read_packet(AVFormatContext *s, ...@@ -485,7 +485,7 @@ static int ea_read_packet(AVFormatContext *s,
break; break;
} else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR || } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR ||
ea->audio_codec == CODEC_ID_MP3) { ea->audio_codec == CODEC_ID_MP3) {
num_samples = get_le32(pb); num_samples = avio_rl32(pb);
url_fskip(pb, 8); url_fskip(pb, 8);
chunk_size -= 12; chunk_size -= 12;
} }
......
...@@ -95,7 +95,7 @@ static int ffm_resync(AVFormatContext *s, int state) ...@@ -95,7 +95,7 @@ static int ffm_resync(AVFormatContext *s, int state)
av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n"); av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
return -1; return -1;
} }
state = (state << 8) | get_byte(s->pb); state = (state << 8) | avio_r8(s->pb);
} }
return 0; return 0;
} }
...@@ -120,14 +120,14 @@ static int ffm_read_data(AVFormatContext *s, ...@@ -120,14 +120,14 @@ static int ffm_read_data(AVFormatContext *s,
if (url_ftell(pb) == ffm->file_size) if (url_ftell(pb) == ffm->file_size)
url_fseek(pb, ffm->packet_size, SEEK_SET); url_fseek(pb, ffm->packet_size, SEEK_SET);
retry_read: retry_read:
id = get_be16(pb); /* PACKET_ID */ id = avio_rb16(pb); /* PACKET_ID */
if (id != PACKET_ID) if (id != PACKET_ID)
if (ffm_resync(s, id) < 0) if (ffm_resync(s, id) < 0)
return -1; return -1;
fill_size = get_be16(pb); fill_size = avio_rb16(pb);
ffm->dts = get_be64(pb); ffm->dts = avio_rb64(pb);
frame_offset = get_be16(pb); frame_offset = avio_rb16(pb);
get_buffer(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE); avio_read(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size); ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);
if (ffm->packet_end < ffm->packet || frame_offset < 0) if (ffm->packet_end < ffm->packet || frame_offset < 0)
return -1; return -1;
...@@ -188,7 +188,7 @@ static int64_t get_dts(AVFormatContext *s, int64_t pos) ...@@ -188,7 +188,7 @@ static int64_t get_dts(AVFormatContext *s, int64_t pos)
ffm_seek1(s, pos); ffm_seek1(s, pos);
url_fskip(pb, 4); url_fskip(pb, 4);
dts = get_be64(pb); dts = avio_rb64(pb);
#ifdef DEBUG_SEEK #ifdef DEBUG_SEEK
av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0); av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0);
#endif #endif
...@@ -273,13 +273,13 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -273,13 +273,13 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
uint32_t tag; uint32_t tag;
/* header */ /* header */
tag = get_le32(pb); tag = avio_rl32(pb);
if (tag != MKTAG('F', 'F', 'M', '1')) if (tag != MKTAG('F', 'F', 'M', '1'))
goto fail; goto fail;
ffm->packet_size = get_be32(pb); ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE) if (ffm->packet_size != FFM_PACKET_SIZE)
goto fail; goto fail;
ffm->write_index = get_be64(pb); ffm->write_index = avio_rb64(pb);
/* get also filesize */ /* get also filesize */
if (!url_is_streamed(pb)) { if (!url_is_streamed(pb)) {
ffm->file_size = url_fsize(pb); ffm->file_size = url_fsize(pb);
...@@ -289,8 +289,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -289,8 +289,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
ffm->file_size = (UINT64_C(1) << 63) - 1; ffm->file_size = (UINT64_C(1) << 63) - 1;
} }
nb_streams = get_be32(pb); nb_streams = avio_rb32(pb);
get_be32(pb); /* total bitrate */ avio_rb32(pb); /* total bitrate */
/* read each stream */ /* read each stream */
for(i=0;i<nb_streams;i++) { for(i=0;i<nb_streams;i++) {
char rc_eq_buf[128]; char rc_eq_buf[128];
...@@ -303,85 +303,85 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -303,85 +303,85 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec = st->codec; codec = st->codec;
/* generic info */ /* generic info */
codec->codec_id = get_be32(pb); codec->codec_id = avio_rb32(pb);
codec->codec_type = get_byte(pb); /* codec_type */ codec->codec_type = avio_r8(pb); /* codec_type */
codec->bit_rate = get_be32(pb); codec->bit_rate = avio_rb32(pb);
st->quality = get_be32(pb); st->quality = avio_rb32(pb);
codec->flags = get_be32(pb); codec->flags = avio_rb32(pb);
codec->flags2 = get_be32(pb); codec->flags2 = avio_rb32(pb);
codec->debug = get_be32(pb); codec->debug = avio_rb32(pb);
/* specific info */ /* specific info */
switch(codec->codec_type) { switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
codec->time_base.num = get_be32(pb); codec->time_base.num = avio_rb32(pb);
codec->time_base.den = get_be32(pb); codec->time_base.den = avio_rb32(pb);
codec->width = get_be16(pb); codec->width = avio_rb16(pb);
codec->height = get_be16(pb); codec->height = avio_rb16(pb);
codec->gop_size = get_be16(pb); codec->gop_size = avio_rb16(pb);
codec->pix_fmt = get_be32(pb); codec->pix_fmt = avio_rb32(pb);
codec->qmin = get_byte(pb); codec->qmin = avio_r8(pb);
codec->qmax = get_byte(pb); codec->qmax = avio_r8(pb);
codec->max_qdiff = get_byte(pb); codec->max_qdiff = avio_r8(pb);
codec->qcompress = get_be16(pb) / 10000.0; codec->qcompress = avio_rb16(pb) / 10000.0;
codec->qblur = get_be16(pb) / 10000.0; codec->qblur = avio_rb16(pb) / 10000.0;
codec->bit_rate_tolerance = get_be32(pb); codec->bit_rate_tolerance = avio_rb32(pb);
codec->rc_eq = av_strdup(get_strz(pb, rc_eq_buf, sizeof(rc_eq_buf))); codec->rc_eq = av_strdup(get_strz(pb, rc_eq_buf, sizeof(rc_eq_buf)));
codec->rc_max_rate = get_be32(pb); codec->rc_max_rate = avio_rb32(pb);
codec->rc_min_rate = get_be32(pb); codec->rc_min_rate = avio_rb32(pb);
codec->rc_buffer_size = get_be32(pb); codec->rc_buffer_size = avio_rb32(pb);
codec->i_quant_factor = av_int2dbl(get_be64(pb)); codec->i_quant_factor = av_int2dbl(avio_rb64(pb));
codec->b_quant_factor = av_int2dbl(get_be64(pb)); codec->b_quant_factor = av_int2dbl(avio_rb64(pb));
codec->i_quant_offset = av_int2dbl(get_be64(pb)); codec->i_quant_offset = av_int2dbl(avio_rb64(pb));
codec->b_quant_offset = av_int2dbl(get_be64(pb)); codec->b_quant_offset = av_int2dbl(avio_rb64(pb));
codec->dct_algo = get_be32(pb); codec->dct_algo = avio_rb32(pb);
codec->strict_std_compliance = get_be32(pb); codec->strict_std_compliance = avio_rb32(pb);
codec->max_b_frames = get_be32(pb); codec->max_b_frames = avio_rb32(pb);
codec->luma_elim_threshold = get_be32(pb); codec->luma_elim_threshold = avio_rb32(pb);
codec->chroma_elim_threshold = get_be32(pb); codec->chroma_elim_threshold = avio_rb32(pb);
codec->mpeg_quant = get_be32(pb); codec->mpeg_quant = avio_rb32(pb);
codec->intra_dc_precision = get_be32(pb); codec->intra_dc_precision = avio_rb32(pb);
codec->me_method = get_be32(pb); codec->me_method = avio_rb32(pb);
codec->mb_decision = get_be32(pb); codec->mb_decision = avio_rb32(pb);
codec->nsse_weight = get_be32(pb); codec->nsse_weight = avio_rb32(pb);
codec->frame_skip_cmp = get_be32(pb); codec->frame_skip_cmp = avio_rb32(pb);
codec->rc_buffer_aggressivity = av_int2dbl(get_be64(pb)); codec->rc_buffer_aggressivity = av_int2dbl(avio_rb64(pb));
codec->codec_tag = get_be32(pb); codec->codec_tag = avio_rb32(pb);
codec->thread_count = get_byte(pb); codec->thread_count = avio_r8(pb);
codec->coder_type = get_be32(pb); codec->coder_type = avio_rb32(pb);
codec->me_cmp = get_be32(pb); codec->me_cmp = avio_rb32(pb);
codec->partitions = get_be32(pb); codec->partitions = avio_rb32(pb);
codec->me_subpel_quality = get_be32(pb); codec->me_subpel_quality = avio_rb32(pb);
codec->me_range = get_be32(pb); codec->me_range = avio_rb32(pb);
codec->keyint_min = get_be32(pb); codec->keyint_min = avio_rb32(pb);
codec->scenechange_threshold = get_be32(pb); codec->scenechange_threshold = avio_rb32(pb);
codec->b_frame_strategy = get_be32(pb); codec->b_frame_strategy = avio_rb32(pb);
codec->qcompress = av_int2dbl(get_be64(pb)); codec->qcompress = av_int2dbl(avio_rb64(pb));
codec->qblur = av_int2dbl(get_be64(pb)); codec->qblur = av_int2dbl(avio_rb64(pb));
codec->max_qdiff = get_be32(pb); codec->max_qdiff = avio_rb32(pb);
codec->refs = get_be32(pb); codec->refs = avio_rb32(pb);
codec->directpred = get_be32(pb); codec->directpred = avio_rb32(pb);
break; break;
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
codec->sample_rate = get_be32(pb); codec->sample_rate = avio_rb32(pb);
codec->channels = get_le16(pb); codec->channels = avio_rl16(pb);
codec->frame_size = get_le16(pb); codec->frame_size = avio_rl16(pb);
codec->sample_fmt = (int16_t) get_le16(pb); codec->sample_fmt = (int16_t) avio_rl16(pb);
break; break;
default: default:
goto fail; goto fail;
} }
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { 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); codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata) if (!codec->extradata)
return AVERROR(ENOMEM); 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 */ /* get until end of block reached */
while ((url_ftell(pb) % ffm->packet_size) != 0) while ((url_ftell(pb) % ffm->packet_size) != 0)
get_byte(pb); avio_r8(pb);
/* init packet demux */ /* init packet demux */
ffm->packet_ptr = ffm->packet; ffm->packet_ptr = ffm->packet;
......
...@@ -36,11 +36,11 @@ static void get_line(AVIOContext *s, uint8_t *buf, int size) ...@@ -36,11 +36,11 @@ static void get_line(AVIOContext *s, uint8_t *buf, int size)
uint8_t c; uint8_t c;
int i = 0; int i = 0;
while ((c = get_byte(s))) { while ((c = avio_r8(s))) {
if (c == '\\') { if (c == '\\') {
if (i < size - 1) if (i < size - 1)
buf[i++] = c; buf[i++] = c;
c = get_byte(s); c = avio_r8(s);
} else if (c == '\n') } else if (c == '\n')
break; break;
......
...@@ -44,7 +44,7 @@ static int read_header(AVFormatContext *s, ...@@ -44,7 +44,7 @@ static int read_header(AVFormatContext *s,
return AVERROR(EIO); return AVERROR(EIO);
url_fseek(pb, url_fsize(pb) - 36, SEEK_SET); 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"); av_log(s, AV_LOG_ERROR, "magic number not found");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
...@@ -53,8 +53,8 @@ static int read_header(AVFormatContext *s, ...@@ -53,8 +53,8 @@ static int read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
st->nb_frames = get_be32(pb); st->nb_frames = avio_rb32(pb);
if (get_be16(pb) != 0) { if (avio_rb16(pb) != 0) {
av_log_ask_for_sample(s, "unsupported packing method\n"); av_log_ask_for_sample(s, "unsupported packing method\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
...@@ -64,10 +64,10 @@ static int read_header(AVFormatContext *s, ...@@ -64,10 +64,10 @@ static int read_header(AVFormatContext *s,
st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = PIX_FMT_RGBA; st->codec->pix_fmt = PIX_FMT_RGBA;
st->codec->codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = get_be16(pb); st->codec->width = avio_rb16(pb);
st->codec->height = get_be16(pb); st->codec->height = avio_rb16(pb);
film->leading = get_be16(pb); film->leading = avio_rb16(pb);
av_set_pts_info(st, 64, 1, get_be16(pb)); av_set_pts_info(st, 64, 1, avio_rb16(pb));
url_fseek(pb, 0, SEEK_SET); url_fseek(pb, 0, SEEK_SET);
......
...@@ -40,14 +40,14 @@ static int flac_read_header(AVFormatContext *s, ...@@ -40,14 +40,14 @@ static int flac_read_header(AVFormatContext *s,
/* the parameters will be extracted from the compressed bitstream */ /* the parameters will be extracted from the compressed bitstream */
/* if fLaC marker is not found, assume there is no header */ /* 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); url_fseek(s->pb, -4, SEEK_CUR);
return 0; return 0;
} }
/* process metadata blocks */ /* process metadata blocks */
while (!url_feof(s->pb) && !metadata_last) { 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, ff_flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size); &metadata_size);
switch (metadata_type) { switch (metadata_type) {
...@@ -58,7 +58,7 @@ static int flac_read_header(AVFormatContext *s, ...@@ -58,7 +58,7 @@ static int flac_read_header(AVFormatContext *s,
if (!buffer) { if (!buffer) {
return AVERROR(ENOMEM); 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); av_freep(&buffer);
return AVERROR(EIO); return AVERROR(EIO);
} }
......
...@@ -96,7 +96,7 @@ static int flic_read_header(AVFormatContext *s, ...@@ -96,7 +96,7 @@ static int flic_read_header(AVFormatContext *s,
flic->frame_number = 0; flic->frame_number = 0;
/* load the whole header and pull out the width and height */ /* 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); return AVERROR(EIO);
magic_number = AV_RL16(&header[4]); magic_number = AV_RL16(&header[4]);
...@@ -130,7 +130,7 @@ static int flic_read_header(AVFormatContext *s, ...@@ -130,7 +130,7 @@ static int flic_read_header(AVFormatContext *s,
memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE); 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 */ /* 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"); av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n");
return AVERROR(EIO); return AVERROR(EIO);
} }
...@@ -207,7 +207,7 @@ static int flic_read_packet(AVFormatContext *s, ...@@ -207,7 +207,7 @@ static int flic_read_packet(AVFormatContext *s,
while (!packet_read) { while (!packet_read) {
if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) != if ((ret = avio_read(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
FLIC_PREAMBLE_SIZE) { FLIC_PREAMBLE_SIZE) {
ret = AVERROR(EIO); ret = AVERROR(EIO);
break; break;
...@@ -225,7 +225,7 @@ static int flic_read_packet(AVFormatContext *s, ...@@ -225,7 +225,7 @@ static int flic_read_packet(AVFormatContext *s,
pkt->pts = flic->frame_number++; pkt->pts = flic->frame_number++;
pkt->pos = url_ftell(pb); pkt->pos = url_ftell(pb);
memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE); 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); size - FLIC_PREAMBLE_SIZE);
if (ret != size - FLIC_PREAMBLE_SIZE) { if (ret != size - FLIC_PREAMBLE_SIZE) {
av_free_packet(pkt); av_free_packet(pkt);
...@@ -243,7 +243,7 @@ static int flic_read_packet(AVFormatContext *s, ...@@ -243,7 +243,7 @@ static int flic_read_packet(AVFormatContext *s,
pkt->stream_index = flic->audio_stream_index; pkt->stream_index = flic->audio_stream_index;
pkt->pos = url_ftell(pb); pkt->pos = url_ftell(pb);
ret = get_buffer(pb, pkt->data, size); ret = avio_read(pb, pkt->data, size);
if (ret != size) { if (ret != size) {
av_free_packet(pkt); av_free_packet(pkt);
......
...@@ -97,7 +97,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co ...@@ -97,7 +97,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
vcodec->extradata_size = 1; vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(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() return 1; // 1 byte body size adjustment for flv_read_packet()
case FLV_CODECID_H264: case FLV_CODECID_H264:
vcodec->codec_id = CODEC_ID_H264; vcodec->codec_id = CODEC_ID_H264;
...@@ -111,13 +111,13 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co ...@@ -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) { static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize) {
int length = get_be16(ioc); int length = avio_rb16(ioc);
if(length >= buffsize) { if(length >= buffsize) {
url_fskip(ioc, length); url_fskip(ioc, length);
return -1; return -1;
} }
get_buffer(ioc, buffer, length); avio_read(ioc, buffer, length);
buffer[length] = '\0'; buffer[length] = '\0';
...@@ -134,13 +134,13 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst ...@@ -134,13 +134,13 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
num_val = 0; num_val = 0;
ioc = s->pb; ioc = s->pb;
amf_type = get_byte(ioc); amf_type = avio_r8(ioc);
switch(amf_type) { switch(amf_type) {
case AMF_DATA_TYPE_NUMBER: 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: case AMF_DATA_TYPE_BOOL:
num_val = get_byte(ioc); break; num_val = avio_r8(ioc); break;
case AMF_DATA_TYPE_STRING: case AMF_DATA_TYPE_STRING:
if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0) if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1; return -1;
...@@ -148,12 +148,12 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst ...@@ -148,12 +148,12 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
case AMF_DATA_TYPE_OBJECT: { case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen; 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 url_fskip(ioc, keylen); //skip key string
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out. 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; return -1;
} }
break; break;
...@@ -168,13 +168,13 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst ...@@ -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) if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
return -1; return -1;
} }
if(get_byte(ioc) != AMF_END_OF_OBJECT) if(avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1; return -1;
break; break;
case AMF_DATA_TYPE_ARRAY: { case AMF_DATA_TYPE_ARRAY: {
unsigned int arraylen, i; unsigned int arraylen, i;
arraylen = get_be32(ioc); arraylen = avio_rb32(ioc);
for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) { 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) if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out. return -1; //if we couldn't skip, bomb out.
...@@ -222,7 +222,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) { ...@@ -222,7 +222,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos) {
ioc = s->pb; ioc = s->pb;
//first object needs to be "onMetaData" string //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")) if(type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0 || strcmp(buffer, "onMetaData"))
return -1; return -1;
...@@ -255,7 +255,7 @@ static int flv_read_header(AVFormatContext *s, ...@@ -255,7 +255,7 @@ static int flv_read_header(AVFormatContext *s,
int offset, flags; int offset, flags;
url_fskip(s->pb, 4); url_fskip(s->pb, 4);
flags = get_byte(s->pb); flags = avio_r8(s->pb);
/* old flvtool cleared this field */ /* old flvtool cleared this field */
/* FIXME: better fix needed */ /* FIXME: better fix needed */
if (!flags) { if (!flags) {
...@@ -276,7 +276,7 @@ static int flv_read_header(AVFormatContext *s, ...@@ -276,7 +276,7 @@ static int flv_read_header(AVFormatContext *s,
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
offset = get_be32(s->pb); offset = avio_rb32(s->pb);
url_fseek(s->pb, offset, SEEK_SET); url_fseek(s->pb, offset, SEEK_SET);
url_fskip(s->pb, 4); url_fskip(s->pb, 4);
...@@ -292,7 +292,7 @@ static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size) ...@@ -292,7 +292,7 @@ static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
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(s->pb, st->codec->extradata, st->codec->extradata_size); avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0; return 0;
} }
...@@ -306,10 +306,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -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 */ for(;;url_fskip(s->pb, 4)){ /* pkt size is repeated at end. skip it */
pos = url_ftell(s->pb); pos = url_ftell(s->pb);
type = get_byte(s->pb); type = avio_r8(s->pb);
size = get_be24(s->pb); size = avio_rb24(s->pb);
dts = get_be24(s->pb); dts = avio_rb24(s->pb);
dts |= get_byte(s->pb) << 24; dts |= avio_r8(s->pb) << 24;
// av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, dts:%d\n", type, size, dts); // av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, dts:%d\n", type, size, dts);
if (url_feof(s->pb)) if (url_feof(s->pb))
return AVERROR_EOF; return AVERROR_EOF;
...@@ -323,11 +323,11 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -323,11 +323,11 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (type == FLV_TAG_TYPE_AUDIO) { if (type == FLV_TAG_TYPE_AUDIO) {
is_audio=1; is_audio=1;
flags = get_byte(s->pb); flags = avio_r8(s->pb);
size--; size--;
} else if (type == FLV_TAG_TYPE_VIDEO) { } else if (type == FLV_TAG_TYPE_VIDEO) {
is_audio=0; is_audio=0;
flags = get_byte(s->pb); flags = avio_r8(s->pb);
size--; size--;
if ((flags & 0xf0) == 0x50) /* video info / command frame */ if ((flags & 0xf0) == 0x50) /* video info / command frame */
goto skip; goto skip;
...@@ -375,11 +375,11 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -375,11 +375,11 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
const int64_t pos= url_ftell(s->pb); const int64_t pos= url_ftell(s->pb);
const int64_t fsize= url_fsize(s->pb); const int64_t fsize= url_fsize(s->pb);
url_fseek(s->pb, fsize-4, SEEK_SET); 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); url_fseek(s->pb, fsize-3-size, SEEK_SET);
if(size == get_be24(s->pb) + 11){ if(size == avio_rb24(s->pb) + 11){
uint32_t ts = get_be24(s->pb); uint32_t ts = avio_rb24(s->pb);
ts |= get_byte(s->pb) << 24; ts |= avio_r8(s->pb) << 24;
s->duration = ts * (int64_t)AV_TIME_BASE / 1000; s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
} }
url_fseek(s->pb, pos, SEEK_SET); url_fseek(s->pb, pos, SEEK_SET);
...@@ -400,10 +400,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -400,10 +400,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
if (st->codec->codec_id == CODEC_ID_AAC || if (st->codec->codec_id == CODEC_ID_AAC ||
st->codec->codec_id == CODEC_ID_H264) { st->codec->codec_id == CODEC_ID_H264) {
int type = get_byte(s->pb); int type = avio_r8(s->pb);
size--; size--;
if (st->codec->codec_id == CODEC_ID_H264) { 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; pts = dts + cts;
if (cts < 0) { // dts are wrong if (cts < 0) { // dts are wrong
flv->wrong_dts = 1; flv->wrong_dts = 1;
......
...@@ -39,20 +39,20 @@ struct gxf_stream_info { ...@@ -39,20 +39,20 @@ struct gxf_stream_info {
* \return 0 if header not found or contains invalid data, 1 otherwise * \return 0 if header not found or contains invalid data, 1 otherwise
*/ */
static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) { static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) {
if (get_be32(pb)) if (avio_rb32(pb))
return 0; return 0;
if (get_byte(pb) != 1) if (avio_r8(pb) != 1)
return 0; return 0;
*type = get_byte(pb); *type = avio_r8(pb);
*length = get_be32(pb); *length = avio_rb32(pb);
if ((*length >> 24) || *length < 16) if ((*length >> 24) || *length < 16)
return 0; return 0;
*length -= 16; *length -= 16;
if (get_be32(pb)) if (avio_rb32(pb))
return 0; return 0;
if (get_byte(pb) != 0xe1) if (avio_r8(pb) != 0xe1)
return 0; return 0;
if (get_byte(pb) != 0xe2) if (avio_r8(pb) != 0xe2)
return 0; return 0;
return 1; return 1;
} }
...@@ -161,14 +161,14 @@ static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info ...@@ -161,14 +161,14 @@ static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info
si->first_field = AV_NOPTS_VALUE; si->first_field = AV_NOPTS_VALUE;
si->last_field = AV_NOPTS_VALUE; si->last_field = AV_NOPTS_VALUE;
while (*len >= 2) { while (*len >= 2) {
GXFMatTag tag = get_byte(pb); GXFMatTag tag = avio_r8(pb);
int tlen = get_byte(pb); int tlen = avio_r8(pb);
*len -= 2; *len -= 2;
if (tlen > *len) if (tlen > *len)
return; return;
*len -= tlen; *len -= tlen;
if (tlen == 4) { if (tlen == 4) {
uint32_t value = get_be32(pb); uint32_t value = avio_rb32(pb);
if (tag == MAT_FIRST_FIELD) if (tag == MAT_FIRST_FIELD)
si->first_field = value; si->first_field = value;
else if (tag == MAT_LAST_FIELD) else if (tag == MAT_LAST_FIELD)
...@@ -210,14 +210,14 @@ static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si ...@@ -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->frames_per_second = (AVRational){0, 0};
si->fields_per_frame = 0; si->fields_per_frame = 0;
while (*len >= 2) { while (*len >= 2) {
GXFTrackTag tag = get_byte(pb); GXFTrackTag tag = avio_r8(pb);
int tlen = get_byte(pb); int tlen = avio_r8(pb);
*len -= 2; *len -= 2;
if (tlen > *len) if (tlen > *len)
return; return;
*len -= tlen; *len -= tlen;
if (tlen == 4) { if (tlen == 4) {
uint32_t value = get_be32(pb); uint32_t value = avio_rb32(pb);
if (tag == TRACK_FPS) if (tag == TRACK_FPS)
si->frames_per_second = fps_tag2avr(value); si->frames_per_second = fps_tag2avr(value);
else if (tag == TRACK_FPF && (value == 1 || value == 2)) 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 ...@@ -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) { static void gxf_read_index(AVFormatContext *s, int pkt_len) {
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
AVStream *st = s->streams[0]; AVStream *st = s->streams[0];
uint32_t fields_per_map = get_le32(pb); uint32_t fields_per_map = avio_rl32(pb);
uint32_t map_cnt = get_le32(pb); uint32_t map_cnt = avio_rl32(pb);
int i; int i;
pkt_len -= 8; pkt_len -= 8;
if (s->flags & AVFMT_FLAG_IGNIDX) { if (s->flags & AVFMT_FLAG_IGNIDX) {
...@@ -253,7 +253,7 @@ static void gxf_read_index(AVFormatContext *s, int pkt_len) { ...@@ -253,7 +253,7 @@ static void gxf_read_index(AVFormatContext *s, int pkt_len) {
pkt_len -= 4 * map_cnt; pkt_len -= 4 * map_cnt;
av_add_index_entry(st, 0, 0, 0, 0, 0); av_add_index_entry(st, 0, 0, 0, 0, 0);
for (i = 0; i < map_cnt; i++) 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); i * (uint64_t)fields_per_map + 1, 0, 0, 0);
url_fskip(pb, pkt_len); url_fskip(pb, pkt_len);
} }
...@@ -271,12 +271,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { ...@@ -271,12 +271,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
return 0; return 0;
} }
map_len -= 2; 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"); av_log(s, AV_LOG_ERROR, "unknown version or invalid map preamble\n");
return 0; return 0;
} }
map_len -= 2; 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) { if (len > map_len) {
av_log(s, AV_LOG_ERROR, "material data longer than map data\n"); av_log(s, AV_LOG_ERROR, "material data longer than map data\n");
return 0; return 0;
...@@ -285,7 +285,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { ...@@ -285,7 +285,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
gxf_material_tags(pb, &len, &si); gxf_material_tags(pb, &len, &si);
url_fskip(pb, len); url_fskip(pb, len);
map_len -= 2; map_len -= 2;
len = get_be16(pb); // length of track description len = avio_rb16(pb); // length of track description
if (len > map_len) { if (len > map_len) {
av_log(s, AV_LOG_ERROR, "track description longer than map data\n"); av_log(s, AV_LOG_ERROR, "track description longer than map data\n");
return 0; return 0;
...@@ -296,9 +296,9 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { ...@@ -296,9 +296,9 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
AVStream *st; AVStream *st;
int idx; int idx;
len -= 4; len -= 4;
track_type = get_byte(pb); track_type = avio_r8(pb);
track_id = get_byte(pb); track_id = avio_r8(pb);
track_len = get_be16(pb); track_len = avio_rb16(pb);
len -= track_len; len -= track_len;
gxf_track_tags(pb, &track_len, &si); gxf_track_tags(pb, &track_len, &si);
url_fskip(pb, track_len); url_fskip(pb, track_len);
...@@ -344,7 +344,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { ...@@ -344,7 +344,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
len -= 0x39; len -= 0x39;
url_fskip(pb, 5); // preamble url_fskip(pb, 5); // preamble
url_fskip(pb, 0x30); // payload description 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) { if (!main_timebase.num || !main_timebase.den) {
// this may not always be correct, but simply the best we can get // this may not always be correct, but simply the best we can get
main_timebase.num = fps.den; main_timebase.num = fps.den;
...@@ -370,7 +370,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { ...@@ -370,7 +370,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
{ \ { \
if (!max_interval-- || url_feof(pb)) \ if (!max_interval-- || url_feof(pb)) \
goto out; \ 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 ...@@ -389,7 +389,7 @@ static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int t
int len; int len;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
GXFPktType type; GXFPktType type;
tmp = get_be32(pb); tmp = avio_rb32(pb);
start: start:
while (tmp) while (tmp)
READ_ONE(); READ_ONE();
...@@ -404,9 +404,9 @@ start: ...@@ -404,9 +404,9 @@ start:
goto out; goto out;
goto start; goto start;
} }
get_byte(pb); avio_r8(pb);
cur_track = get_byte(pb); cur_track = avio_r8(pb);
cur_timestamp = get_be32(pb); cur_timestamp = avio_rb32(pb);
last_found_pos = url_ftell(pb) - 16 - 6; last_found_pos = url_ftell(pb) - 16 - 6;
if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) { if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
if (url_fseek(pb, last_pos, SEEK_SET) >= 0) if (url_fseek(pb, last_pos, SEEK_SET) >= 0)
...@@ -445,17 +445,17 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { ...@@ -445,17 +445,17 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
continue; continue;
} }
pkt_len -= 16; pkt_len -= 16;
track_type = get_byte(pb); track_type = avio_r8(pb);
track_id = get_byte(pb); track_id = avio_r8(pb);
stream_index = get_sindex(s, track_id, track_type); stream_index = get_sindex(s, track_id, track_type);
if (stream_index < 0) if (stream_index < 0)
return stream_index; return stream_index;
st = s->streams[stream_index]; st = s->streams[stream_index];
field_nr = get_be32(pb); field_nr = avio_rb32(pb);
field_info = get_be32(pb); field_info = avio_rb32(pb);
get_be32(pb); // "timeline" field number avio_rb32(pb); // "timeline" field number
get_byte(pb); // flags avio_r8(pb); // flags
get_byte(pb); // reserved avio_r8(pb); // reserved
if (st->codec->codec_id == CODEC_ID_PCM_S24LE || if (st->codec->codec_id == CODEC_ID_PCM_S24LE ||
st->codec->codec_id == CODEC_ID_PCM_S16LE) { st->codec->codec_id == CODEC_ID_PCM_S16LE) {
int first = field_info >> 16; int first = field_info >> 16;
......
...@@ -233,7 +233,7 @@ void ff_id3v1_read(AVFormatContext *s) ...@@ -233,7 +233,7 @@ void ff_id3v1_read(AVFormatContext *s)
filesize = url_fsize(s->pb); filesize = url_fsize(s->pb);
if (filesize > 128) { if (filesize > 128) {
url_fseek(s->pb, filesize - 128, SEEK_SET); 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) { if (ret == ID3v1_TAG_SIZE) {
parse_tag(s, buf); parse_tag(s, buf);
} }
......
...@@ -55,7 +55,7 @@ static unsigned int get_size(AVIOContext *s, int len) ...@@ -55,7 +55,7 @@ static unsigned int get_size(AVIOContext *s, int len)
{ {
int v = 0; int v = 0;
while (len--) while (len--)
v = (v << 7) + (get_byte(s) & 0x7F); v = (v << 7) + (avio_r8(s) & 0x7F);
return v; return v;
} }
...@@ -65,7 +65,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha ...@@ -65,7 +65,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
const char *val = NULL; const char *val = NULL;
int len, dstlen = sizeof(dst) - 1; int len, dstlen = sizeof(dst) - 1;
unsigned genre; unsigned genre;
unsigned int (*get)(AVIOContext*) = get_be16; unsigned int (*get)(AVIOContext*) = avio_rb16;
dst[0] = 0; dst[0] = 0;
if (taglen < 1) if (taglen < 1)
...@@ -73,22 +73,22 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha ...@@ -73,22 +73,22 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
taglen--; /* account for encoding type byte */ taglen--; /* account for encoding type byte */
switch (get_byte(pb)) { /* encoding type */ switch (avio_r8(pb)) { /* encoding type */
case ID3v2_ENCODING_ISO8859: case ID3v2_ENCODING_ISO8859:
q = dst; q = dst;
while (taglen-- && q - dst < dstlen - 7) { while (taglen-- && q - dst < dstlen - 7) {
uint8_t tmp; uint8_t tmp;
PUT_UTF8(get_byte(pb), tmp, *q++ = tmp;) PUT_UTF8(avio_r8(pb), tmp, *q++ = tmp;)
} }
*q = 0; *q = 0;
break; break;
case ID3v2_ENCODING_UTF16BOM: case ID3v2_ENCODING_UTF16BOM:
taglen -= 2; taglen -= 2;
switch (get_be16(pb)) { switch (avio_rb16(pb)) {
case 0xfffe: case 0xfffe:
get = get_le16; get = avio_rl16;
case 0xfeff: case 0xfeff:
break; break;
default: default:
...@@ -111,7 +111,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha ...@@ -111,7 +111,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
case ID3v2_ENCODING_UTF8: case ID3v2_ENCODING_UTF8:
len = FFMIN(taglen, dstlen); len = FFMIN(taglen, dstlen);
get_buffer(pb, dst, len); avio_read(pb, dst, len);
dst[len] = 0; dst[len] = 0;
break; break;
default: default:
...@@ -178,18 +178,18 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t ...@@ -178,18 +178,18 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
int tunsync = 0; int tunsync = 0;
if (isv34) { if (isv34) {
get_buffer(s->pb, tag, 4); avio_read(s->pb, tag, 4);
tag[4] = 0; tag[4] = 0;
if(version==3){ if(version==3){
tlen = get_be32(s->pb); tlen = avio_rb32(s->pb);
}else }else
tlen = get_size(s->pb, 4); tlen = get_size(s->pb, 4);
tflags = get_be16(s->pb); tflags = avio_rb16(s->pb);
tunsync = tflags & ID3v2_FLAG_UNSYNCH; tunsync = tflags & ID3v2_FLAG_UNSYNCH;
} else { } else {
get_buffer(s->pb, tag, 3); avio_read(s->pb, tag, 3);
tag[3] = 0; tag[3] = 0;
tlen = get_be24(s->pb); tlen = avio_rb24(s->pb);
} }
len -= taghdrlen + tlen; len -= taghdrlen + tlen;
...@@ -199,7 +199,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t ...@@ -199,7 +199,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
next = url_ftell(s->pb) + tlen; next = url_ftell(s->pb) + tlen;
if (tflags & ID3v2_FLAG_DATALEN) { if (tflags & ID3v2_FLAG_DATALEN) {
get_be32(s->pb); avio_rb32(s->pb);
tlen -= 4; tlen -= 4;
} }
...@@ -211,7 +211,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t ...@@ -211,7 +211,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
int i, j; int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen); av_fast_malloc(&buffer, &buffer_size, tlen);
for (i = 0, j = 0; i < tlen; i++, j++) { 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) { if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) {
/* Unsynchronised byte, skip it */ /* Unsynchronised byte, skip it */
j--; j--;
...@@ -259,7 +259,7 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic) ...@@ -259,7 +259,7 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic)
do { do {
/* save the current offset in case there's nothing to read/skip */ /* save the current offset in case there's nothing to read/skip */
off = url_ftell(s->pb); 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) if (ret != ID3v2_HEADER_SIZE)
break; break;
found_header = ff_id3v2_match(buf, magic); found_header = ff_id3v2_match(buf, magic);
......
...@@ -149,11 +149,11 @@ static int idcin_read_header(AVFormatContext *s, ...@@ -149,11 +149,11 @@ static int idcin_read_header(AVFormatContext *s,
unsigned int sample_rate, bytes_per_sample, channels; unsigned int sample_rate, bytes_per_sample, channels;
/* get the 5 header parameters */ /* get the 5 header parameters */
width = get_le32(pb); width = avio_rl32(pb);
height = get_le32(pb); height = avio_rl32(pb);
sample_rate = get_le32(pb); sample_rate = avio_rl32(pb);
bytes_per_sample = get_le32(pb); bytes_per_sample = avio_rl32(pb);
channels = get_le32(pb); channels = avio_rl32(pb);
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
...@@ -169,7 +169,7 @@ static int idcin_read_header(AVFormatContext *s, ...@@ -169,7 +169,7 @@ static int idcin_read_header(AVFormatContext *s,
/* load up the Huffman tables into extradata */ /* load up the Huffman tables into extradata */
st->codec->extradata_size = HUFFMAN_TABLE_SIZE; st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(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) HUFFMAN_TABLE_SIZE)
return AVERROR(EIO); return AVERROR(EIO);
/* save a reference in order to transport the palette */ /* save a reference in order to transport the palette */
...@@ -231,13 +231,13 @@ static int idcin_read_packet(AVFormatContext *s, ...@@ -231,13 +231,13 @@ static int idcin_read_packet(AVFormatContext *s,
return AVERROR(EIO); return AVERROR(EIO);
if (idcin->next_chunk_is_video) { if (idcin->next_chunk_is_video) {
command = get_le32(pb); command = avio_rl32(pb);
if (command == 2) { if (command == 2) {
return AVERROR(EIO); return AVERROR(EIO);
} else if (command == 1) { } else if (command == 1) {
/* trigger a palette change */ /* trigger a palette change */
idcin->palctrl.palette_changed = 1; idcin->palctrl.palette_changed = 1;
if (get_buffer(pb, palette_buffer, 768) != 768) if (avio_read(pb, palette_buffer, 768) != 768)
return AVERROR(EIO); return AVERROR(EIO);
/* scale the palette as necessary */ /* scale the palette as necessary */
palette_scale = 2; palette_scale = 2;
...@@ -255,7 +255,7 @@ static int idcin_read_packet(AVFormatContext *s, ...@@ -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) */ /* skip the number of decoded bytes (always equal to width * height) */
url_fseek(pb, 4, SEEK_CUR); url_fseek(pb, 4, SEEK_CUR);
chunk_size -= 4; chunk_size -= 4;
......
...@@ -74,7 +74,7 @@ static int roq_read_header(AVFormatContext *s, ...@@ -74,7 +74,7 @@ static int roq_read_header(AVFormatContext *s,
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE]; unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
/* get the main header */ /* 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) RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO); return AVERROR(EIO);
framerate = AV_RL16(&preamble[6]); framerate = AV_RL16(&preamble[6]);
...@@ -115,7 +115,7 @@ static int roq_read_packet(AVFormatContext *s, ...@@ -115,7 +115,7 @@ static int roq_read_packet(AVFormatContext *s,
return AVERROR(EIO); return AVERROR(EIO);
/* get the next chunk preamble */ /* 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) RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO); return AVERROR(EIO);
...@@ -129,7 +129,7 @@ static int roq_read_packet(AVFormatContext *s, ...@@ -129,7 +129,7 @@ static int roq_read_packet(AVFormatContext *s,
case RoQ_INFO: case RoQ_INFO:
if (!roq->width || !roq->height) { if (!roq->width || !roq->height) {
AVStream *st = s->streams[roq->video_stream_index]; 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); return AVERROR(EIO);
st->codec->width = roq->width = AV_RL16(preamble); st->codec->width = roq->width = AV_RL16(preamble);
st->codec->height = roq->height = AV_RL16(preamble + 2); st->codec->height = roq->height = AV_RL16(preamble + 2);
...@@ -144,7 +144,7 @@ static int roq_read_packet(AVFormatContext *s, ...@@ -144,7 +144,7 @@ static int roq_read_packet(AVFormatContext *s,
codebook_offset = url_ftell(pb) - RoQ_CHUNK_PREAMBLE_SIZE; codebook_offset = url_ftell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
codebook_size = chunk_size; codebook_size = chunk_size;
url_fseek(pb, codebook_size, SEEK_CUR); 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) RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO); return AVERROR(EIO);
chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 + chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
...@@ -198,7 +198,7 @@ static int roq_read_packet(AVFormatContext *s, ...@@ -198,7 +198,7 @@ static int roq_read_packet(AVFormatContext *s,
} }
pkt->pos= url_ftell(pb); 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); chunk_size);
if (ret != chunk_size) if (ret != chunk_size)
ret = AVERROR(EIO); ret = AVERROR(EIO);
......
...@@ -101,7 +101,7 @@ static int get_metadata(AVFormatContext *s, ...@@ -101,7 +101,7 @@ static int get_metadata(AVFormatContext *s,
if (!buf) if (!buf)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (get_buffer(s->pb, buf, data_size) < 0) { if (avio_read(s->pb, buf, data_size) < 0) {
av_free(buf); av_free(buf);
return AVERROR(EIO); return AVERROR(EIO);
} }
...@@ -136,14 +136,14 @@ static int iff_read_header(AVFormatContext *s, ...@@ -136,14 +136,14 @@ static int iff_read_header(AVFormatContext *s,
st->codec->channels = 1; st->codec->channels = 1;
url_fskip(pb, 8); url_fskip(pb, 8);
// codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content // 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)) { while(!url_feof(pb)) {
uint64_t orig_pos; uint64_t orig_pos;
int res; int res;
const char *metadata_tag = NULL; const char *metadata_tag = NULL;
chunk_id = get_le32(pb); chunk_id = avio_rl32(pb);
data_size = get_be32(pb); data_size = avio_rb32(pb);
orig_pos = url_ftell(pb); orig_pos = url_ftell(pb);
switch(chunk_id) { switch(chunk_id) {
...@@ -153,10 +153,10 @@ static int iff_read_header(AVFormatContext *s, ...@@ -153,10 +153,10 @@ static int iff_read_header(AVFormatContext *s,
if (data_size < 14) if (data_size < 14)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
url_fskip(pb, 12); url_fskip(pb, 12);
st->codec->sample_rate = get_be16(pb); st->codec->sample_rate = avio_rb16(pb);
if (data_size >= 16) { if (data_size >= 16) {
url_fskip(pb, 1); url_fskip(pb, 1);
compression = get_byte(pb); compression = avio_r8(pb);
} }
break; break;
...@@ -168,7 +168,7 @@ static int iff_read_header(AVFormatContext *s, ...@@ -168,7 +168,7 @@ static int iff_read_header(AVFormatContext *s,
case ID_CHAN: case ID_CHAN:
if (data_size < 4) if (data_size < 4)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
st->codec->channels = (get_be32(pb) < 6) ? 1 : 2; st->codec->channels = (avio_rb32(pb) < 6) ? 1 : 2;
break; break;
case ID_CMAP: case ID_CMAP:
...@@ -176,7 +176,7 @@ static int iff_read_header(AVFormatContext *s, ...@@ -176,7 +176,7 @@ static int iff_read_header(AVFormatContext *s,
st->codec->extradata = av_malloc(data_size); st->codec->extradata = av_malloc(data_size);
if (!st->codec->extradata) if (!st->codec->extradata)
return AVERROR(ENOMEM); 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); return AVERROR(EIO);
break; break;
...@@ -184,18 +184,18 @@ static int iff_read_header(AVFormatContext *s, ...@@ -184,18 +184,18 @@ static int iff_read_header(AVFormatContext *s,
st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
if (data_size <= 8) if (data_size <= 8)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
st->codec->width = get_be16(pb); st->codec->width = avio_rb16(pb);
st->codec->height = get_be16(pb); st->codec->height = avio_rb16(pb);
url_fskip(pb, 4); // x, y offset 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) { if (data_size >= 11) {
url_fskip(pb, 1); // masking url_fskip(pb, 1); // masking
compression = get_byte(pb); compression = avio_r8(pb);
} }
if (data_size >= 16) { if (data_size >= 16) {
url_fskip(pb, 3); // paddding, transparent url_fskip(pb, 3); // paddding, transparent
st->sample_aspect_ratio.num = get_byte(pb); st->sample_aspect_ratio.num = avio_r8(pb);
st->sample_aspect_ratio.den = get_byte(pb); st->sample_aspect_ratio.den = avio_r8(pb);
} }
break; break;
...@@ -286,7 +286,7 @@ static int iff_read_packet(AVFormatContext *s, ...@@ -286,7 +286,7 @@ static int iff_read_packet(AVFormatContext *s,
if(st->codec->channels == 2) { if(st->codec->channels == 2) {
uint8_t sample_buffer[PACKET_SIZE]; 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) { if(av_new_packet(pkt, PACKET_SIZE) < 0) {
av_log(s, AV_LOG_ERROR, "cannot allocate packet\n"); av_log(s, AV_LOG_ERROR, "cannot allocate packet\n");
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
......
...@@ -298,7 +298,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -298,7 +298,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
pkt->size= 0; pkt->size= 0;
for(i=0; i<3; i++){ for(i=0; i<3; i++){
if(size[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) if (!s->is_pipe)
url_fclose(f[i]); url_fclose(f[i]);
if(ret[i]>0) if(ret[i]>0)
......
...@@ -27,18 +27,18 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -27,18 +27,18 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
{ {
int ret, size, w, h, unk1, unk2; 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 return AVERROR(EIO); // FIXME
size = get_le32(s->pb); size = avio_rl32(s->pb);
w = get_le16(s->pb); w = avio_rl16(s->pb);
h = get_le16(s->pb); h = avio_rl16(s->pb);
url_fskip(s->pb, 8); // zero + size (padded?) url_fskip(s->pb, 8); // zero + size (padded?)
url_fskip(s->pb, 2); url_fskip(s->pb, 2);
unk1 = get_le16(s->pb); unk1 = avio_rl16(s->pb);
unk2 = get_le16(s->pb); unk2 = avio_rl16(s->pb);
url_fskip(s->pb, 22); // ASCII timestamp 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", 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) ...@@ -49,7 +49,7 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = url_ftell(s->pb); pkt->pos = url_ftell(s->pb);
pkt->stream_index = 0; pkt->stream_index = 0;
ret = get_buffer(s->pb, pkt->data, size); ret = avio_read(s->pb, pkt->data, size);
if (ret < 0) { if (ret < 0) {
av_free_packet(pkt); av_free_packet(pkt);
return ret; return ret;
......
...@@ -166,7 +166,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, ...@@ -166,7 +166,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET); url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET);
s->decode_map_chunk_offset = 0; 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) { s->decode_map_chunk_size) {
av_free_packet(pkt); av_free_packet(pkt);
return CHUNK_EOF; return CHUNK_EOF;
...@@ -175,7 +175,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, ...@@ -175,7 +175,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
url_fseek(pb, s->video_chunk_offset, SEEK_SET); url_fseek(pb, s->video_chunk_offset, SEEK_SET);
s->video_chunk_offset = 0; 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) { s->video_chunk_size) != s->video_chunk_size) {
av_free_packet(pkt); av_free_packet(pkt);
return CHUNK_EOF; return CHUNK_EOF;
...@@ -227,7 +227,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, ...@@ -227,7 +227,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
/* read the next chunk, wherever the file happens to be pointing */ /* read the next chunk, wherever the file happens to be pointing */
if (url_feof(pb)) if (url_feof(pb))
return CHUNK_EOF; return CHUNK_EOF;
if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) != if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE) CHUNK_PREAMBLE_SIZE)
return CHUNK_BAD; return CHUNK_BAD;
chunk_size = AV_RL16(&chunk_preamble[0]); chunk_size = AV_RL16(&chunk_preamble[0]);
...@@ -275,7 +275,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, ...@@ -275,7 +275,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_EOF; chunk_type = CHUNK_EOF;
break; break;
} }
if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) != if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE) { CHUNK_PREAMBLE_SIZE) {
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
...@@ -314,7 +314,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, ...@@ -314,7 +314,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
if (get_buffer(pb, scratch, opcode_size) != if (avio_read(pb, scratch, opcode_size) !=
opcode_size) { opcode_size) {
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
...@@ -331,7 +331,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, ...@@ -331,7 +331,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
if (get_buffer(pb, scratch, opcode_size) != if (avio_read(pb, scratch, opcode_size) !=
opcode_size) { opcode_size) {
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
...@@ -369,7 +369,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, ...@@ -369,7 +369,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
if (get_buffer(pb, scratch, opcode_size) != if (avio_read(pb, scratch, opcode_size) !=
opcode_size) { opcode_size) {
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
...@@ -434,7 +434,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, ...@@ -434,7 +434,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
if (get_buffer(pb, scratch, opcode_size) != opcode_size) { if (avio_read(pb, scratch, opcode_size) != opcode_size) {
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
...@@ -528,10 +528,10 @@ static int ipmovie_read_header(AVFormatContext *s, ...@@ -528,10 +528,10 @@ static int ipmovie_read_header(AVFormatContext *s,
int chunk_type; int chunk_type;
uint8_t signature_buffer[sizeof(signature)]; 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))) { while (memcmp(signature_buffer, signature, sizeof(signature))) {
memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1); 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)) if (url_feof(pb))
return AVERROR_EOF; return AVERROR_EOF;
} }
...@@ -549,7 +549,7 @@ static int ipmovie_read_header(AVFormatContext *s, ...@@ -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 /* 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 */ * 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) CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO); return AVERROR(EIO);
chunk_type = AV_RL16(&chunk_preamble[2]); chunk_type = AV_RL16(&chunk_preamble[2]);
......
...@@ -346,7 +346,7 @@ int ff_mp4_read_descr_len(AVIOContext *pb) ...@@ -346,7 +346,7 @@ int ff_mp4_read_descr_len(AVIOContext *pb)
int len = 0; int len = 0;
int count = 4; int count = 4;
while (count--) { while (count--) {
int c = get_byte(pb); int c = avio_r8(pb);
len = (len << 7) | (c & 0x7f); len = (len << 7) | (c & 0x7f);
if (!(c & 0x80)) if (!(c & 0x80))
break; break;
...@@ -357,7 +357,7 @@ int ff_mp4_read_descr_len(AVIOContext *pb) ...@@ -357,7 +357,7 @@ int ff_mp4_read_descr_len(AVIOContext *pb)
int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag) int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
{ {
int len; int len;
*tag = get_byte(pb); *tag = avio_r8(pb);
len = ff_mp4_read_descr_len(pb); len = ff_mp4_read_descr_len(pb);
av_dlog(fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len); av_dlog(fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
return len; return len;
...@@ -375,11 +375,11 @@ static const AVCodecTag mp4_audio_types[] = { ...@@ -375,11 +375,11 @@ static const AVCodecTag mp4_audio_types[] = {
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb) int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
{ {
int len, tag; int len, tag;
int object_type_id = get_byte(pb); int object_type_id = avio_r8(pb);
get_byte(pb); /* stream type */ avio_r8(pb); /* stream type */
get_be24(pb); /* buffer size db */ avio_rb24(pb); /* buffer size db */
get_be32(pb); /* max bitrate */ avio_rb32(pb); /* max bitrate */
get_be32(pb); /* avg bitrate */ avio_rb32(pb); /* avg bitrate */
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); 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); 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 ...@@ -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); st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) if (!st->codec->extradata)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
get_buffer(pb, st->codec->extradata, len); avio_read(pb, st->codec->extradata, len);
st->codec->extradata_size = len; st->codec->extradata_size = len;
if (st->codec->codec_id == CODEC_ID_AAC) { if (st->codec->codec_id == CODEC_ID_AAC) {
MPEG4AudioConfig cfg; MPEG4AudioConfig cfg;
......
...@@ -44,7 +44,7 @@ static void get_token(AVIOContext *s, char *buf, int maxlen) ...@@ -44,7 +44,7 @@ static void get_token(AVIOContext *s, char *buf, int maxlen)
int i = 0; int i = 0;
char c; char c;
while ((c = get_byte(s))) { while ((c = avio_r8(s))) {
if(c == ' ') if(c == ' ')
break; break;
if (i < maxlen-1) if (i < maxlen-1)
...@@ -52,7 +52,7 @@ static void get_token(AVIOContext *s, char *buf, int maxlen) ...@@ -52,7 +52,7 @@ static void get_token(AVIOContext *s, char *buf, int maxlen)
} }
if(!c) if(!c)
get_byte(s); avio_r8(s);
buf[i] = 0; /* Ensure null terminated, but may be truncated */ buf[i] = 0; /* Ensure null terminated, but may be truncated */
} }
......
...@@ -57,13 +57,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -57,13 +57,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
{ {
int ret, size, pts, type; int ret, size, pts, type;
retry: retry:
type= get_be16(s->pb); // 257 or 258 type= avio_rb16(s->pb); // 257 or 258
size= get_be16(s->pb); size= avio_rb16(s->pb);
get_be16(s->pb); //some flags, 0x80 indicates end of frame avio_rb16(s->pb); //some flags, 0x80 indicates end of frame
get_be16(s->pb); //packet number avio_rb16(s->pb); //packet number
pts=get_be32(s->pb); pts=avio_rb32(s->pb);
get_be32(s->pb); //6A 13 E3 88 avio_rb32(s->pb); //6A 13 E3 88
size -= 12; size -= 12;
if(size<1) if(size<1)
......
...@@ -36,9 +36,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -36,9 +36,9 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st; AVStream *st;
AVRational time_base; AVRational time_base;
get_le32(s->pb); // DKIF avio_rl32(s->pb); // DKIF
get_le16(s->pb); // version avio_rl16(s->pb); // version
get_le16(s->pb); // header size avio_rl16(s->pb); // header size
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
...@@ -46,13 +46,13 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -46,13 +46,13 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO; 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->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
st->codec->width = get_le16(s->pb); st->codec->width = avio_rl16(s->pb);
st->codec->height = get_le16(s->pb); st->codec->height = avio_rl16(s->pb);
time_base.den = get_le32(s->pb); time_base.den = avio_rl32(s->pb);
time_base.num = get_le32(s->pb); time_base.num = avio_rl32(s->pb);
st->duration = get_le64(s->pb); st->duration = avio_rl64(s->pb);
st->need_parsing = AVSTREAM_PARSE_HEADERS; st->need_parsing = AVSTREAM_PARSE_HEADERS;
...@@ -68,8 +68,8 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -68,8 +68,8 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
static int read_packet(AVFormatContext *s, AVPacket *pkt) static int read_packet(AVFormatContext *s, AVPacket *pkt)
{ {
int ret, size = get_le32(s->pb); int ret, size = avio_rl32(s->pb);
int64_t pts = get_le64(s->pb); int64_t pts = avio_rl64(s->pb);
ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0; pkt->stream_index = 0;
......
...@@ -173,7 +173,7 @@ static int nut_probe(AVProbeData *p) { ...@@ -173,7 +173,7 @@ static int nut_probe(AVProbeData *p) {
static size_t av_read(void * h, size_t len, uint8_t * buf) { static size_t av_read(void * h, size_t len, uint8_t * buf) {
AVIOContext * bc = h; 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) { static off_t av_seek(void * h, long long pos, int whence) {
......
...@@ -82,9 +82,9 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt) { ...@@ -82,9 +82,9 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt) {
int ret; int ret;
unsigned int frame_type, packet_size, padding, frame_size; unsigned int frame_type, packet_size, padding, frame_size;
get_be16(pb); /* channel number */ avio_rb16(pb); /* channel number */
frame_type = get_be16(pb); frame_type = avio_rb16(pb);
packet_size = get_be32(pb); packet_size = avio_rb32(pb);
padding = -packet_size & 511; padding = -packet_size & 511;
frame_size = packet_size - 8; frame_size = packet_size - 8;
......
...@@ -86,7 +86,7 @@ static int sync(AVFormatContext *s, uint8_t *header) ...@@ -86,7 +86,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
uint8_t buf[LXF_IDENT_LENGTH]; uint8_t buf[LXF_IDENT_LENGTH];
int ret; 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; return ret < 0 ? ret : AVERROR_EOF;
while (memcmp(buf, LXF_IDENT, LXF_IDENT_LENGTH)) { while (memcmp(buf, LXF_IDENT, LXF_IDENT_LENGTH)) {
...@@ -94,7 +94,7 @@ static int sync(AVFormatContext *s, uint8_t *header) ...@@ -94,7 +94,7 @@ static int sync(AVFormatContext *s, uint8_t *header)
return AVERROR_EOF; return AVERROR_EOF;
memmove(buf, &buf[1], LXF_IDENT_LENGTH-1); 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); memcpy(header, LXF_IDENT, LXF_IDENT_LENGTH);
...@@ -120,7 +120,7 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form ...@@ -120,7 +120,7 @@ static int get_packet_header(AVFormatContext *s, uint8_t *header, uint32_t *form
return ret; return ret;
//read the rest of the packet header //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)) !=
LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH) { LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH) {
return ret < 0 ? ret : AVERROR_EOF; return ret < 0 ? ret : AVERROR_EOF;
...@@ -214,7 +214,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -214,7 +214,7 @@ static int lxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR_INVALIDDATA; 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; return ret < 0 ? ret : AVERROR_EOF;
if (!(st = av_new_stream(s, 0))) if (!(st = av_new_stream(s, 0)))
...@@ -315,7 +315,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -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 //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; 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); av_free_packet(pkt);
return ret2 < 0 ? ret2 : AVERROR_EOF; return ret2 < 0 ? ret2 : AVERROR_EOF;
} }
......
...@@ -543,10 +543,10 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb, ...@@ -543,10 +543,10 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
int read = 1, n = 1; int read = 1, n = 1;
uint64_t total = 0; 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 * return 0, but since that's not a valid first ebmlID byte, we can
* use it safely here to catch EOS. */ * use it safely here to catch EOS. */
if (!(total = get_byte(pb))) { if (!(total = avio_r8(pb))) {
/* we might encounter EOS here */ /* we might encounter EOS here */
if (!url_feof(pb)) { if (!url_feof(pb)) {
int64_t pos = url_ftell(pb); int64_t pos = url_ftell(pb);
...@@ -570,7 +570,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb, ...@@ -570,7 +570,7 @@ static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb,
/* read out length */ /* read out length */
total ^= 1 << ff_log2_tab[total]; total ^= 1 << ff_log2_tab[total];
while (n++ < read) while (n++ < read)
total = (total << 8) | get_byte(pb); total = (total << 8) | avio_r8(pb);
*number = total; *number = total;
...@@ -605,7 +605,7 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num) ...@@ -605,7 +605,7 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
/* big-endian ordering; build up number */ /* big-endian ordering; build up number */
*num = 0; *num = 0;
while (n++ < size) while (n++ < size)
*num = (*num << 8) | get_byte(pb); *num = (*num << 8) | avio_r8(pb);
return 0; return 0;
} }
...@@ -619,9 +619,9 @@ static int ebml_read_float(AVIOContext *pb, int size, double *num) ...@@ -619,9 +619,9 @@ static int ebml_read_float(AVIOContext *pb, int size, double *num)
if (size == 0) { if (size == 0) {
*num = 0; *num = 0;
} else if (size == 4) { } else if (size == 4) {
*num= av_int2flt(get_be32(pb)); *num= av_int2flt(avio_rb32(pb));
} else if(size==8){ } else if(size==8){
*num= av_int2dbl(get_be64(pb)); *num= av_int2dbl(avio_rb64(pb));
} else } else
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -639,7 +639,7 @@ static int ebml_read_ascii(AVIOContext *pb, int size, char **str) ...@@ -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. */ * byte more, read the string and NULL-terminate it ourselves. */
if (!(*str = av_malloc(size + 1))) if (!(*str = av_malloc(size + 1)))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (get_buffer(pb, (uint8_t *) *str, size) != size) { if (avio_read(pb, (uint8_t *) *str, size) != size) {
av_freep(str); av_freep(str);
return AVERROR(EIO); return AVERROR(EIO);
} }
...@@ -660,7 +660,7 @@ static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin) ...@@ -660,7 +660,7 @@ static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin)
bin->size = length; bin->size = length;
bin->pos = url_ftell(pb); 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); av_freep(&bin->data);
return AVERROR(EIO); return AVERROR(EIO);
} }
...@@ -1394,12 +1394,12 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -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, ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL); 0, NULL, NULL, NULL, NULL);
url_fskip(&b, 22); url_fskip(&b, 22);
flavor = get_be16(&b); flavor = avio_rb16(&b);
track->audio.coded_framesize = get_be32(&b); track->audio.coded_framesize = avio_rb32(&b);
url_fskip(&b, 12); url_fskip(&b, 12);
track->audio.sub_packet_h = get_be16(&b); track->audio.sub_packet_h = avio_rb16(&b);
track->audio.frame_size = get_be16(&b); track->audio.frame_size = avio_rb16(&b);
track->audio.sub_packet_size = get_be16(&b); track->audio.sub_packet_size = avio_rb16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h); track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) { if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize; st->codec->block_align = track->audio.coded_framesize;
......
...@@ -90,18 +90,18 @@ static int read_header(AVFormatContext *s, ...@@ -90,18 +90,18 @@ static int read_header(AVFormatContext *s,
unsigned int type, length; unsigned int type, length;
unsigned int frame_rate, width, height; unsigned int frame_rate, width, height;
type = get_le16(pb); type = avio_rl16(pb);
length = get_le32(pb); length = avio_rl32(pb);
if (type != MM_TYPE_HEADER) if (type != MM_TYPE_HEADER)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
/* read header */ /* read header */
get_le16(pb); /* total number of chunks */ avio_rl16(pb); /* total number of chunks */
frame_rate = get_le16(pb); frame_rate = avio_rl16(pb);
get_le16(pb); /* ibm-pc video bios mode */ avio_rl16(pb); /* ibm-pc video bios mode */
width = get_le16(pb); width = avio_rl16(pb);
height = get_le16(pb); height = avio_rl16(pb);
url_fseek(pb, length - 10, SEEK_CUR); /* unknown data */ url_fseek(pb, length - 10, SEEK_CUR); /* unknown data */
/* video stream */ /* video stream */
...@@ -143,7 +143,7 @@ static int read_packet(AVFormatContext *s, ...@@ -143,7 +143,7 @@ static int read_packet(AVFormatContext *s,
while(1) { 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); return AVERROR(EIO);
} }
...@@ -162,7 +162,7 @@ static int read_packet(AVFormatContext *s, ...@@ -162,7 +162,7 @@ static int read_packet(AVFormatContext *s,
if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE)) if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE); 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); return AVERROR(EIO);
pkt->size = length + MM_PREAMBLE_SIZE; pkt->size = length + MM_PREAMBLE_SIZE;
pkt->stream_index = 0; pkt->stream_index = 0;
......
...@@ -188,15 +188,15 @@ static int mmf_read_header(AVFormatContext *s, ...@@ -188,15 +188,15 @@ static int mmf_read_header(AVFormatContext *s,
int64_t file_size, size; int64_t file_size, size;
int rate, params; int rate, params;
tag = get_le32(pb); tag = avio_rl32(pb);
if (tag != MKTAG('M', 'M', 'M', 'D')) if (tag != MKTAG('M', 'M', 'M', 'D'))
return -1; return -1;
file_size = get_be32(pb); file_size = avio_rb32(pb);
/* Skip some unused chunks that may or may not be present */ /* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) { for(;; url_fseek(pb, size, SEEK_CUR)) {
tag = get_le32(pb); tag = avio_rl32(pb);
size = get_be32(pb); size = avio_rb32(pb);
if(tag == MKTAG('C','N','T','I')) continue; if(tag == MKTAG('C','N','T','I')) continue;
if(tag == MKTAG('O','P','D','A')) continue; if(tag == MKTAG('O','P','D','A')) continue;
break; break;
...@@ -212,22 +212,22 @@ static int mmf_read_header(AVFormatContext *s, ...@@ -212,22 +212,22 @@ static int mmf_read_header(AVFormatContext *s,
return -1; return -1;
} }
get_byte(pb); /* format type */ avio_r8(pb); /* format type */
get_byte(pb); /* sequence type */ avio_r8(pb); /* sequence type */
params = get_byte(pb); /* (channel << 7) | (format << 4) | rate */ params = avio_r8(pb); /* (channel << 7) | (format << 4) | rate */
rate = mmf_rate(params & 0x0f); rate = mmf_rate(params & 0x0f);
if(rate < 0) { if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate\n"); av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
return -1; return -1;
} }
get_byte(pb); /* wave base bit */ avio_r8(pb); /* wave base bit */
get_byte(pb); /* time base d */ avio_r8(pb); /* time base d */
get_byte(pb); /* time base g */ avio_r8(pb); /* time base g */
/* Skip some unused chunks that may or may not be present */ /* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) { for(;; url_fseek(pb, size, SEEK_CUR)) {
tag = get_le32(pb); tag = avio_rl32(pb);
size = get_be32(pb); size = avio_rb32(pb);
if(tag == MKTAG('A','t','s','q')) continue; if(tag == MKTAG('A','t','s','q')) continue;
if(tag == MKTAG('A','s','p','I')) continue; if(tag == MKTAG('A','s','p','I')) continue;
break; break;
...@@ -280,7 +280,7 @@ static int mmf_read_packet(AVFormatContext *s, ...@@ -280,7 +280,7 @@ static int mmf_read_packet(AVFormatContext *s,
return AVERROR(EIO); return AVERROR(EIO);
pkt->stream_index = 0; 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) if (ret < 0)
av_free_packet(pkt); av_free_packet(pkt);
......
This diff is collapsed.
...@@ -80,7 +80,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) ...@@ -80,7 +80,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
MPADecodeHeader c; MPADecodeHeader c;
int vbrtag_size = 0; int vbrtag_size = 0;
v = get_be32(s->pb); v = avio_rb32(s->pb);
if(ff_mpa_check_header(v) < 0) if(ff_mpa_check_header(v) < 0)
return -1; return -1;
...@@ -91,25 +91,25 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) ...@@ -91,25 +91,25 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
/* Check for Xing / Info tag */ /* Check for Xing / Info tag */
url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR); 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')) { 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) if(v & 0x1)
frames = get_be32(s->pb); frames = avio_rb32(s->pb);
if(v & 0x2) 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) */ /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
url_fseek(s->pb, base + 4 + 32, SEEK_SET); 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')) { if(v == MKBETAG('V', 'B', 'R', 'I')) {
/* Check tag version */ /* Check tag version */
if(get_be16(s->pb) == 1) { if(avio_rb16(s->pb) == 1) {
/* skip delay and quality */ /* skip delay and quality */
url_fseek(s->pb, 4, SEEK_CUR); url_fseek(s->pb, 4, SEEK_CUR);
frames = get_be32(s->pb); frames = avio_rb32(s->pb);
size = get_be32(s->pb); size = avio_rb32(s->pb);
} }
} }
......
...@@ -55,16 +55,16 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -55,16 +55,16 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
MPCContext *c = s->priv_data; MPCContext *c = s->priv_data;
AVStream *st; 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"); av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
return -1; return -1;
} }
c->ver = get_byte(s->pb); c->ver = avio_r8(s->pb);
if(c->ver != 0x07 && c->ver != 0x17){ if(c->ver != 0x07 && c->ver != 0x17){
av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver); av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver);
return -1; return -1;
} }
c->fcount = get_le32(s->pb); c->fcount = avio_rl32(s->pb);
if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){ if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){
av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n"); av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n");
return -1; return -1;
...@@ -85,7 +85,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -85,7 +85,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = 16; st->codec->extradata_size = 16;
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); 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]; st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3];
av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate); av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate);
/* scan for seekpoints */ /* scan for seekpoints */
...@@ -121,11 +121,11 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -121,11 +121,11 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
c->curframe++; c->curframe++;
curbits = c->curbits; curbits = c->curbits;
pos = url_ftell(s->pb); pos = url_ftell(s->pb);
tmp = get_le32(s->pb); tmp = avio_rl32(s->pb);
if(curbits <= 12){ if(curbits <= 12){
size2 = (tmp >> (12 - curbits)) & 0xFFFFF; size2 = (tmp >> (12 - curbits)) & 0xFFFFF;
}else{ }else{
tmp = (tmp << 32) | get_le32(s->pb); tmp = (tmp << 32) | avio_rl32(s->pb);
size2 = (tmp >> (44 - curbits)) & 0xFFFFF; size2 = (tmp >> (44 - curbits)) & 0xFFFFF;
} }
curbits += 20; curbits += 20;
...@@ -151,7 +151,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -151,7 +151,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = 0; pkt->stream_index = 0;
pkt->pts = cur; pkt->pts = cur;
ret = get_buffer(s->pb, pkt->data + 4, size); ret = avio_read(s->pb, pkt->data + 4, size);
if(c->curbits) if(c->curbits)
url_fseek(s->pb, -4, SEEK_CUR); url_fseek(s->pb, -4, SEEK_CUR);
if(ret < size){ if(ret < size){
......
...@@ -121,7 +121,7 @@ static void mpc8_get_chunk_header(AVIOContext *pb, int *tag, int64_t *size) ...@@ -121,7 +121,7 @@ static void mpc8_get_chunk_header(AVIOContext *pb, int *tag, int64_t *size)
{ {
int64_t pos; int64_t pos;
pos = url_ftell(pb); pos = url_ftell(pb);
*tag = get_le16(pb); *tag = avio_rl16(pb);
*size = ff_get_v(pb); *size = ff_get_v(pb);
*size -= url_ftell(pb) - pos; *size -= url_ftell(pb) - pos;
} }
...@@ -143,7 +143,7 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off) ...@@ -143,7 +143,7 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
} }
if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE))) if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE)))
return; return;
get_buffer(s->pb, buf, size); avio_read(s->pb, buf, size);
init_get_bits(&gb, buf, size * 8); init_get_bits(&gb, buf, size * 8);
size = gb_get_v(&gb); size = gb_get_v(&gb);
if(size > UINT_MAX/4 || size > c->samples/1152){ if(size > UINT_MAX/4 || size > c->samples/1152){
...@@ -195,7 +195,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -195,7 +195,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
int64_t size, pos; int64_t size, pos;
c->header_pos = url_ftell(pb); 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"); av_log(s, AV_LOG_ERROR, "Not a Musepack8 file\n");
return -1; return -1;
} }
...@@ -213,7 +213,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -213,7 +213,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
} }
pos = url_ftell(pb); pos = url_ftell(pb);
url_fskip(pb, 4); //CRC url_fskip(pb, 4); //CRC
c->ver = get_byte(pb); c->ver = avio_r8(pb);
if(c->ver != 8){ if(c->ver != 8){
av_log(s, AV_LOG_ERROR, "Unknown stream version %d\n", c->ver); av_log(s, AV_LOG_ERROR, "Unknown stream version %d\n", c->ver);
return -1; return -1;
...@@ -230,7 +230,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -230,7 +230,7 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->extradata_size = 2; st->codec->extradata_size = 2;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 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->channels = (st->codec->extradata[1] >> 4) + 1;
st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5]; st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5];
......
...@@ -113,7 +113,7 @@ static int mpegps_read_header(AVFormatContext *s, ...@@ -113,7 +113,7 @@ static int mpegps_read_header(AVFormatContext *s,
m->sofdec = -1; m->sofdec = -1;
do { do {
v = get_byte(s->pb); v = avio_r8(s->pb);
m->header_state = m->header_state << 8 | v; m->header_state = m->header_state << 8 | v;
m->sofdec++; m->sofdec++;
} while (v == sofdec[i] && i++ < 6); } while (v == sofdec[i] && i++ < 6);
...@@ -128,8 +128,8 @@ static int64_t get_pts(AVIOContext *pb, int c) ...@@ -128,8 +128,8 @@ static int64_t get_pts(AVIOContext *pb, int c)
{ {
uint8_t buf[5]; uint8_t buf[5];
buf[0] = c<0 ? get_byte(pb) : c; buf[0] = c<0 ? avio_r8(pb) : c;
get_buffer(pb, buf+1, 4); avio_read(pb, buf+1, 4);
return ff_parse_pes_pts(buf); return ff_parse_pes_pts(buf);
} }
...@@ -145,7 +145,7 @@ static int find_next_start_code(AVIOContext *pb, int *size_ptr, ...@@ -145,7 +145,7 @@ static int find_next_start_code(AVIOContext *pb, int *size_ptr,
while (n > 0) { while (n > 0) {
if (url_feof(pb)) if (url_feof(pb))
break; break;
v = get_byte(pb); v = avio_r8(pb);
n--; n--;
if (state == 0x000001) { if (state == 0x000001) {
state = ((state << 8) | v) & 0xffffff; state = ((state << 8) | v) & 0xffffff;
...@@ -176,7 +176,7 @@ static int find_prev_start_code(AVIOContext *pb, int *size_ptr) ...@@ -176,7 +176,7 @@ static int find_prev_start_code(AVIOContext *pb, int *size_ptr)
if (pos < 0) if (pos < 0)
pos = 0; pos = 0;
url_fseek(pb, pos, SEEK_SET); url_fseek(pb, pos, SEEK_SET);
get_byte(pb); avio_r8(pb);
pos = pos_start; pos = pos_start;
for(;;) { for(;;) {
...@@ -186,7 +186,7 @@ static int find_prev_start_code(AVIOContext *pb, int *size_ptr) ...@@ -186,7 +186,7 @@ static int find_prev_start_code(AVIOContext *pb, int *size_ptr)
goto the_end; goto the_end;
} }
url_fseek(pb, pos, SEEK_SET); url_fseek(pb, pos, SEEK_SET);
start_code = get_be32(pb); start_code = avio_rb32(pb);
if ((start_code & 0xffffff00) == 0x100) if ((start_code & 0xffffff00) == 0x100)
break; break;
} }
...@@ -206,27 +206,27 @@ static long mpegps_psm_parse(MpegDemuxContext *m, AVIOContext *pb) ...@@ -206,27 +206,27 @@ static long mpegps_psm_parse(MpegDemuxContext *m, AVIOContext *pb)
{ {
int psm_length, ps_info_length, es_map_length; int psm_length, ps_info_length, es_map_length;
psm_length = get_be16(pb); psm_length = avio_rb16(pb);
get_byte(pb); avio_r8(pb);
get_byte(pb); avio_r8(pb);
ps_info_length = get_be16(pb); ps_info_length = avio_rb16(pb);
/* skip program_stream_info */ /* skip program_stream_info */
url_fskip(pb, ps_info_length); url_fskip(pb, ps_info_length);
es_map_length = get_be16(pb); es_map_length = avio_rb16(pb);
/* at least one es available? */ /* at least one es available? */
while (es_map_length >= 4){ while (es_map_length >= 4){
unsigned char type = get_byte(pb); unsigned char type = avio_r8(pb);
unsigned char es_id = get_byte(pb); unsigned char es_id = avio_r8(pb);
uint16_t es_info_length = get_be16(pb); uint16_t es_info_length = avio_rb16(pb);
/* remember mapping from stream id to stream type */ /* remember mapping from stream id to stream type */
m->psm_es_type[es_id] = type; m->psm_es_type[es_id] = type;
/* skip program_stream_info */ /* skip program_stream_info */
url_fskip(pb, es_info_length); url_fskip(pb, es_info_length);
es_map_length -= 4 + es_info_length; es_map_length -= 4 + es_info_length;
} }
get_be32(pb); /* crc32 */ avio_rb32(pb); /* crc32 */
return 2 + psm_length; return 2 + psm_length;
} }
...@@ -264,16 +264,16 @@ static int mpegps_read_pes_header(AVFormatContext *s, ...@@ -264,16 +264,16 @@ static int mpegps_read_pes_header(AVFormatContext *s,
if (startcode == SYSTEM_HEADER_START_CODE) if (startcode == SYSTEM_HEADER_START_CODE)
goto redo; goto redo;
if (startcode == PADDING_STREAM) { if (startcode == PADDING_STREAM) {
url_fskip(s->pb, get_be16(s->pb)); url_fskip(s->pb, avio_rb16(s->pb));
goto redo; goto redo;
} }
if (startcode == PRIVATE_STREAM_2) { if (startcode == PRIVATE_STREAM_2) {
len = get_be16(s->pb); len = avio_rb16(s->pb);
if (!m->sofdec) { if (!m->sofdec) {
while (len-- >= 6) { while (len-- >= 6) {
if (get_byte(s->pb) == 'S') { if (avio_r8(s->pb) == 'S') {
uint8_t buf[5]; uint8_t buf[5];
get_buffer(s->pb, buf, sizeof(buf)); avio_read(s->pb, buf, sizeof(buf));
m->sofdec = !memcmp(buf, "ofdec", 5); m->sofdec = !memcmp(buf, "ofdec", 5);
len -= sizeof(buf); len -= sizeof(buf);
break; break;
...@@ -297,14 +297,14 @@ static int mpegps_read_pes_header(AVFormatContext *s, ...@@ -297,14 +297,14 @@ static int mpegps_read_pes_header(AVFormatContext *s,
if (ppos) { if (ppos) {
*ppos = url_ftell(s->pb) - 4; *ppos = url_ftell(s->pb) - 4;
} }
len = get_be16(s->pb); len = avio_rb16(s->pb);
pts = pts =
dts = AV_NOPTS_VALUE; dts = AV_NOPTS_VALUE;
/* stuffing */ /* stuffing */
for(;;) { for(;;) {
if (len < 1) if (len < 1)
goto error_redo; goto error_redo;
c = get_byte(s->pb); c = avio_r8(s->pb);
len--; len--;
/* XXX: for mpeg1, should test only bit 7 */ /* XXX: for mpeg1, should test only bit 7 */
if (c != 0xff) if (c != 0xff)
...@@ -312,8 +312,8 @@ static int mpegps_read_pes_header(AVFormatContext *s, ...@@ -312,8 +312,8 @@ static int mpegps_read_pes_header(AVFormatContext *s,
} }
if ((c & 0xc0) == 0x40) { if ((c & 0xc0) == 0x40) {
/* buffer scale & size */ /* buffer scale & size */
get_byte(s->pb); avio_r8(s->pb);
c = get_byte(s->pb); c = avio_r8(s->pb);
len -= 2; len -= 2;
} }
if ((c & 0xe0) == 0x20) { if ((c & 0xe0) == 0x20) {
...@@ -331,8 +331,8 @@ static int mpegps_read_pes_header(AVFormatContext *s, ...@@ -331,8 +331,8 @@ static int mpegps_read_pes_header(AVFormatContext *s,
goto redo; goto redo;
} }
#endif #endif
flags = get_byte(s->pb); flags = avio_r8(s->pb);
header_len = get_byte(s->pb); header_len = avio_r8(s->pb);
len -= 2; len -= 2;
if (header_len > len) if (header_len > len)
goto error_redo; goto error_redo;
...@@ -350,7 +350,7 @@ static int mpegps_read_pes_header(AVFormatContext *s, ...@@ -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"); av_log(s, AV_LOG_WARNING, "Further flags set but no bytes left\n");
} }
if (flags & 0x01) { /* PES extension */ if (flags & 0x01) { /* PES extension */
pes_ext = get_byte(s->pb); pes_ext = avio_r8(s->pb);
header_len--; header_len--;
/* Skip PES private data, program packet sequence counter and P-STD buffer */ /* Skip PES private data, program packet sequence counter and P-STD buffer */
skip = (pes_ext >> 4) & 0xb; skip = (pes_ext >> 4) & 0xb;
...@@ -363,10 +363,10 @@ static int mpegps_read_pes_header(AVFormatContext *s, ...@@ -363,10 +363,10 @@ static int mpegps_read_pes_header(AVFormatContext *s,
header_len -= skip; header_len -= skip;
if (pes_ext & 0x01) { /* PES extension 2 */ if (pes_ext & 0x01) { /* PES extension 2 */
ext2_len = get_byte(s->pb); ext2_len = avio_r8(s->pb);
header_len--; header_len--;
if ((ext2_len & 0x7f) > 0) { if ((ext2_len & 0x7f) > 0) {
id_ext = get_byte(s->pb); id_ext = avio_r8(s->pb);
if ((id_ext & 0x80) == 0) if ((id_ext & 0x80) == 0)
startcode = ((startcode & 0xff) << 8) | id_ext; startcode = ((startcode & 0xff) << 8) | id_ext;
header_len--; header_len--;
...@@ -381,17 +381,17 @@ static int mpegps_read_pes_header(AVFormatContext *s, ...@@ -381,17 +381,17 @@ static int mpegps_read_pes_header(AVFormatContext *s,
goto redo; goto redo;
if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) { if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
startcode = get_byte(s->pb); startcode = avio_r8(s->pb);
len--; len--;
if (startcode >= 0x80 && startcode <= 0xcf) { if (startcode >= 0x80 && startcode <= 0xcf) {
/* audio: skip header */ /* audio: skip header */
get_byte(s->pb); avio_r8(s->pb);
get_byte(s->pb); avio_r8(s->pb);
get_byte(s->pb); avio_r8(s->pb);
len -= 3; len -= 3;
if (startcode >= 0xb0 && startcode <= 0xbf) { if (startcode >= 0xb0 && startcode <= 0xbf) {
/* MLP/TrueHD audio has a 4-byte header */ /* MLP/TrueHD audio has a 4-byte header */
get_byte(s->pb); avio_r8(s->pb);
len--; len--;
} }
} }
...@@ -432,7 +432,7 @@ static int mpegps_read_packet(AVFormatContext *s, ...@@ -432,7 +432,7 @@ static int mpegps_read_packet(AVFormatContext *s,
return len; return len;
if(startcode == 0x1bd) { if(startcode == 0x1bd) {
dvdaudio_substream_type = get_byte(s->pb); dvdaudio_substream_type = avio_r8(s->pb);
url_fskip(s->pb, 3); url_fskip(s->pb, 3);
len -= 4; len -= 4;
} }
...@@ -474,7 +474,7 @@ static int mpegps_read_packet(AVFormatContext *s, ...@@ -474,7 +474,7 @@ static int mpegps_read_packet(AVFormatContext *s,
} else if (startcode >= 0x1e0 && startcode <= 0x1ef) { } else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 }; static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
unsigned char buf[8]; unsigned char buf[8];
get_buffer(s->pb, buf, 8); avio_read(s->pb, buf, 8);
url_fseek(s->pb, -8, SEEK_CUR); url_fseek(s->pb, -8, SEEK_CUR);
if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1)) if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
codec_id = CODEC_ID_CAVS; codec_id = CODEC_ID_CAVS;
...@@ -547,9 +547,9 @@ static int mpegps_read_packet(AVFormatContext *s, ...@@ -547,9 +547,9 @@ static int mpegps_read_packet(AVFormatContext *s,
audio data */ audio data */
if (len <= 3) if (len <= 3)
goto skip; goto skip;
get_byte(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */ avio_r8(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
b1 = get_byte(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */ b1 = avio_r8(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
get_byte(s->pb); /* dynamic range control (0x80 = off) */ avio_r8(s->pb); /* dynamic range control (0x80 = off) */
len -= 3; len -= 3;
freq = (b1 >> 4) & 3; freq = (b1 >> 4) & 3;
st->codec->sample_rate = lpcm_freq_tab[freq]; st->codec->sample_rate = lpcm_freq_tab[freq];
...@@ -564,7 +564,7 @@ static int mpegps_read_packet(AVFormatContext *s, ...@@ -564,7 +564,7 @@ static int mpegps_read_packet(AVFormatContext *s,
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
av_new_packet(pkt, len); 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->pts = pts;
pkt->dts = dts; pkt->dts = dts;
pkt->pos = dummy_pos; pkt->pos = dummy_pos;
......
This diff is collapsed.
...@@ -88,7 +88,7 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap) ...@@ -88,7 +88,7 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap)
/* Some files start with "connected\r\n\r\n". /* Some files start with "connected\r\n\r\n".
* So skip until we find the first byte of struct size */ * 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)) { if(url_feof(pb)) {
av_log(ctx, AV_LOG_ERROR, "Could not find valid start."); 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) ...@@ -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, 1); /* one byte has been read ahead */
url_fskip(pb, 2); url_fskip(pb, 2);
url_fskip(pb, 2); url_fskip(pb, 2);
keyframe = get_le16(pb); keyframe = avio_rl16(pb);
size = get_le32(pb); size = avio_rl32(pb);
url_fskip(pb, 4); url_fskip(pb, 4);
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) if(!size || av_get_packet(pb, pkt, size) != size)
return -1; return -1;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment