Mercurial > hg > forks > libbpg
comparison x265/source/encoder/sei.cpp @ 0:772086c29cc7
Initial import.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 16 Nov 2016 11:16:33 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:772086c29cc7 |
---|---|
1 /***************************************************************************** | |
2 * Copyright (C) 2013 x265 project | |
3 * | |
4 * Authors: Steve Borho <steve@borho.org> | |
5 * | |
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. | |
10 * | |
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. | |
15 * | |
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. | |
19 * | |
20 * This program is also available under a commercial proprietary license. | |
21 * For more information, contact us at license @ x265.com. | |
22 *****************************************************************************/ | |
23 | |
24 #include "common.h" | |
25 #include "bitstream.h" | |
26 #include "slice.h" | |
27 #include "sei.h" | |
28 | |
29 using namespace X265_NS; | |
30 | |
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 | |
35 }; | |
36 | |
37 /* marshal a single SEI message sei, storing the marshalled representation | |
38 * in bitstream bs */ | |
39 void SEI::write(Bitstream& bs, const SPS& sps) | |
40 { | |
41 BitCounter count; | |
42 m_bitIf = &count; | |
43 | |
44 /* virtual writeSEI method, write to bit counter */ | |
45 writeSEI(sps); | |
46 | |
47 m_bitIf = &bs; | |
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"); | |
52 | |
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"); | |
58 | |
59 /* virtual writeSEI method, write to bs */ | |
60 writeSEI(sps); | |
61 } | |
62 | |
63 void SEI::writeByteAlign() | |
64 { | |
65 // TODO: expose bs.writeByteAlignment() as virtual function | |
66 if (m_bitIf->getNumberOfWrittenBits() % 8 != 0) | |
67 { | |
68 WRITE_FLAG(1, "bit_equal_to_one"); | |
69 while (m_bitIf->getNumberOfWrittenBits() % 8 != 0) | |
70 { | |
71 WRITE_FLAG(0, "bit_equal_to_zero"); | |
72 } | |
73 } | |
74 } |