2 Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic 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 DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "constants.h"
23 #include "dcpomatic_assert.h"
25 #include "vp9_pcm_block.h"
31 auto constexpr pcm_block_size = SIGN_LANGUAGE_AUDIO_FRAME_RATE * AUDIO_BYTES_PER_SAMPLE * SIGN_LANGUAGE_CHUNK_LENGTH_IN_SECONDS;
34 VP9PCMBlock::VP9PCMBlock(uint8_t const* vp9_segment, int vp9_segment_size, vector<uint8_t> const& ebml_header)
35 : _data(pcm_block_size)
37 uint32_t const ebml_header_size = ebml_header.size();
39 DCPOMATIC_ASSERT(vp9_segment_size < static_cast<int>((pcm_block_size - 20 - ebml_header_size)));
46 // Length of VP9 segment, big-endian, unsigned
47 _data[4] = (vp9_segment_size >> 24) & 0xff;
48 _data[5] = (vp9_segment_size >> 16) & 0xff;
49 _data[6] = (vp9_segment_size >> 8) & 0xff;
50 _data[7] = (vp9_segment_size >> 0) & 0xff;
51 // Length of PCM block, big-endian, unsigned
52 _data[8] = (pcm_block_size >> 24) & 0xff;
53 _data[9] = (pcm_block_size >> 16) & 0xff;
54 _data[10] = (pcm_block_size >> 8) & 0xff;
55 _data[11] = (pcm_block_size >> 0) & 0xff;
56 // Length of VP9 EBML header, big-endian, unsigned
57 _data[12] = (ebml_header_size >> 24) & 0xff;
58 _data[13] = (ebml_header_size >> 16) & 0xff;
59 _data[14] = (ebml_header_size >> 8) & 0xff;
60 _data[15] = (ebml_header_size >> 0) & 0xff;
67 std::copy(ebml_header.begin(), ebml_header.end(), _data.begin() + 20);
69 memcpy(_data.data() + 20 + ebml_header.size(), vp9_segment, vp9_segment_size);