2 * Copyright (c) 2016-present, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
9 #include "SkippableFrame.h"
11 #include "utils/Range.h"
15 using namespace pzstd
;
17 SkippableFrame::SkippableFrame(std::uint32_t size
) : frameSize_(size
) {
18 MEM_writeLE32(data_
.data(), kSkippableFrameMagicNumber
);
19 MEM_writeLE32(data_
.data() + 4, kFrameContentsSize
);
20 MEM_writeLE32(data_
.data() + 8, frameSize_
);
23 /* static */ std::size_t SkippableFrame::tryRead(ByteRange bytes
) {
24 if (bytes
.size() < SkippableFrame::kSize
||
25 MEM_readLE32(bytes
.begin()) != kSkippableFrameMagicNumber
||
26 MEM_readLE32(bytes
.begin() + 4) != kFrameContentsSize
) {
29 return MEM_readLE32(bytes
.begin() + 8);