Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions codec/decoder/core/src/manage_dec_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx) {
iPredFrameNum = pRefPicListReorderSyn->sReorderingSyn[listIdx][i].uiLongTermPicNum;
for (j = 0; j < iLongRefCount; j++) {
if (ppLongRefList[j] != NULL) {
if (ppLongRefList[j]->uiLongTermPicNum == (uint32_t)iPredFrameNum) {
if (ppLongRefList[j]->iLongTermFrameIdx == iPredFrameNum) {
ppRefList[iCount++] = ppLongRefList[j];
break;
}
Expand All @@ -566,7 +566,7 @@ int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx) {
k = iCount;
for (j = k; j <= iRefCount; j++) {
if (ppRefList[j] != NULL) {
if (!ppRefList[j]->bIsLongRef || ppRefList[j]->uiLongTermPicNum != (uint32_t)iPredFrameNum)
if (!ppRefList[j]->bIsLongRef || ppRefList[j]->iLongTermFrameIdx != iPredFrameNum)
ppRefList[k++] = ppRefList[j];
}
}
Expand Down
Binary file added res/ltr_reorder_high_cabac.264
Binary file not shown.
1 change: 1 addition & 0 deletions test/api/decoder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ static const FileParam kFileParamArray[] = {
{"res/VID_1280x544_cavlc_temporal_direct.264", "33bfa44b4a3c87fe28354cace1d4b99a03d2967d"},
{"res/VID_1280x720_cavlc_temporal_direct.264", "4face6b5d73a378b6e564a831b49311c230158e4"},
{"res/VID_1920x1080_cavlc_temporal_direct.264", "b35dc99604ea2a1fda5b84d1b9098cb7565dec8f"},
{"res/ltr_reorder_high_cabac.264", "f496a84291950422de2620e6e022a4ac47b099f1"},
};

INSTANTIATE_TEST_CASE_P (DecodeFile, DecoderOutputTest,
Expand Down
36 changes: 36 additions & 0 deletions test/build/win32/codec_ut/codec_unittest.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,42 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\decoder\DecUT_RefListReorder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\codec\api\wels;..\..\..\..\gtest\include;..\..\..\;..\..\..\..\codec\decoder\plus\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\decoder\core\inc;$(NOINHERIT)"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\codec\api\wels;..\..\..\..\gtest\include;..\..\..\;..\..\..\..\codec\decoder\plus\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\decoder\core\inc;$(NOINHERIT)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\codec\api\wels;..\..\..\..\gtest\include;..\..\..\;..\..\..\..\codec\decoder\plus\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\decoder\core\inc;$(NOINHERIT)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\codec\api\wels;..\..\..\..\gtest\include;..\..\..\;..\..\..\..\codec\decoder\plus\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\decoder\core\inc;$(NOINHERIT)"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="processing"
Expand Down
89 changes: 89 additions & 0 deletions test/decoder/DecUT_RefListReorder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <gtest/gtest.h>
#include <cstring>
#include "decoder_context.h"
#include "manage_dec_ref.h"

using namespace WelsDec;

namespace {

const int kLongRefCount = 3;
const int kTargetFrameIdx = 2; // request the long-term reference with iLongTermFrameIdx == 2

class RefListReorderTest : public ::testing::Test {
protected:
virtual void SetUp() {
m_pCtx = new SWelsDecoderContext;
m_pDqLayer = new SDqLayer;
m_pReorder = new SRefPicListReorderSyn;
m_pSps = new SSps;
memset (m_pCtx, 0, sizeof (SWelsDecoderContext));
memset (m_pDqLayer, 0, sizeof (SDqLayer));
memset (m_pReorder, 0, sizeof (SRefPicListReorderSyn));
memset (m_pSps, 0, sizeof (SSps));
memset (m_aPics, 0, sizeof (m_aPics));

// Three long-term references with distinct frame indices but, as MMCO-6 marking produces,
// an identical (zero) uiLongTermPicNum.
for (int i = 0; i < kLongRefCount; ++i) {
m_aPics[i].bIsLongRef = true;
m_aPics[i].iLongTermFrameIdx = i;
m_aPics[i].uiLongTermPicNum = 0;
}

// Reference list starts in default frame-index order [idx0, idx1, idx2].
SRefPic& sRefPic = m_pCtx->sRefPic;
for (int i = 0; i < kLongRefCount; ++i) {
sRefPic.pLongRefList[LIST_0][i] = &m_aPics[i];
sRefPic.pRefList[LIST_0][i] = &m_aPics[i];
}
sRefPic.uiLongRefCount[LIST_0] = kLongRefCount;
sRefPic.uiShortRefCount[LIST_0] = 0;
sRefPic.uiRefCount[LIST_0] = 0;

// A single long-term reorder command requesting long_term_pic_num == kTargetFrameIdx,
// terminated by idc == 3.
m_pReorder->bRefPicListReorderingFlag[LIST_0] = true;
m_pReorder->sReorderingSyn[LIST_0][0].uiReorderingOfPicNumsIdc = 2;
m_pReorder->sReorderingSyn[LIST_0][0].uiLongTermPicNum = kTargetFrameIdx;
m_pReorder->sReorderingSyn[LIST_0][1].uiReorderingOfPicNumsIdc = 3;

m_pDqLayer->pRefPicListReordering = m_pReorder;
PSliceHeader pSliceHeader = &m_pDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader;
pSliceHeader->iFrameNum = 5;
pSliceHeader->uiRefCount[LIST_0] = kLongRefCount;
pSliceHeader->pSps = m_pSps;
m_pSps->uiLog2MaxFrameNum = 4;

m_pCtx->pCurDqLayer = m_pDqLayer;
m_pCtx->eSliceType = P_SLICE;
m_pCtx->iPicQueueNumber = MAX_REF_PIC_COUNT;
}

virtual void TearDown() {
delete m_pSps;
delete m_pReorder;
delete m_pDqLayer;
delete m_pCtx;
}

PWelsDecoderContext m_pCtx;
PDqLayer m_pDqLayer;
PRefPicListReorderSyn m_pReorder;
PSps m_pSps;
SPicture m_aPics[kLongRefCount];
};

// The long-term reorder command asks for the reference with LongTermFrameIdx == 2 to be placed
// first.
TEST_F (RefListReorderTest, LongTermReorderMatchesByFrameIdx) {
int32_t iRet = WelsReorderRefList2 (m_pCtx);
ASSERT_EQ (iRet, ERR_NONE);

PPicture pFirst = m_pCtx->sRefPic.pRefList[LIST_0][0];
ASSERT_TRUE (pFirst != NULL);
EXPECT_TRUE (pFirst->bIsLongRef);
EXPECT_EQ (pFirst->iLongTermFrameIdx, kTargetFrameIdx);
}

} // anonymous namespace
1 change: 1 addition & 0 deletions test/decoder/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test_sources = [
'DecUT_IntraPrediction.cpp',
'DecUT_ParseSyntax.cpp',
'DecUT_PredMv.cpp',
'DecUT_RefListReorder.cpp',
]

e = executable('test_decoder', test_sources,
Expand Down
1 change: 1 addition & 0 deletions test/decoder/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DECODER_UNITTEST_CPP_SRCS=\
$(DECODER_UNITTEST_SRCDIR)/DecUT_IntraPrediction.cpp\
$(DECODER_UNITTEST_SRCDIR)/DecUT_ParseSyntax.cpp\
$(DECODER_UNITTEST_SRCDIR)/DecUT_PredMv.cpp\
$(DECODER_UNITTEST_SRCDIR)/DecUT_RefListReorder.cpp\

DECODER_UNITTEST_OBJS += $(DECODER_UNITTEST_CPP_SRCS:.cpp=.$(OBJ))

Expand Down