Skip to content

Commit

Permalink
Initialize more stuff in FFMS_Index's constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Mar 18, 2014
1 parent c306e43 commit c755de9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/core/ffms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,12 @@ FFMS_API(void) FFMS_CancelIndexing(FFMS_Indexer *Indexer) {

FFMS_API(FFMS_Index *) FFMS_ReadIndex(const char *IndexFile, FFMS_ErrorInfo *ErrorInfo) {
ClearErrorInfo(ErrorInfo);
FFMS_Index *Index = new FFMS_Index();
try {
Index->ReadIndex(IndexFile);
return new FFMS_Index(IndexFile);
} catch (FFMS_Exception &e) {
delete Index;
e.CopyOut(ErrorInfo);
return NULL;
}
return Index;
}

FFMS_API(int) FFMS_IndexBelongsToFile(FFMS_Index *Index, const char *SourceFile, FFMS_ErrorInfo *ErrorInfo) {
Expand Down
6 changes: 1 addition & 5 deletions src/core/haaliindexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ FFMS_Index *FFHaaliIndexer::DoIndexing() {
std::vector<SharedAudioContext> AudioContexts(NumTracks, SharedAudioContext(false));
std::vector<SharedVideoContext> VideoContexts(NumTracks, SharedVideoContext(false));

std::auto_ptr<FFMS_Index> TrackIndices(new FFMS_Index(Filesize, Digest));
TrackIndices->Decoder = FFMS_SOURCE_HAALIMPEG;
if (SourceMode == FFMS_SOURCE_HAALIOGG)
TrackIndices->Decoder = FFMS_SOURCE_HAALIOGG;
TrackIndices->ErrorHandling = ErrorHandling;
std::auto_ptr<FFMS_Index> TrackIndices(new FFMS_Index(Filesize, Digest, SourceMode, ErrorHandling));

for (int i = 0; i < NumTracks; i++) {
TrackIndices->push_back(FFMS_Track(1, 1000000, TrackType[i]));
Expand Down
14 changes: 9 additions & 5 deletions src/core/indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ void FFMS_Index::WriteIndex(const char *IndexFile) {
zf.finish();
}

void FFMS_Index::ReadIndex(const char *IndexFile) {
FFMS_Index::FFMS_Index(const char *IndexFile)
: RefCount(1)
{
ffms_fstream Index(IndexFile, std::ios::in | std::ios::binary);

if (!Index.is_open())
Expand Down Expand Up @@ -597,10 +599,12 @@ void FFMS_Index::ReadIndex(const char *IndexFile) {
}
}

FFMS_Index::FFMS_Index() : RefCount(1) {
}

FFMS_Index::FFMS_Index(int64_t Filesize, uint8_t Digest[20]) : RefCount(1), Filesize(Filesize) {
FFMS_Index::FFMS_Index(int64_t Filesize, uint8_t Digest[20], int Decoder, int ErrorHandling)
: RefCount(1)
, Decoder(Decoder)
, ErrorHandling(ErrorHandling)
, Filesize(Filesize)
{
memcpy(this->Digest, Digest, sizeof(this->Digest));
}

Expand Down
5 changes: 2 additions & 3 deletions src/core/indexing.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ struct FFMS_Index : public std::vector<FFMS_Track> {
void Sort();
bool CompareFileSignature(const char *Filename);
void WriteIndex(const char *IndexFile);
void ReadIndex(const char *IndexFile);

FFMS_Index();
FFMS_Index(int64_t Filesize, uint8_t Digest[20]);
FFMS_Index(const char *IndexFile);
FFMS_Index(int64_t Filesize, uint8_t Digest[20], int Decoder, int ErrorHandling);
};

struct FFMS_Indexer {
Expand Down
4 changes: 1 addition & 3 deletions src/core/lavfindexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ FFMS_Index *FFLAVFIndexer::DoIndexing() {
std::vector<SharedAudioContext> AudioContexts(FormatContext->nb_streams, SharedAudioContext(false));
std::vector<SharedVideoContext> VideoContexts(FormatContext->nb_streams, SharedVideoContext(false));

std::auto_ptr<FFMS_Index> TrackIndices(new FFMS_Index(Filesize, Digest));
TrackIndices->Decoder = FFMS_SOURCE_LAVF;
TrackIndices->ErrorHandling = ErrorHandling;
std::auto_ptr<FFMS_Index> TrackIndices(new FFMS_Index(Filesize, Digest, FFMS_SOURCE_LAVF, ErrorHandling));

for (unsigned int i = 0; i < FormatContext->nb_streams; i++) {
TrackIndices->push_back(FFMS_Track((int64_t)FormatContext->streams[i]->time_base.num * 1000,
Expand Down
4 changes: 1 addition & 3 deletions src/core/matroskaindexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ FFMS_Index *FFMatroskaIndexer::DoIndexing() {
std::vector<SharedAudioContext> AudioContexts(mkv_GetNumTracks(MF), SharedAudioContext(true));
std::vector<SharedVideoContext> VideoContexts(mkv_GetNumTracks(MF), SharedVideoContext(true));

std::auto_ptr<FFMS_Index> TrackIndices(new FFMS_Index(Filesize, Digest));
TrackIndices->Decoder = FFMS_SOURCE_MATROSKA;
TrackIndices->ErrorHandling = ErrorHandling;
std::auto_ptr<FFMS_Index> TrackIndices(new FFMS_Index(Filesize, Digest, FFMS_SOURCE_MATROSKA, ErrorHandling));

for (unsigned int i = 0; i < mkv_GetNumTracks(MF); i++) {
TrackInfo *TI = mkv_GetTrackInfo(MF, i);
Expand Down

0 comments on commit c755de9

Please sign in to comment.