2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
25 #ifndef I965_STREAMABLE_H
26 #define I965_STREAMABLE_H
34 #include <va/va_str.h>
37 template <typename T, const size_t S> inline std::ostream&
38 operator<<(std::ostream& os, const std::array<T, S>& a)
41 for (const auto& s : a) {
49 template <const size_t S> inline std::ostream&
50 operator<<(std::ostream& os, const std::array<uint8_t, S>& a)
52 os << "{" << std::hex;
53 for (const auto& s : a) {
56 os << "0x" << std::setfill('0') << std::setw(2) << unsigned(s);
58 return os << std::dec << "}";
61 template <typename T> inline std::ostream&
62 operator<<(std::ostream& os, const std::valarray<T>& a)
65 for (const auto& s : a) {
73 template <> inline std::ostream&
74 operator<<(std::ostream& os, const std::valarray<uint8_t>& a)
76 os << "{" << std::hex;
77 for (const auto& s : a) {
80 os << "0x" << std::setfill('0') << std::setw(2) << unsigned(s);
82 return os << std::dec << "}";
87 const std::string toString(const T& t)
89 std::ostringstream os;
95 operator<<(std::ostream& os, const VAEncPictureParameterBufferJPEG& b)
97 os << "VAEncPictureParameterBufferJPEG (" << &b << ")" << std::endl
98 << " .reconstructed_picture = " << b.reconstructed_picture
101 << " .picture_width = " << b.picture_width
104 << " .picture_height = " << b.picture_height
107 << " .coded_buf = " << b.coded_buf
110 << " .pic_flags.value = "
111 << std::hex << std::setw(8) << std::setfill('0') << b.pic_flags.value
115 << " ...profile = " << b.pic_flags.bits.profile
116 << " (0 - Baseline, 1 - Extended, 2 - Lossless, 3 - Hierarchical)"
119 << " ...progressive = " << b.pic_flags.bits.progressive
120 << " (0 - sequential, 1 - extended, 2 - progressive)"
123 << " ...huffman = " << b.pic_flags.bits.huffman
124 << " (0 - arithmetic, 1 - huffman)"
127 << " ...interleaved = " << b.pic_flags.bits.interleaved
128 << " (0 - non interleaved, 1 - interleaved)"
131 << " ...differential = " << b.pic_flags.bits.differential
132 << " (0 - non differential, 1 - differential)"
135 << " .sample_bit_depth = " << (unsigned)b.sample_bit_depth
138 << " .num_scan = " << (unsigned)b.num_scan
141 << " .num_components = " << (unsigned)b.num_components
144 << " .component_id = "
145 << (unsigned)b.component_id[0] << ","
146 << (unsigned)b.component_id[1] << ","
147 << (unsigned)b.component_id[2] << ","
148 << (unsigned)b.component_id[3] << ","
151 << " .quantiser_table_selector = "
152 << (unsigned)b.quantiser_table_selector[0] << ","
153 << (unsigned)b.quantiser_table_selector[1] << ","
154 << (unsigned)b.quantiser_table_selector[2] << ","
155 << (unsigned)b.quantiser_table_selector[3] << ","
158 << " .quality = " << (unsigned)b.quality
165 operator<<(std::ostream& os, const VAEncPictureParameterBufferJPEG* b)
172 operator<<(std::ostream& os, const VAQMatrixBufferJPEG& b)
174 os << "VAQMatrixBufferJPEG (" << &b << ")" << std::endl;
176 os << " .load_lum_quantiser_matrix = " << b.load_lum_quantiser_matrix
180 if (b.load_lum_quantiser_matrix)
182 os << " .lum_quantiser_matrix = ";
183 for (size_t i(0); i < sizeof(b.lum_quantiser_matrix); ++i) {
184 os << std::hex << std::setw(2) << std::setfill('0')
185 << (unsigned)b.lum_quantiser_matrix[i] << ",";
186 if (((i+1) % 12) == 0)
187 os << std::endl << " ";
189 os << std::dec << std::endl;
192 os << " .load_chroma_quantiser_matrix = " << b.load_chroma_quantiser_matrix
196 if (b.load_lum_quantiser_matrix)
198 os << " .chroma_quantiser_matrix = ";
199 for (size_t i(0); i < sizeof(b.chroma_quantiser_matrix); ++i) {
200 os << std::hex << std::setw(2) << std::setfill('0')
201 << (unsigned)b.chroma_quantiser_matrix[i] << ",";
202 if (((i+1) % 12) == 0)
203 os << std::endl << " ";
205 os << std::dec << std::endl;
212 operator<<(std::ostream& os, const VAQMatrixBufferJPEG* b)
219 operator<<(std::ostream& os, const VAHuffmanTableBufferJPEGBaseline& b)
221 os << "VAHuffmanTableBufferJPEGBaseline (" << &b << ")" << std::endl;
223 os << " .load_huffman_table = "
224 << (unsigned)b.load_huffman_table[0] << ","
225 << (unsigned)b.load_huffman_table[1] << ","
229 for (size_t i(0); i < 2; ++i) {
231 os << " .huffman_table[" << i << "].num_dc_codes = ";
232 for (size_t j(0); j < sizeof(b.huffman_table[i].num_dc_codes); ++j) {
233 if (j and (j % 12) == 0)
234 os << std::endl << " ";
235 os << std::hex << std::setfill('0') << std::setw(2)
236 << (unsigned)b.huffman_table[i].num_dc_codes[j] << ","
239 sum += b.huffman_table[i].num_dc_codes[j];
241 os << " (sum = " << sum << ")" << std::endl;
243 os << " .huffman_table[" << i << "].dc_values = ";
244 for (size_t j(0); j < sizeof(b.huffman_table[i].dc_values); ++j) {
245 if (j and (j % 12) == 0)
246 os << std::endl << " ";
247 os << std::hex << std::setfill('0') << std::setw(2)
248 << (unsigned)b.huffman_table[i].dc_values[j] << ","
255 os << " .huffman_table[" << i << "].num_ac_codes = ";
256 for (size_t j(0); j < sizeof(b.huffman_table[i].num_ac_codes); ++j) {
257 if (j and (j % 12) == 0)
258 os << std::endl << " ";
259 os << std::hex << std::setfill('0') << std::setw(2)
260 << (unsigned)b.huffman_table[i].num_ac_codes[j] << ","
263 sum += b.huffman_table[i].num_ac_codes[j];
265 os << " (sum = " << sum << ")" << std::endl;
267 os << " .huffman_table[" << i << "].ac_values = ";
268 for (size_t j(0); j < sizeof(b.huffman_table[i].ac_values); ++j) {
269 if (j and (j % 12) == 0)
270 os << std::endl << " ";
271 os << std::hex << std::setfill('0') << std::setw(2)
272 << (unsigned)b.huffman_table[i].ac_values[j] << ","
282 operator<<(std::ostream& os, const VAHuffmanTableBufferJPEGBaseline* b)
289 operator<<(std::ostream& os, const VAEncSliceParameterBufferJPEG& b)
291 os << "VAEncSliceParameterBufferJPEG (" << &b << ")" << std::endl
292 << " .restart_interval = " << b.restart_interval
295 << " .num_components = " << b.num_components
299 for (size_t i(0); i < 4; ++i) {
300 os << " .components[" << i << "]" << std::endl
301 << " .component_selector = "
302 << (unsigned)b.components[i].component_selector
305 << " .dc_table_selector = "
306 << (unsigned)b.components[i].dc_table_selector
309 << " .ac_table_selector = "
310 << (unsigned)b.components[i].ac_table_selector
319 operator<<(std::ostream& os, const VAEncSliceParameterBufferJPEG* b)
326 operator<<(std::ostream& os, const VAEncPackedHeaderParameterBuffer& b)
328 os << "VAEncPackedHeaderParameterBuffer (" << &b << ")" << std::endl
329 << " .type = " << b.type
331 << " .bit_length = " << b.bit_length
333 << " .has_emulation_bytes = " << (unsigned)b.has_emulation_bytes
341 operator<<(std::ostream& os, const VAEncPackedHeaderParameterBuffer* b)
348 operator<<(std::ostream& os, const VAImage& image)
350 os << "VAImage (" << &image << ")"
351 << std::dec << std::endl
352 << " id : " << image.image_id
355 << std::string(reinterpret_cast<const char*>(&image.format.fourcc), 4)
357 << " size : " << image.width << "x" << image.height
359 << " planes : " << image.num_planes
363 << image.offsets[0] << ","
364 << image.offsets[1] << ","
370 << image.pitches[0] << ","
371 << image.pitches[1] << ","
375 << " bpp : " << image.format.bits_per_pixel
377 << " depth : " << image.format.depth
379 << " byteorder: " << image.format.byte_order
383 << image.format.red_mask << ","
384 << image.format.green_mask << ","
385 << image.format.blue_mask << ","
386 << image.format.alpha_mask
389 << " buffer id: " << image.buf
391 << " data size: " << image.data_size
397 operator<<(std::ostream& os, const VAProfile& profile)
399 return os << vaProfileStr(profile);
403 operator<<(std::ostream& os, const VAEntrypoint& entrypoint)
405 return os << vaEntrypointStr(entrypoint);
408 #endif // I965_STREAMABLE_H