1 /* -----------------------------------------------------------------------------
2 The copyright in this software is being made available under the BSD
3 License, included below. No patent rights, trademark rights and/or
4 other Intellectual Property Rights other than the copyrights concerning
5 the Software are granted under this license.
6 
7 For any license concerning other Intellectual Property rights than the software,
8 especially patent licenses, a separate Agreement needs to be closed.
9 For more information please contact:
10 
11 Fraunhofer Heinrich Hertz Institute
12 Einsteinufer 37
13 10587 Berlin, Germany
14 www.hhi.fraunhofer.de/vvc
15 vvc@hhi.fraunhofer.de
16 
17 Copyright (c) 2018-2021, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
18 All rights reserved.
19 
20 Redistribution and use in source and binary forms, with or without
21 modification, are permitted provided that the following conditions are met:
22 
23  * Redistributions of source code must retain the above copyright notice,
24    this list of conditions and the following disclaimer.
25  * Redistributions in binary form must reproduce the above copyright notice,
26    this list of conditions and the following disclaimer in the documentation
27    and/or other materials provided with the distribution.
28  * Neither the name of Fraunhofer nor the names of its contributors may
29    be used to endorse or promote products derived from this software without
30    specific prior written permission.
31 
32 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
36 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
42 THE POSSIBILITY OF SUCH DAMAGE.
43 
44 
45 ------------------------------------------------------------------------------------------- */
46 
47 #pragma once
48 
49 #include <list>
50 #include <vector>
51 #include <cstdint>
52 #include <cstring>
53 
54 #include "vvdec/sei.h"
55 
56 namespace vvdec
57 {
58 
59 typedef std::list<vvdecSEI*> seiMessages;
60 
61 class SEI_internal
62 {
63 public:
64 
SEI_internal()65   SEI_internal() {}
~SEI_internal()66   virtual ~SEI_internal() {}
67 
68   static const char *getSEIMessageString( vvdecSEIPayloadType payloadType);
69 
70   /// output a selection of SEI messages by payload type. Ownership stays in original message list.
71   static seiMessages getSeisByType(const seiMessages &seiList, vvdecSEIPayloadType seiType);
72 
73   /// remove a selection of SEI messages by payload type from the original list and return them in a new list.
74   static seiMessages extractSeisByType(seiMessages &seiList, vvdecSEIPayloadType seiType);
75 
76   /// delete list of SEI messages (freeing the referenced objects)
77   static void deleteSEIs (seiMessages &seiList);
78 
79   static vvdecSEI* allocSEI ( vvdecSEIPayloadType payloadType );
80   static int allocSEIPayload( vvdecSEI* sei, int userDefSize = -1 );
81   static int getPayloadSize ( vvdecSEIPayloadType payloadType);
82 };
83 
84 
85 
86 struct PictureHash
87 {
88   std::vector<uint8_t> hash = {};
89 
90   bool operator==(const PictureHash &other) const
91   {
92     if (other.hash.size() != hash.size())
93     {
94       return false;
95     }
96     for(uint32_t i=0; i<uint32_t(hash.size()); i++)
97     {
98       if (other.hash[i] != hash[i])
99       {
100         return false;
101       }
102     }
103     return true;
104   }
105 
106   bool operator!=(const PictureHash &other) const
107   {
108     return !(*this == other);
109   }
110 
equalPictureHash111   bool equal( vvdecSEIDecodedPictureHash digest ) const
112   {
113     if ((size_t)digest.digist_length != hash.size())
114     {
115       return false;
116     }
117     for(uint32_t i=0; i<uint32_t(hash.size()); i++)
118     {
119       if (digest.digest[i] != hash[i])
120       {
121         return false;
122       }
123     }
124     return true;
125   }
126 };
127 
128 }
129