Skip to content

Commit 3d8f971

Browse files
committed
MPCVideoDec: Используем функции "direct" только для аппаратных декодеров "copyback".
Для программного декодера это позволит, например, вместо plane_copy_direct_sse4 использовать функцию plane_copy_sse2, которая не требует выравнивания и соответственно не будет сильно проседать по производительности из-за неудачного стечения обстоятельств.
1 parent 50250b5 commit 3d8f971

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/filters/transform/MPCVideoDec/FormatConverter.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void CFormatConverter::SetConvertFunc()
280280
m_RequiredAlignment = 16;
281281

282282
// optimized direct function
283-
if (CPUInfo::HaveSSE4()) {
283+
if (m_bDirect && CPUInfo::HaveSSE4()) {
284284
if (m_FProps.pftype == PFType_NV12) {
285285
if (m_out_pixfmt == PixFmt_NV12) {
286286
m_pConvertFn = &CFormatConverter::plane_copy_direct_nv12_sse4;
@@ -320,6 +320,8 @@ void CFormatConverter::SetConvertFunc()
320320
return;
321321
}
322322

323+
m_pConvertFn = &CFormatConverter::ConvertGeneric;
324+
323325
// optimized function
324326
switch (m_out_pixfmt) {
325327
case PixFmt_NV12:
@@ -448,13 +450,6 @@ void CFormatConverter::SetConvertFunc()
448450
}
449451
break;
450452
}
451-
452-
if (m_pConvertFn) {
453-
return;
454-
}
455-
456-
m_pConvertFn = &CFormatConverter::ConvertGeneric;
457-
m_RequiredAlignment = 16;
458453
}
459454

460455
void CFormatConverter::UpdateOutput(MPCPixelFormat out_pixfmt, int dstStride, int planeHeight)

src/filters/transform/MPCVideoDec/FormatConverter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class CFormatConverter
148148
// Conversion function pointer
149149
typedef HRESULT (CFormatConverter::*ConverterFn)(CONV_FUNC_PARAMS);
150150
ConverterFn m_pConvertFn = nullptr;
151+
BOOL m_bDirect = FALSE;
151152

152153
// from LAV Filters
153154
HRESULT ConvertGeneric(CONV_FUNC_PARAMS);
@@ -197,6 +198,7 @@ class CFormatConverter
197198
MPCPixelFormat GetOutPixFormat() { return m_out_pixfmt; }
198199

199200
bool Converting(BYTE* dst, AVFrame* pFrame);
201+
void SetDirect(BOOL bDirect) { m_bDirect = bDirect; }
200202

201203
void Cleanup();
202204

src/filters/transform/MPCVideoDec/MPCVideoDec.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,6 +3615,7 @@ HRESULT CMPCVideoDecFilter::DecodeInternal(AVPacket *avpkt, REFERENCE_TIME rtSta
36153615

36163616
if (m_pHWFrame->format == m_HWPixFmt && !DXVAState::GetState()) {
36173617
SetDXVAState();
3618+
m_FormatConverter.SetDirect(TRUE);
36183619
}
36193620
}
36203621

0 commit comments

Comments
 (0)