1 /*****************************************************************************
2 * Copyright (C) 2013 x265 project
4 * Authors: Steve Borho <steve@borho.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
20 * This program is also available under a commercial proprietary license.
21 * For more information, contact us at license @ x265.com.
22 *****************************************************************************/
25 #include "bitstream.h"
31 /* x265's identifying GUID */
32 const uint8_t SEIuserDataUnregistered::m_uuid_iso_iec_11578
[16] = {
33 0x2C, 0xA2, 0xDE, 0x09, 0xB5, 0x17, 0x47, 0xDB,
34 0xBB, 0x55, 0xA4, 0xFE, 0x7F, 0xC2, 0xFC, 0x4E
37 /* marshal a single SEI message sei, storing the marshalled representation
39 void SEI::write(Bitstream
& bs
, const SPS
& sps
)
44 /* virtual writeSEI method, write to bit counter */
48 uint32_t type
= payloadType();
49 for (; type
>= 0xff; type
-= 0xff)
50 WRITE_CODE(0xff, 8, "payload_type");
51 WRITE_CODE(type
, 8, "payload_type");
53 X265_CHECK(0 == (count
.getNumberOfWrittenBits() & 7), "payload unaligned\n");
54 uint32_t payloadSize
= count
.getNumberOfWrittenBits() >> 3;
55 for (; payloadSize
>= 0xff; payloadSize
-= 0xff)
56 WRITE_CODE(0xff, 8, "payload_size");
57 WRITE_CODE(payloadSize
, 8, "payload_size");
59 /* virtual writeSEI method, write to bs */
63 void SEI::writeByteAlign()
65 // TODO: expose bs.writeByteAlignment() as virtual function
66 if (m_bitIf
->getNumberOfWrittenBits() % 8 != 0)
68 WRITE_FLAG(1, "bit_equal_to_one");
69 while (m_bitIf
->getNumberOfWrittenBits() % 8 != 0)
71 WRITE_FLAG(0, "bit_equal_to_zero");