FFMS2: Another much needed set of fixes to the Haali part

Originally committed to SVN as r2853.
This commit is contained in:
Fredrik Mellbin 2009-04-25 22:09:49 +00:00
parent 3655fbb7fa
commit bc46304aa1
2 changed files with 22 additions and 14 deletions

View File

@ -648,7 +648,6 @@ HaaliVideoSource::HaaliVideoSource(const char *SourceFile, int Track,
throw ErrorMsg; throw ErrorMsg;
} }
BSTR CodecID = NULL;
CodecPrivate = NULL; CodecPrivate = NULL;
int CodecPrivateSize = 0; int CodecPrivateSize = 0;
int CurrentTrack = 0; int CurrentTrack = 0;
@ -663,14 +662,19 @@ HaaliVideoSource::HaaliVideoSource(const char *SourceFile, int Track,
if (pBag) { if (pBag) {
CComVariant pV; CComVariant pV;
if (SUCCEEDED(pBag->Read(L"CodecID", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_BSTR))) pV.Clear();
CodecID = pV.bstrVal;
if (SUCCEEDED(pBag->Read(L"CodecPrivate", &pV, NULL))) { if (SUCCEEDED(pBag->Read(L"CodecPrivate", &pV, NULL))) {
CodecPrivateSize = vtSize(pV); CodecPrivateSize = vtSize(pV);
CodecPrivate = new uint8_t[CodecPrivateSize]; CodecPrivate = new uint8_t[CodecPrivateSize];
vtCopy(pV, CodecPrivate); vtCopy(pV, CodecPrivate);
} }
pV.Clear();
if (SUCCEEDED(pBag->Read(L"CodecID", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_BSTR))) {
char ACodecID[2048];
wcstombs(ACodecID, pV.bstrVal, 2000);
Codec = avcodec_find_decoder(MatroskaToFFCodecID(ACodecID, CodecPrivate));
}
} }
} }
pU = NULL; pU = NULL;
@ -682,9 +686,6 @@ HaaliVideoSource::HaaliVideoSource(const char *SourceFile, int Track,
CodecContext->extradata_size = CodecPrivateSize; CodecContext->extradata_size = CodecPrivateSize;
CodecContext->thread_count = Threads; CodecContext->thread_count = Threads;
char ACodecID[2048];
wcstombs(ACodecID, CodecID, 2000);
Codec = avcodec_find_decoder(MatroskaToFFCodecID(ACodecID, CodecPrivate));
if (Codec == NULL) { if (Codec == NULL) {
Free(false); Free(false);
_snprintf(ErrorMsg, MsgSize, "Video codec not found"); _snprintf(ErrorMsg, MsgSize, "Video codec not found");
@ -738,8 +739,11 @@ HaaliVideoSource::HaaliVideoSource(const char *SourceFile, int Track,
// Set AR variables // Set AR variables
CComVariant pV; CComVariant pV;
pV.Clear();
if (SUCCEEDED(pBag->Read(L"Video.DisplayWidth", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4))) if (SUCCEEDED(pBag->Read(L"Video.DisplayWidth", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
VP.SARNum = pV.uiVal; VP.SARNum = pV.uiVal;
pV.Clear();
if (SUCCEEDED(pBag->Read(L"Video.DisplayHeight", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4))) if (SUCCEEDED(pBag->Read(L"Video.DisplayHeight", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
VP.SARDen = pV.uiVal; VP.SARDen = pV.uiVal;
} }

View File

@ -272,7 +272,7 @@ static FrameIndex *MakeHaaliIndex(const char *SourceFile, int IndexMask, int Dum
CComPtr<IUnknown> pU; CComPtr<IUnknown> pU;
while (pEU->Next(1, &pU, NULL) == S_OK) { while (pEU->Next(1, &pU, NULL) == S_OK) {
CComQIPtr<IPropertyBag> pBag = pU; CComQIPtr<IPropertyBag> pBag = pU;
BSTR CodecID = NULL; AVCodec *CodecID = NULL;
TrackTypes[CurrentTrack] = -200; TrackTypes[CurrentTrack] = -200;
uint8_t * CodecPrivate = NULL; uint8_t * CodecPrivate = NULL;
int CodecPrivateSize = 0; int CodecPrivateSize = 0;
@ -280,17 +280,23 @@ static FrameIndex *MakeHaaliIndex(const char *SourceFile, int IndexMask, int Dum
if (pBag) { if (pBag) {
CComVariant pV; CComVariant pV;
if (SUCCEEDED(pBag->Read(L"CodecID", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_BSTR))) pV.Clear();
CodecID = pV.bstrVal;
if (SUCCEEDED(pBag->Read(L"Type", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4))) if (SUCCEEDED(pBag->Read(L"Type", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
TrackTypes[CurrentTrack] = pV.uintVal; TrackTypes[CurrentTrack] = pV.uintVal;
pV.Clear();
if (SUCCEEDED(pBag->Read(L"CodecPrivate", &pV, NULL))) { if (SUCCEEDED(pBag->Read(L"CodecPrivate", &pV, NULL))) {
CodecPrivateSize = vtSize(pV); CodecPrivateSize = vtSize(pV);
CodecPrivate = new uint8_t[CodecPrivateSize]; CodecPrivate = new uint8_t[CodecPrivateSize];
vtCopy(pV, CodecPrivate); vtCopy(pV, CodecPrivate);
} }
pV.Clear();
if (SUCCEEDED(pBag->Read(L"CodecID", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_BSTR))) {
char ACodecID[2048];
wcstombs(ACodecID, pV.bstrVal, 2000);
CodecID = avcodec_find_decoder(MatroskaToFFCodecID(ACodecID, CodecPrivate));
}
} }
TrackIndices->push_back(FrameInfoVector(1, 1000000000, TrackTypes[CurrentTrack] - 1)); TrackIndices->push_back(FrameInfoVector(1, 1000000000, TrackTypes[CurrentTrack] - 1));
@ -301,9 +307,7 @@ static FrameIndex *MakeHaaliIndex(const char *SourceFile, int IndexMask, int Dum
AudioCodecContext->extradata_size = CodecPrivateSize; AudioCodecContext->extradata_size = CodecPrivateSize;
AudioContexts[CurrentTrack].CTX = AudioCodecContext; AudioContexts[CurrentTrack].CTX = AudioCodecContext;
char ACodecID[2048]; AVCodec *AudioCodec = CodecID;
wcstombs(ACodecID, CodecID, 2000);
AVCodec *AudioCodec = avcodec_find_decoder(MatroskaToFFCodecID(ACodecID, NULL));
if (AudioCodec == NULL) { if (AudioCodec == NULL) {
av_free(AudioCodecContext); av_free(AudioCodecContext);
AudioContexts[CurrentTrack].CTX = NULL; AudioContexts[CurrentTrack].CTX = NULL;