typedef struct film_sample {
int stream;
- int64_t sample_offset;
unsigned int sample_size;
+ int64_t sample_offset;
int64_t pts;
int keyframe;
} film_sample;
unsigned int version;
} FilmDemuxContext;
-static int film_probe(AVProbeData *p)
+static int film_probe(const AVProbeData *p)
{
if (AV_RB32(&p->buf[0]) != FILM_TAG)
return 0;
film->video_type = AV_CODEC_ID_NONE;
}
+ if (film->video_type == AV_CODEC_ID_NONE && film->audio_type == AV_CODEC_ID_NONE)
+ return AVERROR_INVALIDDATA;
+
/* initialize the decoder streams */
- if (film->video_type) {
+ if (film->video_type != AV_CODEC_ID_NONE) {
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
}
}
- if (film->audio_type) {
+ if (film->audio_type != AV_CODEC_ID_NONE) {
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
return AVERROR_INVALIDDATA;
film->base_clock = AV_RB32(&scratch[8]);
film->sample_count = AV_RB32(&scratch[12]);
- if(film->sample_count >= UINT_MAX / sizeof(film_sample))
- return -1;
film->sample_table = av_malloc_array(film->sample_count, sizeof(film_sample));
if (!film->sample_table)
return AVERROR(ENOMEM);
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : AVINDEX_KEYFRAME;
video_frame_counter++;
- if (film->video_type)
+ if (film->video_type != AV_CODEC_ID_NONE)
av_add_index_entry(s->streams[film->video_stream_index],
film->sample_table[i].sample_offset,
film->sample_table[i].pts,
}
}
- if (film->audio_type)
+ if (film->audio_type != AV_CODEC_ID_NONE)
s->streams[film->audio_stream_index]->duration = audio_frame_counter;
- if (film->video_type)
+ if (film->video_type != AV_CODEC_ID_NONE)
s->streams[film->video_stream_index]->duration = video_frame_counter;
film->current_sample = 0;
if (ret < 0)
return ret;
- pos = avio_seek(s->pb, st->index_entries[ret].pos, SEEK_SET);
+ pos = avio_seek(s->pb, st->internal->index_entries[ret].pos, SEEK_SET);
if (pos < 0)
return pos;