From: Tomas Härdin <[email protected]>
The mxf_d10 muxer outputs files with zero IndexDuratios.
---
libavformat/mxfdec.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 846fc4a..d602818 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1262,7 +1262,7 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf,
MXFIndexTable *index_ta
*/
static int mxf_compute_index_tables(MXFContext *mxf)
{
- int i, j, ret, nb_sorted_segments;
+ int i, j, k, ret, nb_sorted_segments;
MXFIndexTableSegment **sorted_segments = NULL;
if ((ret = mxf_get_sorted_table_segments(mxf, &nb_sorted_segments,
&sorted_segments)) ||
@@ -1320,6 +1320,27 @@ static int mxf_compute_index_tables(MXFContext *mxf)
if ((ret = mxf_compute_ptses_fake_index(mxf, t)) < 0)
goto finish_decoding_index;
+
+ /* fix zero IndexDurations */
+ for (k = 0; k < t->nb_segments; k++) {
+ if (t->segments[k]->index_duration)
+ continue;
+
+ if (t->nb_segments > 1)
+ av_log(mxf->fc, AV_LOG_WARNING, "IndexSID %i segment %i has
zero IndexDuration and there's more than one segment\n",
+ t->index_sid, k);
+
+ if (mxf->fc->nb_streams <= 0) {
+ av_log(mxf->fc, AV_LOG_WARNING, "no streams?\n");
+ break;
+ }
+
+ /* assume the first stream's duration is reasonable
+ * leave index_duration = 0 on further segments in case we have
any (unlikely)
+ */
+ t->segments[k]->index_duration = mxf->fc->streams[0]->duration;
+ break;
+ }
}
ret = 0;
@@ -1829,6 +1850,11 @@ static int mxf_read_header(AVFormatContext *s,
AVFormatParameters *ap)
mxf_compute_essence_containers(mxf);
+ /* we need to do this before computing the index tables
+ * to be able to fill in zero IndexDurations with st->duration */
+ if ((ret = mxf_parse_structural_metadata(mxf)) < 0)
+ return ret;
+
if ((ret = mxf_compute_index_tables(mxf)) < 0)
return ret;
@@ -1841,7 +1867,7 @@ static int mxf_read_header(AVFormatContext *s,
AVFormatParameters *ap)
return AVERROR_INVALIDDATA;
}
- return mxf_parse_structural_metadata(mxf);
+ return 0;
}
--
1.7.8
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel