#define strk_SIZE 0x28
#define GET_LIST_HEADER() \
- fourcc_tag = get_le32(pb); \
- size = get_le32(pb); \
+ fourcc_tag = avio_rl32(pb); \
+ size = avio_rl32(pb); \
if (fourcc_tag != LIST_TAG) \
return AVERROR_INVALIDDATA; \
- fourcc_tag = get_le32(pb);
+ fourcc_tag = avio_rl32(pb);
typedef struct AudioTrack {
int sample_rate;
header = av_malloc(header_size);
if (!header)
return AVERROR(ENOMEM);
- if (get_buffer(pb, header, header_size) != header_size){
+ if (avio_read(pb, header, header_size) != header_size){
av_free(header);
return AVERROR(EIO);
}
while (!packet_read) {
- if ((ret = get_buffer(s->pb, header, 8)) < 0)
+ if ((ret = avio_read(s->pb, header, 8)) < 0)
return ret;
fourcc_tag = AV_RL32(&header[0]);
size = AV_RL32(&header[4]);
fourxm->video_pts ++;
/* skip the LIST-* tag and move on to the next fourcc */
- get_le32(pb);
+ avio_rl32(pb);
break;
case ifrm_TAG:
pkt->pts = fourxm->video_pts;
pkt->pos = url_ftell(s->pb);
memcpy(pkt->data, header, 8);
- ret = get_buffer(s->pb, &pkt->data[8], size);
+ ret = avio_read(s->pb, &pkt->data[8], size);
if (ret < 0){
av_free_packet(pkt);
break;
case snd__TAG:
- track_number = get_le32(pb);
- out_size= get_le32(pb);
+ track_number = avio_rl32(pb);
+ out_size= avio_rl32(pb);
size-=8;
if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) {
/* Parse the amount of channels and skip to pos 2048(0x800) */
url_fskip(s->pb, 264);
- st->codec->channels = get_byte(s->pb);
+ st->codec->channels = avio_r8(s->pb);
url_fskip(s->pb, 1783);
if (url_feof(pb))
return AVERROR(EIO);
- *tag = get_le32(pb);
- size = get_be32(pb);
+ *tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if (size < 0)
size = 0x7fffffff;
return;
}
- res = get_buffer(s->pb, str, size);
+ res = avio_read(s->pb, str, size);
if (res < 0)
return;
if (size & 1)
size++;
codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->channels = get_be16(pb);
- num_frames = get_be32(pb);
- codec->bits_per_coded_sample = get_be16(pb);
+ codec->channels = avio_rb16(pb);
+ num_frames = avio_rb32(pb);
+ codec->bits_per_coded_sample = avio_rb16(pb);
- get_buffer(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
+ avio_read(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */
codec->sample_rate = sample_rate;
size -= 18;
/* Got an AIFF-C? */
if (version == AIFF_C_VERSION1) {
- codec->codec_tag = get_le32(pb);
+ codec->codec_tag = avio_rl32(pb);
codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
switch (codec->codec_id) {
return AVERROR_INVALIDDATA;
/* AIFF data type */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */
version = AIFF;
else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */
goto got_sound;
break;
case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */
- version = get_be32(pb);
+ version = avio_rb32(pb);
break;
case MKTAG('N', 'A', 'M', 'E'): /* Sample name chunk */
get_meta(s, "title" , size);
break;
case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
aiff->data_end = url_ftell(pb) + size;
- offset = get_be32(pb); /* Offset of sound data */
- get_be32(pb); /* BlockSize... don't care */
+ offset = avio_rb32(pb); /* Offset of sound data */
+ avio_rb32(pb); /* BlockSize... don't care */
offset += url_ftell(pb); /* Compute absolute data offset */
if (st->codec->block_align) /* Assume COMM already parsed */
goto got_sound;
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
- get_buffer(pb, st->codec->extradata, size);
+ avio_read(pb, st->codec->extradata, size);
break;
default: /* Jump */
if (size & 1) /* Always even aligned */
AVStream *st;
uint8_t header[9];
- get_buffer(pb, header, 6);
+ avio_read(pb, header, 6);
st = av_new_stream(s, 0);
if (!st)
}
if(memcmp(header,AMR_header,6)!=0)
{
- get_buffer(pb, header+6, 3);
+ avio_read(pb, header+6, 3);
if(memcmp(header,AMRWB_header,9)!=0)
{
return -1;
}
//FIXME this is wrong, this should rather be in a AVParset
- toc=get_byte(s->pb);
+ toc=avio_r8(s->pb);
mode = (toc >> 3) & 0x0F;
if (enc->codec_id == CODEC_ID_AMR_NB)
pkt->pos= url_ftell(s->pb);
pkt->data[0]=toc;
pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
- read = get_buffer(s->pb, pkt->data+1, size-1);
+ read = avio_read(s->pb, pkt->data+1, size-1);
if (read != size-1)
{
int i, ret;
url_fskip(pb, 4); /* magic number */
- if (get_le16(pb) != MAX_PAGES) {
+ if (avio_rl16(pb) != MAX_PAGES) {
av_log_ask_for_sample(s, "max_pages != " AV_STRINGIFY(MAX_PAGES) "\n");
return AVERROR_INVALIDDATA;
}
- anm->nb_pages = get_le16(pb);
- anm->nb_records = get_le32(pb);
+ anm->nb_pages = avio_rl16(pb);
+ anm->nb_records = avio_rl32(pb);
url_fskip(pb, 2); /* max records per page */
- anm->page_table_offset = get_le16(pb);
- if (get_le32(pb) != ANIM_TAG)
+ anm->page_table_offset = avio_rl16(pb);
+ if (avio_rl32(pb) != ANIM_TAG)
return AVERROR_INVALIDDATA;
/* video stream */
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ANM;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_le16(pb);
- st->codec->height = get_le16(pb);
- if (get_byte(pb) != 0)
+ st->codec->width = avio_rl16(pb);
+ st->codec->height = avio_rl16(pb);
+ if (avio_r8(pb) != 0)
goto invalid;
url_fskip(pb, 1); /* frame rate multiplier info */
/* ignore last delta record (used for looping) */
- if (get_byte(pb)) /* has_last_delta */
+ if (avio_r8(pb)) /* has_last_delta */
anm->nb_records = FFMAX(anm->nb_records - 1, 0);
url_fskip(pb, 1); /* last_delta_valid */
- if (get_byte(pb) != 0)
+ if (avio_r8(pb) != 0)
goto invalid;
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
goto invalid;
url_fskip(pb, 1); /* other recs per frame */
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
goto invalid;
url_fskip(pb, 32); /* record_types */
- st->nb_frames = get_le32(pb);
- av_set_pts_info(st, 64, 1, get_le16(pb));
+ st->nb_frames = avio_rl32(pb);
+ av_set_pts_info(st, 64, 1, avio_rl16(pb));
url_fskip(pb, 58);
/* color cycling and palette data */
ret = AVERROR(ENOMEM);
goto close_and_return;
}
- ret = get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size);
if (ret < 0)
goto close_and_return;
for (i = 0; i < MAX_PAGES; i++) {
Page *p = &anm->pt[i];
- p->base_record = get_le16(pb);
- p->nb_records = get_le16(pb);
- p->size = get_le16(pb);
+ p->base_record = avio_rl16(pb);
+ p->nb_records = avio_rl16(pb);
+ p->size = avio_rl16(pb);
}
/* find page of first frame */
tmp = url_ftell(pb);
url_fseek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) +
8 + anm->record * 2, SEEK_SET);
- record_size = get_le16(pb);
+ record_size = avio_rl16(pb);
url_fseek(pb, tmp, SEEK_SET);
/* fetch record */
AVIOContext *pb = s->pb;
AVStream *st;
- get_le32(pb); /* CRYO */
- get_le32(pb); /* _APC */
- get_le32(pb); /* 1.20 */
+ avio_rl32(pb); /* CRYO */
+ avio_rl32(pb); /* _APC */
+ avio_rl32(pb); /* 1.20 */
st = av_new_stream(s, 0);
if (!st)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
- get_le32(pb); /* number of samples */
- st->codec->sample_rate = get_le32(pb);
+ avio_rl32(pb); /* number of samples */
+ st->codec->sample_rate = avio_rl32(pb);
st->codec->extradata_size = 2 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size +
return AVERROR(ENOMEM);
/* initial predictor values for adpcm decoder */
- get_buffer(pb, st->codec->extradata, 2 * 4);
+ avio_read(pb, st->codec->extradata, 2 * 4);
st->codec->channels = 1;
- if (get_le32(pb))
+ if (avio_rl32(pb))
st->codec->channels = 2;
st->codec->bits_per_coded_sample = 4;
/* TODO: Skip any leading junk such as id3v2 tags */
ape->junklength = 0;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' '))
return -1;
- ape->fileversion = get_le16(pb);
+ ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
}
if (ape->fileversion >= 3980) {
- ape->padding1 = get_le16(pb);
- ape->descriptorlength = get_le32(pb);
- ape->headerlength = get_le32(pb);
- ape->seektablelength = get_le32(pb);
- ape->wavheaderlength = get_le32(pb);
- ape->audiodatalength = get_le32(pb);
- ape->audiodatalength_high = get_le32(pb);
- ape->wavtaillength = get_le32(pb);
- get_buffer(pb, ape->md5, 16);
+ ape->padding1 = avio_rl16(pb);
+ ape->descriptorlength = avio_rl32(pb);
+ ape->headerlength = avio_rl32(pb);
+ ape->seektablelength = avio_rl32(pb);
+ ape->wavheaderlength = avio_rl32(pb);
+ ape->audiodatalength = avio_rl32(pb);
+ ape->audiodatalength_high = avio_rl32(pb);
+ ape->wavtaillength = avio_rl32(pb);
+ avio_read(pb, ape->md5, 16);
/* Skip any unknown bytes at the end of the descriptor.
This is for future compatibility */
url_fseek(pb, ape->descriptorlength - 52, SEEK_CUR);
/* Read header data */
- ape->compressiontype = get_le16(pb);
- ape->formatflags = get_le16(pb);
- ape->blocksperframe = get_le32(pb);
- ape->finalframeblocks = get_le32(pb);
- ape->totalframes = get_le32(pb);
- ape->bps = get_le16(pb);
- ape->channels = get_le16(pb);
- ape->samplerate = get_le32(pb);
+ ape->compressiontype = avio_rl16(pb);
+ ape->formatflags = avio_rl16(pb);
+ ape->blocksperframe = avio_rl32(pb);
+ ape->finalframeblocks = avio_rl32(pb);
+ ape->totalframes = avio_rl32(pb);
+ ape->bps = avio_rl16(pb);
+ ape->channels = avio_rl16(pb);
+ ape->samplerate = avio_rl32(pb);
} else {
ape->descriptorlength = 0;
ape->headerlength = 32;
- ape->compressiontype = get_le16(pb);
- ape->formatflags = get_le16(pb);
- ape->channels = get_le16(pb);
- ape->samplerate = get_le32(pb);
- ape->wavheaderlength = get_le32(pb);
- ape->wavtaillength = get_le32(pb);
- ape->totalframes = get_le32(pb);
- ape->finalframeblocks = get_le32(pb);
+ ape->compressiontype = avio_rl16(pb);
+ ape->formatflags = avio_rl16(pb);
+ ape->channels = avio_rl16(pb);
+ ape->samplerate = avio_rl32(pb);
+ ape->wavheaderlength = avio_rl32(pb);
+ ape->wavtaillength = avio_rl32(pb);
+ ape->totalframes = avio_rl32(pb);
+ ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
url_fseek(pb, 4, SEEK_CUR); /* Skip the peak level */
}
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
- ape->seektablelength = get_le32(pb);
+ ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t);
} else
if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
- ape->seektable[i] = get_le32(pb);
+ ape->seektable[i] = avio_rl32(pb);
}
ape->frames[0].pos = ape->firstframe;
AV_WL32(pkt->data , nblocks);
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
- ret = get_buffer(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
+ ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
pkt->pts = ape->frames[ape->currentframe].pts;
pkt->stream_index = 0;
uint32_t size, flags;
int i, c;
- size = get_le32(pb); /* field size */
- flags = get_le32(pb); /* field flags */
+ size = avio_rl32(pb); /* field size */
+ flags = avio_rl32(pb); /* field flags */
for (i = 0; i < sizeof(key) - 1; i++) {
- c = get_byte(pb);
+ c = avio_r8(pb);
if (c < 0x20 || c > 0x7E)
break;
else
value = av_malloc(size+1);
if (!value)
return AVERROR(ENOMEM);
- get_buffer(pb, value, size);
+ avio_read(pb, value, size);
value[size] = 0;
av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
return 0;
url_fseek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET);
- get_buffer(pb, buf, 8); /* APETAGEX */
+ avio_read(pb, buf, 8); /* APETAGEX */
if (strncmp(buf, "APETAGEX", 8)) {
return;
}
- val = get_le32(pb); /* APE tag version */
+ val = avio_rl32(pb); /* APE tag version */
if (val > APE_TAG_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION);
return;
}
- tag_bytes = get_le32(pb); /* tag size */
+ tag_bytes = avio_rl32(pb); /* tag size */
if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) {
av_log(s, AV_LOG_ERROR, "Tag size is way too big\n");
return;
}
- fields = get_le32(pb); /* number of fields */
+ fields = avio_rl32(pb); /* number of fields */
if (fields > 65536) {
av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields);
return;
}
- val = get_le32(pb); /* flags */
+ val = avio_rl32(pb); /* flags */
if (val & APE_TAG_FLAG_IS_HEADER) {
av_log(s, AV_LOG_ERROR, "APE Tag is a header\n");
return;
void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
assert(sizeof(*g) == 16);
- get_buffer(s, *g, sizeof(*g));
+ avio_read(s, *g, sizeof(*g));
}
static int asf_probe(AVProbeData *pd)
static int get_value(AVIOContext *pb, int type){
switch(type){
- case 2: return get_le32(pb);
- case 3: return get_le32(pb);
- case 4: return get_le64(pb);
- case 5: return get_le16(pb);
+ case 2: return avio_rl32(pb);
+ case 3: return avio_rl32(pb);
+ case 4: return avio_rl64(pb);
+ case 5: return avio_rl16(pb);
default:return INT_MIN;
}
}
AVIOContext *pb = s->pb;
ff_get_guid(pb, &asf->hdr.guid);
- asf->hdr.file_size = get_le64(pb);
- asf->hdr.create_time = get_le64(pb);
- get_le64(pb); /* number of packets */
- asf->hdr.play_time = get_le64(pb);
- asf->hdr.send_time = get_le64(pb);
- asf->hdr.preroll = get_le32(pb);
- asf->hdr.ignore = get_le32(pb);
- asf->hdr.flags = get_le32(pb);
- asf->hdr.min_pktsize = get_le32(pb);
- asf->hdr.max_pktsize = get_le32(pb);
- asf->hdr.max_bitrate = get_le32(pb);
+ asf->hdr.file_size = avio_rl64(pb);
+ asf->hdr.create_time = avio_rl64(pb);
+ avio_rl64(pb); /* number of packets */
+ asf->hdr.play_time = avio_rl64(pb);
+ asf->hdr.send_time = avio_rl64(pb);
+ asf->hdr.preroll = avio_rl32(pb);
+ asf->hdr.ignore = avio_rl32(pb);
+ asf->hdr.flags = avio_rl32(pb);
+ asf->hdr.min_pktsize = avio_rl32(pb);
+ asf->hdr.max_pktsize = avio_rl32(pb);
+ asf->hdr.max_bitrate = avio_rl32(pb);
s->packet_size = asf->hdr.max_pktsize;
return 0;
return -1;
}
ff_get_guid(pb, &g);
- total_size = get_le64(pb);
- type_specific_size = get_le32(pb);
- get_le32(pb);
- st->id = get_le16(pb) & 0x7f; /* stream id */
+ total_size = avio_rl64(pb);
+ type_specific_size = avio_rl32(pb);
+ avio_rl32(pb);
+ st->id = avio_rl16(pb) & 0x7f; /* stream id */
// mapping of asf ID to AV stream ID;
asf->asfid2avid[st->id] = s->nb_streams - 1;
- get_le32(pb);
+ avio_rl32(pb);
if (test_for_ext_stream_audio) {
ff_get_guid(pb, &g);
type = AVMEDIA_TYPE_AUDIO;
is_dvr_ms_audio=1;
ff_get_guid(pb, &g);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
ff_get_guid(pb, &g);
- get_le32(pb);
+ avio_rl32(pb);
}
}
/* We have to init the frame size at some point .... */
pos2 = url_ftell(pb);
if (size >= (pos2 + 8 - pos1 + 24)) {
- asf_st->ds_span = get_byte(pb);
- asf_st->ds_packet_size = get_le16(pb);
- asf_st->ds_chunk_size = get_le16(pb);
- get_le16(pb); //ds_data_size
- get_byte(pb); //ds_silence_data
+ asf_st->ds_span = avio_r8(pb);
+ asf_st->ds_packet_size = avio_rl16(pb);
+ asf_st->ds_chunk_size = avio_rl16(pb);
+ avio_rl16(pb); //ds_data_size
+ avio_r8(pb); //ds_silence_data
}
//printf("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d\n",
// asf_st->ds_packet_size, asf_st->ds_chunk_size,
}
} else if (type == AVMEDIA_TYPE_VIDEO &&
size - (url_ftell(pb) - pos1 + 24) >= 51) {
- get_le32(pb);
- get_le32(pb);
- get_byte(pb);
- get_le16(pb); /* size */
- sizeX= get_le32(pb); /* size */
- st->codec->width = get_le32(pb);
- st->codec->height = get_le32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_r8(pb);
+ avio_rl16(pb); /* size */
+ sizeX= avio_rl32(pb); /* size */
+ st->codec->width = avio_rl32(pb);
+ st->codec->height = avio_rl32(pb);
/* not available for asf */
- get_le16(pb); /* panes */
- st->codec->bits_per_coded_sample = get_le16(pb); /* depth */
- tag1 = get_le32(pb);
+ avio_rl16(pb); /* panes */
+ st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
+ tag1 = avio_rl32(pb);
url_fskip(pb, 20);
// av_log(s, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
if (sizeX > 40) {
st->codec->extradata_size = sizeX - 40;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
}
/* Extract palette from extradata if bpp <= 8 */
uint32_t ext_d, leak_rate, stream_num;
unsigned int stream_languageid_index;
- get_le64(pb); // starttime
- get_le64(pb); // endtime
- leak_rate = get_le32(pb); // leak-datarate
- get_le32(pb); // bucket-datasize
- get_le32(pb); // init-bucket-fullness
- get_le32(pb); // alt-leak-datarate
- get_le32(pb); // alt-bucket-datasize
- get_le32(pb); // alt-init-bucket-fullness
- get_le32(pb); // max-object-size
- get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
- stream_num = get_le16(pb); // stream-num
-
- stream_languageid_index = get_le16(pb); // stream-language-id-index
+ avio_rl64(pb); // starttime
+ avio_rl64(pb); // endtime
+ leak_rate = avio_rl32(pb); // leak-datarate
+ avio_rl32(pb); // bucket-datasize
+ avio_rl32(pb); // init-bucket-fullness
+ avio_rl32(pb); // alt-leak-datarate
+ avio_rl32(pb); // alt-bucket-datasize
+ avio_rl32(pb); // alt-init-bucket-fullness
+ avio_rl32(pb); // max-object-size
+ avio_rl32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
+ stream_num = avio_rl16(pb); // stream-num
+
+ stream_languageid_index = avio_rl16(pb); // stream-language-id-index
if (stream_num < 128)
asf->streams[stream_num].stream_language_index = stream_languageid_index;
- get_le64(pb); // avg frametime in 100ns units
- stream_ct = get_le16(pb); //stream-name-count
- payload_ext_ct = get_le16(pb); //payload-extension-system-count
+ avio_rl64(pb); // avg frametime in 100ns units
+ stream_ct = avio_rl16(pb); //stream-name-count
+ payload_ext_ct = avio_rl16(pb); //payload-extension-system-count
if (stream_num < 128)
asf->stream_bitrates[stream_num] = leak_rate;
for (i=0; i<stream_ct; i++){
- get_le16(pb);
- ext_len = get_le16(pb);
+ avio_rl16(pb);
+ ext_len = avio_rl16(pb);
url_fseek(pb, ext_len, SEEK_CUR);
}
for (i=0; i<payload_ext_ct; i++){
ff_get_guid(pb, &g);
- ext_d=get_le16(pb);
- ext_len=get_le32(pb);
+ ext_d=avio_rl16(pb);
+ ext_len=avio_rl32(pb);
url_fseek(pb, ext_len, SEEK_CUR);
}
AVIOContext *pb = s->pb;
int len1, len2, len3, len4, len5;
- len1 = get_le16(pb);
- len2 = get_le16(pb);
- len3 = get_le16(pb);
- len4 = get_le16(pb);
- len5 = get_le16(pb);
+ len1 = avio_rl16(pb);
+ len2 = avio_rl16(pb);
+ len3 = avio_rl16(pb);
+ len4 = avio_rl16(pb);
+ len5 = avio_rl16(pb);
get_tag(s, "title" , 0, len1);
get_tag(s, "author" , 0, len2);
get_tag(s, "copyright", 0, len3);
ASFContext *asf = s->priv_data;
int desc_count, i, ret;
- desc_count = get_le16(pb);
+ desc_count = avio_rl16(pb);
for(i=0;i<desc_count;i++) {
int name_len,value_type,value_len;
char name[1024];
- name_len = get_le16(pb);
+ name_len = avio_rl16(pb);
if (name_len%2) // must be even, broken lavf versions wrote len-1
name_len += 1;
if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len)
url_fskip(pb, name_len - ret);
- value_type = get_le16(pb);
- value_len = get_le16(pb);
+ value_type = avio_rl16(pb);
+ value_len = avio_rl16(pb);
if (!value_type && value_len%2)
value_len += 1;
/**
AVIOContext *pb = s->pb;
ASFContext *asf = s->priv_data;
int j, ret;
- int stream_count = get_le16(pb);
+ int stream_count = avio_rl16(pb);
for(j = 0; j < stream_count; j++) {
char lang[6];
- unsigned int lang_len = get_byte(pb);
+ unsigned int lang_len = avio_r8(pb);
if ((ret = avio_get_str16le(pb, lang_len, lang, sizeof(lang))) < lang_len)
url_fskip(pb, lang_len - ret);
if (j < 128)
ASFContext *asf = s->priv_data;
int n, stream_num, name_len, value_len, value_type, value_num;
int ret, i;
- n = get_le16(pb);
+ n = avio_rl16(pb);
for(i=0;i<n;i++) {
char name[1024];
- get_le16(pb); //lang_list_index
- stream_num= get_le16(pb);
- name_len= get_le16(pb);
- value_type= get_le16(pb);
- value_len= get_le32(pb);
+ avio_rl16(pb); //lang_list_index
+ stream_num= avio_rl16(pb);
+ name_len= avio_rl16(pb);
+ value_type= avio_rl16(pb);
+ value_len= avio_rl32(pb);
if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len)
url_fskip(pb, name_len - ret);
//av_log(s, AV_LOG_ERROR, "%d %d %d %d %d <%s>\n", i, stream_num, name_len, value_type, value_len, name);
- value_num= get_le16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
+ value_num= avio_rl16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
url_fskip(pb, value_len - 2);
if(stream_num<128){
int i, count, name_len, ret;
char name[1024];
- get_le64(pb); // reserved 16 bytes
- get_le64(pb); // ...
- count = get_le32(pb); // markers count
- get_le16(pb); // reserved 2 bytes
- name_len = get_le16(pb); // name length
+ avio_rl64(pb); // reserved 16 bytes
+ avio_rl64(pb); // ...
+ count = avio_rl32(pb); // markers count
+ avio_rl16(pb); // reserved 2 bytes
+ name_len = avio_rl16(pb); // name length
for(i=0;i<name_len;i++){
- get_byte(pb); // skip the name
+ avio_r8(pb); // skip the name
}
for(i=0;i<count;i++){
int64_t pres_time;
int name_len;
- get_le64(pb); // offset, 8 bytes
- pres_time = get_le64(pb); // presentation time
- get_le16(pb); // entry length
- get_le32(pb); // send time
- get_le32(pb); // flags
- name_len = get_le32(pb); // name length
+ avio_rl64(pb); // offset, 8 bytes
+ pres_time = avio_rl64(pb); // presentation time
+ avio_rl16(pb); // entry length
+ avio_rl32(pb); // send time
+ avio_rl32(pb); // flags
+ name_len = avio_rl32(pb); // name length
if ((ret = avio_get_str16le(pb, name_len * 2, name, sizeof(name))) < name_len)
url_fskip(pb, name_len - ret);
ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name );
ff_get_guid(pb, &g);
if (ff_guidcmp(&g, &ff_asf_header))
return -1;
- get_le64(pb);
- get_le32(pb);
- get_byte(pb);
- get_byte(pb);
+ avio_rl64(pb);
+ avio_rl32(pb);
+ avio_r8(pb);
+ avio_r8(pb);
memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
for(;;) {
uint64_t gpos= url_ftell(pb);
ff_get_guid(pb, &g);
- gsize = get_le64(pb);
+ gsize = avio_rl64(pb);
av_dlog(s, "%08"PRIx64": ", gpos);
print_guid(&g);
av_dlog(s, " size=0x%"PRIx64"\n", gsize);
} else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) {
int v1, v2;
ff_get_guid(pb, &g);
- v1 = get_le32(pb);
- v2 = get_le16(pb);
+ v1 = avio_rl32(pb);
+ v2 = avio_rl16(pb);
continue;
} else if (!ff_guidcmp(&g, &ff_asf_marker_header)) {
asf_read_marker(s, gsize);
url_fseek(pb, gpos + gsize, SEEK_SET);
}
ff_get_guid(pb, &g);
- get_le64(pb);
- get_byte(pb);
- get_byte(pb);
+ avio_rl64(pb);
+ avio_r8(pb);
+ avio_r8(pb);
if (url_feof(pb))
return -1;
asf->data_offset = url_ftell(pb);
#define DO_2BITS(bits, var, defval) \
switch (bits & 3) \
{ \
- case 3: var = get_le32(pb); rsize += 4; break; \
- case 2: var = get_le16(pb); rsize += 2; break; \
- case 1: var = get_byte(pb); rsize++; break; \
+ case 3: var = avio_rl32(pb); rsize += 4; break; \
+ case 2: var = avio_rl16(pb); rsize += 2; break; \
+ case 1: var = avio_r8(pb); rsize++; break; \
default: var = defval; break; \
}
c=d=e=-1;
while(off-- > 0){
c=d; d=e;
- e= get_byte(pb);
+ e= avio_r8(pb);
if(c == 0x82 && !d && !e)
break;
}
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -1;
}
- c= get_byte(pb);
- d= get_byte(pb);
+ c= avio_r8(pb);
+ d= avio_r8(pb);
rsize+=3;
}else{
url_fseek(pb, -1, SEEK_CUR); //FIXME
return -1;
}
- asf->packet_timestamp = get_le32(pb);
- get_le16(pb); /* duration */
+ asf->packet_timestamp = avio_rl32(pb);
+ avio_rl16(pb); /* duration */
// rsize has at least 11 bytes which have to be present
if (asf->packet_flags & 0x01) {
- asf->packet_segsizetype = get_byte(pb); rsize++;
+ asf->packet_segsizetype = avio_r8(pb); rsize++;
asf->packet_segments = asf->packet_segsizetype & 0x3f;
} else {
asf->packet_segments = 1;
static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
ASFContext *asf = s->priv_data;
int rsize = 1;
- int num = get_byte(pb);
+ int num = avio_r8(pb);
int64_t ts0, ts1;
asf->packet_segments--;
DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
//printf("key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, //asf->packet_frag_offset, asf->packet_replic_size);
if (asf->packet_replic_size >= 8) {
- asf->packet_obj_size = get_le32(pb);
+ asf->packet_obj_size = avio_rl32(pb);
if(asf->packet_obj_size >= (1<<24) || asf->packet_obj_size <= 0){
av_log(s, AV_LOG_ERROR, "packet_obj_size invalid\n");
return -1;
}
- asf->packet_frag_timestamp = get_le32(pb); // timestamp
+ asf->packet_frag_timestamp = avio_rl32(pb); // timestamp
if(asf->packet_replic_size >= 8+38+4){
// for(i=0; i<asf->packet_replic_size-8; i++)
-// av_log(s, AV_LOG_DEBUG, "%02X ",get_byte(pb));
+// av_log(s, AV_LOG_DEBUG, "%02X ",avio_r8(pb));
// av_log(s, AV_LOG_DEBUG, "\n");
url_fskip(pb, 10);
- ts0= get_le64(pb);
- ts1= get_le64(pb);
+ ts0= avio_rl64(pb);
+ ts1= avio_rl64(pb);
url_fskip(pb, 12);
- get_le32(pb);
+ avio_rl32(pb);
url_fskip(pb, asf->packet_replic_size - 8 - 38 - 4);
if(ts0!= -1) asf->packet_frag_timestamp= ts0/10000;
else asf->packet_frag_timestamp= AV_NOPTS_VALUE;
asf->packet_frag_offset = 0;
asf->packet_frag_timestamp = asf->packet_timestamp;
- asf->packet_time_delta = get_byte(pb);
+ asf->packet_time_delta = avio_r8(pb);
rsize++;
}else if(asf->packet_replic_size!=0){
av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", asf->packet_replic_size);
// frag_offset is here used as the beginning timestamp
asf->packet_frag_timestamp = asf->packet_time_start;
asf->packet_time_start += asf->packet_time_delta;
- asf->packet_obj_size = asf->packet_frag_size = get_byte(pb);
+ asf->packet_obj_size = asf->packet_frag_size = avio_r8(pb);
asf->packet_size_left--;
asf->packet_multi_size--;
if (asf->packet_multi_size < asf->packet_obj_size)
continue;
}
- ret = get_buffer(pb, asf_st->pkt.data + asf->packet_frag_offset,
+ ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset,
asf->packet_frag_size);
if (ret != asf->packet_frag_size) {
if (ret < 0 || asf->packet_frag_offset + ret == 0)
/* the data object can be followed by other top-level objects,
skip them until the simple index object is reached */
while (ff_guidcmp(&g, &index_guid)) {
- int64_t gsize= get_le64(s->pb);
+ int64_t gsize= avio_rl64(s->pb);
if (gsize < 24 || url_feof(s->pb)) {
url_fseek(s->pb, current_pos, SEEK_SET);
return;
{
int64_t itime, last_pos=-1;
int pct, ict;
- int64_t av_unused gsize= get_le64(s->pb);
+ int64_t av_unused gsize= avio_rl64(s->pb);
ff_get_guid(s->pb, &g);
- itime=get_le64(s->pb);
- pct=get_le32(s->pb);
- ict=get_le32(s->pb);
+ itime=avio_rl64(s->pb);
+ pct=avio_rl32(s->pb);
+ ict=avio_rl32(s->pb);
av_log(s, AV_LOG_DEBUG, "itime:0x%"PRIx64", pct:%d, ict:%d\n",itime,pct,ict);
for (i=0;i<ict;i++){
- int pktnum=get_le32(s->pb);
- int pktct =get_le16(s->pb);
+ int pktnum=avio_rl32(s->pb);
+ int pktct =avio_rl16(s->pb);
int64_t pos = s->data_offset + s->packet_size*(int64_t)pktnum;
int64_t index_pts= av_rescale(itime, i, 10000);
AVStream *st;
/* check ".snd" header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
- size = get_be32(pb); /* header size */
- get_be32(pb); /* data size */
+ size = avio_rb32(pb); /* header size */
+ avio_rb32(pb); /* data size */
- id = get_be32(pb);
- rate = get_be32(pb);
- channels = get_be32(pb);
+ id = avio_rb32(pb);
+ rate = avio_rb32(pb);
+ channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id);
int i;
/* check RIFF header */
- get_buffer(pb, header, 4);
- avi->riff_end = get_le32(pb); /* RIFF chunk size */
+ avio_read(pb, header, 4);
+ avi->riff_end = avio_rl32(pb); /* RIFF chunk size */
avi->riff_end += url_ftell(pb); /* RIFF chunk end */
- get_buffer(pb, header+4, 4);
+ avio_read(pb, header+4, 4);
for(i=0; avi_headers[i][0]; i++)
if(!memcmp(header, avi_headers[i], 8))
static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
- int longs_pre_entry= get_le16(pb);
- int index_sub_type = get_byte(pb);
- int index_type = get_byte(pb);
- int entries_in_use = get_le32(pb);
- int chunk_id = get_le32(pb);
- int64_t base = get_le64(pb);
+ int longs_pre_entry= avio_rl16(pb);
+ int index_sub_type = avio_r8(pb);
+ int index_type = avio_r8(pb);
+ int entries_in_use = avio_rl32(pb);
+ int chunk_id = avio_rl32(pb);
+ int64_t base = avio_rl64(pb);
int stream_id= 10*((chunk_id&0xFF) - '0') + (((chunk_id>>8)&0xFF) - '0');
AVStream *st;
AVIStream *ast;
if(index_sub_type)
return -1;
- get_le32(pb);
+ avio_rl32(pb);
if(index_type && longs_pre_entry != 2)
return -1;
for(i=0; i<entries_in_use; i++){
if(index_type){
- int64_t pos= get_le32(pb) + base - 8;
- int len = get_le32(pb);
+ int64_t pos= avio_rl32(pb) + base - 8;
+ int len = avio_rl32(pb);
int key= len >= 0;
len &= 0x7FFFFFFF;
}else{
int64_t offset, pos;
int duration;
- offset = get_le64(pb);
- get_le32(pb); /* size */
- duration = get_le32(pb);
+ offset = avio_rl64(pb);
+ avio_rl32(pb); /* size */
+ duration = avio_rl32(pb);
if(url_feof(pb))
return -1;
value = av_malloc(size+1);
if (!value)
return -1;
- get_buffer(pb, value, size);
+ avio_read(pb, value, size);
value[size]=0;
AV_WL32(key, tag);
static void avi_read_info(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
- uint32_t tag = get_le32(s->pb);
- uint32_t size = get_le32(s->pb);
+ uint32_t tag = avio_rl32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
avi_read_tag(s, NULL, tag, size);
}
}
static void avi_read_nikon(AVFormatContext *s, uint64_t end)
{
while (url_ftell(s->pb) < end) {
- uint32_t tag = get_le32(s->pb);
- uint32_t size = get_le32(s->pb);
+ uint32_t tag = avio_rl32(s->pb);
+ uint32_t size = avio_rl32(s->pb);
switch (tag) {
case MKTAG('n', 'c', 't', 'g'): { /* Nikon Tags */
uint64_t tag_end = url_ftell(s->pb) + size;
while (url_ftell(s->pb) < tag_end) {
- uint16_t tag = get_le16(s->pb);
- uint16_t size = get_le16(s->pb);
+ uint16_t tag = avio_rl16(s->pb);
+ uint16_t size = avio_rl16(s->pb);
const char *name = NULL;
char buffer[64] = {0};
- size -= get_buffer(s->pb, buffer,
+ size -= avio_read(s->pb, buffer,
FFMIN(size, sizeof(buffer)-1));
switch (tag) {
case 0x03: name = "maker"; break;
for(;;) {
if (url_feof(pb))
goto fail;
- tag = get_le32(pb);
- size = get_le32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rl32(pb);
print_tag("tag", tag, size);
case MKTAG('L', 'I', 'S', 'T'):
list_end = url_ftell(pb) + size;
/* Ignored, except at start of video packets. */
- tag1 = get_le32(pb);
+ tag1 = avio_rl32(pb);
print_tag("list", tag1, 0);
case MKTAG('I', 'D', 'I', 'T'): {
unsigned char date[64] = {0};
size += (size & 1);
- size -= get_buffer(pb, date, FFMIN(size, sizeof(date)-1));
+ size -= avio_read(pb, date, FFMIN(size, sizeof(date)-1));
url_fskip(pb, size);
avi_metadata_creation_time(&s->metadata, date);
break;
case MKTAG('a', 'v', 'i', 'h'):
/* AVI header */
/* using frame_period is bad idea */
- frame_period = get_le32(pb);
- bit_rate = get_le32(pb) * 8;
- get_le32(pb);
- avi->non_interleaved |= get_le32(pb) & AVIF_MUSTUSEINDEX;
+ frame_period = avio_rl32(pb);
+ bit_rate = avio_rl32(pb) * 8;
+ avio_rl32(pb);
+ avi->non_interleaved |= avio_rl32(pb) & AVIF_MUSTUSEINDEX;
url_fskip(pb, 2 * 4);
- get_le32(pb);
- get_le32(pb);
- avih_width=get_le32(pb);
- avih_height=get_le32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avih_width=avio_rl32(pb);
+ avih_height=avio_rl32(pb);
url_fskip(pb, size - 10 * 4);
break;
case MKTAG('s', 't', 'r', 'h'):
/* stream header */
- tag1 = get_le32(pb);
- handler = get_le32(pb); /* codec tag */
+ tag1 = avio_rl32(pb);
+ handler = avio_rl32(pb); /* codec tag */
if(tag1 == MKTAG('p', 'a', 'd', 's')){
url_fskip(pb, size - 8);
}
s->streams[0]->priv_data = ast;
url_fskip(pb, 3 * 4);
- ast->scale = get_le32(pb);
- ast->rate = get_le32(pb);
+ ast->scale = avio_rl32(pb);
+ ast->rate = avio_rl32(pb);
url_fskip(pb, 4); /* start time */
- dv_dur = get_le32(pb);
+ dv_dur = avio_rl32(pb);
if (ast->scale > 0 && ast->rate > 0 && dv_dur > 0) {
dv_dur *= AV_TIME_BASE;
s->duration = av_rescale(dv_dur, ast->scale, ast->rate);
assert(stream_index < s->nb_streams);
st->codec->stream_codec_tag= handler;
- get_le32(pb); /* flags */
- get_le16(pb); /* priority */
- get_le16(pb); /* language */
- get_le32(pb); /* initial frame */
- ast->scale = get_le32(pb);
- ast->rate = get_le32(pb);
+ avio_rl32(pb); /* flags */
+ avio_rl16(pb); /* priority */
+ avio_rl16(pb); /* language */
+ avio_rl32(pb); /* initial frame */
+ ast->scale = avio_rl32(pb);
+ ast->rate = avio_rl32(pb);
if(!(ast->scale && ast->rate)){
av_log(s, AV_LOG_WARNING, "scale/rate is %u/%u which is invalid. (This file has been generated by broken software.)\n", ast->scale, ast->rate);
if(frame_period){
}
av_set_pts_info(st, 64, ast->scale, ast->rate);
- ast->cum_len=get_le32(pb); /* start */
- st->nb_frames = get_le32(pb);
+ ast->cum_len=avio_rl32(pb); /* start */
+ st->nb_frames = avio_rl32(pb);
st->start_time = 0;
- get_le32(pb); /* buffer size */
- get_le32(pb); /* quality */
- ast->sample_size = get_le32(pb); /* sample ssize */
+ avio_rl32(pb); /* buffer size */
+ avio_rl32(pb); /* quality */
+ ast->sample_size = avio_rl32(pb); /* sample ssize */
ast->cum_len *= FFMAX(1, ast->sample_size);
// av_log(s, AV_LOG_DEBUG, "%d %d %d %d\n", ast->rate, ast->scale, ast->start, ast->sample_size);
st->codec->extradata_size= 0;
return AVERROR(ENOMEM);
}
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
}
if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
- get_byte(pb);
+ avio_r8(pb);
/* Extract palette from extradata if bpp <= 8. */
/* This code assumes that extradata contains only palette. */
AVRational active, active_aspect;
st = s->streams[stream_index];
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
-
- active_aspect.den= get_le16(pb);
- active_aspect.num= get_le16(pb);
- active.num = get_le32(pb);
- active.den = get_le32(pb);
- get_le32(pb); //nbFieldsPerFrame
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+
+ active_aspect.den= avio_rl16(pb);
+ active_aspect.num= avio_rl16(pb);
+ active.num = avio_rl32(pb);
+ active.den = avio_rl32(pb);
+ avio_rl32(pb); //nbFieldsPerFrame
if(active_aspect.num && active_aspect.den && active.num && active.den){
st->sample_aspect_ratio= av_div_q(active_aspect, active);
pkt->size - 7,
0, NULL, NULL, NULL, NULL);
AVProbeData pd;
- unsigned int desc_len = get_le32(pb);
+ unsigned int desc_len = avio_rl32(pb);
if (desc_len > pb->buf_end - pb->buf_ptr)
goto error;
if (*desc)
av_metadata_set2(&st->metadata, "title", desc, 0);
- get_le16(pb); /* flags? */
- get_le32(pb); /* data size */
+ avio_rl16(pb); /* flags? */
+ avio_rl32(pb); /* data size */
pd = (AVProbeData) { .buf = pb->buf_ptr, .buf_size = pb->buf_end - pb->buf_ptr };
if (!(sub_demuxer = av_probe_input_format2(&pd, 1, &score)))
for(j=0; j<7; j++)
d[j]= d[j+1];
- d[7]= get_byte(pb);
+ d[7]= avio_r8(pb);
size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
}
if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) {
- int k = get_byte(pb);
- int last = (k + get_byte(pb) - 1) & 0xFF;
+ int k = avio_r8(pb);
+ int last = (k + avio_r8(pb) - 1) & 0xFF;
- get_le16(pb); //flags
+ avio_rl16(pb); //flags
for (; k <= last; k++)
- ast->pal[k] = get_be32(pb)>>8;// b + (g << 8) + (r << 16);
+ ast->pal[k] = avio_rb32(pb)>>8;// b + (g << 8) + (r << 16);
ast->has_pal= 1;
goto resync;
} else if( ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) ||
/* Read the entries and sort them in each stream component. */
for(i = 0; i < nb_index_entries; i++) {
- tag = get_le32(pb);
- flags = get_le32(pb);
- pos = get_le32(pb);
- len = get_le32(pb);
+ tag = avio_rl32(pb);
+ flags = avio_rl32(pb);
+ pos = avio_rl32(pb);
+ len = avio_rl32(pb);
#if defined(DEBUG_SEEK)
av_log(s, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
i, tag, flags, pos, len);
if(n >= 2){
int64_t pos= st->index_entries[0].pos;
url_fseek(s->pb, pos + 4, SEEK_SET);
- size= get_le32(s->pb);
+ size= avio_rl32(s->pb);
if(pos + size > st->index_entries[1].pos)
last_start= INT64_MAX;
}
for(;;) {
if (url_feof(pb))
break;
- tag = get_le32(pb);
- size = get_le32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rl32(pb);
#ifdef DEBUG_SEEK
printf("tag=%c%c%c%c size=0x%x\n",
tag & 0xff,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
+
+/**
+ * @defgroup old_avio_funcs Old put_/get_*() functions
+ * @deprecated use the avio_ -prefixed functions instead.
+ * @{
+ */
+attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size);
+attribute_deprecated int get_byte(AVIOContext *s);
+attribute_deprecated unsigned int get_le16(AVIOContext *s);
+attribute_deprecated unsigned int get_le24(AVIOContext *s);
+attribute_deprecated unsigned int get_le32(AVIOContext *s);
+attribute_deprecated uint64_t get_le64(AVIOContext *s);
+attribute_deprecated unsigned int get_be16(AVIOContext *s);
+attribute_deprecated unsigned int get_be24(AVIOContext *s);
+attribute_deprecated unsigned int get_be32(AVIOContext *s);
+attribute_deprecated uint64_t get_be64(AVIOContext *s);
+/**
+ * @}
+ */
#endif
AVIOContext *avio_alloc_context(
* Read size bytes from AVIOContext into buf.
* @return number of bytes read or AVERROR
*/
-int get_buffer(AVIOContext *s, unsigned char *buf, int size);
+int avio_read(AVIOContext *s, unsigned char *buf, int size);
/**
* Read size bytes from AVIOContext into buf.
/** @note return 0 if EOF, so you cannot use it if EOF handling is
necessary */
-int get_byte(AVIOContext *s);
-unsigned int get_le24(AVIOContext *s);
-unsigned int get_le32(AVIOContext *s);
-uint64_t get_le64(AVIOContext *s);
-unsigned int get_le16(AVIOContext *s);
+int avio_r8 (AVIOContext *s);
+unsigned int avio_rl16(AVIOContext *s);
+unsigned int avio_rl24(AVIOContext *s);
+unsigned int avio_rl32(AVIOContext *s);
+uint64_t avio_rl64(AVIOContext *s);
/**
* Read a UTF-16 string from pb and convert it to UTF-8.
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
char *get_strz(AVIOContext *s, char *buf, int maxlen);
-unsigned int get_be16(AVIOContext *s);
-unsigned int get_be24(AVIOContext *s);
-unsigned int get_be32(AVIOContext *s);
-uint64_t get_be64(AVIOContext *s);
+unsigned int avio_rb16(AVIOContext *s);
+unsigned int avio_rb24(AVIOContext *s);
+unsigned int avio_rb32(AVIOContext *s);
+uint64_t avio_rb64(AVIOContext *s);
uint64_t ff_get_v(AVIOContext *bc);
{
avio_put_str(s, str);
}
+
+#define GET(name, type) \
+ type get_be ##name(AVIOContext *s) \
+{\
+ return avio_rb ##name(s);\
+}\
+ type get_le ##name(AVIOContext *s) \
+{\
+ return avio_rl ##name(s);\
+}
+
+GET(16, unsigned int)
+GET(24, unsigned int)
+GET(32, unsigned int)
+GET(64, uint64_t)
+
+#undef GET
+
+int get_byte(AVIOContext *s)
+{
+ return avio_r8(s);
+}
+int get_buffer(AVIOContext *s, unsigned char *buf, int size)
+{
+ return avio_read(s, buf, size);
+}
#endif
int avio_put_str(AVIOContext *s, const char *str)
}
/* XXX: put an inline version */
-int get_byte(AVIOContext *s)
+int avio_r8(AVIOContext *s)
{
if (s->buf_ptr >= s->buf_end)
fill_buffer(s);
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;
return len;
}
-unsigned int get_le16(AVIOContext *s)
+unsigned int avio_rl16(AVIOContext *s)
{
unsigned int val;
- val = get_byte(s);
- val |= get_byte(s) << 8;
+ val = avio_r8(s);
+ val |= avio_r8(s) << 8;
return val;
}
-unsigned int get_le24(AVIOContext *s)
+unsigned int avio_rl24(AVIOContext *s)
{
unsigned int val;
- val = get_le16(s);
- val |= get_byte(s) << 16;
+ val = avio_rl16(s);
+ val |= avio_r8(s) << 16;
return val;
}
-unsigned int get_le32(AVIOContext *s)
+unsigned int avio_rl32(AVIOContext *s)
{
unsigned int val;
- val = get_le16(s);
- val |= get_le16(s) << 16;
+ val = avio_rl16(s);
+ val |= avio_rl16(s) << 16;
return val;
}
-uint64_t get_le64(AVIOContext *s)
+uint64_t avio_rl64(AVIOContext *s)
{
uint64_t val;
- val = (uint64_t)get_le32(s);
- val |= (uint64_t)get_le32(s) << 32;
+ val = (uint64_t)avio_rl32(s);
+ val |= (uint64_t)avio_rl32(s) << 32;
return val;
}
-unsigned int get_be16(AVIOContext *s)
+unsigned int avio_rb16(AVIOContext *s)
{
unsigned int val;
- val = get_byte(s) << 8;
- val |= get_byte(s);
+ val = avio_r8(s) << 8;
+ val |= avio_r8(s);
return val;
}
-unsigned int get_be24(AVIOContext *s)
+unsigned int avio_rb24(AVIOContext *s)
{
unsigned int val;
- val = get_be16(s) << 8;
- val |= get_byte(s);
+ val = avio_rb16(s) << 8;
+ val |= avio_r8(s);
return val;
}
-unsigned int get_be32(AVIOContext *s)
+unsigned int avio_rb32(AVIOContext *s)
{
unsigned int val;
- val = get_be16(s) << 16;
- val |= get_be16(s);
+ val = avio_rb16(s) << 16;
+ val |= avio_rb16(s);
return val;
}
int i = 0;
char c;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if (i < maxlen-1)
buf[i++] = c;
}
char c;
do {
- c = get_byte(s);
+ c = avio_r8(s);
if (c && i < maxlen-1)
buf[i++] = c;
} while (c != '\n' && c);
return ret;\
}\
-GET_STR16(le, get_le16)
-GET_STR16(be, get_be16)
+GET_STR16(le, avio_rl16)
+GET_STR16(be, avio_rb16)
#undef GET_STR16
-uint64_t get_be64(AVIOContext *s)
+uint64_t avio_rb64(AVIOContext *s)
{
uint64_t val;
- val = (uint64_t)get_be32(s) << 32;
- val |= (uint64_t)get_be32(s);
+ val = (uint64_t)avio_rb32(s) << 32;
+ val |= (uint64_t)avio_rb32(s);
return val;
}
int tmp;
do{
- tmp = get_byte(bc);
+ tmp = avio_r8(bc);
val= (val<<7) + (tmp&127);
}while(tmp&128);
return val;
s->ctx_flags |= AVFMTCTX_NOHEADER;
url_fskip(s->pb, 4);
- avs->width = get_le16(s->pb);
- avs->height = get_le16(s->pb);
- avs->bits_per_sample = get_le16(s->pb);
- avs->fps = get_le16(s->pb);
- avs->nb_frames = get_le32(s->pb);
+ avs->width = avio_rl16(s->pb);
+ avs->height = avio_rl16(s->pb);
+ avs->bits_per_sample = avio_rl16(s->pb);
+ avs->fps = avio_rl16(s->pb);
+ avs->nb_frames = avio_rl32(s->pb);
avs->remaining_frame_size = 0;
avs->remaining_audio_size = 0;
pkt->data[palette_size + 1] = type;
pkt->data[palette_size + 2] = size & 0xFF;
pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
- ret = get_buffer(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
+ ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
if (ret < size) {
av_free_packet(pkt);
return AVERROR(EIO);
while (1) {
if (avs->remaining_frame_size <= 0) {
- if (!get_le16(s->pb)) /* found EOF */
+ if (!avio_rl16(s->pb)) /* found EOF */
return AVERROR(EIO);
- avs->remaining_frame_size = get_le16(s->pb) - 4;
+ avs->remaining_frame_size = avio_rl16(s->pb) - 4;
}
while (avs->remaining_frame_size > 0) {
- sub_type = get_byte(s->pb);
- type = get_byte(s->pb);
- size = get_le16(s->pb);
+ sub_type = avio_r8(s->pb);
+ type = avio_r8(s->pb);
+ size = avio_rl16(s->pb);
avs->remaining_frame_size -= size;
switch (type) {
case AVS_PALETTE:
- ret = get_buffer(s->pb, palette, size - 4);
+ ret = avio_read(s->pb, palette, size - 4);
if (ret < size - 4)
return AVERROR(EIO);
palette_size = size;
* int16s: always_512, nframes, width, height, delay, always_14
*/
url_fseek(pb, 5, SEEK_CUR);
- vid->nframes = get_le16(pb);
+ vid->nframes = avio_rl16(pb);
stream = av_new_stream(s, 0);
if (!stream)
av_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps
stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
stream->codec->codec_id = CODEC_ID_BETHSOFTVID;
- stream->codec->width = get_le16(pb);
- stream->codec->height = get_le16(pb);
+ stream->codec->width = avio_rl16(pb);
+ stream->codec->height = avio_rl16(pb);
stream->codec->pix_fmt = PIX_FMT_PAL8;
- vid->bethsoft_global_delay = get_le16(pb);
- get_le16(pb);
+ vid->bethsoft_global_delay = avio_rl16(pb);
+ avio_rl16(pb);
// done with video codec, set up audio codec
stream = av_new_stream(s, 0);
vidbuf_start[vidbuf_nbytes++] = block_type;
// get the video delay (next int16), and set the presentation time
- vid->video_pts += vid->bethsoft_global_delay + get_le16(pb);
+ vid->video_pts += vid->bethsoft_global_delay + avio_rl16(pb);
// set the y offset if it exists (decoder header data should be in data section)
if(block_type == VIDEO_YOFF_P_FRAME){
- if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
+ if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
goto fail;
vidbuf_nbytes += 2;
}
if(!vidbuf_start)
return AVERROR(ENOMEM);
- code = get_byte(pb);
+ code = avio_r8(pb);
vidbuf_start[vidbuf_nbytes++] = code;
if(code >= 0x80){ // rle sequence
if(block_type == VIDEO_I_FRAME)
- vidbuf_start[vidbuf_nbytes++] = get_byte(pb);
+ vidbuf_start[vidbuf_nbytes++] = avio_r8(pb);
} else if(code){ // plain sequence
- if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
+ if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
goto fail;
vidbuf_nbytes += code;
}
bytes_copied += code & 0x7F;
if(bytes_copied == npixels){ // sometimes no stop character is given, need to keep track of bytes copied
// may contain a 0 byte even if read all pixels
- if(get_byte(pb))
+ if(avio_r8(pb))
url_fseek(pb, -1, SEEK_CUR);
break;
}
if(vid->is_finished || url_feof(pb))
return AVERROR(EIO);
- block_type = get_byte(pb);
+ block_type = avio_r8(pb);
switch(block_type){
case PALETTE_BLOCK:
url_fseek(pb, -1, SEEK_CUR); // include block type
return ret_value;
case FIRST_AUDIO_BLOCK:
- get_le16(pb);
+ avio_rl16(pb);
// soundblaster DAC used for sample rate, as on specification page (link above)
- s->streams[1]->codec->sample_rate = 1000000 / (256 - get_byte(pb));
+ s->streams[1]->codec->sample_rate = 1000000 / (256 - avio_r8(pb));
s->streams[1]->codec->bit_rate = s->streams[1]->codec->channels * s->streams[1]->codec->sample_rate * s->streams[1]->codec->bits_per_coded_sample;
case AUDIO_BLOCK:
- audio_length = get_le16(pb);
+ audio_length = avio_rl16(pb);
ret_value = av_get_packet(pb, pkt, audio_length);
pkt->stream_index = 1;
return ret_value != audio_length ? AVERROR(EIO) : ret_value;
/* Set the total number of frames. */
url_fskip(pb, 8);
- chunk_header = get_le32(pb);
- bfi->nframes = get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- fps = get_le32(pb);
+ chunk_header = avio_rl32(pb);
+ bfi->nframes = avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ avio_rl32(pb);
+ fps = avio_rl32(pb);
url_fskip(pb, 12);
- vstream->codec->width = get_le32(pb);
- vstream->codec->height = get_le32(pb);
+ vstream->codec->width = avio_rl32(pb);
+ vstream->codec->height = avio_rl32(pb);
/*Load the palette to extradata */
url_fskip(pb, 8);
vstream->codec->extradata = av_malloc(768);
vstream->codec->extradata_size = 768;
- get_buffer(pb, vstream->codec->extradata,
+ avio_read(pb, vstream->codec->extradata,
vstream->codec->extradata_size);
- astream->codec->sample_rate = get_le32(pb);
+ astream->codec->sample_rate = avio_rl32(pb);
/* Set up the video codec... */
av_set_pts_info(vstream, 32, 1, fps);
while(state != MKTAG('S','A','V','I')){
if (url_feof(pb))
return AVERROR(EIO);
- state = 256*state + get_byte(pb);
+ state = 256*state + avio_r8(pb);
}
/* Now that the chunk's location is confirmed, we proceed... */
- chunk_size = get_le32(pb);
- get_le32(pb);
- audio_offset = get_le32(pb);
- get_le32(pb);
- video_offset = get_le32(pb);
+ chunk_size = avio_rl32(pb);
+ avio_rl32(pb);
+ audio_offset = avio_rl32(pb);
+ avio_rl32(pb);
+ video_offset = avio_rl32(pb);
audio_size = video_offset - audio_offset;
bfi->video_size = chunk_size - video_offset;
if (!vst)
return AVERROR(ENOMEM);
- vst->codec->codec_tag = get_le32(pb);
+ vst->codec->codec_tag = avio_rl32(pb);
- bink->file_size = get_le32(pb) + 8;
- vst->duration = get_le32(pb);
+ bink->file_size = avio_rl32(pb) + 8;
+ vst->duration = avio_rl32(pb);
if (vst->duration > 1000000) {
av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n");
return AVERROR(EIO);
}
- if (get_le32(pb) > bink->file_size) {
+ if (avio_rl32(pb) > bink->file_size) {
av_log(s, AV_LOG_ERROR,
"invalid header: largest frame size greater than file size\n");
return AVERROR(EIO);
url_fskip(pb, 4);
- vst->codec->width = get_le32(pb);
- vst->codec->height = get_le32(pb);
+ vst->codec->width = avio_rl32(pb);
+ vst->codec->height = avio_rl32(pb);
- fps_num = get_le32(pb);
- fps_den = get_le32(pb);
+ fps_num = avio_rl32(pb);
+ fps_den = avio_rl32(pb);
if (fps_num == 0 || fps_den == 0) {
av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den);
return AVERROR(EIO);
vst->codec->codec_id = CODEC_ID_BINKVIDEO;
vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
vst->codec->extradata_size = 4;
- get_buffer(pb, vst->codec->extradata, 4);
+ avio_read(pb, vst->codec->extradata, 4);
- bink->num_audio_tracks = get_le32(pb);
+ bink->num_audio_tracks = avio_rl32(pb);
if (bink->num_audio_tracks > BINK_MAX_AUDIO_TRACKS) {
av_log(s, AV_LOG_ERROR,
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_tag = 0;
- ast->codec->sample_rate = get_le16(pb);
+ ast->codec->sample_rate = avio_rl16(pb);
av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
- flags = get_le16(pb);
+ flags = avio_rl16(pb);
ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT;
ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1;
}
/* frame index table */
- next_pos = get_le32(pb);
+ next_pos = avio_rl32(pb);
for (i = 0; i < vst->duration; i++) {
pos = next_pos;
if (i == vst->duration - 1) {
next_pos = bink->file_size;
keyframe = 0;
} else {
- next_pos = get_le32(pb);
+ next_pos = avio_rl32(pb);
keyframe = pos & 1;
}
pos &= ~1;
}
while (bink->current_track < bink->num_audio_tracks) {
- uint32_t audio_size = get_le32(pb);
+ uint32_t audio_size = avio_rl32(pb);
if (audio_size > bink->remain_packet_size - 4) {
av_log(s, AV_LOG_ERROR,
"frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n",
int framecount = 0;
for (i = 0; i < 512; i++) {
- c93->block_records[i].index = get_le16(pb);
- c93->block_records[i].length = get_byte(pb);
- c93->block_records[i].frames = get_byte(pb);
+ c93->block_records[i].index = avio_rl16(pb);
+ c93->block_records[i].length = avio_r8(pb);
+ c93->block_records[i].frames = avio_r8(pb);
if (c93->block_records[i].frames > 32) {
av_log(s, AV_LOG_ERROR, "too many frames in block\n");
return AVERROR_INVALIDDATA;
if (c93->next_pkt_is_audio) {
c93->current_frame++;
c93->next_pkt_is_audio = 0;
- datasize = get_le16(pb);
+ datasize = avio_rl16(pb);
if (datasize > 42) {
if (!c93->audio) {
c93->audio = av_new_stream(s, 1);
if (c93->current_frame == 0) {
url_fseek(pb, br->index * 2048, SEEK_SET);
for (i = 0; i < 32; i++) {
- c93->frame_offsets[i] = get_le32(pb);
+ c93->frame_offsets[i] = avio_rl32(pb);
}
}
url_fseek(pb,br->index * 2048 +
c93->frame_offsets[c93->current_frame], SEEK_SET);
- datasize = get_le16(pb); /* video frame size */
+ datasize = avio_rl16(pb); /* video frame size */
ret = av_new_packet(pkt, datasize + 768 + 1);
if (ret < 0)
pkt->data[0] = 0;
pkt->size = datasize + 1;
- ret = get_buffer(pb, pkt->data + 1, datasize);
+ ret = avio_read(pb, pkt->data + 1, datasize);
if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
}
- datasize = get_le16(pb); /* palette size */
+ datasize = avio_rl16(pb); /* palette size */
if (datasize) {
if (datasize != 768) {
av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize);
goto fail;
}
pkt->data[0] |= C93_HAS_PALETTE;
- ret = get_buffer(pb, pkt->data + pkt->size, datasize);
+ ret = avio_read(pb, pkt->data + pkt->size, datasize);
if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
/* parse format description */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->sample_rate = av_int2dbl(get_be64(pb));
- st->codec->codec_tag = get_be32(pb);
- flags = get_be32(pb);
- caf->bytes_per_packet = get_be32(pb);
+ st->codec->sample_rate = av_int2dbl(avio_rb64(pb));
+ st->codec->codec_tag = avio_rb32(pb);
+ flags = avio_rb32(pb);
+ caf->bytes_per_packet = avio_rb32(pb);
st->codec->block_align = caf->bytes_per_packet;
- caf->frames_per_packet = get_be32(pb);
- st->codec->channels = get_be32(pb);
- st->codec->bits_per_coded_sample = get_be32(pb);
+ caf->frames_per_packet = avio_rb32(pb);
+ st->codec->channels = avio_rb32(pb);
+ st->codec->bits_per_coded_sample = avio_rb32(pb);
/* calculate bit rate for constant size packets */
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, ALAC_HEADER);
+ avio_read(pb, st->codec->extradata, ALAC_HEADER);
st->codec->extradata_size = ALAC_HEADER;
url_fskip(pb, size - ALAC_PREAMBLE - ALAC_HEADER);
} else {
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, size);
+ avio_read(pb, st->codec->extradata, size);
st->codec->extradata_size = size;
}
ccount = url_ftell(pb);
- num_packets = get_be64(pb);
+ num_packets = avio_rb64(pb);
if (num_packets < 0 || INT32_MAX / sizeof(AVIndexEntry) < num_packets)
return AVERROR_INVALIDDATA;
- st->nb_frames = get_be64(pb); /* valid frames */
- st->nb_frames += get_be32(pb); /* priming frames */
- st->nb_frames += get_be32(pb); /* remainder frames */
+ st->nb_frames = avio_rb64(pb); /* valid frames */
+ st->nb_frames += avio_rb32(pb); /* priming frames */
+ st->nb_frames += avio_rb32(pb); /* remainder frames */
st->duration = 0;
for (i = 0; i < num_packets; i++) {
{
AVIOContext *pb = s->pb;
unsigned int i;
- unsigned int nb_entries = get_be32(pb);
+ unsigned int nb_entries = avio_rb32(pb);
for (i = 0; i < nb_entries; i++) {
char key[32];
char value[1024];
url_fskip(pb, 8); /* magic, version, file flags */
/* audio description chunk */
- if (get_be32(pb) != MKBETAG('d','e','s','c')) {
+ if (avio_rb32(pb) != MKBETAG('d','e','s','c')) {
av_log(s, AV_LOG_ERROR, "desc chunk not present\n");
return AVERROR_INVALIDDATA;
}
- size = get_be64(pb);
+ size = avio_rb64(pb);
if (size != 32)
return AVERROR_INVALIDDATA;
if (found_data && (caf->data_size < 0 || url_is_streamed(pb)))
break;
- tag = get_be32(pb);
- size = get_be64(pb);
+ tag = avio_rb32(pb);
+ size = avio_rb64(pb);
if (url_feof(pb))
break;
int ret, size;
if (url_feof(pb))
return AVERROR(EIO);
- size = get_be16(pb);
- get_be16(pb); // unknown
+ size = avio_rb16(pb);
+ avio_rb16(pb); // unknown
ret = av_get_packet(pb, pkt, size);
pkt->stream_index = 0;
return ret;
static int cin_read_file_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFileHeader *hdr = &cin->file_header;
- if (get_le32(pb) != 0x55AA0000)
+ if (avio_rl32(pb) != 0x55AA0000)
return AVERROR_INVALIDDATA;
- hdr->video_frame_size = get_le32(pb);
- hdr->video_frame_width = get_le16(pb);
- hdr->video_frame_height = get_le16(pb);
- hdr->audio_frequency = get_le32(pb);
- hdr->audio_bits = get_byte(pb);
- hdr->audio_stereo = get_byte(pb);
- hdr->audio_frame_size = get_le16(pb);
+ hdr->video_frame_size = avio_rl32(pb);
+ hdr->video_frame_width = avio_rl16(pb);
+ hdr->video_frame_height = avio_rl16(pb);
+ hdr->audio_frequency = avio_rl32(pb);
+ hdr->audio_bits = avio_r8(pb);
+ hdr->audio_stereo = avio_r8(pb);
+ hdr->audio_frame_size = avio_rl16(pb);
if (hdr->audio_frequency != 22050 || hdr->audio_bits != 16 || hdr->audio_stereo != 0)
return AVERROR_INVALIDDATA;
static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFrameHeader *hdr = &cin->frame_header;
- hdr->video_frame_type = get_byte(pb);
- hdr->audio_frame_type = get_byte(pb);
- hdr->pal_colors_count = get_le16(pb);
- hdr->video_frame_size = get_le32(pb);
- hdr->audio_frame_size = get_le32(pb);
+ hdr->video_frame_type = avio_r8(pb);
+ hdr->audio_frame_type = avio_r8(pb);
+ hdr->pal_colors_count = avio_rl16(pb);
+ hdr->video_frame_size = avio_rl32(pb);
+ hdr->audio_frame_size = avio_rl32(pb);
if (url_feof(pb) || url_ferror(pb))
return AVERROR(EIO);
- if (get_le32(pb) != 0xAA55AA55)
+ if (avio_rl32(pb) != 0xAA55AA55)
return AVERROR_INVALIDDATA;
return 0;
pkt->data[2] = hdr->pal_colors_count >> 8;
pkt->data[3] = hdr->video_frame_type;
- ret = get_buffer(pb, &pkt->data[4], pkt_size);
+ ret = avio_read(pb, &pkt->data[4], pkt_size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
if (!c->dv_demux)
return -1;
- state = get_be32(s->pb);
+ state = avio_rb32(s->pb);
while ((state & 0xffffff7f) != 0x1f07003f) {
if (url_feof(s->pb)) {
av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
marker_pos = url_ftell(s->pb);
if (state == 0xff3f0701 && url_ftell(s->pb) - marker_pos == 80) {
url_fseek(s->pb, -163, SEEK_CUR);
- state = get_be32(s->pb);
+ state = avio_rb32(s->pb);
break;
}
- state = (state << 8) | get_byte(s->pb);
+ state = (state << 8) | avio_r8(s->pb);
}
AV_WB32(c->buf, state);
- if (get_buffer(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 ||
+ if (avio_read(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 ||
url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
return AVERROR(EIO);
if (!c->dv_demux->sys)
return AVERROR(EIO);
size = c->dv_demux->sys->frame_size;
- if (get_buffer(s->pb, c->buf, size) <= 0)
+ if (avio_read(s->pb, c->buf, size) <= 0)
return AVERROR(EIO);
size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);
int num, den;
int flags;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('D', 'E', 'X', 'A'))
return -1;
- flags = get_byte(pb);
- c->frames = get_be16(pb);
+ flags = avio_r8(pb);
+ c->frames = avio_rb16(pb);
if(!c->frames){
av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
return -1;
}
- fps = get_be32(pb);
+ fps = avio_rb32(pb);
if(fps > 0){
den = 1000;
num = fps;
den = 10;
num = 1;
}
- w = get_be16(pb);
- h = get_be16(pb);
+ w = avio_rb16(pb);
+ h = avio_rb16(pb);
c->has_sound = 0;
st = av_new_stream(s, 0);
return -1;
// Parse WAV data header
- if(get_le32(pb) == MKTAG('W', 'A', 'V', 'E')){
+ if(avio_rl32(pb) == MKTAG('W', 'A', 'V', 'E')){
uint32_t size, fsize;
c->has_sound = 1;
- size = get_be32(pb);
+ size = avio_rb32(pb);
c->vidpos = url_ftell(pb) + size;
url_fskip(pb, 16);
- fsize = get_le32(pb);
+ fsize = avio_rl32(pb);
ast = av_new_stream(s, 0);
if (!ast)
ff_get_wav_header(pb, ast->codec, fsize);
// find 'data' chunk
while(url_ftell(pb) < c->vidpos && !url_feof(pb)){
- tag = get_le32(pb);
- fsize = get_le32(pb);
+ tag = avio_rl32(pb);
+ fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break;
url_fskip(pb, fsize);
}
}
url_fseek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){
- get_buffer(s->pb, buf, 4);
+ avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(pkt, 4 + pal_size) < 0)
case MKTAG('C', 'M', 'A', 'P'):
pal_size = 768+4;
memcpy(pal, buf, 4);
- get_buffer(s->pb, pal + 4, 768);
+ avio_read(s->pb, pal + 4, 768);
break;
case MKTAG('F', 'R', 'A', 'M'):
- get_buffer(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
+ avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
size = AV_RB32(buf + 5);
if(size > 0xFFFFFF){
av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
- ret = get_buffer(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
+ ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){
av_free_packet(pkt);
return AVERROR(EIO);
unsigned int sample_rate, header;
AVStream *st;
- header = get_be16(pb);
+ header = avio_rb16(pb);
switch (header) {
case 0x0400: cdata->channels = 1; break;
case 0x0404: cdata->channels = 2; break;
return -1;
};
- sample_rate = get_be16(pb);
+ sample_rate = avio_rb16(pb);
url_fskip(pb, 12);
st = av_new_stream(s, 0);
int i;
uint32_t word;
- size = get_byte(pb);
+ size = avio_r8(pb);
word = 0;
for (i = 0; i < size; i++) {
- byte = get_byte(pb);
+ byte = avio_r8(pb);
word <<= 8;
word |= byte;
}
while (!url_feof(pb) && inHeader) {
int inSubheader;
uint8_t byte;
- byte = get_byte(pb);
+ byte = avio_r8(pb);
switch (byte) {
case 0xFD:
inSubheader = 1;
while (!url_feof(pb) && inSubheader) {
uint8_t subbyte;
- subbyte = get_byte(pb);
+ subbyte = avio_r8(pb);
switch (subbyte) {
case 0x80:
AVIOContext *pb = s->pb;
int compression_type;
- ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb);
- ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */
- ea->num_channels = get_byte(pb);
- compression_type = get_byte(pb);
+ ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
+ ea->bytes = avio_r8(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = avio_r8(pb);
+ compression_type = avio_r8(pb);
url_fskip(pb, 13);
switch (compression_type) {
EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb;
- ea->sample_rate = get_le32(pb);
- ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */
- ea->num_channels = get_le32(pb);
+ ea->sample_rate = avio_rl32(pb);
+ ea->bytes = avio_rl32(pb); /* 1=8-bit, 2=16-bit */
+ ea->num_channels = avio_rl32(pb);
ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD;
return 1;
EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb;
url_fskip(pb, 4);
- ea->width = get_le16(pb);
- ea->height = get_le16(pb);
+ ea->width = avio_rl16(pb);
+ ea->height = avio_rl16(pb);
ea->time_base = (AVRational){1,15};
ea->video_codec = CODEC_ID_MDEC;
return 1;
AVIOContext *pb = s->pb;
url_fskip(pb, 16);
- ea->time_base.den = get_le32(pb);
- ea->time_base.num = get_le32(pb);
+ ea->time_base.den = avio_rl32(pb);
+ ea->time_base.num = avio_rl32(pb);
ea->video_codec = CODEC_ID_VP6;
return 1;
unsigned int startpos = url_ftell(pb);
int err = 0;
- blockid = get_le32(pb);
- size = get_le32(pb);
+ blockid = avio_rl32(pb);
+ size = avio_rl32(pb);
if (i == 0)
ea->big_endian = size > 0x000FFFFF;
if (ea->big_endian)
switch (blockid) {
case ISNh_TAG:
- if (get_le32(pb) != EACS_TAG) {
+ if (avio_rl32(pb) != EACS_TAG) {
av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n");
return 0;
}
case SCHl_TAG :
case SHEN_TAG :
- blockid = get_le32(pb);
+ blockid = avio_rl32(pb);
if (blockid == GSTR_TAG) {
url_fskip(pb, 4);
} else if ((blockid & 0xFFFF)!=PT00_TAG) {
int av_uninit(num_samples);
while (!packet_read) {
- chunk_type = get_le32(pb);
- chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8;
+ chunk_type = avio_rl32(pb);
+ chunk_size = (ea->big_endian ? avio_rb32(pb) : avio_rl32(pb)) - 8;
switch (chunk_type) {
/* audio data */
break;
} else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR ||
ea->audio_codec == CODEC_ID_MP3) {
- num_samples = get_le32(pb);
+ num_samples = avio_rl32(pb);
url_fskip(pb, 8);
chunk_size -= 12;
}
av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
return -1;
}
- state = (state << 8) | get_byte(s->pb);
+ state = (state << 8) | avio_r8(s->pb);
}
return 0;
}
if (url_ftell(pb) == ffm->file_size)
url_fseek(pb, ffm->packet_size, SEEK_SET);
retry_read:
- id = get_be16(pb); /* PACKET_ID */
+ id = avio_rb16(pb); /* PACKET_ID */
if (id != PACKET_ID)
if (ffm_resync(s, id) < 0)
return -1;
- fill_size = get_be16(pb);
- ffm->dts = get_be64(pb);
- frame_offset = get_be16(pb);
- get_buffer(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
+ fill_size = avio_rb16(pb);
+ ffm->dts = avio_rb64(pb);
+ frame_offset = avio_rb16(pb);
+ avio_read(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);
if (ffm->packet_end < ffm->packet || frame_offset < 0)
return -1;
ffm_seek1(s, pos);
url_fskip(pb, 4);
- dts = get_be64(pb);
+ dts = avio_rb64(pb);
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0);
#endif
uint32_t tag;
/* header */
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('F', 'F', 'M', '1'))
goto fail;
- ffm->packet_size = get_be32(pb);
+ ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE)
goto fail;
- ffm->write_index = get_be64(pb);
+ ffm->write_index = avio_rb64(pb);
/* get also filesize */
if (!url_is_streamed(pb)) {
ffm->file_size = url_fsize(pb);
ffm->file_size = (UINT64_C(1) << 63) - 1;
}
- nb_streams = get_be32(pb);
- get_be32(pb); /* total bitrate */
+ nb_streams = avio_rb32(pb);
+ avio_rb32(pb); /* total bitrate */
/* read each stream */
for(i=0;i<nb_streams;i++) {
char rc_eq_buf[128];
codec = st->codec;
/* generic info */
- codec->codec_id = get_be32(pb);
- codec->codec_type = get_byte(pb); /* codec_type */
- codec->bit_rate = get_be32(pb);
- st->quality = get_be32(pb);
- codec->flags = get_be32(pb);
- codec->flags2 = get_be32(pb);
- codec->debug = get_be32(pb);
+ codec->codec_id = avio_rb32(pb);
+ codec->codec_type = avio_r8(pb); /* codec_type */
+ codec->bit_rate = avio_rb32(pb);
+ st->quality = avio_rb32(pb);
+ codec->flags = avio_rb32(pb);
+ codec->flags2 = avio_rb32(pb);
+ codec->debug = avio_rb32(pb);
/* specific info */
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- codec->time_base.num = get_be32(pb);
- codec->time_base.den = get_be32(pb);
- codec->width = get_be16(pb);
- codec->height = get_be16(pb);
- codec->gop_size = get_be16(pb);
- codec->pix_fmt = get_be32(pb);
- codec->qmin = get_byte(pb);
- codec->qmax = get_byte(pb);
- codec->max_qdiff = get_byte(pb);
- codec->qcompress = get_be16(pb) / 10000.0;
- codec->qblur = get_be16(pb) / 10000.0;
- codec->bit_rate_tolerance = get_be32(pb);
+ codec->time_base.num = avio_rb32(pb);
+ codec->time_base.den = avio_rb32(pb);
+ codec->width = avio_rb16(pb);
+ codec->height = avio_rb16(pb);
+ codec->gop_size = avio_rb16(pb);
+ codec->pix_fmt = avio_rb32(pb);
+ codec->qmin = avio_r8(pb);
+ codec->qmax = avio_r8(pb);
+ codec->max_qdiff = avio_r8(pb);
+ codec->qcompress = avio_rb16(pb) / 10000.0;
+ codec->qblur = avio_rb16(pb) / 10000.0;
+ codec->bit_rate_tolerance = avio_rb32(pb);
codec->rc_eq = av_strdup(get_strz(pb, rc_eq_buf, sizeof(rc_eq_buf)));
- codec->rc_max_rate = get_be32(pb);
- codec->rc_min_rate = get_be32(pb);
- codec->rc_buffer_size = get_be32(pb);
- codec->i_quant_factor = av_int2dbl(get_be64(pb));
- codec->b_quant_factor = av_int2dbl(get_be64(pb));
- codec->i_quant_offset = av_int2dbl(get_be64(pb));
- codec->b_quant_offset = av_int2dbl(get_be64(pb));
- codec->dct_algo = get_be32(pb);
- codec->strict_std_compliance = get_be32(pb);
- codec->max_b_frames = get_be32(pb);
- codec->luma_elim_threshold = get_be32(pb);
- codec->chroma_elim_threshold = get_be32(pb);
- codec->mpeg_quant = get_be32(pb);
- codec->intra_dc_precision = get_be32(pb);
- codec->me_method = get_be32(pb);
- codec->mb_decision = get_be32(pb);
- codec->nsse_weight = get_be32(pb);
- codec->frame_skip_cmp = get_be32(pb);
- codec->rc_buffer_aggressivity = av_int2dbl(get_be64(pb));
- codec->codec_tag = get_be32(pb);
- codec->thread_count = get_byte(pb);
- codec->coder_type = get_be32(pb);
- codec->me_cmp = get_be32(pb);
- codec->partitions = get_be32(pb);
- codec->me_subpel_quality = get_be32(pb);
- codec->me_range = get_be32(pb);
- codec->keyint_min = get_be32(pb);
- codec->scenechange_threshold = get_be32(pb);
- codec->b_frame_strategy = get_be32(pb);
- codec->qcompress = av_int2dbl(get_be64(pb));
- codec->qblur = av_int2dbl(get_be64(pb));
- codec->max_qdiff = get_be32(pb);
- codec->refs = get_be32(pb);
- codec->directpred = get_be32(pb);
+ codec->rc_max_rate = avio_rb32(pb);
+ codec->rc_min_rate = avio_rb32(pb);
+ codec->rc_buffer_size = avio_rb32(pb);
+ codec->i_quant_factor = av_int2dbl(avio_rb64(pb));
+ codec->b_quant_factor = av_int2dbl(avio_rb64(pb));
+ codec->i_quant_offset = av_int2dbl(avio_rb64(pb));
+ codec->b_quant_offset = av_int2dbl(avio_rb64(pb));
+ codec->dct_algo = avio_rb32(pb);
+ codec->strict_std_compliance = avio_rb32(pb);
+ codec->max_b_frames = avio_rb32(pb);
+ codec->luma_elim_threshold = avio_rb32(pb);
+ codec->chroma_elim_threshold = avio_rb32(pb);
+ codec->mpeg_quant = avio_rb32(pb);
+ codec->intra_dc_precision = avio_rb32(pb);
+ codec->me_method = avio_rb32(pb);
+ codec->mb_decision = avio_rb32(pb);
+ codec->nsse_weight = avio_rb32(pb);
+ codec->frame_skip_cmp = avio_rb32(pb);
+ codec->rc_buffer_aggressivity = av_int2dbl(avio_rb64(pb));
+ codec->codec_tag = avio_rb32(pb);
+ codec->thread_count = avio_r8(pb);
+ codec->coder_type = avio_rb32(pb);
+ codec->me_cmp = avio_rb32(pb);
+ codec->partitions = avio_rb32(pb);
+ codec->me_subpel_quality = avio_rb32(pb);
+ codec->me_range = avio_rb32(pb);
+ codec->keyint_min = avio_rb32(pb);
+ codec->scenechange_threshold = avio_rb32(pb);
+ codec->b_frame_strategy = avio_rb32(pb);
+ codec->qcompress = av_int2dbl(avio_rb64(pb));
+ codec->qblur = av_int2dbl(avio_rb64(pb));
+ codec->max_qdiff = avio_rb32(pb);
+ codec->refs = avio_rb32(pb);
+ codec->directpred = avio_rb32(pb);
break;
case AVMEDIA_TYPE_AUDIO:
- codec->sample_rate = get_be32(pb);
- codec->channels = get_le16(pb);
- codec->frame_size = get_le16(pb);
- codec->sample_fmt = (int16_t) get_le16(pb);
+ codec->sample_rate = avio_rb32(pb);
+ codec->channels = avio_rl16(pb);
+ codec->frame_size = avio_rl16(pb);
+ codec->sample_fmt = (int16_t) avio_rl16(pb);
break;
default:
goto fail;
}
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
- codec->extradata_size = get_be32(pb);
+ codec->extradata_size = avio_rb32(pb);
codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_read(pb, codec->extradata, codec->extradata_size);
}
}
/* get until end of block reached */
while ((url_ftell(pb) % ffm->packet_size) != 0)
- get_byte(pb);
+ avio_r8(pb);
/* init packet demux */
ffm->packet_ptr = ffm->packet;
uint8_t c;
int i = 0;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if (c == '\\') {
if (i < size - 1)
buf[i++] = c;
- c = get_byte(s);
+ c = avio_r8(s);
} else if (c == '\n')
break;
return AVERROR(EIO);
url_fseek(pb, url_fsize(pb) - 36, SEEK_SET);
- if (get_be32(pb) != RAND_TAG) {
+ if (avio_rb32(pb) != RAND_TAG) {
av_log(s, AV_LOG_ERROR, "magic number not found");
return AVERROR_INVALIDDATA;
}
if (!st)
return AVERROR(ENOMEM);
- st->nb_frames = get_be32(pb);
- if (get_be16(pb) != 0) {
+ st->nb_frames = avio_rb32(pb);
+ if (avio_rb16(pb) != 0) {
av_log_ask_for_sample(s, "unsupported packing method\n");
return AVERROR_INVALIDDATA;
}
st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = PIX_FMT_RGBA;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
- film->leading = get_be16(pb);
- av_set_pts_info(st, 64, 1, get_be16(pb));
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
+ film->leading = avio_rb16(pb);
+ av_set_pts_info(st, 64, 1, avio_rb16(pb));
url_fseek(pb, 0, SEEK_SET);
/* the parameters will be extracted from the compressed bitstream */
/* if fLaC marker is not found, assume there is no header */
- if (get_le32(s->pb) != MKTAG('f','L','a','C')) {
+ if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) {
url_fseek(s->pb, -4, SEEK_CUR);
return 0;
}
/* process metadata blocks */
while (!url_feof(s->pb) && !metadata_last) {
- get_buffer(s->pb, header, 4);
+ avio_read(s->pb, header, 4);
ff_flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size);
switch (metadata_type) {
if (!buffer) {
return AVERROR(ENOMEM);
}
- if (get_buffer(s->pb, buffer, metadata_size) != metadata_size) {
+ if (avio_read(s->pb, buffer, metadata_size) != metadata_size) {
av_freep(&buffer);
return AVERROR(EIO);
}
flic->frame_number = 0;
/* load the whole header and pull out the width and height */
- if (get_buffer(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
+ if (avio_read(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
return AVERROR(EIO);
magic_number = AV_RL16(&header[4]);
memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
- if (get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
+ if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n");
return AVERROR(EIO);
}
while (!packet_read) {
- if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
+ if ((ret = avio_read(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
FLIC_PREAMBLE_SIZE) {
ret = AVERROR(EIO);
break;
pkt->pts = flic->frame_number++;
pkt->pos = url_ftell(pb);
memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);
- ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE,
+ ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
size - FLIC_PREAMBLE_SIZE);
if (ret != size - FLIC_PREAMBLE_SIZE) {
av_free_packet(pkt);
pkt->stream_index = flic->audio_stream_index;
pkt->pos = url_ftell(pb);
- ret = get_buffer(pb, pkt->data, size);
+ ret = avio_read(pb, pkt->data, size);
if (ret != size) {
av_free_packet(pkt);
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
- vcodec->extradata[0] = get_byte(s->pb);
+ vcodec->extradata[0] = avio_r8(s->pb);
return 1; // 1 byte body size adjustment for flv_read_packet()
case FLV_CODECID_H264:
vcodec->codec_id = CODEC_ID_H264;
}
static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize) {
- int length = get_be16(ioc);
+ int length = avio_rb16(ioc);
if(length >= buffsize) {
url_fskip(ioc, length);
return -1;
}
- get_buffer(ioc, buffer, length);
+ avio_read(ioc, buffer, length);
buffer[length] = '\0';
num_val = 0;
ioc = s->pb;
- amf_type = get_byte(ioc);
+ amf_type = avio_r8(ioc);
switch(amf_type) {
case AMF_DATA_TYPE_NUMBER:
- num_val = av_int2dbl(get_be64(ioc)); break;
+ num_val = av_int2dbl(avio_rb64(ioc)); break;
case AMF_DATA_TYPE_BOOL:
- num_val = get_byte(ioc); break;
+ num_val = avio_r8(ioc); break;
case AMF_DATA_TYPE_STRING:
if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen;
- while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
+ while(url_ftell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) {
url_fskip(ioc, keylen); //skip key string
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
}
- if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ if(avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
}
break;
if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
return -1;
}
- if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ if(avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY: {
unsigned int arraylen, i;
- arraylen = get_be32(ioc);
+ arraylen = avio_rb32(ioc);
for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
ioc = s->pb;
//first object needs to be "onMetaData" string
- type = get_byte(ioc);
+ type = avio_r8(ioc);
if(type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0 || strcmp(buffer, "onMetaData"))
return -1;
int offset, flags;
url_fskip(s->pb, 4);
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
/* old flvtool cleared this field */
/* FIXME: better fix needed */
if (!flags) {
return AVERROR(ENOMEM);
}
- offset = get_be32(s->pb);
+ offset = avio_rb32(s->pb);
url_fseek(s->pb, offset, SEEK_SET);
url_fskip(s->pb, 4);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
- get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}
for(;;url_fskip(s->pb, 4)){ /* pkt size is repeated at end. skip it */
pos = url_ftell(s->pb);
- type = get_byte(s->pb);
- size = get_be24(s->pb);
- dts = get_be24(s->pb);
- dts |= get_byte(s->pb) << 24;
+ type = avio_r8(s->pb);
+ size = avio_rb24(s->pb);
+ dts = avio_rb24(s->pb);
+ dts |= avio_r8(s->pb) << 24;
// av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, dts:%d\n", type, size, dts);
if (url_feof(s->pb))
return AVERROR_EOF;
if (type == FLV_TAG_TYPE_AUDIO) {
is_audio=1;
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
size--;
} else if (type == FLV_TAG_TYPE_VIDEO) {
is_audio=0;
- flags = get_byte(s->pb);
+ flags = avio_r8(s->pb);
size--;
if ((flags & 0xf0) == 0x50) /* video info / command frame */
goto skip;
const int64_t pos= url_ftell(s->pb);
const int64_t fsize= url_fsize(s->pb);
url_fseek(s->pb, fsize-4, SEEK_SET);
- size= get_be32(s->pb);
+ size= avio_rb32(s->pb);
url_fseek(s->pb, fsize-3-size, SEEK_SET);
- if(size == get_be24(s->pb) + 11){
- uint32_t ts = get_be24(s->pb);
- ts |= get_byte(s->pb) << 24;
+ if(size == avio_rb24(s->pb) + 11){
+ uint32_t ts = avio_rb24(s->pb);
+ ts |= avio_r8(s->pb) << 24;
s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
}
url_fseek(s->pb, pos, SEEK_SET);
if (st->codec->codec_id == CODEC_ID_AAC ||
st->codec->codec_id == CODEC_ID_H264) {
- int type = get_byte(s->pb);
+ int type = avio_r8(s->pb);
size--;
if (st->codec->codec_id == CODEC_ID_H264) {
- int32_t cts = (get_be24(s->pb)+0xff800000)^0xff800000; // sign extension
+ int32_t cts = (avio_rb24(s->pb)+0xff800000)^0xff800000; // sign extension
pts = dts + cts;
if (cts < 0) { // dts are wrong
flv->wrong_dts = 1;
* \return 0 if header not found or contains invalid data, 1 otherwise
*/
static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) {
- if (get_be32(pb))
+ if (avio_rb32(pb))
return 0;
- if (get_byte(pb) != 1)
+ if (avio_r8(pb) != 1)
return 0;
- *type = get_byte(pb);
- *length = get_be32(pb);
+ *type = avio_r8(pb);
+ *length = avio_rb32(pb);
if ((*length >> 24) || *length < 16)
return 0;
*length -= 16;
- if (get_be32(pb))
+ if (avio_rb32(pb))
return 0;
- if (get_byte(pb) != 0xe1)
+ if (avio_r8(pb) != 0xe1)
return 0;
- if (get_byte(pb) != 0xe2)
+ if (avio_r8(pb) != 0xe2)
return 0;
return 1;
}
si->first_field = AV_NOPTS_VALUE;
si->last_field = AV_NOPTS_VALUE;
while (*len >= 2) {
- GXFMatTag tag = get_byte(pb);
- int tlen = get_byte(pb);
+ GXFMatTag tag = avio_r8(pb);
+ int tlen = avio_r8(pb);
*len -= 2;
if (tlen > *len)
return;
*len -= tlen;
if (tlen == 4) {
- uint32_t value = get_be32(pb);
+ uint32_t value = avio_rb32(pb);
if (tag == MAT_FIRST_FIELD)
si->first_field = value;
else if (tag == MAT_LAST_FIELD)
si->frames_per_second = (AVRational){0, 0};
si->fields_per_frame = 0;
while (*len >= 2) {
- GXFTrackTag tag = get_byte(pb);
- int tlen = get_byte(pb);
+ GXFTrackTag tag = avio_r8(pb);
+ int tlen = avio_r8(pb);
*len -= 2;
if (tlen > *len)
return;
*len -= tlen;
if (tlen == 4) {
- uint32_t value = get_be32(pb);
+ uint32_t value = avio_rb32(pb);
if (tag == TRACK_FPS)
si->frames_per_second = fps_tag2avr(value);
else if (tag == TRACK_FPF && (value == 1 || value == 2))
static void gxf_read_index(AVFormatContext *s, int pkt_len) {
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
- uint32_t fields_per_map = get_le32(pb);
- uint32_t map_cnt = get_le32(pb);
+ uint32_t fields_per_map = avio_rl32(pb);
+ uint32_t map_cnt = avio_rl32(pb);
int i;
pkt_len -= 8;
if (s->flags & AVFMT_FLAG_IGNIDX) {
pkt_len -= 4 * map_cnt;
av_add_index_entry(st, 0, 0, 0, 0, 0);
for (i = 0; i < map_cnt; i++)
- av_add_index_entry(st, (uint64_t)get_le32(pb) * 1024,
+ av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,
i * (uint64_t)fields_per_map + 1, 0, 0, 0);
url_fskip(pb, pkt_len);
}
return 0;
}
map_len -= 2;
- if (get_byte(pb) != 0x0e0 || get_byte(pb) != 0xff) {
+ if (avio_r8(pb) != 0x0e0 || avio_r8(pb) != 0xff) {
av_log(s, AV_LOG_ERROR, "unknown version or invalid map preamble\n");
return 0;
}
map_len -= 2;
- len = get_be16(pb); // length of material data section
+ len = avio_rb16(pb); // length of material data section
if (len > map_len) {
av_log(s, AV_LOG_ERROR, "material data longer than map data\n");
return 0;
gxf_material_tags(pb, &len, &si);
url_fskip(pb, len);
map_len -= 2;
- len = get_be16(pb); // length of track description
+ len = avio_rb16(pb); // length of track description
if (len > map_len) {
av_log(s, AV_LOG_ERROR, "track description longer than map data\n");
return 0;
AVStream *st;
int idx;
len -= 4;
- track_type = get_byte(pb);
- track_id = get_byte(pb);
- track_len = get_be16(pb);
+ track_type = avio_r8(pb);
+ track_id = avio_r8(pb);
+ track_len = avio_rb16(pb);
len -= track_len;
gxf_track_tags(pb, &track_len, &si);
url_fskip(pb, track_len);
len -= 0x39;
url_fskip(pb, 5); // preamble
url_fskip(pb, 0x30); // payload description
- fps = fps_umf2avr(get_le32(pb));
+ fps = fps_umf2avr(avio_rl32(pb));
if (!main_timebase.num || !main_timebase.den) {
// this may not always be correct, but simply the best we can get
main_timebase.num = fps.den;
{ \
if (!max_interval-- || url_feof(pb)) \
goto out; \
- tmp = tmp << 8 | get_byte(pb); \
+ tmp = tmp << 8 | avio_r8(pb); \
}
/**
int len;
AVIOContext *pb = s->pb;
GXFPktType type;
- tmp = get_be32(pb);
+ tmp = avio_rb32(pb);
start:
while (tmp)
READ_ONE();
goto out;
goto start;
}
- get_byte(pb);
- cur_track = get_byte(pb);
- cur_timestamp = get_be32(pb);
+ avio_r8(pb);
+ cur_track = avio_r8(pb);
+ cur_timestamp = avio_rb32(pb);
last_found_pos = url_ftell(pb) - 16 - 6;
if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
if (url_fseek(pb, last_pos, SEEK_SET) >= 0)
continue;
}
pkt_len -= 16;
- track_type = get_byte(pb);
- track_id = get_byte(pb);
+ track_type = avio_r8(pb);
+ track_id = avio_r8(pb);
stream_index = get_sindex(s, track_id, track_type);
if (stream_index < 0)
return stream_index;
st = s->streams[stream_index];
- field_nr = get_be32(pb);
- field_info = get_be32(pb);
- get_be32(pb); // "timeline" field number
- get_byte(pb); // flags
- get_byte(pb); // reserved
+ field_nr = avio_rb32(pb);
+ field_info = avio_rb32(pb);
+ avio_rb32(pb); // "timeline" field number
+ avio_r8(pb); // flags
+ avio_r8(pb); // reserved
if (st->codec->codec_id == CODEC_ID_PCM_S24LE ||
st->codec->codec_id == CODEC_ID_PCM_S16LE) {
int first = field_info >> 16;
filesize = url_fsize(s->pb);
if (filesize > 128) {
url_fseek(s->pb, filesize - 128, SEEK_SET);
- ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE);
+ ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE);
if (ret == ID3v1_TAG_SIZE) {
parse_tag(s, buf);
}
{
int v = 0;
while (len--)
- v = (v << 7) + (get_byte(s) & 0x7F);
+ v = (v << 7) + (avio_r8(s) & 0x7F);
return v;
}
const char *val = NULL;
int len, dstlen = sizeof(dst) - 1;
unsigned genre;
- unsigned int (*get)(AVIOContext*) = get_be16;
+ unsigned int (*get)(AVIOContext*) = avio_rb16;
dst[0] = 0;
if (taglen < 1)
taglen--; /* account for encoding type byte */
- switch (get_byte(pb)) { /* encoding type */
+ switch (avio_r8(pb)) { /* encoding type */
case ID3v2_ENCODING_ISO8859:
q = dst;
while (taglen-- && q - dst < dstlen - 7) {
uint8_t tmp;
- PUT_UTF8(get_byte(pb), tmp, *q++ = tmp;)
+ PUT_UTF8(avio_r8(pb), tmp, *q++ = tmp;)
}
*q = 0;
break;
case ID3v2_ENCODING_UTF16BOM:
taglen -= 2;
- switch (get_be16(pb)) {
+ switch (avio_rb16(pb)) {
case 0xfffe:
- get = get_le16;
+ get = avio_rl16;
case 0xfeff:
break;
default:
case ID3v2_ENCODING_UTF8:
len = FFMIN(taglen, dstlen);
- get_buffer(pb, dst, len);
+ avio_read(pb, dst, len);
dst[len] = 0;
break;
default:
int tunsync = 0;
if (isv34) {
- get_buffer(s->pb, tag, 4);
+ avio_read(s->pb, tag, 4);
tag[4] = 0;
if(version==3){
- tlen = get_be32(s->pb);
+ tlen = avio_rb32(s->pb);
}else
tlen = get_size(s->pb, 4);
- tflags = get_be16(s->pb);
+ tflags = avio_rb16(s->pb);
tunsync = tflags & ID3v2_FLAG_UNSYNCH;
} else {
- get_buffer(s->pb, tag, 3);
+ avio_read(s->pb, tag, 3);
tag[3] = 0;
- tlen = get_be24(s->pb);
+ tlen = avio_rb24(s->pb);
}
len -= taghdrlen + tlen;
next = url_ftell(s->pb) + tlen;
if (tflags & ID3v2_FLAG_DATALEN) {
- get_be32(s->pb);
+ avio_rb32(s->pb);
tlen -= 4;
}
int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen);
for (i = 0, j = 0; i < tlen; i++, j++) {
- buffer[j] = get_byte(s->pb);
+ buffer[j] = avio_r8(s->pb);
if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) {
/* Unsynchronised byte, skip it */
j--;
do {
/* save the current offset in case there's nothing to read/skip */
off = url_ftell(s->pb);
- ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
+ ret = avio_read(s->pb, buf, ID3v2_HEADER_SIZE);
if (ret != ID3v2_HEADER_SIZE)
break;
found_header = ff_id3v2_match(buf, magic);
unsigned int sample_rate, bytes_per_sample, channels;
/* get the 5 header parameters */
- width = get_le32(pb);
- height = get_le32(pb);
- sample_rate = get_le32(pb);
- bytes_per_sample = get_le32(pb);
- channels = get_le32(pb);
+ width = avio_rl32(pb);
+ height = avio_rl32(pb);
+ sample_rate = avio_rl32(pb);
+ bytes_per_sample = avio_rl32(pb);
+ channels = avio_rl32(pb);
st = av_new_stream(s, 0);
if (!st)
/* load up the Huffman tables into extradata */
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
- if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
+ if (avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
HUFFMAN_TABLE_SIZE)
return AVERROR(EIO);
/* save a reference in order to transport the palette */
return AVERROR(EIO);
if (idcin->next_chunk_is_video) {
- command = get_le32(pb);
+ command = avio_rl32(pb);
if (command == 2) {
return AVERROR(EIO);
} else if (command == 1) {
/* trigger a palette change */
idcin->palctrl.palette_changed = 1;
- if (get_buffer(pb, palette_buffer, 768) != 768)
+ if (avio_read(pb, palette_buffer, 768) != 768)
return AVERROR(EIO);
/* scale the palette as necessary */
palette_scale = 2;
}
}
- chunk_size = get_le32(pb);
+ chunk_size = avio_rl32(pb);
/* skip the number of decoded bytes (always equal to width * height) */
url_fseek(pb, 4, SEEK_CUR);
chunk_size -= 4;
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
/* get the main header */
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
framerate = AV_RL16(&preamble[6]);
return AVERROR(EIO);
/* get the next chunk preamble */
- if ((ret = get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
+ if ((ret = avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
case RoQ_INFO:
if (!roq->width || !roq->height) {
AVStream *st = s->streams[roq->video_stream_index];
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
st->codec->width = roq->width = AV_RL16(preamble);
st->codec->height = roq->height = AV_RL16(preamble + 2);
codebook_offset = url_ftell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
codebook_size = chunk_size;
url_fseek(pb, codebook_size, SEEK_CUR);
- if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
}
pkt->pos= url_ftell(pb);
- ret = get_buffer(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
+ ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
chunk_size);
if (ret != chunk_size)
ret = AVERROR(EIO);
if (!buf)
return AVERROR(ENOMEM);
- if (get_buffer(s->pb, buf, data_size) < 0) {
+ if (avio_read(s->pb, buf, data_size) < 0) {
av_free(buf);
return AVERROR(EIO);
}
st->codec->channels = 1;
url_fskip(pb, 8);
// codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
- st->codec->codec_tag = get_le32(pb);
+ st->codec->codec_tag = avio_rl32(pb);
while(!url_feof(pb)) {
uint64_t orig_pos;
int res;
const char *metadata_tag = NULL;
- chunk_id = get_le32(pb);
- data_size = get_be32(pb);
+ chunk_id = avio_rl32(pb);
+ data_size = avio_rb32(pb);
orig_pos = url_ftell(pb);
switch(chunk_id) {
if (data_size < 14)
return AVERROR_INVALIDDATA;
url_fskip(pb, 12);
- st->codec->sample_rate = get_be16(pb);
+ st->codec->sample_rate = avio_rb16(pb);
if (data_size >= 16) {
url_fskip(pb, 1);
- compression = get_byte(pb);
+ compression = avio_r8(pb);
}
break;
case ID_CHAN:
if (data_size < 4)
return AVERROR_INVALIDDATA;
- st->codec->channels = (get_be32(pb) < 6) ? 1 : 2;
+ st->codec->channels = (avio_rb32(pb) < 6) ? 1 : 2;
break;
case ID_CMAP:
st->codec->extradata = av_malloc(data_size);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- if (get_buffer(pb, st->codec->extradata, data_size) < 0)
+ if (avio_read(pb, st->codec->extradata, data_size) < 0)
return AVERROR(EIO);
break;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
if (data_size <= 8)
return AVERROR_INVALIDDATA;
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
+ st->codec->width = avio_rb16(pb);
+ st->codec->height = avio_rb16(pb);
url_fskip(pb, 4); // x, y offset
- st->codec->bits_per_coded_sample = get_byte(pb);
+ st->codec->bits_per_coded_sample = avio_r8(pb);
if (data_size >= 11) {
url_fskip(pb, 1); // masking
- compression = get_byte(pb);
+ compression = avio_r8(pb);
}
if (data_size >= 16) {
url_fskip(pb, 3); // paddding, transparent
- st->sample_aspect_ratio.num = get_byte(pb);
- st->sample_aspect_ratio.den = get_byte(pb);
+ st->sample_aspect_ratio.num = avio_r8(pb);
+ st->sample_aspect_ratio.den = avio_r8(pb);
}
break;
if(st->codec->channels == 2) {
uint8_t sample_buffer[PACKET_SIZE];
- ret = get_buffer(pb, sample_buffer, PACKET_SIZE);
+ ret = avio_read(pb, sample_buffer, PACKET_SIZE);
if(av_new_packet(pkt, PACKET_SIZE) < 0) {
av_log(s, AV_LOG_ERROR, "cannot allocate packet\n");
return AVERROR(ENOMEM);
pkt->size= 0;
for(i=0; i<3; i++){
if(size[i]){
- ret[i]= get_buffer(f[i], pkt->data + pkt->size, size[i]);
+ ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]);
if (!s->is_pipe)
url_fclose(f[i]);
if(ret[i]>0)
{
int ret, size, w, h, unk1, unk2;
- if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
+ if (avio_rl32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
return AVERROR(EIO); // FIXME
- size = get_le32(s->pb);
+ size = avio_rl32(s->pb);
- w = get_le16(s->pb);
- h = get_le16(s->pb);
+ w = avio_rl16(s->pb);
+ h = avio_rl16(s->pb);
url_fskip(s->pb, 8); // zero + size (padded?)
url_fskip(s->pb, 2);
- unk1 = get_le16(s->pb);
- unk2 = get_le16(s->pb);
+ unk1 = avio_rl16(s->pb);
+ unk2 = avio_rl16(s->pb);
url_fskip(s->pb, 22); // ASCII timestamp
av_log(s, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
pkt->pos = url_ftell(s->pb);
pkt->stream_index = 0;
- ret = get_buffer(s->pb, pkt->data, size);
+ ret = avio_read(s->pb, pkt->data, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET);
s->decode_map_chunk_offset = 0;
- if (get_buffer(pb, pkt->data, s->decode_map_chunk_size) !=
+ if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
s->decode_map_chunk_size) {
av_free_packet(pkt);
return CHUNK_EOF;
url_fseek(pb, s->video_chunk_offset, SEEK_SET);
s->video_chunk_offset = 0;
- if (get_buffer(pb, pkt->data + s->decode_map_chunk_size,
+ if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
s->video_chunk_size) != s->video_chunk_size) {
av_free_packet(pkt);
return CHUNK_EOF;
/* read the next chunk, wherever the file happens to be pointing */
if (url_feof(pb))
return CHUNK_EOF;
- if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return CHUNK_BAD;
chunk_size = AV_RL16(&chunk_preamble[0]);
chunk_type = CHUNK_EOF;
break;
}
- if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE) {
chunk_type = CHUNK_BAD;
break;
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) !=
+ if (avio_read(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
chunk_type = CHUNK_BAD;
break;
}
- if (get_buffer(pb, scratch, opcode_size) != opcode_size) {
+ if (avio_read(pb, scratch, opcode_size) != opcode_size) {
chunk_type = CHUNK_BAD;
break;
}
int chunk_type;
uint8_t signature_buffer[sizeof(signature)];
- get_buffer(pb, signature_buffer, sizeof(signature_buffer));
+ avio_read(pb, signature_buffer, sizeof(signature_buffer));
while (memcmp(signature_buffer, signature, sizeof(signature))) {
memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
- signature_buffer[sizeof(signature_buffer) - 1] = get_byte(pb);
+ signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
if (url_feof(pb))
return AVERROR_EOF;
}
/* peek ahead to the next chunk-- if it is an init audio chunk, process
* it; if it is the first video chunk, this is a silent file */
- if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
+ if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_type = AV_RL16(&chunk_preamble[2]);
int len = 0;
int count = 4;
while (count--) {
- int c = get_byte(pb);
+ int c = avio_r8(pb);
len = (len << 7) | (c & 0x7f);
if (!(c & 0x80))
break;
int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
{
int len;
- *tag = get_byte(pb);
+ *tag = avio_r8(pb);
len = ff_mp4_read_descr_len(pb);
av_dlog(fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
return len;
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
{
int len, tag;
- int object_type_id = get_byte(pb);
- get_byte(pb); /* stream type */
- get_be24(pb); /* buffer size db */
- get_be32(pb); /* max bitrate */
- get_be32(pb); /* avg bitrate */
+ int object_type_id = avio_r8(pb);
+ avio_r8(pb); /* stream type */
+ avio_rb24(pb); /* buffer size db */
+ avio_rb32(pb); /* max bitrate */
+ avio_rb32(pb); /* avg bitrate */
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
av_dlog(fc, "esds object type id 0x%02x\n", object_type_id);
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
- get_buffer(pb, st->codec->extradata, len);
+ avio_read(pb, st->codec->extradata, len);
st->codec->extradata_size = len;
if (st->codec->codec_id == CODEC_ID_AAC) {
MPEG4AudioConfig cfg;
int i = 0;
char c;
- while ((c = get_byte(s))) {
+ while ((c = avio_r8(s))) {
if(c == ' ')
break;
if (i < maxlen-1)
}
if(!c)
- get_byte(s);
+ avio_r8(s);
buf[i] = 0; /* Ensure null terminated, but may be truncated */
}
{
int ret, size, pts, type;
retry:
- type= get_be16(s->pb); // 257 or 258
- size= get_be16(s->pb);
+ type= avio_rb16(s->pb); // 257 or 258
+ size= avio_rb16(s->pb);
- get_be16(s->pb); //some flags, 0x80 indicates end of frame
- get_be16(s->pb); //packet number
- pts=get_be32(s->pb);
- get_be32(s->pb); //6A 13 E3 88
+ avio_rb16(s->pb); //some flags, 0x80 indicates end of frame
+ avio_rb16(s->pb); //packet number
+ pts=avio_rb32(s->pb);
+ avio_rb32(s->pb); //6A 13 E3 88
size -= 12;
if(size<1)
AVStream *st;
AVRational time_base;
- get_le32(s->pb); // DKIF
- get_le16(s->pb); // version
- get_le16(s->pb); // header size
+ avio_rl32(s->pb); // DKIF
+ avio_rl16(s->pb); // version
+ avio_rl16(s->pb); // header size
st = av_new_stream(s, 0);
if (!st)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = get_le32(s->pb);
+ st->codec->codec_tag = avio_rl32(s->pb);
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
- st->codec->width = get_le16(s->pb);
- st->codec->height = get_le16(s->pb);
- time_base.den = get_le32(s->pb);
- time_base.num = get_le32(s->pb);
- st->duration = get_le64(s->pb);
+ st->codec->width = avio_rl16(s->pb);
+ st->codec->height = avio_rl16(s->pb);
+ time_base.den = avio_rl32(s->pb);
+ time_base.num = avio_rl32(s->pb);
+ st->duration = avio_rl64(s->pb);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
- int ret, size = get_le32(s->pb);
- int64_t pts = get_le64(s->pb);
+ int ret, size = avio_rl32(s->pb);
+ int64_t pts = avio_rl64(s->pb);
ret = av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0;
static size_t av_read(void * h, size_t len, uint8_t * buf) {
AVIOContext * bc = h;
- return get_buffer(bc, buf, len);
+ return avio_read(bc, buf, len);
}
static off_t av_seek(void * h, long long pos, int whence) {
int ret;
unsigned int frame_type, packet_size, padding, frame_size;
- get_be16(pb); /* channel number */
- frame_type = get_be16(pb);
- packet_size = get_be32(pb);
+ avio_rb16(pb); /* channel number */
+ frame_type = avio_rb16(pb);
+ packet_size = avio_rb32(pb);
padding = -packet_size & 511;
frame_size = packet_size - 8;
uint8_t buf[LXF_IDENT_LENGTH];
int ret;
- if ((ret = get_buffer(s->pb, buf, LXF_IDENT_LENGTH)) != LXF_IDENT_LENGTH)
+ if ((ret = avio_read(s->pb, buf, LXF_IDENT_LENGTH)) != LXF_IDENT_LENGTH)
return ret < 0 ? ret : AVERROR_EOF;
while (memcmp(buf, LXF_IDENT, LXF_IDENT_LENGTH)) {
return AVERROR_EOF;
memmove(buf, &buf[1], LXF_IDENT_LENGTH-1);
- buf[LXF_IDENT_LENGTH-1] = get_byte(s->pb);
+ buf[LXF_IDENT_LENGTH-1] = avio_r8(s->pb);
}
memcpy(header, LXF_IDENT, LXF_IDENT_LENGTH);
return ret;
//read the rest of the packet header
- if ((ret = get_buffer(pb, header + LXF_IDENT_LENGTH,
+ if ((ret = avio_read(pb, header + LXF_IDENT_LENGTH,
LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH)) !=
LXF_PACKET_HEADER_SIZE - LXF_IDENT_LENGTH) {
return ret < 0 ? ret : AVERROR_EOF;
return AVERROR_INVALIDDATA;
}
- if ((ret = get_buffer(pb, header_data, LXF_HEADER_DATA_SIZE)) != LXF_HEADER_DATA_SIZE)
+ if ((ret = avio_read(pb, header_data, LXF_HEADER_DATA_SIZE)) != LXF_HEADER_DATA_SIZE)
return ret < 0 ? ret : AVERROR_EOF;
if (!(st = av_new_stream(s, 0)))
//read non-20-bit audio data into lxf->temp so we can deplanarize it
buf = ast && ast->codec->codec_id != CODEC_ID_PCM_LXF ? lxf->temp : pkt->data;
- if ((ret2 = get_buffer(pb, buf, ret)) != ret) {
+ if ((ret2 = avio_read(pb, buf, ret)) != ret) {
av_free_packet(pkt);
return ret2 < 0 ? ret2 : AVERROR_EOF;
}
int read = 1, n = 1;
uint64_t total = 0;
- /* The first byte tells us the length in bytes - get_byte() can normally
+ /* The first byte tells us the length in bytes - avio_r8() can normally
* return 0, but since that's not a valid first ebmlID byte, we can
* use it safely here to catch EOS. */
- if (!(total = get_byte(pb))) {
+ if (!(total = avio_r8(pb))) {
/* we might encounter EOS here */
if (!url_feof(pb)) {
int64_t pos = url_ftell(pb);
/* read out length */
total ^= 1 << ff_log2_tab[total];
while (n++ < read)
- total = (total << 8) | get_byte(pb);
+ total = (total << 8) | avio_r8(pb);
*number = total;
/* big-endian ordering; build up number */
*num = 0;
while (n++ < size)
- *num = (*num << 8) | get_byte(pb);
+ *num = (*num << 8) | avio_r8(pb);
return 0;
}
if (size == 0) {
*num = 0;
} else if (size == 4) {
- *num= av_int2flt(get_be32(pb));
+ *num= av_int2flt(avio_rb32(pb));
} else if(size==8){
- *num= av_int2dbl(get_be64(pb));
+ *num= av_int2dbl(avio_rb64(pb));
} else
return AVERROR_INVALIDDATA;
* byte more, read the string and NULL-terminate it ourselves. */
if (!(*str = av_malloc(size + 1)))
return AVERROR(ENOMEM);
- if (get_buffer(pb, (uint8_t *) *str, size) != size) {
+ if (avio_read(pb, (uint8_t *) *str, size) != size) {
av_freep(str);
return AVERROR(EIO);
}
bin->size = length;
bin->pos = url_ftell(pb);
- if (get_buffer(pb, bin->data, length) != length) {
+ if (avio_read(pb, bin->data, length) != length) {
av_freep(&bin->data);
return AVERROR(EIO);
}
ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
url_fskip(&b, 22);
- flavor = get_be16(&b);
- track->audio.coded_framesize = get_be32(&b);
+ flavor = avio_rb16(&b);
+ track->audio.coded_framesize = avio_rb32(&b);
url_fskip(&b, 12);
- track->audio.sub_packet_h = get_be16(&b);
- track->audio.frame_size = get_be16(&b);
- track->audio.sub_packet_size = get_be16(&b);
+ track->audio.sub_packet_h = avio_rb16(&b);
+ track->audio.frame_size = avio_rb16(&b);
+ track->audio.sub_packet_size = avio_rb16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
unsigned int type, length;
unsigned int frame_rate, width, height;
- type = get_le16(pb);
- length = get_le32(pb);
+ type = avio_rl16(pb);
+ length = avio_rl32(pb);
if (type != MM_TYPE_HEADER)
return AVERROR_INVALIDDATA;
/* read header */
- get_le16(pb); /* total number of chunks */
- frame_rate = get_le16(pb);
- get_le16(pb); /* ibm-pc video bios mode */
- width = get_le16(pb);
- height = get_le16(pb);
+ avio_rl16(pb); /* total number of chunks */
+ frame_rate = avio_rl16(pb);
+ avio_rl16(pb); /* ibm-pc video bios mode */
+ width = avio_rl16(pb);
+ height = avio_rl16(pb);
url_fseek(pb, length - 10, SEEK_CUR); /* unknown data */
/* video stream */
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);
}
if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
- if (get_buffer(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
+ if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
return AVERROR(EIO);
pkt->size = length + MM_PREAMBLE_SIZE;
pkt->stream_index = 0;
int64_t file_size, size;
int rate, params;
- tag = get_le32(pb);
+ tag = avio_rl32(pb);
if (tag != MKTAG('M', 'M', 'M', 'D'))
return -1;
- file_size = get_be32(pb);
+ file_size = avio_rb32(pb);
/* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) {
- tag = get_le32(pb);
- size = get_be32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if(tag == MKTAG('C','N','T','I')) continue;
if(tag == MKTAG('O','P','D','A')) continue;
break;
return -1;
}
- get_byte(pb); /* format type */
- get_byte(pb); /* sequence type */
- params = get_byte(pb); /* (channel << 7) | (format << 4) | rate */
+ avio_r8(pb); /* format type */
+ avio_r8(pb); /* sequence type */
+ params = avio_r8(pb); /* (channel << 7) | (format << 4) | rate */
rate = mmf_rate(params & 0x0f);
if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
return -1;
}
- get_byte(pb); /* wave base bit */
- get_byte(pb); /* time base d */
- get_byte(pb); /* time base g */
+ avio_r8(pb); /* wave base bit */
+ avio_r8(pb); /* time base d */
+ avio_r8(pb); /* time base g */
/* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) {
- tag = get_le32(pb);
- size = get_be32(pb);
+ tag = avio_rl32(pb);
+ size = avio_rb32(pb);
if(tag == MKTAG('A','t','s','q')) continue;
if(tag == MKTAG('A','s','p','I')) continue;
break;
return AVERROR(EIO);
pkt->stream_index = 0;
- ret = get_buffer(s->pb, pkt->data, pkt->size);
+ ret = avio_read(s->pb, pkt->data, pkt->size);
if (ret < 0)
av_free_packet(pkt);
{
char buf[16];
- get_be16(pb); // unknown
- snprintf(buf, sizeof(buf), "%d", get_be16(pb));
+ avio_rb16(pb); // unknown
+ snprintf(buf, sizeof(buf), "%d", avio_rb16(pb));
av_metadata_set2(&c->fc->metadata, "track", buf, 0);
- get_be16(pb); // total tracks
+ avio_rb16(pb); // total tracks
return 0;
}
int i;
for (i = 0; i < len; i++) {
- uint8_t t, c = get_byte(pb);
+ uint8_t t, c = avio_r8(pb);
if (c < 0x80 && p < end)
*p++ = c;
else
}
if (c->itunes_metadata && atom.size > 8) {
- int data_size = get_be32(pb);
- int tag = get_le32(pb);
+ int data_size = avio_rb32(pb);
+ int tag = avio_rl32(pb);
if (tag == MKTAG('d','a','t','a')) {
- data_type = get_be32(pb); // type
- get_be32(pb); // unknown
+ data_type = avio_rb32(pb); // type
+ avio_rb32(pb); // unknown
str_size = data_size - 16;
atom.size -= 16;
} else return 0;
} else if (atom.size > 4 && key && !c->itunes_metadata) {
- str_size = get_be16(pb); // string length
- langcode = get_be16(pb);
+ str_size = avio_rb16(pb); // string length
+ langcode = avio_rb16(pb);
ff_mov_lang_to_iso639(langcode, language);
atom.size -= 4;
} else
if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded
mov_read_mac_string(c, pb, str_size, str, sizeof(str));
} else {
- get_buffer(pb, str, str_size);
+ avio_read(pb, str, str_size);
str[str_size] = 0;
}
av_metadata_set2(&c->fc->metadata, key, str, 0);
if ((atom.size -= 5) < 0)
return 0;
- version = get_byte(pb);
- get_be24(pb);
+ version = avio_r8(pb);
+ avio_rb24(pb);
if (version)
- get_be32(pb); // ???
- nb_chapters = get_byte(pb);
+ avio_rb32(pb); // ???
+ nb_chapters = avio_r8(pb);
for (i = 0; i < nb_chapters; i++) {
if (atom.size < 9)
return 0;
- start = get_be64(pb);
- str_len = get_byte(pb);
+ start = avio_rb64(pb);
+ str_len = avio_r8(pb);
if ((atom.size -= 9+str_len) < 0)
return 0;
- get_buffer(pb, str, str_len);
+ avio_read(pb, str, str_len);
str[str_len] = 0;
ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str);
}
a.size = atom.size;
a.type=0;
if(atom.size >= 8) {
- a.size = get_be32(pb);
- a.type = get_le32(pb);
+ a.size = avio_rb32(pb);
+ a.type = avio_rl32(pb);
}
av_dlog(c->fc, "type: %08x '%.4s' parent:'%.4s' sz: %"PRId64" %"PRId64" %"PRId64"\n",
a.type, (char*)&a.type, (char*)&atom.type, a.size, total_size, atom.size);
total_size += 8;
if (a.size == 1) { /* 64 bit extended size */
- a.size = get_be64(pb) - 8;
+ a.size = avio_rb64(pb) - 8;
total_size += 8;
}
if (a.size == 0) {
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_be32(pb); // version + flags
- entries = get_be32(pb);
+ avio_rb32(pb); // version + flags
+ entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->drefs))
return -1;
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
for (i = 0; i < sc->drefs_count; i++) {
MOVDref *dref = &sc->drefs[i];
- uint32_t size = get_be32(pb);
+ uint32_t size = avio_rb32(pb);
int64_t next = url_ftell(pb) + size - 4;
if (size < 12)
return -1;
- dref->type = get_le32(pb);
- get_be32(pb); // version + flags
+ dref->type = avio_rl32(pb);
+ avio_rb32(pb); // version + flags
av_dlog(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);
if (dref->type == MKTAG('a','l','i','s') && size > 150) {
url_fskip(pb, 10);
- volume_len = get_byte(pb);
+ volume_len = avio_r8(pb);
volume_len = FFMIN(volume_len, 27);
- get_buffer(pb, dref->volume, 27);
+ avio_read(pb, dref->volume, 27);
dref->volume[volume_len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", dref->volume, volume_len);
url_fskip(pb, 12);
- len = get_byte(pb);
+ len = avio_r8(pb);
len = FFMIN(len, 63);
- get_buffer(pb, dref->filename, 63);
+ avio_read(pb, dref->filename, 63);
dref->filename[len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "filename %s, len %d\n", dref->filename, len);
url_fskip(pb, 16);
/* read next level up_from_alias/down_to_target */
- dref->nlvl_from = get_be16(pb);
- dref->nlvl_to = get_be16(pb);
+ dref->nlvl_from = avio_rb16(pb);
+ dref->nlvl_to = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "nlvl from %d, nlvl to %d\n",
dref->nlvl_from, dref->nlvl_to);
url_fskip(pb, 16);
for (type = 0; type != -1 && url_ftell(pb) < next; ) {
- type = get_be16(pb);
- len = get_be16(pb);
+ type = avio_rb16(pb);
+ len = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
if (len&1)
len += 1;
dref->path = av_mallocz(len+1);
if (!dref->path)
return AVERROR(ENOMEM);
- get_buffer(pb, dref->path, len);
+ avio_read(pb, dref->path, len);
if (len > volume_len && !strncmp(dref->path, dref->volume, volume_len)) {
len -= volume_len;
memmove(dref->path, dref->path+volume_len, len);
dref->dir = av_malloc(len+1);
if (!dref->dir)
return AVERROR(ENOMEM);
- get_buffer(pb, dref->dir, len);
+ avio_read(pb, dref->dir, len);
dref->dir[len] = 0;
for (j = 0; j < len; j++)
if (dref->dir[j] == ':')
st = c->fc->streams[c->fc->nb_streams-1];
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
/* component type */
- ctype = get_le32(pb);
- type = get_le32(pb); /* component subtype */
+ ctype = avio_rl32(pb);
+ type = avio_rl32(pb); /* component subtype */
av_dlog(c->fc, "ctype= %.4s (0x%08x)\n", (char*)&ctype, ctype);
av_dlog(c->fc, "stype= %.4s\n", (char*)&type);
else if(type == MKTAG('s','u','b','p'))
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- get_be32(pb); /* component manufacture */
- get_be32(pb); /* component flags */
- get_be32(pb); /* component flags mask */
+ avio_rb32(pb); /* component manufacture */
+ avio_rb32(pb); /* component flags */
+ avio_rb32(pb); /* component flags mask */
return 0;
}
return 0;
st = fc->streams[fc->nb_streams-1];
- get_be32(pb); /* version + flags */
+ avio_rb32(pb); /* version + flags */
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
- get_be16(pb); /* ID */
- get_byte(pb); /* priority */
+ avio_rb16(pb); /* ID */
+ avio_r8(pb); /* priority */
} else
- get_be16(pb); /* ID */
+ avio_rb16(pb); /* ID */
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- ac3info = get_be24(pb);
+ ac3info = avio_rb24(pb);
acmod = (ac3info >> 11) & 0x7;
lfeon = (ac3info >> 10) & 0x1;
st->codec->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
- const int num = get_be32(pb);
- const int den = get_be32(pb);
+ const int num = avio_rb32(pb);
+ const int den = avio_rb32(pb);
AVStream *st;
if (c->fc->nb_streams < 1)
char* comp_brands_str;
uint8_t type[5] = {0};
- get_buffer(pb, type, 4);
+ avio_read(pb, type, 4);
if (strcmp(type, "qt "))
c->isom = 1;
av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
av_metadata_set2(&c->fc->metadata, "major_brand", type, 0);
- minor_ver = get_be32(pb); /* minor version */
+ minor_ver = avio_rb32(pb); /* minor version */
snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */
if (!comp_brands_str)
return AVERROR(ENOMEM);
- get_buffer(pb, comp_brands_str, comp_brand_size);
+ avio_read(pb, comp_brands_str, comp_brand_size);
comp_brands_str[comp_brand_size] = 0;
av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_freep(&comp_brands_str);
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- version = get_byte(pb);
+ version = avio_r8(pb);
if (version > 1)
return -1; /* unsupported */
- get_be24(pb); /* flags */
+ avio_rb24(pb); /* flags */
if (version == 1) {
- creation_time = get_be64(pb);
- get_be64(pb);
+ creation_time = avio_rb64(pb);
+ avio_rb64(pb);
} else {
- creation_time = get_be32(pb);
- get_be32(pb); /* modification time */
+ creation_time = avio_rb32(pb);
+ avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&st->metadata, creation_time);
- sc->time_scale = get_be32(pb);
- st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
+ sc->time_scale = avio_rb32(pb);
+ st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
- lang = get_be16(pb); /* language */
+ lang = avio_rb16(pb); /* language */
if (ff_mov_lang_to_iso639(lang, language))
av_metadata_set2(&st->metadata, "language", language, 0);
- get_be16(pb); /* quality */
+ avio_rb16(pb); /* quality */
return 0;
}
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
time_t creation_time;
- int version = get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ int version = avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
if (version == 1) {
- creation_time = get_be64(pb);
- get_be64(pb);
+ creation_time = avio_rb64(pb);
+ avio_rb64(pb);
} else {
- creation_time = get_be32(pb);
- get_be32(pb); /* modification time */
+ creation_time = avio_rb32(pb);
+ avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&c->fc->metadata, creation_time);
- c->time_scale = get_be32(pb); /* time scale */
+ c->time_scale = avio_rb32(pb); /* time scale */
av_dlog(c->fc, "time scale = %i\n", c->time_scale);
- c->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
- get_be32(pb); /* preferred scale */
+ c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
+ avio_rb32(pb); /* preferred scale */
- get_be16(pb); /* preferred volume */
+ avio_rb16(pb); /* preferred volume */
url_fskip(pb, 10); /* reserved */
url_fskip(pb, 36); /* display matrix */
- get_be32(pb); /* preview time */
- get_be32(pb); /* preview duration */
- get_be32(pb); /* poster time */
- get_be32(pb); /* selection time */
- get_be32(pb); /* selection duration */
- get_be32(pb); /* current time */
- get_be32(pb); /* next track ID */
+ avio_rb32(pb); /* preview time */
+ avio_rb32(pb); /* preview duration */
+ avio_rb32(pb); /* poster time */
+ avio_rb32(pb); /* selection time */
+ avio_rb32(pb); /* selection duration */
+ avio_rb32(pb); /* current time */
+ avio_rb32(pb); /* next track ID */
return 0;
}
return AVERROR(ENOMEM);
st->codec->extradata_size = 0x5a + atom.size;
memcpy(st->codec->extradata, "SVQ3", 4); // fake
- get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
+ avio_read(pb, st->codec->extradata + 0x5a, atom.size);
av_dlog(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
return 0;
}
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- little_endian = get_be16(pb);
+ little_endian = avio_rb16(pb);
av_dlog(c->fc, "enda %d\n", little_endian);
if (little_endian == 1) {
switch (st->codec->codec_id) {
st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE;
AV_WB32( buf , atom.size + 8);
AV_WL32( buf + 4, atom.type);
- get_buffer(pb, buf + 8, atom.size);
+ avio_read(pb, buf + 8, atom.size);
return 0;
}
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
- get_buffer(pb, st->codec->extradata, atom.size);
+ avio_read(pb, st->codec->extradata, atom.size);
} else if (atom.size > 8) { /* to read frma, esds atoms */
if (mov_read_default(c, pb, atom) < 0)
return -1;
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
- get_buffer(pb, st->codec->extradata, atom.size);
+ avio_read(pb, st->codec->extradata, atom.size);
return 0;
}
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 40;
url_fskip(pb, 40);
- get_buffer(pb, st->codec->extradata, atom.size - 40);
+ avio_read(pb, st->codec->extradata, atom.size - 40);
return 0;
}
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
if(entries >= UINT_MAX/sizeof(int64_t))
return -1;
if (atom.type == MKTAG('s','t','c','o'))
for(i=0; i<entries; i++)
- sc->chunk_offsets[i] = get_be32(pb);
+ sc->chunk_offsets[i] = avio_rb32(pb);
else if (atom.type == MKTAG('c','o','6','4'))
for(i=0; i<entries; i++)
- sc->chunk_offsets[i] = get_be64(pb);
+ sc->chunk_offsets[i] = avio_rb64(pb);
else
return -1;
int dref_id = 1;
MOVAtom a = { AV_RL32("stsd") };
int64_t start_pos = url_ftell(pb);
- int size = get_be32(pb); /* size */
- uint32_t format = get_le32(pb); /* data format */
+ int size = avio_rb32(pb); /* size */
+ uint32_t format = avio_rl32(pb); /* data format */
if (size >= 16) {
- get_be32(pb); /* reserved */
- get_be16(pb); /* reserved */
- dref_id = get_be16(pb);
+ avio_rb32(pb); /* reserved */
+ avio_rb16(pb); /* reserved */
+ dref_id = avio_rb16(pb);
}
if (st->codec->codec_tag &&
int color_greyscale;
st->codec->codec_id = id;
- get_be16(pb); /* version */
- get_be16(pb); /* revision level */
- get_be32(pb); /* vendor */
- get_be32(pb); /* temporal quality */
- get_be32(pb); /* spatial quality */
+ avio_rb16(pb); /* version */
+ avio_rb16(pb); /* revision level */
+ avio_rb32(pb); /* vendor */
+ avio_rb32(pb); /* temporal quality */
+ avio_rb32(pb); /* spatial quality */
- st->codec->width = get_be16(pb); /* width */
- st->codec->height = get_be16(pb); /* height */
+ st->codec->width = avio_rb16(pb); /* width */
+ st->codec->height = avio_rb16(pb); /* height */
- get_be32(pb); /* horiz resolution */
- get_be32(pb); /* vert resolution */
- get_be32(pb); /* data size, always 0 */
- get_be16(pb); /* frames per samples */
+ avio_rb32(pb); /* horiz resolution */
+ avio_rb32(pb); /* vert resolution */
+ avio_rb32(pb); /* data size, always 0 */
+ avio_rb16(pb); /* frames per samples */
- len = get_byte(pb); /* codec name, pascal string */
+ len = avio_r8(pb); /* codec name, pascal string */
if (len > 31)
len = 31;
mov_read_mac_string(c, pb, len, st->codec->codec_name, 32);
if (!memcmp(st->codec->codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25))
st->codec->codec_tag=MKTAG('I', '4', '2', '0');
- st->codec->bits_per_coded_sample = get_be16(pb); /* depth */
- st->codec->color_table_id = get_be16(pb); /* colortable id */
+ st->codec->bits_per_coded_sample = avio_rb16(pb); /* depth */
+ st->codec->color_table_id = avio_rb16(pb); /* colortable id */
av_dlog(c->fc, "depth %d, ctab id %d\n",
st->codec->bits_per_coded_sample, st->codec->color_table_id);
/* figure out the palette situation */
}
} else {
/* load the palette from the file */
- color_start = get_be32(pb);
- color_count = get_be16(pb);
- color_end = get_be16(pb);
+ color_start = avio_rb32(pb);
+ color_count = avio_rb16(pb);
+ color_end = avio_rb16(pb);
if ((color_start <= 255) &&
(color_end <= 255)) {
for (j = color_start; j <= color_end; j++) {
/* each R, G, or B component is 16 bits;
* only use the top 8 bits; skip alpha bytes
* up front */
- get_byte(pb);
- get_byte(pb);
- r = get_byte(pb);
- get_byte(pb);
- g = get_byte(pb);
- get_byte(pb);
- b = get_byte(pb);
- get_byte(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ r = avio_r8(pb);
+ avio_r8(pb);
+ g = avio_r8(pb);
+ avio_r8(pb);
+ b = avio_r8(pb);
+ avio_r8(pb);
st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b);
}
}
} else if(st->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
int bits_per_sample, flags;
- uint16_t version = get_be16(pb);
+ uint16_t version = avio_rb16(pb);
st->codec->codec_id = id;
- get_be16(pb); /* revision level */
- get_be32(pb); /* vendor */
+ avio_rb16(pb); /* revision level */
+ avio_rb32(pb); /* vendor */
- st->codec->channels = get_be16(pb); /* channel count */
+ st->codec->channels = avio_rb16(pb); /* channel count */
av_dlog(c->fc, "audio channels %d\n", st->codec->channels);
- st->codec->bits_per_coded_sample = get_be16(pb); /* sample size */
+ st->codec->bits_per_coded_sample = avio_rb16(pb); /* sample size */
- sc->audio_cid = get_be16(pb);
- get_be16(pb); /* packet size = 0 */
+ sc->audio_cid = avio_rb16(pb);
+ avio_rb16(pb); /* packet size = 0 */
- st->codec->sample_rate = ((get_be32(pb) >> 16));
+ st->codec->sample_rate = ((avio_rb32(pb) >> 16));
//Read QT version 1 fields. In version 0 these do not exist.
av_dlog(c->fc, "version =%d, isom =%d\n",version,c->isom);
if(!c->isom) {
if(version==1) {
- sc->samples_per_frame = get_be32(pb);
- get_be32(pb); /* bytes per packet */
- sc->bytes_per_frame = get_be32(pb);
- get_be32(pb); /* bytes per sample */
+ sc->samples_per_frame = avio_rb32(pb);
+ avio_rb32(pb); /* bytes per packet */
+ sc->bytes_per_frame = avio_rb32(pb);
+ avio_rb32(pb); /* bytes per sample */
} else if(version==2) {
- get_be32(pb); /* sizeof struct only */
- st->codec->sample_rate = av_int2dbl(get_be64(pb)); /* float 64 */
- st->codec->channels = get_be32(pb);
- get_be32(pb); /* always 0x7F000000 */
- st->codec->bits_per_coded_sample = get_be32(pb); /* bits per channel if sound is uncompressed */
- flags = get_be32(pb); /* lpcm format specific flag */
- sc->bytes_per_frame = get_be32(pb); /* bytes per audio packet if constant */
- sc->samples_per_frame = get_be32(pb); /* lpcm frames per audio packet if constant */
+ avio_rb32(pb); /* sizeof struct only */
+ st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); /* float 64 */
+ st->codec->channels = avio_rb32(pb);
+ avio_rb32(pb); /* always 0x7F000000 */
+ st->codec->bits_per_coded_sample = avio_rb32(pb); /* bits per channel if sound is uncompressed */
+ flags = avio_rb32(pb); /* lpcm format specific flag */
+ sc->bytes_per_frame = avio_rb32(pb); /* bytes per audio packet if constant */
+ sc->samples_per_frame = avio_rb32(pb); /* lpcm frames per audio packet if constant */
if (format == MKTAG('l','p','c','m'))
st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
}
{
int entries;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
return ff_mov_read_stsd_entries(c, pb, entries);
}
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
sc->stsc_count = entries;
for(i=0; i<entries; i++) {
- sc->stsc_data[i].first = get_be32(pb);
- sc->stsc_data[i].count = get_be32(pb);
- sc->stsc_data[i].id = get_be32(pb);
+ sc->stsc_data[i].first = avio_rb32(pb);
+ sc->stsc_data[i].count = avio_rb32(pb);
+ sc->stsc_data[i].id = avio_rb32(pb);
}
return 0;
}
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_be32(pb); // version + flags
+ avio_rb32(pb); // version + flags
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->stps_data))
return -1;
sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data));
sc->stps_count = entries;
for (i = 0; i < entries; i++) {
- sc->stps_data[i] = get_be32(pb);
+ sc->stps_data[i] = avio_rb32(pb);
//av_dlog(c->fc, "stps %d\n", sc->stps_data[i]);
}
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "keyframe_count = %d\n", entries);
sc->keyframe_count = entries;
for(i=0; i<entries; i++) {
- sc->keyframes[i] = get_be32(pb);
+ sc->keyframes[i] = avio_rb32(pb);
//av_dlog(c->fc, "keyframes[]=%d\n", sc->keyframes[i]);
}
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
if (atom.type == MKTAG('s','t','s','z')) {
- sample_size = get_be32(pb);
+ sample_size = avio_rb32(pb);
if (!sc->sample_size) /* do not overwrite value computed in stsd */
sc->sample_size = sample_size;
field_size = 32;
} else {
sample_size = 0;
- get_be24(pb); /* reserved */
- field_size = get_byte(pb);
+ avio_rb24(pb); /* reserved */
+ field_size = avio_r8(pb);
}
- entries = get_be32(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
return AVERROR(ENOMEM);
}
- if (get_buffer(pb, buf, num_bytes) < num_bytes) {
+ if (avio_read(pb, buf, num_bytes) < num_bytes) {
av_freep(&sc->sample_sizes);
av_free(buf);
return -1;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries);
int sample_duration;
int sample_count;
- sample_count=get_be32(pb);
- sample_duration = get_be32(pb);
+ sample_count=avio_rb32(pb);
+ sample_duration = avio_rb32(pb);
sc->stts_data[i].count= sample_count;
sc->stts_data[i].duration= sample_duration;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
sc->ctts_count = entries;
for(i=0; i<entries; i++) {
- int count =get_be32(pb);
- int duration =get_be32(pb);
+ int count =avio_rb32(pb);
+ int duration =avio_rb32(pb);
sc->ctts_data[i].count = count;
sc->ctts_data[i].duration= duration;
static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
while (atom.size > 8) {
- uint32_t tag = get_le32(pb);
+ uint32_t tag = avio_rl32(pb);
atom.size -= 4;
if (tag == MKTAG('h','d','l','r')) {
url_fseek(pb, -8, SEEK_CUR);
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
- version = get_byte(pb);
- get_be24(pb); /* flags */
+ version = avio_r8(pb);
+ avio_rb24(pb); /* flags */
/*
MOV_TRACK_ENABLED 0x0001
MOV_TRACK_IN_MOVIE 0x0002
*/
if (version == 1) {
- get_be64(pb);
- get_be64(pb);
+ avio_rb64(pb);
+ avio_rb64(pb);
} else {
- get_be32(pb); /* creation time */
- get_be32(pb); /* modification time */
+ avio_rb32(pb); /* creation time */
+ avio_rb32(pb); /* modification time */
}
- st->id = (int)get_be32(pb); /* track id (NOT 0 !)*/
- get_be32(pb); /* reserved */
+ st->id = (int)avio_rb32(pb); /* track id (NOT 0 !)*/
+ avio_rb32(pb); /* reserved */
/* highlevel (considering edits) duration in movie timebase */
- (version == 1) ? get_be64(pb) : get_be32(pb);
- get_be32(pb); /* reserved */
- get_be32(pb); /* reserved */
+ (version == 1) ? avio_rb64(pb) : avio_rb32(pb);
+ avio_rb32(pb); /* reserved */
+ avio_rb32(pb); /* reserved */
- get_be16(pb); /* layer */
- get_be16(pb); /* alternate group */
- get_be16(pb); /* volume */
- get_be16(pb); /* reserved */
+ avio_rb16(pb); /* layer */
+ avio_rb16(pb); /* alternate group */
+ avio_rb16(pb); /* volume */
+ avio_rb16(pb); /* reserved */
//read in the display matrix (outlined in ISO 14496-12, Section 6.2.2)
// they're kept in fixed point format through all calculations
// ignore u,v,z b/c we don't need the scale factor to calc aspect ratio
for (i = 0; i < 3; i++) {
- display_matrix[i][0] = get_be32(pb); // 16.16 fixed point
- display_matrix[i][1] = get_be32(pb); // 16.16 fixed point
- get_be32(pb); // 2.30 fixed point (not used)
+ display_matrix[i][0] = avio_rb32(pb); // 16.16 fixed point
+ display_matrix[i][1] = avio_rb32(pb); // 16.16 fixed point
+ avio_rb32(pb); // 2.30 fixed point (not used)
}
- width = get_be32(pb); // 16.16 fixed point track width
- height = get_be32(pb); // 16.16 fixed point track height
+ width = avio_rb32(pb); // 16.16 fixed point track width
+ height = avio_rb32(pb); // 16.16 fixed point track height
sc->width = width >> 16;
sc->height = height >> 16;
MOVTrackExt *trex = NULL;
int flags, track_id, i;
- get_byte(pb); /* version */
- flags = get_be24(pb);
+ avio_r8(pb); /* version */
+ flags = avio_rb24(pb);
- track_id = get_be32(pb);
+ track_id = avio_rb32(pb);
if (!track_id)
return -1;
frag->track_id = track_id;
return -1;
}
- if (flags & 0x01) frag->base_data_offset = get_be64(pb);
+ if (flags & 0x01) frag->base_data_offset = avio_rb64(pb);
else frag->base_data_offset = frag->moof_offset;
- if (flags & 0x02) frag->stsd_id = get_be32(pb);
+ if (flags & 0x02) frag->stsd_id = avio_rb32(pb);
else frag->stsd_id = trex->stsd_id;
- frag->duration = flags & 0x08 ? get_be32(pb) : trex->duration;
- frag->size = flags & 0x10 ? get_be32(pb) : trex->size;
- frag->flags = flags & 0x20 ? get_be32(pb) : trex->flags;
+ frag->duration = flags & 0x08 ? avio_rb32(pb) : trex->duration;
+ frag->size = flags & 0x10 ? avio_rb32(pb) : trex->size;
+ frag->flags = flags & 0x20 ? avio_rb32(pb) : trex->flags;
av_dlog(c->fc, "frag flags 0x%x\n", frag->flags);
return 0;
}
static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
- c->chapter_track = get_be32(pb);
+ c->chapter_track = avio_rb32(pb);
return 0;
}
return AVERROR(ENOMEM);
c->trex_data = trex;
trex = &c->trex_data[c->trex_count++];
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- trex->track_id = get_be32(pb);
- trex->stsd_id = get_be32(pb);
- trex->duration = get_be32(pb);
- trex->size = get_be32(pb);
- trex->flags = get_be32(pb);
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ trex->track_id = avio_rb32(pb);
+ trex->stsd_id = avio_rb32(pb);
+ trex->duration = avio_rb32(pb);
+ trex->size = avio_rb32(pb);
+ trex->flags = avio_rb32(pb);
return 0;
}
sc = st->priv_data;
if (sc->pseudo_stream_id+1 != frag->stsd_id)
return 0;
- get_byte(pb); /* version */
- flags = get_be24(pb);
- entries = get_be32(pb);
+ avio_r8(pb); /* version */
+ flags = avio_rb24(pb);
+ entries = avio_rb32(pb);
av_dlog(c->fc, "flags 0x%x entries %d\n", flags, entries);
- if (flags & 0x001) data_offset = get_be32(pb);
- if (flags & 0x004) first_sample_flags = get_be32(pb);
+ if (flags & 0x001) data_offset = avio_rb32(pb);
+ if (flags & 0x004) first_sample_flags = avio_rb32(pb);
if (flags & 0x800) {
MOVStts *ctts_data;
if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))
unsigned sample_duration = frag->duration;
int keyframe;
- if (flags & 0x100) sample_duration = get_be32(pb);
- if (flags & 0x200) sample_size = get_be32(pb);
- if (flags & 0x400) sample_flags = get_be32(pb);
+ if (flags & 0x100) sample_duration = avio_rb32(pb);
+ if (flags & 0x200) sample_size = avio_rb32(pb);
+ if (flags & 0x400) sample_flags = avio_rb32(pb);
if (flags & 0x800) {
sc->ctts_data[sc->ctts_count].count = 1;
- sc->ctts_data[sc->ctts_count].duration = get_be32(pb);
+ sc->ctts_data[sc->ctts_count].duration = avio_rb32(pb);
sc->ctts_count++;
}
if ((keyframe = st->codec->codec_type == AVMEDIA_TYPE_AUDIO ||
if (atom.size < 8)
return 0; /* continue */
- if (get_be32(pb) != 0) { /* 0 sized mdat atom... use the 'wide' atom size */
+ if (avio_rb32(pb) != 0) { /* 0 sized mdat atom... use the 'wide' atom size */
url_fskip(pb, atom.size - 4);
return 0;
}
- atom.type = get_le32(pb);
+ atom.type = avio_rl32(pb);
atom.size -= 8;
if (atom.type != MKTAG('m','d','a','t')) {
url_fskip(pb, atom.size);
long cmov_len, moov_len;
int ret = -1;
- get_be32(pb); /* dcom atom */
- if (get_le32(pb) != MKTAG('d','c','o','m'))
+ avio_rb32(pb); /* dcom atom */
+ if (avio_rl32(pb) != MKTAG('d','c','o','m'))
return -1;
- if (get_le32(pb) != MKTAG('z','l','i','b')) {
+ if (avio_rl32(pb) != MKTAG('z','l','i','b')) {
av_log(c->fc, AV_LOG_ERROR, "unknown compression for cmov atom !");
return -1;
}
- get_be32(pb); /* cmvd atom */
- if (get_le32(pb) != MKTAG('c','m','v','d'))
+ avio_rb32(pb); /* cmvd atom */
+ if (avio_rl32(pb) != MKTAG('c','m','v','d'))
return -1;
- moov_len = get_be32(pb); /* uncompressed size */
+ moov_len = avio_rb32(pb); /* uncompressed size */
cmov_len = atom.size - 6 * 4;
cmov_data = av_malloc(cmov_len);
av_free(cmov_data);
return AVERROR(ENOMEM);
}
- get_buffer(pb, cmov_data, cmov_len);
+ avio_read(pb, cmov_data, cmov_len);
if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK)
goto free_and_return;
if(ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
return 0;
sc = c->fc->streams[c->fc->nb_streams-1]->priv_data;
- get_byte(pb); /* version */
- get_be24(pb); /* flags */
- edit_count = get_be32(pb); /* entries */
+ avio_r8(pb); /* version */
+ avio_rb24(pb); /* flags */
+ edit_count = avio_rb32(pb); /* entries */
if((uint64_t)edit_count*12+8 > atom.size)
return -1;
for(i=0; i<edit_count; i++){
int time;
- int duration = get_be32(pb); /* Track duration */
- time = get_be32(pb); /* Media time */
- get_be32(pb); /* Media rate */
+ int duration = avio_rb32(pb); /* Track duration */
+ time = avio_rb32(pb); /* Media time */
+ avio_rb32(pb); /* Media rate */
if (i == 0 && time >= -1) {
sc->time_offset = time != -1 ? time : -duration;
}
}
// the first two bytes are the length of the title
- len = get_be16(sc->pb);
+ len = avio_rb16(sc->pb);
if (len > sample->size-2)
continue;
title_len = 2*len + 1;
// The samples could theoretically be in any encoding if there's an encd
// atom following, but in practice are only utf-8 or utf-16, distinguished
// instead by the presence of a BOM
- ch = get_be16(sc->pb);
+ ch = avio_rb16(sc->pb);
if (ch == 0xfeff)
avio_get_str16be(sc->pb, len, title, title_len);
else if (ch == 0xfffe)
MPADecodeHeader c;
int vbrtag_size = 0;
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(ff_mpa_check_header(v) < 0)
return -1;
/* Check for Xing / Info tag */
url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR);
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) {
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(v & 0x1)
- frames = get_be32(s->pb);
+ frames = avio_rb32(s->pb);
if(v & 0x2)
- size = get_be32(s->pb);
+ size = avio_rb32(s->pb);
}
/* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
url_fseek(s->pb, base + 4 + 32, SEEK_SET);
- v = get_be32(s->pb);
+ v = avio_rb32(s->pb);
if(v == MKBETAG('V', 'B', 'R', 'I')) {
/* Check tag version */
- if(get_be16(s->pb) == 1) {
+ if(avio_rb16(s->pb) == 1) {
/* skip delay and quality */
url_fseek(s->pb, 4, SEEK_CUR);
- frames = get_be32(s->pb);
- size = get_be32(s->pb);
+ frames = avio_rb32(s->pb);
+ size = avio_rb32(s->pb);
}
}
MPCContext *c = s->priv_data;
AVStream *st;
- if(get_le24(s->pb) != MKTAG('M', 'P', '+', 0)){
+ if(avio_rl24(s->pb) != MKTAG('M', 'P', '+', 0)){
av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
return -1;
}
- c->ver = get_byte(s->pb);
+ c->ver = avio_r8(s->pb);
if(c->ver != 0x07 && c->ver != 0x17){
av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver);
return -1;
}
- c->fcount = get_le32(s->pb);
+ c->fcount = avio_rl32(s->pb);
if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){
av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n");
return -1;
st->codec->extradata_size = 16;
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(s->pb, st->codec->extradata, 16);
+ avio_read(s->pb, st->codec->extradata, 16);
st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3];
av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate);
/* scan for seekpoints */
c->curframe++;
curbits = c->curbits;
pos = url_ftell(s->pb);
- tmp = get_le32(s->pb);
+ tmp = avio_rl32(s->pb);
if(curbits <= 12){
size2 = (tmp >> (12 - curbits)) & 0xFFFFF;
}else{
- tmp = (tmp << 32) | get_le32(s->pb);
+ tmp = (tmp << 32) | avio_rl32(s->pb);
size2 = (tmp >> (44 - curbits)) & 0xFFFFF;
}
curbits += 20;
pkt->stream_index = 0;
pkt->pts = cur;
- ret = get_buffer(s->pb, pkt->data + 4, size);
+ ret = avio_read(s->pb, pkt->data + 4, size);
if(c->curbits)
url_fseek(s->pb, -4, SEEK_CUR);
if(ret < size){
{
int64_t pos;
pos = url_ftell(pb);
- *tag = get_le16(pb);
+ *tag = avio_rl16(pb);
*size = ff_get_v(pb);
*size -= url_ftell(pb) - pos;
}
}
if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE)))
return;
- get_buffer(s->pb, buf, size);
+ avio_read(s->pb, buf, size);
init_get_bits(&gb, buf, size * 8);
size = gb_get_v(&gb);
if(size > UINT_MAX/4 || size > c->samples/1152){
int64_t size, pos;
c->header_pos = url_ftell(pb);
- if(get_le32(pb) != TAG_MPCK){
+ if(avio_rl32(pb) != TAG_MPCK){
av_log(s, AV_LOG_ERROR, "Not a Musepack8 file\n");
return -1;
}
}
pos = url_ftell(pb);
url_fskip(pb, 4); //CRC
- c->ver = get_byte(pb);
+ c->ver = avio_r8(pb);
if(c->ver != 8){
av_log(s, AV_LOG_ERROR, "Unknown stream version %d\n", c->ver);
return -1;
st->codec->extradata_size = 2;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codec->extradata, st->codec->extradata_size);
st->codec->channels = (st->codec->extradata[1] >> 4) + 1;
st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5];
m->sofdec = -1;
do {
- v = get_byte(s->pb);
+ v = avio_r8(s->pb);
m->header_state = m->header_state << 8 | v;
m->sofdec++;
} while (v == sofdec[i] && i++ < 6);
{
uint8_t buf[5];
- buf[0] = c<0 ? get_byte(pb) : c;
- get_buffer(pb, buf+1, 4);
+ buf[0] = c<0 ? avio_r8(pb) : c;
+ avio_read(pb, buf+1, 4);
return ff_parse_pes_pts(buf);
}
while (n > 0) {
if (url_feof(pb))
break;
- v = get_byte(pb);
+ v = avio_r8(pb);
n--;
if (state == 0x000001) {
state = ((state << 8) | v) & 0xffffff;
if (pos < 0)
pos = 0;
url_fseek(pb, pos, SEEK_SET);
- get_byte(pb);
+ avio_r8(pb);
pos = pos_start;
for(;;) {
goto the_end;
}
url_fseek(pb, pos, SEEK_SET);
- start_code = get_be32(pb);
+ start_code = avio_rb32(pb);
if ((start_code & 0xffffff00) == 0x100)
break;
}
{
int psm_length, ps_info_length, es_map_length;
- psm_length = get_be16(pb);
- get_byte(pb);
- get_byte(pb);
- ps_info_length = get_be16(pb);
+ psm_length = avio_rb16(pb);
+ avio_r8(pb);
+ avio_r8(pb);
+ ps_info_length = avio_rb16(pb);
/* skip program_stream_info */
url_fskip(pb, ps_info_length);
- es_map_length = get_be16(pb);
+ es_map_length = avio_rb16(pb);
/* at least one es available? */
while (es_map_length >= 4){
- unsigned char type = get_byte(pb);
- unsigned char es_id = get_byte(pb);
- uint16_t es_info_length = get_be16(pb);
+ unsigned char type = avio_r8(pb);
+ unsigned char es_id = avio_r8(pb);
+ uint16_t es_info_length = avio_rb16(pb);
/* remember mapping from stream id to stream type */
m->psm_es_type[es_id] = type;
/* skip program_stream_info */
url_fskip(pb, es_info_length);
es_map_length -= 4 + es_info_length;
}
- get_be32(pb); /* crc32 */
+ avio_rb32(pb); /* crc32 */
return 2 + psm_length;
}
if (startcode == SYSTEM_HEADER_START_CODE)
goto redo;
if (startcode == PADDING_STREAM) {
- url_fskip(s->pb, get_be16(s->pb));
+ url_fskip(s->pb, avio_rb16(s->pb));
goto redo;
}
if (startcode == PRIVATE_STREAM_2) {
- len = get_be16(s->pb);
+ len = avio_rb16(s->pb);
if (!m->sofdec) {
while (len-- >= 6) {
- if (get_byte(s->pb) == 'S') {
+ if (avio_r8(s->pb) == 'S') {
uint8_t buf[5];
- get_buffer(s->pb, buf, sizeof(buf));
+ avio_read(s->pb, buf, sizeof(buf));
m->sofdec = !memcmp(buf, "ofdec", 5);
len -= sizeof(buf);
break;
if (ppos) {
*ppos = url_ftell(s->pb) - 4;
}
- len = get_be16(s->pb);
+ len = avio_rb16(s->pb);
pts =
dts = AV_NOPTS_VALUE;
/* stuffing */
for(;;) {
if (len < 1)
goto error_redo;
- c = get_byte(s->pb);
+ c = avio_r8(s->pb);
len--;
/* XXX: for mpeg1, should test only bit 7 */
if (c != 0xff)
}
if ((c & 0xc0) == 0x40) {
/* buffer scale & size */
- get_byte(s->pb);
- c = get_byte(s->pb);
+ avio_r8(s->pb);
+ c = avio_r8(s->pb);
len -= 2;
}
if ((c & 0xe0) == 0x20) {
goto redo;
}
#endif
- flags = get_byte(s->pb);
- header_len = get_byte(s->pb);
+ flags = avio_r8(s->pb);
+ header_len = avio_r8(s->pb);
len -= 2;
if (header_len > len)
goto error_redo;
av_log(s, AV_LOG_WARNING, "Further flags set but no bytes left\n");
}
if (flags & 0x01) { /* PES extension */
- pes_ext = get_byte(s->pb);
+ pes_ext = avio_r8(s->pb);
header_len--;
/* Skip PES private data, program packet sequence counter and P-STD buffer */
skip = (pes_ext >> 4) & 0xb;
header_len -= skip;
if (pes_ext & 0x01) { /* PES extension 2 */
- ext2_len = get_byte(s->pb);
+ ext2_len = avio_r8(s->pb);
header_len--;
if ((ext2_len & 0x7f) > 0) {
- id_ext = get_byte(s->pb);
+ id_ext = avio_r8(s->pb);
if ((id_ext & 0x80) == 0)
startcode = ((startcode & 0xff) << 8) | id_ext;
header_len--;
goto redo;
if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
- startcode = get_byte(s->pb);
+ startcode = avio_r8(s->pb);
len--;
if (startcode >= 0x80 && startcode <= 0xcf) {
/* audio: skip header */
- get_byte(s->pb);
- get_byte(s->pb);
- get_byte(s->pb);
+ avio_r8(s->pb);
+ avio_r8(s->pb);
+ avio_r8(s->pb);
len -= 3;
if (startcode >= 0xb0 && startcode <= 0xbf) {
/* MLP/TrueHD audio has a 4-byte header */
- get_byte(s->pb);
+ avio_r8(s->pb);
len--;
}
}
return len;
if(startcode == 0x1bd) {
- dvdaudio_substream_type = get_byte(s->pb);
+ dvdaudio_substream_type = avio_r8(s->pb);
url_fskip(s->pb, 3);
len -= 4;
}
} else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
unsigned char buf[8];
- get_buffer(s->pb, buf, 8);
+ avio_read(s->pb, buf, 8);
url_fseek(s->pb, -8, SEEK_CUR);
if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
codec_id = CODEC_ID_CAVS;
audio data */
if (len <= 3)
goto skip;
- get_byte(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
- b1 = get_byte(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
- get_byte(s->pb); /* dynamic range control (0x80 = off) */
+ avio_r8(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
+ b1 = avio_r8(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
+ avio_r8(s->pb); /* dynamic range control (0x80 = off) */
len -= 3;
freq = (b1 >> 4) & 3;
st->codec->sample_rate = lpcm_freq_tab[freq];
return AVERROR(EINVAL);
}
av_new_packet(pkt, len);
- get_buffer(s->pb, pkt->data, pkt->size);
+ avio_read(s->pb, pkt->data, pkt->size);
pkt->pts = pts;
pkt->dts = dts;
pkt->pos = dummy_pos;
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4IODescrTag) {
- get_be16(&pb); // ID
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
- get_byte(&pb);
+ avio_rb16(&pb); // ID
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
+ avio_r8(&pb);
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4ESDescrTag) {
- *es_id = get_be16(&pb); /* ES_ID */
+ *es_id = avio_rb16(&pb); /* ES_ID */
av_dlog(s, "ES_ID %#x\n", *es_id);
- get_byte(&pb); /* priority */
+ avio_r8(&pb); /* priority */
len = ff_mp4_read_descr(s, &pb, &tag);
if (tag == MP4DecConfigDescrTag) {
*dec_config_descr = av_malloc(len);
if (!*dec_config_descr)
return AVERROR(ENOMEM);
*dec_config_descr_size = len;
- get_buffer(&pb, *dec_config_descr, len);
+ avio_read(&pb, *dec_config_descr, len);
}
}
}
int skip, len;
for(;;) {
- len = get_buffer(pb, buf, TS_PACKET_SIZE);
+ len = avio_read(pb, buf, TS_PACKET_SIZE);
if (len != TS_PACKET_SIZE)
return AVERROR(EIO);
/* check paquet sync byte */
/* read the first 1024 bytes to get packet size */
pos = url_ftell(pb);
- len = get_buffer(pb, buf, sizeof(buf));
+ len = avio_read(pb, buf, sizeof(buf));
if (len != sizeof(buf))
goto fail;
ts->raw_packet_size = get_packet_size(buf, sizeof(buf));
pos = url_ftell(s->pb);
for(i = 0; i < MAX_PACKET_READAHEAD; i++) {
url_fseek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
- get_buffer(s->pb, pcr_buf, 12);
+ avio_read(s->pb, pcr_buf, 12);
if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
/* XXX: not precise enough */
ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) /
if (find_next) {
for(;;) {
url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return AV_NOPTS_VALUE;
if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
parse_pcr(×tamp, &pcr_l, buf) == 0) {
if (pos < 0)
return AV_NOPTS_VALUE;
url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return AV_NOPTS_VALUE;
if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
parse_pcr(×tamp, &pcr_l, buf) == 0) {
for(;;) {
url_fseek(s->pb, pos, SEEK_SET);
- if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
+ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return -1;
// pid = AV_RB16(buf + 1) & 0x1fff;
if(buf[1] & 0x40) break;
/* Some files start with "connected\r\n\r\n".
* So skip until we find the first byte of struct size */
- while(get_byte(pb) != HEADER_SIZE && !url_feof(pb));
+ while(avio_r8(pb) != HEADER_SIZE && !url_feof(pb));
if(url_feof(pb)) {
av_log(ctx, AV_LOG_ERROR, "Could not find valid start.");
url_fskip(pb, 1); /* one byte has been read ahead */
url_fskip(pb, 2);
url_fskip(pb, 2);
- keyframe = get_le16(pb);
- size = get_le32(pb);
+ keyframe = avio_rl16(pb);
+ size = avio_rl32(pb);
url_fskip(pb, 4);
url_fskip(pb, 4);
- timestamp = get_le32(pb);
+ timestamp = avio_rl32(pb);
if(!size || av_get_packet(pb, pkt, size) != size)
return -1;
unsigned int audio_subsegments;
url_fskip(pb, 3);
- mtv->file_size = get_le32(pb);
- mtv->segments = get_le32(pb);
+ mtv->file_size = avio_rl32(pb);
+ mtv->segments = avio_rl32(pb);
url_fskip(pb, 32);
- mtv->audio_identifier = get_le24(pb);
- mtv->audio_br = get_le16(pb);
- mtv->img_colorfmt = get_le24(pb);
- mtv->img_bpp = get_byte(pb);
- mtv->img_width = get_le16(pb);
- mtv->img_height = get_le16(pb);
- mtv->img_segment_size = get_le16(pb);
+ mtv->audio_identifier = avio_rl24(pb);
+ mtv->audio_br = avio_rl16(pb);
+ mtv->img_colorfmt = avio_rl24(pb);
+ mtv->img_bpp = avio_r8(pb);
+ mtv->img_width = avio_rl16(pb);
+ mtv->img_height = avio_rl16(pb);
+ mtv->img_segment_size = avio_rl16(pb);
/* Calculate width and height if missing from header */
/ mtv->img_width;
url_fskip(pb, 4);
- audio_subsegments = get_le16(pb);
+ audio_subsegments = avio_rl16(pb);
mtv->full_segment_size =
audio_subsegments * (MTV_AUDIO_PADDING_SIZE + MTV_ASUBCHUNK_DATA_SIZE) +
mtv->img_segment_size;
vst->codec->extradata_size = 2;
vst->codec->extradata = av_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE);
- version = get_byte(pb);
- vst->codec->extradata[0] = get_byte(pb);
- vst->codec->extradata[1] = get_byte(pb);
- frames_count = get_le32(pb);
- msecs_per_frame = get_le32(pb);
- vst->codec->width = get_le16(pb);
- vst->codec->height = get_le16(pb);
- get_byte(pb);
- ast->codec->sample_rate = get_le16(pb);
- mvi->audio_data_size = get_le32(pb);
- get_byte(pb);
- player_version = get_le32(pb);
- get_le16(pb);
- get_byte(pb);
+ version = avio_r8(pb);
+ vst->codec->extradata[0] = avio_r8(pb);
+ vst->codec->extradata[1] = avio_r8(pb);
+ frames_count = avio_rl32(pb);
+ msecs_per_frame = avio_rl32(pb);
+ vst->codec->width = avio_rl16(pb);
+ vst->codec->height = avio_rl16(pb);
+ avio_r8(pb);
+ ast->codec->sample_rate = avio_rl16(pb);
+ mvi->audio_data_size = avio_rl32(pb);
+ avio_r8(pb);
+ player_version = avio_rl32(pb);
+ avio_rl16(pb);
+ avio_r8(pb);
if (frames_count == 0 || mvi->audio_data_size == 0)
return AVERROR_INVALIDDATA;
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = CODEC_ID_MOTIONPIXELS;
- mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? get_le16 : get_le24;
+ mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? avio_rl16 : avio_rl24;
mvi->audio_frame_size = ((uint64_t)mvi->audio_data_size << MVI_FRAC_BITS) / frames_count;
mvi->audio_size_counter = (ast->codec->sample_rate * 830 / mvi->audio_frame_size - 1) * mvi->audio_frame_size;
static int64_t klv_decode_ber_length(AVIOContext *pb)
{
- uint64_t size = get_byte(pb);
+ uint64_t size = avio_r8(pb);
if (size & 0x80) { /* long form */
int bytes_num = size & 0x7f;
/* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
return -1;
size = 0;
while (bytes_num--)
- size = size << 8 | get_byte(pb);
+ size = size << 8 | avio_r8(pb);
}
return size;
}
{
int i, b;
for (i = 0; i < size && !url_feof(pb); i++) {
- b = get_byte(pb);
+ b = avio_r8(pb);
if (b == key[0])
i = 0;
else if (b != key[i])
return -1;
klv->offset = url_ftell(pb) - 4;
memcpy(klv->key, mxf_klv_key, 4);
- get_buffer(pb, klv->key + 4, 12);
+ avio_read(pb, klv->key + 4, 12);
klv->length = klv_decode_ber_length(pb);
return klv->length == -1 ? -1 : 0;
}
if (length > 61444) /* worst case PAL 1920 samples 8 channels */
return -1;
av_new_packet(pkt, length);
- get_buffer(pb, pkt->data, length);
+ avio_read(pb, pkt->data, length);
data_ptr = pkt->data;
end_ptr = pkt->data + length;
buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
url_fskip(pb, klv_decode_ber_length(pb));
// plaintext offset
klv_decode_ber_length(pb);
- plaintext_size = get_be64(pb);
+ plaintext_size = avio_rb64(pb);
// source klv key
klv_decode_ber_length(pb);
- get_buffer(pb, klv->key, 16);
+ avio_read(pb, klv->key, 16);
if (!IS_KLV_KEY(klv, mxf_essence_element_key))
return -1;
index = mxf_get_stream_index(s, klv);
return -1;
// source size
klv_decode_ber_length(pb);
- orig_size = get_be64(pb);
+ orig_size = avio_rb64(pb);
if (orig_size < plaintext_size)
return -1;
// enc. code
size = klv_decode_ber_length(pb);
if (size < 32 || size - 32 < orig_size)
return -1;
- get_buffer(pb, ivec, 16);
- get_buffer(pb, tmpbuf, 16);
+ avio_read(pb, ivec, 16);
+ avio_read(pb, tmpbuf, 16);
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
if (memcmp(tmpbuf, checkv, 16))
static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFContext *mxf = arg;
- int item_num = get_be32(pb);
- int item_len = get_be32(pb);
+ int item_num = avio_rb32(pb);
+ int item_len = avio_rb32(pb);
if (item_len != 18) {
av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n");
mxf->local_tags = av_malloc(item_num*item_len);
if (!mxf->local_tags)
return -1;
- get_buffer(pb, mxf->local_tags, item_num*item_len);
+ avio_read(pb, mxf->local_tags, item_num*item_len);
return 0;
}
if (size != 16)
return -1;
if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul))
- get_buffer(pb, cryptocontext->source_container_ul, 16);
+ avio_read(pb, cryptocontext->source_container_ul, 16);
return 0;
}
MXFContext *mxf = arg;
switch (tag) {
case 0x1901:
- mxf->packages_count = get_be32(pb);
+ mxf->packages_count = avio_rb32(pb);
if (mxf->packages_count >= UINT_MAX / sizeof(UID))
return -1;
mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID));
if (!mxf->packages_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
break;
}
return 0;
MXFStructuralComponent *source_clip = arg;
switch(tag) {
case 0x0202:
- source_clip->duration = get_be64(pb);
+ source_clip->duration = avio_rb64(pb);
break;
case 0x1201:
- source_clip->start_position = get_be64(pb);
+ source_clip->start_position = avio_rb64(pb);
break;
case 0x1101:
/* UMID, only get last 16 bytes */
url_fskip(pb, 16);
- get_buffer(pb, source_clip->source_package_uid, 16);
+ avio_read(pb, source_clip->source_package_uid, 16);
break;
case 0x1102:
- source_clip->source_track_id = get_be32(pb);
+ source_clip->source_track_id = avio_rb32(pb);
break;
}
return 0;
MXFPackage *package = arg;
switch(tag) {
case 0x4403:
- package->tracks_count = get_be32(pb);
+ package->tracks_count = avio_rb32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
}
return 0;
MXFTrack *track = arg;
switch(tag) {
case 0x4801:
- track->track_id = get_be32(pb);
+ track->track_id = avio_rb32(pb);
break;
case 0x4804:
- get_buffer(pb, track->track_number, 4);
+ avio_read(pb, track->track_number, 4);
break;
case 0x4B01:
- track->edit_rate.den = get_be32(pb);
- track->edit_rate.num = get_be32(pb);
+ track->edit_rate.den = avio_rb32(pb);
+ track->edit_rate.num = avio_rb32(pb);
break;
case 0x4803:
- get_buffer(pb, track->sequence_ref, 16);
+ avio_read(pb, track->sequence_ref, 16);
break;
}
return 0;
MXFSequence *sequence = arg;
switch(tag) {
case 0x0202:
- sequence->duration = get_be64(pb);
+ sequence->duration = avio_rb64(pb);
break;
case 0x0201:
- get_buffer(pb, sequence->data_definition_ul, 16);
+ avio_read(pb, sequence->data_definition_ul, 16);
break;
case 0x1001:
- sequence->structural_components_count = get_be32(pb);
+ sequence->structural_components_count = avio_rb32(pb);
if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
return -1;
sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
if (!sequence->structural_components_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
break;
}
return 0;
MXFPackage *package = arg;
switch(tag) {
case 0x4403:
- package->tracks_count = get_be32(pb);
+ package->tracks_count = avio_rb32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
case 0x4401:
/* UMID, only get last 16 bytes */
url_fskip(pb, 16);
- get_buffer(pb, package->package_uid, 16);
+ avio_read(pb, package->package_uid, 16);
break;
case 0x4701:
- get_buffer(pb, package->descriptor_ref, 16);
+ avio_read(pb, package->descriptor_ref, 16);
break;
}
return 0;
static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
switch(tag) {
- case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break;
- case 0x3F06: av_dlog(NULL, "IndexSID %d\n", get_be32(pb)); break;
- case 0x3F07: av_dlog(NULL, "BodySID %d\n", get_be32(pb)); break;
- case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", get_be32(pb), get_be32(pb)); break;
- case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", get_be64(pb)); break;
- case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", get_be64(pb)); break;
+ case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", avio_rb32(pb)); break;
+ case 0x3F06: av_dlog(NULL, "IndexSID %d\n", avio_rb32(pb)); break;
+ case 0x3F07: av_dlog(NULL, "BodySID %d\n", avio_rb32(pb)); break;
+ case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", avio_rb32(pb), avio_rb32(pb)); break;
+ case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", avio_rb64(pb)); break;
+ case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", avio_rb64(pb)); break;
}
return 0;
}
char layout[16] = {0};
do {
- code = get_byte(pb);
- value = get_byte(pb);
+ code = avio_r8(pb);
+ value = avio_r8(pb);
av_dlog(NULL, "pixel layout: code %#x\n", code);
if (ofs < 16) {
MXFDescriptor *descriptor = arg;
switch(tag) {
case 0x3F01:
- descriptor->sub_descriptors_count = get_be32(pb);
+ descriptor->sub_descriptors_count = avio_rb32(pb);
if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
return -1;
descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
if (!descriptor->sub_descriptors_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
+ avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
break;
case 0x3004:
- get_buffer(pb, descriptor->essence_container_ul, 16);
+ avio_read(pb, descriptor->essence_container_ul, 16);
break;
case 0x3006:
- descriptor->linked_track_id = get_be32(pb);
+ descriptor->linked_track_id = avio_rb32(pb);
break;
case 0x3201: /* PictureEssenceCoding */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
+ avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3203:
- descriptor->width = get_be32(pb);
+ descriptor->width = avio_rb32(pb);
break;
case 0x3202:
- descriptor->height = get_be32(pb);
+ descriptor->height = avio_rb32(pb);
break;
case 0x320E:
- descriptor->aspect_ratio.num = get_be32(pb);
- descriptor->aspect_ratio.den = get_be32(pb);
+ descriptor->aspect_ratio.num = avio_rb32(pb);
+ descriptor->aspect_ratio.den = avio_rb32(pb);
break;
case 0x3D03:
- descriptor->sample_rate.num = get_be32(pb);
- descriptor->sample_rate.den = get_be32(pb);
+ descriptor->sample_rate.num = avio_rb32(pb);
+ descriptor->sample_rate.den = avio_rb32(pb);
break;
case 0x3D06: /* SoundEssenceCompression */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
+ avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3D07:
- descriptor->channels = get_be32(pb);
+ descriptor->channels = avio_rb32(pb);
break;
case 0x3D01:
- descriptor->bits_per_sample = get_be32(pb);
+ descriptor->bits_per_sample = avio_rb32(pb);
break;
case 0x3401:
mxf_read_pixel_layout(pb, descriptor);
if (!descriptor->extradata)
return -1;
descriptor->extradata_size = size;
- get_buffer(pb, descriptor->extradata, size);
+ avio_read(pb, descriptor->extradata, size);
}
break;
}
if (!ctx)
return -1;
while (url_ftell(pb) + 4 < klv_end) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
+ int tag = avio_rb16(pb);
+ int size = avio_rb16(pb); /* KLV specified by 0x53 */
uint64_t next = url_ftell(pb) + size;
UID uid = {0};
}
}
if (ctx_size && tag == 0x3C0A)
- get_buffer(pb, ctx->uid, 16);
+ avio_read(pb, ctx->uid, 16);
else if (read_child(ctx, pb, tag, size, uid) < 0)
return -1;
if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + soi_pos;
/* get data */
- ret = get_buffer(s->pb, mxg->buffer_ptr + mxg->cache_size,
+ ret = avio_read(s->pb, mxg->buffer_ptr + mxg->cache_size,
cache_size - mxg->cache_size);
if (ret < 0)
return ret;
while (state != NC_VIDEO_FLAG) {
if (url_feof(s->pb))
return AVERROR(EIO);
- state = (state<<8) + get_byte(s->pb);
+ state = (state<<8) + avio_r8(s->pb);
}
- get_byte(s->pb);
- size = get_le16(s->pb);
+ avio_r8(s->pb);
+ size = avio_rl16(s->pb);
url_fskip(s->pb, 9);
if (size == 0) {
return -1;
}
v <<= 8;
- v |= get_byte(pb);
+ v |= avio_r8(pb);
if (i < 8) {
av_dlog(s, "NSV resync: [%d] = %02x\n", i, v & 0x0FF);
}
nsv->state = NSV_UNSYNC; /* in case we fail */
- size = get_le32(pb);
+ size = avio_rl32(pb);
if (size < 28)
return -1;
nsv->NSVf_end = size;
- //s->file_size = (uint32_t)get_le32(pb);
- file_size = (uint32_t)get_le32(pb);
+ //s->file_size = (uint32_t)avio_rl32(pb);
+ file_size = (uint32_t)avio_rl32(pb);
av_dlog(s, "NSV NSVf chunk_size %u\n", size);
av_dlog(s, "NSV NSVf file_size %u\n", file_size);
- nsv->duration = duration = get_le32(pb); /* in ms */
+ nsv->duration = duration = avio_rl32(pb); /* in ms */
av_dlog(s, "NSV NSVf duration %"PRId64" ms\n", duration);
// XXX: store it in AVStreams
- strings_size = get_le32(pb);
- table_entries = get_le32(pb);
- table_entries_used = get_le32(pb);
+ strings_size = avio_rl32(pb);
+ table_entries = avio_rl32(pb);
+ table_entries_used = avio_rl32(pb);
av_dlog(s, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
strings_size, table_entries, table_entries_used);
if (url_feof(pb))
p = strings = av_mallocz(strings_size + 1);
endp = strings + strings_size;
- get_buffer(pb, strings, strings_size);
+ avio_read(pb, strings, strings_size);
while (p < endp) {
while (*p == ' ')
p++; /* strip out spaces */
nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t));
for(i=0;i<table_entries_used;i++)
- nsv->nsvs_file_offset[i] = get_le32(pb) + size;
+ nsv->nsvs_file_offset[i] = avio_rl32(pb) + size;
if(table_entries > table_entries_used &&
- get_le32(pb) == MKTAG('T','O','C','2')) {
+ avio_rl32(pb) == MKTAG('T','O','C','2')) {
nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t));
for(i=0;i<table_entries_used;i++) {
- nsv->nsvs_timestamps[i] = get_le32(pb);
+ nsv->nsvs_timestamps[i] = avio_rl32(pb);
}
}
}
for (i = 0; i < table_entries; i++) {
unsigned char b[8];
url_fseek(pb, size + nsv->nsvs_file_offset[i], SEEK_SET);
- get_buffer(pb, b, 8);
+ avio_read(pb, b, 8);
av_dlog(s, "NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x"
"%c%c%c%c%c%c%c%c\n",
nsv->nsvs_file_offset[i], size + nsv->nsvs_file_offset[i],
NSVStream *nst;
av_dlog(s, "%s()\n", __FUNCTION__);
- vtag = get_le32(pb);
- atag = get_le32(pb);
- vwidth = get_le16(pb);
- vheight = get_le16(pb);
- i = get_byte(pb);
+ vtag = avio_rl32(pb);
+ atag = avio_rl32(pb);
+ vwidth = avio_rl16(pb);
+ vheight = avio_rl16(pb);
+ i = avio_r8(pb);
av_dlog(s, "NSV NSVs framerate code %2x\n", i);
if(i&0x80) { /* odd way of giving native framerates from docs */
else
framerate= (AVRational){i, 1};
- nsv->avsync = get_le16(pb);
+ nsv->avsync = avio_rl16(pb);
nsv->framerate = framerate;
print_tag("NSV NSVs vtag", vtag, 0);
if (nsv->state != NSV_HAS_READ_NSVS && nsv->state != NSV_FOUND_BEEF)
return -1;
- auxcount = get_byte(pb);
- vsize = get_le16(pb);
- asize = get_le16(pb);
+ auxcount = avio_r8(pb);
+ vsize = avio_rl16(pb);
+ asize = avio_rl16(pb);
vsize = (vsize << 4) | (auxcount >> 4);
auxcount &= 0x0f;
av_dlog(s, "NSV CHUNK %d aux, %u bytes video, %d bytes audio\n", auxcount, vsize, asize);
/* skip aux stuff */
for (i = 0; i < auxcount; i++) {
- auxsize = get_le16(pb);
- auxtag = get_le32(pb);
+ auxsize = avio_rl16(pb);
+ auxtag = avio_rl32(pb);
av_dlog(s, "NSV aux data: '%c%c%c%c', %d bytes\n",
(auxtag & 0x0ff),
((auxtag >> 8) & 0x0ff),
uint8_t bps;
uint8_t channels;
uint16_t samplerate;
- bps = get_byte(pb);
- channels = get_byte(pb);
- samplerate = get_le16(pb);
+ bps = avio_r8(pb);
+ channels = avio_r8(pb);
+ samplerate = avio_rl16(pb);
asize-=4;
av_dlog(s, "NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
if (fill_header) {
unsigned int len= ff_get_v(bc);
if(len && maxlen)
- get_buffer(bc, string, FFMIN(len, maxlen));
+ avio_read(bc, string, FFMIN(len, maxlen));
while(len > maxlen){
- get_byte(bc);
+ avio_r8(bc);
len--;
}
static uint64_t get_fourcc(AVIOContext *bc){
unsigned int len= ff_get_v(bc);
- if (len==2) return get_le16(bc);
- else if(len==4) return get_le32(bc);
+ if (len==2) return avio_rl16(bc);
+ else if(len==4) return avio_rl32(bc);
else return -1;
}
init_checksum(bc, ff_crc04C11DB7_update, startcode);
size= ff_get_v(bc);
if(size > 4096)
- get_be32(bc);
+ avio_rb32(bc);
if(get_checksum(bc) && size > 4096)
return -1;
url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we currently are
while(!url_feof(bc)){
- state= (state<<8) | get_byte(bc);
+ state= (state<<8) | avio_r8(bc);
if((state>>56) != 'N')
continue;
switch(state){
return -1;
}else{
while(pos--)
- get_byte(bc);
+ avio_r8(bc);
return 0;
}
}
return AVERROR_INVALIDDATA;
}
nut->header[i]= av_malloc(nut->header_len[i]);
- get_buffer(bc, nut->header[i], nut->header_len[i]);
+ avio_read(bc, nut->header[i], nut->header_len[i]);
}
assert(nut->header_len[0]==0);
}
GET_V(st->codec->extradata_size, tmp < (1<<30));
if(st->codec->extradata_size){
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- get_buffer(bc, st->codec->extradata, st->codec->extradata_size);
+ avio_read(bc, st->codec->extradata, st->codec->extradata_size);
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
int ret= -1;
url_fseek(bc, filesize-12, SEEK_SET);
- url_fseek(bc, filesize-get_be64(bc), SEEK_SET);
- if(get_be64(bc) != INDEX_STARTCODE){
+ url_fseek(bc, filesize-avio_rb64(bc), SEEK_SET);
+ if(avio_rb64(bc) != INDEX_STARTCODE){
av_log(s, AV_LOG_ERROR, "no index at the end\n");
return -1;
}
size -= nut->header_len[*header_idx];
if(flags&FLAG_CHECKSUM){
- get_be32(bc); //FIXME check this
+ avio_rb32(bc); //FIXME check this
}else if(size > 2*nut->max_distance || FFABS(stc->last_pts - *pts) > stc->max_pts_distance){
av_log(s, AV_LOG_ERROR, "frame size > 2max_distance and no checksum\n");
return AVERROR_INVALIDDATA;