aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Härdin <tomas.hardin@codemill.se>2012-04-04 14:24:49 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-04-04 17:43:17 +0200
commita61fada3805122acf8f362d563c9cbae00c2c8cf (patch)
tree4f3cd3dba323e838991b5d4a430bde034778e7fd
parent6fb35dbad11155ad0e30c421b10450cccb5429ba (diff)
downloadffmpeg-a61fada3805122acf8f362d563c9cbae00c2c8cf.tar.gz
mxfdec: Fix regression on files from Pinnacle Thunder
The reason for this is that such files have IndexTableSegments which when parsed cover EditUnit ranges like this: [0,1) [249,250) [249,377) [0,249) where each interval is [IndexStartPosition,IndexStartPosition+IndexDuration). This would be reduced to a sparse index like: [0,1), [249,250) instead of the full range: [0,249), [249,377) See TimeCode_HD.mxf, UMID = 060a2b340101010101010410130000000004001aa0e59175025b2a5600da4101. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/mxfdec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 5910ccde22..fb47afa5eb 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -952,6 +952,7 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment
int i, j, nb_segments = 0;
MXFIndexTableSegment **unsorted_segments;
int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
+ uint64_t last_index_duration = 0;
/* count number of segments, allocate arrays and copy unsorted segments */
for (i = 0; i < mxf->metadata_sets_count; i++)
@@ -974,19 +975,23 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment
/* sort segments by {BodySID, IndexSID, IndexStartPosition}, remove duplicates while we're at it */
for (i = 0; i < nb_segments; i++) {
int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
+ uint64_t best_index_duration = 0;
for (j = 0; j < nb_segments; j++) {
MXFIndexTableSegment *s = unsorted_segments[j];
/* Require larger BosySID, IndexSID or IndexStartPosition then the previous entry. This removes duplicates.
* We want the smallest values for the keys than what we currently have, unless this is the first such entry this time around.
+ * If we come across an entry with the same IndexStartPosition but larger IndexDuration, then we'll prefer it over the one we currently have.
*/
if ((i == 0 || s->body_sid > last_body_sid || s->index_sid > last_index_sid || s->index_start_position > last_index_start) &&
- (best == -1 || s->body_sid < best_body_sid || s->index_sid < best_index_sid || s->index_start_position < best_index_start)) {
+ (best == -1 || s->body_sid < best_body_sid || s->index_sid < best_index_sid || s->index_start_position < best_index_start ||
+ (s->index_start_position == best_index_start && s->index_duration > best_index_duration))) {
best = j;
best_body_sid = s->body_sid;
best_index_sid = s->index_sid;
best_index_start = s->index_start_position;
+ best_index_duration = s->index_duration;
}
}
@@ -998,6 +1003,7 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment
last_body_sid = best_body_sid;
last_index_sid = best_index_sid;
last_index_start = best_index_start;
+ last_index_duration = best_index_duration;
}
av_free(unsorted_segments);