@@ -553,7 +553,9 @@ mfxStatus CEncodingPipeline::InitMfxEncParams(sInputParams *pInParams)
553
553
// frame info parameters
554
554
m_mfxEncParams.mfx .FrameInfo .FourCC = pInParams->EncodeFourCC ;
555
555
m_mfxEncParams.mfx .FrameInfo .ChromaFormat = FourCCToChroma (pInParams->EncodeFourCC );
556
- m_mfxEncParams.mfx .FrameInfo .PicStruct = pInParams->nPicStruct ;
556
+ m_mfxEncParams.mfx .FrameInfo .PicStruct = pInParams->CodecId == MFX_CODEC_HEVC ?
557
+ pInParams->nPicStruct | MFX_PICSTRUCT_FIELD_SINGLE :
558
+ pInParams->nPicStruct ;
557
559
m_mfxEncParams.mfx .FrameInfo .Shift = pInParams->shouldUseShifted10BitEnc ;
558
560
559
561
// width must be a multiple of 16
@@ -2297,6 +2299,7 @@ mfxStatus CEncodingPipeline::VPPOneFrame(const ExtendedSurface& In, ExtendedSurf
2297
2299
}
2298
2300
return sts;
2299
2301
}
2302
+
2300
2303
mfxStatus CEncodingPipeline::EncodeOneFrame (const ExtendedSurface& In, sTask *& pTask)
2301
2304
{
2302
2305
mfxStatus sts = MFX_ERR_NONE;
@@ -2316,6 +2319,13 @@ mfxStatus CEncodingPipeline::EncodeOneFrame(const ExtendedSurface& In, sTask*& p
2316
2319
sts = InitEncFrameParams (pTask);
2317
2320
MSDK_CHECK_STATUS (sts, " ENCODE: InitEncFrameParams failed" );
2318
2321
2322
+ if (In.pSurface && (In.pSurface ->Info .PicStruct & MFX_PICSTRUCT_FIELD_SINGLE) && m_mfxEncParams.mfx .CodecId == MFX_CODEC_HEVC)
2323
+ {
2324
+ // If mfxFrameSurface1::mfxFrameInfo::PicStruct is zero for a particular surface
2325
+ // then encode will internally use MFX_PICSTRUCT_FIELD_TOP or MFX_PICSTRUCT_FIELD_BOTTOM
2326
+ // for that surface depending on initialization picture structure and expected field polarity
2327
+ In.pSurface ->Info .PicStruct = 0 ;
2328
+ }
2319
2329
// at this point surface for encoder contains either a frame from file or a frame processed by vpp/preenc
2320
2330
sts = m_pmfxENC->EncodeFrameAsync (In.pCtrl , In.pSurface , &pTask->mfxBS , &pTask->EncSyncP );
2321
2331
@@ -2486,6 +2496,9 @@ mfxStatus CEncodingPipeline::Run()
2486
2496
bVppMultipleOutput = false ; // reset the flag before a call to VPP
2487
2497
2488
2498
sts = VPPOneFrame (vppSurface, preencSurface, skipLoadingNextFrame);
2499
+
2500
+ skipLoadingNextFrame = false ;
2501
+
2489
2502
// process errors
2490
2503
if (MFX_ERR_MORE_DATA == sts)
2491
2504
{
0 commit comments