# HG changeset patch # User Ashok Kumar Mishra <as...@multicorewareinc.com> # 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.cpp Thu Apr 12 15:10:59 2018 +0530 +++ b/source/encoder/encoder.cpp Thu 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 && 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) { diff -r 04a337abd70d -r ace55bce0e3c source/encoder/sei.h --- a/source/encoder/sei.h Thu Apr 12 15:10:59 2018 +0530 +++ b/source/encoder/sei.h Thu Apr 12 16:57:19 2018 +0530 @@ -296,5 +296,23 @@ WRITE_CODE(m_payload[i], 8, "creative_intent_metadata"); } }; + +class SEIAlternativeTC : public SEI +{ +public: + int m_preferredTransferCharacteristics; + SEIAlternativeTC() + { + m_payloadType = ALTERNATIVE_TRANSFER_CHARACTERISTICS; + m_payloadSize = 0; + m_preferredTransferCharacteristics = -1; + } + + void writeSEI(const SPS&) + { + WRITE_CODE(m_preferredTransferCharacteristics, 8, "Preferred transfer characteristics"); + } +}; + } #endif // ifndef X265_SEI_H diff -r 04a337abd70d -r ace55bce0e3c source/x265.h --- a/source/x265.h Thu Apr 12 15:10:59 2018 +0530 +++ b/source/x265.h Thu Apr 12 16:57:19 2018 +0530 @@ -265,6 +265,7 @@ REGION_REFRESH_INFO = 134, MASTERING_DISPLAY_INFO = 137, CONTENT_LIGHT_LEVEL_INFO = 144, + ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147, } SEIPayloadType; typedef struct x265_sei_payload @@ -1161,6 +1162,18 @@ * Default is 0, which is recommended */ int crQpOffset; + /* Specifies the preferred transfer characteristics syntax element in the + * alternative transfer characteristics SEI message (see. D.2.38 and D.3.38 of + * JCTVC-W1005 http://phenix.it-sudparis.eu/jct/doc_end_user/documents/23_San%20Diego/wg11/JCTVC-W1005-v4.zip + * */ + int preferredTransferCharacteristics; + + /* + * Specifies the value for the pic_struc syntax element of the picture timing SEI message (See D2.3 and D3.3) + * of the HEVC spec. for a detailed explanation + * */ + int pictureStructure; + struct { /* Explicit mode of rate-control, necessary for API users. It must diff -r 04a337abd70d -r ace55bce0e3c source/x265cli.h --- a/source/x265cli.h Thu Apr 12 15:10:59 2018 +0530 +++ b/source/x265cli.h Thu Apr 12 16:57:19 2018 +0530 @@ -300,6 +300,8 @@ { "no-idr-recovery-sei", no_argument, NULL, 0 }, { "single-sei", no_argument, NULL, 0 }, { "no-single-sei", no_argument, NULL, 0 }, + { "atc-sei", required_argument, NULL, 0 }, + { "pic-struct", required_argument, NULL, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, @@ -563,6 +565,8 @@ H0(" --[no-]temporal-layers Enable a temporal sublayer for unreferenced B frames. Default %s\n", OPT(param->bEnableTemporalSubLayers)); H0(" --[no-]aud Emit access unit delimiters at the start of each access unit. Default %s\n", OPT(param->bEnableAccessUnitDelimiters)); H1(" --hash <integer> Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum. Default %d\n", param->decodedPictureHashSEI); + H0(" --atc-sei <integer> Emit the alternative transfer characteristics SEI message where the integer is the preferred transfer characteristics. Default disabled\n"); + 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."); H0(" --log2-max-poc-lsb <integer> Maximum of the picture order count\n"); H0(" --[no-]vui-timing-info Emit VUI timing information in the bistream. Default %s\n", OPT(param->bEmitVUITimingInfo)); H0(" --[no-]vui-hrd-info Emit VUI HRD information in the bistream. Default %s\n", OPT(param->bEmitVUIHRDInfo)); _______________________________________________ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel