<div dir="ltr"><div># HG changeset patch</div><div># User Deepthi Nandakumar <<a href="mailto:deepthi@multicorewareinc.com">deepthi@multicorewareinc.com</a>></div><div># Date 1452163804 -19800</div><div># Thu Jan 07 16:20:04 2016 +0530</div><div># Node ID 427fadf8fe2baa1713f468c6bd084d389fb18053</div><div># Parent 70581d6cd0651e763f8c312b3c94eb42fd2c4872</div><div>sei: add user defined SEI</div><div><br></div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/CMakeLists.txt</div><div>--- a/source/CMakeLists.txt<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/CMakeLists.txt<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -30,7 +30,7 @@</div><div> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)</div><div> </div><div> # X265_BUILD must be incremented each time the public API is changed</div><div>-set(X265_BUILD 87)</div><div>+set(X265_BUILD 88)</div><div> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in">x265.def.in</a>"</div><div> "${PROJECT_BINARY_DIR}/x265.def")</div><div> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in">x265_config.h.in</a>"</div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/common/frame.cpp</div><div>--- a/source/common/frame.cpp<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/common/frame.cpp<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -143,6 +143,13 @@</div><div> delete[] m_quantOffsets;</div><div> }</div><div> </div><div>+ if (m_userSEI.numPayloads)</div><div>+ {</div><div>+ for (int i = 0; i < m_userSEI.numPayloads; i++)</div><div>+ delete[] m_userSEI.payloads[i].payload;</div><div>+ delete[] m_userSEI.payloads;</div><div>+ }</div><div>+</div><div> m_lowres.destroy();</div><div> X265_FREE(m_rcData);</div><div> }</div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/common/frame.h</div><div>--- a/source/common/frame.h<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/common/frame.h<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -85,6 +85,7 @@</div><div> bool m_bChromaExtended; // orig chroma planes motion extended for weight analysis</div><div> </div><div> float* m_quantOffsets; // points to quantOffsets in x265_picture</div><div>+ x265_sei m_userSEI;</div><div> </div><div> /* Frame Parallelism - notification between FrameEncoders of available motion reference rows */</div><div> ThreadSafeInteger m_reconRowCount; // count of CTU rows completely reconstructed and extended for motion reference</div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/encoder/api.cpp</div><div>--- a/source/encoder/api.cpp<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/encoder/api.cpp<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -282,6 +282,9 @@</div><div> pic->colorSpace = param->internalCsp;</div><div> pic->forceqp = X265_QP_AUTO;</div><div> pic->quantOffsets = NULL;</div><div>+ pic->userSEI.payloads = NULL;</div><div>+ pic->userSEI.numPayloads = 0;</div><div>+</div><div> if (param->analysisMode)</div><div> {</div><div> uint32_t widthInCU = (param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;</div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/encoder/encoder.cpp</div><div>--- a/source/encoder/encoder.cpp<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/encoder/encoder.cpp<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -589,7 +589,20 @@</div><div> inFrame->m_pts = pic_in->pts;</div><div> inFrame->m_forceqp = pic_in->forceqp;</div><div> inFrame->m_param = m_reconfigure ? m_latestParam : m_param;</div><div>- </div><div>+</div><div>+ if (pic_in->userSEI.numPayloads)</div><div>+ {</div><div>+ int numPayloads = inFrame->m_userSEI.numPayloads = pic_in->userSEI.numPayloads;</div><div>+ inFrame->m_userSEI.payloads = new x265_sei_payload[numPayloads];</div><div>+ for (int i = 0; i < numPayloads; i++)</div><div>+ {</div><div>+ int size = inFrame->m_userSEI.payloads[i].payloadSize = pic_in->userSEI.payloads[i].payloadSize;</div><div>+ inFrame->m_userSEI.payloads[i].payloadType = pic_in->userSEI.payloads[i].payloadType;</div><div>+ inFrame->m_userSEI.payloads[i].payload = new uint8_t[size];</div><div>+ memcpy(inFrame->m_userSEI.payloads[i].payload, pic_in->userSEI.payloads[i].payload, size);</div><div>+ }</div><div>+ }</div><div>+</div><div> if (pic_in->quantOffsets != NULL)</div><div> {</div><div> int cuCount = inFrame->m_lowres.maxBlocksInRow * inFrame->m_lowres.maxBlocksInCol;</div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/encoder/frameencoder.cpp</div><div>--- a/source/encoder/frameencoder.cpp<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/encoder/frameencoder.cpp<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -523,6 +523,22 @@</div><div> m_nalList.serialize(NAL_UNIT_PREFIX_SEI, m_bs);</div><div> }</div><div> </div><div>+ /* Write user SEI */</div><div>+ for (int i = 0; i < m_frame->m_userSEI.numPayloads; i++)</div><div>+ {</div><div>+ x265_sei_payload *payload = &m_frame->m_userSEI.payloads[i];</div><div>+ SEIuserDataUnregistered sei;</div><div>+</div><div>+ sei.m_payloadType = payload->payloadType;</div><div>+ sei.m_userDataLength = payload->payloadSize;</div><div>+ sei.m_userData = payload->payload;</div><div>+</div><div>+ m_bs.resetBits();</div><div>+ sei.write(m_bs, *slice->m_sps);</div><div>+ m_bs.writeByteAlignment();</div><div>+ m_nalList.serialize(NAL_UNIT_PREFIX_SEI, m_bs);</div><div>+ }</div><div>+</div><div> /* CQP and CRF (without capped VBV) doesn't use mid-frame statistics to </div><div> * tune RateControl parameters for other frames.</div><div> * Hence, for these modes, update m_startEndOrder and unlock RC for previous threads waiting in</div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/encoder/sei.h</div><div>--- a/source/encoder/sei.h<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/encoder/sei.h<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -46,36 +46,7 @@</div><div> </div><div> protected:</div><div> </div><div>- enum PayloadType</div><div>- {</div><div>- BUFFERING_PERIOD = 0,</div><div>- PICTURE_TIMING = 1,</div><div>- PAN_SCAN_RECT = 2,</div><div>- FILLER_PAYLOAD = 3,</div><div>- USER_DATA_REGISTERED_ITU_T_T35 = 4,</div><div>- USER_DATA_UNREGISTERED = 5,</div><div>- RECOVERY_POINT = 6,</div><div>- SCENE_INFO = 9,</div><div>- FULL_FRAME_SNAPSHOT = 15,</div><div>- PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,</div><div>- PROGRESSIVE_REFINEMENT_SEGMENT_END = 17,</div><div>- FILM_GRAIN_CHARACTERISTICS = 19,</div><div>- POST_FILTER_HINT = 22,</div><div>- TONE_MAPPING_INFO = 23,</div><div>- FRAME_PACKING = 45,</div><div>- DISPLAY_ORIENTATION = 47,</div><div>- SOP_DESCRIPTION = 128,</div><div>- ACTIVE_PARAMETER_SETS = 129,</div><div>- DECODING_UNIT_INFO = 130,</div><div>- TEMPORAL_LEVEL0_INDEX = 131,</div><div>- DECODED_PICTURE_HASH = 132,</div><div>- SCALABLE_NESTING = 133,</div><div>- REGION_REFRESH_INFO = 134,</div><div>- MASTERING_DISPLAY_INFO = 137,</div><div>- CONTENT_LIGHT_LEVEL_INFO = 144,</div><div>- };</div><div>-</div><div>- virtual PayloadType payloadType() const = 0;</div><div>+ virtual SEIPayloadType payloadType() const = 0;</div><div> </div><div> virtual void writeSEI(const SPS&) { X265_CHECK(0, "empty writeSEI method called\n"); }</div><div> </div><div>@@ -86,11 +57,12 @@</div><div> {</div><div> public:</div><div> </div><div>- PayloadType payloadType() const { return USER_DATA_UNREGISTERED; }</div><div>+ SEIPayloadType payloadType() const { return m_payloadType; }</div><div> </div><div> SEIuserDataUnregistered() : m_userData(NULL) {}</div><div> </div><div> static const uint8_t m_uuid_iso_iec_11578[16];</div><div>+ SEIPayloadType m_payloadType;</div><div> uint32_t m_userDataLength;</div><div> uint8_t *m_userData;</div><div> </div><div>@@ -98,7 +70,7 @@</div><div> {</div><div> m_bitIf = &bs;</div><div> </div><div>- WRITE_CODE(USER_DATA_UNREGISTERED, 8, "payload_type");</div><div>+ WRITE_CODE(m_payloadType, 8, "payload_type");</div><div> </div><div> uint32_t payloadSize = 16 + m_userDataLength;</div><div> for (; payloadSize >= 0xff; payloadSize -= 0xff)</div><div>@@ -123,7 +95,7 @@</div><div> uint32_t maxDisplayMasteringLuminance;</div><div> uint32_t minDisplayMasteringLuminance;</div><div> </div><div>- PayloadType payloadType() const { return MASTERING_DISPLAY_INFO; }</div><div>+ SEIPayloadType payloadType() const { return MASTERING_DISPLAY_INFO; }</div><div> </div><div> bool parse(const char* value)</div><div> {</div><div>@@ -161,7 +133,7 @@</div><div> uint16_t max_content_light_level;</div><div> uint16_t max_pic_average_light_level;</div><div> </div><div>- PayloadType payloadType() const { return CONTENT_LIGHT_LEVEL_INFO; }</div><div>+ SEIPayloadType payloadType() const { return CONTENT_LIGHT_LEVEL_INFO; }</div><div> </div><div> void write(Bitstream& bs, const SPS&)</div><div> {</div><div>@@ -178,7 +150,7 @@</div><div> {</div><div> public:</div><div> </div><div>- PayloadType payloadType() const { return DECODED_PICTURE_HASH; }</div><div>+ SEIPayloadType payloadType() const { return DECODED_PICTURE_HASH; }</div><div> </div><div> enum Method</div><div> {</div><div>@@ -238,7 +210,7 @@</div><div> {</div><div> public:</div><div> </div><div>- PayloadType payloadType() const { return ACTIVE_PARAMETER_SETS; }</div><div>+ SEIPayloadType payloadType() const { return ACTIVE_PARAMETER_SETS; }</div><div> </div><div> bool m_selfContainedCvsFlag;</div><div> bool m_noParamSetUpdateFlag;</div><div>@@ -258,7 +230,7 @@</div><div> {</div><div> public:</div><div> </div><div>- PayloadType payloadType() const { return BUFFERING_PERIOD; }</div><div>+ SEIPayloadType payloadType() const { return BUFFERING_PERIOD; }</div><div> </div><div> SEIBufferingPeriod()</div><div> : m_cpbDelayOffset(0)</div><div>@@ -292,7 +264,7 @@</div><div> {</div><div> public:</div><div> </div><div>- PayloadType payloadType() const { return PICTURE_TIMING; }</div><div>+ SEIPayloadType payloadType() const { return PICTURE_TIMING; }</div><div> </div><div> uint32_t m_picStruct;</div><div> uint32_t m_sourceScanType;</div><div>@@ -327,7 +299,7 @@</div><div> {</div><div> public:</div><div> </div><div>- PayloadType payloadType() const { return RECOVERY_POINT; }</div><div>+ SEIPayloadType payloadType() const { return RECOVERY_POINT; }</div><div> </div><div> int m_recoveryPocCnt;</div><div> bool m_exactMatchingFlag;</div><div>diff -r 70581d6cd065 -r 427fadf8fe2b source/x265.h</div><div>--- a/source/x265.h<span class="" style="white-space:pre"> </span>Wed Jul 13 19:24:37 2016 +0530</div><div>+++ b/source/x265.h<span class="" style="white-space:pre"> </span>Thu Jan 07 16:20:04 2016 +0530</div><div>@@ -150,6 +150,55 @@</div><div> x265_cu_stats cuStats;</div><div> } x265_frame_stats;</div><div> </div><div>+/* Arbitrary User SEI</div><div>+ * Payload size is in bytes and the payload pointer must be non-NULL. </div><div>+ * Payload types and syntax can be found in Annex D of the H.265 Specification.</div><div>+ * SEI Payload Alignment bits as described in Annex D must be included at the </div><div>+ * end of the payload if needed. The payload should not be NAL-encapsulated.</div><div>+ * Payloads are written in the order of input */</div><div>+</div><div>+typedef enum</div><div>+{</div><div>+ BUFFERING_PERIOD = 0,</div><div>+ PICTURE_TIMING = 1,</div><div>+ PAN_SCAN_RECT = 2,</div><div>+ FILLER_PAYLOAD = 3,</div><div>+ USER_DATA_REGISTERED_ITU_T_T35 = 4,</div><div>+ USER_DATA_UNREGISTERED = 5,</div><div>+ RECOVERY_POINT = 6,</div><div>+ SCENE_INFO = 9,</div><div>+ FULL_FRAME_SNAPSHOT = 15,</div><div>+ PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,</div><div>+ PROGRESSIVE_REFINEMENT_SEGMENT_END = 17,</div><div>+ FILM_GRAIN_CHARACTERISTICS = 19,</div><div>+ POST_FILTER_HINT = 22,</div><div>+ TONE_MAPPING_INFO = 23,</div><div>+ FRAME_PACKING = 45,</div><div>+ DISPLAY_ORIENTATION = 47,</div><div>+ SOP_DESCRIPTION = 128,</div><div>+ ACTIVE_PARAMETER_SETS = 129,</div><div>+ DECODING_UNIT_INFO = 130,</div><div>+ TEMPORAL_LEVEL0_INDEX = 131,</div><div>+ DECODED_PICTURE_HASH = 132,</div><div>+ SCALABLE_NESTING = 133,</div><div>+ REGION_REFRESH_INFO = 134,</div><div>+ MASTERING_DISPLAY_INFO = 137,</div><div>+ CONTENT_LIGHT_LEVEL_INFO = 144,</div><div>+} SEIPayloadType;</div><div>+</div><div>+typedef struct x265_sei_payload</div><div>+{</div><div>+ int payloadSize;</div><div>+ SEIPayloadType payloadType;</div><div>+ uint8_t* payload;</div><div>+} x265_sei_payload;</div><div>+</div><div>+typedef struct x265_sei</div><div>+{</div><div>+ int numPayloads;</div><div>+ x265_sei_payload *payloads;</div><div>+} x265_sei;</div><div>+</div><div> /* Used to pass pictures into the encoder, and to get picture data back out of</div><div> * the encoder. The input and output semantics are different */</div><div> typedef struct x265_picture</div><div>@@ -221,6 +270,9 @@</div><div> /* Frame level statistics */</div><div> x265_frame_stats frameData;</div><div> </div><div>+ /* User defined SEI */</div><div>+ x265_sei userSEI;</div><div>+</div><div> /* Ratecontrol statistics for collecting the ratecontrol information.</div><div> * It is not used for collecting the last pass ratecontrol data in </div><div> * multi pass ratecontrol mode. */</div><div><br></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div>