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