mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack
This commit is contained in:
parent
fd34dbea58
commit
5fb800f49a
@ -190,7 +190,6 @@ typedef struct {
|
|||||||
uint8_t *local_tags;
|
uint8_t *local_tags;
|
||||||
int local_tags_count;
|
int local_tags_count;
|
||||||
uint64_t footer_partition;
|
uint64_t footer_partition;
|
||||||
int system_item;
|
|
||||||
int64_t essence_offset;
|
int64_t essence_offset;
|
||||||
int first_essence_kl_length;
|
int first_essence_kl_length;
|
||||||
int64_t first_essence_length;
|
int64_t first_essence_length;
|
||||||
@ -986,17 +985,22 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st)
|
static int mxf_parse_index(MXFContext *mxf, int track_id, AVStream *st)
|
||||||
{
|
{
|
||||||
int64_t accumulated_offset = 0;
|
int64_t accumulated_offset = 0;
|
||||||
int j, k, ret, nb_sorted_segments;
|
int j, k, ret, nb_sorted_segments;
|
||||||
MXFIndexTableSegment **sorted_segments;
|
MXFIndexTableSegment **sorted_segments;
|
||||||
|
int n_delta = track_id - 1; /* TrackID = 1-based stream index */
|
||||||
|
|
||||||
|
if (track_id < 1) {
|
||||||
|
av_log(mxf->fc, AV_LOG_ERROR, "TrackID not positive: %i\n", track_id);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = mxf_get_sorted_table_segments(mxf, &nb_sorted_segments, &sorted_segments)))
|
if ((ret = mxf_get_sorted_table_segments(mxf, &nb_sorted_segments, &sorted_segments)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (j = 0; j < nb_sorted_segments; j++) {
|
for (j = 0; j < nb_sorted_segments; j++) {
|
||||||
int n_delta = i;
|
|
||||||
int duration, sample_duration = 1, last_sample_size = 0;
|
int duration, sample_duration = 1, last_sample_size = 0;
|
||||||
int64_t segment_size;
|
int64_t segment_size;
|
||||||
MXFIndexTableSegment *tableseg = sorted_segments[j];
|
MXFIndexTableSegment *tableseg = sorted_segments[j];
|
||||||
@ -1005,9 +1009,6 @@ static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st)
|
|||||||
if (j > 0 && tableseg->body_sid != sorted_segments[j-1]->body_sid)
|
if (j > 0 && tableseg->body_sid != sorted_segments[j-1]->body_sid)
|
||||||
accumulated_offset = 0;
|
accumulated_offset = 0;
|
||||||
|
|
||||||
/* HACK: How to correctly link between streams and slices? */
|
|
||||||
if (i < mxf->system_item + st->index)
|
|
||||||
n_delta++;
|
|
||||||
if (n_delta >= tableseg->nb_delta_entries && st->index != 0)
|
if (n_delta >= tableseg->nb_delta_entries && st->index != 0)
|
||||||
continue;
|
continue;
|
||||||
duration = tableseg->index_duration > 0 ? tableseg->index_duration :
|
duration = tableseg->index_duration > 0 ? tableseg->index_duration :
|
||||||
@ -1075,8 +1076,8 @@ static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st)
|
|||||||
|
|
||||||
pos += mxf->essence_offset;
|
pos += mxf->essence_offset;
|
||||||
|
|
||||||
av_dlog(mxf->fc, "Stream %d IndexEntry %d n_Delta %d Offset %"PRIx64" Timestamp %"PRId64"\n",
|
av_dlog(mxf->fc, "Stream %d IndexEntry %d TrackID %d Offset %"PRIx64" Timestamp %"PRId64"\n",
|
||||||
st->index, st->nb_index_entries, n_delta, pos, sample_duration * st->nb_index_entries);
|
st->index, st->nb_index_entries, track_id, pos, sample_duration * st->nb_index_entries);
|
||||||
|
|
||||||
if ((ret = av_add_index_entry(st, pos, sample_duration * st->nb_index_entries, size, 0, flags)) < 0)
|
if ((ret = av_add_index_entry(st, pos, sample_duration * st->nb_index_entries, size, 0, flags)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -1275,7 +1276,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
|
|||||||
st->need_parsing = AVSTREAM_PARSE_FULL;
|
st->need_parsing = AVSTREAM_PARSE_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = mxf_parse_index(mxf, i, st)))
|
if ((ret = mxf_parse_index(mxf, material_track->track_id, st)))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1524,10 +1525,6 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_KLV_KEY(klv.key, mxf_system_item_key)) {
|
|
||||||
mxf->system_item = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mxf->essence_offset)
|
if (!mxf->essence_offset)
|
||||||
mxf->essence_offset = klv.offset;
|
mxf->essence_offset = klv.offset;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user