Re: [x265] [PATCH 307 of 307] x86:AVX512 Set run time flag to enable/disable avx512
W dniu 07.04.2018 o 04:35, mythr...@multicorewareinc.com pisze: > # HG changeset patch > # User Jayashree> # Date 1522928767 -19800 > # Thu Apr 05 17:16:07 2018 +0530 > # Node ID f6ad2fa637fd3c8f9e2811982b89aa28228e9f6b > # Parent 876b6e006f2080072c0684dbf75e7cfde974ba79 > x86:AVX512 Set run time flag to enable/disable avx512 > > diff -r 876b6e006f20 -r f6ad2fa637fd source/common/cpu.cpp > --- a/source/common/cpu.cpp Mon Feb 05 10:39:00 2018 -0800 > +++ b/source/common/cpu.cpp Thu Apr 05 17:16:07 2018 +0530 > @@ -122,7 +122,7 @@ > #pragma warning(disable: 4309) // truncation of constant value > #endif > > -uint32_t cpu_detect(void) > +uint32_t cpu_detect(bool benableavx512 ) > { > uint32_t cpu = 0; > > @@ -184,11 +184,13 @@ > { > if (ebx & 0x0020) > cpu |= X265_CPU_AVX2; > - > -if ((xcr0 & 0xE0) == 0xE0) /* OPMASK/ZMM state */ > +if (benableavx512) > { > -if ((ebx & 0xD003) == 0xD003) > -cpu |= X265_CPU_AVX512; > +if ((xcr0 & 0xE0) == 0xE0) /* OPMASK/ZMM state */ > +{ > +if ((ebx & 0xD003) == 0xD003) > +cpu |= X265_CPU_AVX512; > +} > } > } > } > @@ -327,7 +329,7 @@ > int PFX(cpu_fast_neon_mrc_test)(void); > } > > -uint32_t cpu_detect(void) > +uint32_t cpu_detect(bool benableavx512) > { > int flags = 0; > > @@ -370,7 +372,7 @@ > > #elif X265_ARCH_POWER8 > > -uint32_t cpu_detect(void) > +uint32_t cpu_detect(bool benableavx512) > { > #if HAVE_ALTIVEC > return X265_CPU_ALTIVEC; > @@ -381,7 +383,7 @@ > > #else // if X265_ARCH_POWER8 > > -uint32_t cpu_detect(void) > +uint32_t cpu_detect(bool benableavx512) > { > return 0; > } > diff -r 876b6e006f20 -r f6ad2fa637fd source/common/cpu.h > --- a/source/common/cpu.h Mon Feb 05 10:39:00 2018 -0800 > +++ b/source/common/cpu.h Thu Apr 05 17:16:07 2018 +0530 > @@ -50,7 +50,7 @@ > #endif > > namespace X265_NS { > -uint32_t cpu_detect(void); > +uint32_t cpu_detect(bool); > > struct cpu_name_t > { > diff -r 876b6e006f20 -r f6ad2fa637fd source/common/param.cpp > --- a/source/common/param.cpp Mon Feb 05 10:39:00 2018 -0800 > +++ b/source/common/param.cpp Thu Apr 05 17:16:07 2018 +0530 > @@ -99,13 +99,13 @@ > { > x265_free(p); > } > - > +bool benableavx512 = false; > void x265_param_default(x265_param* param) > { > memset(param, 0, sizeof(x265_param)); > > /* Applying default values to all elements in the param structure */ > -param->cpuid = X265_NS::cpu_detect(); > +param->cpuid = X265_NS::cpu_detect(benableavx512); > param->bEnableWavefront = 1; > param->frameNumThreads = 0; > > @@ -609,6 +609,17 @@ > if (0) ; > OPT("asm") > { > +sscanf(value, "%s", p->asmname); p->asmname is a pointer to unallocated memory. It is not used in x265. VS 2015 and VS 2017 builds hangs at command-line: x265 --asm sse4 -V I think we should remove 'asmname' from x265_param or allocate memory before we copy anything to this location. > +if (strcmp(value, "avx512")==0) > +{ > +p->bEnableavx512 = 1; > +benableavx512 = true; > +} > +else > +{ > +p->bEnableavx512 = 0; > +benableavx512 = false; > +} > if (bValueWasNull) > p->cpuid = atobool(value); > else > @@ -1072,7 +1083,7 @@ > if (isdigit(value[0])) > cpu = x265_atoi(value, bError); > else > -cpu = !strcmp(value, "auto") || x265_atobool(value, bError) ? > X265_NS::cpu_detect() : 0; > +cpu = !strcmp(value, "auto") || x265_atobool(value, bError) ? > X265_NS::cpu_detect(benableavx512) : 0; > > if (bError) > { > diff -r 876b6e006f20 -r f6ad2fa637fd source/test/pixelharness.cpp > --- a/source/test/pixelharness.cppMon Feb 05 10:39:00 2018 -0800 > +++ b/source/test/pixelharness.cppThu Apr 05 17:16:07 2018 +0530 > @@ -332,8 +332,9 @@ > memset(ref_dest, 0, 64 * 64 * sizeof(pixel)); > memset(opt_dest, 0, 64 * 64 * sizeof(pixel)); > int j = 0; > +bool enableavx512 = true; > int width = 16 * (rand() % 4 + 1); > -int cpuid = X265_NS::cpu_detect(); > +int cpuid = X265_NS::cpu_detect(enableavx512); > if (cpuid & X265_CPU_AVX512) > width = 32 * (rand() % 2 + 1); > int height = 8; > diff -r 876b6e006f20 -r f6ad2fa637fd source/test/testbench.cpp > --- a/source/test/testbench.cpp Mon Feb 05 10:39:00 2018 -0800 > +++ b/source/test/testbench.cpp Thu Apr 05 17:16:07 2018 +0530 > @@ -96,7 +96,8 @@ > > int main(int argc, char *argv[]) > { > -int cpuid = X265_NS::cpu_detect(); > +bool enableavx512 = true; > +int cpuid = X265_NS::cpu_detect(enableavx512); > const char *testname = 0; > >
Re: [x265] [PATCH] Add VMAF suppport to report per frame and aggregate VMAF score
Am 12.04.2018, 13:13 Uhr, schrieb: +.. Note:: + +When setting ENABLE_LIBVMAF cmake option to ON, it is recommended to +also set ENABLE_SHARED to OFF to prevent build problems. +We only need the static library from these builds. + +Binaries build with windows will not have VMAF support. Can you explain why support for Windows builds is not (yet?) possible? I do remember that MABS is able to compile ffmpeg including VMAF, and also I do remember that it compiled only for x86-64 architecture due to some specific EMMS intrinsics. But, of course, MABS pulls the whole libvmaf source to do so. You will probably not want to require that. But it might not be too hard in MSYS/MinGW64 if an experienced user does it manually? -- Fun and success! Mario *LigH* Rohkrämer mailto:cont...@ligh.de ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
Re: [x265] [PATCH 000 of 307 ] AVX-512 implementataion in x265
Pradeep Ramachandran schrieb am 12.04.2018 um 16:11: On the average we see 18% improvement for 4K main10 high quality encoding; for other resolutions and presets, the improvement isn’t significant. There are already a few reports in the doom9 forum: An intel Core i9 can accelerate the encoding especially with slower presets, while a Xeon was reported to be slower when AVX-512 was enabled, probably mostly due to the temperature related throttling. ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
Re: [x265] [PATCH] Support for HLG-graded content and pic_struct
On Thu, Apr 12, 2018 at 4:49 PM, Vittorio Giovara < vittorio.giov...@gmail.com> wrote: > > > > On Thu, Apr 12, 2018 at 1:44 PM,wrote: > >> # HG changeset patch >> # User Ashok Kumar Mishra >> # Date 1523532439 -19800 >> # Thu Apr 12 16:57:19 2018 +0530 >> # Node ID ace55bce0e3c6e0beb52712fd71e01025bd73a22 >> # Parent 04a337abd70de269cef7d9655365f3a3ebde02aa >> Support for HLG-graded content and pic_struct >> >> diff -r 04a337abd70d -r ace55bce0e3c source/common/param.cpp >> --- a/source/common/param.cpp Thu Apr 12 15:10:59 2018 +0530 >> +++ b/source/common/param.cpp Thu Apr 12 16:57:19 2018 +0530 >> @@ -134,7 +134,8 @@ >> param->bEmitInfoSEI = 1; >> param->bEmitHDRSEI = 0; >> param->bEmitIDRRecoverySEI = 0; >> -/* CU definitions */ >> + >> + /* CU definitions */ >> param->maxCUSize = 64; >> param->minCUSize = 8; >> param->tuQTMaxInterDepth = 1; >> @@ -192,7 +193,8 @@ >> param->bEnableSAO = 1; >> param->bSaoNonDeblocked = 0; >> param->bLimitSAO = 0; >> -/* Coding Quality */ >> + >> + /* Coding Quality */ >> param->cbQpOffset = 0; >> param->crQpOffset = 0; >> param->rdPenalty = 0; >> @@ -302,6 +304,10 @@ >> param->bLowPassDct = 0; >> param->bMVType = 0; >> param->bSingleSeiNal = 0; >> + >> + /* SEI messages */ >> + param->preferredTransferCharacteristics = -1; >> + param->pictureStructure = -1; >> } >> >> int x265_param_default_preset(x265_param* param, const char* preset, >> const char* tune) >> @@ -1030,6 +1036,8 @@ >> OPT("max-ausize-factor") p->maxAUSizeFactor = atof(value); >> OPT("dynamic-refine") p->bDynamicRefine = atobool(value); >> OPT("single-sei") p->bSingleSeiNal = atobool(value); >> + OPT("atc-sei") p->preferredTransferCharacteristics = >> atoi(value); >> + OPT("pic-struct") p->pictureStructure = atoi(value); >> else >> return X265_PARAM_BAD_NAME; >> } >> diff -r 04a337abd70d -r ace55bce0e3c source/encoder/encoder.cpp >> --- a/source/encoder/encoder.cppThu Apr 12 15:10:59 2018 +0530 >> +++ b/source/encoder/encoder.cppThu Apr 12 16:57:19 2018 +0530 >> @@ -338,10 +338,12 @@ >> >> if (m_param->bEmitHRDSEI) >> m_rateControl->initHRD(m_sps); >> + >> if (!m_rateControl->init(m_sps)) >> m_aborted = true; >> if (!m_lookahead->create()) >> m_aborted = true; >> + >> initRefIdx(); >> if (m_param->analysisSave && m_param->bUseAnalysisFile) >> { >> > > For the future, could you please keep cosmetic changes (such as the ones > above) in a separate patch? > It gets confusing really fast and makes reading history needlessly fast. > > needlessy hard* -- Vittorio ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
Re: [x265] [PATCH] Support for HLG-graded content and pic_struct
On Thu, Apr 12, 2018 at 1:44 PM,wrote: > # HG changeset patch > # User Ashok Kumar Mishra > # Date 1523532439 -19800 > # Thu Apr 12 16:57:19 2018 +0530 > # Node ID ace55bce0e3c6e0beb52712fd71e01025bd73a22 > # Parent 04a337abd70de269cef7d9655365f3a3ebde02aa > Support for HLG-graded content and pic_struct > > diff -r 04a337abd70d -r ace55bce0e3c source/common/param.cpp > --- a/source/common/param.cpp Thu Apr 12 15:10:59 2018 +0530 > +++ b/source/common/param.cpp Thu Apr 12 16:57:19 2018 +0530 > @@ -134,7 +134,8 @@ > param->bEmitInfoSEI = 1; > param->bEmitHDRSEI = 0; > param->bEmitIDRRecoverySEI = 0; > -/* CU definitions */ > + > + /* CU definitions */ > param->maxCUSize = 64; > param->minCUSize = 8; > param->tuQTMaxInterDepth = 1; > @@ -192,7 +193,8 @@ > param->bEnableSAO = 1; > param->bSaoNonDeblocked = 0; > param->bLimitSAO = 0; > -/* Coding Quality */ > + > + /* Coding Quality */ > param->cbQpOffset = 0; > param->crQpOffset = 0; > param->rdPenalty = 0; > @@ -302,6 +304,10 @@ > param->bLowPassDct = 0; > param->bMVType = 0; > param->bSingleSeiNal = 0; > + > + /* SEI messages */ > + param->preferredTransferCharacteristics = -1; > + param->pictureStructure = -1; > } > > int x265_param_default_preset(x265_param* param, const char* preset, > const char* tune) > @@ -1030,6 +1036,8 @@ > OPT("max-ausize-factor") p->maxAUSizeFactor = atof(value); > OPT("dynamic-refine") p->bDynamicRefine = atobool(value); > OPT("single-sei") p->bSingleSeiNal = atobool(value); > + OPT("atc-sei") p->preferredTransferCharacteristics = > atoi(value); > + OPT("pic-struct") p->pictureStructure = atoi(value); > else > return X265_PARAM_BAD_NAME; > } > diff -r 04a337abd70d -r ace55bce0e3c source/encoder/encoder.cpp > --- a/source/encoder/encoder.cppThu Apr 12 15:10:59 2018 +0530 > +++ b/source/encoder/encoder.cppThu Apr 12 16:57:19 2018 +0530 > @@ -338,10 +338,12 @@ > > if (m_param->bEmitHRDSEI) > m_rateControl->initHRD(m_sps); > + > if (!m_rateControl->init(m_sps)) > m_aborted = true; > if (!m_lookahead->create()) > m_aborted = true; > + > initRefIdx(); > if (m_param->analysisSave && m_param->bUseAnalysisFile) > { > For the future, could you please keep cosmetic changes (such as the ones above) in a separate patch? It gets confusing really fast and makes reading history needlessly fast. -- Vittorio ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
Re: [x265] [PATCH 000 of 307 ] AVX-512 implementataion in x265
On the average we see 18% improvement for 4K main10 high quality encoding; for other resolutions and presets, the improvement isn’t significant. You can read this paper for some thoughts ( https://networkbuilders.intel.com/docs/accelerating-x265-the-hevc-encoder-with-intel-advanced-vector-extensions-512.pdf ) Pradeep On Fri, 6 Apr 2018 at 12:28 PM, Praveen Tiwariwrote: > Your request is on the way, soon we will share the performance related > details. Thanks. > > Regards, > Praveen Tiwari > > On Fri, Apr 6, 2018 at 9:36 PM, Vittorio Giovara < > vittorio.giov...@gmail.com> wrote: > >> just curious, what kind of general speed improvement does this give? >> I could have missed them in the series, but it would be nice to have some >> sort of benchmarks >> thanks >> Vittorio >> >> On Sat, Apr 7, 2018 at 4:29 AM, wrote: >> >>> This series of patches enables AVX-512 in x265. USe CLI option --asm >>> avx512 to enable AVX-512 kernels. >>> ___ >>> x265-devel mailing list >>> x265-devel@videolan.org >>> https://mailman.videolan.org/listinfo/x265-devel >>> >> >> >> >> -- >> Vittorio >> >> ___ >> x265-devel mailing list >> x265-devel@videolan.org >> https://mailman.videolan.org/listinfo/x265-devel >> >> > ___ > x265-devel mailing list > x265-devel@videolan.org > https://mailman.videolan.org/listinfo/x265-devel > -- Pradeep Ramachandran, PhD Principal Engineer at www.multicorewareinc.com/ Adjunct Faculty at www.cse.iitm.ac.in/ pradeeprama.info/ Ph: +91 99627 82018 ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
Re: [x265] [PATCH] Support for HLG-graded content and pic_struct
Ashok Kumar Mishra schrieb am 12.04.2018 um 14:21: + H0(" --pic-struct Set the picture structure and emits it in the picture timing SEI message. Values in the range 0..12. See D.3.3 of the HEVC spec. for a detailed explanation."); Missing a new line at the end. Furthermore, another very very long CLI help output line (190 chars)... ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
Re: [x265] [PATCH x265] dynamic-refine: Remove lock while collecting CTU data
Please ignore this patch. Thanks, Bhavna Hariharan On Thu, Apr 12, 2018 at 3:52 PM,wrote: > # HG changeset patch > # User Bhavna Hariharan > # Date 1523528451 -19800 > # Thu Apr 12 15:50:51 2018 +0530 > # Node ID bff8e6d4407bebd8ff19be8323deacc16be4875c > # Parent 04a337abd70de269cef7d9655365f3a3ebde02aa > dynamic-refine: Remove lock while collecting CTU data > > Locks were used to avoid the possibility of race conditions while copying > data from CTU level to frame level. Now, the data is collected for each > row and > when the entire frame completes analysis the row data is copied to the > frame. > This method eliminates the possibility of a race condition without having > to > employ locks. > > diff -r 04a337abd70d -r bff8e6d4407b source/common/common.h > --- a/source/common/common.hThu Apr 12 15:10:59 2018 +0530 > +++ b/source/common/common.hThu Apr 12 15:50:51 2018 +0530 > @@ -332,6 +332,8 @@ > #define START_CODE_OVERHEAD 3 > #define FILLER_OVERHEAD (NAL_TYPE_OVERHEAD + START_CODE_OVERHEAD + 1) > > +#define MAX_NUM_DYN_REFINE ((NUM_CU_DEPTH - 1) * > X265_REFINE_INTER_LEVELS) > + > namespace X265_NS { > > enum { SAO_NUM_OFFSET = 4 }; > diff -r 04a337abd70d -r bff8e6d4407b source/common/framedata.h > --- a/source/common/framedata.h Thu Apr 12 15:10:59 2018 +0530 > +++ b/source/common/framedata.h Thu Apr 12 15:50:51 2018 +0530 > @@ -88,6 +88,11 @@ > uint64_tcntInterPu[NUM_CU_DEPTH][INTER_MODES - 1]; > uint64_tcntMergePu[NUM_CU_DEPTH][INTER_MODES - 1]; > > +/* Feature values per row for dynamic refinement */ > +uint64_t rowRdDyn[MAX_NUM_DYN_REFINE]; > +uint32_t rowVarDyn[MAX_NUM_DYN_REFINE]; > +uint32_t rowCntDyn[MAX_NUM_DYN_REFINE]; > + > FrameStats() > { > memset(this, 0, sizeof(FrameStats)); > diff -r 04a337abd70d -r bff8e6d4407b source/encoder/frameencoder.cpp > --- a/source/encoder/frameencoder.cpp Thu Apr 12 15:10:59 2018 +0530 > +++ b/source/encoder/frameencoder.cpp Thu Apr 12 15:50:51 2018 +0530 > @@ -935,6 +935,9 @@ > } > } // end of (m_param->maxSlices > 1) > > +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->rc.bStatWrite) > { > int totalI = 0, totalP = 0, totalSkip = 0; > @@ -1473,27 +1476,13 @@ > > // Does all the CU analysis, returns best top level mode decision > Mode& best = tld.analysis.compressCTU(*ctu, *m_frame, > m_cuGeoms[m_ctuGeomMap[cuAddr]], rowCoder); > -if (m_param->bDynamicRefine) > + > +/* startPoint > encodeOrder is true when the start point changes > for > +a new GOP but all frames of the previous GOP is still incomplete > +The data from these frames will not be used by any future frames. > */ > +if (m_param->bDynamicRefine && m_top->m_startPoint <= > m_frame->m_encodeOrder) > { > -if (m_top->m_startPoint <= m_frame->m_encodeOrder) // Avoid > collecting data that will not be used by future frames. > -{ > -ScopedLock dynLock(m_top->m_dynamicRefineLock); > -for (uint32_t i = 0; i < X265_REFINE_INTER_LEVELS; i++) > -{ > -for (uint32_t depth = 0; depth < m_param->maxCUDepth; > depth++) > -{ > -int offset = (depth * X265_REFINE_INTER_LEVELS) + > i; > -int curFrameIndex = m_frame->m_encodeOrder - > m_top->m_startPoint; > -int index = (curFrameIndex * > X265_REFINE_INTER_LEVELS * m_param->maxCUDepth) + offset; > -if (ctu->m_collectCUCount[offset]) > -{ > -m_top->m_variance[index] += > ctu->m_collectCUVariance[offset]; > -m_top->m_rdCost[index] += > ctu->m_collectCURd[offset]; > -m_top->m_trainingCount[index] += > ctu->m_collectCUCount[offset]; > -} > -} > -} > -} > +collectDynDataRow(*ctu, ); > X265_FREE_ZERO(ctu->m_collectCUVariance); > X265_FREE_ZERO(ctu->m_collectCURd); > X265_FREE_ZERO(ctu->m_collectCUCount); > @@ -1880,6 +1869,46 @@ > if (ATOMIC_INC(_completionCount) == 2 * (int)m_numRows) > m_completionEvent.trigger(); > } > + > +void FrameEncoder::collectDynDataRow(const CUData& ctu, FrameStats* > rowStats) > +{ > +for (uint32_t i = 0; i < X265_REFINE_INTER_LEVELS; i++) > +{ > +for (uint32_t depth = 0; depth < m_param->maxCUDepth; depth++) > +{ > +int offset = (depth * X265_REFINE_INTER_LEVELS) + i; > +if (ctu.m_collectCUCount[offset]) > +{ > +
Re: [x265] [PATCH] Support for HLG-graded content and pic_struct
On Thu, Apr 12, 2018 at 5:44 PM, Ashok Kumar Mishra < as...@multicorewareinc.com> wrote: > Adding the patch file. > > > On Thu, Apr 12, 2018 at 5:14 PM,wrote: > >> # HG changeset patch >> # User Ashok Kumar Mishra >> # Date 1523532439 -19800 >> # Thu Apr 12 16:57:19 2018 +0530 >> # Node ID ace55bce0e3c6e0beb52712fd71e01025bd73a22 >> # Parent 04a337abd70de269cef7d9655365f3a3ebde02aa >> Support for HLG-graded content and pic_struct >> >> diff -r 04a337abd70d -r ace55bce0e3c source/common/param.cpp >> --- a/source/common/param.cpp Thu Apr 12 15:10:59 2018 +0530 >> +++ b/source/common/param.cpp Thu Apr 12 16:57:19 2018 +0530 >> @@ -134,7 +134,8 @@ >> param->bEmitInfoSEI = 1; >> param->bEmitHDRSEI = 0; >> param->bEmitIDRRecoverySEI = 0; >> -/* CU definitions */ >> + >> + /* CU definitions */ >> param->maxCUSize = 64; >> param->minCUSize = 8; >> param->tuQTMaxInterDepth = 1; >> @@ -192,7 +193,8 @@ >> param->bEnableSAO = 1; >> param->bSaoNonDeblocked = 0; >> param->bLimitSAO = 0; >> -/* Coding Quality */ >> + >> + /* Coding Quality */ >> param->cbQpOffset = 0; >> param->crQpOffset = 0; >> param->rdPenalty = 0; >> @@ -302,6 +304,10 @@ >> param->bLowPassDct = 0; >> param->bMVType = 0; >> param->bSingleSeiNal = 0; >> + >> + /* SEI messages */ >> + param->preferredTransferCharacteristics = -1; >> + param->pictureStructure = -1; >> } >> >> int x265_param_default_preset(x265_param* param, const char* preset, >> const char* tune) >> @@ -1030,6 +1036,8 @@ >> OPT("max-ausize-factor") p->maxAUSizeFactor = atof(value); >> OPT("dynamic-refine") p->bDynamicRefine = atobool(value); >> OPT("single-sei") p->bSingleSeiNal = atobool(value); >> + OPT("atc-sei") p->preferredTransferCharacteristics = >> atoi(value); >> + OPT("pic-struct") p->pictureStructure = atoi(value); >> else >> return X265_PARAM_BAD_NAME; >> } >> diff -r 04a337abd70d -r ace55bce0e3c source/encoder/encoder.cpp >> --- a/source/encoder/encoder.cppThu Apr 12 15:10:59 2018 +0530 >> +++ b/source/encoder/encoder.cppThu Apr 12 16:57:19 2018 +0530 >> @@ -338,10 +338,12 @@ >> >> if (m_param->bEmitHRDSEI) >> m_rateControl->initHRD(m_sps); >> + >> if (!m_rateControl->init(m_sps)) >> m_aborted = true; >> if (!m_lookahead->create()) >> m_aborted = true; >> + >> initRefIdx(); >> if (m_param->analysisSave && m_param->bUseAnalysisFile) >> { >> @@ -2436,7 +2438,7 @@ >> vui.defaultDisplayWindow.bottomOffset = >> m_param->vui.defDispWinBottomOffset; >> vui.defaultDisplayWindow.leftOffset = m_param->vui.defDispWinLeftOff >> set; >> >> -vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode; >> + vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode || >> (m_param->pictureStructure >= 0); >> vui.fieldSeqFlag = !!m_param->interlaceMode; >> >> vui.hrdParametersPresentFlag = m_param->bEmitHRDSEI; >> diff -r 04a337abd70d -r ace55bce0e3c source/encoder/frameencoder.cpp >> --- a/source/encoder/frameencoder.cpp Thu Apr 12 15:10:59 2018 +0530 >> +++ b/source/encoder/frameencoder.cpp Thu Apr 12 16:57:19 2018 +0530 >> @@ -674,9 +674,14 @@ >> sei->m_picStruct = (poc & 1) ? 1 /* top */ : 2 /* bottom >> */; >> else if (m_param->interlaceMode == 1) >> sei->m_picStruct = (poc & 1) ? 2 /* bottom */ : 1 /* top >> */; >> -else >> -sei->m_picStruct = 0; >> -sei->m_sourceScanType = 0; >> + else >> + sei->m_picStruct = >> m_param->pictureStructure; >> + >> + if (m_param->interlaceMode) >> +sei->m_sourceScanType = 0; >> + else >> +sei->m_sourceScanType = 1; >> + >> sei->m_duplicateFlag = false; >> } >> >> @@ -696,6 +701,18 @@ >> sei->write(m_bs, *slice->m_sps); >> sei->alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, >> NAL_UNIT_PREFIX_SEI, m_nalList); >> } >> + >> + if (m_param->preferredTransferCharacteristics > -1 && >> slice->isIRAP()) >> + { >> + SEIAlternativeTC m_seiAlternativeTC; >> + m_seiAlternativeTC.m_preferredTransferCharacteristics = >> m_param->preferredTransferCharacteristics; >> + m_bs.resetBits(); >> + int payloadSize = m_seiAlternativeTC.countPayloa >> dSize(*slice->m_sps); >> + m_seiAlternativeTC.setSize(payloadSize); >> + m_seiAlternativeTC.write(m_bs, *slice->m_sps); >> + m_seiAlternativeTC.alignAndSerialize(m_bs, false, >> m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); >> + } >> + >> bool isSei =
Re: [x265] [PATCH] Support for HLG-graded content and pic_struct
Adding the patch file. On Thu, Apr 12, 2018 at 5:14 PM,wrote: > # HG changeset patch > # User Ashok Kumar Mishra > # Date 1523532439 -19800 > # Thu Apr 12 16:57:19 2018 +0530 > # Node ID ace55bce0e3c6e0beb52712fd71e01025bd73a22 > # Parent 04a337abd70de269cef7d9655365f3a3ebde02aa > Support for HLG-graded content and pic_struct > > diff -r 04a337abd70d -r ace55bce0e3c source/common/param.cpp > --- a/source/common/param.cpp Thu Apr 12 15:10:59 2018 +0530 > +++ b/source/common/param.cpp Thu Apr 12 16:57:19 2018 +0530 > @@ -134,7 +134,8 @@ > param->bEmitInfoSEI = 1; > param->bEmitHDRSEI = 0; > param->bEmitIDRRecoverySEI = 0; > -/* CU definitions */ > + > + /* CU definitions */ > param->maxCUSize = 64; > param->minCUSize = 8; > param->tuQTMaxInterDepth = 1; > @@ -192,7 +193,8 @@ > param->bEnableSAO = 1; > param->bSaoNonDeblocked = 0; > param->bLimitSAO = 0; > -/* Coding Quality */ > + > + /* Coding Quality */ > param->cbQpOffset = 0; > param->crQpOffset = 0; > param->rdPenalty = 0; > @@ -302,6 +304,10 @@ > param->bLowPassDct = 0; > param->bMVType = 0; > param->bSingleSeiNal = 0; > + > + /* SEI messages */ > + param->preferredTransferCharacteristics = -1; > + param->pictureStructure = -1; > } > > int x265_param_default_preset(x265_param* param, const char* preset, > const char* tune) > @@ -1030,6 +1036,8 @@ > OPT("max-ausize-factor") p->maxAUSizeFactor = atof(value); > OPT("dynamic-refine") p->bDynamicRefine = atobool(value); > OPT("single-sei") p->bSingleSeiNal = atobool(value); > + OPT("atc-sei") p->preferredTransferCharacteristics = > atoi(value); > + OPT("pic-struct") p->pictureStructure = atoi(value); > else > return X265_PARAM_BAD_NAME; > } > diff -r 04a337abd70d -r ace55bce0e3c source/encoder/encoder.cpp > --- a/source/encoder/encoder.cppThu Apr 12 15:10:59 2018 +0530 > +++ b/source/encoder/encoder.cppThu Apr 12 16:57:19 2018 +0530 > @@ -338,10 +338,12 @@ > > if (m_param->bEmitHRDSEI) > m_rateControl->initHRD(m_sps); > + > if (!m_rateControl->init(m_sps)) > m_aborted = true; > if (!m_lookahead->create()) > m_aborted = true; > + > initRefIdx(); > if (m_param->analysisSave && m_param->bUseAnalysisFile) > { > @@ -2436,7 +2438,7 @@ > vui.defaultDisplayWindow.bottomOffset = > m_param->vui.defDispWinBottomOffset; > vui.defaultDisplayWindow.leftOffset = m_param->vui.defDispWinLeftOff > set; > > -vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode; > + vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode || > (m_param->pictureStructure >= 0); > vui.fieldSeqFlag = !!m_param->interlaceMode; > > vui.hrdParametersPresentFlag = m_param->bEmitHRDSEI; > diff -r 04a337abd70d -r ace55bce0e3c source/encoder/frameencoder.cpp > --- a/source/encoder/frameencoder.cpp Thu Apr 12 15:10:59 2018 +0530 > +++ b/source/encoder/frameencoder.cpp Thu Apr 12 16:57:19 2018 +0530 > @@ -674,9 +674,14 @@ > sei->m_picStruct = (poc & 1) ? 1 /* top */ : 2 /* bottom > */; > else if (m_param->interlaceMode == 1) > sei->m_picStruct = (poc & 1) ? 2 /* bottom */ : 1 /* top > */; > -else > -sei->m_picStruct = 0; > -sei->m_sourceScanType = 0; > + else > + sei->m_picStruct = > m_param->pictureStructure; > + > + if (m_param->interlaceMode) > +sei->m_sourceScanType = 0; > + else > +sei->m_sourceScanType = 1; > + > sei->m_duplicateFlag = false; > } > > @@ -696,6 +701,18 @@ > sei->write(m_bs, *slice->m_sps); > sei->alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, > NAL_UNIT_PREFIX_SEI, m_nalList); > } > + > + if (m_param->preferredTransferCharacteristics > -1 && > slice->isIRAP()) > + { > + SEIAlternativeTC m_seiAlternativeTC; > + m_seiAlternativeTC.m_preferredTransferCharacteristics = > m_param->preferredTransferCharacteristics; > + m_bs.resetBits(); > + int payloadSize = m_seiAlternativeTC.countPayloa > dSize(*slice->m_sps); > + m_seiAlternativeTC.setSize(payloadSize); > + m_seiAlternativeTC.write(m_bs, *slice->m_sps); > + m_seiAlternativeTC.alignAndSerialize(m_bs, false, > m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); > + } > + > bool isSei = false; > /* Write user SEI */ > for (int i = 0; i < m_frame->m_userSEI.numPayloads; i++) > @@ -729,8 +746,9 @@ > else > x265_log(m_param, X265_LOG_ERROR, "Unrecognized SEI type\n"); > } >
Re: [x265] [PATCH] Add VMAF suppport to report per frame and aggregate VMAF score
On Thu, Apr 12, 2018 at 4:43 PM,wrote: > # HG changeset patch > # User IndumathiR > # Date 1518528290 -19800 > # Tue Feb 13 18:54:50 2018 +0530 > # Node ID 27e3b161cd8b59ad1cae67a96e11e3e0506d5017 > # Parent 04a337abd70de269cef7d9655365f3a3ebde02aa > Add VMAF suppport to report per frame and aggregate VMAF score > > diff -r 04a337abd70d -r 27e3b161cd8b doc/reST/api.rst > --- a/doc/reST/api.rst Thu Apr 12 15:10:59 2018 +0530 > +++ b/doc/reST/api.rst Tue Feb 13 18:54:50 2018 +0530 > @@ -398,7 +398,30 @@ > * release library static allocations, reset configured CTU > size */ > void x265_cleanup(void); > > +VMAF (Video Multi-Method Assessment Fusion) > +== > > +If you set the ENABLE_LIBVMAF cmake option to ON, then x265 will report > per frame > +and aggregate VMAF score for the given input and dump the scores in csv > file. > +The user also need to specify the :option:`--recon` in command line to > get the VMAF scores. > + > +/* x265_calculate_vmafScore: > + *returns VMAF score for the input video. > + *This api must be called only after encoding was done. */ > +double x265_calculate_vmafscore(x265_param*, x265_vmaf_data*); > + > +/* x265_calculate_vmaf_framelevelscore: > + *returns VMAF score for each frame in a given input video. */ > +double x265_calculate_vmaf_framelevelscore(x265_vmaf_framedata*); > + > +.. Note:: > + > +When setting ENABLE_LIBVMAF cmake option to ON, it is recommended to > +also set ENABLE_SHARED to OFF to prevent build problems. > +We only need the static library from these builds. > + > +Binaries build with windows will not have VMAF support. > + > Multi-library Interface > === > > diff -r 04a337abd70d -r 27e3b161cd8b source/CMakeLists.txt > --- a/source/CMakeLists.txt Thu Apr 12 15:10:59 2018 +0530 > +++ b/source/CMakeLists.txt Tue Feb 13 18:54:50 2018 +0530 > @@ -29,7 +29,7 @@ > option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF) > mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD) > # X265_BUILD must be incremented each time the public API is changed > -set(X265_BUILD 157) > +set(X265_BUILD 158) > configure_file("${PROJECT_SOURCE_DIR}/x265.def.in" > "${PROJECT_BINARY_DIR}/x265.def") > configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in" > @@ -109,6 +109,11 @@ > if(NO_ATOMICS) > add_definitions(-DNO_ATOMICS=1) > endif(NO_ATOMICS) > +find_library(VMAF vmaf) > +option(ENABLE_LIBVMAF "Enable VMAF" OFF) > +if(ENABLE_LIBVMAF) > +add_definitions(-DENABLE_LIBVMAF) > +endif() > endif(UNIX) > > if(X64 AND NOT WIN32) > @@ -536,6 +541,9 @@ > if(EXTRA_LIB) > target_link_libraries(x265-static ${EXTRA_LIB}) > endif() > +if(ENABLE_LIBVMAF) > +target_link_libraries(x265-static ${VMAF}) > +endif() > install(TARGETS x265-static > LIBRARY DESTINATION ${LIB_INSTALL_DIR} > ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) > diff -r 04a337abd70d -r 27e3b161cd8b source/common/picyuv.h > --- a/source/common/picyuv.hThu Apr 12 15:10:59 2018 +0530 > +++ b/source/common/picyuv.hTue Feb 13 18:54:50 2018 +0530 > @@ -72,6 +72,7 @@ > pixel m_maxChromaVLevel; > pixel m_minChromaVLevel; > double m_avgChromaVLevel; > +double m_vmafScore; > x265_param *m_param; > > PicYuv(); > diff -r 04a337abd70d -r 27e3b161cd8b source/encoder/api.cpp > --- a/source/encoder/api.cppThu Apr 12 15:10:59 2018 +0530 > +++ b/source/encoder/api.cppTue Feb 13 18:54:50 2018 +0530 > @@ -31,6 +31,10 @@ > #include "nal.h" > #include "bitcost.h" > > +#if ENABLE_LIBVMAF > +#include "libvmaf.h" > +#endif > + > /* multilib namespace reflectors */ > #if LINKED_8BIT > namespace x265_8bit { > @@ -302,13 +306,34 @@ > encoder->fetchStats(outputStats, statsSizeBytes); > } > } > +#if ENABLE_LIBVMAF > +void x265_vmaf_encoder_log(x265_encoder* enc, int argc, char **argv, > x265_param *param, x265_vmaf_data *vmafdata) > +{ > +if (enc) > +{ > +Encoder *encoder = static_cast (enc); > +x265_stats stats; > +stats.aggregateVmafScore = x265_calculate_vmafscore(param, > vmafdata); > +if(vmafdata->reference_file) > +fclose(vmafdata->reference_file); > +if(vmafdata->distorted_file) > +fclose(vmafdata->distorted_file); > +if(vmafdata) > +x265_free(vmafdata); > +encoder->fetchStats(, sizeof(stats)); > +int padx = encoder->m_sps.conformanceWindow.rightOffset; > +int pady = encoder->m_sps.conformanceWindow.bottomOffset; > +x265_csvlog_encode(encoder->m_param, , padx, pady, argc, > argv); > +} > +} > +#endif > > void x265_encoder_log(x265_encoder* enc, int argc, char **argv) > { > if (enc) > { > Encoder *encoder =
[x265] [PATCH] Support for HLG-graded content and pic_struct
# HG changeset patch # User Ashok Kumar Mishra# Date 1523532439 -19800 # Thu Apr 12 16:57:19 2018 +0530 # Node ID ace55bce0e3c6e0beb52712fd71e01025bd73a22 # Parent 04a337abd70de269cef7d9655365f3a3ebde02aa Support for HLG-graded content and pic_struct diff -r 04a337abd70d -r ace55bce0e3c source/common/param.cpp --- a/source/common/param.cpp Thu Apr 12 15:10:59 2018 +0530 +++ b/source/common/param.cpp Thu Apr 12 16:57:19 2018 +0530 @@ -134,7 +134,8 @@ param->bEmitInfoSEI = 1; param->bEmitHDRSEI = 0; param->bEmitIDRRecoverySEI = 0; -/* CU definitions */ + + /* CU definitions */ param->maxCUSize = 64; param->minCUSize = 8; param->tuQTMaxInterDepth = 1; @@ -192,7 +193,8 @@ param->bEnableSAO = 1; param->bSaoNonDeblocked = 0; param->bLimitSAO = 0; -/* Coding Quality */ + + /* Coding Quality */ param->cbQpOffset = 0; param->crQpOffset = 0; param->rdPenalty = 0; @@ -302,6 +304,10 @@ param->bLowPassDct = 0; param->bMVType = 0; param->bSingleSeiNal = 0; + + /* SEI messages */ + param->preferredTransferCharacteristics = -1; + param->pictureStructure = -1; } int x265_param_default_preset(x265_param* param, const char* preset, const char* tune) @@ -1030,6 +1036,8 @@ OPT("max-ausize-factor") p->maxAUSizeFactor = atof(value); OPT("dynamic-refine") p->bDynamicRefine = atobool(value); OPT("single-sei") p->bSingleSeiNal = atobool(value); + OPT("atc-sei") p->preferredTransferCharacteristics = atoi(value); + OPT("pic-struct") p->pictureStructure = atoi(value); else return X265_PARAM_BAD_NAME; } diff -r 04a337abd70d -r ace55bce0e3c source/encoder/encoder.cpp --- a/source/encoder/encoder.cppThu Apr 12 15:10:59 2018 +0530 +++ b/source/encoder/encoder.cppThu Apr 12 16:57:19 2018 +0530 @@ -338,10 +338,12 @@ if (m_param->bEmitHRDSEI) m_rateControl->initHRD(m_sps); + if (!m_rateControl->init(m_sps)) m_aborted = true; if (!m_lookahead->create()) m_aborted = true; + initRefIdx(); if (m_param->analysisSave && m_param->bUseAnalysisFile) { @@ -2436,7 +2438,7 @@ vui.defaultDisplayWindow.bottomOffset = m_param->vui.defDispWinBottomOffset; vui.defaultDisplayWindow.leftOffset = m_param->vui.defDispWinLeftOffset; -vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode; + vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode || (m_param->pictureStructure >= 0); vui.fieldSeqFlag = !!m_param->interlaceMode; vui.hrdParametersPresentFlag = m_param->bEmitHRDSEI; diff -r 04a337abd70d -r ace55bce0e3c source/encoder/frameencoder.cpp --- a/source/encoder/frameencoder.cpp Thu Apr 12 15:10:59 2018 +0530 +++ b/source/encoder/frameencoder.cpp Thu Apr 12 16:57:19 2018 +0530 @@ -674,9 +674,14 @@ sei->m_picStruct = (poc & 1) ? 1 /* top */ : 2 /* bottom */; else if (m_param->interlaceMode == 1) sei->m_picStruct = (poc & 1) ? 2 /* bottom */ : 1 /* top */; -else -sei->m_picStruct = 0; -sei->m_sourceScanType = 0; + else + sei->m_picStruct = m_param->pictureStructure; + + if (m_param->interlaceMode) +sei->m_sourceScanType = 0; + else +sei->m_sourceScanType = 1; + sei->m_duplicateFlag = false; } @@ -696,6 +701,18 @@ sei->write(m_bs, *slice->m_sps); sei->alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); } + + if (m_param->preferredTransferCharacteristics > -1 && slice->isIRAP()) + { + SEIAlternativeTC m_seiAlternativeTC; + m_seiAlternativeTC.m_preferredTransferCharacteristics = m_param->preferredTransferCharacteristics; + m_bs.resetBits(); + int payloadSize = m_seiAlternativeTC.countPayloadSize(*slice->m_sps); + m_seiAlternativeTC.setSize(payloadSize); + m_seiAlternativeTC.write(m_bs, *slice->m_sps); + m_seiAlternativeTC.alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); + } + bool isSei = false; /* Write user SEI */ for (int i = 0; i < m_frame->m_userSEI.numPayloads; i++) @@ -729,8 +746,9 @@ else x265_log(m_param, X265_LOG_ERROR, "Unrecognized SEI type\n"); } -isSei |= ((m_frame->m_lowres.bKeyframe && m_param->bRepeatHeaders) || m_param->bEmitHRDSEI -|| !!m_param->interlaceMode || (m_frame->m_lowres.sliceType == X265_TYPE_IDR && m_param->bEmitIDRRecoverySEI)); + +isSei |= ((m_frame->m_lowres.bKeyframe &&
Re: [x265] [PATCH ] Fix 32 bit build error
On Thu, Apr 12, 2018 at 3:13 PM,wrote: > # HG changeset patch > # User Mythreyi P > # Date 1523566023 25200 > # Thu Apr 12 13:47:03 2018 -0700 > # Node ID cef7d4791b1077f7dd145ae940e9d88c14655324 > # Parent 593e63cda903370af926711c0ba05ce37d045c90 > Fix 32 bit build error > > diff -r 593e63cda903 -r cef7d4791b10 source/common/x86/pixel-util8.asm > --- a/source/common/x86/pixel-util8.asm Thu Apr 05 17:16:07 2018 +0530 > +++ b/source/common/x86/pixel-util8.asm Thu Apr 12 13:47:03 2018 -0700 > @@ -1861,6 +1861,7 @@ > ;--- > -- > ; int x265_count_nonzero_16x16_avx512(const int16_t *quantCoeff); > ;--- > -- > +%if ARCH_X86_64 > INIT_ZMM avx512 > cglobal count_nonzero_16x16, 1,4,2 > mov r1, 0x > @@ -1881,7 +1882,7 @@ > mov eax, r3d > > RET > - > +%endif > > ;--- > -- > ; int x265_count_nonzero_32x32_sse2(const int16_t *quantCoeff); > @@ -1935,6 +1936,7 @@ > ;--- > -- > ; int x265_count_nonzero_32x32_avx512(const int16_t *quantCoeff); > ;--- > -- > +%if ARCH_X86_64 > INIT_ZMM avx512 > cglobal count_nonzero_32x32, 1,4,2 > mov r1, 0x > @@ -1955,7 +1957,7 @@ > mov eax, r3d > > RET > - > +%endif > ;--- > > > ;void weight_pp(pixel *src, pixel *dst, intptr_t stride, int width, int > height, int w0, int round, int shift, int offset) > ;--- > > > ___ > x265-devel mailing list > x265-devel@videolan.org > https://mailman.videolan.org/listinfo/x265-devel Thanks. Pushed to default. ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
[x265] [PATCH ] Fix 32 bit build error
# HG changeset patch # User Mythreyi P# Date 1523566023 25200 # Thu Apr 12 13:47:03 2018 -0700 # Node ID cef7d4791b1077f7dd145ae940e9d88c14655324 # Parent 593e63cda903370af926711c0ba05ce37d045c90 Fix 32 bit build error diff -r 593e63cda903 -r cef7d4791b10 source/common/x86/pixel-util8.asm --- a/source/common/x86/pixel-util8.asm Thu Apr 05 17:16:07 2018 +0530 +++ b/source/common/x86/pixel-util8.asm Thu Apr 12 13:47:03 2018 -0700 @@ -1861,6 +1861,7 @@ ;- ; int x265_count_nonzero_16x16_avx512(const int16_t *quantCoeff); ;- +%if ARCH_X86_64 INIT_ZMM avx512 cglobal count_nonzero_16x16, 1,4,2 mov r1, 0x @@ -1881,7 +1882,7 @@ mov eax, r3d RET - +%endif ;- ; int x265_count_nonzero_32x32_sse2(const int16_t *quantCoeff); @@ -1935,6 +1936,7 @@ ;- ; int x265_count_nonzero_32x32_avx512(const int16_t *quantCoeff); ;- +%if ARCH_X86_64 INIT_ZMM avx512 cglobal count_nonzero_32x32, 1,4,2 mov r1, 0x @@ -1955,7 +1957,7 @@ mov eax, r3d RET - +%endif ;--- ;void weight_pp(pixel *src, pixel *dst, intptr_t stride, int width, int height, int w0, int round, int shift, int offset) ;--- ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
[x265] [PATCH] fix conditions for single-sei NAL
# HG changeset patch # User Santhoshini Sekar# Date 1523526059 -19800 # Thu Apr 12 15:10:59 2018 +0530 # Node ID ad37e53f78dcdd600f7ad31095db490b2a93a8c6 # Parent 593e63cda903370af926711c0ba05ce37d045c90 fix conditions for single-sei NAL diff --git a/source/encoder/frameencoder.cpp b/source/encoder/frameencoder.cpp --- a/source/encoder/frameencoder.cpp +++ b/source/encoder/frameencoder.cpp @@ -696,7 +696,7 @@ sei->write(m_bs, *slice->m_sps); sei->alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); } - +bool isSei = false; /* Write user SEI */ for (int i = 0; i < m_frame->m_userSEI.numPayloads; i++) { @@ -710,6 +710,7 @@ sei.setSize(payload->payloadSize); sei.write(m_bs, *slice->m_sps); sei.alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); +isSei = true; } else if (payload->payloadType == USER_DATA_REGISTERED_ITU_T_T35) { @@ -717,18 +718,19 @@ { SEICreativeIntentMeta sei; sei.m_payload = payload->payload; -m_bs.resetBits(); +if (!m_param->bSingleSeiNal) +m_bs.resetBits(); sei.setSize(payload->payloadSize); sei.write(m_bs, *slice->m_sps); -sei.alignAndSerialize(m_bs, true, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); +sei.alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); +isSei = true; } } else x265_log(m_param, X265_LOG_ERROR, "Unrecognized SEI type\n"); } -bool isSei = (m_frame->m_lowres.bKeyframe && -(m_param->bRepeatHeaders || m_param->bEmitHRDSEI -|| !!m_param->interlaceMode || m_param->bEmitIDRRecoverySEI)); +isSei |= ((m_frame->m_lowres.bKeyframe && m_param->bRepeatHeaders) || m_param->bEmitHRDSEI +|| !!m_param->interlaceMode || (m_frame->m_lowres.sliceType == X265_TYPE_IDR && m_param->bEmitIDRRecoverySEI)); if (isSei && m_param->bSingleSeiNal) { # HG changeset patch # User Santhoshini Sekar # Date 1523526059 -19800 # Thu Apr 12 15:10:59 2018 +0530 # Node ID ad37e53f78dcdd600f7ad31095db490b2a93a8c6 # Parent 593e63cda903370af926711c0ba05ce37d045c90 fix conditions for single-sei NAL diff --git a/source/encoder/frameencoder.cpp b/source/encoder/frameencoder.cpp --- a/source/encoder/frameencoder.cpp +++ b/source/encoder/frameencoder.cpp @@ -696,7 +696,7 @@ sei->write(m_bs, *slice->m_sps); sei->alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); } - +bool isSei = false; /* Write user SEI */ for (int i = 0; i < m_frame->m_userSEI.numPayloads; i++) { @@ -710,6 +710,7 @@ sei.setSize(payload->payloadSize); sei.write(m_bs, *slice->m_sps); sei.alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); +isSei = true; } else if (payload->payloadType == USER_DATA_REGISTERED_ITU_T_T35) { @@ -717,18 +718,19 @@ { SEICreativeIntentMeta sei; sei.m_payload = payload->payload; -m_bs.resetBits(); +if (!m_param->bSingleSeiNal) +m_bs.resetBits(); sei.setSize(payload->payloadSize); sei.write(m_bs, *slice->m_sps); -sei.alignAndSerialize(m_bs, true, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); +sei.alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList); +isSei = true; } } else x265_log(m_param, X265_LOG_ERROR, "Unrecognized SEI type\n"); } -bool isSei = (m_frame->m_lowres.bKeyframe && -(m_param->bRepeatHeaders || m_param->bEmitHRDSEI -|| !!m_param->interlaceMode || m_param->bEmitIDRRecoverySEI)); +isSei |= ((m_frame->m_lowres.bKeyframe && m_param->bRepeatHeaders) || m_param->bEmitHRDSEI +|| !!m_param->interlaceMode || (m_frame->m_lowres.sliceType == X265_TYPE_IDR && m_param->bEmitIDRRecoverySEI)); if (isSei && m_param->bSingleSeiNal) { ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
[x265] [PATCH] Add VMAF suppport to report per frame and aggregate VMAF score
# HG changeset patch # User IndumathiR# Date 1518528290 -19800 # Tue Feb 13 18:54:50 2018 +0530 # Node ID ca4a690f5036951da78441a4c70577a5977b1e0e # Parent 593e63cda903370af926711c0ba05ce37d045c90 Add VMAF suppport to report per frame and aggregate VMAF score diff -r 593e63cda903 -r ca4a690f5036 doc/reST/api.rst --- a/doc/reST/api.rst Thu Apr 05 17:16:07 2018 +0530 +++ b/doc/reST/api.rst Tue Feb 13 18:54:50 2018 +0530 @@ -398,7 +398,30 @@ * release library static allocations, reset configured CTU size */ void x265_cleanup(void); +VMAF (Video Multi-Method Assessment Fusion) +== +If you set the ENABLE_LIBVMAF cmake option to ON, then x265 will report per frame +and aggregate VMAF score for the given input and dump the scores in csv file. +The user also need to specify the :option:`--recon` in command line to get the VMAF scores. + +/* x265_calculate_vmafScore: + *returns VMAF score for the input video. + *This api must be called only after encoding was done. */ +double x265_calculate_vmafscore(x265_param*, x265_vmaf_data*); + +/* x265_calculate_vmaf_framelevelscore: + *returns VMAF score for each frame in a given input video. */ +double x265_calculate_vmaf_framelevelscore(x265_vmaf_framedata*); + +.. Note:: + +When setting ENABLE_LIBVMAF cmake option to ON, it is recommended to +also set ENABLE_SHARED to OFF to prevent build problems. +We only need the static library from these builds. + +Binaries build with windows will not have VMAF support. + Multi-library Interface === diff -r 593e63cda903 -r ca4a690f5036 source/CMakeLists.txt --- a/source/CMakeLists.txt Thu Apr 05 17:16:07 2018 +0530 +++ b/source/CMakeLists.txt Tue Feb 13 18:54:50 2018 +0530 @@ -29,7 +29,7 @@ option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF) mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD) # X265_BUILD must be incremented each time the public API is changed -set(X265_BUILD 157) +set(X265_BUILD 158) configure_file("${PROJECT_SOURCE_DIR}/x265.def.in" "${PROJECT_BINARY_DIR}/x265.def") configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in" @@ -109,6 +109,11 @@ if(NO_ATOMICS) add_definitions(-DNO_ATOMICS=1) endif(NO_ATOMICS) +find_library(VMAF vmaf) +option(ENABLE_LIBVMAF "Enable VMAF" OFF) +if(ENABLE_LIBVMAF) +add_definitions(-DENABLE_LIBVMAF) +endif() endif(UNIX) if(X64 AND NOT WIN32) @@ -536,6 +541,9 @@ if(EXTRA_LIB) target_link_libraries(x265-static ${EXTRA_LIB}) endif() +if(ENABLE_LIBVMAF) +target_link_libraries(x265-static ${VMAF}) +endif() install(TARGETS x265-static LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) diff -r 593e63cda903 -r ca4a690f5036 source/common/picyuv.h --- a/source/common/picyuv.hThu Apr 05 17:16:07 2018 +0530 +++ b/source/common/picyuv.hTue Feb 13 18:54:50 2018 +0530 @@ -72,6 +72,7 @@ pixel m_maxChromaVLevel; pixel m_minChromaVLevel; double m_avgChromaVLevel; +double m_vmafScore; x265_param *m_param; PicYuv(); diff -r 593e63cda903 -r ca4a690f5036 source/encoder/api.cpp --- a/source/encoder/api.cppThu Apr 05 17:16:07 2018 +0530 +++ b/source/encoder/api.cppTue Feb 13 18:54:50 2018 +0530 @@ -31,6 +31,10 @@ #include "nal.h" #include "bitcost.h" +#if ENABLE_LIBVMAF +#include "libvmaf.h" +#endif + /* multilib namespace reflectors */ #if LINKED_8BIT namespace x265_8bit { @@ -302,13 +306,34 @@ encoder->fetchStats(outputStats, statsSizeBytes); } } +#if ENABLE_LIBVMAF +void x265_vmaf_encoder_log(x265_encoder* enc, int argc, char **argv, x265_param *param, x265_vmaf_data *vmafdata) +{ +if (enc) +{ +Encoder *encoder = static_cast (enc); +x265_stats stats; +stats.aggregateVmafScore = x265_calculate_vmafscore(param, vmafdata); +if(vmafdata->reference_file) +fclose(vmafdata->reference_file); +if(vmafdata->distorted_file) +fclose(vmafdata->distorted_file); +if(vmafdata) +x265_free(vmafdata); +encoder->fetchStats(, sizeof(stats)); +int padx = encoder->m_sps.conformanceWindow.rightOffset; +int pady = encoder->m_sps.conformanceWindow.bottomOffset; +x265_csvlog_encode(encoder->m_param, , padx, pady, argc, argv); +} +} +#endif void x265_encoder_log(x265_encoder* enc, int argc, char **argv) { if (enc) { Encoder *encoder = static_cast (enc); -x265_stats stats; +x265_stats stats; encoder->fetchStats(, sizeof(stats)); int padx = encoder->m_sps.conformanceWindow.rightOffset; int pady = encoder->m_sps.conformanceWindow.bottomOffset; @@ -457,7 +482,13 @@ _csvlog_frame,