aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-21 15:51:42 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-21 15:51:51 +0100
commit1fbb859cdf02933742779890884f1769a2a50eae (patch)
treeac5e269695dff1e3817d4084d688589698a2c040
parentc3846e3ebab610be691adb8b40d376dc2f675dc4 (diff)
parent5b718009b2c54a6ade9241fe5ae175e6f069791b (diff)
downloadffmpeg-1fbb859cdf02933742779890884f1769a2a50eae.tar.gz
Merge remote-tracking branch 'tjoppen/mxf_fixes_20111220'
* tjoppen/mxf_fixes_20111220: mxfdec: Sanity-check SampleRate mxfdec: Make sure mxf->nb_index_tables > 0 in mxf_packet_timestamps() mxfdec: Remove unused variables mxfdec: Make sure x < index_table->nb_ptses mxfdec: Ignore the last entry in Avid's index table segments Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/mxfdec.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 2e5a03936e..b6a63c90a2 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -662,7 +662,7 @@ static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size
static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
{
- int i, j, length;
+ int i, length;
segment->nb_index_entries = avio_rb32(pb);
length = avio_rb32(pb);
@@ -1072,14 +1072,25 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, MXFIndexTable *index_ta
for (i = x = 0; i < index_table->nb_segments; i++) {
MXFIndexTableSegment *s = index_table->segments[i];
int index_delta = 1;
+ int n = s->nb_index_entries;
- if (s->nb_index_entries == 2 * s->index_duration + 1)
+ if (s->nb_index_entries == 2 * s->index_duration + 1) {
index_delta = 2; /* Avid index */
- for (j = 0; j < s->nb_index_entries; j += index_delta, x++) {
+ /* ignore the last entry - it's the size of the essence container */
+ n--;
+ }
+
+ for (j = 0; j < n; j += index_delta, x++) {
int offset = s->temporal_offset_entries[j] / index_delta;
int index = x + offset;
+ if (x >= index_table->nb_ptses) {
+ av_log(mxf->fc, AV_LOG_ERROR, "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64"?\n",
+ s->nb_index_entries, s->index_duration);
+ break;
+ }
+
index_table->fake_index[x].timestamp = x;
index_table->fake_index[x].flags = !(s->flag_entries[j] & 0x30) ? AVINDEX_KEYFRAME : 0;
@@ -1359,6 +1370,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->codec->codec_id = container_ul->id;
st->codec->channels = descriptor->channels;
st->codec->bits_per_coded_sample = descriptor->bits_per_sample;
+ if (descriptor->sample_rate.den > 0)
st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
/* TODO: implement CODEC_ID_RAWAUDIO */
if (st->codec->codec_id == CODEC_ID_PCM_S16LE) {
@@ -1833,7 +1845,7 @@ static int mxf_read_close(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
MXFIndexTableSegment *seg;
- int i, j;
+ int i;
av_freep(&mxf->packages_refs);