[x265] [PATCH 11/14] Cleanup
Snehaa Giridharan
snehaa at multicorewareinc.com
Wed Oct 19 07:31:46 UTC 2022
>From b896548fe4b38f2f32596d423b13362c6d31f79f Mon Sep 17 00:00:00 2001
From: ashok2022 <ashok at multicorewareinc.com>
Date: Thu, 13 Oct 2022 23:31:15 +0530
Subject: [PATCH] Cleanup
---
source/common/common.h | 2 +-
source/common/frame.cpp | 4 +-
source/common/param.cpp | 16 +++---
source/common/slice.h | 2 +-
source/common/temporalfilter.cpp | 92 +++++++++++++++-----------------
source/common/temporalfilter.h | 38 +++++--------
source/encoder/dpb.cpp | 4 +-
source/encoder/encoder.cpp | 84 ++++++++++++++---------------
source/encoder/encoder.h | 2 +-
source/encoder/frameencoder.cpp | 19 ++++---
source/encoder/frameencoder.h | 2 +-
source/x265.h | 2 +-
source/x265cli.cpp | 2 +-
source/x265cli.h | 4 +-
14 files changed, 129 insertions(+), 144 deletions(-)
diff --git a/source/common/common.h b/source/common/common.h
index 982b03d89..f115d6a24 100644
--- a/source/common/common.h
+++ b/source/common/common.h
@@ -342,7 +342,7 @@ typedef int16_t coeff_t; // transform coefficient
#define MAX_NUM_DYN_REFINE (NUM_CU_DEPTH *
X265_REFINE_INTER_LEVELS)
#define X265_BYTE 8
-#define MAX_MCTF_TEMPORAL_WINDOW_LENGTH 8
+#define MAX_MCSTF_TEMPORAL_WINDOW_LENGTH 8
namespace X265_NS {
diff --git a/source/common/frame.cpp b/source/common/frame.cpp
index 0ce301bfa..9de3495cb 100644
--- a/source/common/frame.cpp
+++ b/source/common/frame.cpp
@@ -80,7 +80,7 @@ bool Frame::create(x265_param *param, float* quantOffsets)
m_fencPic = new PicYuv;
m_param = param;
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
m_mcstf = new TemporalFilter;
m_mcstf->init(param);
@@ -251,7 +251,7 @@ void Frame::destroy()
m_fencPic = NULL;
}
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
if (m_fencPicSubsampled2)
diff --git a/source/common/param.cpp b/source/common/param.cpp
index 0bc9f7f74..262f401fa 100755
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -380,8 +380,8 @@ void x265_param_default(x265_param* param)
param->bEnableSvtHevc = 0;
param->svtHevcParam = NULL;
- /* MCTF */
- param->bEnableGopBasedTemporalFilter = 0;
+ /* MCSTF */
+ param->bEnableTemporalFilter = 0;
param->temporalFilterStrength = 0.95;
#ifdef SVT_HEVC
@@ -1468,7 +1468,7 @@ int x265_param_parse(x265_param* p, const char* name,
const char* value)
OPT("eos") p->bEnableEndOfSequence = atobool(value);
/* Film grain characterstics model filename */
OPT("film-grain") p->filmGrain = (char* )value;
- OPT("mctf") p->bEnableGopBasedTemporalFilter = atobool(value);
+ OPT("mcstf") p->bEnableTemporalFilter = atobool(value);
else
return X265_PARAM_BAD_NAME;
}
@@ -1921,10 +1921,10 @@ int x265_check_params(x265_param* param)
param->bSingleSeiNal = 0;
x265_log(param, X265_LOG_WARNING, "None of the SEI messages are
enabled. Disabling Single SEI NAL\n");
}
- if (param->bEnableGopBasedTemporalFilter && (param->frameNumThreads >
1))
+ if (param->bEnableTemporalFilter && (param->frameNumThreads > 1))
{
- param->bEnableGopBasedTemporalFilter = 0;
- x265_log(param, X265_LOG_WARNING, "MCTF can be enabled with frame
thread = 1 only. Disabling MCTF\n");
+ param->bEnableTemporalFilter = 0;
+ x265_log(param, X265_LOG_WARNING, "MCSTF can be enabled with frame
thread = 1 only. Disabling MCSTF\n");
}
CHECK(param->confWinRightOffset < 0, "Conformance Window Right Offset
must be 0 or greater");
CHECK(param->confWinBottomOffset < 0, "Conformance Window Bottom
Offset must be 0 or greater");
@@ -2369,7 +2369,7 @@ char *x265_param2string(x265_param* p, int padx, int
pady)
BOOL(p->bliveVBV2pass, "vbv-live-multi-pass");
if (p->filmGrain)
s += sprintf(s, " film-grain=%s", p->filmGrain); // Film grain
characteristics model filename
- BOOL(p->bEnableGopBasedTemporalFilter, "mctf");
+ BOOL(p->bEnableTemporalFilter, "mcstf");
#undef BOOL
return buf;
}
@@ -2733,7 +2733,7 @@ void x265_copy_params(x265_param* dst, x265_param*
src)
dst->bwdRefQpDelta = src->bwdRefQpDelta;
dst->bwdNonRefQpDelta = src->bwdNonRefQpDelta;
dst->bField = src->bField;
- dst->bEnableGopBasedTemporalFilter =
src->bEnableGopBasedTemporalFilter;
+ dst->bEnableTemporalFilter = src->bEnableTemporalFilter;
dst->temporalFilterStrength = src->temporalFilterStrength;
dst->confWinRightOffset = src->confWinRightOffset;
dst->confWinBottomOffset = src->confWinBottomOffset;
diff --git a/source/common/slice.h b/source/common/slice.h
index c5327c198..9b7cb0bed 100644
--- a/source/common/slice.h
+++ b/source/common/slice.h
@@ -363,7 +363,7 @@ public:
int m_iNumRPSInSPS;
const x265_param *m_param;
int m_fieldNum;
- Frame* m_mcstfRefFrameList[2][MAX_MCTF_TEMPORAL_WINDOW_LENGTH];
+ Frame* m_mcstfRefFrameList[2][MAX_MCSTF_TEMPORAL_WINDOW_LENGTH];
Slice()
{
diff --git a/source/common/temporalfilter.cpp
b/source/common/temporalfilter.cpp
index a937e2a67..f3e2dc73c 100644
--- a/source/common/temporalfilter.cpp
+++ b/source/common/temporalfilter.cpp
@@ -67,8 +67,8 @@ void OrigPicBuffer::setOrigPicList(Frame* inFrame, int
frameCnt)
{
Slice* slice = inFrame->m_encData->m_slice;
uint8_t j = 0;
- for (int iterPOC = (inFrame->m_poc - inFrame->m_mcstf->s_range);
- iterPOC <= (inFrame->m_poc + inFrame->m_mcstf->s_range); iterPOC++)
+ for (int iterPOC = (inFrame->m_poc - inFrame->m_mcstf->m_range);
+ iterPOC <= (inFrame->m_poc + inFrame->m_mcstf->m_range); iterPOC++)
{
if (iterPOC != inFrame->m_poc)
{
@@ -137,22 +137,19 @@ void OrigPicBuffer::addPictureToFreelist(Frame*
inFrame)
m_mcstfOrigPicFreeList.pushBack(*inFrame);
}
-TemporalFilter::TemporalFilter() {
- m_FrameSkip = 0;
+TemporalFilter::TemporalFilter()
+{
m_sourceWidth = 0;
m_sourceHeight = 0,
m_QP = 0;
- m_GOPSize = 0;
- m_framesToBeEncoded = 0;
m_sliceTypeConfig = 3;
m_numRef = 0;
- s_range = 2;
- s_chromaFactor = 0.55;
- s_sigmaMultiplier = 9.0;
- s_sigmaZeroPoint = 10.0;
- s_motionVectorFactor = 16;
- s_padding = 128;
+ m_range = 2;
+ m_chromaFactor = 0.55;
+ m_sigmaMultiplier = 9.0;
+ m_sigmaZeroPoint = 10.0;
+ m_motionVectorFactor = 16;
}
void TemporalFilter::init(const x265_param* param)
@@ -169,7 +166,7 @@ void TemporalFilter::init(const x265_param* param)
predPUYuv.create(FENC_STRIDE, X265_CSP_I400);
}
-int TemporalFilter::createRefPicInfo(MCTFReferencePicInfo* refFrame,
x265_param* param)
+int TemporalFilter::createRefPicInfo(TemporalFilterRefPicInfo* refFrame,
x265_param* param)
{
CHECKED_MALLOC_ZERO(refFrame->mvs, MV, sizeof(MV)* ((m_sourceWidth ) /
4) * ((m_sourceHeight ) / 4));
refFrame->mvsStride = m_sourceWidth / 4;
@@ -211,8 +208,8 @@ int TemporalFilter::motionErrorLuma(
int error = 0;// dx * 10 + dy * 10;
if (((dx | dy) & 0xF) == 0)
{
- dx /= s_motionVectorFactor;
- dy /= s_motionVectorFactor;
+ dx /= m_motionVectorFactor;
+ dy /= m_motionVectorFactor;
const pixel* bufferRowStart = buffOrigin + (y + dy) * buffStride +
(x + dx);
#if 0
@@ -311,7 +308,7 @@ void TemporalFilter::applyMotion(MV *mvs, uint32_t
mvsStride, PicYuv *input, Pic
const pixel *pSrcImage = input->m_picOrg[c];
pixel *pDstImage = output->m_picOrg[c];
- if (c == 0)
+ if (!c)
{
srcStride = (int)input->m_stride;
dstStride = (int)output->m_stride;
@@ -397,7 +394,7 @@ void TemporalFilter::applyMotion(MV *mvs, uint32_t
mvsStride, PicYuv *input, Pic
* Old Version: bilateralFilter
*/
void TemporalFilter::bilateralFilter(Frame* frame,
- MCTFReferencePicInfo* m_mctfRefList,
+ TemporalFilterRefPicInfo* m_mcstfRefList,
double overallStrength)
{
@@ -405,21 +402,21 @@ void TemporalFilter::bilateralFilter(Frame* frame,
for (int i = 0; i < numRefs; i++)
{
- MCTFReferencePicInfo *ref = &m_mctfRefList[i];
- applyMotion(m_mctfRefList[i].mvs, m_mctfRefList[i].mvsStride,
m_mctfRefList[i].picBuffer, ref->compensatedPic);
+ TemporalFilterRefPicInfo *ref = &m_mcstfRefList[i];
+ applyMotion(m_mcstfRefList[i].mvs, m_mcstfRefList[i].mvsStride,
m_mcstfRefList[i].picBuffer, ref->compensatedPic);
}
int refStrengthRow = 2;
- if (numRefs == s_range * 2)
+ if (numRefs == m_range * 2)
{
refStrengthRow = 0;
}
- else if (numRefs == s_range)
+ else if (numRefs == m_range)
{
refStrengthRow = 1;
}
- const double lumaSigmaSq = (m_QP - s_sigmaZeroPoint) * (m_QP -
s_sigmaZeroPoint) * s_sigmaMultiplier;
+ const double lumaSigmaSq = (m_QP - m_sigmaZeroPoint) * (m_QP -
m_sigmaZeroPoint) * m_sigmaMultiplier;
const double chromaSigmaSq = 30 * 30;
PicYuv* orgPic = frame->m_fencPic;
@@ -430,7 +427,7 @@ void TemporalFilter::bilateralFilter(Frame* frame,
pixel *srcPelRow = NULL;
intptr_t srcStride, correctedPicsStride = 0;
- if (c == 0)
+ if (!c)
{
height = orgPic->m_picHeight;
width = orgPic->m_picWidth;
@@ -449,12 +446,12 @@ void TemporalFilter::bilateralFilter(Frame* frame,
}
const double sigmaSq = (!c) ? lumaSigmaSq : chromaSigmaSq;
- const double weightScaling = overallStrength * ((!c) ? 0.4 :
s_chromaFactor);
+ const double weightScaling = overallStrength * ((!c) ? 0.4 :
m_chromaFactor);
const pixel maxSampleValue = (1 << m_bitDepth) - 1;
const double bitDepthDiffWeighting = 1024.0 / (maxSampleValue + 1);
- for (int y = 0; y < height; y++, srcPelRow += srcStride/*,
dstPelRow += dstStride*/)
+ for (int y = 0; y < height; y++, srcPelRow += srcStride)
{
pixel *srcPel = srcPelRow;
@@ -466,9 +463,9 @@ void TemporalFilter::bilateralFilter(Frame* frame,
for (int i = 0; i < numRefs; i++)
{
- MCTFReferencePicInfo *refPicInfo = &m_mctfRefList[i];
+ TemporalFilterRefPicInfo *refPicInfo =
&m_mcstfRefList[i];
- if (c == 0)
+ if (!c)
correctedPicsStride =
refPicInfo->compensatedPic->m_stride;
else
correctedPicsStride =
refPicInfo->compensatedPic->m_strideC;
@@ -488,7 +485,6 @@ void TemporalFilter::bilateralFilter(Frame* frame,
newVal /= temporalWeightSum;
pixel sampleVal = (pixel)round(newVal);
sampleVal = (sampleVal < 0 ? 0 : (sampleVal >
maxSampleValue ? maxSampleValue : sampleVal));
- //*dstPel = sampleVal;
*srcPel = sampleVal;
}
}
@@ -501,7 +497,7 @@ void TemporalFilter::bilateralFilter(Frame* frame,
* New Version: bilateralFilter
*/
void TemporalFilter::bilateralFilter(Frame* frame,
- MCTFReferencePicInfo* m_mctfRefList,
+ TemporalFilterRefPicInfo* m_mcstfRefList,
double overallStrength)
{
@@ -509,21 +505,21 @@ void TemporalFilter::bilateralFilter(Frame* frame,
for (int i = 0; i < numRefs; i++)
{
- MCTFReferencePicInfo *ref = &m_mctfRefList[i];
- applyMotion(m_mctfRefList[i].mvs, m_mctfRefList[i].mvsStride,
m_mctfRefList[i].picBuffer, ref->compensatedPic);
+ TemporalFilterRefPicInfo *ref = &m_mcstfRefList[i];
+ applyMotion(m_mcstfRefList[i].mvs, m_mcstfRefList[i].mvsStride,
m_mcstfRefList[i].picBuffer, ref->compensatedPic);
}
int refStrengthRow = 2;
- if (numRefs == s_range * 2)
+ if (numRefs == m_range * 2)
{
refStrengthRow = 0;
}
- else if (numRefs == s_range)
+ else if (numRefs == m_range)
{
refStrengthRow = 1;
}
- const double lumaSigmaSq = (m_QP - s_sigmaZeroPoint) * (m_QP -
s_sigmaZeroPoint) * s_sigmaMultiplier;
+ const double lumaSigmaSq = (m_QP - m_sigmaZeroPoint) * (m_QP -
m_sigmaZeroPoint) * m_sigmaMultiplier;
const double chromaSigmaSq = 30 * 30;
PicYuv* orgPic = frame->m_fencPic;
@@ -534,7 +530,7 @@ void TemporalFilter::bilateralFilter(Frame* frame,
pixel *srcPelRow = NULL;
intptr_t srcStride, correctedPicsStride = 0;
- if (c == 0)
+ if (!c)
{
height = orgPic->m_picHeight;
width = orgPic->m_picWidth;
@@ -553,7 +549,7 @@ void TemporalFilter::bilateralFilter(Frame* frame,
}
const double sigmaSq = (!c) ? lumaSigmaSq : chromaSigmaSq;
- const double weightScaling = overallStrength * ( (!c) ? 0.4 :
s_chromaFactor);
+ const double weightScaling = overallStrength * ( (!c) ? 0.4 :
m_chromaFactor);
const pixel maxSampleValue = (1 << m_bitDepth) - 1;
const double bitDepthDiffWeighting = 1024.0 / (maxSampleValue + 1);
@@ -574,7 +570,7 @@ void TemporalFilter::bilateralFilter(Frame* frame,
{
for (int i = 0; i < numRefs; i++)
{
- MCTFReferencePicInfo *refPicInfo =
&m_mctfRefList[i];
+ TemporalFilterRefPicInfo *refPicInfo =
&m_mcstfRefList[i];
if (!c)
correctedPicsStride =
refPicInfo->compensatedPic->m_stride;
@@ -611,13 +607,13 @@ void TemporalFilter::bilateralFilter(Frame* frame,
double minError = 9999999;
for (int i = 0; i < numRefs; i++)
{
- MCTFReferencePicInfo *refPicInfo = &m_mctfRefList[i];
+ TemporalFilterRefPicInfo *refPicInfo =
&m_mcstfRefList[i];
minError = X265_MIN(minError,
(double)refPicInfo->error[(y / blkSize) * refPicInfo->mvsStride + (x /
blkSize)]);
}
for (int i = 0; i < numRefs; i++)
{
- MCTFReferencePicInfo *refPicInfo = &m_mctfRefList[i];
+ TemporalFilterRefPicInfo *refPicInfo =
&m_mcstfRefList[i];
const int error = refPicInfo->error[(y / blkSize) *
refPicInfo->mvsStride + (x / blkSize)];
const int noise = refPicInfo->noise[(y / blkSize) *
refPicInfo->mvsStride + (x / blkSize)];
@@ -826,14 +822,14 @@ void TemporalFilter::motionEstimationLuma(MV *mvs,
uint32_t mvStride, PicYuv *or
}
MV prevBest = best;
- for (int y2 = prevBest.y / s_motionVectorFactor - range; y2 <=
prevBest.y / s_motionVectorFactor + range; y2++)
+ for (int y2 = prevBest.y / m_motionVectorFactor - range; y2 <=
prevBest.y / m_motionVectorFactor + range; y2++)
{
- for (int x2 = prevBest.x / s_motionVectorFactor - range;
x2 <= prevBest.x / s_motionVectorFactor + range; x2++)
+ for (int x2 = prevBest.x / m_motionVectorFactor - range;
x2 <= prevBest.x / m_motionVectorFactor + range; x2++)
{
- int error = motionErrorLuma(orig, buffer, blockX,
blockY, x2 * s_motionVectorFactor, y2 * s_motionVectorFactor, blockSize,
leastError);
+ int error = motionErrorLuma(orig, buffer, blockX,
blockY, x2 * m_motionVectorFactor, y2 * m_motionVectorFactor, blockSize,
leastError);
if (error < leastError)
{
- best.set(x2 * s_motionVectorFactor, y2 *
s_motionVectorFactor);
+ best.set(x2 * m_motionVectorFactor, y2 *
m_motionVectorFactor);
leastError = error;
}
}
@@ -958,14 +954,14 @@ void TemporalFilter::motionEstimationLumaDoubleRes(MV
*mvs, uint32_t mvStride, P
}
MV prevBest = best;
- for (int y2 = prevBest.y / s_motionVectorFactor - range; y2 <=
prevBest.y / s_motionVectorFactor + range; y2++)
+ for (int y2 = prevBest.y / m_motionVectorFactor - range; y2 <=
prevBest.y / m_motionVectorFactor + range; y2++)
{
- for (int x2 = prevBest.x / s_motionVectorFactor - range;
x2 <= prevBest.x / s_motionVectorFactor + range; x2++)
+ for (int x2 = prevBest.x / m_motionVectorFactor - range;
x2 <= prevBest.x / m_motionVectorFactor + range; x2++)
{
- int error = motionErrorLuma(orig, buffer, blockX,
blockY, x2 * s_motionVectorFactor, y2 * s_motionVectorFactor, blockSize,
leastError);
+ int error = motionErrorLuma(orig, buffer, blockX,
blockY, x2 * m_motionVectorFactor, y2 * m_motionVectorFactor, blockSize,
leastError);
if (error < leastError)
{
- best.set(x2 * s_motionVectorFactor, y2 *
s_motionVectorFactor);
+ best.set(x2 * m_motionVectorFactor, y2 *
m_motionVectorFactor);
leastError = error;
}
}
@@ -1087,7 +1083,7 @@ void TemporalFilter::subsampleLuma(PicYuv *input,
PicYuv *output, int factor)
extendPicBorder(output->m_picOrg[0], output->m_stride,
output->m_picWidth, output->m_picHeight, output->m_lumaMarginX,
output->m_lumaMarginY);
}
-void TemporalFilter::destroyRefPicInfo(MCTFReferencePicInfo* curFrame)
+void TemporalFilter::destroyRefPicInfo(TemporalFilterRefPicInfo* curFrame)
{
if (curFrame)
{
diff --git a/source/common/temporalfilter.h b/source/common/temporalfilter.h
index 801359914..bdefa2824 100644
--- a/source/common/temporalfilter.h
+++ b/source/common/temporalfilter.h
@@ -1,6 +1,8 @@
/*****************************************************************************
* Copyright (C) 2013-2021 MulticoreWare, Inc
*
+ * Authors: Ashok Kumar Mishra <ashok at multicorewareinc.com>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -88,13 +90,6 @@ public:
void addEncPictureToPicList(Frame*);
};
-struct TemporalFilterRefPicInfo
-{
- PicYuv* picBuffer;
- MV* mvs;
- int origOffset;
-};
-
struct MotionEstimatorTLD
{
MotionEstimate me;
@@ -108,7 +103,7 @@ struct MotionEstimatorTLD
~MotionEstimatorTLD() {}
};
-struct MCTFReferencePicInfo
+struct TemporalFilterRefPicInfo
{
PicYuv* picBuffer;
PicYuv* picBufferSubSampled2;
@@ -145,25 +140,20 @@ public:
// Private static member variables
const x265_param *m_param;
int32_t m_bitDepth;
- int s_range;
+ int m_range;
uint8_t m_numRef;
- double s_chromaFactor;
- double s_sigmaMultiplier;
- double s_sigmaZeroPoint;
- int s_motionVectorFactor;
- int s_padding;
+ double m_chromaFactor;
+ double m_sigmaMultiplier;
+ double m_sigmaZeroPoint;
+ int m_motionVectorFactor;
+ int m_padding;
// Private member variables
- int m_FrameSkip;
+
int m_sourceWidth;
int m_sourceHeight;
int m_QP;
- int m_GOPSize;
- int m_aiPad[2];
- int m_framesToBeEncoded;
- bool m_bClipInputVideoToRec709Range;
- bool m_gopBasedTemporalFilterFutureReference;
int m_internalCsp;
int m_numComponents;
uint8_t m_sliceTypeConfig;
@@ -173,14 +163,14 @@ public:
void subsampleLuma(PicYuv *input, PicYuv *output, int factor = 2);
- int createRefPicInfo(MCTFReferencePicInfo* refFrame, x265_param*
param);
+ int createRefPicInfo(TemporalFilterRefPicInfo* refFrame, x265_param*
param);
- void bilateralFilter(Frame* frame, MCTFReferencePicInfo* mctfRefList,
double overallStrength);
+ void bilateralFilter(Frame* frame, TemporalFilterRefPicInfo*
mctfRefList, double overallStrength);
void motionEstimationLuma(MV *mvs, uint32_t mvStride, PicYuv *orig,
PicYuv *buffer, int bs,
MV *previous = 0, uint32_t prevmvStride = 0, int factor = 1);
- void TemporalFilter::motionEstimationLumaDoubleRes(MV *mvs, uint32_t
mvStride, PicYuv *orig, PicYuv *buffer, int blockSize,
+ void motionEstimationLumaDoubleRes(MV *mvs, uint32_t mvStride, PicYuv
*orig, PicYuv *buffer, int blockSize,
MV *previous, uint32_t prevMvStride, int factor, int* minError);
int motionErrorLuma(PicYuv *orig,
@@ -192,7 +182,7 @@ public:
int bs,
int besterror = 8 * 8 * 1024 * 1024);
- void destroyRefPicInfo(MCTFReferencePicInfo* curFrame);
+ void destroyRefPicInfo(TemporalFilterRefPicInfo* curFrame);
void applyMotion(MV *mvs, uint32_t mvsStride, PicYuv *input, PicYuv
*output);
diff --git a/source/encoder/dpb.cpp b/source/encoder/dpb.cpp
index 2fdcd6a92..9292b6c75 100644
--- a/source/encoder/dpb.cpp
+++ b/source/encoder/dpb.cpp
@@ -72,14 +72,14 @@ void DPB::recycleUnreferenced()
iterFrame = iterFrame->m_next;
bool isMCSTFReferenced = false;
- if (curFrame->m_param->bEnableGopBasedTemporalFilter)
+ if (curFrame->m_param->bEnableTemporalFilter)
isMCSTFReferenced = curFrame->m_refPicCnt[1];
if (!curFrame->m_encData->m_bHasReferences &&
!curFrame->m_countRefEncoders && !isMCSTFReferenced)
{
curFrame->m_bChromaExtended = false;
- if (curFrame->m_param->bEnableGopBasedTemporalFilter)
+ if (curFrame->m_param->bEnableTemporalFilter)
*curFrame->m_isSubSampled = false;
// Reset column counter
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index 53094cdf1..47a9913bc 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -393,7 +393,7 @@ void Encoder::create()
m_lookahead->m_numPools = pools;
m_dpb = new DPB(m_param);
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
m_origPicBuffer = new OrigPicBuffer();
m_rateControl = new RateControl(*m_param, this);
@@ -973,7 +973,7 @@ void Encoder::destroy()
delete[] zoneWriteCount;
}
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
delete m_origPicBuffer;
if (m_rateControl)
@@ -1647,7 +1647,7 @@ bool Encoder::isFilterThisframe(uint8_t
sliceTypeConfig, int curSliceType)
inline int enqueueRefFrame(FrameEncoder* curframeEncoder, Frame*
iterFrame, Frame* curFrame, bool isPreFiltered, int16_t i)
{
- MCTFReferencePicInfo* dest =
&curframeEncoder->m_mcstfRefList[curFrame->m_mcstf->m_numRef];
+ TemporalFilterRefPicInfo* dest =
&curframeEncoder->m_mcstfRefList[curFrame->m_mcstf->m_numRef];
dest->picBuffer = iterFrame->m_fencPic;
dest->picBufferSubSampled2 = iterFrame->m_fencPicSubsampled2;
dest->picBufferSubSampled4 = iterFrame->m_fencPicSubsampled4;
@@ -1659,12 +1659,12 @@ inline int enqueueRefFrame(FrameEncoder*
curframeEncoder, Frame* iterFrame, Fram
return 1;
}
-bool Encoder::generateMctfRef(Frame* frameEnc, FrameEncoder* currEncoder)
+bool Encoder::generateMcstfRef(Frame* frameEnc, FrameEncoder* currEncoder)
{
frameEnc->m_mcstf->m_numRef = 0;
- for (int iterPOC = (frameEnc->m_poc - frameEnc->m_mcstf->s_range);
- iterPOC <= (frameEnc->m_poc + frameEnc->m_mcstf->s_range);
iterPOC++)
+ for (int iterPOC = (frameEnc->m_poc - frameEnc->m_mcstf->m_range);
+ iterPOC <= (frameEnc->m_poc + frameEnc->m_mcstf->m_range);
iterPOC++)
{
bool isFound = false;
if (iterPOC != frameEnc->m_poc)
@@ -1672,24 +1672,24 @@ bool Encoder::generateMctfRef(Frame* frameEnc,
FrameEncoder* currEncoder)
//search for the reference frame in the Original Picture Buffer
if (!isFound)
{
- for (int j = 0; j < (2 * frameEnc->m_mcstf->s_range); j++)
+ for (int j = 0; j < (2 * frameEnc->m_mcstf->m_range); j++)
{
if (iterPOC < 0)
continue;
if (iterPOC >= m_pocLast)
{
- TemporalFilter* mctf = frameEnc->m_mcstf;
- while (mctf->m_numRef)
+ TemporalFilter* mcstf = frameEnc->m_mcstf;
+ while (mcstf->m_numRef)
{
-
memset(currEncoder->m_mcstfRefList[mctf->m_numRef].mvs0, 0, sizeof(MV) *
((mctf->m_sourceWidth / 16) * (mctf->m_sourceHeight / 16)));
-
memset(currEncoder->m_mcstfRefList[mctf->m_numRef].mvs1, 0, sizeof(MV) *
((mctf->m_sourceWidth / 16) * (mctf->m_sourceHeight / 16)));
-
memset(currEncoder->m_mcstfRefList[mctf->m_numRef].mvs2, 0, sizeof(MV) *
((mctf->m_sourceWidth / 16) * (mctf->m_sourceHeight / 16)));
-
memset(currEncoder->m_mcstfRefList[mctf->m_numRef].mvs, 0, sizeof(MV) *
((mctf->m_sourceWidth / 4) * (mctf->m_sourceHeight / 4)));
-
memset(currEncoder->m_mcstfRefList[mctf->m_numRef].noise, 0, sizeof(int) *
((mctf->m_sourceWidth / 4) * (mctf->m_sourceHeight / 4)));
-
memset(currEncoder->m_mcstfRefList[mctf->m_numRef].error, 0, sizeof(int) *
((mctf->m_sourceWidth / 4) * (mctf->m_sourceHeight / 4)));
-
- mctf->m_numRef--;
+
memset(currEncoder->m_mcstfRefList[mcstf->m_numRef].mvs0, 0, sizeof(MV) *
((mcstf->m_sourceWidth / 16) * (mcstf->m_sourceHeight / 16)));
+
memset(currEncoder->m_mcstfRefList[mcstf->m_numRef].mvs1, 0, sizeof(MV) *
((mcstf->m_sourceWidth / 16) * (mcstf->m_sourceHeight / 16)));
+
memset(currEncoder->m_mcstfRefList[mcstf->m_numRef].mvs2, 0, sizeof(MV) *
((mcstf->m_sourceWidth / 16) * (mcstf->m_sourceHeight / 16)));
+
memset(currEncoder->m_mcstfRefList[mcstf->m_numRef].mvs, 0, sizeof(MV) *
((mcstf->m_sourceWidth / 4) * (mcstf->m_sourceHeight / 4)));
+
memset(currEncoder->m_mcstfRefList[mcstf->m_numRef].noise, 0, sizeof(int) *
((mcstf->m_sourceWidth / 4) * (mcstf->m_sourceHeight / 4)));
+
memset(currEncoder->m_mcstfRefList[mcstf->m_numRef].error, 0, sizeof(int) *
((mcstf->m_sourceWidth / 4) * (mcstf->m_sourceHeight / 4)));
+
+ mcstf->m_numRef--;
}
break;
@@ -1752,7 +1752,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
m_exportedPic = NULL;
m_dpb->recycleUnreferenced();
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
m_origPicBuffer->recycleOrigPicList();
}
@@ -2125,12 +2125,12 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
if (m_reconfigureRc)
inFrame->m_reconfigureRc = true;
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
if (!m_pocLast)
{
/*One shot allocation of frames in OriginalPictureBuffer*/
- int numFramesinOPB = X265_MAX(m_param->bframes,
(inFrame->m_mcstf->s_range << 1)) + 1;
+ int numFramesinOPB = X265_MAX(m_param->bframes,
(inFrame->m_mcstf->m_range << 1)) + 1;
for (int i = 0; i < numFramesinOPB; i++)
{
Frame* dupFrame = new Frame;
@@ -2162,11 +2162,11 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
}
}
- inFrame->m_refPicCnt[1] = 2 * inFrame->m_mcstf->s_range + 1;
- if (inFrame->m_poc < inFrame->m_mcstf->s_range)
- inFrame->m_refPicCnt[1] -=
(uint8_t)(inFrame->m_mcstf->s_range - inFrame->m_poc);
- if (m_param->totalFrames && (inFrame->m_poc >=
(m_param->totalFrames - inFrame->m_mcstf->s_range)))
- inFrame->m_refPicCnt[1] -= (uint8_t)(inFrame->m_poc +
inFrame->m_mcstf->s_range - m_param->totalFrames + 1);
+ inFrame->m_refPicCnt[1] = 2 * inFrame->m_mcstf->m_range + 1;
+ if (inFrame->m_poc < inFrame->m_mcstf->m_range)
+ inFrame->m_refPicCnt[1] -=
(uint8_t)(inFrame->m_mcstf->m_range - inFrame->m_poc);
+ if (m_param->totalFrames && (inFrame->m_poc >=
(m_param->totalFrames - inFrame->m_mcstf->m_range)))
+ inFrame->m_refPicCnt[1] -= (uint8_t)(inFrame->m_poc +
inFrame->m_mcstf->m_range - m_param->totalFrames + 1);
//Extend full-res original picture border
PicYuv *orig = inFrame->m_fencPic;
@@ -2420,14 +2420,14 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
outFrame->m_rcData->currentSatd =
curEncoder->m_rce.coeffBits;
}
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
Frame *curFrame =
m_origPicBuffer->m_mcstfPicList.getPOCMCSTF(outFrame->m_poc);
- X265_CHECK(curFrame, "Outframe not found in DPB's
mctfPicList");
+ X265_CHECK(curFrame, "Outframe not found in DPB's
mcstfPicList");
curFrame->m_refPicCnt[0]--;
curFrame->m_refPicCnt[1]--;
curFrame =
m_origPicBuffer->m_mcstfOrigPicList.getPOCMCSTF(outFrame->m_poc);
- X265_CHECK(curFrame, "Outframe not found in OPB's
mctfOrigPicList");
+ X265_CHECK(curFrame, "Outframe not found in OPB's
mcstfOrigPicList");
curFrame->m_refPicCnt[1]--;
}
@@ -2436,7 +2436,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
{
ATOMIC_DEC(&outFrame->m_countRefEncoders);
m_dpb->recycleUnreferenced();
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
m_origPicBuffer->recycleOrigPicList();
}
else
@@ -2640,7 +2640,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
/* determine references, setup RPS, etc */
m_dpb->prepareEncode(frameEnc);
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
X265_CHECK(!m_origPicBuffer->m_mcstfOrigPicFreeList.empty(), "Frames not
available in Encoded OPB");
@@ -2648,12 +2648,12 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
dupFrame->m_fencPic->copyFromFrame(frameEnc->m_fencPic);
dupFrame->m_poc = frameEnc->m_poc;
dupFrame->m_encodeOrder = frameEnc->m_encodeOrder;
- dupFrame->m_refPicCnt[1] = 2 * dupFrame->m_mcstf->s_range
+ 1;
+ dupFrame->m_refPicCnt[1] = 2 * dupFrame->m_mcstf->m_range
+ 1;
- if (dupFrame->m_poc < dupFrame->m_mcstf->s_range)
- dupFrame->m_refPicCnt[1] -=
(uint8_t)(dupFrame->m_mcstf->s_range - dupFrame->m_poc);
- if (m_param->totalFrames && (dupFrame->m_poc >=
(m_param->totalFrames - dupFrame->m_mcstf->s_range)))
- dupFrame->m_refPicCnt[1] -= (uint8_t)(dupFrame->m_poc
+ dupFrame->m_mcstf->s_range - m_param->totalFrames + 1);
+ if (dupFrame->m_poc < dupFrame->m_mcstf->m_range)
+ dupFrame->m_refPicCnt[1] -=
(uint8_t)(dupFrame->m_mcstf->m_range - dupFrame->m_poc);
+ if (m_param->totalFrames && (dupFrame->m_poc >=
(m_param->totalFrames - dupFrame->m_mcstf->m_range)))
+ dupFrame->m_refPicCnt[1] -= (uint8_t)(dupFrame->m_poc
+ dupFrame->m_mcstf->m_range - m_param->totalFrames + 1);
m_origPicBuffer->addEncPictureToPicList(dupFrame);
m_origPicBuffer->setOrigPicList(frameEnc, m_pocLast);
@@ -2688,14 +2688,14 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
if (m_param->bIntraRefresh)
calcRefreshInterval(frameEnc);
- // Generate MCTF References and perform HME
- if (m_param->bEnableGopBasedTemporalFilter &&
isFilterThisframe(frameEnc->m_mcstf->m_sliceTypeConfig,
frameEnc->m_lowres.sliceType))
+ // Generate MCSTF References and perform HME
+ if (m_param->bEnableTemporalFilter &&
isFilterThisframe(frameEnc->m_mcstf->m_sliceTypeConfig,
frameEnc->m_lowres.sliceType))
{
- if (!generateMctfRef(frameEnc, curEncoder))
+ if (!generateMcstfRef(frameEnc, curEncoder))
{
m_aborted = true;
- x265_log(m_param, X265_LOG_ERROR, "Failed to
initialize MCTFReferencePicInfo at POC %d\n", frameEnc->m_poc);
+ x265_log(m_param, X265_LOG_ERROR, "Failed to
initialize MCSTFReferencePicInfo at POC %d\n", frameEnc->m_poc);
fflush(stderr);
return -1;
}
@@ -2710,7 +2710,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
for (uint8_t i = 1; i <= frameEnc->m_mcstf->m_numRef; i++)
{
- MCTFReferencePicInfo *ref =
&curEncoder->m_mcstfRefList[i - 1];
+ TemporalFilterRefPicInfo *ref =
&curEncoder->m_mcstfRefList[i - 1];
if (!*ref->isSubsampled)
{
curEncoder->m_frameEncTF->subsampleLuma(ref->picBuffer,
ref->picBufferSubSampled2);
@@ -2721,7 +2721,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
for (uint8_t i = 1; i <= frameEnc->m_mcstf->m_numRef; i++)
{
- MCTFReferencePicInfo *ref =
&curEncoder->m_mcstfRefList[i - 1];
+ TemporalFilterRefPicInfo *ref =
&curEncoder->m_mcstfRefList[i - 1];
curEncoder->m_frameEncTF->motionEstimationLuma(ref->mvs0, ref->mvsStride0,
frameEnc->m_fencPicSubsampled4, ref->picBufferSubSampled4, 16);
curEncoder->m_frameEncTF->motionEstimationLuma(ref->mvs1, ref->mvsStride1,
frameEnc->m_fencPicSubsampled2, ref->picBufferSubSampled2, 16, ref->mvs0,
ref->mvsStride0, 2);
@@ -2731,7 +2731,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
for (int i = 0; i < frameEnc->m_mcstf->m_numRef; i++)
{
- MCTFReferencePicInfo *ref =
&curEncoder->m_mcstfRefList[i];
+ TemporalFilterRefPicInfo *ref =
&curEncoder->m_mcstfRefList[i];
ref->slicetype =
m_lookahead->FindSliceType(frameEnc->m_poc + ref->origOffset);
Frame* dpbframePtr =
m_dpb->m_picList.getPOC(frameEnc->m_poc + ref->origOffset);
if (dpbframePtr != NULL)
diff --git a/source/encoder/encoder.h b/source/encoder/encoder.h
index 41f2ed463..669154da3 100644
--- a/source/encoder/encoder.h
+++ b/source/encoder/encoder.h
@@ -396,7 +396,7 @@ public:
void configureVideoSignalTypePreset(x265_param* p);
bool isFilterThisframe(uint8_t sliceTypeConfig, int curSliceType);
- bool generateMctfRef(Frame* frameEnc, FrameEncoder* currEncoder);
+ bool generateMcstfRef(Frame* frameEnc, FrameEncoder* currEncoder);
protected:
diff --git a/source/encoder/frameencoder.cpp
b/source/encoder/frameencoder.cpp
index ec78fc9f2..6f567b9cf 100644
--- a/source/encoder/frameencoder.cpp
+++ b/source/encoder/frameencoder.cpp
@@ -103,11 +103,11 @@ void FrameEncoder::destroy()
delete m_rce.hrdTiming;
}
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
delete m_frameEncTF->m_metld;
- for (int i = 0; i < (m_frameEncTF->s_range << 1); i++)
+ for (int i = 0; i < (m_frameEncTF->m_range << 1); i++)
m_frameEncTF->destroyRefPicInfo(&m_mcstfRefList[i]);
delete m_frameEncTF;
@@ -206,13 +206,13 @@ bool FrameEncoder::init(Encoder *top, int numRows,
int numCols)
m_sliceAddrBits = (uint16_t)(tmp + 1);
}
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
m_frameEncTF = new TemporalFilter();
if (m_frameEncTF)
m_frameEncTF->init(m_param);
- for (int i = 0; i < (m_frameEncTF->s_range << 1); i++)
+ for (int i = 0; i < (m_frameEncTF->m_range << 1); i++)
ok &= !!m_frameEncTF->createRefPicInfo(&m_mcstfRefList[i],
m_param);
}
@@ -600,11 +600,10 @@ void FrameEncoder::compressFrame()
int qp = m_top->m_rateControl->rateControlStart(m_frame, &m_rce,
m_top);
m_rce.newQp = qp;
- if (m_param->bEnableGopBasedTemporalFilter)
+ if (m_param->bEnableTemporalFilter)
{
m_frameEncTF->m_QP = qp;
- double overallStrength = 0.95;
- m_frameEncTF->bilateralFilter(m_frame, m_mcstfRefList,
overallStrength);
+ m_frameEncTF->bilateralFilter(m_frame, m_mcstfRefList,
m_param->temporalFilterStrength);
}
if (m_nr)
@@ -974,10 +973,10 @@ void FrameEncoder::compressFrame()
if (m_param->bDynamicRefine && m_top->m_startPoint <=
m_frame->m_encodeOrder) //Avoid collecting data that will not be used by
future frames.
collectDynDataFrame();
- if (m_param->bEnableGopBasedTemporalFilter &&
m_top->isFilterThisframe(m_frame->m_mcstf->m_sliceTypeConfig,
m_frame->m_lowres.sliceType))
+ if (m_param->bEnableTemporalFilter &&
m_top->isFilterThisframe(m_frame->m_mcstf->m_sliceTypeConfig,
m_frame->m_lowres.sliceType))
{
- //Reset the MCTF context in Frame Encoder and Frame
- for (int i = 0; i < (m_frameEncTF->s_range << 1); i++)
+ //Reset the MCSTF context in Frame Encoder and Frame
+ for (int i = 0; i < (m_frameEncTF->m_range << 1); i++)
{
memset(m_mcstfRefList[i].mvs0, 0, sizeof(MV) *
((m_param->sourceWidth / 16) * (m_param->sourceHeight / 16)));
memset(m_mcstfRefList[i].mvs1, 0, sizeof(MV) *
((m_param->sourceWidth / 16) * (m_param->sourceHeight / 16)));
diff --git a/source/encoder/frameencoder.h b/source/encoder/frameencoder.h
index 267e9033a..9c5810883 100644
--- a/source/encoder/frameencoder.h
+++ b/source/encoder/frameencoder.h
@@ -236,7 +236,7 @@ public:
// initialization for mcstf
TemporalFilter* m_frameEncTF;
- MCTFReferencePicInfo
m_mcstfRefList[MAX_MCTF_TEMPORAL_WINDOW_LENGTH];
+ TemporalFilterRefPicInfo
m_mcstfRefList[MAX_MCSTF_TEMPORAL_WINDOW_LENGTH];
class WeightAnalysis : public BondedTaskGroup
{
diff --git a/source/x265.h b/source/x265.h
index 4b3177a94..c10c767c3 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -1994,7 +1994,7 @@ typedef struct x265_param
char* filmGrain;
/*Motion compensated temporal filter*/
- int bEnableGopBasedTemporalFilter;
+ int bEnableTemporalFilter;
double temporalFilterStrength;
} x265_param;
diff --git a/source/x265cli.cpp b/source/x265cli.cpp
index 69d77e7bf..75e628f7f 100755
--- a/source/x265cli.cpp
+++ b/source/x265cli.cpp
@@ -370,7 +370,7 @@ namespace X265_NS {
H0(" --lowpass-dct Use low-pass subband dct
approximation. Default %s\n", OPT(param->bLowPassDct));
H0(" --[no-]frame-dup Enable Frame duplication.
Default %s\n", OPT(param->bEnableFrameDuplication));
H0(" --dup-threshold <integer> PSNR threshold for Frame
duplication. Default %d\n", param->dupThreshold);
- H0(" --[no-]mctf Enable GOP based temporal
filter. Default %d\n", param->bEnableGopBasedTemporalFilter);
+ H0(" --[no-]mcstf Enable GOP based temporal
filter. Default %d\n", param->bEnableTemporalFilter);
#ifdef SVT_HEVC
H0(" --[no]svt Enable SVT HEVC encoder
%s\n", OPT(param->bEnableSvtHevc));
H0(" --[no-]svt-hme Enable Hierarchial motion
estimation(HME) in SVT HEVC encoder \n");
diff --git a/source/x265cli.h b/source/x265cli.h
index 29d85f96f..78938f923 100644
--- a/source/x265cli.h
+++ b/source/x265cli.h
@@ -356,8 +356,8 @@ static const struct option long_options[] =
{ "frame-dup", no_argument, NULL, 0 },
{ "no-frame-dup", no_argument, NULL, 0 },
{ "dup-threshold", required_argument, NULL, 0 },
- { "mctf", no_argument, NULL, 0 },
- { "no-mctf", no_argument, NULL, 0 },
+ { "mcstf", no_argument, NULL, 0 },
+ { "no-mcstf", no_argument, NULL, 0 },
#ifdef SVT_HEVC
{ "svt", no_argument, NULL, 0 },
{ "no-svt", no_argument, NULL, 0 },
--
2.34.1.windows.1
*Thanks and Regards,*
*Snehaa.GVideo Codec Engineer,Media & AI analytics
<https://multicorewareinc.com/>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20221019/7c1b488d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mcstf_patch_11.diff
Type: application/octet-stream
Size: 41173 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20221019/7c1b488d/attachment-0001.obj>
More information about the x265-devel
mailing list