Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 16 files). Show all
Unified · Split
| @@ -521,22 +521,32 @@ int CWelsH264SVCEncoder::EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSIn · 520 unmodified lines | ||
| 521 | 521 | |
| 522 | 522 | |
| 523 | 523 | int CWelsH264SVCEncoder::EncodeFrame2 (const SSourcePicture** pSrcPicList, int nSrcPicNum, SFrameBSInfo* pBsInfo) { |
| 524 | − if (! (pSrcPicList && m_pEncContext && m_bInitialFlag)) { | |
| 524 | + if (!(pSrcPicList && m_pEncContext && m_bInitialFlag) || (nSrcPicNum<=0) ){ | |
| 525 | 525 | return videoFrameTypeInvalid; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | int32_t iFrameTypeReturned = 0; |
| 529 | 529 | int32_t iFrameType = videoFrameTypeInvalid; |
| 530 | + XMMREG_PROTECT_STORE(CWelsH264SVCEncoder); | |
| 531 | + const int32_t kiEncoderReturn = WelsEncoderEncodeExt (m_pEncContext, pBsInfo, pSrcPicList, nSrcPicNum); | |
| 532 | + XMMREG_PROTECT_LOAD(CWelsH264SVCEncoder); | |
| 530 | 533 | |
| 531 | − if (nSrcPicNum > 0) { | |
| 532 | − XMMREG_PROTECT_STORE(CWelsH264SVCEncoder); | |
| 533 | − iFrameTypeReturned = WelsEncoderEncodeExt (m_pEncContext, pBsInfo, pSrcPicList, nSrcPicNum); | |
| 534 | − XMMREG_PROTECT_LOAD(CWelsH264SVCEncoder); | |
| 535 | − } else { | |
| 536 | − assert (0); | |
| 534 | + switch (kiEncoderReturn) { | |
| 535 | + case ENC_RETURN_MEMALLOCERR: | |
| 536 | + WelsUninitEncoderExt (&m_pEncContext); | |
| 537 | + return videoFrameTypeInvalid; | |
| 538 | + case ENC_RETURN_SUCCESS: | |
| 539 | + case ENC_RETURN_CORRECTED: | |
| 540 | + break;//continue processing | |
| 541 | + case ENC_RETURN_UNSUPPORTED_PARA: | |
| 542 | + case ENC_RETURN_UNEXPECTED: | |
| 543 | + return videoFrameTypeInvalid; | |
| 544 | + default: | |
| 545 | + WelsLog (m_pEncContext, WELS_LOG_ERROR, "unexpected return(%d) from WelsEncoderEncodeExt()!\n", kiEncoderReturn); | |
| 537 | 546 | return videoFrameTypeInvalid; |
| 538 | 547 | } |
| 539 | 548 | |
| 549 | + iFrameTypeReturned = pBsInfo->eOutputFrameType; | |
| 540 | 550 | switch (iFrameTypeReturned) { |
| 541 | 551 | case WELS_FRAME_TYPE_P: |
| 542 | 552 | iFrameType = videoFrameTypeP; |
| @@ -832,7 +842,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 289 unmodified lines | ||
| 832 | 842 | return cmInitParaError; |
| 833 | 843 | } |
| 834 | 844 | //adjust to valid range |
| 835 | − m_pEncContext->pSvcParam->fMaxFrameRate = WELS_CLIP3 (iValue, MIN_FRAME_RATE, MAX_FRAME_RATE); | |
| 845 | + m_pEncContext->pSvcParam->fMaxFrameRate = WELS_CLIP3 (iValue, MIN_FRAME_RATE, MAX_FRAME_RATE); | |
| 836 | 846 | WelsEncoderApplyFrameRate (m_pEncContext->pSvcParam); |
| 837 | 847 | } |
| 838 | 848 | break; |