• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef TESTVAAPI_test_streamable_h
26 #define TESTVAAPI_test_streamable_h
27 
28 #include <iostream>
29 #include <va/va.h>
30 #include <va/va_str.h>
31 
32 #define CASE_ENUM_TO_STREAM(caseEnum) case caseEnum: os << #caseEnum; break;
33 
34 inline std::ostream&
35 operator<<(std::ostream& os, const VAProfile& profile)
36 {
37     return os << static_cast<int>(profile)
38            << ":" << vaProfileStr(profile);
39 }
40 
41 inline std::ostream&
42 operator<<(std::ostream& os, const VAEntrypoint& entrypoint)
43 {
44     return os << static_cast<int>(entrypoint)
45            << ":" << vaEntrypointStr(entrypoint);
46 }
47 
48 inline std::ostream&
49 operator<<(std::ostream& os, const VABufferType& type)
50 {
51     return os << static_cast<int>(type)
52            << ":" << vaBufferTypeStr(type);
53 }
54 
55 inline std::ostream&
56 operator<<(std::ostream& os, const VAGenericValueType& type)
57 {
58     switch (type) {
59         CASE_ENUM_TO_STREAM(VAGenericValueTypeInteger)
60         CASE_ENUM_TO_STREAM(VAGenericValueTypeFloat)
61         CASE_ENUM_TO_STREAM(VAGenericValueTypePointer)
62         CASE_ENUM_TO_STREAM(VAGenericValueTypeFunc)
63     default:
64         break;
65     }
66     return os << "(" << static_cast<int>(type) << ")";
67 }
68 
69 inline std::ostream&
70 operator<<(std::ostream& os, const VAGenericValue& value)
71 {
72 #define TOSTR(enumCase, field) case enumCase: return os << value.value.field; break
73     os << value.type << ":";
74     switch (value.type) {
75         TOSTR(VAGenericValueTypeInteger, i);
76         TOSTR(VAGenericValueTypeFloat, f);
77         TOSTR(VAGenericValueTypePointer, p);
78         TOSTR(VAGenericValueTypeFunc, fn);
79     default:
80         return os << "?";
81     }
82 #undef TOSTR
83 }
84 
85 inline std::ostream&
86 operator <<(std::ostream& os, const VASurfaceAttribType& type)
87 {
88     switch (type) {
89         CASE_ENUM_TO_STREAM(VASurfaceAttribNone)
90         CASE_ENUM_TO_STREAM(VASurfaceAttribPixelFormat)
91         CASE_ENUM_TO_STREAM(VASurfaceAttribMinWidth)
92         CASE_ENUM_TO_STREAM(VASurfaceAttribMaxWidth)
93         CASE_ENUM_TO_STREAM(VASurfaceAttribMinHeight)
94         CASE_ENUM_TO_STREAM(VASurfaceAttribMaxHeight)
95         CASE_ENUM_TO_STREAM(VASurfaceAttribMemoryType)
96         CASE_ENUM_TO_STREAM(VASurfaceAttribExternalBufferDescriptor)
97         CASE_ENUM_TO_STREAM(VASurfaceAttribUsageHint)
98         CASE_ENUM_TO_STREAM(VASurfaceAttribCount)
99     default:
100         break;
101     }
102     return os << "(" << static_cast<int>(type) << ")";
103 }
104 
105 inline std::ostream&
106 operator<<(std::ostream& os, const VASurfaceAttrib& attrib)
107 {
108     return os << "VASurfaceAttrib("
109            << "type = " << attrib.type
110            << ", "
111            << "flags = " << attrib.flags
112            << ", "
113            << "value = " << attrib.value
114            << ")"
115            ;
116 }
117 
118 inline std::ostream&
119 operator <<(std::ostream& os, const VAConfigAttribType& type)
120 {
121     switch (type) {
122         CASE_ENUM_TO_STREAM(VAConfigAttribRTFormat)
123         CASE_ENUM_TO_STREAM(VAConfigAttribSpatialResidual)
124         CASE_ENUM_TO_STREAM(VAConfigAttribSpatialClipping)
125         CASE_ENUM_TO_STREAM(VAConfigAttribIntraResidual)
126         CASE_ENUM_TO_STREAM(VAConfigAttribEncryption)
127         CASE_ENUM_TO_STREAM(VAConfigAttribRateControl)
128         CASE_ENUM_TO_STREAM(VAConfigAttribDecSliceMode)
129         CASE_ENUM_TO_STREAM(VAConfigAttribDecJPEG)
130         CASE_ENUM_TO_STREAM(VAConfigAttribDecProcessing)
131         CASE_ENUM_TO_STREAM(VAConfigAttribEncPackedHeaders)
132         CASE_ENUM_TO_STREAM(VAConfigAttribEncInterlaced)
133         CASE_ENUM_TO_STREAM(VAConfigAttribEncMaxRefFrames)
134         CASE_ENUM_TO_STREAM(VAConfigAttribEncMaxSlices)
135         CASE_ENUM_TO_STREAM(VAConfigAttribEncSliceStructure)
136         CASE_ENUM_TO_STREAM(VAConfigAttribEncMacroblockInfo)
137         CASE_ENUM_TO_STREAM(VAConfigAttribMaxPictureWidth)
138         CASE_ENUM_TO_STREAM(VAConfigAttribMaxPictureHeight)
139         CASE_ENUM_TO_STREAM(VAConfigAttribEncJPEG)
140         CASE_ENUM_TO_STREAM(VAConfigAttribEncQualityRange)
141         CASE_ENUM_TO_STREAM(VAConfigAttribEncQuantization)
142         CASE_ENUM_TO_STREAM(VAConfigAttribEncIntraRefresh)
143         CASE_ENUM_TO_STREAM(VAConfigAttribEncSkipFrame)
144         CASE_ENUM_TO_STREAM(VAConfigAttribEncROI)
145         CASE_ENUM_TO_STREAM(VAConfigAttribEncRateControlExt)
146         CASE_ENUM_TO_STREAM(VAConfigAttribProcessingRate)
147         CASE_ENUM_TO_STREAM(VAConfigAttribEncDirtyRect)
148         CASE_ENUM_TO_STREAM(VAConfigAttribEncParallelRateControl)
149         CASE_ENUM_TO_STREAM(VAConfigAttribEncDynamicScaling)
150         CASE_ENUM_TO_STREAM(VAConfigAttribFrameSizeToleranceSupport)
151         CASE_ENUM_TO_STREAM(VAConfigAttribFEIFunctionType)
152         CASE_ENUM_TO_STREAM(VAConfigAttribFEIMVPredictors)
153         CASE_ENUM_TO_STREAM(VAConfigAttribStats)
154         CASE_ENUM_TO_STREAM(VAConfigAttribEncTileSupport)
155         CASE_ENUM_TO_STREAM(VAConfigAttribCustomRoundingControl)
156         CASE_ENUM_TO_STREAM(VAConfigAttribQPBlockSize)
157         CASE_ENUM_TO_STREAM(VAConfigAttribMaxFrameSize)
158         CASE_ENUM_TO_STREAM(VAConfigAttribPredictionDirection)
159         CASE_ENUM_TO_STREAM(VAConfigAttribTypeMax)
160     default:
161         break;
162     }
163     return os << "(" << static_cast<int>(type) << ")";
164 }
165 
166 inline std::ostream&
167 operator <<(std::ostream& os, const VAConfigAttrib& attrib)
168 {
169     return os << "VAConfigAttrib("
170            << "type = " << attrib.type
171            << ", "
172            << "value = 0x" << std::hex << attrib.value << std::dec
173            << ")"
174            ;
175 }
176 
177 #undef CASE_ENUM_TO_STREAM
178 
179 #endif
180