#include "riff.h"
#include "intfloat_readwrite.h"
#include "matroska.h"
+#include "libavcodec/mpeg4audio.h"
typedef struct Track {
MatroskaTrackType type;
//..
} MatroskaSubtitleTrack;
-#define MAX_TRACK_SIZE (FFMAX(FFMAX(sizeof(MatroskaVideoTrack), \
- sizeof(MatroskaAudioTrack)), \
+#define MAX_TRACK_SIZE (FFMAX3(sizeof(MatroskaVideoTrack), \
+ sizeof(MatroskaAudioTrack), \
sizeof(MatroskaSubtitleTrack)))
typedef struct MatroskaLevel {
static int
matroska_aac_sri (int samplerate)
{
- static const int aac_sample_rates[] = {
- 96000, 88200, 64000, 48000, 44100, 32000,
- 24000, 22050, 16000, 12000, 11025, 8000,
- };
int sri;
- for (sri=0; sri<ARRAY_SIZE(aac_sample_rates); sri++)
- if (aac_sample_rates[sri] == samplerate)
+ for (sri=0; sri<ARRAY_SIZE(ff_mpeg4audio_sample_rates); sri++)
+ if (ff_mpeg4audio_sample_rates[sri] == samplerate)
break;
return sri;
}
for (i=0; i<matroska->num_indexes; i++) {
MatroskaDemuxIndex *idx = &matroska->index[i];
track = matroska_find_track_by_num(matroska, idx->track);
+ if (track < 0) continue;
stream = matroska->tracks[track]->stream_index;
- if (stream >= 0)
+ if (stream >= 0 && stream < matroska->ctx->nb_streams)
av_add_index_entry(matroska->ctx->streams[stream],
idx->pos, idx->time/matroska->time_scale,
0, 0, AVINDEX_KEYFRAME);
return res;
}
stream_index = matroska->tracks[track]->stream_index;
- if (stream_index < 0) {
+ if (stream_index < 0 || stream_index >= matroska->ctx->nb_streams) {
av_free(origdata);
return res;
}