Skip to content

Commit fcc3939

Browse files
committed
VapourSynth: добавлена поддержка раскладки каналов. Игнорируем аудиопотоки, у которых маска каналов выходит за 32-бита.
Всегда используем WAVEFORMATEXTENSIBLE для медиатипа (так проще). Исправлено описание выходного пина видео.
1 parent 575d0ee commit fcc3939

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

Source/VapourSynthStream.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void CVapourSynthFile::SetVSNodes()
158158

159159
auto ai = m_vsAPI->getAudioInfo(vsNode);
160160

161-
if (ai && ai->format.numChannels > 0 && ai->format.numChannels <= 32) {
161+
if (ai && ai->format.numChannels > 0 && ai->format.numChannels <= 32 && (ai->format.channelLayout & 0xffffffff00000000ui64) == 0) {
162162
m_vsNodeAudio = vsNode;
163163
vsNode = nullptr;
164164
}
@@ -174,8 +174,8 @@ void CVapourSynthFile::SetVSNodes()
174174
//
175175

176176
CVapourSynthVideoStream::CVapourSynthVideoStream(CVapourSynthFile* pVapourSynthFile, CSource* pParent, HRESULT* phr)
177-
: CSourceStream(L"Audio", phr, pParent, L"Audio")
178-
, CSourceSeeking(L"Audio", (IPin*)this, phr, &m_cSharedState)
177+
: CSourceStream(L"Video", phr, pParent, L"Video")
178+
, CSourceSeeking(L"Video", (IPin*)this, phr, &m_cSharedState)
179179
, m_pVapourSynthFile(pVapourSynthFile)
180180
{
181181
CAutoLock cAutoLock(&m_cSharedState);
@@ -686,14 +686,17 @@ CVapourSynthAudioStream::CVapourSynthAudioStream(CVapourSynthFile* pVapourSynthF
686686
m_mt.SetTemporalCompression(FALSE);
687687
m_mt.SetSampleSize(m_BytesPerSample);
688688

689-
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
690-
wfe->wFormatTag = wFormatTag;
691-
wfe->nChannels = m_Channels;
692-
wfe->nSamplesPerSec = m_SampleRate;
693-
wfe->nAvgBytesPerSec = m_BytesPerSample * m_SampleRate;
694-
wfe->nBlockAlign = m_BytesPerSample;
695-
wfe->wBitsPerSample = m_BitDepth;
696-
wfe->cbSize = 0;
689+
WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)m_mt.AllocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
690+
wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
691+
wfex->Format.nChannels = m_Channels;
692+
wfex->Format.nSamplesPerSec = m_SampleRate;
693+
wfex->Format.nAvgBytesPerSec = m_BytesPerSample * m_SampleRate;
694+
wfex->Format.nBlockAlign = m_BytesPerSample;
695+
wfex->Format.wBitsPerSample = m_BitDepth;
696+
wfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); // 22
697+
wfex->Samples.wValidBitsPerSample = m_BitDepth;
698+
wfex->dwChannelMask = (DWORD)m_vsAudioInfo->format.channelLayout;
699+
wfex->SubFormat = m_Subtype;
697700

698701
m_StreamInfo = std::format(L"Audio stream: {} channels, {} Hz, ", m_Channels, m_SampleRate);
699702
if (m_SampleType == stFloat) {

Source/VapourSynthStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class CVapourSynthAudioStream
148148
int m_FrameCounter = 0;
149149
int m_CurrentFrame = 0;
150150

151-
char m_vsErrorMessage[1024];
151+
char m_vsErrorMessage[1024] = {};
152152
std::wstring m_StreamInfo;
153153

154154
public:

0 commit comments

Comments
 (0)