FFMS2: The usual small fixes

Originally committed to SVN as r2979.
This commit is contained in:
Fredrik Mellbin 2009-05-23 20:04:38 +00:00
parent 3220a2301a
commit f1fbef752c
4 changed files with 20 additions and 7 deletions

View file

@ -158,7 +158,7 @@ FFMS_API(int) FFMS_GetNumTracks(FFIndex *Index) {
return Index->size();
}
FFMS_API(int) FFMS_GetNumTracksI(FFIndexer *Indexer, int Track) {
FFMS_API(int) FFMS_GetNumTracksI(FFIndexer *Indexer) {
return Indexer->GetNumberOfTracks();
}
@ -170,6 +170,10 @@ FFMS_API(FFMS_TrackType) FFMS_GetTrackTypeI(FFIndexer *Indexer, int Track) {
return Indexer->GetTrackType(Track);
}
FFMS_API(const char *) FFMS_GetCodecNameI(FFIndexer *Indexer, int Track) {
return Indexer->GetTrackCodec(Track);
}
FFMS_API(int) FFMS_GetNumFrames(FFTrack *T) {
return T->size();
}

View file

@ -141,10 +141,10 @@ FFMS_API(void) FFMS_DestroyFFIndex(FFIndex *Index);
FFMS_API(int) FFMS_GetFirstTrackOfType(FFIndex *Index, int TrackType, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_GetFirstIndexedTrackOfType(FFIndex *Index, int TrackType, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_GetNumTracks(FFIndex *Index);
FFMS_API(int) FFMS_GetNumTracksI(FFIndexer *Indexer, int Track);
FFMS_API(int) FFMS_GetNumTracksI(FFIndexer *Indexer);
FFMS_API(FFMS_TrackType) FFMS_GetTrackType(FFTrack *T);
FFMS_API(FFMS_TrackType) FFMS_GetTrackTypeI(FFIndexer *Indexer, int Track);
FFMS_API(const char *) FFMS_CodecName(FFIndexer *Indexer, int Track);
FFMS_API(const char *) FFMS_GetCodecNameI(FFIndexer *Indexer, int Track);
FFMS_API(int) FFMS_GetNumFrames(FFTrack *T);
FFMS_API(const FFFrameInfo *) FFMS_GetFrameInfo(FFTrack *T, int Frame);
FFMS_API(FFTrack *) FFMS_GetTrackFromIndex(FFIndex *Index, int Track);

View file

@ -346,6 +346,7 @@ FFIndex *FFHaaliIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) {
#endif
FFMatroskaIndexer::FFMatroskaIndexer(const char *Filename, char *ErrorMsg, unsigned MsgSize) {
memset(Codec, 0, sizeof(Codec));
SourceFile = Filename;
char ErrorMessage[256];
@ -364,6 +365,11 @@ FFMatroskaIndexer::FFMatroskaIndexer(const char *Filename, char *ErrorMsg, unsig
_snprintf(ErrorMsg, MsgSize, "Can't parse Matroska file: %s", ErrorMessage);
throw ErrorMsg;
}
for (unsigned int i = 0; i < mkv_GetNumTracks(MF); i++) {
TrackInfo *TI = mkv_GetTrackInfo(MF, i);
Codec[i] = avcodec_find_decoder(MatroskaToFFCodecID(TI->CodecID, TI->CodecPrivate));
}
}
FFIndex *FFMatroskaIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) {
@ -391,7 +397,7 @@ FFIndex *FFMatroskaIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) {
}
}
AVCodec *AudioCodec = avcodec_find_decoder(MatroskaToFFCodecID(TI->CodecID, TI->CodecPrivate));
AVCodec *AudioCodec = Codec[i];
if (AudioCodec == NULL) {
av_free(AudioCodecContext);
AudioContexts[i].CTX = NULL;

View file

@ -94,19 +94,22 @@ public:
FFIndex *DoIndexing(char *ErrorMsg, unsigned MsgSize);
int GetNumberOfTracks() { return FormatContext->nb_streams; }
FFMS_TrackType GetTrackType(int Track) { return static_cast<FFMS_TrackType>(FormatContext->streams[Track]->codec->codec_type); }
const char *GetTrackCodec(int Track) { return FormatContext->streams[Track]->codec->codec_name; }
const char *GetTrackCodec(int Track) {
return (avcodec_find_decoder(FormatContext->streams[Track]->codec->codec_id))->long_name;
}
};
class FFMatroskaIndexer : public FFIndexer {
private:
MatroskaFile *MF;
MatroskaReaderContext MC;
AVCodec *Codec[32];
public:
FFMatroskaIndexer(const char *Filename, char *ErrorMsg, unsigned MsgSize);
FFIndex *DoIndexing(char *ErrorMsg, unsigned MsgSize);
int GetNumberOfTracks() { return mkv_GetNumTracks(MF); }
FFMS_TrackType GetTrackType(int Track) { return HaaliTrackTypeToFFTrackType(mkv_GetTrackInfo(MF, Track)->Type); }
const char *GetTrackCodec(int Track) { return mkv_GetTrackInfo(MF, Track)->CodecID; }
const char *GetTrackCodec(int Track) { if (Codec[Track]) return Codec[Track]->long_name; else return "Unsupported codec/Unknown codec name"; }
};
#ifdef HAALISOURCE
@ -126,7 +129,7 @@ public:
FFIndex *DoIndexing(char *ErrorMsg, unsigned MsgSize);
int GetNumberOfTracks() { return NumTracks; }
FFMS_TrackType GetTrackType(int Track) { return TrackType[Track]; }
const char *GetTrackCodec(int Track) { if (Codec[Track]) return Codec[Track]->name; else return "Unsupported codec/Unknown codec name"; }
const char *GetTrackCodec(int Track) { if (Codec[Track]) return Codec[Track]->long_name; else return "Unsupported codec/Unknown codec name"; }
};
#endif // HAALISOURCE