diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-02-21 16:43:01 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-02-22 02:44:37 +0100 |
commit | e63a362857d9807b23e65872598d782fa53bb6af (patch) | |
tree | 7a21287e54bfbd2ec9c45bcb5a22e441e4992f2b /libavformat/mxfdec.c | |
parent | 6a786b15c34765ec00be3cd808dafbb041fd5881 (diff) | |
download | ffmpeg-e63a362857d9807b23e65872598d782fa53bb6af.tar.gz |
avio: avio_ prefixes for get_* functions
In the name of consistency:
get_byte -> avio_r8
get_<type> -> avio_r<type>
get_buffer -> avio_read
get_partial_buffer will be made private later
get_strz is left out becase I want to change it later to return
something useful.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit b7effd4e8338f6ed5bda630ad7ed0809bf458648)
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r-- | libavformat/mxfdec.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 6246fca0aa..9f694e30ff 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -163,7 +163,7 @@ static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x static int64_t klv_decode_ber_length(AVIOContext *pb) { - uint64_t size = get_byte(pb); + uint64_t size = avio_r8(pb); if (size & 0x80) { /* long form */ int bytes_num = size & 0x7f; /* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */ @@ -171,7 +171,7 @@ static int64_t klv_decode_ber_length(AVIOContext *pb) return -1; size = 0; while (bytes_num--) - size = size << 8 | get_byte(pb); + size = size << 8 | avio_r8(pb); } return size; } @@ -180,7 +180,7 @@ static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size) { int i, b; for (i = 0; i < size && !url_feof(pb); i++) { - b = get_byte(pb); + b = avio_r8(pb); if (b == key[0]) i = 0; else if (b != key[i]) @@ -195,7 +195,7 @@ static int klv_read_packet(KLVPacket *klv, AVIOContext *pb) return -1; klv->offset = url_ftell(pb) - 4; memcpy(klv->key, mxf_klv_key, 4); - get_buffer(pb, klv->key + 4, 12); + avio_read(pb, klv->key + 4, 12); klv->length = klv_decode_ber_length(pb); return klv->length == -1 ? -1 : 0; } @@ -224,7 +224,7 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt, if (length > 61444) /* worst case PAL 1920 samples 8 channels */ return -1; av_new_packet(pkt, length); - get_buffer(pb, pkt->data, length); + avio_read(pb, pkt->data, length); data_ptr = pkt->data; end_ptr = pkt->data + length; buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */ @@ -265,10 +265,10 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv url_fskip(pb, klv_decode_ber_length(pb)); // plaintext offset klv_decode_ber_length(pb); - plaintext_size = get_be64(pb); + plaintext_size = avio_rb64(pb); // source klv key klv_decode_ber_length(pb); - get_buffer(pb, klv->key, 16); + avio_read(pb, klv->key, 16); if (!IS_KLV_KEY(klv, mxf_essence_element_key)) return -1; index = mxf_get_stream_index(s, klv); @@ -276,15 +276,15 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv return -1; // source size klv_decode_ber_length(pb); - orig_size = get_be64(pb); + orig_size = avio_rb64(pb); if (orig_size < plaintext_size) return -1; // enc. code size = klv_decode_ber_length(pb); if (size < 32 || size - 32 < orig_size) return -1; - get_buffer(pb, ivec, 16); - get_buffer(pb, tmpbuf, 16); + avio_read(pb, ivec, 16); + avio_read(pb, tmpbuf, 16); if (mxf->aesc) av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1); if (memcmp(tmpbuf, checkv, 16)) @@ -347,8 +347,8 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt) static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFContext *mxf = arg; - int item_num = get_be32(pb); - int item_len = get_be32(pb); + int item_num = avio_rb32(pb); + int item_len = avio_rb32(pb); if (item_len != 18) { av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n"); @@ -360,7 +360,7 @@ static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, U mxf->local_tags = av_malloc(item_num*item_len); if (!mxf->local_tags) return -1; - get_buffer(pb, mxf->local_tags, item_num*item_len); + avio_read(pb, mxf->local_tags, item_num*item_len); return 0; } @@ -382,7 +382,7 @@ static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, i if (size != 16) return -1; if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul)) - get_buffer(pb, cryptocontext->source_container_ul, 16); + avio_read(pb, cryptocontext->source_container_ul, 16); return 0; } @@ -391,14 +391,14 @@ static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int siz MXFContext *mxf = arg; switch (tag) { case 0x1901: - mxf->packages_count = get_be32(pb); + mxf->packages_count = avio_rb32(pb); if (mxf->packages_count >= UINT_MAX / sizeof(UID)) return -1; mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID)); if (!mxf->packages_refs) return -1; url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ - get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID)); + avio_read(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID)); break; } return 0; @@ -409,18 +409,18 @@ static int mxf_read_source_clip(void *arg, AVIOContext *pb, int tag, int size, U MXFStructuralComponent *source_clip = arg; switch(tag) { case 0x0202: - source_clip->duration = get_be64(pb); + source_clip->duration = avio_rb64(pb); break; case 0x1201: - source_clip->start_position = get_be64(pb); + source_clip->start_position = avio_rb64(pb); break; case 0x1101: /* UMID, only get last 16 bytes */ url_fskip(pb, 16); - get_buffer(pb, source_clip->source_package_uid, 16); + avio_read(pb, source_clip->source_package_uid, 16); break; case 0x1102: - source_clip->source_track_id = get_be32(pb); + source_clip->source_track_id = avio_rb32(pb); break; } return 0; @@ -431,14 +431,14 @@ static int mxf_read_material_package(void *arg, AVIOContext *pb, int tag, int si MXFPackage *package = arg; switch(tag) { case 0x4403: - package->tracks_count = get_be32(pb); + package->tracks_count = avio_rb32(pb); if (package->tracks_count >= UINT_MAX / sizeof(UID)) return -1; package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); if (!package->tracks_refs) return -1; url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ - get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); + avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); break; } return 0; @@ -449,17 +449,17 @@ static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid MXFTrack *track = arg; switch(tag) { case 0x4801: - track->track_id = get_be32(pb); + track->track_id = avio_rb32(pb); break; case 0x4804: - get_buffer(pb, track->track_number, 4); + avio_read(pb, track->track_number, 4); break; case 0x4B01: - track->edit_rate.den = get_be32(pb); - track->edit_rate.num = get_be32(pb); + track->edit_rate.den = avio_rb32(pb); + track->edit_rate.num = avio_rb32(pb); break; case 0x4803: - get_buffer(pb, track->sequence_ref, 16); + avio_read(pb, track->sequence_ref, 16); break; } return 0; @@ -470,20 +470,20 @@ static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID MXFSequence *sequence = arg; switch(tag) { case 0x0202: - sequence->duration = get_be64(pb); + sequence->duration = avio_rb64(pb); break; case 0x0201: - get_buffer(pb, sequence->data_definition_ul, 16); + avio_read(pb, sequence->data_definition_ul, 16); break; case 0x1001: - sequence->structural_components_count = get_be32(pb); + sequence->structural_components_count = avio_rb32(pb); if (sequence->structural_components_count >= UINT_MAX / sizeof(UID)) return -1; sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID)); if (!sequence->structural_components_refs) return -1; url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ - get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID)); + avio_read(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID)); break; } return 0; @@ -494,22 +494,22 @@ static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size MXFPackage *package = arg; switch(tag) { case 0x4403: - package->tracks_count = get_be32(pb); + package->tracks_count = avio_rb32(pb); if (package->tracks_count >= UINT_MAX / sizeof(UID)) return -1; package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); if (!package->tracks_refs) return -1; url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ - get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); + avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); break; case 0x4401: /* UMID, only get last 16 bytes */ url_fskip(pb, 16); - get_buffer(pb, package->package_uid, 16); + avio_read(pb, package->package_uid, 16); break; case 0x4701: - get_buffer(pb, package->descriptor_ref, 16); + avio_read(pb, package->descriptor_ref, 16); break; } return 0; @@ -518,12 +518,12 @@ static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid) { switch(tag) { - case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break; - case 0x3F06: av_dlog(NULL, "IndexSID %d\n", get_be32(pb)); break; - case 0x3F07: av_dlog(NULL, "BodySID %d\n", get_be32(pb)); break; - case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", get_be32(pb), get_be32(pb)); break; - case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", get_be64(pb)); break; - case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", get_be64(pb)); break; + case 0x3F05: av_dlog(NULL, "EditUnitByteCount %d\n", avio_rb32(pb)); break; + case 0x3F06: av_dlog(NULL, "IndexSID %d\n", avio_rb32(pb)); break; + case 0x3F07: av_dlog(NULL, "BodySID %d\n", avio_rb32(pb)); break; + case 0x3F0B: av_dlog(NULL, "IndexEditRate %d/%d\n", avio_rb32(pb), avio_rb32(pb)); break; + case 0x3F0C: av_dlog(NULL, "IndexStartPosition %lld\n", avio_rb64(pb)); break; + case 0x3F0D: av_dlog(NULL, "IndexDuration %lld\n", avio_rb64(pb)); break; } return 0; } @@ -534,8 +534,8 @@ static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor) char layout[16] = {0}; do { - code = get_byte(pb); - value = get_byte(pb); + code = avio_r8(pb); + value = avio_r8(pb); av_dlog(NULL, "pixel layout: code %#x\n", code); if (ofs < 16) { @@ -552,46 +552,46 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int MXFDescriptor *descriptor = arg; switch(tag) { case 0x3F01: - descriptor->sub_descriptors_count = get_be32(pb); + descriptor->sub_descriptors_count = avio_rb32(pb); if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID)) return -1; descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID)); if (!descriptor->sub_descriptors_refs) return -1; url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ - get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID)); + avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID)); break; case 0x3004: - get_buffer(pb, descriptor->essence_container_ul, 16); + avio_read(pb, descriptor->essence_container_ul, 16); break; case 0x3006: - descriptor->linked_track_id = get_be32(pb); + descriptor->linked_track_id = avio_rb32(pb); break; case 0x3201: /* PictureEssenceCoding */ - get_buffer(pb, descriptor->essence_codec_ul, 16); + avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3203: - descriptor->width = get_be32(pb); + descriptor->width = avio_rb32(pb); break; case 0x3202: - descriptor->height = get_be32(pb); + descriptor->height = avio_rb32(pb); break; case 0x320E: - descriptor->aspect_ratio.num = get_be32(pb); - descriptor->aspect_ratio.den = get_be32(pb); + descriptor->aspect_ratio.num = avio_rb32(pb); + descriptor->aspect_ratio.den = avio_rb32(pb); break; case 0x3D03: - descriptor->sample_rate.num = get_be32(pb); - descriptor->sample_rate.den = get_be32(pb); + descriptor->sample_rate.num = avio_rb32(pb); + descriptor->sample_rate.den = avio_rb32(pb); break; case 0x3D06: /* SoundEssenceCompression */ - get_buffer(pb, descriptor->essence_codec_ul, 16); + avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3D07: - descriptor->channels = get_be32(pb); + descriptor->channels = avio_rb32(pb); break; case 0x3D01: - descriptor->bits_per_sample = get_be32(pb); + descriptor->bits_per_sample = avio_rb32(pb); break; case 0x3401: mxf_read_pixel_layout(pb, descriptor); @@ -603,7 +603,7 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int if (!descriptor->extradata) return -1; descriptor->extradata_size = size; - get_buffer(pb, descriptor->extradata, size); + avio_read(pb, descriptor->extradata, size); } break; } @@ -871,8 +871,8 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF if (!ctx) return -1; while (url_ftell(pb) + 4 < klv_end) { - int tag = get_be16(pb); - int size = get_be16(pb); /* KLV specified by 0x53 */ + int tag = avio_rb16(pb); + int size = avio_rb16(pb); /* KLV specified by 0x53 */ uint64_t next = url_ftell(pb) + size; UID uid = {0}; @@ -893,7 +893,7 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF } } if (ctx_size && tag == 0x3C0A) - get_buffer(pb, ctx->uid, 16); + avio_read(pb, ctx->uid, 16); else if (read_child(ctx, pb, tag, size, uid) < 0) return -1; |