ffmpeg | branch: master | Marton Balint <c...@passwd.hu> | Wed Jul 4 23:42:56 2018 +0200| [a5c17cf43e42ae3562a66a3f350cd1619361a395] | committer: Marton Balint
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 <c...@passwd.hu> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5c17cf43e42ae3562a66a3f350cd1619361a395 --- libavformat/mxfdec.c | 25 +++++++++++++++++-------- 1 file 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) _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog