[x265] [PATCH 05/10] shifted full resolution functions to lookahead
Anusuya Kumarasamy
anusuya.kumarasamy at multicorewareinc.com
Mon Nov 11 14:15:23 UTC 2024
>From 7b9bf4bc9c5bdfae6aec2d22ab2a8430f9b1603f Mon Sep 17 00:00:00 2001
From: AnusuyaKumarasamy <anusuya.kumarasamy at multicorewareinc.com>
Date: Thu, 24 Oct 2024 17:57:48 +0530
Subject: [PATCH 05/10] shifted full resolution functions to lookahead
---
source/common/frame.cpp | 2 ++
source/common/frame.h | 1 +
source/encoder/encoder.cpp | 17 ++++-------------
source/encoder/slicetype.cpp | 6 +++---
4 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/source/common/frame.cpp b/source/common/frame.cpp
index 80f341edf..63e9b829b 100644
--- a/source/common/frame.cpp
+++ b/source/common/frame.cpp
@@ -91,6 +91,7 @@ bool Frame::create(x265_param *param, float* quantOffsets)
if (m_param->bEnableTemporalFilter)
{
m_mcstf = new TemporalFilter;
+ m_mcstffencPic = new PicYuv;
m_mcstf->m_range = param->mcstfFrameRange;
m_mcstf->init(param);
@@ -105,6 +106,7 @@ bool Frame::create(x265_param *param, float*
quantOffsets)
if (!m_fencPicSubsampled4->createScaledPicYUV(param, 4))
return false;
+ m_mcstffencPic->create(param, !!m_param->bCopyPicToFrame);
CHECKED_MALLOC_ZERO(m_isSubSampled, int, 1);
}
diff --git a/source/common/frame.h b/source/common/frame.h
index e85727deb..588fa6696 100644
--- a/source/common/frame.h
+++ b/source/common/frame.h
@@ -148,6 +148,7 @@ public:
Frame* m_prevMCSTF;
int* m_isSubSampled;
TemporalFilterRefPicInfo
m_mcstfRefList[MAX_MCSTF_TEMPORAL_WINDOW_LENGTH];
+ PicYuv* m_mcstffencPic;
/*Vbv-End-Flag*/
int vbvEndFlag;
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index d75dcafd8..7745a7196 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1409,7 +1409,7 @@ inline int enqueueRefFrame(FrameEncoder*
curframeEncoder, Frame* iterFrame, Fram
{
TemporalFilterRefPicInfo* dest =
&curframeEncoder->m_mcstfRefList[curFrame->m_mcstf->m_numRef];
dest->poc = iterFrame->m_poc;
- dest->picBuffer = iterFrame->m_fencPic;
+ dest->picBuffer = iterFrame->m_mcstffencPic;
dest->picBufferSubSampled2 = iterFrame->m_fencPicSubsampled2;
dest->picBufferSubSampled4 = iterFrame->m_fencPicSubsampled4;
dest->isFilteredFrame = isPreFiltered;
@@ -1418,7 +1418,7 @@ inline int enqueueRefFrame(FrameEncoder*
curframeEncoder, Frame* iterFrame, Fram
TemporalFilterRefPicInfo* temp =
&curFrame->m_mcstfRefList[curFrame->m_mcstf->m_numRef];
temp->poc = iterFrame->m_poc;
- temp->picBuffer = iterFrame->m_fencPic;
+ temp->picBuffer = iterFrame->m_mcstffencPic;
temp->lowres = iterFrame->m_lowres.lowresPlane[0];
temp->lowerRes = iterFrame->m_lowres.lowerResPlane[0];
temp->isFilteredFrame = isPreFiltered;
@@ -1945,6 +1945,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
extendPicBorder(orig->m_picOrg[2], orig->m_strideC,
orig->m_picWidth >> orig->m_hChromaShift, orig->m_picHeight >>
orig->m_vChromaShift, orig->m_chromaMarginX, orig->m_chromaMarginY);
//TODO: Add subsampling here if required
+
inFrame[0]->m_mcstffencPic->copyFromFrame(inFrame[0]->m_fencPic);
m_lookahead->m_origPicBuf->addPicture(inFrame[0]);;
}
@@ -2461,6 +2462,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
Frame* dupFrame =
m_lookahead->m_origPicBuf->m_mcstfOrigPicFreeList.popBackMCSTF();
dupFrame->m_fencPic->copyFromFrame(frameEnc[0]->m_fencPic);
+
dupFrame->m_mcstffencPic->copyFromFrame(frameEnc[0]->m_mcstffencPic);
dupFrame->m_poc = frameEnc[0]->m_poc;
dupFrame->m_encodeOrder = frameEnc[0]->m_encodeOrder;
dupFrame->m_refPicCnt[1] = 2 * dupFrame->m_mcstf->m_range
+ 1;
@@ -2517,17 +2519,6 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
return -1;
}
- for (uint8_t i = 1; i <= frameEnc[0]->m_mcstf->m_numRef;
i++)
- {
- TemporalFilterRefPicInfo* ref =
&frameEnc[0]->m_mcstfRefList[i - 1];
- Frame* curFrame =
m_lookahead->m_origPicBuf->m_mcstfPicList.getPOCMCSTF(ref->poc);
-
- //curFrame->m_mcstf->motionEstimationLuma(ref->mvs0,
ref->mvsStride0, frameEnc[0]->m_lowres.lowerResPlane[0],
(curFrame->m_lowres.lumaStride / 2), (curFrame->m_lowres.lines / 2),
(curFrame->m_lowres.width / 2), ref->lowerRes, 16);
- //curFrame->m_mcstf->motionEstimationLuma(ref->mvs1,
ref->mvsStride1, frameEnc[0]->m_lowres.lowresPlane[0],
(curFrame->m_lowres.lumaStride), (curFrame->m_lowres.lines),
(curFrame->m_lowres.width), ref->lowres, 16, ref->mvs0, ref->mvsStride0, 2);
- curFrame->m_mcstf->motionEstimationLuma(ref->mvs2,
ref->mvsStride2, frameEnc[0]->m_fencPic->m_picOrg[0],
curFrame->m_fencPic->m_stride, curFrame->m_fencPic->m_picHeight,
curFrame->m_fencPic->m_picWidth, ref->picBuffer->m_picOrg[0], 16,
ref->mvs1, ref->mvsStride1, 2);
-
curFrame->m_mcstf->motionEstimationLumaDoubleRes(ref->mvs, ref->mvsStride,
frameEnc[0]->m_fencPic, ref->picBuffer, 8, ref->mvs2, ref->mvsStride2, 1,
ref->error);
- }
-
for (int i = 0; i < frameEnc[0]->m_mcstf->m_numRef; i++)
{
TemporalFilterRefPicInfo* ref =
&frameEnc[0]->m_mcstfRefList[i];
diff --git a/source/encoder/slicetype.cpp b/source/encoder/slicetype.cpp
index 19f6d8f53..bd9f0793a 100644
--- a/source/encoder/slicetype.cpp
+++ b/source/encoder/slicetype.cpp
@@ -1803,8 +1803,8 @@ void Lookahead::estimatelowresmotion(Frame* curframe)
curframe->m_mcstf->motionEstimationLuma(ref->mvs0,
ref->mvsStride0, curframe->m_lowres.lowerResPlane[0],
(curframe->m_lowres.lumaStride / 2), (curframe->m_lowres.lines / 2),
(curframe->m_lowres.width / 2), ref->lowerRes, 16);
curframe->m_mcstf->motionEstimationLuma(ref->mvs1,
ref->mvsStride1, curframe->m_lowres.lowresPlane[0],
(curframe->m_lowres.lumaStride), (curframe->m_lowres.lines),
(curframe->m_lowres.width), ref->lowres, 16, ref->mvs0, ref->mvsStride0, 2);
- //curframe->m_mcstf->motionEstimationLuma(ref->mvs2,
ref->mvsStride2, curframe->m_fencPic->m_picOrg[0],
curframe->m_fencPic->m_stride, curframe->m_fencPic->m_picHeight,
curframe->m_fencPic->m_picWidth, ref->picBuffer->m_picOrg[0], 16,
ref->mvs1, ref->mvsStride1, 2);
- //curframe->m_mcstf->motionEstimationLumaDoubleRes(ref->mvs,
ref->mvsStride, curframe->m_fencPic, ref->picBuffer, 8, ref->mvs2,
ref->mvsStride2, 1, ref->error);
+ curframe->m_mcstf->motionEstimationLuma(ref->mvs2,
ref->mvsStride2, curframe->m_fencPic->m_picOrg[0],
curframe->m_fencPic->m_stride, curframe->m_fencPic->m_picHeight,
curframe->m_fencPic->m_picWidth, ref->picBuffer->m_picOrg[0], 16,
ref->mvs1, ref->mvsStride1, 2);
+ curframe->m_mcstf->motionEstimationLumaDoubleRes(ref->mvs,
ref->mvsStride, curframe->m_fencPic, ref->picBuffer, 8, ref->mvs2,
ref->mvsStride2, 1, ref->error);
}
}
@@ -1813,7 +1813,7 @@ inline int enqueueRefFrame(Frame* iterFrame, Frame*
curFrame, bool isPreFiltered
{
TemporalFilterRefPicInfo * temp =
&curFrame->m_mcstfRefList[curFrame->m_mcstf->m_numRef];
temp->poc = iterFrame->m_poc;
- temp->picBuffer = iterFrame->m_fencPic;
+ temp->picBuffer = iterFrame->m_mcstffencPic;
temp->lowres = iterFrame->m_lowres.lowresPlane[0];
temp->lowerRes = iterFrame->m_lowres.lowerResPlane[0];
temp->isFilteredFrame = isPreFiltered;
--
2.36.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241111/9354f45c/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-shifted-full-resolution-functions-to-lookahead.patch
Type: application/octet-stream
Size: 7680 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241111/9354f45c/attachment-0001.obj>
More information about the x265-devel
mailing list