/src/vvenc/source/Lib/apputils/IStreamIO.h
Line | Count | Source |
1 | | /* ----------------------------------------------------------------------------- |
2 | | The copyright in this software is being made available under the Clear 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 | | The Clear BSD License |
8 | | |
9 | | Copyright (c) 2019-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVenC Authors. |
10 | | All rights reserved. |
11 | | |
12 | | Redistribution and use in source and binary forms, with or without modification, |
13 | | are permitted (subject to the limitations in the disclaimer below) provided that |
14 | | the following conditions are met: |
15 | | |
16 | | * Redistributions of source code must retain the above copyright notice, |
17 | | this list of conditions and the following disclaimer. |
18 | | |
19 | | * Redistributions in binary form must reproduce the above copyright |
20 | | notice, this list of conditions and the following disclaimer in the |
21 | | documentation and/or other materials provided with the distribution. |
22 | | |
23 | | * Neither the name of the copyright holder nor the names of its |
24 | | contributors may be used to endorse or promote products derived from this |
25 | | software without specific prior written permission. |
26 | | |
27 | | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY |
28 | | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
29 | | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
30 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
31 | | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
32 | | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
33 | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
34 | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
35 | | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
36 | | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
37 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
38 | | POSSIBILITY OF SUCH DAMAGE. |
39 | | |
40 | | |
41 | | ------------------------------------------------------------------------------------------- */ |
42 | | #pragma once |
43 | | |
44 | | #include <iostream> |
45 | | #include <sstream> |
46 | | #include <string> |
47 | | #include <list> |
48 | | #include <map> |
49 | | #include <vector> |
50 | | #include <algorithm> |
51 | | #include <cstdint> |
52 | | #include <limits> |
53 | | |
54 | | #include "VVEncAppCfg.h" |
55 | | #include <vvenc/vvencCfg.h> |
56 | | |
57 | | //! \ingroup Interface |
58 | | //! \{ |
59 | | |
60 | | namespace apputils { |
61 | | |
62 | | template<typename E> |
63 | | struct SVPair |
64 | | { |
65 | | const char* str; |
66 | | E value; |
67 | | }; |
68 | | |
69 | | // ==================================================================================================================== |
70 | | // string <-> vector |
71 | | // ==================================================================================================================== |
72 | | |
73 | | template<typename T> |
74 | | class IStreamToRefVec |
75 | | { |
76 | | public: |
77 | | IStreamToRefVec( std::vector<T*> v, bool _allRequired, char _sep = 'x' ) |
78 | 0 | : valVec( v ) |
79 | 0 | , sep( _sep) |
80 | 0 | , allRequired( _allRequired) |
81 | 0 | { |
82 | 0 | } Unexecuted instantiation: apputils::IStreamToRefVec<int>::IStreamToRefVec(std::__1::vector<int*, std::__1::allocator<int*> >, bool, char) Unexecuted instantiation: apputils::IStreamToRefVec<double>::IStreamToRefVec(std::__1::vector<double*, std::__1::allocator<double*> >, bool, char) |
83 | | |
84 | | ~IStreamToRefVec() |
85 | 0 | { |
86 | 0 | } Unexecuted instantiation: apputils::IStreamToRefVec<double>::~IStreamToRefVec() Unexecuted instantiation: apputils::IStreamToRefVec<int>::~IStreamToRefVec() |
87 | | |
88 | | template<typename F> |
89 | | friend std::istream& operator >> ( std::istream& in, IStreamToRefVec<F>& toVec ); |
90 | | |
91 | | template<typename F> |
92 | | friend std::ostream& operator << ( std::ostream& os, const IStreamToRefVec<F>& toVec ); |
93 | | |
94 | | private: |
95 | | std::vector<T*> valVec; |
96 | | char sep; |
97 | | bool allRequired; |
98 | | }; |
99 | | |
100 | | template<typename T> |
101 | | inline std::istream& operator >> ( std::istream& in, IStreamToRefVec<T>& toVec ) |
102 | 0 | { |
103 | 0 | const size_t maxSize = toVec.valVec.size(); |
104 | 0 | size_t idx = 0; |
105 | 0 | bool fail = false; |
106 | | // split into multiple lines if any |
107 | 0 | while ( ! in.eof() ) |
108 | 0 | { |
109 | 0 | std::string line; |
110 | 0 | std::getline( in, line ); |
111 | | // treat all whitespaces and commas as valid separators |
112 | 0 | if( toVec.sep == 'x') |
113 | 0 | replace_if( line.begin(), line.end(), []( int c ){ return isspace( c ) || c == 'x'; }, ' ' );Unexecuted instantiation: apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<int>&)::{lambda(int)#1}::operator()(int) constUnexecuted instantiation: apputils::operator>><double>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<double>&)::{lambda(int)#1}::operator()(int) const |
114 | 0 | else if( toVec.sep == '/') |
115 | 0 | replace_if( line.begin(), line.end(), []( int c ){ return isspace( c ) || c == '/'; }, ' ' );Unexecuted instantiation: apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<int>&)::{lambda(int)#2}::operator()(int) constUnexecuted instantiation: apputils::operator>><double>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<double>&)::{lambda(int)#2}::operator()(int) const |
116 | 0 | else |
117 | 0 | replace_if( line.begin(), line.end(), []( int c ){ return isspace( c ) || c == ','; }, ' ' );Unexecuted instantiation: apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<int>&)::{lambda(int)#3}::operator()(int) constUnexecuted instantiation: apputils::operator>><double>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<double>&)::{lambda(int)#3}::operator()(int) const |
118 | 0 | std::stringstream tokenStream( line ); |
119 | 0 | std::string token; |
120 | | // split into multiple tokens if any |
121 | 0 | while( std::getline( tokenStream, token, ' ' ) ) |
122 | 0 | { |
123 | 0 | if ( ! token.length() ) |
124 | 0 | continue; |
125 | | // convert to value |
126 | 0 | std::stringstream convStream( token ); |
127 | 0 | T val; |
128 | 0 | convStream >> val; |
129 | 0 | fail |= convStream.fail(); |
130 | 0 | if( idx >= maxSize ) |
131 | 0 | { |
132 | 0 | fail = true;//try to write behind buffer |
133 | 0 | } |
134 | 0 | else |
135 | 0 | { |
136 | 0 | *toVec.valVec[idx++] = val; |
137 | 0 | } |
138 | 0 | } |
139 | 0 | } |
140 | |
|
141 | 0 | if ( fail || (toVec.allRequired && idx != maxSize) ) |
142 | 0 | { |
143 | 0 | in.setstate( std::ios::failbit ); |
144 | 0 | } |
145 | |
|
146 | 0 | return in; |
147 | 0 | } Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<int>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><double>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<double>&) |
148 | | |
149 | | template<typename T> |
150 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToRefVec<T>& toVec ) |
151 | 0 | { |
152 | 0 | bool bfirst = true; |
153 | 0 | for( auto& e: toVec.valVec ) |
154 | 0 | { |
155 | 0 | if( bfirst ) |
156 | 0 | { |
157 | 0 | bfirst = false; |
158 | 0 | } |
159 | 0 | else |
160 | 0 | { |
161 | 0 | os << toVec.sep; |
162 | 0 | } |
163 | 0 | os << *e; |
164 | 0 | } |
165 | 0 | return os; |
166 | 0 | } Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <int>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<int> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <double>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToRefVec<double> const&) |
167 | | |
168 | | |
169 | | // ==================================================================================================================== |
170 | | // string <-> enum |
171 | | // ==================================================================================================================== |
172 | | |
173 | | template<typename E> |
174 | | class IStreamToEnum |
175 | | { |
176 | | public: |
177 | | IStreamToEnum( E* d, const std::vector<SVPair<E>>* m ) |
178 | 0 | : dstVal ( d ) |
179 | 0 | , toMap( m ) |
180 | 0 | { |
181 | 0 | } Unexecuted instantiation: apputils::IStreamToEnum<vvencMsgLevel>::IStreamToEnum(vvencMsgLevel*, std::__1::vector<apputils::SVPair<vvencMsgLevel>, std::__1::allocator<apputils::SVPair<vvencMsgLevel> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencProfile>::IStreamToEnum(vvencProfile*, std::__1::vector<apputils::SVPair<vvencProfile>, std::__1::allocator<apputils::SVPair<vvencProfile> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencTier>::IStreamToEnum(vvencTier*, std::__1::vector<apputils::SVPair<vvencTier>, std::__1::allocator<apputils::SVPair<vvencTier> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencLevel>::IStreamToEnum(vvencLevel*, std::__1::vector<apputils::SVPair<vvencLevel>, std::__1::allocator<apputils::SVPair<vvencLevel> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencSegmentMode>::IStreamToEnum(vvencSegmentMode*, std::__1::vector<apputils::SVPair<vvencSegmentMode>, std::__1::allocator<apputils::SVPair<vvencSegmentMode> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencHDRMode>::IStreamToEnum(vvencHDRMode*, std::__1::vector<apputils::SVPair<vvencHDRMode>, std::__1::allocator<apputils::SVPair<vvencHDRMode> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencDecodingRefreshType>::IStreamToEnum(vvencDecodingRefreshType*, std::__1::vector<apputils::SVPair<vvencDecodingRefreshType>, std::__1::allocator<apputils::SVPair<vvencDecodingRefreshType> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<int>::IStreamToEnum(int*, std::__1::vector<apputils::SVPair<int>, std::__1::allocator<apputils::SVPair<int> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<signed char>::IStreamToEnum(signed char*, std::__1::vector<apputils::SVPair<signed char>, std::__1::allocator<apputils::SVPair<signed char> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<bool>::IStreamToEnum(bool*, std::__1::vector<apputils::SVPair<bool>, std::__1::allocator<apputils::SVPair<bool> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencCostMode>::IStreamToEnum(vvencCostMode*, std::__1::vector<apputils::SVPair<vvencCostMode>, std::__1::allocator<apputils::SVPair<vvencCostMode> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencChromaFormat>::IStreamToEnum(vvencChromaFormat*, std::__1::vector<apputils::SVPair<vvencChromaFormat>, std::__1::allocator<apputils::SVPair<vvencChromaFormat> > > const*) Unexecuted instantiation: apputils::IStreamToEnum<vvencHashType>::IStreamToEnum(vvencHashType*, std::__1::vector<apputils::SVPair<vvencHashType>, std::__1::allocator<apputils::SVPair<vvencHashType> > > const*) |
182 | | |
183 | | ~IStreamToEnum() |
184 | 0 | { |
185 | 0 | } Unexecuted instantiation: apputils::IStreamToEnum<signed char>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<int>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencHashType>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencChromaFormat>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencCostMode>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<bool>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencDecodingRefreshType>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencHDRMode>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencSegmentMode>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencLevel>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencTier>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencProfile>::~IStreamToEnum() Unexecuted instantiation: apputils::IStreamToEnum<vvencMsgLevel>::~IStreamToEnum() |
186 | | |
187 | | template<typename F> |
188 | | friend std::ostream& operator << ( std::ostream& os, const IStreamToEnum<F>& toEnum ); |
189 | | |
190 | | template<typename F> |
191 | | friend std::istream& operator >> ( std::istream& in, IStreamToEnum<F>& toEnum ); |
192 | | |
193 | | private: |
194 | | E* dstVal; |
195 | | const std::vector<SVPair<E>>* toMap; |
196 | | }; |
197 | | |
198 | | template<typename E> |
199 | | inline std::istream& operator >> ( std::istream& in, IStreamToEnum<E>& toEnum ) |
200 | 0 | { |
201 | 0 | std::string str; |
202 | 0 | in >> str; |
203 | |
|
204 | 0 | for ( const auto& map : *toEnum.toMap ) |
205 | 0 | { |
206 | 0 | if ( str == map.str ) |
207 | 0 | { |
208 | 0 | *toEnum.dstVal = map.value; |
209 | 0 | return in; |
210 | 0 | } |
211 | 0 | } |
212 | | |
213 | | /* not found */ |
214 | 0 | in.setstate( std::ios::failbit ); |
215 | 0 | return in; |
216 | 0 | } Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencMsgLevel>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencMsgLevel>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><bool>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<bool>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><signed char>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<signed char>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencDecodingRefreshType>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencDecodingRefreshType>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencProfile>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencProfile>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencLevel>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencLevel>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencTier>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencTier>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencHDRMode>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencHDRMode>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<int>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencHashType>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencHashType>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencSegmentMode>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencSegmentMode>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencChromaFormat>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencChromaFormat>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencCostMode>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencCostMode>&) |
217 | | |
218 | | template<typename E> |
219 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToEnum<E>& toEnum ) |
220 | 0 | { |
221 | 0 | for ( const auto& map : *toEnum.toMap ) |
222 | 0 | { |
223 | 0 | if ( *toEnum.dstVal == map.value ) |
224 | 0 | { |
225 | 0 | os << map.str; |
226 | 0 | return os; |
227 | 0 | } |
228 | 0 | } |
229 | | |
230 | | /* not found */ |
231 | 0 | os.setstate( std::ios::failbit ); |
232 | 0 | return os; |
233 | 0 | } Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencMsgLevel>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencMsgLevel> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <bool>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<bool> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <signed char>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<signed char> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencDecodingRefreshType>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencDecodingRefreshType> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencProfile>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencProfile> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencLevel>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencLevel> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencTier>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencTier> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencHDRMode>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencHDRMode> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <int>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<int> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencHashType>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencHashType> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencSegmentMode>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencSegmentMode> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencChromaFormat>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencChromaFormat> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencCostMode>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToEnum<vvencCostMode> const&) |
234 | | |
235 | | // ==================================================================================================================== |
236 | | // string <-> int8_t |
237 | | // ==================================================================================================================== |
238 | | |
239 | | class IStreamToInt8 |
240 | | { |
241 | | public: |
242 | | IStreamToInt8( int8_t * d ) |
243 | 0 | : dstVal ( d ) |
244 | 0 | { |
245 | 0 | } |
246 | | |
247 | | ~IStreamToInt8() |
248 | 0 | { |
249 | 0 | } |
250 | | |
251 | | friend std::ostream& operator << ( std::ostream& os, const IStreamToInt8& toInt8 ); |
252 | | |
253 | | friend std::istream& operator >> ( std::istream& in, IStreamToInt8& toInt8 ); |
254 | | |
255 | | private: |
256 | | int8_t* dstVal; |
257 | | }; |
258 | | |
259 | | inline std::istream& operator >> ( std::istream& in, IStreamToInt8& toInt8 ) |
260 | 0 | { |
261 | 0 | std::string str; |
262 | 0 | in >> str; |
263 | 0 | int ret = std::stoi( str ); |
264 | 0 | if( ret < std::numeric_limits<int8_t>::min() || ret > std::numeric_limits<int8_t>::max() ) |
265 | 0 | { |
266 | 0 | in.setstate( std::ios::failbit ); |
267 | 0 | } |
268 | 0 | *toInt8.dstVal = (int8_t)ret; |
269 | 0 | return in; |
270 | 0 | } |
271 | | |
272 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToInt8& toInt8 ) |
273 | 0 | { |
274 | 0 | os << (int)(*toInt8.dstVal); |
275 | 0 | return os; |
276 | 0 | } |
277 | | |
278 | | // ==================================================================================================================== |
279 | | // string <-> function |
280 | | // ==================================================================================================================== |
281 | | |
282 | | class VVEncAppCfg; |
283 | | typedef void (*setParamFunc) (VVEncAppCfg*, vvenc_config*, int); |
284 | | |
285 | | template<typename E> |
286 | | class IStreamToFunc |
287 | | { |
288 | | public: |
289 | | IStreamToFunc( setParamFunc func, VVEncAppCfg* appCfg, vvenc_config* encCfg, const std::vector<SVPair<E>>* m, const E _default ) |
290 | 0 | : mfunc( func ) |
291 | 0 | , mappCfg ( appCfg ) |
292 | 0 | , mencCfg( encCfg ) |
293 | 0 | , toMap( m ) |
294 | 0 | , dstVal( _default ) |
295 | 0 | { |
296 | 0 | } Unexecuted instantiation: apputils::IStreamToFunc<vvencPresetMode>::IStreamToFunc(void (*)(apputils::VVEncAppCfg*, vvenc_config*, int), apputils::VVEncAppCfg*, vvenc_config*, std::__1::vector<apputils::SVPair<vvencPresetMode>, std::__1::allocator<apputils::SVPair<vvencPresetMode> > > const*, vvencPresetMode) Unexecuted instantiation: apputils::IStreamToFunc<int>::IStreamToFunc(void (*)(apputils::VVEncAppCfg*, vvenc_config*, int), apputils::VVEncAppCfg*, vvenc_config*, std::__1::vector<apputils::SVPair<int>, std::__1::allocator<apputils::SVPair<int> > > const*, int) Unexecuted instantiation: apputils::IStreamToFunc<apputils::BitDepthAndColorSpace>::IStreamToFunc(void (*)(apputils::VVEncAppCfg*, vvenc_config*, int), apputils::VVEncAppCfg*, vvenc_config*, std::__1::vector<apputils::SVPair<apputils::BitDepthAndColorSpace>, std::__1::allocator<apputils::SVPair<apputils::BitDepthAndColorSpace> > > const*, apputils::BitDepthAndColorSpace) |
297 | | |
298 | | ~IStreamToFunc() |
299 | 0 | { |
300 | 0 | } Unexecuted instantiation: apputils::IStreamToFunc<int>::~IStreamToFunc() Unexecuted instantiation: apputils::IStreamToFunc<apputils::BitDepthAndColorSpace>::~IStreamToFunc() Unexecuted instantiation: apputils::IStreamToFunc<vvencPresetMode>::~IStreamToFunc() |
301 | | |
302 | | template<typename F> |
303 | | friend std::istream& operator >> ( std::istream& in, IStreamToFunc<F>& toEnum ); |
304 | | |
305 | | template<typename F> |
306 | | friend std::ostream& operator << ( std::ostream& in, const IStreamToFunc<F>& toEnum ); |
307 | | |
308 | | private: |
309 | | setParamFunc mfunc; |
310 | | VVEncAppCfg* mappCfg; |
311 | | vvenc_config* mencCfg; |
312 | | const std::vector<SVPair<E>>* toMap; |
313 | | E dstVal; |
314 | | }; |
315 | | |
316 | | template<typename E> |
317 | | inline std::istream& operator >> ( std::istream& in, IStreamToFunc<E>& toEnum ) |
318 | 0 | { |
319 | 0 | std::string str; |
320 | 0 | in >> str; |
321 | |
|
322 | 0 | for ( const auto& map : *toEnum.toMap ) |
323 | 0 | { |
324 | 0 | if ( str == map.str ) |
325 | 0 | { |
326 | 0 | toEnum.dstVal = map.value; |
327 | 0 | toEnum.mfunc( toEnum.mappCfg, toEnum.mencCfg, map.value); |
328 | 0 | return in; |
329 | 0 | } |
330 | 0 | } |
331 | | |
332 | | /* not found */ |
333 | 0 | in.setstate( std::ios::failbit ); |
334 | 0 | return in; |
335 | 0 | } Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><apputils::BitDepthAndColorSpace>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToFunc<apputils::BitDepthAndColorSpace>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><vvencPresetMode>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToFunc<vvencPresetMode>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToFunc<int>&) |
336 | | |
337 | | template<typename F> |
338 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToFunc<F>& toEnum ) |
339 | 0 | { |
340 | 0 | for ( const auto& map : *toEnum.toMap ) |
341 | 0 | { |
342 | 0 | if ( toEnum.dstVal == map.value ) |
343 | 0 | { |
344 | 0 | os << map.str; |
345 | 0 | return os; |
346 | 0 | } |
347 | 0 | } |
348 | | |
349 | | /* not found */ |
350 | 0 | os.setstate( std::ios::failbit ); |
351 | 0 | return os; |
352 | 0 | } Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <apputils::BitDepthAndColorSpace>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToFunc<apputils::BitDepthAndColorSpace> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <vvencPresetMode>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToFunc<vvencPresetMode> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <int>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToFunc<int> const&) |
353 | | |
354 | | // ==================================================================================================================== |
355 | | // string -> list |
356 | | // ==================================================================================================================== |
357 | | |
358 | | template<typename T> |
359 | | class IStreamToVec |
360 | | { |
361 | | public: |
362 | | IStreamToVec( std::vector<T>* v ) |
363 | | : valVec( v ) |
364 | | { |
365 | | } |
366 | | |
367 | | ~IStreamToVec() |
368 | | { |
369 | | } |
370 | | |
371 | | template<typename F> |
372 | | friend std::istream& operator >> ( std::istream& in, IStreamToVec<F>& toVec ); |
373 | | |
374 | | template<typename F> |
375 | | friend std::ostream& operator << ( std::ostream& in, const IStreamToVec<F>& toVec ); |
376 | | |
377 | | private: |
378 | | std::vector<T>* valVec; |
379 | | }; |
380 | | |
381 | | template<typename T> |
382 | | inline std::istream& operator >> ( std::istream& in, IStreamToVec<T>& toVec ) |
383 | | { |
384 | | std::vector<T>* valVec = toVec.valVec; |
385 | | valVec->clear(); |
386 | | |
387 | | bool fail = false; |
388 | | // split into multiple lines if any |
389 | | while ( ! in.eof() ) |
390 | | { |
391 | | std::string line; |
392 | | std::getline( in, line ); |
393 | | |
394 | | if( line == "[]" || line == "empty" ) |
395 | | { |
396 | | return in; // forcing empty entry |
397 | | } |
398 | | else |
399 | | { |
400 | | // treat all whitespaces and commas as valid separators |
401 | | replace_if( line.begin(), line.end(), []( int c ){ return isspace( c ) || c == ','; }, ' ' ); |
402 | | std::stringstream tokenStream( line ); |
403 | | std::string token; |
404 | | // split into multiple tokens if any |
405 | | while( std::getline( tokenStream, token, ' ' ) ) |
406 | | { |
407 | | if ( ! token.length() ) |
408 | | continue; |
409 | | // convert to value |
410 | | std::stringstream convStream( token ); |
411 | | T val; |
412 | | convStream >> val; |
413 | | fail |= convStream.fail(); |
414 | | valVec->push_back( val ); |
415 | | } |
416 | | } |
417 | | } |
418 | | |
419 | | if ( fail || (! valVec->size() ) ) |
420 | | { |
421 | | in.setstate( std::ios::failbit ); |
422 | | } |
423 | | |
424 | | return in; |
425 | | } |
426 | | |
427 | | template<typename T> |
428 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToVec<T>& toVec ) |
429 | | { |
430 | | if( (*(toVec.valVec)).empty() ) |
431 | | { |
432 | | os << "[]"; |
433 | | return os; |
434 | | } |
435 | | |
436 | | bool bfirst = true; |
437 | | for( auto& e : (*(toVec.valVec))) |
438 | | { |
439 | | if( bfirst ) |
440 | | { |
441 | | bfirst = false; |
442 | | } |
443 | | else |
444 | | { |
445 | | os << ","; |
446 | | } |
447 | | os << e; |
448 | | } |
449 | | |
450 | | return os; |
451 | | } |
452 | | |
453 | | |
454 | | // ==================================================================================================================== |
455 | | // string -> array |
456 | | // ==================================================================================================================== |
457 | | |
458 | | template<typename T> |
459 | | class IStreamToArr |
460 | | { |
461 | | public: |
462 | | IStreamToArr( T* v, size_t maxSize ) |
463 | 0 | : _valVec ( v ) |
464 | 0 | , _maxSize ( maxSize ) |
465 | 0 | , _curSize ( nullptr ) |
466 | 0 | { |
467 | 0 | } Unexecuted instantiation: apputils::IStreamToArr<int>::IStreamToArr(int*, unsigned long) Unexecuted instantiation: apputils::IStreamToArr<double>::IStreamToArr(double*, unsigned long) Unexecuted instantiation: apputils::IStreamToArr<unsigned int>::IStreamToArr(unsigned int*, unsigned long) Unexecuted instantiation: apputils::IStreamToArr<char>::IStreamToArr(char*, unsigned long) |
468 | | |
469 | | IStreamToArr( T* v, size_t maxSize, int* curSize ) |
470 | 0 | : _valVec ( v ) |
471 | 0 | , _maxSize ( maxSize ) |
472 | 0 | , _curSize ( curSize ) |
473 | 0 | { |
474 | 0 | } Unexecuted instantiation: apputils::IStreamToArr<int>::IStreamToArr(int*, unsigned long, int*) Unexecuted instantiation: apputils::IStreamToArr<double>::IStreamToArr(double*, unsigned long, int*) |
475 | | |
476 | | ~IStreamToArr() |
477 | 0 | { |
478 | 0 | } Unexecuted instantiation: apputils::IStreamToArr<char>::~IStreamToArr() Unexecuted instantiation: apputils::IStreamToArr<unsigned int>::~IStreamToArr() Unexecuted instantiation: apputils::IStreamToArr<double>::~IStreamToArr() Unexecuted instantiation: apputils::IStreamToArr<int>::~IStreamToArr() |
479 | | |
480 | | template<typename F> |
481 | | friend std::istream& operator >> ( std::istream& in, IStreamToArr<F>& toArr ); |
482 | | |
483 | | template<typename F> |
484 | | friend std::ostream& operator << ( std::ostream& in, const IStreamToArr<F>& toArr ); |
485 | | |
486 | | private: |
487 | | T* _valVec; |
488 | | size_t _maxSize; |
489 | | int* _curSize; |
490 | | }; |
491 | | |
492 | | template<typename T> |
493 | | inline std::istream& operator >> ( std::istream& in, IStreamToArr<T>& toArr ) |
494 | 0 | { |
495 | 0 | for( size_t i = 0; i < toArr._maxSize; i++ ) memset(&toArr._valVec[i],0, sizeof(T)); |
496 | |
|
497 | 0 | bool fail = false; |
498 | 0 | size_t pos = 0; |
499 | 0 | if ( toArr._curSize ) *toArr._curSize = 0; |
500 | | // split into multiple lines if any |
501 | 0 | while ( ! in.eof() ) |
502 | 0 | { |
503 | 0 | std::string line; |
504 | 0 | std::getline( in, line ); |
505 | |
|
506 | 0 | if( line == "[]" || line == "empty" ) |
507 | 0 | { |
508 | 0 | return in; // forcing empty entry |
509 | 0 | } |
510 | 0 | else |
511 | 0 | { |
512 | | // treat all whitespaces and commas as valid separators |
513 | 0 | replace_if( line.begin(), line.end(), []( int c ){ return isspace( c ) || c == ','; }, ' ' );Unexecuted instantiation: apputils::operator>><double>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<double>&)::{lambda(int)#1}::operator()(int) constUnexecuted instantiation: apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<int>&)::{lambda(int)#1}::operator()(int) constUnexecuted instantiation: apputils::operator>><unsigned int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<unsigned int>&)::{lambda(int)#1}::operator()(int) const |
514 | 0 | std::stringstream tokenStream( line ); |
515 | 0 | std::string token; |
516 | | // split into multiple tokens if any |
517 | 0 | while( std::getline( tokenStream, token, ' ' ) ) |
518 | 0 | { |
519 | 0 | if ( ! token.length() ) |
520 | 0 | continue; |
521 | | // convert to value |
522 | 0 | std::stringstream convStream( token ); |
523 | 0 | T val; |
524 | 0 | convStream >> val; |
525 | 0 | fail |= convStream.fail(); |
526 | |
|
527 | 0 | if ( pos < toArr._maxSize ) |
528 | 0 | { |
529 | 0 | toArr._valVec[pos] = val; |
530 | 0 | } |
531 | 0 | pos++; |
532 | 0 | } |
533 | 0 | } |
534 | 0 | } |
535 | | |
536 | 0 | if ( fail || ( 0 == pos ) || (pos > toArr._maxSize) ) |
537 | 0 | { |
538 | 0 | in.setstate( std::ios::failbit ); |
539 | 0 | } |
540 | |
|
541 | 0 | if ( toArr._curSize ) *toArr._curSize = static_cast<int>( std::min<size_t>( pos, toArr._maxSize ) ); |
542 | |
|
543 | 0 | return in; |
544 | 0 | } Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><double>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<double>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<int>&) Unexecuted instantiation: std::__1::basic_istream<char, std::__1::char_traits<char> >& apputils::operator>><unsigned int>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<unsigned int>&) |
545 | | |
546 | | template<> |
547 | | inline std::istream& operator >> ( std::istream& in, IStreamToArr<char>& toArr ) |
548 | 0 | { |
549 | 0 | for( size_t i = 0; i < toArr._maxSize; i++ ) memset(&toArr._valVec[i],0, sizeof(char)); |
550 | |
|
551 | 0 | bool fail = false; |
552 | 0 | size_t size = 0; |
553 | | // split into multiple lines if any |
554 | 0 | while ( ! in.eof() ) |
555 | 0 | { |
556 | 0 | std::string line; |
557 | 0 | std::getline( in, line ); |
558 | |
|
559 | 0 | if( line == "" || line == "\"\"" || line == "[]" || line == "empty" || line == "''" ) |
560 | 0 | { |
561 | 0 | return in; // forcing empty entry |
562 | 0 | } |
563 | 0 | else |
564 | 0 | { |
565 | 0 | if( line.size() >= toArr._maxSize ) |
566 | 0 | { |
567 | 0 | line.copy( toArr._valVec , toArr._maxSize-1 ); |
568 | 0 | toArr._valVec[toArr._maxSize-1] = '\0'; |
569 | 0 | fail = true; |
570 | 0 | } |
571 | 0 | else |
572 | 0 | { |
573 | 0 | line.copy( toArr._valVec , line.size()+1 ); |
574 | 0 | toArr._valVec[line.size()] = '\0'; |
575 | 0 | size = line.size(); |
576 | 0 | } |
577 | 0 | } |
578 | 0 | } |
579 | | |
580 | 0 | if ( fail || ( 0 == size ) ) |
581 | 0 | { |
582 | 0 | in.setstate( std::ios::failbit ); |
583 | 0 | } |
584 | |
|
585 | 0 | return in; |
586 | 0 | } |
587 | | |
588 | | template<typename T> |
589 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToArr<T>& toArr ) |
590 | 0 | { |
591 | 0 | int size=0; |
592 | 0 | for ( size_t i = 0; i < toArr._maxSize; i++ ) |
593 | 0 | { |
594 | 0 | if( toArr._valVec[i] != 0 ) size++; |
595 | 0 | else break; |
596 | 0 | } |
597 | |
|
598 | 0 | if( 0 == size ) |
599 | 0 | { |
600 | 0 | os << "[]"; |
601 | 0 | return os; |
602 | 0 | } |
603 | | |
604 | 0 | bool bfirst = true; |
605 | 0 | for ( int i = 0; i < size; i++ ) |
606 | 0 | { |
607 | 0 | if( bfirst ) |
608 | 0 | { |
609 | 0 | bfirst = false; |
610 | 0 | } |
611 | 0 | else |
612 | 0 | { |
613 | 0 | os << ","; |
614 | 0 | } |
615 | 0 | os << toArr._valVec[i]; |
616 | 0 | } |
617 | |
|
618 | 0 | return os; |
619 | 0 | } Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <double>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<double> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <int>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<int> const&) Unexecuted instantiation: std::__1::basic_ostream<char, std::__1::char_traits<char> >& apputils::operator<< <unsigned int>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, apputils::IStreamToArr<unsigned int> const&) |
620 | | |
621 | | template<> |
622 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToArr<char>& toArr ) |
623 | 0 | { |
624 | 0 | int size=0; |
625 | 0 | for ( size_t i = 0; i < toArr._maxSize; i++ ) |
626 | 0 | { |
627 | 0 | if( toArr._valVec[i] != '\0' ) size++; |
628 | 0 | else break; |
629 | 0 | } |
630 | |
|
631 | 0 | if( 0 == size ) |
632 | 0 | { |
633 | 0 | os << "''"; |
634 | 0 | return os; |
635 | 0 | } |
636 | | |
637 | 0 | for ( int i = 0; i < size; i++ ) |
638 | 0 | { |
639 | 0 | os << toArr._valVec[i]; |
640 | 0 | } |
641 | |
|
642 | 0 | return os; |
643 | 0 | } |
644 | | |
645 | | |
646 | | // ==================================================================================================================== |
647 | | // string -> abbreviated value |
648 | | // ==================================================================================================================== |
649 | | |
650 | | // T: value type, A abbreviation value type |
651 | | template<typename T, typename A> |
652 | | class IStreamToAbbr |
653 | | { |
654 | | public: |
655 | | IStreamToAbbr( T* v, const std::vector<SVPair<A>>* m ) |
656 | 0 | : dstVal ( v ) |
657 | 0 | , toMap ( m ) |
658 | 0 | { |
659 | 0 | } |
660 | | |
661 | | ~IStreamToAbbr() |
662 | 0 | { |
663 | 0 | } |
664 | | |
665 | | template<typename F, typename G> |
666 | | friend std::istream& operator >> ( std::istream& in, IStreamToAbbr<F,G>& toValue ); |
667 | | |
668 | | template<typename F, typename G> |
669 | | friend std::ostream& operator << ( std::ostream& in, const IStreamToAbbr<F,G>& toValue ); |
670 | | |
671 | | private: |
672 | | T* dstVal; |
673 | | const std::vector<SVPair<A>>* toMap; |
674 | | }; |
675 | | |
676 | | template<typename T, typename A> |
677 | | inline std::istream& operator >> ( std::istream& in, IStreamToAbbr<T,A>& toValue ) |
678 | 0 | { |
679 | 0 | std::string str; |
680 | 0 | in >> str; |
681 | | |
682 | | // search map for a used abbreviation |
683 | 0 | for ( const auto& map : *toValue.toMap ) |
684 | 0 | { |
685 | 0 | std::string key(map.str); |
686 | 0 | std::size_t n = str.find( key ); |
687 | 0 | if (n!=std::string::npos) |
688 | 0 | { |
689 | 0 | str.erase(n, key.length()); // remove the scaling unit, e.g. 1.5M -> 1.5 |
690 | 0 | replace_if( str.begin(), str.end(), []( int c ){ return c == ','; }, '.' ); // use correct comma syntax for double representaion |
691 | |
|
692 | 0 | bool isNumber = strspn( str.c_str(), "-.0123456789" ) == str.size(); // check if valid double value |
693 | 0 | if( !isNumber) |
694 | 0 | { |
695 | 0 | in.setstate( std::ios::failbit ); |
696 | 0 | return in; |
697 | 0 | } |
698 | | |
699 | 0 | double value = strtod(str.c_str(), NULL); // convert input string to double |
700 | 0 | value *= map.value; // scale depending on given abbreviation/scaling factor |
701 | 0 | double roundDir = value < 0 ? -1 : ( value > 0 ? 1 : 0 ); |
702 | 0 | double roundOffset = std::is_floating_point<T>::value ? 0.0 : 0.5; |
703 | 0 | value += roundDir * roundOffset; |
704 | 0 | *toValue.dstVal = ( T ) value; |
705 | 0 | return in; |
706 | 0 | } |
707 | 0 | } |
708 | | |
709 | | // read value in original format |
710 | 0 | std::string::size_type posAfter; |
711 | 0 | *toValue.dstVal = std::stoi( str, &posAfter ); |
712 | |
|
713 | 0 | if( posAfter && !str.substr(posAfter).empty() ) // check if value is valid int |
714 | 0 | { |
715 | 0 | in.setstate( std::ios::failbit ); |
716 | 0 | } |
717 | |
|
718 | 0 | return in; |
719 | 0 | } |
720 | | |
721 | | template<typename T, typename A> |
722 | | inline std::ostream& operator << ( std::ostream& os, const IStreamToAbbr<T,A>& toValue ) |
723 | 0 | { |
724 | 0 | os << *toValue.dstVal; |
725 | 0 | return os; |
726 | 0 | } |
727 | | |
728 | | |
729 | | // ==================================================================================================================== |
730 | | // vvencGOPEntry |
731 | | // ==================================================================================================================== |
732 | | |
733 | | |
734 | | inline std::ostream& operator<< ( std::ostream& os, const vvencGOPEntry& entry ) |
735 | 0 | { |
736 | 0 | os << entry.m_sliceType; |
737 | 0 | os << entry.m_POC; |
738 | 0 | os << entry.m_QPOffset; |
739 | 0 | os << entry.m_QPOffsetModelOffset; |
740 | 0 | os << entry.m_QPOffsetModelScale; |
741 | 0 | os << entry.m_CbQPoffset; |
742 | 0 | os << entry.m_CrQPoffset; |
743 | 0 | os << entry.m_QPFactor; |
744 | 0 | os << entry.m_tcOffsetDiv2; |
745 | 0 | os << entry.m_betaOffsetDiv2; |
746 | 0 | os << entry.m_cfgUnused1; |
747 | 0 | os << entry.m_cfgUnused2; |
748 | 0 | os << entry.m_cfgUnused3; |
749 | 0 | os << entry.m_cfgUnused4; |
750 | 0 | os << entry.m_temporalId; |
751 | |
|
752 | 0 | for( int l = 0; l < 2; l++) |
753 | 0 | { |
754 | 0 | os << entry.m_numRefPicsActive[l]; |
755 | 0 | os << entry.m_numRefPics[l]; |
756 | 0 | for ( int i = 0; i < entry.m_numRefPics[l]; i++ ) |
757 | 0 | { |
758 | 0 | os << entry.m_deltaRefPics[l][i]; |
759 | 0 | } |
760 | 0 | } |
761 | |
|
762 | 0 | return os; |
763 | 0 | } |
764 | | |
765 | | inline std::istream& operator>> ( std::istream& in, vvencGOPEntry& entry ) |
766 | 0 | { |
767 | 0 | in >> entry.m_sliceType; |
768 | 0 | in >> entry.m_POC; |
769 | 0 | in >> entry.m_QPOffset; |
770 | 0 | in >> entry.m_QPOffsetModelOffset; |
771 | 0 | in >> entry.m_QPOffsetModelScale; |
772 | 0 | in >> entry.m_CbQPoffset; |
773 | 0 | in >> entry.m_CrQPoffset; |
774 | 0 | in >> entry.m_QPFactor; |
775 | 0 | in >> entry.m_tcOffsetDiv2; |
776 | 0 | in >> entry.m_betaOffsetDiv2; |
777 | 0 | in >> entry.m_cfgUnused1; |
778 | 0 | in >> entry.m_cfgUnused2; |
779 | 0 | in >> entry.m_cfgUnused3; |
780 | 0 | in >> entry.m_cfgUnused4; |
781 | 0 | in >> entry.m_temporalId; |
782 | |
|
783 | 0 | for( int l = 0; l < 2; l++) |
784 | 0 | { |
785 | 0 | in >> entry.m_numRefPicsActive[l]; |
786 | 0 | in >> entry.m_numRefPics[l]; |
787 | 0 | for ( int i = 0; i < entry.m_numRefPics[l]; i++ ) |
788 | 0 | { |
789 | 0 | in >> entry.m_deltaRefPics[l][i]; |
790 | 0 | } |
791 | 0 | } |
792 | |
|
793 | 0 | return in; |
794 | 0 | } |
795 | | |
796 | | |
797 | | } // namespace |
798 | | |
799 | | //! \} |
800 | | |