Mercurial > libavformat.hg
comparison mxf.c @ 1395:c956d0ce5e91 libavformat
skip run in sequence, fix C0023S01.mxf
author | bcoudurier |
---|---|
date | Tue, 17 Oct 2006 11:23:04 +0000 |
parents | 00cdaa81086a |
children | 069c0c5a1baf |
comparison
equal
deleted
inserted
replaced
1394:bd265fedcd65 | 1395:c956d0ce5e91 |
---|---|
941 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 }, mxf_read_metadata_track }, /* Static Track */ | 941 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 }, mxf_read_metadata_track }, /* Static Track */ |
942 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 }, mxf_read_metadata_track }, /* Generic Track */ | 942 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 }, mxf_read_metadata_track }, /* Generic Track */ |
943 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL }, | 943 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL }, |
944 }; | 944 }; |
945 | 945 |
946 static int mxf_read_sync(ByteIOContext *pb, const uint8_t *key, unsigned size) | |
947 { | |
948 int i, b; | |
949 for (i = 0; i < size && !url_feof(pb); i++) { | |
950 b = get_byte(pb); | |
951 if (b == key[0]) | |
952 i = 0; | |
953 else if (b != key[i]) | |
954 i = -1; | |
955 } | |
956 return i == size; | |
957 } | |
958 | |
946 static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap) | 959 static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap) |
947 { | 960 { |
948 MXFContext *mxf = s->priv_data; | 961 MXFContext *mxf = s->priv_data; |
949 KLVPacket klv; | 962 KLVPacket klv; |
950 | 963 |
964 if (!mxf_read_sync(&s->pb, mxf_header_partition_pack_key, 14)) { | |
965 av_log(s, AV_LOG_ERROR, "could not find header partition pack key\n"); | |
966 return -1; | |
967 } | |
968 url_fseek(&s->pb, -14, SEEK_CUR); | |
951 mxf->fc = s; | 969 mxf->fc = s; |
952 while (!url_feof(&s->pb)) { | 970 while (!url_feof(&s->pb)) { |
953 const MXFMetadataReadTableEntry *function; | 971 const MXFMetadataReadTableEntry *function; |
954 | 972 |
955 if (klv_read_packet(&klv, &s->pb) < 0) { | 973 if (klv_read_packet(&klv, &s->pb) < 0) { |
1029 /* XXX: use MXF Index */ | 1047 /* XXX: use MXF Index */ |
1030 static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags) | 1048 static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags) |
1031 { | 1049 { |
1032 AVStream *st = s->streams[stream_index]; | 1050 AVStream *st = s->streams[stream_index]; |
1033 int64_t seconds; | 1051 int64_t seconds; |
1034 int i; | |
1035 | 1052 |
1036 if (!s->bit_rate) | 1053 if (!s->bit_rate) |
1037 return -1; | 1054 return -1; |
1038 if (sample_time < 0) | 1055 if (sample_time < 0) |
1039 sample_time = 0; | 1056 sample_time = 0; |
1040 seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den); | 1057 seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den); |
1041 url_fseek(&s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET); | 1058 url_fseek(&s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET); |
1042 /* sync on KLV essence element */ | 1059 if (!mxf_read_sync(&s->pb, mxf_essence_element_key, 12)) |
1043 for (i = 0; i < 12 && url_ftell(&s->pb) < s->file_size; i++) { | 1060 return -1; |
1044 int b = get_byte(&s->pb); | 1061 |
1045 if (b == mxf_essence_element_key[0]) | 1062 /* found KLV key */ |
1046 i = 0; | 1063 url_fseek(&s->pb, -12, SEEK_CUR); |
1047 else if (b != mxf_essence_element_key[i]) | 1064 av_update_cur_dts(s, st, sample_time); |
1048 i = -1; | 1065 return 0; |
1049 } | |
1050 if (i == 12) { /* found KLV key */ | |
1051 url_fseek(&s->pb, -12, SEEK_CUR); | |
1052 av_update_cur_dts(s, st, sample_time); | |
1053 return 0; | |
1054 } | |
1055 return -1; | |
1056 } | 1066 } |
1057 | 1067 |
1058 AVInputFormat mxf_demuxer = { | 1068 AVInputFormat mxf_demuxer = { |
1059 "mxf", | 1069 "mxf", |
1060 "MXF format", | 1070 "MXF format", |