aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mxf.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2007-06-03 17:10:55 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2007-06-03 17:10:55 +0000
commitcabe2527ef37c6d5db7a63ebfa3a35294b9c099a (patch)
treef835852170952da24c50df90a2b69705c0db7059 /libavformat/mxf.c
parent6982462f50947e3ce71e734f3794f3140245e551 (diff)
downloadffmpeg-cabe2527ef37c6d5db7a63ebfa3a35294b9c099a.tar.gz
sync to mxf klv key before trying to read klv packet
Originally committed as revision 9185 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mxf.c')
-rw-r--r--libavformat/mxf.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index 5c361dcefc..7c24c15282 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -181,6 +181,7 @@ typedef struct MXFMetadataReadTableEntry {
/* partial keys to match */
static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
+static const uint8_t mxf_klv_key[] = { 0x06,0x0e,0x2b,0x34 };
/* complete keys to match */
static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
@@ -205,10 +206,26 @@ static int64_t klv_decode_ber_length(ByteIOContext *pb)
return size;
}
+static int mxf_read_sync(ByteIOContext *pb, const uint8_t *key, unsigned size)
+{
+ int i, b;
+ for (i = 0; i < size && !url_feof(pb); i++) {
+ b = get_byte(pb);
+ if (b == key[0])
+ i = 0;
+ else if (b != key[i])
+ i = -1;
+ }
+ return i == size;
+}
+
static int klv_read_packet(KLVPacket *klv, ByteIOContext *pb)
{
- klv->offset = url_ftell(pb);
- get_buffer(pb, klv->key, 16);
+ if (!mxf_read_sync(pb, mxf_klv_key, 4))
+ return -1;
+ klv->offset = url_ftell(pb) - 4;
+ memcpy(klv->key, mxf_klv_key, 4);
+ get_buffer(pb, klv->key + 4, 12);
klv->length = klv_decode_ber_length(pb);
return klv->length == -1 ? -1 : 0;
}
@@ -886,19 +903,6 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = {
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0, AnyType },
};
-static int mxf_read_sync(ByteIOContext *pb, const uint8_t *key, unsigned size)
-{
- int i, b;
- for (i = 0; i < size && !url_feof(pb); i++) {
- b = get_byte(pb);
- if (b == key[0])
- i = 0;
- else if (b != key[i])
- i = -1;
- }
- return i == size;
-}
-
static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type)
{
ByteIOContext *pb = &mxf->fc->pb;