kodi
HevcSei.h
1 /*
2  * Copyright (C) 2024 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "BitstreamReader.h"
12 
13 #include <optional>
14 #include <vector>
15 
27 class CHevcSei
28 {
29 public:
30  CHevcSei() = default;
31  ~CHevcSei() = default;
32 
33  uint8_t m_payloadType{0};
34  size_t m_payloadSize{0};
35 
36  // In relation to the input SEI rbsp payload
37  size_t m_msgOffset{0};
38  size_t m_payloadOffset{0};
39 
40  // Parses SEI payload assumed to not have emulation prevention 3 bytes
41  static std::vector<CHevcSei> ParseSeiRbsp(const uint8_t* buf, const size_t len);
42 
43  // Clears emulation prevention 3 bytes and fills in the passed buf
44  static std::vector<CHevcSei> ParseSeiRbspUnclearedEmulation(const uint8_t* inData,
45  const size_t inDataLen,
46  std::vector<uint8_t>& buf);
47 
48  // Returns a HDR10+ SEI message if present in the list
49  static std::optional<const CHevcSei*> FindHdr10PlusSeiMessage(
50  const std::vector<uint8_t>& buf, const std::vector<CHevcSei>& messages);
51 
52  // Returns a pair with:
53  // 1) a bool for whether or not the NALU SEI payload contains a HDR10+ SEI message.
54  // 2) a vector of bytes:
55  // When not empty: the new NALU containing all but the HDR10+ SEI message.
56  // Otherwise: the NALU contained only one HDR10+ SEI and can be discarded.
57  static std::pair<bool, const std::vector<uint8_t>> RemoveHdr10PlusFromSeiNalu(
58  const uint8_t* inData, const size_t inDataLen);
59 
60 private:
61  // Parses single SEI message from the reader and pushes it to the list
62  static int ParseSeiMessage(CBitstreamReader& br, std::vector<CHevcSei>& messages);
63 
64  static std::vector<CHevcSei> ParseSeiRbspInternal(const uint8_t* buf, const size_t len);
65 };
Definition: BitstreamReader.h:13
Parses HEVC SEI messages for supplemental video information.
Definition: HevcSei.h:27