data_ptr = pkt->data;
end_ptr = pkt->data + length;
buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
- for (; buf_ptr + st->codec->channels*4 <= end_ptr; ) {
+ for (; end_ptr - buf_ptr >= st->codec->channels * 4; ) {
for (i = 0; i < st->codec->channels; i++) {
uint32_t sample = bytestream_get_le32(&buf_ptr);
if (st->codec->bits_per_coded_sample == 24)
}
}
- if (!(mxf->index_tables = av_calloc(mxf->nb_index_tables, sizeof(MXFIndexTable)))) {
+ mxf->index_tables = av_mallocz_array(mxf->nb_index_tables,
+ sizeof(*mxf->index_tables));
+ if (!mxf->index_tables) {
av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate index tables\n");
ret = AVERROR(ENOMEM);
goto finish_decoding_index;
for (i = j = 0; j < mxf->nb_index_tables; i += mxf->index_tables[j++].nb_segments) {
MXFIndexTable *t = &mxf->index_tables[j];
- if (!(t->segments = av_calloc(t->nb_segments, sizeof(MXFIndexTableSegment*)))) {
- av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate IndexTableSegment pointer array\n");
+ t->segments = av_mallocz_array(t->nb_segments,
+ sizeof(*t->segments));
+
+ if (!t->segments) {
+ av_log(mxf->fc, AV_LOG_ERROR, "failed to allocate IndexTableSegment"
+ " pointer array\n");
ret = AVERROR(ENOMEM);
goto finish_decoding_index;
}
MXFContext* mxf = s->priv_data;
int64_t seekpos;
int i, ret;
- int64_t ret64;
MXFIndexTable *t;
MXFTrack *source_track = st->priv_data;
sample_time = 0;
seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);
- if ((ret64 = avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET)) < 0)
- return ret64;
+ seekpos = avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET);
+ if (seekpos < 0)
+ return seekpos;
+
ff_update_cur_dts(s, st, sample_time);
mxf->current_edit_unit = sample_time;
} else {
sample_time = FFMIN(sample_time, source_track->original_duration - 1);
}
- if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, 1)) << 0)
+ if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, 1)) < 0)
return ret;
ff_update_cur_dts(s, st, sample_time);