[x265] [PATCH] sei: emit SEI describing the encoder and encode options

Steve Borho steve at borho.org
Sat Jul 12 02:38:59 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1405125515 18000
#      Fri Jul 11 19:38:35 2014 -0500
# Node ID 4b4f60890200280ce61d54be9a9356bd69ad6297
# Parent  6e116afd68e711a04427b5f1a4f618a37800f3c2
sei: emit SEI describing the encoder and encode options

example:
% x265 ../sintel_trailer_2k_480p24.y4m o.bin
% strings o.bin | head
x265 (build 26) - 1.2+74-a5024bfc0b50:[Mac OS X][clang 5.1.0][64 bit] 8bpp -
H.265/HEVC codec - Copyright 2013-2014 (c) Multicoreware Inc - http://x265.org
- options: 856x480 fps=24/1 bitdepth=8 wpp ctu=64 tu-intra-depth=1
tu-inter-depth=1 me=1 subme=2 merange=57 no-rect no-amp max-merge=2
no-early-skip no-fast-cbf rdpenalty=0 no-tskip no-tskip-fast
strong-intra-smoothing no-lossless no-cu-lossless no-constrained-intra open-gop
interlace=0 keyint=250 min-keyint=24 scenecut=40 rc-lookahead=20 bframes=4
bframe-bias=0 b-adapt=2 ref=3 weightp no-weightb aq-mode=2 aq-strength=1.00
cbqpoffs=0 crqpoffs=0 rd=3 signhide lft sao sao-lcu-bounds=0 sao-lcu-opt=1
b-pyramid cutree rc=crf crf=28.0 qcomp=0.60 qpmin=0 qpmax=51 qpstep=4
ipratio=1.40 pbratio=1.30

diff -r 6e116afd68e7 -r 4b4f60890200 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Fri Jul 11 16:53:40 2014 -0500
+++ b/source/encoder/frameencoder.cpp	Fri Jul 11 19:38:35 2014 -0500
@@ -25,6 +25,7 @@
 
 #include "PPA/ppa.h"
 #include "wavefront.h"
+#include "param.h"
 
 #include "encoder.h"
 #include "frameencoder.h"
@@ -224,6 +225,33 @@
     bs.writeByteAlignment();
     list.serialize(NAL_UNIT_PPS, bs);
 
+    SEIuserDataUnregistered idsei;
+    char *opts = x265_param2string(m_param);
+    if (opts)
+    {
+        char *buffer = X265_MALLOC(char, strlen(opts) + strlen(x265_version_str) +
+                                         strlen(x265_build_info_str) + 200);
+        if (buffer)
+        {
+            sprintf(buffer, "x265 (build %d) - %s:%s - H.265/HEVC codec - "
+                    "Copyright 2013-2014 (c) Multicoreware Inc - "
+                    "http://x265.org - options: %s",
+                    X265_BUILD, x265_version_str, x265_build_info_str, opts);
+            
+            idsei.m_userData = (uint8_t*)buffer;
+            idsei.m_userDataLength = strlen(buffer);
+
+            bs.resetBits();
+            idsei.write(bs, m_sps);
+            bs.writeByteAlignment();
+            list.serialize(NAL_UNIT_PREFIX_SEI, bs);
+
+            X265_FREE(buffer);
+        }
+
+        X265_FREE(opts);
+    }
+
     if (m_param->bEmitHRDSEI)
     {
         SEIActiveParameterSets sei;
diff -r 6e116afd68e7 -r 4b4f60890200 source/encoder/sei.cpp
--- a/source/encoder/sei.cpp	Fri Jul 11 16:53:40 2014 -0500
+++ b/source/encoder/sei.cpp	Fri Jul 11 19:38:35 2014 -0500
@@ -28,6 +28,12 @@
 
 using namespace x265;
 
+/* x265's identifying GUID */
+const uint8_t SEIuserDataUnregistered::m_uuid_iso_iec_11578[16] = {
+    0x2C, 0xA2, 0xDE, 0x09, 0xB5, 0x17, 0x47, 0xDB,
+    0xBB, 0x55, 0xA4, 0xFE, 0x7F, 0xC2, 0xFC, 0x4E
+};
+
 /* marshal a single SEI message sei, storing the marshalled representation
  * in bitstream bs */
 void SEI::write(Bitstream& bs, TComSPS& sps)
diff -r 6e116afd68e7 -r 4b4f60890200 source/encoder/sei.h
--- a/source/encoder/sei.h	Fri Jul 11 16:53:40 2014 -0500
+++ b/source/encoder/sei.h	Fri Jul 11 19:38:35 2014 -0500
@@ -80,6 +80,37 @@
     void writeByteAlign();
 };
 
+class SEIuserDataUnregistered : public SEI
+{
+public:
+
+    PayloadType payloadType() const { return USER_DATA_UNREGISTERED; }
+
+    SEIuserDataUnregistered() : m_userData(NULL) {}
+
+    static const uint8_t m_uuid_iso_iec_11578[16];
+    uint32_t m_userDataLength;
+    uint8_t *m_userData;
+
+    void write(Bitstream& bs, TComSPS&)
+    {
+        m_bitIf = &bs;
+
+        WRITE_CODE(USER_DATA_UNREGISTERED, 8, "payload_type");
+
+        uint32_t payloadSize = 16 + m_userDataLength;
+        for (; payloadSize >= 0xff; payloadSize -= 0xff)
+            WRITE_CODE(0xff, 8, "payload_size");
+        WRITE_CODE(payloadSize, 8, "payload_size");
+
+        for (uint32_t i = 0; i < 16; i++)
+            WRITE_CODE(m_uuid_iso_iec_11578[i], 8, "sei.uuid_iso_iec_11578[i]");
+
+        for (uint32_t i = 0; i < m_userDataLength; i++)
+            WRITE_CODE(m_userData[i], 8, "user_data");
+    }
+};
+
 class SEIDecodedPictureHash : public SEI
 {
 public:


More information about the x265-devel mailing list