mirror of https://github.com/odrling/Aegisub
FFMS2:
Fix the weird crash bug Fix *nix compilation Originally committed to SVN as r2976.
This commit is contained in:
parent
870f46f85e
commit
159552f36e
|
@ -29,7 +29,6 @@ extern "C" {
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
#define _snprintf snprintf
|
#define _snprintf snprintf
|
||||||
#define _scprintf scprintf
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int InitCount = 0;
|
static int InitCount = 0;
|
||||||
|
@ -219,9 +218,9 @@ FFMS_API(FFIndex *) FFMS_MakeIndex(const char *SourceFile, int IndexMask, int Du
|
||||||
FFMS_API(int) FFMS_DefaultAudioFilename(const char *SourceFile, int Track, const TAudioProperties *AP, char *FileName, void *Private) {
|
FFMS_API(int) FFMS_DefaultAudioFilename(const char *SourceFile, int Track, const TAudioProperties *AP, char *FileName, void *Private) {
|
||||||
const char * FormatString = "%s.%d2.w64";
|
const char * FormatString = "%s.%d2.w64";
|
||||||
if (FileName == NULL)
|
if (FileName == NULL)
|
||||||
return _scprintf(FormatString, SourceFile, Track) + 1;
|
return _snprintf(NULL, 0, FormatString, SourceFile, Track) + 1;
|
||||||
else
|
else
|
||||||
return sprintf(FileName, FormatString, SourceFile, Track) + 1;
|
return _snprintf(FileName, 999999, FormatString, SourceFile, Track) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FFMS_API(FFIndexer *) FFMS_CreateIndexer(const char *SourceFile, char *ErrorMsg, unsigned MsgSize) {
|
FFMS_API(FFIndexer *) FFMS_CreateIndexer(const char *SourceFile, char *ErrorMsg, unsigned MsgSize) {
|
||||||
|
|
|
@ -34,13 +34,13 @@ using namespace std;
|
||||||
|
|
||||||
static int FFMS_CC UpdateProgress(int64_t Current, int64_t Total, void *Private) {
|
static int FFMS_CC UpdateProgress(int64_t Current, int64_t Total, void *Private) {
|
||||||
|
|
||||||
int LastPercentage = (int)Private;
|
int *LastPercentage = (int *)Private;
|
||||||
int Percentage = int((double(Current)/double(Total)) * 100);
|
int Percentage = int((double(Current)/double(Total)) * 100);
|
||||||
|
|
||||||
if (Percentage <= LastPercentage)
|
if (Percentage <= *LastPercentage)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Private = (void *)Percentage;
|
*LastPercentage = Percentage;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Indexing, please wait... " << Percentage << "% \r" << flush;
|
cout << "Indexing, please wait... " << Percentage << "% \r" << flush;
|
||||||
|
@ -50,6 +50,7 @@ static int FFMS_CC UpdateProgress(int64_t Current, int64_t Total, void *Private)
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestFullDump1(char *SrcFile, bool WithAudio) {
|
void TestFullDump1(char *SrcFile, bool WithAudio) {
|
||||||
|
int Private;
|
||||||
char ErrorMsg[2000];
|
char ErrorMsg[2000];
|
||||||
int ret = FFMS_Init();
|
int ret = FFMS_Init();
|
||||||
assert(!ret);
|
assert(!ret);
|
||||||
|
@ -60,7 +61,7 @@ void TestFullDump1(char *SrcFile, bool WithAudio) {
|
||||||
FIdx = FFMS_CreateIndexer(SrcFile, ErrorMsg, sizeof(ErrorMsg));
|
FIdx = FFMS_CreateIndexer(SrcFile, ErrorMsg, sizeof(ErrorMsg));
|
||||||
assert(FIdx);
|
assert(FIdx);
|
||||||
|
|
||||||
FFIndex *FI = FFMS_DoIndexing(FIdx, -1, -1, FFMS_DefaultAudioFilename, NULL, false, UpdateProgress, NULL, ErrorMsg, sizeof(ErrorMsg));
|
FFIndex *FI = FFMS_DoIndexing(FIdx, -1, -1, FFMS_DefaultAudioFilename, NULL, false, UpdateProgress, &Private, ErrorMsg, sizeof(ErrorMsg));
|
||||||
assert(FI);
|
assert(FI);
|
||||||
|
|
||||||
int vtrack = FFMS_GetFirstTrackOfType(FI, FFMS_TYPE_VIDEO, ErrorMsg, sizeof(ErrorMsg));
|
int vtrack = FFMS_GetFirstTrackOfType(FI, FFMS_TYPE_VIDEO, ErrorMsg, sizeof(ErrorMsg));
|
||||||
|
@ -68,7 +69,7 @@ void TestFullDump1(char *SrcFile, bool WithAudio) {
|
||||||
int atrack = FFMS_GetFirstTrackOfType(FI, FFMS_TYPE_AUDIO, ErrorMsg, sizeof(ErrorMsg));
|
int atrack = FFMS_GetFirstTrackOfType(FI, FFMS_TYPE_AUDIO, ErrorMsg, sizeof(ErrorMsg));
|
||||||
assert(atrack >= 0);
|
assert(atrack >= 0);
|
||||||
|
|
||||||
FFVideo *V = FFMS_CreateVideoSource(SrcFile, vtrack, FI, "", 1, 1, ErrorMsg, sizeof(ErrorMsg));
|
FFVideo *V = FFMS_CreateVideoSource(SrcFile, vtrack, FI, "", 2, 1, ErrorMsg, sizeof(ErrorMsg));
|
||||||
assert(V);
|
assert(V);
|
||||||
|
|
||||||
if (WithAudio) {
|
if (WithAudio) {
|
||||||
|
@ -101,13 +102,13 @@ int main(int argc, char *argv[]) {
|
||||||
char *TestFiles1[10];
|
char *TestFiles1[10];
|
||||||
TestFiles1[0] = "[FLV1]_The_Melancholy_of_Haruhi_Suzumiya_-_Full_Clean_Ending.flv";
|
TestFiles1[0] = "[FLV1]_The_Melancholy_of_Haruhi_Suzumiya_-_Full_Clean_Ending.flv";
|
||||||
TestFiles1[1] = "jra_jupiter.avi";
|
TestFiles1[1] = "jra_jupiter.avi";
|
||||||
TestFiles1[2] = "h264_16-bframes_16-references_pyramid_crash-indexing.mkv";
|
TestFiles1[2] = "Zero1_ITV2_TS_Test.ts";
|
||||||
TestFiles1[3] = "pyramid-adaptive-10-bframes.mkv";
|
TestFiles1[3] = "zx.starship.operators.01.h264.mkv";
|
||||||
TestFiles1[4] = "negative-timecodes.avi";
|
TestFiles1[4] = "negative-timecodes.avi";
|
||||||
TestFiles1[5] = "Zero1_ITV2_TS_Test.ts";
|
TestFiles1[5] = "h264_16-bframes_16-references_pyramid_crash-indexing.mkv";
|
||||||
TestFiles1[6] = "zx.starship.operators.01.h264.mkv";
|
TestFiles1[6] = "pyramid-adaptive-10-bframes.mkv";
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
TestFullDump1(TestFiles1[i], true);
|
TestFullDump1(TestFiles1[i], true);
|
||||||
/*
|
/*
|
||||||
TestFullDump1(TestFiles1[5], false);
|
TestFullDump1(TestFiles1[5], false);
|
||||||
|
|
|
@ -66,12 +66,13 @@ protected:
|
||||||
TAudioNameCallback ANC;
|
TAudioNameCallback ANC;
|
||||||
void *ANCPrivate;
|
void *ANCPrivate;
|
||||||
const char *SourceFile;
|
const char *SourceFile;
|
||||||
int16_t DecodingBuffer[AVCODEC_MAX_AUDIO_FRAME_SIZE * 5];
|
int16_t *DecodingBuffer;
|
||||||
|
|
||||||
bool WriteAudio(SharedAudioContext &AudioContext, FFIndex *Index, int Track, int DBSize, char *ErrorMsg, unsigned MsgSize);
|
bool WriteAudio(SharedAudioContext &AudioContext, FFIndex *Index, int Track, int DBSize, char *ErrorMsg, unsigned MsgSize);
|
||||||
public:
|
public:
|
||||||
static FFIndexer *CreateFFIndexer(const char *Filename, char *ErrorMsg, unsigned MsgSize);
|
static FFIndexer *CreateFFIndexer(const char *Filename, char *ErrorMsg, unsigned MsgSize);
|
||||||
virtual ~FFIndexer() { }
|
FFIndexer() { DecodingBuffer = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE * 5]; }
|
||||||
|
virtual ~FFIndexer() { delete[] DecodingBuffer; }
|
||||||
void SetIndexMask(int IndexMask) { this->IndexMask = IndexMask; }
|
void SetIndexMask(int IndexMask) { this->IndexMask = IndexMask; }
|
||||||
void SetDumpMask(int DumpMask) { this->DumpMask = DumpMask; }
|
void SetDumpMask(int DumpMask) { this->DumpMask = DumpMask; }
|
||||||
void SetIgnoreDecodeErrors(bool IgnoreDecodeErrors) { this->IgnoreDecodeErrors = IgnoreDecodeErrors; }
|
void SetIgnoreDecodeErrors(bool IgnoreDecodeErrors) { this->IgnoreDecodeErrors = IgnoreDecodeErrors; }
|
||||||
|
|
Loading…
Reference in New Issue