<div dir="ltr">Pushed to master.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 25, 2021 at 7:22 PM Niranjan Bala <<a href="mailto:niranjan@multicorewareinc.com">niranjan@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">From c63e08e651e475bfde614049070eb6003fe5ef07 Mon Sep 17 00:00:00 2001<br>From: Niranjan <<a href="mailto:niranjan@multicorewareinc.com" target="_blank">niranjan@multicorewareinc.com</a>><br>Date: Thu, 18 Mar 2021 09:41:49 +0530<br>Subject: [PATCH] Add: End Of Bitstream and End Of Sequence NAL units<br><br>---<br> doc/reST/cli.rst | 10 ++++++++++<br> source/CMakeLists.txt | 2 +-<br> source/common/param.cpp | 8 ++++++++<br> source/encoder/api.cpp | 8 ++++++++<br> source/encoder/encoder.cpp | 13 +++++++++++++<br> source/encoder/encoder.h | 2 ++<br> source/encoder/frameencoder.cpp | 6 ++++++<br> source/test/regression-tests.txt | 1 +<br> source/x265.h | 7 +++++++<br> source/x265cli.cpp | 2 ++<br> source/x265cli.h | 4 ++++<br> 11 files changed, 62 insertions(+), 1 deletion(-)<br><br>diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst<br>index c39fee83f..2f556326b 100755<br>--- a/doc/reST/cli.rst<br>+++ b/doc/reST/cli.rst<br>@@ -2529,6 +2529,16 @@ Bitstream options<br> the very first AUD will be skipped since it cannot be placed at the<br> start of the access unit, where it belongs. Default disabled<br> <br>+.. option:: --eob, --no-eob<br>+<br>+ Emit an end of bitstream NAL unit at the end of the bitstream.<br>+ Default disabled<br>+<br>+.. option:: --eos, --no-eos<br>+<br>+ Emit an end of sequence NAL unit at the end of every coded<br>+ video sequence. Default disabled<br>+<br> .. option:: --hrd, --no-hrd<br> <br> Enable the signaling of HRD parameters to the decoder. The HRD<br>diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt<br>index a407271b4..b4e57b592 100755<br>--- a/source/CMakeLists.txt<br>+++ b/source/CMakeLists.txt<br>@@ -29,7 +29,7 @@ option(NATIVE_BUILD "Target the build CPU" OFF)<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 199)<br>+set(X265_BUILD 200)<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" target="_blank">x265.def.in</a>"<br> "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in" target="_blank">x265_config.h.in</a>"<br>diff --git a/source/common/param.cpp b/source/common/param.cpp<br>index fb74d759b..8a27aaef3 100755<br>--- a/source/common/param.cpp<br>+++ b/source/common/param.cpp<br>@@ -145,6 +145,8 @@ void x265_param_default(x265_param* param)<br> param->bAnnexB = 1;<br> param->bRepeatHeaders = 0;<br> param->bEnableAccessUnitDelimiters = 0;<br>+ param->bEnableEndOfBitstream = 0;<br>+ param->bEnableEndOfSequence = 0;<br> param->bEmitHRDSEI = 0;<br> param->bEmitInfoSEI = 1;<br> param->bEmitHDRSEI = 0; /*Deprecated*/<br>@@ -1448,6 +1450,8 @@ int x265_param_parse(x265_param* p, const char* name, const char* value)<br> OPT("min-vbv-fullness") p->minVbvFullness = atof(value);<br> OPT("max-vbv-fullness") p->maxVbvFullness = atof(value);<br> OPT("video-signal-type-preset") p->videoSignalTypePreset = strdup(value);<br>+ OPT("eob") p->bEnableEndOfBitstream = atobool(value);<br>+ OPT("eos") p->bEnableEndOfSequence = atobool(value);<br> else<br> return X265_PARAM_BAD_NAME;<br> }<br>@@ -2130,6 +2134,8 @@ char *x265_param2string(x265_param* p, int padx, int pady)<br> BOOL(p->bRepeatHeaders, "repeat-headers");<br> BOOL(p->bAnnexB, "annexb");<br> BOOL(p->bEnableAccessUnitDelimiters, "aud");<br>+ BOOL(p->bEnableEndOfBitstream, "eob");<br>+ BOOL(p->bEnableEndOfSequence, "eos");<br> BOOL(p->bEmitHRDSEI, "hrd");<br> BOOL(p->bEmitInfoSEI, "info");<br> s += sprintf(s, " hash=%d", p->decodedPictureHashSEI);<br>@@ -2444,6 +2450,8 @@ void x265_copy_params(x265_param* dst, x265_param* src)<br> dst->bRepeatHeaders = src->bRepeatHeaders;<br> dst->bAnnexB = src->bAnnexB;<br> dst->bEnableAccessUnitDelimiters = src->bEnableAccessUnitDelimiters;<br>+ dst->bEnableEndOfBitstream = src->bEnableEndOfBitstream;<br>+ dst->bEnableEndOfSequence = src->bEnableEndOfSequence;<br> dst->bEmitInfoSEI = src->bEmitInfoSEI;<br> dst->decodedPictureHashSEI = src->decodedPictureHashSEI;<br> dst->bEnableTemporalSubLayers = src->bEnableTemporalSubLayers;<br>diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp<br>index a986355e0..66f26e37e 100644<br>--- a/source/encoder/api.cpp<br>+++ b/source/encoder/api.cpp<br>@@ -608,6 +608,14 @@ fail:<br> if (numEncoded < 0)<br> encoder->m_aborted = true;<br> <br>+ if ((!encoder->m_numDelayedPic && !numEncoded) && (encoder->m_param->bEnableEndOfSequence || encoder->m_param->bEnableEndOfBitstream))<br>+ {<br>+ Bitstream bs;<br>+ encoder->getEndNalUnits(encoder->m_nalList, bs);<br>+ *pp_nal = &encoder->m_nalList.m_nal[0];<br>+ if (pi_nal) *pi_nal = encoder->m_nalList.m_numNal;<br>+ }<br>+<br> return numEncoded;<br> }<br> <br>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp<br>index 19d15fb0d..c1e1cb46d 100644<br>--- a/source/encoder/encoder.cpp<br>+++ b/source/encoder/encoder.cpp<br>@@ -3374,6 +3374,19 @@ void Encoder::getStreamHeaders(NALList& list, Entropy& sbacCoder, Bitstream& bs)<br> }<br> }<br> <br>+void Encoder::getEndNalUnits(NALList& list, Bitstream& bs)<br>+{<br>+ NALList nalList;<br>+ bs.resetBits();<br>+<br>+ if (m_param->bEnableEndOfSequence)<br>+ nalList.serialize(NAL_UNIT_EOS, bs);<br>+ if (m_param->bEnableEndOfBitstream)<br>+ nalList.serialize(NAL_UNIT_EOB, bs);<br>+<br>+ list.takeContents(nalList);<br>+}<br>+<br> void Encoder::initVPS(VPS *vps)<br> {<br> /* Note that much of the VPS is initialized by determineLevel() */<br>diff --git a/source/encoder/encoder.h b/source/encoder/encoder.h<br>index 22a886ef4..2ee5bdaee 100644<br>--- a/source/encoder/encoder.h<br>+++ b/source/encoder/encoder.h<br>@@ -327,6 +327,8 @@ public:<br> <br> void getStreamHeaders(NALList& list, Entropy& sbacCoder, Bitstream& bs);<br> <br>+ void getEndNalUnits(NALList& list, Bitstream& bs);<br>+<br> void fetchStats(x265_stats* stats, size_t statsSizeBytes);<br> <br> void printSummary();<br>diff --git a/source/encoder/frameencoder.cpp b/source/encoder/frameencoder.cpp<br>index efe85282f..1b3875a25 100644<br>--- a/source/encoder/frameencoder.cpp<br>+++ b/source/encoder/frameencoder.cpp<br>@@ -467,6 +467,12 @@ void FrameEncoder::compressFrame()<br> * unit) */<br> Slice* slice = m_frame->m_encData->m_slice;<br> <br>+ if (m_param->bEnableEndOfSequence && m_frame->m_lowres.sliceType == X265_TYPE_IDR && m_frame->m_poc)<br>+ {<br>+ m_bs.resetBits();<br>+ m_nalList.serialize(NAL_UNIT_EOS, m_bs);<br>+ }<br>+<br> if (m_param->bEnableAccessUnitDelimiters && (m_frame->m_poc || m_param->bRepeatHeaders))<br> {<br> m_bs.resetBits();<br>diff --git a/source/test/regression-tests.txt b/source/test/regression-tests.txt<br>index a4fcab87f..971c854df 100644<br>--- a/source/test/regression-tests.txt<br>+++ b/source/test/regression-tests.txt<br>@@ -166,6 +166,7 @@ crowd_run_1920x1080_50.yuv, --preset fast --ctu 64 --rskip 2 --rskip-edge-thresh<br> crowd_run_1920x1080_50.yuv, --preset slow --ctu 32 --rskip 2 --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1<br> crowd_run_1920x1080_50.yuv, --preset slower --ctu 16 --rskip 2 --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1 --aq-mode 4<br> crowd_run_1920x1080_50.yuv, --preset ultrafast --video-signal-type-preset BT2100_PQ_YCC:BT2100x108n0005<br>+crowd_run_1920x1080_50.yuv, --preset ultrafast --eob --eos<br> <br> # Main12 intraCost overflow bug test<br> 720p50_parkrun_ter.y4m,--preset medium<br>diff --git a/source/x265.h b/source/x265.h<br>index 1c51e769d..324f3163f 100644<br>--- a/source/x265.h<br>+++ b/source/x265.h<br>@@ -1956,6 +1956,13 @@ typedef struct x265_param<br> * or color-volume, it will be discarded. */<br> const char* videoSignalTypePreset;<br> <br>+ /* Flag indicating whether the encoder should emit an End of Bitstream<br>+ * NAL at the end of bitstream. Default false */<br>+ int bEnableEndOfBitstream;<br>+<br>+ /* Flag indicating whether the encoder should emit an End of Sequence<br>+ * NAL at the end of every Coded Video Sequence. Default false */<br>+ int bEnableEndOfSequence;<br> } x265_param;<br> <br> /* x265_param_alloc:<br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index e9af67c09..bfb6293f3 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -351,6 +351,8 @@ namespace X265_NS {<br> H0(" --[no-]idr-recovery-sei Emit recovery point infor SEI at each IDR frame \n");<br> H0(" --[no-]temporal-layers Enable a temporal sublayer for unreferenced B frames. Default %s\n", OPT(param->bEnableTemporalSubLayers));<br> H0(" --[no-]aud Emit access unit delimiters at the start of each access unit. Default %s\n", OPT(param->bEnableAccessUnitDelimiters));<br>+ H0(" --[no-]eob Emit end of bitstream nal unit at the end of the bitstream. Default %s\n", OPT(param->bEnableEndOfBitstream));<br>+ H0(" --[no-]eos Emit end of sequence nal unit at the end of every coded video sequence. Default %s\n", OPT(param->bEnableEndOfSequence));<br> H1(" --hash <integer> Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum. Default %d\n", param->decodedPictureHashSEI);<br> H0(" --atc-sei <integer> Emit the alternative transfer characteristics SEI message where the integer is the preferred transfer characteristics. Default disabled\n");<br> H0(" --pic-struct <integer> 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.\n");<br>diff --git a/source/x265cli.h b/source/x265cli.h<br>index 9eb571cfb..46a2b68ae 100644<br>--- a/source/x265cli.h<br>+++ b/source/x265cli.h<br>@@ -264,6 +264,10 @@ static const struct option long_options[] =<br> { "repeat-headers", no_argument, NULL, 0 },<br> { "aud", no_argument, NULL, 0 },<br> { "no-aud", no_argument, NULL, 0 },<br>+ { "eob", no_argument, NULL, 0 },<br>+ { "no-eob", no_argument, NULL, 0 },<br>+ { "eos", no_argument, NULL, 0 },<br>+ { "no-eos", no_argument, NULL, 0 },<br> { "info", no_argument, NULL, 0 },<br> { "no-info", no_argument, NULL, 0 },<br> { "zones", required_argument, NULL, 0 },<br>-- <br>2.18.0.windows.1<br><br><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><font color="#0c343d" face="verdana, sans-serif"><br></font></div><div dir="ltr"><font color="#0c343d" face="verdana, sans-serif">Thanks & Regards</font><div><font color="#0c343d" face="verdana, sans-serif"><b>Niranjan Kumar B</b></font></div><div><font size="1" color="#0c343d" face="verdana, sans-serif">Video Codec Engineer </font></div><div><font size="1" color="#0c343d" face="verdana, sans-serif">Media & AI Analytics</font></div><div><font face="trebuchet ms, sans-serif" color="#0c343d">+91 958 511 1449</font></div><div><a href="https://multicorewareinc.com/" style="color:rgb(17,85,204)" target="_blank"><img src="https://docs.google.com/uc?export=download&id=1kc3RJu9M8bnIf6Xa5rUw2d-eEVUsPBE5&revid=0B7tw9XJBmynaemR1VUpQUi9DVytRVW5SVkRwVTFjb1hBMUcwPQ"></a></div></div></div></div></div></div></div></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div>