api fixup

Originally committed to SVN as r2383.
This commit is contained in:
Fredrik Mellbin 2008-09-23 21:56:30 +00:00
parent fabcd033b0
commit 82810de584
4 changed files with 28 additions and 11 deletions

View File

@ -108,6 +108,10 @@ FFMS_API(int) FFMS_GetNumTracks(FrameIndex *TrackIndices, char *ErrorMsg, unsign
return TrackIndices->size();
}
FFMS_API(int) FFMS_GetTrackType(FrameInfoVector *FIV, char *ErrorMsg, unsigned MsgSize) {
return FIV->TT;
}
FFMS_API(int) FFMS_GetNumFrames(FrameInfoVector *FIV, char *ErrorMsg, unsigned MsgSize) {
return FIV->size();
}

View File

@ -50,6 +50,11 @@ class FrameInfoVector;
typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private);
enum TrackType {
FFMS_TYPE_VIDEO = 0,
FFMS_TYPE_AUDIO = 1,
};
// PixelFormat declarations from avutil.h so external libraries don't necessarily have to include and ffmpeg headers
enum FFMS_PixelFormat {
FFMS_PIX_FMT_NONE= -1,
@ -166,6 +171,7 @@ FFMS_API(int) FFMS_SetOutputFormat(VideoBase *VB, int TargetFormat, int Width, i
FFMS_API(void) FFMS_ResetOutputFormat(VideoBase *VB);
FFMS_API(void) FFMS_DestroyFrameIndex(FrameIndex *FI);
FFMS_API(int) FFMS_GetNumTracks(FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_GetTrackType(FrameInfoVector *FIV, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_GetNumFrames(FrameInfoVector *FIV, char *ErrorMsg, unsigned MsgSize);
FFMS_API(const FrameInfo *) FFMS_GetFrameInfo(FrameInfoVector *FIV, int Frame, char *ErrorMsg, unsigned MsgSize);
FFMS_API(FrameInfoVector *) FFMS_GetTITrackIndex(FrameIndex *TrackIndices, int Track, char *ErrorMsg, unsigned MsgSize);

View File

@ -113,13 +113,14 @@ int WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg,
Index.write(reinterpret_cast<char *>(&IH), sizeof(IH));
for (unsigned int i = 0; i < IH.Tracks; i++) {
// Write how many records belong to the current stream
size_t Frames = (*TrackIndices)[i].size();
Index.write(reinterpret_cast<char *>(&Frames), sizeof(Frames));
int TT = (*TrackIndices)[i].TT;
Index.write(reinterpret_cast<char *>(&TT), sizeof(TT));
int Num = (*TrackIndices)[i].TB.Num;
Index.write(reinterpret_cast<char *>(&Num), sizeof(Num));
int Den = (*TrackIndices)[i].TB.Den;
Index.write(reinterpret_cast<char *>(&Den), sizeof(Den));
size_t Frames = (*TrackIndices)[i].size();
Index.write(reinterpret_cast<char *>(&Frames), sizeof(Frames));
for (size_t j = 0; j < Frames; j++)
Index.write(reinterpret_cast<char *>(&(TrackIndices->at(i)[j])), sizeof(FrameInfo));
@ -200,7 +201,7 @@ static FrameIndex *MakeMatroskaIndex(const char *SourceFile, int AudioTrackMask,
TrackIndices->Decoder = 1;
for (unsigned int i = 0; i < mkv_GetNumTracks(MF); i++)
TrackIndices->push_back(FrameInfoVector(mkv_TruncFloat(mkv_GetTrackInfo(MF, i)->TimecodeScale), 1000000));
TrackIndices->push_back(FrameInfoVector(mkv_TruncFloat(mkv_GetTrackInfo(MF, i)->TimecodeScale), 1000000, mkv_GetTrackInfo(MF, i)->Type - 1));
ulonglong StartTime, EndTime, FilePos;
unsigned int Track, FrameFlags, FrameSize;
@ -316,7 +317,8 @@ FrameIndex *MakeIndex(const char *SourceFile, int AudioTrackMask, const char *Au
for (unsigned int i = 0; i < FormatContext->nb_streams; i++)
TrackIndices->push_back(FrameInfoVector(FormatContext->streams[i]->time_base.num * 1000,
FormatContext->streams[i]->time_base.den));
FormatContext->streams[i]->time_base.den,
FormatContext->streams[i]->codec->codec_type));
AVPacket Packet;
while (av_read_frame(FormatContext, &Packet) >= 0) {
@ -409,13 +411,15 @@ FrameIndex *ReadIndex(const char *IndexFile, char *ErrorMsg, unsigned MsgSize) {
for (unsigned int i = 0; i < IH.Tracks; i++) {
// Read how many records belong to the current stream
size_t Frames;
Index.read(reinterpret_cast<char *>(&Frames), sizeof(Frames));
int TT;
Index.read(reinterpret_cast<char *>(&TT), sizeof(TT));
int Num;
Index.read(reinterpret_cast<char *>(&Num), sizeof(Num));
int Den;
Index.read(reinterpret_cast<char *>(&Den), sizeof(Den));
TrackIndices->push_back(FrameInfoVector(Num, Den));
size_t Frames;
Index.read(reinterpret_cast<char *>(&Frames), sizeof(Frames));
TrackIndices->push_back(FrameInfoVector(Num, Den, TT));
FrameInfo FI(0, false);
for (size_t j = 0; j < Frames; j++) {
@ -492,11 +496,13 @@ int FrameInfoVector::FindClosestKeyFrame(int Frame) {
}
FrameInfoVector::FrameInfoVector() {
TT = 0;
TB.Num = 0;
TB.Den = 0;
}
FrameInfoVector::FrameInfoVector(int Num, int Den) {
FrameInfoVector::FrameInfoVector(int Num, int Den, int TT) {
this->TT = TT;
TB.Num = Num;
TB.Den = Den;
}

View File

@ -33,7 +33,7 @@ extern "C" {
#include "utils.h"
#include "ffms.h"
#define INDEXVERSION 5
#define INDEXVERSION 6
#define INDEXID 0x53920873
struct IndexHeader {
@ -45,6 +45,7 @@ struct IndexHeader {
class FrameInfoVector : public std::vector<FrameInfo> {
public:
int TT;
TrackTimeBase TB;
int FindClosestKeyFrame(int Frame);
@ -53,7 +54,7 @@ public:
int WriteTimecodes(const char *TimecodeFile, char *ErrorMsg, unsigned MsgSize);
FrameInfoVector();
FrameInfoVector(int Num, int Den);
FrameInfoVector(int Num, int Den, int TT);
};
class FrameIndex : public std::vector<FrameInfoVector> {