History

second commit for threaded decoding support: Add function WelsDecodeAndConstructSlice (and add associted functions) which combines decoding->reconstructing->deblocking in single MB loop so that it allows multile frames to decode MBs in parallel.

xiaotiansf committed 7 years ago

Commit fd42f041 parent 2f5ecec22 files · +924 −190Browse files

Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 22 files). Show all

Unified · Split

codec/decoder/core/src/decoder_core.cpp+83−0
@@ -2211,6 +2211,89 @@ void DecodeFinishUpdate (PWelsDecoderContext pCtx) { · 2210 unmodified lines
22112211 ResetActiveSPSForEachLayer (pCtx);
22122212 }
22132213
2214+/*
2215+* WelsDecodeInitAccessUnitStart
2216+* check and (re)allocate picture buffers on new sequence begin
2217+* bit_len: size in bit length of data
2218+* buf_len: size in byte length of data
2219+* coded_au: mark an Access Unit decoding finished
2220+* return:
2221+* 0 - success; otherwise returned error_no defined in error_no.h
2222+*/
2223+int32_t WelsDecodeInitAccessUnitStart (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo) {
2224+ int32_t iErr = ERR_NONE;
2225+ PAccessUnit pCurAu = pCtx->pAccessUnitList;
2226+ pCtx->bAuReadyFlag = false;
2227+ pCtx->pLastDecPicInfo->bLastHasMmco5 = false;
2228+ bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps (pCtx);
2229+ pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || bTmpNewSeqBegin;
2230+ iErr = WelsDecodeAccessUnitStart (pCtx);
2231+ GetVclNalTemporalId (pCtx);
2232+
2233+ if (ERR_NONE != iErr) {
2234+ ForceResetCurrentAccessUnit (pCtx->pAccessUnitList);
2235+ if (!pCtx->pParam->bParseOnly)
2236+ pDstInfo->iBufferStatus = 0;
2237+ pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin;
2238+ pCtx->bNextNewSeqBegin = false; // reset it
2239+ if (pCtx->bNewSeqBegin)
2240+ ResetActiveSPSForEachLayer (pCtx);
2241+ return iErr;
2242+ }
2243+
2244+ pCtx->pSps = pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
2245+ pCtx->pPps = pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps;
2246+
2247+ return iErr;
2248+}
2249+
2250+/*
2251+* AllocPicBuffOnNewSeqBegin
2252+* check and (re)allocate picture buffers on new sequence begin
2253+* return:
2254+* 0 - success; otherwise returned error_no defined in error_no.h
2255+*/
2256+int32_t AllocPicBuffOnNewSeqBegin (PWelsDecoderContext pCtx) {
2257+ //try to allocate or relocate DPB memory only when new sequence is coming.
2258+ if (pCtx->pThreadCtx == NULL) {
2259+ WelsResetRefPic (pCtx); //clear ref pPic when IDR NAL
2260+ }
2261+ int32_t iErr = SyncPictureResolutionExt (pCtx, pCtx->pSps->iMbWidth, pCtx->pSps->iMbHeight);
2262+
2263+ if (ERR_NONE != iErr) {
2264+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "sync picture resolution ext failed, the error is %d", iErr);
2265+ return iErr;
2266+ }
2267+
2268+ return iErr;
2269+}
2270+
2271+/*
2272+* InitConstructAccessUnit
2273+* Init before constructing an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to
2274+* joint a collective access unit.
2275+* parameter\
2276+* SBufferInfo: Buffer info
2277+* return:
2278+* 0 - success; otherwise returned error_no defined in error_no.h
2279+*/
2280+int32_t InitConstructAccessUnit (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo) {
2281+ int32_t iErr = ERR_NONE;
2282+
2283+ iErr = WelsDecodeInitAccessUnitStart (pCtx, pDstInfo);
2284+ if (ERR_NONE != iErr) {
2285+ return iErr;
2286+ }
2287+ if (pCtx->bNewSeqBegin) {
2288+ iErr = AllocPicBuffOnNewSeqBegin (pCtx);
2289+ if (ERR_NONE != iErr) {
2290+ return iErr;
2291+ }
2292+ }
2293+
2294+ return iErr;
2295+}
2296+
22142297 /*
22152298 * ConstructAccessUnit
22162299 * construct an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t