<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 12, 2018 at 5:44 PM, Ashok Kumar Mishra <span dir="ltr"><<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Adding the patch file.<div><div class="h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 12, 2018 at 5:14 PM, <span dir="ltr"><<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Ashok Kumar Mishra <<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>><br>
# Date 1523532439 -19800<br>
# Thu Apr 12 16:57:19 2018 +0530<br>
# Node ID ace55bce0e3c6e0beb52712fd71e01<wbr>025bd73a22<br>
# Parent 04a337abd70de269cef7d9655365f3<wbr>a3ebde02aa<br>
Support for HLG-graded content and pic_struct<br>
<br>
diff -r 04a337abd70d -r ace55bce0e3c source/common/param.cpp<br>
--- a/source/common/param.cpp Thu Apr 12 15:10:59 2018 +0530<br>
+++ b/source/common/param.cpp Thu Apr 12 16:57:19 2018 +0530<br>
@@ -134,7 +134,8 @@<br>
param->bEmitInfoSEI = 1;<br>
param->bEmitHDRSEI = 0;<br>
param->bEmitIDRRecoverySEI = 0;<br>
- /* CU definitions */<br>
+<br>
+ /* CU definitions */<br>
param->maxCUSize = 64;<br>
param->minCUSize = 8;<br>
param->tuQTMaxInterDepth = 1;<br>
@@ -192,7 +193,8 @@<br>
param->bEnableSAO = 1;<br>
param->bSaoNonDeblocked = 0;<br>
param->bLimitSAO = 0;<br>
- /* Coding Quality */<br>
+<br>
+ /* Coding Quality */<br>
param->cbQpOffset = 0;<br>
param->crQpOffset = 0;<br>
param->rdPenalty = 0;<br>
@@ -302,6 +304,10 @@<br>
param->bLowPassDct = 0;<br>
param->bMVType = 0;<br>
param->bSingleSeiNal = 0;<br>
+<br>
+ /* SEI messages */<br>
+ param->preferredTransferChara<wbr>cteristics = -1;<br>
+ param->pictureStructure = -1;<br>
}<br>
<br>
int x265_param_default_preset(x265<wbr>_param* param, const char* preset, const char* tune)<br>
@@ -1030,6 +1036,8 @@<br>
OPT("max-ausize-factor") p->maxAUSizeFactor = atof(value);<br>
OPT("dynamic-refine") p->bDynamicRefine = atobool(value);<br>
OPT("single-sei") p->bSingleSeiNal = atobool(value);<br>
+ OPT("atc-sei") p->preferredTransferCharacteri<wbr>stics = atoi(value);<br>
+ OPT("pic-struct") p->pictureStructure = atoi(value);<br>
else<br>
return X265_PARAM_BAD_NAME;<br>
}<br>
diff -r 04a337abd70d -r ace55bce0e3c source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Thu Apr 12 15:10:59 2018 +0530<br>
+++ b/source/encoder/encoder.cpp Thu Apr 12 16:57:19 2018 +0530<br>
@@ -338,10 +338,12 @@<br>
<br>
if (m_param->bEmitHRDSEI)<br>
m_rateControl->initHRD(m_sps)<wbr>;<br>
+<br>
if (!m_rateControl->init(m_sps))<br>
m_aborted = true;<br>
if (!m_lookahead->create())<br>
m_aborted = true;<br>
+<br>
initRefIdx();<br>
if (m_param->analysisSave && m_param->bUseAnalysisFile)<br>
{<br>
@@ -2436,7 +2438,7 @@<br>
vui.defaultDisplayWindow.bott<wbr>omOffset = m_param->vui.defDispWinBottomO<wbr>ffset;<br>
vui.defaultDisplayWindow.left<wbr>Offset = m_param->vui.defDispWinLeftOff<wbr>set;<br>
<br>
- vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode;<br>
+ vui.frameFieldInfoPresentFlag = !!m_param->interlaceMode || (m_param->pictureStructure >= 0);<br>
vui.fieldSeqFlag = !!m_param->interlaceMode;<br>
<br>
vui.hrdParametersPresentFlag = m_param->bEmitHRDSEI;<br>
diff -r 04a337abd70d -r ace55bce0e3c source/encoder/frameencoder.cp<wbr>p<br>
--- a/source/encoder/frameencoder.<wbr>cpp Thu Apr 12 15:10:59 2018 +0530<br>
+++ b/source/encoder/frameencoder.<wbr>cpp Thu Apr 12 16:57:19 2018 +0530<br>
@@ -674,9 +674,14 @@<br>
sei->m_picStruct = (poc & 1) ? 1 /* top */ : 2 /* bottom */;<br>
else if (m_param->interlaceMode == 1)<br>
sei->m_picStruct = (poc & 1) ? 2 /* bottom */ : 1 /* top */;<br>
- else<br>
- sei->m_picStruct = 0;<br>
- sei->m_sourceScanType = 0;<br>
+ else<br>
+ sei->m_picStruct = m_param->pictureStructure;<br>
+<br>
+ if (m_param->interlaceMode)<br>
+ sei->m_sourceScanType = 0;<br>
+ else<br>
+ sei->m_sourceScanType = 1;<br>
+<br>
sei->m_duplicateFlag = false;<br>
}<br>
<br>
@@ -696,6 +701,18 @@<br>
sei->write(m_bs, *slice->m_sps);<br>
sei->alignAndSerialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList);<br>
}<br>
+<br>
+ if (m_param->preferredTransferCha<wbr>racteristics > -1 && slice->isIRAP())<br>
+ {<br>
+ SEIAlternativeTC m_seiAlternativeTC;<br>
+ m_seiAlternativeTC.m_preferre<wbr>dTransferCharacteristics = m_param->preferredTransferChar<wbr>acteristics;<br>
+ m_bs.resetBits();<br>
+ int payloadSize = m_seiAlternativeTC.countPayloa<wbr>dSize(*slice->m_sps);<br>
+ m_seiAlternativeTC.setSize(pa<wbr>yloadSize);<br>
+ m_seiAlternativeTC.write(m_bs<wbr>, *slice->m_sps);<br>
+ m_seiAlternativeTC.alignAndSe<wbr>rialize(m_bs, false, m_param->bSingleSeiNal, NAL_UNIT_PREFIX_SEI, m_nalList);<br>
+ }<br>
+<br>
bool isSei = false;<br>
/* Write user SEI */<br>
for (int i = 0; i < m_frame->m_userSEI.numPayloads<wbr>; i++)<br>
@@ -729,8 +746,9 @@<br>
else<br>
x265_log(m_param, X265_LOG_ERROR, "Unrecognized SEI type\n");<br>
}<br>
- isSei |= ((m_frame->m_lowres.bKeyframe && m_param->bRepeatHeaders) || m_param->bEmitHRDSEI<br>
- || !!m_param->interlaceMode || (m_frame->m_lowres.sliceType == X265_TYPE_IDR && m_param->bEmitIDRRecoverySEI))<wbr>;<br>
+<br>
+ isSei |= ((m_frame->m_lowres.bKeyframe && m_param->bRepeatHeaders) || m_param->bEmitHRDSEI ||<br>
+ !!m_param->interlaceMode || (m_frame->m_lowres.sliceType == X265_TYPE_IDR && m_param->bEmitIDRRecoverySEI))<wbr>;<br>
<br>
if (isSei && m_param->bSingleSeiNal)<br>
{<br>
diff -r 04a337abd70d -r ace55bce0e3c source/encoder/sei.h<br>
--- a/source/encoder/sei.h Thu Apr 12 15:10:59 2018 +0530<br>
+++ b/source/encoder/sei.h Thu Apr 12 16:57:19 2018 +0530<br>
@@ -296,5 +296,23 @@<br>
WRITE_CODE(m_payload[i], 8, "creative_intent_metadata");<br>
}<br>
};<br>
+<br>
+class SEIAlternativeTC : public SEI<br>
+{<br>
+public:<br>
+ int m_preferredTransferCharacteris<wbr>tics;<br>
+ SEIAlternativeTC()<br>
+ {<br>
+ m_payloadType = ALTERNATIVE_TRANSFER_CHARACTER<wbr>ISTICS;<br>
+ m_payloadSize = 0;<br>
+ m_preferredTransferCharacteri<wbr>stics = -1;<br>
+ }<br>
+<br>
+ void writeSEI(const SPS&)<br>
+ {<br>
+ WRITE_CODE(m_preferredTransfe<wbr>rCharacteristics, 8, "Preferred transfer characteristics");<br>
+ }<br>
+};<br>
+<br>
}<br>
#endif // ifndef X265_SEI_H<br>
diff -r 04a337abd70d -r ace55bce0e3c source/x265.h<br>
--- a/source/x265.h Thu Apr 12 15:10:59 2018 +0530<br>
+++ b/source/x265.h Thu Apr 12 16:57:19 2018 +0530<br>
@@ -265,6 +265,7 @@<br>
REGION_REFRESH_INFO = 134,<br>
MASTERING_DISPLAY_INFO = 137,<br>
CONTENT_LIGHT_LEVEL_INFO = 144,<br>
+ ALTERNATIVE_TRANSFER_CHARACTE<wbr>RISTICS = 147,<br>
} SEIPayloadType;<br>
<br>
typedef struct x265_sei_payload<br>
@@ -1161,6 +1162,18 @@<br>
* Default is 0, which is recommended */<br>
int crQpOffset;<br>
<br>
+ /* Specifies the preferred transfer characteristics syntax element in the<br>
+ * alternative transfer characteristics SEI message (see. D.2.38 and D.3.38 of<br>
+ * JCTVC-W1005 <a href="http://phenix.it-sudparis.eu/jct/doc_end_user/documents/23_San%20Diego/wg11/JCTVC-W1005-v4.zip" rel="noreferrer" target="_blank">http://phenix.it-sudparis.eu/j<wbr>ct/doc_end_user/documents/23_S<wbr>an%20Diego/wg11/JCTVC-W1005-v4<wbr>.zip</a><br>
+ * */<br>
+ int preferredTransferCharacterist<wbr>ics;<br>
+<br>
+ /*<br>
+ * Specifies the value for the pic_struc syntax element of the picture timing SEI message (See D2.3 and D3.3)<br>
+ * of the HEVC spec. for a detailed explanation<br>
+ * */<br>
+ int pictureStructure;<br>
+<br>
struct<br>
{<br>
/* Explicit mode of rate-control, necessary for API users. It must<br>
diff -r 04a337abd70d -r ace55bce0e3c source/x265cli.h<br>
--- a/source/x265cli.h Thu Apr 12 15:10:59 2018 +0530<br>
+++ b/source/x265cli.h Thu Apr 12 16:57:19 2018 +0530<br>
@@ -300,6 +300,8 @@<br>
{ "no-idr-recovery-sei", no_argument, NULL, 0 },<br>
{ "single-sei", no_argument, NULL, 0 },<br>
{ "no-single-sei", no_argument, NULL, 0 },<br>
+ { "atc-sei", required_argument, NULL, 0 },<br>
+ { "pic-struct", required_argument, NULL, 0 },<br>
{ 0, 0, 0, 0 },<br>
{ 0, 0, 0, 0 },<br>
{ 0, 0, 0, 0 },<br>
@@ -563,6 +565,8 @@<br>
H0(" --[no-]temporal-layers Enable a temporal sublayer for unreferenced B frames. Default %s\n", OPT(param->bEnableTemporalSubL<wbr>ayers));<br>
H0(" --[no-]aud Emit access unit delimiters at the start of each access unit. Default %s\n", OPT(param->bEnableAccessUnitDe<wbr>limiters));<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.");<br>
H0(" --log2-max-poc-lsb <integer> Maximum of the picture order count\n");<br>
H0(" --[no-]vui-timing-info Emit VUI timing information in the bistream. Default %s\n", OPT(param->bEmitVUITimingInfo)<wbr>);<br>
H0(" --[no-]vui-hrd-info Emit VUI HRD information in the bistream. Default %s\n", OPT(param->bEmitVUIHRDInfo));<br>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Pushed.</div></div>