summaryrefslogtreecommitdiff
path: root/libavformat/mxfdec.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2018-07-04 23:42:56 +0200
committerMarton Balint <cus@passwd.hu>2018-07-24 09:06:55 +0200
commita5c17cf43e42ae3562a66a3f350cd1619361a395 (patch)
treece86b072b2361209897959ba19b3ea1ac3fd2d3b /libavformat/mxfdec.c
parent0bb5cd8c4d566d38d6f056fb13eba3a0a5c4d211 (diff)
avformat/mxfdec: drop invalid index table segments when sorting them
This way if an index table segment is present multiple times, we can always use the proper one instead of the invalid one. Fixes seeking in the sample of ticket #5671. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r--libavformat/mxfdec.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 8d3e8ed4db..8e1089620f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1348,9 +1348,22 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment
return AVERROR(ENOMEM);
}
- for (i = j = 0; i < mxf->metadata_sets_count; i++)
- if (mxf->metadata_sets[i]->type == IndexTableSegment)
- unsorted_segments[j++] = (MXFIndexTableSegment*)mxf->metadata_sets[i];
+ for (i = nb_segments = 0; i < mxf->metadata_sets_count; i++) {
+ if (mxf->metadata_sets[i]->type == IndexTableSegment) {
+ MXFIndexTableSegment *s = (MXFIndexTableSegment*)mxf->metadata_sets[i];
+ if (s->edit_unit_byte_count || s->nb_index_entries)
+ unsorted_segments[nb_segments++] = s;
+ else
+ av_log(mxf->fc, AV_LOG_WARNING, "IndexSID %i segment at %"PRId64" missing EditUnitByteCount and IndexEntryArray\n",
+ s->index_sid, s->index_start_position);
+ }
+ }
+
+ if (!nb_segments) {
+ av_freep(sorted_segments);
+ av_free(unsorted_segments);
+ return AVERROR_INVALIDDATA;
+ }
*nb_sorted_segments = 0;
@@ -1482,7 +1495,7 @@ static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_t
if (s->edit_unit_byte_count)
offset_temp += s->edit_unit_byte_count * index;
- else if (s->nb_index_entries) {
+ else {
if (s->nb_index_entries == 2 * s->index_duration + 1)
index *= 2; /* Avid index */
@@ -1493,10 +1506,6 @@ static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_t
}
offset_temp = s->stream_offset_entries[index];
- } else {
- av_log(mxf->fc, AV_LOG_ERROR, "IndexSID %i segment at %"PRId64" missing EditUnitByteCount and IndexEntryArray\n",
- index_table->index_sid, s->index_start_position);
- return AVERROR_INVALIDDATA;
}
if (edit_unit_out)