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 a41e48a159
commit 140dc44882
2 changed files with 22 additions and 14 deletions

View file

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

View file

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