vdpau_trace.cpp 174 KB
Newer Older
Aaron Plattner's avatar
Aaron Plattner committed
1
/*
2
 * Copyright (c) 2008-2015 NVIDIA Corporation
Aaron Plattner's avatar
Aaron Plattner committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#define __STDC_FORMAT_MACROS
#define __STDC_LIMIT_MACROS
#include <inttypes.h>

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vdpau/vdpau_x11.h>

34
35
#include "../src/util.h"

Aaron Plattner's avatar
Aaron Plattner committed
36
37
38
39
40
41
#define _VDP_TRACE_ARSIZE(_x_) ((sizeof (_x_)) / (sizeof ((_x_)[0])))

#if DEBUG

static void _vdp_trace_error_breakpoint(char const * file, int line, char const * function)
{
Aaron Plattner's avatar
Aaron Plattner committed
42
    fprintf(stderr, "VDPAU trace: Error detected at %s:%d %s()\n", file, line, function);
Aaron Plattner's avatar
Aaron Plattner committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
}

#define _VDP_TRACE_ERROR_BREAKPOINT() _vdp_trace_error_breakpoint(__FILE__, __LINE__, __FUNCTION__)

#else

#define _VDP_TRACE_ERROR_BREAKPOINT()

#endif

#define LEVEL_PARAMS 1
#define LEVEL_DATA   2

struct _VdpCapData {
    void * dll;

    int    level;
    FILE * fp;

    VdpDevice           vdp_device;
    VdpGetProcAddress * vdp_get_proc_address;

    VdpGetErrorString * vdp_get_error_string;
    VdpGetApiVersion * vdp_get_api_version;
    VdpGetInformationString * vdp_get_information_string;
    VdpDeviceDestroy * vdp_device_destroy;
    VdpGenerateCSCMatrix * vdp_generate_csc_matrix;
    VdpVideoSurfaceQueryCapabilities * vdp_video_surface_query_capabilities;
    VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities * vdp_video_surface_query_get_put_bits_y_cb_cr_capabilities;
    VdpVideoSurfaceCreate * vdp_video_surface_create;
    VdpVideoSurfaceDestroy * vdp_video_surface_destroy;
    VdpVideoSurfaceGetParameters * vdp_video_surface_get_parameters;
    VdpVideoSurfaceGetBitsYCbCr * vdp_video_surface_get_bits_y_cb_cr;
    VdpVideoSurfacePutBitsYCbCr * vdp_video_surface_put_bits_y_cb_cr;
    VdpOutputSurfaceQueryCapabilities * vdp_output_surface_query_capabilities;
    VdpOutputSurfaceQueryGetPutBitsNativeCapabilities * vdp_output_surface_query_get_put_bits_native_capabilities;
    VdpOutputSurfaceQueryPutBitsIndexedCapabilities * vdp_output_surface_query_put_bits_indexed_capabilities;
    VdpOutputSurfaceQueryPutBitsYCbCrCapabilities * vdp_output_surface_query_put_bits_y_cb_cr_capabilities;
    VdpOutputSurfaceCreate * vdp_output_surface_create;
    VdpOutputSurfaceDestroy * vdp_output_surface_destroy;
    VdpOutputSurfaceGetParameters * vdp_output_surface_get_parameters;
    VdpOutputSurfaceGetBitsNative * vdp_output_surface_get_bits_native;
    VdpOutputSurfacePutBitsNative * vdp_output_surface_put_bits_native;
    VdpOutputSurfacePutBitsIndexed * vdp_output_surface_put_bits_indexed;
    VdpOutputSurfacePutBitsYCbCr * vdp_output_surface_put_bits_y_cb_cr;
    VdpBitmapSurfaceQueryCapabilities * vdp_bitmap_surface_query_capabilities;
    VdpBitmapSurfaceCreate * vdp_bitmap_surface_create;
    VdpBitmapSurfaceDestroy * vdp_bitmap_surface_destroy;
    VdpBitmapSurfaceGetParameters * vdp_bitmap_surface_get_parameters;
    VdpBitmapSurfacePutBitsNative * vdp_bitmap_surface_put_bits_native;
    VdpOutputSurfaceRenderOutputSurface * vdp_output_surface_render_output_surface;
    VdpOutputSurfaceRenderBitmapSurface * vdp_output_surface_render_bitmap_surface;
    VdpDecoderQueryCapabilities * vdp_decoder_query_capabilities;
    VdpDecoderCreate * vdp_decoder_create;
    VdpDecoderDestroy * vdp_decoder_destroy;
    VdpDecoderGetParameters * vdp_decoder_get_parameters;
    VdpDecoderRender * vdp_decoder_render;
    VdpVideoMixerQueryFeatureSupport * vdp_video_mixer_query_feature_support;
    VdpVideoMixerQueryParameterSupport * vdp_video_mixer_query_parameter_support;
    VdpVideoMixerQueryAttributeSupport * vdp_video_mixer_query_attribute_support;
    VdpVideoMixerQueryParameterValueRange * vdp_video_mixer_query_parameter_value_range;
    VdpVideoMixerQueryAttributeValueRange * vdp_video_mixer_query_attribute_value_range;
    VdpVideoMixerCreate * vdp_video_mixer_create;
    VdpVideoMixerSetFeatureEnables * vdp_video_mixer_set_feature_enables;
    VdpVideoMixerSetAttributeValues * vdp_video_mixer_set_attribute_values;
    VdpVideoMixerGetFeatureSupport * vdp_video_mixer_get_feature_support;
    VdpVideoMixerGetFeatureEnables * vdp_video_mixer_get_feature_enables;
    VdpVideoMixerGetParameterValues * vdp_video_mixer_get_parameter_values;
    VdpVideoMixerGetAttributeValues * vdp_video_mixer_get_attribute_values;
    VdpVideoMixerDestroy * vdp_video_mixer_destroy;
    VdpVideoMixerRender * vdp_video_mixer_render;
    VdpPresentationQueueTargetDestroy * vdp_presentation_queue_target_destroy;
    VdpPresentationQueueCreate * vdp_presentation_queue_create;
    VdpPresentationQueueDestroy * vdp_presentation_queue_destroy;
    VdpPresentationQueueSetBackgroundColor * vdp_presentation_queue_set_background_color;
    VdpPresentationQueueGetBackgroundColor * vdp_presentation_queue_get_background_color;
    VdpPresentationQueueGetTime * vdp_presentation_queue_get_time;
    VdpPresentationQueueDisplay * vdp_presentation_queue_display;
    VdpPresentationQueueBlockUntilSurfaceIdle * vdp_presentation_queue_block_until_surface_idle;
    VdpPresentationQueueQuerySurfaceStatus * vdp_presentation_queue_query_surface_status;
    VdpPreemptionCallbackRegister * vdp_preemption_callback_register;
    VdpPresentationQueueTargetCreateX11 * vdp_presentation_queue_target_create_x11;
};

static _VdpCapData _vdp_cap_data;

template<class T> static inline T const delta(T const & a, T const & b)
{
    if (a < b) {
        return b - a;
    }
    else {
        return a - b;
    }
}

static void _vdp_cap_dump_procamp(VdpProcamp * procamp)
{
    if (!procamp) {
        fprintf(_vdp_cap_data.fp, "NULL");
        return;
    }

    fprintf(
        _vdp_cap_data.fp,
        "{(ver=%d)%s %f, %f, %f, %f}",
        procamp->struct_version,
        (procamp->struct_version > 0)
            ? "(unsupported; cannot dump all fields)"
            : "",
        procamp->brightness,
        procamp->contrast,
        procamp->saturation,
        procamp->hue
    );
}

static void _vdp_cap_dump_color(
    VdpColor const * color
)
{
    if (!color) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fprintf(
        _vdp_cap_data.fp,
        "{%f, %f, %f, %f}",
        color->red,
        color->green,
        color->blue,
        color->alpha
    );
}

static void _vdp_cap_dump_rect(
    VdpRect const * rect
)
{
    if (!rect) {
        fprintf(_vdp_cap_data.fp, "NULL");
        return;
    }

    fprintf(
        _vdp_cap_data.fp,
        "{%u, %u, %u, %u}",
        rect->x0,
        rect->y0,
        rect->x1,
        rect->y1
    );
}

static void _vdp_cap_dump_csc_matrix(
    VdpCSCMatrix const * matrix
)
{
    if (!matrix) {
        fprintf(_vdp_cap_data.fp, "NULL");
        return;
    }

    fprintf(
        _vdp_cap_data.fp,
        "{{%f, %f, %f, %f}, {%f, %f, %f, %f}, {%f, %f, %f, %f}}",
        (*matrix)[0][0],
        (*matrix)[0][1],
        (*matrix)[0][2],
        (*matrix)[0][3],
        (*matrix)[1][0],
        (*matrix)[1][1],
        (*matrix)[1][2],
        (*matrix)[1][3],
        (*matrix)[2][0],
        (*matrix)[2][1],
        (*matrix)[2][2],
        (*matrix)[2][3]
    );
}

static void _vdp_cap_dump_blend_state(
    VdpOutputSurfaceRenderBlendState const * blend_state
)
{
    if (!blend_state) {
        fprintf(_vdp_cap_data.fp, "NULL");
        return;
    }

    fprintf(
        _vdp_cap_data.fp,
        "{(ver=%d)%s %u, %u, %u, %u, %u, %u, ",
        blend_state->struct_version,
        (blend_state->struct_version > 0)
            ? "(unsupported; cannot dump all fields)"
            : "",
        blend_state->blend_factor_source_color,
        blend_state->blend_factor_destination_color,
        blend_state->blend_factor_source_alpha,
        blend_state->blend_factor_destination_alpha,
        blend_state->blend_equation_color,
        blend_state->blend_equation_alpha
    );
    _vdp_cap_dump_color(&(blend_state->blend_constant));
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_picture_info(
    VdpDecoderProfile      profile,
    VdpPictureInfo const * picture_info
)
{
    switch (profile) {
    case VDP_DECODER_PROFILE_MPEG1:
    case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
    case VDP_DECODER_PROFILE_MPEG2_MAIN:
261
262
263
264
        {
            VdpPictureInfoMPEG1Or2 const * picture_info_mpeg1or2 =
                (VdpPictureInfoMPEG1Or2 const *)picture_info;

Aaron Plattner's avatar
Aaron Plattner committed
265
266
            fprintf(
                _vdp_cap_data.fp,
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
                "{%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, {{%u, %u}, {%u, %u}}, {",
                picture_info_mpeg1or2->forward_reference,
                picture_info_mpeg1or2->backward_reference,
                picture_info_mpeg1or2->slice_count,
                (uint32_t)picture_info_mpeg1or2->picture_structure,
                (uint32_t)picture_info_mpeg1or2->picture_coding_type,
                (uint32_t)picture_info_mpeg1or2->intra_dc_precision,
                (uint32_t)picture_info_mpeg1or2->frame_pred_frame_dct,
                (uint32_t)picture_info_mpeg1or2->concealment_motion_vectors,
                (uint32_t)picture_info_mpeg1or2->intra_vlc_format,
                (uint32_t)picture_info_mpeg1or2->alternate_scan,
                (uint32_t)picture_info_mpeg1or2->q_scale_type,
                (uint32_t)picture_info_mpeg1or2->top_field_first,
                (uint32_t)picture_info_mpeg1or2->full_pel_forward_vector,
                (uint32_t)picture_info_mpeg1or2->full_pel_backward_vector,
                (uint32_t)picture_info_mpeg1or2->f_code[0][0],
                (uint32_t)picture_info_mpeg1or2->f_code[0][1],
                (uint32_t)picture_info_mpeg1or2->f_code[1][0],
                (uint32_t)picture_info_mpeg1or2->f_code[1][1]
Aaron Plattner's avatar
Aaron Plattner committed
286
            );
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_mpeg1or2->intra_quantizer_matrix); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_mpeg1or2->intra_quantizer_matrix[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_mpeg1or2->non_intra_quantizer_matrix); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_mpeg1or2->non_intra_quantizer_matrix[i]
                );
            }
            fputs("}}", _vdp_cap_data.fp);
Aaron Plattner's avatar
Aaron Plattner committed
305
        }
306
307
308
309
310
311
312
313
        break;
    case VDP_DECODER_PROFILE_H264_BASELINE:
    case VDP_DECODER_PROFILE_H264_MAIN:
    case VDP_DECODER_PROFILE_H264_HIGH:
        {
            VdpPictureInfoH264 const * picture_info_h264 =
                (VdpPictureInfoH264 const *)picture_info;

Aaron Plattner's avatar
Aaron Plattner committed
314
315
            fprintf(
                _vdp_cap_data.fp,
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
                "{%u, {%d, %d}, %d, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %d, %d, %d, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
                picture_info_h264->slice_count,
                picture_info_h264->field_order_cnt[0],
                picture_info_h264->field_order_cnt[1],
                (int32_t)picture_info_h264->is_reference,
                (uint32_t)picture_info_h264->frame_num,
                (uint32_t)picture_info_h264->field_pic_flag,
                (uint32_t)picture_info_h264->bottom_field_flag,
                (uint32_t)picture_info_h264->num_ref_frames,
                (uint32_t)picture_info_h264->mb_adaptive_frame_field_flag,
                (uint32_t)picture_info_h264->constrained_intra_pred_flag,
                (uint32_t)picture_info_h264->weighted_pred_flag,
                (uint32_t)picture_info_h264->weighted_bipred_idc,
                (uint32_t)picture_info_h264->frame_mbs_only_flag,
                (uint32_t)picture_info_h264->transform_8x8_mode_flag,
                (int32_t)picture_info_h264->chroma_qp_index_offset,
                (int32_t)picture_info_h264->second_chroma_qp_index_offset,
                (int32_t)picture_info_h264->pic_init_qp_minus26,
                (uint32_t)picture_info_h264->num_ref_idx_l0_active_minus1,
                (uint32_t)picture_info_h264->num_ref_idx_l1_active_minus1,
                (uint32_t)picture_info_h264->log2_max_frame_num_minus4,
                (uint32_t)picture_info_h264->pic_order_cnt_type,
                (uint32_t)picture_info_h264->log2_max_pic_order_cnt_lsb_minus4,
                (uint32_t)picture_info_h264->delta_pic_order_always_zero_flag,
                (uint32_t)picture_info_h264->direct_8x8_inference_flag,
                (uint32_t)picture_info_h264->entropy_coding_mode_flag,
                (uint32_t)picture_info_h264->pic_order_present_flag,
                (uint32_t)picture_info_h264->deblocking_filter_control_present_flag,
                (uint32_t)picture_info_h264->redundant_pic_cnt_present_flag
Aaron Plattner's avatar
Aaron Plattner committed
345
            );
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_h264->scaling_lists_4x4); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_h264->scaling_lists_4x4[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_h264->scaling_lists_4x4[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_h264->scaling_lists_8x8); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_h264->scaling_lists_8x8[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_h264->scaling_lists_8x8[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_h264->referenceFrames); ++i) {
                VdpReferenceFrameH264 const * rf = &(picture_info_h264->referenceFrames[i]);
                fprintf(
                    _vdp_cap_data.fp,
                    "%s{%u, %d, %d, %d, {%d, %d}, %u}",
                    (i == 0) ? "" : ", ",
                    rf->surface,
                    (int32_t)rf->is_long_term,
                    (int32_t)rf->top_is_reference,
                    (int32_t)rf->bottom_is_reference,
                    (int32_t)rf->field_order_cnt[0],
                    (int32_t)rf->field_order_cnt[1],
                    (uint32_t)rf->frame_idx
                );
            }
385
            fputs("}}", _vdp_cap_data.fp);
Aaron Plattner's avatar
Aaron Plattner committed
386
387
388
389
390
        }
        break;
    case VDP_DECODER_PROFILE_VC1_SIMPLE:
    case VDP_DECODER_PROFILE_VC1_MAIN:
    case VDP_DECODER_PROFILE_VC1_ADVANCED:
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
        {
            VdpPictureInfoVC1 const * picture_info_vc1 =
                (VdpPictureInfoVC1 const *)picture_info;

            fprintf(
                _vdp_cap_data.fp,
                "{%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u}",
                picture_info_vc1->forward_reference,
                picture_info_vc1->backward_reference,
                picture_info_vc1->slice_count,
                (uint32_t)picture_info_vc1->picture_type,
                (uint32_t)picture_info_vc1->frame_coding_mode,
                (uint32_t)picture_info_vc1->postprocflag,
                (uint32_t)picture_info_vc1->pulldown,
                (uint32_t)picture_info_vc1->interlace,
                (uint32_t)picture_info_vc1->tfcntrflag,
                (uint32_t)picture_info_vc1->finterpflag,
                (uint32_t)picture_info_vc1->psf,
                (uint32_t)picture_info_vc1->dquant,
                (uint32_t)picture_info_vc1->panscan_flag,
                (uint32_t)picture_info_vc1->refdist_flag,
                (uint32_t)picture_info_vc1->quantizer,
                (uint32_t)picture_info_vc1->extended_mv,
                (uint32_t)picture_info_vc1->extended_dmv,
                (uint32_t)picture_info_vc1->overlap,
                (uint32_t)picture_info_vc1->vstransform,
                (uint32_t)picture_info_vc1->loopfilter,
                (uint32_t)picture_info_vc1->fastuvmc,
                (uint32_t)picture_info_vc1->range_mapy_flag,
                (uint32_t)picture_info_vc1->range_mapy,
                (uint32_t)picture_info_vc1->range_mapuv_flag,
                (uint32_t)picture_info_vc1->range_mapuv,
                (uint32_t)picture_info_vc1->multires,
                (uint32_t)picture_info_vc1->syncmarker,
                (uint32_t)picture_info_vc1->rangered,
                (uint32_t)picture_info_vc1->maxbframes,
                (uint32_t)picture_info_vc1->deblockEnable,
                (uint32_t)picture_info_vc1->pquant
            );
        }
        break;
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
    case VDP_DECODER_PROFILE_MPEG4_PART2_SP:
    case VDP_DECODER_PROFILE_MPEG4_PART2_ASP:
    case VDP_DECODER_PROFILE_DIVX4_QMOBILE:
    case VDP_DECODER_PROFILE_DIVX4_MOBILE:
    case VDP_DECODER_PROFILE_DIVX4_HOME_THEATER:
    case VDP_DECODER_PROFILE_DIVX4_HD_1080P:
    case VDP_DECODER_PROFILE_DIVX5_QMOBILE:
    case VDP_DECODER_PROFILE_DIVX5_MOBILE:
    case VDP_DECODER_PROFILE_DIVX5_HOME_THEATER:
    case VDP_DECODER_PROFILE_DIVX5_HD_1080P:
        {
            VdpPictureInfoMPEG4Part2 const * picture_info_mpeg4 =
                (VdpPictureInfoMPEG4Part2 const *)picture_info;

            fprintf(
                _vdp_cap_data.fp,
                "{%u, %u, {%d, %d}, {%d, %d}, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
                picture_info_mpeg4->forward_reference,
                picture_info_mpeg4->backward_reference,
                (int32_t)picture_info_mpeg4->trd[0],
                (int32_t)picture_info_mpeg4->trd[1],
                (int32_t)picture_info_mpeg4->trb[0],
                (int32_t)picture_info_mpeg4->trb[1],
                (uint32_t)picture_info_mpeg4->vop_time_increment_resolution,
456
                (uint32_t)picture_info_mpeg4->vop_coding_type,
457
458
459
                (uint32_t)picture_info_mpeg4->vop_fcode_forward,
                (uint32_t)picture_info_mpeg4->vop_fcode_backward,
                (uint32_t)picture_info_mpeg4->resync_marker_disable,
460
461
462
463
                (uint32_t)picture_info_mpeg4->interlaced,
                (uint32_t)picture_info_mpeg4->quant_type,
                (uint32_t)picture_info_mpeg4->quarter_sample,
                (uint32_t)picture_info_mpeg4->short_video_header,
464
                (uint32_t)picture_info_mpeg4->rounding_control,
465
                (uint32_t)picture_info_mpeg4->alternate_vertical_scan_flag,
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
                (uint32_t)picture_info_mpeg4->top_field_first
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_mpeg4->intra_quantizer_matrix); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_mpeg4->intra_quantizer_matrix[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_mpeg4->non_intra_quantizer_matrix); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_mpeg4->non_intra_quantizer_matrix[i]
                );
            }
            fputs("}}", _vdp_cap_data.fp);
        }
        break;
488
489
490
    case VDP_DECODER_PROFILE_HEVC_MAIN:
    case VDP_DECODER_PROFILE_HEVC_MAIN_10:
    case VDP_DECODER_PROFILE_HEVC_MAIN_STILL:
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
        {
            VdpPictureInfoHEVC const * picture_info_hevc =
                (VdpPictureInfoHEVC const *)picture_info;

            fprintf(
                _vdp_cap_data.fp,
                "{%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
                (uint32_t)picture_info_hevc->chroma_format_idc,
                (uint32_t)picture_info_hevc->separate_colour_plane_flag,
                (uint32_t)picture_info_hevc->pic_width_in_luma_samples,
                (uint32_t)picture_info_hevc->pic_height_in_luma_samples,
                (uint32_t)picture_info_hevc->bit_depth_luma_minus8,
                (uint32_t)picture_info_hevc->bit_depth_chroma_minus8,
                (uint32_t)picture_info_hevc->log2_max_pic_order_cnt_lsb_minus4,
                (uint32_t)picture_info_hevc->sps_max_dec_pic_buffering_minus1,
                (uint32_t)picture_info_hevc->log2_min_luma_coding_block_size_minus3,
                (uint32_t)picture_info_hevc->log2_diff_max_min_luma_coding_block_size,
                (uint32_t)picture_info_hevc->log2_min_transform_block_size_minus2,
                (uint32_t)picture_info_hevc->log2_diff_max_min_transform_block_size,
                (uint32_t)picture_info_hevc->max_transform_hierarchy_depth_inter,
                (uint32_t)picture_info_hevc->max_transform_hierarchy_depth_intra,
                (uint32_t)picture_info_hevc->scaling_list_enabled_flag
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList4x4); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList4x4[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList4x4[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList8x8); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList8x8[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList8x8[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList16x16); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList16x16[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList16x16[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList32x32); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList32x32[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList32x32[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingListDCCoeff16x16); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->ScalingListDCCoeff16x16[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingListDCCoeff32x32); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->ScalingListDCCoeff32x32[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %d, %u, %u, %u, %u, %d, %d, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
                (uint32_t)picture_info_hevc->amp_enabled_flag,
                (uint32_t)picture_info_hevc->sample_adaptive_offset_enabled_flag,
                (uint32_t)picture_info_hevc->pcm_enabled_flag,
                (uint32_t)picture_info_hevc->pcm_sample_bit_depth_luma_minus1,
                (uint32_t)picture_info_hevc->pcm_sample_bit_depth_chroma_minus1,
                (uint32_t)picture_info_hevc->log2_min_pcm_luma_coding_block_size_minus3,
                (uint32_t)picture_info_hevc->log2_diff_max_min_pcm_luma_coding_block_size,
                (uint32_t)picture_info_hevc->pcm_loop_filter_disabled_flag,
                (uint32_t)picture_info_hevc->num_short_term_ref_pic_sets,
                (uint32_t)picture_info_hevc->long_term_ref_pics_present_flag,
                (uint32_t)picture_info_hevc->num_long_term_ref_pics_sps,
                (uint32_t)picture_info_hevc->sps_temporal_mvp_enabled_flag,
                (uint32_t)picture_info_hevc->strong_intra_smoothing_enabled_flag,
                (uint32_t)picture_info_hevc->dependent_slice_segments_enabled_flag,
                (uint32_t)picture_info_hevc->output_flag_present_flag,
                (uint32_t)picture_info_hevc->num_extra_slice_header_bits,
                (uint32_t)picture_info_hevc->sign_data_hiding_enabled_flag,
                (uint32_t)picture_info_hevc->cabac_init_present_flag,
                (uint32_t)picture_info_hevc->num_ref_idx_l0_default_active_minus1,
                (uint32_t)picture_info_hevc->num_ref_idx_l1_default_active_minus1,
                (int32_t)picture_info_hevc->init_qp_minus26,
                (uint32_t)picture_info_hevc->constrained_intra_pred_flag,
                (uint32_t)picture_info_hevc->transform_skip_enabled_flag,
                (uint32_t)picture_info_hevc->cu_qp_delta_enabled_flag,
                (uint32_t)picture_info_hevc->diff_cu_qp_delta_depth,
                (int32_t)picture_info_hevc->pps_cb_qp_offset,
                (int32_t)picture_info_hevc->pps_cr_qp_offset,
                (uint32_t)picture_info_hevc->pps_slice_chroma_qp_offsets_present_flag,
                (uint32_t)picture_info_hevc->weighted_pred_flag,
                (uint32_t)picture_info_hevc->weighted_bipred_flag,
                (uint32_t)picture_info_hevc->transquant_bypass_enabled_flag,
                (uint32_t)picture_info_hevc->tiles_enabled_flag,
                (uint32_t)picture_info_hevc->entropy_coding_sync_enabled_flag,
                (uint32_t)picture_info_hevc->num_tile_columns_minus1,
                (uint32_t)picture_info_hevc->num_tile_rows_minus1,
                (uint32_t)picture_info_hevc->uniform_spacing_flag
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->column_width_minus1); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->column_width_minus1[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->row_height_minus1); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->row_height_minus1[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, %u, %u, %d, %d, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %d, {",
                (uint32_t)picture_info_hevc->loop_filter_across_tiles_enabled_flag,
                (uint32_t)picture_info_hevc->pps_loop_filter_across_slices_enabled_flag,
                (uint32_t)picture_info_hevc->deblocking_filter_control_present_flag,
                (uint32_t)picture_info_hevc->deblocking_filter_override_enabled_flag,
                (uint32_t)picture_info_hevc->pps_deblocking_filter_disabled_flag,
                (int32_t)picture_info_hevc->pps_beta_offset_div2,
                (int32_t)picture_info_hevc->pps_tc_offset_div2,
                (uint32_t)picture_info_hevc->lists_modification_present_flag,
                (uint32_t)picture_info_hevc->log2_parallel_merge_level_minus2,
                (uint32_t)picture_info_hevc->slice_segment_header_extension_present_flag,
                (uint32_t)picture_info_hevc->IDRPicFlag,
                (uint32_t)picture_info_hevc->RAPPicFlag,
                (uint32_t)picture_info_hevc->CurrRpsIdx,
                (uint32_t)picture_info_hevc->NumPocTotalCurr,
                (uint32_t)picture_info_hevc->NumDeltaPocsOfRefRpsIdx,
                (uint32_t)picture_info_hevc->NumShortTermPictureSliceHeaderBits,
                (uint32_t)picture_info_hevc->NumLongTermPictureSliceHeaderBits,
                (int32_t)picture_info_hevc->CurrPicOrderCntVal
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPics); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPics[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->PicOrderCntVal); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%d",
                    (i == 0) ? "" : ", ",
                    (int32_t)picture_info_hevc->PicOrderCntVal[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->IsLongTerm); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->IsLongTerm[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, {",
                (uint32_t)picture_info_hevc->NumPocStCurrBefore,
                (uint32_t)picture_info_hevc->NumPocStCurrAfter,
                (uint32_t)picture_info_hevc->NumPocLtCurr
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPicSetStCurrBefore); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPicSetStCurrBefore[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPicSetStCurrAfter); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPicSetStCurrAfter[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPicSetLtCurr); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPicSetLtCurr[i]
                );
            }
            fputs("}}", _vdp_cap_data.fp);
        }
        break;
723
724
    case VDP_DECODER_PROFILE_HEVC_MAIN_12:
    case VDP_DECODER_PROFILE_HEVC_MAIN_444:
725
726
    case VDP_DECODER_PROFILE_HEVC_MAIN_444_10:
    case VDP_DECODER_PROFILE_HEVC_MAIN_444_12:
727
728
729
730
        {
            VdpPictureInfoHEVC const * picture_info_hevc =
                (VdpPictureInfoHEVC const *)picture_info;

731
732
733
            VdpPictureInfoHEVCRangeExt const * picture_info_hevc_rxt =
                (VdpPictureInfoHEVCRangeExt const *)picture_info;

734
735
            fprintf(
                _vdp_cap_data.fp,
736
                "{{%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
                (uint32_t)picture_info_hevc->chroma_format_idc,
                (uint32_t)picture_info_hevc->separate_colour_plane_flag,
                (uint32_t)picture_info_hevc->pic_width_in_luma_samples,
                (uint32_t)picture_info_hevc->pic_height_in_luma_samples,
                (uint32_t)picture_info_hevc->bit_depth_luma_minus8,
                (uint32_t)picture_info_hevc->bit_depth_chroma_minus8,
                (uint32_t)picture_info_hevc->log2_max_pic_order_cnt_lsb_minus4,
                (uint32_t)picture_info_hevc->sps_max_dec_pic_buffering_minus1,
                (uint32_t)picture_info_hevc->log2_min_luma_coding_block_size_minus3,
                (uint32_t)picture_info_hevc->log2_diff_max_min_luma_coding_block_size,
                (uint32_t)picture_info_hevc->log2_min_transform_block_size_minus2,
                (uint32_t)picture_info_hevc->log2_diff_max_min_transform_block_size,
                (uint32_t)picture_info_hevc->max_transform_hierarchy_depth_inter,
                (uint32_t)picture_info_hevc->max_transform_hierarchy_depth_intra,
                (uint32_t)picture_info_hevc->scaling_list_enabled_flag
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList4x4); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList4x4[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList4x4[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList8x8); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList8x8[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList8x8[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList16x16); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList16x16[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList16x16[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList32x32); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingList32x32[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_hevc->ScalingList32x32[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingListDCCoeff16x16); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->ScalingListDCCoeff16x16[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->ScalingListDCCoeff32x32); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->ScalingListDCCoeff32x32[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %d, %u, %u, %u, %u, %d, %d, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
                (uint32_t)picture_info_hevc->amp_enabled_flag,
                (uint32_t)picture_info_hevc->sample_adaptive_offset_enabled_flag,
                (uint32_t)picture_info_hevc->pcm_enabled_flag,
                (uint32_t)picture_info_hevc->pcm_sample_bit_depth_luma_minus1,
                (uint32_t)picture_info_hevc->pcm_sample_bit_depth_chroma_minus1,
                (uint32_t)picture_info_hevc->log2_min_pcm_luma_coding_block_size_minus3,
                (uint32_t)picture_info_hevc->log2_diff_max_min_pcm_luma_coding_block_size,
                (uint32_t)picture_info_hevc->pcm_loop_filter_disabled_flag,
                (uint32_t)picture_info_hevc->num_short_term_ref_pic_sets,
                (uint32_t)picture_info_hevc->long_term_ref_pics_present_flag,
                (uint32_t)picture_info_hevc->num_long_term_ref_pics_sps,
                (uint32_t)picture_info_hevc->sps_temporal_mvp_enabled_flag,
                (uint32_t)picture_info_hevc->strong_intra_smoothing_enabled_flag,
                (uint32_t)picture_info_hevc->dependent_slice_segments_enabled_flag,
                (uint32_t)picture_info_hevc->output_flag_present_flag,
                (uint32_t)picture_info_hevc->num_extra_slice_header_bits,
                (uint32_t)picture_info_hevc->sign_data_hiding_enabled_flag,
                (uint32_t)picture_info_hevc->cabac_init_present_flag,
                (uint32_t)picture_info_hevc->num_ref_idx_l0_default_active_minus1,
                (uint32_t)picture_info_hevc->num_ref_idx_l1_default_active_minus1,
                (int32_t)picture_info_hevc->init_qp_minus26,
                (uint32_t)picture_info_hevc->constrained_intra_pred_flag,
                (uint32_t)picture_info_hevc->transform_skip_enabled_flag,
                (uint32_t)picture_info_hevc->cu_qp_delta_enabled_flag,
                (uint32_t)picture_info_hevc->diff_cu_qp_delta_depth,
                (int32_t)picture_info_hevc->pps_cb_qp_offset,
                (int32_t)picture_info_hevc->pps_cr_qp_offset,
                (uint32_t)picture_info_hevc->pps_slice_chroma_qp_offsets_present_flag,
                (uint32_t)picture_info_hevc->weighted_pred_flag,
                (uint32_t)picture_info_hevc->weighted_bipred_flag,
                (uint32_t)picture_info_hevc->transquant_bypass_enabled_flag,
                (uint32_t)picture_info_hevc->tiles_enabled_flag,
                (uint32_t)picture_info_hevc->entropy_coding_sync_enabled_flag,
                (uint32_t)picture_info_hevc->num_tile_columns_minus1,
                (uint32_t)picture_info_hevc->num_tile_rows_minus1,
                (uint32_t)picture_info_hevc->uniform_spacing_flag
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->column_width_minus1); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->column_width_minus1[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->row_height_minus1); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->row_height_minus1[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, %u, %u, %d, %d, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %d, {",
                (uint32_t)picture_info_hevc->loop_filter_across_tiles_enabled_flag,
                (uint32_t)picture_info_hevc->pps_loop_filter_across_slices_enabled_flag,
                (uint32_t)picture_info_hevc->deblocking_filter_control_present_flag,
                (uint32_t)picture_info_hevc->deblocking_filter_override_enabled_flag,
                (uint32_t)picture_info_hevc->pps_deblocking_filter_disabled_flag,
                (int32_t)picture_info_hevc->pps_beta_offset_div2,
                (int32_t)picture_info_hevc->pps_tc_offset_div2,
                (uint32_t)picture_info_hevc->lists_modification_present_flag,
                (uint32_t)picture_info_hevc->log2_parallel_merge_level_minus2,
                (uint32_t)picture_info_hevc->slice_segment_header_extension_present_flag,
                (uint32_t)picture_info_hevc->IDRPicFlag,
                (uint32_t)picture_info_hevc->RAPPicFlag,
                (uint32_t)picture_info_hevc->CurrRpsIdx,
                (uint32_t)picture_info_hevc->NumPocTotalCurr,
                (uint32_t)picture_info_hevc->NumDeltaPocsOfRefRpsIdx,
                (uint32_t)picture_info_hevc->NumShortTermPictureSliceHeaderBits,
                (uint32_t)picture_info_hevc->NumLongTermPictureSliceHeaderBits,
                (int32_t)picture_info_hevc->CurrPicOrderCntVal
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPics); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPics[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->PicOrderCntVal); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%d",
                    (i == 0) ? "" : ", ",
                    (int32_t)picture_info_hevc->PicOrderCntVal[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->IsLongTerm); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->IsLongTerm[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, {",
                (uint32_t)picture_info_hevc->NumPocStCurrBefore,
                (uint32_t)picture_info_hevc->NumPocStCurrAfter,
                (uint32_t)picture_info_hevc->NumPocLtCurr
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPicSetStCurrBefore); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPicSetStCurrBefore[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPicSetStCurrAfter); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPicSetStCurrAfter[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc->RefPicSetLtCurr); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc->RefPicSetLtCurr[i]
                );
            }
            fputs("}}", _vdp_cap_data.fp);
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
                (uint32_t)picture_info_hevc_rxt->sps_range_extension_flag,
                (uint32_t)picture_info_hevc_rxt->transformSkipRotationEnableFlag,
                (uint32_t)picture_info_hevc_rxt->transformSkipContextEnableFlag,
                (uint32_t)picture_info_hevc_rxt->implicitRdpcmEnableFlag,
                (uint32_t)picture_info_hevc_rxt->explicitRdpcmEnableFlag,
                (uint32_t)picture_info_hevc_rxt->extendedPrecisionProcessingFlag,
                (uint32_t)picture_info_hevc_rxt->intraSmoothingDisabledFlag,
                (uint32_t)picture_info_hevc_rxt->highPrecisionOffsetsEnableFlag,
                (uint32_t)picture_info_hevc_rxt->persistentRiceAdaptationEnableFlag,
                (uint32_t)picture_info_hevc_rxt->cabacBypassAlignmentEnableFlag,
                (uint32_t)picture_info_hevc_rxt->intraBlockCopyEnableFlag,
                (uint32_t)picture_info_hevc_rxt->pps_range_extension_flag,
                (uint32_t)picture_info_hevc_rxt->log2MaxTransformSkipSize,
                (uint32_t)picture_info_hevc_rxt->crossComponentPredictionEnableFlag,
                (uint32_t)picture_info_hevc_rxt->chromaQpAdjustmentEnableFlag,
                (uint32_t)picture_info_hevc_rxt->diffCuChromaQpAdjustmentDepth,
                (uint32_t)picture_info_hevc_rxt->chromaQpAdjustmentTableSize,
                (uint32_t)picture_info_hevc_rxt->log2SaoOffsetScaleLuma,
                (uint32_t)picture_info_hevc_rxt->log2SaoOffsetScaleChroma
            );
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc_rxt->cb_qp_adjustment); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc_rxt->cb_qp_adjustment[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_hevc_rxt->cr_qp_adjustment); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_hevc_rxt->cr_qp_adjustment[i]
                );
            }
            fputs("}}", _vdp_cap_data.fp);
1002
1003
        }
        break;
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
    case VDP_DECODER_PROFILE_VP9_PROFILE_0:
    case VDP_DECODER_PROFILE_VP9_PROFILE_1:
    case VDP_DECODER_PROFILE_VP9_PROFILE_2:
    case VDP_DECODER_PROFILE_VP9_PROFILE_3:
        {
            VdpPictureInfoVP9 const * picture_info_vp9 =
                (VdpPictureInfoVP9 const *)picture_info;

            fprintf(
                _vdp_cap_data.fp,
                "{%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u {",
                (uint32_t)picture_info_vp9->width,
                (uint32_t)picture_info_vp9->height,
                picture_info_vp9->lastReference,
                picture_info_vp9->goldenReference,
                picture_info_vp9->altReference,
                (uint32_t)picture_info_vp9->colorSpace,
                (uint32_t)picture_info_vp9->profile,
                (uint32_t)picture_info_vp9->frameContextIdx,
                (uint32_t)picture_info_vp9->keyFrame,
                (uint32_t)picture_info_vp9->showFrame,
                (uint32_t)picture_info_vp9->errorResilient,
                (uint32_t)picture_info_vp9->frameParallelDecoding,
                (uint32_t)picture_info_vp9->subSamplingX,
                (uint32_t)picture_info_vp9->subSamplingY,
                (uint32_t)picture_info_vp9->intraOnly,
                (uint32_t)picture_info_vp9->allowHighPrecisionMv,
                (uint32_t)picture_info_vp9->refreshEntropyProbs
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->refFrameSignBias); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_vp9->refFrameSignBias[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, {",
                (uint32_t)picture_info_vp9->bitDepthMinus8Luma,
                (uint32_t)picture_info_vp9->bitDepthMinus8Chroma,
                (uint32_t)picture_info_vp9->loopFilterLevel,
                (uint32_t)picture_info_vp9->loopFilterSharpness,
                (uint32_t)picture_info_vp9->modeRefLfEnabled,
                (uint32_t)picture_info_vp9->log2TileColumns,
                (uint32_t)picture_info_vp9->log2TileRows,
                (uint32_t)picture_info_vp9->segmentEnabled,
                (uint32_t)picture_info_vp9->segmentMapUpdate,
                (uint32_t)picture_info_vp9->segmentMapTemporalUpdate,
                (uint32_t)picture_info_vp9->segmentFeatureMode
            );
           for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->segmentFeatureEnable); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_vp9->segmentFeatureEnable[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%u",
                        (j == 0) ? "" : ", ",
                        (uint32_t)picture_info_vp9->segmentFeatureEnable[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->segmentFeatureData); ++i) {
                fputs((i == 0) ? "{" : "}, {", _vdp_cap_data.fp);
                for (uint32_t j = 0; j < _VDP_TRACE_ARSIZE(picture_info_vp9->segmentFeatureData[0]); ++j) {
                    fprintf(
                        _vdp_cap_data.fp,
                        "%s%d",
                        (j == 0) ? "" : ", ",
                        (int32_t)picture_info_vp9->segmentFeatureData[i][j]
                    );
                }
            }
            fputs("}}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->mbSegmentTreeProbs); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_vp9->mbSegmentTreeProbs[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->segmentPredProbs); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_vp9->segmentPredProbs[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->reservedSegment16Bits); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_vp9->reservedSegment16Bits[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%d, %d, %d, %d, {",
                (int32_t)picture_info_vp9->qpYAc,
                (int32_t)picture_info_vp9->qpYDc,
                (int32_t)picture_info_vp9->qpChDc,
                (int32_t)picture_info_vp9->qpChAc
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->activeRefIdx); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_vp9->activeRefIdx[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, {",
                (uint32_t)picture_info_vp9->resetFrameContext,
                (uint32_t)picture_info_vp9->mcompFilterType
            );
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->mbRefLfDelta); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%u",
                    (i == 0) ? "" : ", ",
                    (uint32_t)picture_info_vp9->mbRefLfDelta[i]
                );
            }
            fputs("}, {", _vdp_cap_data.fp);
            for (uint32_t i = 0; i < _VDP_TRACE_ARSIZE(picture_info_vp9->mbModeLfDelta); ++i) {
                fprintf(
                    _vdp_cap_data.fp,
                    "%s%d",
                    (i == 0) ? "" : ", ",
                    (int32_t)picture_info_vp9->mbModeLfDelta[i]
                );
            }
            fputs("}, ", _vdp_cap_data.fp);
            fprintf(
                _vdp_cap_data.fp,
                "%u, %u, {",
                (uint32_t)picture_info_vp9->uncompressedHeaderSize,
                (uint32_t)picture_info_vp9->compressedHeaderSize
            );
            fputs("}", _vdp_cap_data.fp);
        }
        break;
Aaron Plattner's avatar
Aaron Plattner committed
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
    default:
        fputs("{...}", _vdp_cap_data.fp);
        break;
    }
}

static void _vdp_cap_dump_video_mixer_parameter_value(
    VdpVideoMixerParameter parameter,
    void const *           value
)
{
    switch (parameter) {
    case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH:
    case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT:
    case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE:
    case VDP_VIDEO_MIXER_PARAMETER_LAYERS:
        if (!value) {
            fputs("???", _vdp_cap_data.fp);
        }
        else {
            fprintf(_vdp_cap_data.fp, "%u", *(uint32_t const *)value);
        }
        break;
    default:
        fputs("???", _vdp_cap_data.fp);
        break;
    }
}

static void _vdp_cap_dump_video_mixer_attribute_value(
    VdpVideoMixerAttribute attribute,
    void const *           value,
    bool                   get_operation
)
{
    if (!value) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    switch (attribute) {
    case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
        _vdp_cap_dump_color((VdpColor const *)value);
        break;
    case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
        {
Aaron Plattner's avatar
Aaron Plattner committed
1204
            VdpCSCMatrix const * ptr;
Aaron Plattner's avatar
Aaron Plattner committed
1205
1206
1207
1208
1209
1210

            // For some objects, the "default" value is a NULL pointer.
            // So, VdpVideoMixerGetAttributeValues expects a double pointer to
            // the value, so it can either fill in the value, or NULL out the
            // pointer.
            if (get_operation) {
1211
                ptr = *(VdpCSCMatrix const * const *)value;
Aaron Plattner's avatar
Aaron Plattner committed
1212
1213
            }
            else {
Aaron Plattner's avatar
Aaron Plattner committed
1214
                ptr = (VdpCSCMatrix const *)value;
Aaron Plattner's avatar
Aaron Plattner committed
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
            }
            _vdp_cap_dump_csc_matrix(ptr);
        }
        break;
    case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
    case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
    case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
    case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
        fprintf(_vdp_cap_data.fp, "%f", *(float const *)value);
        break;
1225
1226
1227
    case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
        fprintf(_vdp_cap_data.fp, "%u", *(uint8_t const *)value);
        break;
Aaron Plattner's avatar
Aaron Plattner committed
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
    default:
        fputs("???", _vdp_cap_data.fp);
        break;
    }
}

static void _vdp_cap_dump_uint8_t_stream(
    uint32_t        count,
    uint8_t const * values
)
{
    if (!values) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (count) {
        fprintf(
            _vdp_cap_data.fp,
            "%02x",
            values[0]
        );

        --count;
        ++values;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_uint32_t_stream(
    uint32_t         count,
    uint32_t const * values
)
{
    if (!values) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (count) {
        fprintf(
            _vdp_cap_data.fp,
            "%08x%s",
            values[0],
            (count > 1) ? " " : ""
        );

        --count;
        ++values;
    }
    fputs("}", _vdp_cap_data.fp);
}

struct _VdpcapPlane {
    void const * data;
    uint32_t     pitch;
    uint32_t     item_count;
    uint32_t     item_size;
    uint32_t     lines;
};

typedef void _VdpcapPlaneDumper(uint32_t count, void const * values);

static void _vdp_cap_dump_plane_list(
    uint32_t             plane_count,
    _VdpcapPlane const * planes
)
{
    if (!planes) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (plane_count) {
        uint32_t lines = planes[0].lines;

        _VdpcapPlaneDumper * dumper;
        if (planes[0].item_size == 4) {
            dumper = (_VdpcapPlaneDumper*)_vdp_cap_dump_uint32_t_stream;
        }
        else {
            dumper = (_VdpcapPlaneDumper*)_vdp_cap_dump_uint8_t_stream;
        }

        fputs("{", _vdp_cap_data.fp);
        uint8_t const * ptr = (uint8_t const *)planes[0].data;
        while (lines) {
            dumper(planes[0].item_count, ptr);
            if (lines > 1) {
                fputs(", ", _vdp_cap_data.fp);
            }

            ptr += planes[0].pitch;
            --lines;
        }
        fputs("}", _vdp_cap_data.fp);

        if (plane_count > 1) {
            fputs(", ", _vdp_cap_data.fp);
        }

        --plane_count;
        ++planes;
    }
    fputs("}", _vdp_cap_data.fp);
}

static bool _vdp_cap_init_planes_for_ycbcr_format(
    uint32_t *     plane_count,
    _VdpcapPlane * planes,
    VdpYCbCrFormat format,
    uint32_t       region_width,
    uint32_t       region_height
)
{
    switch (format) {
    case VDP_YCBCR_FORMAT_NV12:
        if (*plane_count < 2) {
            return false;
        }
        *plane_count = 2;
        planes[0].item_size = 1;
        planes[0].item_count = region_width;
        planes[0].lines = region_height;
        planes[1].item_size = 1;
        planes[1].item_count = region_width;
        planes[1].lines = region_height / 2;
        break;
    case VDP_YCBCR_FORMAT_YV12:
        if (*plane_count < 3) {
            return false;
        }
        *plane_count = 3;
        planes[0].item_size = 1;
        planes[0].item_count = region_width;
        planes[0].lines = region_height;
        planes[1].item_size = 1;
        planes[1].item_count = region_width / 2;
        planes[1].lines = region_height / 2;
        planes[2].item_size = 1;
        planes[2].item_count = region_width / 2;
        planes[2].lines = region_height / 2;
        break;
    case VDP_YCBCR_FORMAT_UYVY:
    case VDP_YCBCR_FORMAT_YUYV:
        if (*plane_count < 1) {
            return false;
        }
        *plane_count = 1;
        planes[0].item_size = 1;
        planes[0].item_count = region_width * 2;
        planes[0].lines = region_height;
        break;
    case VDP_YCBCR_FORMAT_Y8U8V8A8:
    case VDP_YCBCR_FORMAT_V8U8Y8A8:
        if (*plane_count < 1) {
            return false;
        }
        *plane_count = 1;
        planes[0].item_size = 4;
        planes[0].item_count = region_width;
        planes[0].lines = region_height;
        break;
    default:
        return false;
    }

    return true;
}

static bool _vdp_cap_init_planes_for_rgba_format(
    uint32_t *     plane_count,
    _VdpcapPlane * planes,
    VdpRGBAFormat  format,
    uint32_t       region_width,
    uint32_t       region_height
)
{
    switch (format) {
    case VDP_RGBA_FORMAT_B8G8R8A8:
    case VDP_RGBA_FORMAT_R8G8B8A8:
    case VDP_RGBA_FORMAT_R10G10B10A2:
    case VDP_RGBA_FORMAT_B10G10R10A2:
        if (*plane_count < 1) {
            return false;
        }
        *plane_count = 1;
        planes[0].item_size = 4;
        break;
    case VDP_RGBA_FORMAT_A8:
        if (*plane_count < 1) {
            return false;
        }
        *plane_count = 1;
        planes[0].item_size = 1;
        break;
    default:
        return false;
    }
    planes[0].item_count = region_width;
    planes[0].lines = region_height;

    return true;
}

static bool _vdp_cap_init_planes_for_indexed_format(
    uint32_t *       plane_count,
    _VdpcapPlane *   planes,
    VdpIndexedFormat format,
    uint32_t         region_width,
    uint32_t         region_height
)
{
    uint32_t width_multiplier;

    switch (format) {
    case VDP_INDEXED_FORMAT_A4I4:
    case VDP_INDEXED_FORMAT_I4A4:
        width_multiplier = 1;
        break;
    case VDP_INDEXED_FORMAT_A8I8:
    case VDP_INDEXED_FORMAT_I8A8:
        width_multiplier = 2;
        break;
    default:
        return false;
    }

    if (*plane_count < 1) {
        return false;
    }
    *plane_count = 1;
    planes[0].item_size = 1;
    planes[0].item_count = region_width * width_multiplier;
    planes[0].lines = region_height;

    return true;
}

static bool _vdp_cap_init_planes_adapt_format_bits_ycbcr(
    uint32_t *     plane_count,
    _VdpcapPlane * planes,
    uint32_t       surface_format,
    uint32_t       bits_format,
    uint32_t       region_width,
    uint32_t       region_height
)
{
    return _vdp_cap_init_planes_for_ycbcr_format(
        plane_count,
        planes,
        bits_format,
        region_width,
        region_height
    );
}

static bool _vdp_cap_init_planes_adapt_format_surface_rgba(
    uint32_t *     plane_count,
    _VdpcapPlane * planes,
    uint32_t       surface_format,
    uint32_t       bits_format,
    uint32_t       region_width,
    uint32_t       region_height
)
{
    return _vdp_cap_init_planes_for_rgba_format(
        plane_count,
        planes,
        surface_format,
        region_width,
        region_height
    );
}

static bool _vdp_cap_init_planes_adapt_format_bits_indexed(
    uint32_t *     plane_count,
    _VdpcapPlane * planes,
    uint32_t       surface_format,
    uint32_t       bits_format,
    uint32_t       region_width,
    uint32_t       region_height
)
{
    return _vdp_cap_init_planes_for_indexed_format(
        plane_count,
        planes,
        bits_format,
        region_width,
        region_height
    );
}

1524
static bool _vdp_cap_init_planes_adapt_surface_video(
Aaron Plattner's avatar
Aaron Plattner committed
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
    uint32_t   surface,
    uint32_t * surface_format,
    uint32_t * width,
    uint32_t * height
)
{
    VdpStatus ret;

    VdpChromaType chroma_type;
    ret = _vdp_cap_data.vdp_video_surface_get_parameters(
        surface,
        &chroma_type,
        width,
        height
    );
    if (ret != VDP_STATUS_OK) {
        return false;
    }

    *surface_format = chroma_type;

    return true;
}

1549
static bool _vdp_cap_init_planes_adapt_surface_output(
Aaron Plattner's avatar
Aaron Plattner committed
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
    uint32_t   surface,
    uint32_t * surface_format,
    uint32_t * width,
    uint32_t * height
)
{
    VdpStatus ret;

    VdpRGBAFormat rgba_format;
    ret = _vdp_cap_data.vdp_output_surface_get_parameters(
        surface,
        &rgba_format,
        width,
        height
    );
    if (ret != VDP_STATUS_OK) {
        return false;
    }

    *surface_format = rgba_format;

    return true;
}

1574
static bool _vdp_cap_init_planes_adapt_surface_bitmap(
Aaron Plattner's avatar
Aaron Plattner committed
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
    uint32_t   surface,
    uint32_t * surface_format,
    uint32_t * width,
    uint32_t * height
)
{
    VdpStatus ret;

    VdpRGBAFormat rgba_format;
    VdpBool       frequently_accessed;
    ret = _vdp_cap_data.vdp_bitmap_surface_get_parameters(
        surface,
        &rgba_format,
        width,
        height,
        &frequently_accessed
    );
    if (ret != VDP_STATUS_OK) {
        return false;
    }

    *surface_format = rgba_format;

    return true;
}

typedef bool _Vdpcap_Init_Planes_Adapt_Format(
    uint32_t *     plane_count,
    _VdpcapPlane * planes,
    uint32_t       surface_format,
    uint32_t       bits_format,
    uint32_t       region_width,
    uint32_t       region_height
);

typedef bool _Vdpcap_Init_Planes_Adapt_Surface(
    uint32_t   surface,
    uint32_t * surface_format,
    uint32_t * width,
    uint32_t * height
);

static bool _vdp_cap_init_planes(
    uint32_t                            surface,
    void const * const *                source_data,
    uint32_t const *                    source_pitches,
    VdpRect const *                     destination_rect,
    uint32_t *                          plane_count,
    _VdpcapPlane *                      planes,
    _Vdpcap_Init_Planes_Adapt_Surface * adapt_surface,
    _Vdpcap_Init_Planes_Adapt_Format *  adapt_format,
    uint32_t                            adapt_format_bits_format
)
{
    bool ok;

    if (!source_data || !source_pitches) {
        return false;
    }

    if (_vdp_cap_data.level < LEVEL_PARAMS) {
        return false;
    }

    uint32_t surface_format;
    uint32_t width;
    uint32_t height;
    ok = adapt_surface(
        surface,
        &surface_format,
        &width,
        &height
    );
    if (!ok) {
        return false;
    }

    if (destination_rect) {
        width = delta<uint32_t>(destination_rect->x0, destination_rect->x1);
        height = delta<uint32_t>(destination_rect->y0, destination_rect->y1);
    }

    ok = adapt_format(
        plane_count,
        planes,
        surface_format,
        adapt_format_bits_format,
        width,
        height
    );
    if (!ok) {
        return false;
    }

    for (uint32_t i = 0; i < *plane_count; ++i) {
        planes[i].data = source_data[i];
        planes[i].pitch = source_pitches[i];
    }

    return true;
}

static void _vdp_cap_dump_bool_list(
    uint32_t        count,
    VdpBool const * values
)
{
    if (!values) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (count) {
        fprintf(
            _vdp_cap_data.fp,
            "%d%s",
            (int)values[0],
            (count > 1) ? ", " : ""
        );

        --count;
        ++values;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_void_pointer_list(
    uint32_t             count,
    void const * const * values,
    bool                 zero_count_question_marks
)
{
    if (!values) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    if (!count && zero_count_question_marks) {
        fputs("???", _vdp_cap_data.fp);
    }
    while (count) {
        fprintf(
            _vdp_cap_data.fp,
            "%p%s",
            values[0],
            (count > 1) ? ", " : ""
        );

        --count;
        ++values;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_uint32_t_list(
    uint32_t         count,
    uint32_t const * values,
    bool             zero_count_question_marks
)
{
    if (!values) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    if (!count && zero_count_question_marks) {
        fputs("???", _vdp_cap_data.fp);
    }
    while (count) {
        fprintf(
            _vdp_cap_data.fp,
            "%u%s",
            values[0],
            (count > 1) ? ", " : ""
        );

        --count;
        ++values;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_color_list(
    uint32_t         count,
    VdpColor const * colors
)
{
    if (!colors) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (count) {
        _vdp_cap_dump_color(&colors[0]);
        fputs(
            (count > 1) ? ", " : "",
            _vdp_cap_data.fp
        );

        --count;
        ++colors;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_color_table(
    VdpIndexedFormat    indexed_format,
    VdpColorTableFormat format,
    void const *        table
)
{
    if (!table) {
        fprintf(_vdp_cap_data.fp, "NULL");
        return;
    }

    uint32_t count;
    switch (indexed_format) {
    case VDP_INDEXED_FORMAT_A4I4:
    case VDP_INDEXED_FORMAT_I4A4:
        count = 1 << 4;
        break;
    case VDP_INDEXED_FORMAT_A8I8:
    case VDP_INDEXED_FORMAT_I8A8:
        count = 1 << 8;
        break;
    default:
        fprintf(_vdp_cap_data.fp, "???");
        return;
    }

    switch (format) {
    case VDP_COLOR_TABLE_FORMAT_B8G8R8X8:
        break;
    default:
        fprintf(_vdp_cap_data.fp, "???");
        return;
    }

    _vdp_cap_dump_uint32_t_list(
        count,
        (uint32_t const *)table,
        true
    );
}

static void _vdp_cap_dump_bitstream_buffer_list(
    uint32_t                   count,
    VdpBitstreamBuffer const * buffers
)
{
    if (!buffers) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (count) {
        fprintf(
            _vdp_cap_data.fp,
             "{(ver %d)%s %u, ",
            buffers[0].struct_version,
            (buffers[0].struct_version > 0)
                ? "(unsupported; cannot dump all fields)"
                : "",
            buffers[0].bitstream_bytes
        );
        if (_vdp_cap_data.level >= LEVEL_DATA) {
1847
            const uint8_t * ptr = (const uint8_t * )buffers[0].bitstream;
Aaron Plattner's avatar
Aaron Plattner committed
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
            for (uint32_t i = 0; i < buffers[0].bitstream_bytes; ++i) {
                fprintf(_vdp_cap_data.fp, "%02x ", ptr[i]);
            }
        }
        else {
            fputs("...", _vdp_cap_data.fp);
        }
        fputs(
            (count > 1) ? "}, " : "}",
            _vdp_cap_data.fp
        );

        --count;
        ++buffers;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_video_mixer_feature_list(
    uint32_t                     feature_count,
    VdpVideoMixerFeature const * features
)
{
    _vdp_cap_dump_uint32_t_list(
        feature_count,
        features,
        false
    );
}

static void _vdp_cap_dump_video_mixer_parameter_list(
    uint32_t                       parameter_count,
    VdpVideoMixerParameter const * parameters
)
{
    _vdp_cap_dump_uint32_t_list(
        parameter_count,
        parameters,
        false
    );
}

static void _vdp_cap_dump_video_mixer_attribute_list(
    uint32_t                       attribute_count,
    VdpVideoMixerAttribute const * attributes
)
{
    _vdp_cap_dump_uint32_t_list(
        attribute_count,
        attributes,
        false
    );
}

static void _vdp_cap_dump_video_mixer_parameter_value_list(
    uint32_t                       parameter_count,
    VdpVideoMixerParameter const * parameters,
    void const * const *           parameter_values
)
{
    if (!parameters || !parameter_values) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (parameter_count) {
        _vdp_cap_dump_video_mixer_parameter_value(parameters[0], parameter_values[0]);
        fputs((parameter_count > 1) ? ", " : "", _vdp_cap_data.fp);

        --parameter_count;
        ++parameters;
        ++parameter_values;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_video_mixer_attribute_value_list(
    uint32_t                       attribute_count,
    VdpVideoMixerAttribute const * attributes,
    void const * const *           attribute_values,
    bool                           get_operation
)
{
    if (!attributes || !attribute_values) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (attribute_count) {
        _vdp_cap_dump_video_mixer_attribute_value(
            attributes[0],
            attribute_values[0],
            get_operation
        );
        fputs((attribute_count > 1) ? ", " : "", _vdp_cap_data.fp);

        --attribute_count;
        ++attributes;
        ++attribute_values;
    }
    fputs("}", _vdp_cap_data.fp);
}

static void _vdp_cap_dump_layers_list(
    uint32_t         layer_count,
    VdpLayer const * layers
)
{
    if (!layers) {
        fputs("NULL", _vdp_cap_data.fp);
        return;
    }

    fputs("{", _vdp_cap_data.fp);
    while (layer_count) {
        fprintf(
            _vdp_cap_data.fp,
            "{(ver %d)%s %u,",
            layers[0].struct_version,
            (layers[0].struct_version > 0)
                ? "(unsupported; cannot dump all fields)"
                : "",
            layers[0].source_surface
        );

        _vdp_cap_dump_rect(layers[0].source_rect);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_rect(layers[0].destination_rect);

        fputs((layer_count > 1) ? "}, " : "}", _vdp_cap_data.fp);

        --layer_count;
        ++layers;
    }
    fputs("}", _vdp_cap_data.fp);
}

static char const * _vdp_cap_get_error_string(
    VdpStatus status
)
{
    char const * ret;

    fputs("vdp_get_error_string(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%d",
            status
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_get_error_string(
        status
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        if (ret) {
            fprintf(_vdp_cap_data.fp, "    -> '%s'\n", ret);
        }
        else {
            fprintf(_vdp_cap_data.fp, "    -> NULL\n");
        }
    }

    return ret;
}

static VdpStatus _vdp_cap_get_api_version(
    /* output parameters follow */
    uint32_t * api_version
)
{
    VdpStatus ret;

    fputs("vdp_get_api_version(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%s",
            api_version ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_get_api_version(
        api_version
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2043
2044
2045
2046
2047
2048
            if (api_version) {
                fprintf(_vdp_cap_data.fp, ", %u", *api_version);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_get_information_string(
    /* output parameters follow */
    char const * * information_string
)
{
    VdpStatus ret;

    fputs("vdp_get_information_string(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%s",
            information_string ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_get_information_string(
        information_string
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2080
2081
2082
2083
2084
2085
2086
2087
2088
            if (information_string && *information_string) {
                fprintf(_vdp_cap_data.fp, ", \"%s\"", *information_string);
            }
            else if (information_string) {
                fputs(", (null)", _vdp_cap_data.fp);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_device_destroy(
    VdpDevice device
)
{
    VdpStatus ret;

    fputs("vdp_device_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            device
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_device_destroy(
        device
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_generate_csc_matrix(
    VdpProcamp *     procamp,
    VdpColorStandard standard,
    /* output parameters follow */
    VdpCSCMatrix *   csc_matrix
)
{
    VdpStatus ret;

    fputs("vdp_generate_csc_matrix(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        _vdp_cap_dump_procamp(procamp);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, %s",
            standard,
            csc_matrix ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_generate_csc_matrix(
        procamp,
        standard,
        csc_matrix
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2153
2154
2155
2156
2157
2158
2159
            if (csc_matrix) {
                fputs(", ", _vdp_cap_data.fp);
                _vdp_cap_dump_csc_matrix(csc_matrix);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_surface_query_capabilities(
    VdpDevice     device,
    VdpChromaType surface_chroma_type,
    /* output parameters follow */
    VdpBool *     is_supported,
    uint32_t *    max_width,
    uint32_t *    max_height
)
{
    VdpStatus ret;

    fputs("vdp_video_surface_query_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s, %s, %s",
            device,
            surface_chroma_type,
            is_supported ? "-" : "NULL",
            max_width ? "-" : "NULL",
            max_height ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_surface_query_capabilities(
        device,
        surface_chroma_type,
        is_supported,
        max_width,
        max_height
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_width) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_height) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_surface_query_get_put_bits_y_cb_cr_capabilities(
    VdpDevice      device,
    VdpChromaType  surface_chroma_type,
    VdpYCbCrFormat bits_ycbcr_format,
    /* output parameters follow */
    VdpBool *      is_supported
)
{
    VdpStatus ret;

    fputs("vdp_video_surface_query_get_put_bits_y_cb_cr_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %s",
            device,
            surface_chroma_type,
            bits_ycbcr_format,
            is_supported ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_surface_query_get_put_bits_y_cb_cr_capabilities(
        device,
        surface_chroma_type,
        bits_ycbcr_format,
        is_supported
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2261
2262
2263
2264
2265
2266
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_surface_create(
    VdpDevice         device,
    VdpChromaType     chroma_type,
    uint32_t          width,
    uint32_t          height,
    /* output parameters follow */
    VdpVideoSurface * surface
)
{
    VdpStatus ret;

    fputs("vdp_video_surface_create(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %u, %s",
            device,
            chroma_type,
            width,
            height,
            surface ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_surface_create(
        device,
        chroma_type,
        width,
        height,
        surface
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2310
2311
2312
2313
2314
2315
            if (surface) {
                fprintf(_vdp_cap_data.fp, ", %u", *surface);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_surface_destroy(
    VdpVideoSurface surface
)
{
    VdpStatus ret;

    fputs("vdp_video_surface_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            surface
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_surface_destroy(
        surface
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_surface_get_parameters(
    VdpVideoSurface surface,
    /* output parameters follow */
    VdpChromaType * chroma_type,
    uint32_t *      width,
    uint32_t *      height
)
{
    VdpStatus ret;

    fputs("vdp_video_surface_get_parameters(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %s, %s, %s",
            surface,
            chroma_type ? "-" : "NULL",
            width ? "-" : "NULL",
            height ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_surface_get_parameters(
        surface,
        chroma_type,
        width,
        height
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
            if (chroma_type) {
                fprintf(_vdp_cap_data.fp, ", %u", *chroma_type);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (width) {
                fprintf(_vdp_cap_data.fp, ", %u", *width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (height) {
                fprintf(_vdp_cap_data.fp, ", %u", *height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_surface_get_bits_y_cb_cr(
    VdpVideoSurface  surface,
    VdpYCbCrFormat   destination_ycbcr_format,
    void * const *   destination_data,
    uint32_t const * destination_pitches
)
{
    VdpStatus ret;

    _VdpcapPlane planes[3];
    uint32_t    plane_count = _VDP_TRACE_ARSIZE(planes);
    bool dump_data = _vdp_cap_init_planes(
        surface,
        destination_data,
        destination_pitches,
        0,
        &plane_count,
        planes,
        _vdp_cap_init_planes_adapt_surface_video,
        _vdp_cap_init_planes_adapt_format_bits_ycbcr,
        destination_ycbcr_format
    );
    if (!dump_data) {
        plane_count = 0;
    }

    fputs("vdp_video_surface_get_bits_y_cb_cr(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, ",
            surface,
            destination_ycbcr_format
        );
        _vdp_cap_dump_void_pointer_list(plane_count, destination_data, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_uint32_t_list(plane_count, destination_pitches, true);
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_surface_get_bits_y_cb_cr(
        surface,
        destination_ycbcr_format,
        destination_data,
        destination_pitches
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }
    if (_vdp_cap_data.level >= LEVEL_DATA) {
        fputs("    ... Data: ", _vdp_cap_data.fp);
        if (dump_data) {
            _vdp_cap_dump_plane_list(plane_count, planes);
        }
        else {
           fputs("???", _vdp_cap_data.fp);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_surface_put_bits_y_cb_cr(
    VdpVideoSurface      surface,
    VdpYCbCrFormat       source_ycbcr_format,
    void const * const * source_data,
    uint32_t const *     source_pitches
)
{
    VdpStatus ret;

    _VdpcapPlane planes[3];
    uint32_t    plane_count = _VDP_TRACE_ARSIZE(planes);
    bool dump_data = _vdp_cap_init_planes(
        surface,
        source_data,
        source_pitches,
        0,
        &plane_count,
        planes,
        _vdp_cap_init_planes_adapt_surface_video,
        _vdp_cap_init_planes_adapt_format_bits_ycbcr,
        source_ycbcr_format
    );
    if (!dump_data) {
        plane_count = 0;
    }

    fputs("vdp_video_surface_put_bits_y_cb_cr(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, ",
            surface,
            source_ycbcr_format
        );
        _vdp_cap_dump_void_pointer_list(plane_count, source_data, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_uint32_t_list(plane_count, source_pitches, true);
        fputs(", ", _vdp_cap_data.fp);
    }
    fputs(")\n", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_DATA) {
        fputs("    ... Data: ", _vdp_cap_data.fp);
        if (dump_data) {
            _vdp_cap_dump_plane_list(plane_count, planes);
        }
        else {
           fputs("???", _vdp_cap_data.fp);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    ret = _vdp_cap_data.vdp_video_surface_put_bits_y_cb_cr(
        surface,
        source_ycbcr_format,
        source_data,
        source_pitches
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_query_capabilities(
    VdpDevice     device,
    VdpRGBAFormat surface_rgba_format,
    /* output parameters follow */
    VdpBool *     is_supported,
    uint32_t *    max_width,
    uint32_t *    max_height
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_query_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s, %s, %s",
            device,
            surface_rgba_format,
            is_supported ? "-" : "NULL",
            max_width ? "-" : "NULL",
            max_height ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_query_capabilities(
        device,
        surface_rgba_format,
        is_supported,
        max_width,
        max_height
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_width) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_height) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_query_get_put_bits_native_capabilities(
    VdpDevice     device,
    VdpRGBAFormat surface_rgba_format,
    /* output parameters follow */
    VdpBool *     is_supported
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_query_get_put_bits_native_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s",
            device,
            surface_rgba_format,
            is_supported ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_query_get_put_bits_native_capabilities(
        device,
        surface_rgba_format,
        is_supported
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2628
2629
2630
2631
2632
2633
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_query_put_bits_indexed_capabilities(
    VdpDevice           device,
    VdpRGBAFormat       surface_rgba_format,
    VdpIndexedFormat    bits_indexed_format,
    VdpColorTableFormat color_table_format,
    /* output parameters follow */
    VdpBool *           is_supported
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_query_put_bits_indexed_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %u, %s",
            device,
            surface_rgba_format,
            bits_indexed_format,
            color_table_format,
            is_supported ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_query_put_bits_indexed_capabilities(
        device,
        surface_rgba_format,
        bits_indexed_format,
        color_table_format,
        is_supported
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2677
2678
2679
2680
2681
2682
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_query_put_bits_y_cb_cr_capabilities(
    VdpDevice      device,
    VdpRGBAFormat  surface_rgba_format,
    VdpYCbCrFormat bits_ycbcr_format,
    /* output parameters follow */
    VdpBool *      is_supported
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_query_put_bits_y_cb_cr_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %s",
            device,
            surface_rgba_format,
            bits_ycbcr_format,
            is_supported ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_query_put_bits_y_cb_cr_capabilities(
        device,
        surface_rgba_format,
        bits_ycbcr_format,
        is_supported
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2723
2724
2725
2726
2727
2728
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_create(
    VdpDevice          device,
    VdpRGBAFormat      rgba_format,
    uint32_t           width,
    uint32_t           height,
    /* output parameters follow */
    VdpOutputSurface * surface
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_create(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %u, %s",
            device,
            rgba_format,
            width,
            height,
            surface ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_create(
        device,
        rgba_format,
        width,
        height,
        surface
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2772
2773
2774
2775
2776
2777
            if (surface) {
                fprintf(_vdp_cap_data.fp, ", %u", *surface);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_destroy(
    VdpOutputSurface surface
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            surface
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_destroy(
        surface
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_get_parameters(
    VdpOutputSurface surface,
    /* output parameters follow */
    VdpRGBAFormat *  rgba_format,
    uint32_t *       width,
    uint32_t *       height
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_get_parameters(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %s, %s, %s",
            surface,
            rgba_format ? "-" : "NULL",
            width ? "-" : "NULL",
            height ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_get_parameters(
        surface,
        rgba_format,
        width,
        height
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
            if (rgba_format) {
                fprintf(_vdp_cap_data.fp, ", %u", *rgba_format);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (width) {
                fprintf(_vdp_cap_data.fp, ", %u", *width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (height) {
                fprintf(_vdp_cap_data.fp, ", %u", *height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_get_bits_native(
    VdpOutputSurface  surface,
    VdpRect const *   source_rect,
    void * const *    destination_data,
    uint32_t const *  destination_pitches
)
{
    VdpStatus ret;

    _VdpcapPlane planes[1];
    uint32_t    plane_count = _VDP_TRACE_ARSIZE(planes);
    bool dump_data = _vdp_cap_init_planes(
        surface,
        destination_data,
        destination_pitches,
        source_rect,
        &plane_count,
        planes,
        _vdp_cap_init_planes_adapt_surface_output,
        _vdp_cap_init_planes_adapt_format_surface_rgba,
        0
    );
    if (!dump_data) {
        plane_count = 0;
    }

    fputs("vdp_output_surface_get_bits_native(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, ",
            surface
        );
        _vdp_cap_dump_rect(source_rect);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_void_pointer_list(plane_count, destination_data, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_uint32_t_list(plane_count, destination_pitches, true);
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_get_bits_native(
        surface,
        source_rect,
        destination_data,
        destination_pitches
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }
    if (_vdp_cap_data.level >= LEVEL_DATA) {
        fputs("    ... Data: ", _vdp_cap_data.fp);
        if (dump_data) {
            _vdp_cap_dump_plane_list(plane_count, planes);
        }
        else {
           fputs("???", _vdp_cap_data.fp);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_put_bits_native(
    VdpOutputSurface     surface,
    void const * const * source_data,
    uint32_t const *     source_pitches,
    VdpRect const *      destination_rect
)
{
    VdpStatus ret;

    _VdpcapPlane planes[1];
    uint32_t    plane_count = _VDP_TRACE_ARSIZE(planes);
    bool dump_data = _vdp_cap_init_planes(
        surface,
        source_data,
        source_pitches,
        destination_rect,
        &plane_count,
        planes,
        _vdp_cap_init_planes_adapt_surface_output,
        _vdp_cap_init_planes_adapt_format_surface_rgba,
        0
    );
    if (!dump_data) {
        plane_count = 0;
    }

    fputs("vdp_output_surface_put_bits_native(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, ",
            surface
        );
        _vdp_cap_dump_void_pointer_list(plane_count, source_data, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_uint32_t_list(plane_count, source_pitches, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_rect(destination_rect);
    }
    fputs(")\n", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_DATA) {
        fputs("    ... Data: ", _vdp_cap_data.fp);
        if (dump_data) {
            _vdp_cap_dump_plane_list(plane_count, planes);
        }
        else {
           fputs("???", _vdp_cap_data.fp);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    ret = _vdp_cap_data.vdp_output_surface_put_bits_native(
        surface,
        source_data,
        source_pitches,
        destination_rect
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_put_bits_indexed(
    VdpOutputSurface     surface,
    VdpIndexedFormat     source_indexed_format,
    void const * const * source_data,
    uint32_t const *     source_pitches,
    VdpRect const *      destination_rect,
    VdpColorTableFormat  color_table_format,
    void const *         color_table
)
{
    VdpStatus ret;

    _VdpcapPlane planes[1];
    uint32_t    plane_count = _VDP_TRACE_ARSIZE(planes);
    bool dump_data = _vdp_cap_init_planes(
        surface,
        source_data,
        source_pitches,
        destination_rect,
        &plane_count,
        planes,
        _vdp_cap_init_planes_adapt_surface_output,
        _vdp_cap_init_planes_adapt_format_bits_indexed,
        source_indexed_format
    );
    if (!dump_data) {
        plane_count = 0;
    }

    fputs("vdp_output_surface_put_bits_indexed(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, ",
            surface,
            source_indexed_format
        );
        _vdp_cap_dump_void_pointer_list(plane_count, source_data, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_uint32_t_list(plane_count, source_pitches, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_rect(destination_rect);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, ",
            color_table_format
        );
        _vdp_cap_dump_color_table(
            source_indexed_format,
            color_table_format,
            color_table
        );
    }
    fputs(")\n", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_DATA) {
        fputs("    ... Data: ", _vdp_cap_data.fp);
        if (dump_data) {
            _vdp_cap_dump_plane_list(plane_count, planes);
        }
        else {
           fputs("???", _vdp_cap_data.fp);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    ret = _vdp_cap_data.vdp_output_surface_put_bits_indexed(
        surface,
        source_indexed_format,
        source_data,
        source_pitches,
        destination_rect,
        color_table_format,
        color_table
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_put_bits_y_cb_cr(
    VdpOutputSurface     surface,
    VdpYCbCrFormat       source_ycbcr_format,
    void const * const * source_data,
    uint32_t const *     source_pitches,
    VdpRect const *      destination_rect,
    VdpCSCMatrix const * csc_matrix
)
{
    VdpStatus ret;

    _VdpcapPlane planes[1];
    uint32_t    plane_count = _VDP_TRACE_ARSIZE(planes);
    bool dump_data = _vdp_cap_init_planes(
        surface,
        source_data,
        source_pitches,
        destination_rect,
        &plane_count,
        planes,
        _vdp_cap_init_planes_adapt_surface_output,
        _vdp_cap_init_planes_adapt_format_bits_ycbcr,
        source_ycbcr_format
    );
    if (!dump_data) {
        plane_count = 0;
    }

    fputs("vdp_output_surface_put_bits_y_cb_cr(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, ",
            surface,
            source_ycbcr_format
        );
        _vdp_cap_dump_void_pointer_list(plane_count, source_data, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_uint32_t_list(plane_count, source_pitches, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_rect(destination_rect);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_csc_matrix(csc_matrix);
    }
    fputs(")\n", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_DATA) {
        fputs("    ... Data: ", _vdp_cap_data.fp);
        if (dump_data) {
            _vdp_cap_dump_plane_list(plane_count, planes);
        }
        else {
           fputs("???", _vdp_cap_data.fp);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    ret = _vdp_cap_data.vdp_output_surface_put_bits_y_cb_cr(
        surface,
        source_ycbcr_format,
        source_data,
        source_pitches,
        destination_rect,
        csc_matrix
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_bitmap_surface_query_capabilities(
    VdpDevice     device,
    VdpRGBAFormat surface_rgba_format,
    /* output parameters follow */
    VdpBool *     is_supported,
    uint32_t *    max_width,
    uint32_t *    max_height
)
{
    VdpStatus ret;

    fputs("vdp_bitmap_surface_query_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s, %s, %s",
            device,
            surface_rgba_format,
            is_supported ? "-" : "NULL",
            max_width ? "-" : "NULL",
            max_height ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_bitmap_surface_query_capabilities(
        device,
        surface_rgba_format,
        is_supported,
        max_width,
        max_height
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_width) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_height) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_bitmap_surface_create(
    VdpDevice         device,
    VdpRGBAFormat     rgba_format,
    uint32_t          width,
    uint32_t          height,
    VdpBool           frequently_accessed,
    /* output parameters follow */
    VdpBitmapSurface * surface
)
{
    VdpStatus ret;

    fputs("vdp_bitmap_surface_create(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %u, %d, %s",
            device,
            rgba_format,
            width,
            height,
            frequently_accessed,
            surface ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_bitmap_surface_create(
        device,
        rgba_format,
        width,
        height,
        frequently_accessed,
        surface
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3254
3255
3256
3257
3258
3259
            if (surface) {
                fprintf(_vdp_cap_data.fp, ", %u", *surface);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_bitmap_surface_destroy(
    VdpBitmapSurface surface
)
{
    VdpStatus ret;

    fputs("vdp_bitmap_surface_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            surface
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_bitmap_surface_destroy(
        surface
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_bitmap_surface_get_parameters(
    VdpBitmapSurface surface,
    /* output parameters follow */
    VdpRGBAFormat * rgba_format,
    uint32_t *      width,
    uint32_t *      height,
    VdpBool *       frequently_accessed
)
{
    VdpStatus ret;

    fputs("vdp_bitmap_surface_get_parameters(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %s, %s, %s, %s",
            surface,
            rgba_format ? "-" : "NULL",
            width ? "-" : "NULL",
            height ? "-" : "NULL",
            frequently_accessed ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_bitmap_surface_get_parameters(
        surface,
        rgba_format,
        width,
        height,
        frequently_accessed
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
            if (rgba_format) {
                fprintf(_vdp_cap_data.fp, ", %u", *rgba_format);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (width) {
                fprintf(_vdp_cap_data.fp, ", %u", *width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (height) {
                fprintf(_vdp_cap_data.fp, ", %u", *height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (frequently_accessed) {
                fprintf(_vdp_cap_data.fp, ", %d", *frequently_accessed);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_bitmap_surface_put_bits_native(
    VdpBitmapSurface     surface,
    void const * const * source_data,
    uint32_t const *     source_pitches,
    VdpRect const *      destination_rect
)
{
    VdpStatus ret;

    _VdpcapPlane planes[1];
    uint32_t    plane_count = _VDP_TRACE_ARSIZE(planes);
    bool dump_data = _vdp_cap_init_planes(
        surface,
        source_data,
        source_pitches,
        destination_rect,
        &plane_count,
        planes,
        _vdp_cap_init_planes_adapt_surface_bitmap,
        _vdp_cap_init_planes_adapt_format_surface_rgba,
        0
    );
    if (!dump_data) {
        plane_count = 0;
    }

    fputs("vdp_bitmap_surface_put_bits_native(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, ",
            surface
        );
        _vdp_cap_dump_void_pointer_list(plane_count, source_data, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_uint32_t_list(plane_count, source_pitches, true);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_rect(destination_rect);
    }
    fputs(")\n", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_DATA) {
        fputs("    ... Data: ", _vdp_cap_data.fp);
        if (dump_data) {
            _vdp_cap_dump_plane_list(plane_count, planes);
        }
        else {
           fputs("???", _vdp_cap_data.fp);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    ret = _vdp_cap_data.vdp_bitmap_surface_put_bits_native(
        surface,
        source_data,
        source_pitches,
        destination_rect
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_render_output_surface(
    VdpOutputSurface                         destination_surface,
    VdpRect const *                          destination_rect,
    VdpOutputSurface                         source_surface,
    VdpRect const *                          source_rect,
    VdpColor const *                         colors,
    VdpOutputSurfaceRenderBlendState const * blend_state,
    uint32_t                                 flags
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_render_output_surface(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, ",
            destination_surface
        );
        _vdp_cap_dump_rect(destination_rect);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, ",
            source_surface
        );
        _vdp_cap_dump_rect(source_rect);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_color_list((flags & VDP_OUTPUT_SURFACE_RENDER_COLOR_PER_VERTEX) ? 4 : 1, colors);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_blend_state(blend_state);
        fprintf(
            _vdp_cap_data.fp,
            ", %u",
            flags
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_render_output_surface(
        destination_surface,
        destination_rect,
        source_surface,
        source_rect,
        colors,
        blend_state,
        flags
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_output_surface_render_bitmap_surface(
    VdpOutputSurface                         destination_surface,
    VdpRect const *                          destination_rect,
    VdpBitmapSurface                         source_surface,
    VdpRect const *                          source_rect,
    VdpColor const *                         colors,
    VdpOutputSurfaceRenderBlendState const * blend_state,
    uint32_t                                 flags
)
{
    VdpStatus ret;

    fputs("vdp_output_surface_render_bitmap_surface(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, ",
            destination_surface
        );
        _vdp_cap_dump_rect(destination_rect);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, ",
            source_surface
        );
        _vdp_cap_dump_rect(source_rect);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_color_list((flags & VDP_OUTPUT_SURFACE_RENDER_COLOR_PER_VERTEX) ? 4 : 1, colors);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_blend_state(blend_state);
        fprintf(
            _vdp_cap_data.fp,
            ", %u",
            flags
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_output_surface_render_bitmap_surface(
        destination_surface,
        destination_rect,
        source_surface,
        source_rect,
        colors,
        blend_state,
        flags
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_decoder_query_capabilities(
    VdpDevice         device,
    VdpDecoderProfile profile,
    /* output parameters follow */
    VdpBool *         is_supported,
    uint32_t *        max_level,
    uint32_t *        max_macroblocks,
    uint32_t *        max_width,
    uint32_t *        max_height
)
{
    VdpStatus ret;

    fputs("vdp_decoder_query_capabilities(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s, %s, %s, %s, %s",
            device,
            profile,
            is_supported ? "-" : "NULL",
            max_level ? "-" : "NULL",
            max_macroblocks ? "-" : "NULL",
            max_width ? "-" : "NULL",
            max_height ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_decoder_query_capabilities(
        device,
        profile,
        is_supported,
        max_level,
        max_macroblocks,
        max_width,
        max_height
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_level) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_level);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_macroblocks) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_macroblocks);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_width) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (max_height) {
                fprintf(_vdp_cap_data.fp, ", %u", *max_height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_decoder_create(
    VdpDevice         device,
    VdpDecoderProfile profile,
    uint32_t          width,
    uint32_t          height,
    uint32_t          max_references,
    /* output parameters follow */
    VdpDecoder *      decoder
)
{
    VdpStatus ret;

    fputs("vdp_decoder_create(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %u, %u, %s",
            device,
            profile,
            width,
            height,
            max_references,
            decoder ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_decoder_create(
        device,
        profile,
        width,
        height,
        max_references,
        decoder
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3654
3655
3656
3657
3658
3659
            if (decoder) {
                fprintf(_vdp_cap_data.fp, ", %u", *decoder);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_decoder_destroy(
    VdpDecoder decoder
)
{
    VdpStatus ret;

    fputs("vdp_decoder_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            decoder
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_decoder_destroy(
        decoder
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_decoder_get_parameters(
    VdpDecoder          decoder,
    /* output parameters follow */
    VdpDecoderProfile * profile,
    uint32_t *          width,
    uint32_t *          height
)
{
    VdpStatus ret;

    fputs("vdp_decoder_get_parameters(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %s, %s, %s",
            decoder,
            profile ? "-" : "NULL",
            width ? "-" : "NULL",
            height ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_decoder_get_parameters(
        decoder,
        profile,
        width,
        height
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
            if (profile) {
                fprintf(_vdp_cap_data.fp, ", %u", *profile);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (width) {
                fprintf(_vdp_cap_data.fp, ", %u", *width);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (height) {
                fprintf(_vdp_cap_data.fp, ", %u", *height);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_decoder_render(
    VdpDecoder                 decoder,
    VdpVideoSurface            target,
    VdpPictureInfo const *     picture_info,
    uint32_t                   bitstream_buffer_count,
    VdpBitstreamBuffer const * bitstream_buffers
)
{
    VdpStatus ret;

    fputs("vdp_decoder_render(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        VdpDecoderProfile profile;
        uint32_t          width;
        uint32_t          height;

        ret = _vdp_cap_data.vdp_decoder_get_parameters(
            decoder,
            &profile,
            &width,
            &height
        );

        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, ",
            decoder,
            target
        );
        _vdp_cap_dump_picture_info(profile, picture_info);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, ",
            bitstream_buffer_count
        );
        _vdp_cap_dump_bitstream_buffer_list(bitstream_buffer_count, bitstream_buffers);
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_decoder_render(
        decoder,
        target,
        picture_info,
        bitstream_buffer_count,
        bitstream_buffers
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}


static VdpStatus _vdp_cap_video_mixer_query_feature_support(
    VdpDevice            device,
    VdpVideoMixerFeature feature,
    /* output parameters follow */
    VdpBool *            is_supported
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_query_feature_support(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s",
            device,
            feature,
            is_supported ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_query_feature_support(
        device,
        feature,
        is_supported
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3837
3838
3839
3840
3841
3842
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_query_parameter_support(
    VdpDevice              device,
    VdpVideoMixerParameter parameter,
    /* output parameters follow */
    VdpBool *              is_supported
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_query_parameter_support(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s",
            device,
            parameter,
            is_supported ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_query_parameter_support(
        device,
        parameter,
        is_supported
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3880
3881
3882
3883
3884
3885
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_query_attribute_support(
    VdpDevice              device,
    VdpVideoMixerAttribute attribute,
    /* output parameters follow */
    VdpBool *              is_supported
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_query_attribute_support(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s",
            device,
            attribute,
            is_supported ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_query_attribute_support(
        device,
        attribute,
        is_supported
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
3923
3924
3925
3926
3927
3928
            if (is_supported) {
                fprintf(_vdp_cap_data.fp, ", %d", *is_supported);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_query_parameter_value_range(
    VdpDevice              device,
    VdpVideoMixerParameter parameter,
    /* output parameters follow */
    void *                 min_value,
    void *                 max_value
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_query_parameter_value_range(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s, %s",
            device,
            parameter,
            min_value ? "-" : "NULL",
            max_value ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_query_parameter_value_range(
        device,
        parameter,
        min_value,
        max_value
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_video_mixer_parameter_value(parameter, min_value);
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_video_mixer_parameter_value(parameter, max_value);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_query_attribute_value_range(
    VdpDevice              device,
    VdpVideoMixerAttribute attribute,
    /* output parameters follow */
    void *                 min_value,
    void *                 max_value
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_query_attribute_value_range(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s, %s",
            device,
            attribute,
            min_value ? "-" : "NULL",
            max_value ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_query_attribute_value_range(
        device,
        attribute,
        min_value,
        max_value
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_video_mixer_attribute_value(attribute, min_value, false);
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_video_mixer_attribute_value(attribute, max_value, false);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_create(
    VdpDevice                      device,
    uint32_t                       feature_count,
    VdpVideoMixerFeature const *   features,
    uint32_t                       parameter_count,
    VdpVideoMixerParameter const * parameters,
    void const * const *           parameter_values,
    /* output parameters follow */
    VdpVideoMixer *                mixer
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_create(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "%u, %u, ", device, feature_count);
        _vdp_cap_dump_video_mixer_feature_list(feature_count, features);
        fprintf(_vdp_cap_data.fp, ", %u, ", parameter_count);
        _vdp_cap_dump_video_mixer_parameter_list(parameter_count, parameters);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_video_mixer_parameter_value_list(
            parameter_count,
            parameters,
            parameter_values
        );
        fprintf(_vdp_cap_data.fp, ", %s", mixer ? "-" : "NULL");
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_create(
        device,
        feature_count,
        features,
        parameter_count,
        parameters,
        parameter_values,
        mixer
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
4066
4067
4068
4069
4070
4071
            if (mixer) {
                fprintf(_vdp_cap_data.fp, ", %u", *mixer);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_set_feature_enables(
    VdpVideoMixer                mixer,
    uint32_t                     feature_count,
    VdpVideoMixerFeature const * features,
    VdpBool const *              feature_enables
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_set_feature_enables(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "%u, %u, ", mixer, feature_count);
        _vdp_cap_dump_video_mixer_feature_list(feature_count, features);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_bool_list(feature_count, feature_enables);
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_set_feature_enables(
        mixer,
        feature_count,
        features,
        feature_enables
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_set_attribute_values(
    VdpVideoMixer                  mixer,
    uint32_t                       attribute_count,
    VdpVideoMixerAttribute const * attributes,
    void const * const *           attribute_values
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_set_attribute_values(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "%u, %u, ", mixer, attribute_count);
        _vdp_cap_dump_video_mixer_attribute_list(attribute_count, attributes);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_video_mixer_attribute_value_list(
            attribute_count,
            attributes,
            attribute_values,
            false
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_set_attribute_values(
        mixer,
        attribute_count,
        attributes,
        attribute_values
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_get_feature_support(
    VdpVideoMixer                mixer,
    uint32_t                     feature_count,
    VdpVideoMixerFeature const * features,
    /* output parameters follow */
    VdpBool *                    feature_supports
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_get_feature_support(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "%u, %u, ", mixer, feature_count);
        _vdp_cap_dump_video_mixer_feature_list(feature_count, features);
        fputs(feature_supports ? "-" : "NULL", _vdp_cap_data.fp);
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_get_feature_support(
        mixer,
        feature_count,
        features,
        feature_supports
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_bool_list(feature_count, feature_supports);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_get_feature_enables(
    VdpVideoMixer                mixer,
    uint32_t                     feature_count,
    VdpVideoMixerFeature const * features,
    /* output parameters follow */
    VdpBool *                    feature_enables
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_get_feature_enables(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "%u, %u, ", mixer, feature_count);
        _vdp_cap_dump_video_mixer_feature_list(feature_count, features);
        fprintf(_vdp_cap_data.fp, ", %s", feature_enables ? "-" : "NULL");
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_get_feature_enables(
        mixer,
        feature_count,
        features,
        feature_enables
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_bool_list(feature_count, feature_enables);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_get_parameter_values(
    VdpVideoMixer                  mixer,
    uint32_t                       parameter_count,
    VdpVideoMixerParameter const * parameters,
    /* output parameters follow */
    void * const *                 parameter_values
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_get_parameter_values(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "%u, %u, ", mixer, parameter_count);
        _vdp_cap_dump_video_mixer_parameter_list(parameter_count, parameters);
        fprintf(_vdp_cap_data.fp, ", %s", parameter_values ? "-" : "NULL");
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_get_parameter_values(
        mixer,
        parameter_count,
        parameters,
        parameter_values
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_video_mixer_parameter_value_list(
                parameter_count,
                parameters,
                parameter_values
            );
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_get_attribute_values(
    VdpVideoMixer                  mixer,
    uint32_t                       attribute_count,
    VdpVideoMixerAttribute const * attributes,
    /* output parameters follow */
    void * const *                 attribute_values
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_get_attribute_values(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "%u, %u, ", mixer, attribute_count);
        _vdp_cap_dump_video_mixer_attribute_list(attribute_count, attributes);
        fprintf(_vdp_cap_data.fp, ", %s", attribute_values ? "-" : "NULL");
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_get_attribute_values(
        mixer,
        attribute_count,
        attributes,
        attribute_values
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_video_mixer_attribute_value_list(
                attribute_count,
                attributes,
                attribute_values,
                true
            );
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_destroy(
    VdpVideoMixer mixer
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            mixer
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_destroy(
        mixer
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_video_mixer_render(
    VdpVideoMixer                 mixer,
    VdpOutputSurface              background_surface,
    VdpRect const *               background_source_rect,
    VdpVideoMixerPictureStructure current_picture_structure,
    uint32_t                      video_surface_past_count,
    VdpVideoSurface const *       video_surface_past,
    VdpVideoSurface               video_surface_current,
    uint32_t                      video_surface_future_count,
    VdpVideoSurface const *       video_surface_future,
    VdpRect const *               video_source_rect,
    VdpOutputSurface              destination_surface,
    VdpRect const *               destination_rect,
    VdpRect const *               destination_video_rect,
    uint32_t                      layer_count,
    VdpLayer const *              layers
)
{
    VdpStatus ret;

    fputs("vdp_video_mixer_render(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, ",
            mixer,
            background_surface
        );
        _vdp_cap_dump_rect(background_source_rect);
        fprintf(
            _vdp_cap_data.fp,
            ", %d, %u, ",
            current_picture_structure,
            video_surface_past_count
        );
        _vdp_cap_dump_uint32_t_list(video_surface_past_count, video_surface_past, false);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, %u, ",
            video_surface_current,
            video_surface_future_count
        );
        _vdp_cap_dump_uint32_t_list(video_surface_future_count, video_surface_future, false);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_rect(video_source_rect);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, ",
            destination_surface
        );
        _vdp_cap_dump_rect(destination_rect);
        fputs(", ", _vdp_cap_data.fp);
        _vdp_cap_dump_rect(destination_video_rect);
        fprintf(
            _vdp_cap_data.fp,
            ", %u, ",
            layer_count
        );
        _vdp_cap_dump_layers_list(layer_count, layers);
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_video_mixer_render(
        mixer,
        background_surface,
        background_source_rect,
        current_picture_structure,
        video_surface_past_count,
        video_surface_past,
        video_surface_current,
        video_surface_future_count,
        video_surface_future,
        video_source_rect,
        destination_surface,
        destination_rect,
        destination_video_rect,
        layer_count,
        layers
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_target_destroy(
    VdpPresentationQueueTarget presentation_queue_target
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_target_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            presentation_queue_target
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_target_destroy(
        presentation_queue_target
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_create(
    VdpDevice                  device,
    VdpPresentationQueueTarget presentation_queue_target,
    /* output parameters follow */
    VdpPresentationQueue *     presentation_queue
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_create(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s",
            device,
            presentation_queue_target,
            presentation_queue ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_create(
        device,
        presentation_queue_target,
        presentation_queue
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
4476
4477
4478
4479
4480
4481
            if (presentation_queue) {
                fprintf(_vdp_cap_data.fp, ", %u", *presentation_queue);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_destroy(
    VdpPresentationQueue presentation_queue
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_destroy(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u",
            presentation_queue
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_destroy(
        presentation_queue
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_set_background_color(
    VdpPresentationQueue presentation_queue,
    VdpColor * const     background_color
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_set_background_color(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, ",
            presentation_queue
        );
        _vdp_cap_dump_color(background_color);
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_set_background_color(
        presentation_queue,
        background_color
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_get_background_color(
    VdpPresentationQueue presentation_queue,
    VdpColor *           background_color
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_get_background_color(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %s",
            presentation_queue,
            background_color ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_get_background_color(
        presentation_queue,
        background_color
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fputs(", ", _vdp_cap_data.fp);
            _vdp_cap_dump_color(background_color);
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_get_time(
    VdpPresentationQueue presentation_queue,
    /* output parameters follow */
    VdpTime *            current_time
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_get_time(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %s",
            presentation_queue,
            current_time ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_get_time(
        presentation_queue,
        current_time
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
4608
4609
4610
4611
4612
4613
            if (current_time) {
                fprintf(_vdp_cap_data.fp, ", %" PRIu64, *current_time);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_display(
    VdpPresentationQueue presentation_queue,
    VdpOutputSurface     surface,
    uint32_t             clip_width,
    uint32_t             clip_height,
    VdpTime              earliest_presentation_time
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_display(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %u, %u, %" PRIu64,
            presentation_queue,
            surface,
            clip_width,
            clip_height,
            earliest_presentation_time
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_display(
        presentation_queue,
        surface,
        clip_width,
        clip_height,
        earliest_presentation_time
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_block_until_surface_idle(
    VdpPresentationQueue presentation_queue,
    VdpOutputSurface     surface,
    /* output parameters follow */
    VdpTime *            first_presentation_time
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_block_until_surface_idle(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s",
            presentation_queue,
            surface,
            first_presentation_time ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_block_until_surface_idle(
        presentation_queue,
        surface,
        first_presentation_time
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
4690
4691
4692
4693
4694
4695
            if (first_presentation_time) {
                fprintf(_vdp_cap_data.fp, ", %" PRIu64, *first_presentation_time);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_query_surface_status(
    VdpPresentationQueue         presentation_queue,
    VdpOutputSurface             surface,
    /* output parameters follow */
    VdpPresentationQueueStatus * status,
    VdpTime *                    first_presentation_time
)
{
    VdpStatus ret;

    fputs("vdp_presentation_queue_query_surface_status(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s, %s",
            presentation_queue,
            surface,
            status ? "-" : "NULL",
            first_presentation_time ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_query_surface_status(
        presentation_queue,
        surface,
        status,
        first_presentation_time
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
            if (status) {
                fprintf(_vdp_cap_data.fp, ", %d", *status);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
            if (first_presentation_time) {
                fprintf(_vdp_cap_data.fp, ", %" PRIu64, *first_presentation_time);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_preemption_callback_register(
    VdpDevice             device,
    VdpPreemptionCallback callback,
    void *                context
)
{
    VdpStatus ret;

    fputs("vdp_preemption_callback_register(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %p, %p",
            device,
            callback,
            context
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_preemption_callback_register(
        device,
        callback,
        context
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d\n", ret);
    }

    return ret;
}

static VdpStatus _vdp_cap_presentation_queue_target_create_x11(
    VdpDevice                    device,
    Drawable                     drawable,
    /* output parameters follow */
    VdpPresentationQueueTarget * target
)
{
    VdpStatus ret;

    fprintf(_vdp_cap_data.fp, "vdp_presentation_queue_target_create_x11(");
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %lu, %s",
            device,
            drawable,
            target ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    ret = _vdp_cap_data.vdp_presentation_queue_target_create_x11(
        device,
        drawable,
        target
    );

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
Aaron Plattner's avatar
Aaron Plattner committed
4818
4819
4820
4821
4822
4823
            if (target) {
                fprintf(_vdp_cap_data.fp, ", %u", *target);
            }
            else {
                fputs(", ???", _vdp_cap_data.fp);
            }
Aaron Plattner's avatar
Aaron Plattner committed
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

static VdpStatus _vdp_cap_get_proc_address(
    VdpDevice device,
    VdpFuncId function_id,
    /* output parameters follow */
    void * *  function_pointer
)
{
    VdpStatus ret;

    fputs("vdp_get_proc_address(", _vdp_cap_data.fp);
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
            "%u, %u, %s",
            device,
            function_id,
            function_pointer ? "-" : "NULL"
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    if (device != _vdp_cap_data.vdp_device) {
        _VDP_TRACE_ERROR_BREAKPOINT();
        ret =  VDP_STATUS_ERROR;
    }
    else if (!function_pointer) {
        _VDP_TRACE_ERROR_BREAKPOINT();
        ret =  VDP_STATUS_ERROR;
    }
    else {
        ret = VDP_STATUS_OK;
Aaron Plattner's avatar
Aaron Plattner committed
4862
        *function_pointer = 0;
Aaron Plattner's avatar
Aaron Plattner committed
4863
4864
4865

        switch (function_id) {
        case VDP_FUNC_ID_GET_ERROR_STRING:
Aaron Plattner's avatar
Aaron Plattner committed
4866
4867
4868
            if (_vdp_cap_data.vdp_get_error_string) {
                *function_pointer = (void *)&_vdp_cap_get_error_string;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4869
4870
            break;
        case VDP_FUNC_ID_GET_PROC_ADDRESS:
Aaron Plattner's avatar
Aaron Plattner committed
4871
4872
4873
            if (_vdp_cap_data.vdp_get_proc_address) {
                *function_pointer = (void *)&_vdp_cap_get_proc_address;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4874
4875
            break;
        case VDP_FUNC_ID_GET_API_VERSION:
Aaron Plattner's avatar
Aaron Plattner committed
4876
4877
4878
            if (_vdp_cap_data.vdp_get_api_version) {
                *function_pointer = (void *)&_vdp_cap_get_api_version;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4879
4880
            break;
        case VDP_FUNC_ID_GET_INFORMATION_STRING:
Aaron Plattner's avatar
Aaron Plattner committed
4881
4882
4883
            if (_vdp_cap_data.vdp_get_information_string) {
                *function_pointer = (void *)&_vdp_cap_get_information_string;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4884
4885
            break;
        case VDP_FUNC_ID_DEVICE_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
4886
4887
4888
            if (_vdp_cap_data.vdp_device_destroy) {
                *function_pointer = (void *)&_vdp_cap_device_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4889
4890
            break;
        case VDP_FUNC_ID_GENERATE_CSC_MATRIX:
Aaron Plattner's avatar
Aaron Plattner committed
4891
4892
4893
            if (_vdp_cap_data.vdp_generate_csc_matrix) {
                *function_pointer = (void *)&_vdp_cap_generate_csc_matrix;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4894
4895
            break;
        case VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
4896
4897
4898
            if (_vdp_cap_data.vdp_video_surface_query_capabilities) {
                *function_pointer = (void *)&_vdp_cap_video_surface_query_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4899
4900
            break;
        case VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
4901
4902
4903
            if (_vdp_cap_data.vdp_video_surface_query_get_put_bits_y_cb_cr_capabilities) {
                *function_pointer = (void *)&_vdp_cap_video_surface_query_get_put_bits_y_cb_cr_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4904
4905
            break;
        case VDP_FUNC_ID_VIDEO_SURFACE_CREATE:
Aaron Plattner's avatar
Aaron Plattner committed
4906
4907
4908
            if (_vdp_cap_data.vdp_video_surface_create) {
                *function_pointer = (void *)&_vdp_cap_video_surface_create;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4909
4910
            break;
        case VDP_FUNC_ID_VIDEO_SURFACE_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
4911
4912
4913
            if (_vdp_cap_data.vdp_video_surface_destroy) {
                *function_pointer = (void *)&_vdp_cap_video_surface_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4914
4915
            break;
        case VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS:
Aaron Plattner's avatar
Aaron Plattner committed
4916
4917
4918
            if (_vdp_cap_data.vdp_video_surface_get_parameters) {
                *function_pointer = (void *)&_vdp_cap_video_surface_get_parameters;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4919
4920
            break;
        case VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR:
Aaron Plattner's avatar
Aaron Plattner committed
4921
4922
4923
            if (_vdp_cap_data.vdp_video_surface_get_bits_y_cb_cr) {
                *function_pointer = (void *)&_vdp_cap_video_surface_get_bits_y_cb_cr;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4924
4925
            break;
        case VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR:
Aaron Plattner's avatar
Aaron Plattner committed
4926
4927
4928
            if (_vdp_cap_data.vdp_video_surface_put_bits_y_cb_cr) {
                *function_pointer = (void *)&_vdp_cap_video_surface_put_bits_y_cb_cr;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4929
4930
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
4931
4932
4933
            if (_vdp_cap_data.vdp_output_surface_query_capabilities) {
                *function_pointer = (void *)&_vdp_cap_output_surface_query_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4934
4935
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
4936
4937
4938
            if (_vdp_cap_data.vdp_output_surface_query_get_put_bits_native_capabilities) {
                *function_pointer = (void *)&_vdp_cap_output_surface_query_get_put_bits_native_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4939
4940
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
4941
4942
4943
            if (_vdp_cap_data.vdp_output_surface_query_put_bits_indexed_capabilities) {
                *function_pointer = (void *)&_vdp_cap_output_surface_query_put_bits_indexed_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4944
4945
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
4946
4947
4948
            if (_vdp_cap_data.vdp_output_surface_query_put_bits_y_cb_cr_capabilities) {
                *function_pointer = (void *)&_vdp_cap_output_surface_query_put_bits_y_cb_cr_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4949
4950
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_CREATE:
Aaron Plattner's avatar
Aaron Plattner committed
4951
4952
4953
            if (_vdp_cap_data.vdp_output_surface_create) {
                *function_pointer = (void *)&_vdp_cap_output_surface_create;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4954
4955
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
4956
4957
4958
            if (_vdp_cap_data.vdp_output_surface_destroy) {
                *function_pointer = (void *)&_vdp_cap_output_surface_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4959
4960
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS:
Aaron Plattner's avatar
Aaron Plattner committed
4961
4962
4963
            if (_vdp_cap_data.vdp_output_surface_get_parameters) {
                *function_pointer = (void *)&_vdp_cap_output_surface_get_parameters;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4964
4965
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE:
Aaron Plattner's avatar
Aaron Plattner committed
4966
4967
4968
            if (_vdp_cap_data.vdp_output_surface_get_bits_native) {
                *function_pointer = (void *)&_vdp_cap_output_surface_get_bits_native;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4969
4970
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE:
Aaron Plattner's avatar
Aaron Plattner committed
4971
4972
4973
            if (_vdp_cap_data.vdp_output_surface_put_bits_native) {
                *function_pointer = (void *)&_vdp_cap_output_surface_put_bits_native;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4974
4975
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED:
Aaron Plattner's avatar
Aaron Plattner committed
4976
4977
4978
            if (_vdp_cap_data.vdp_output_surface_put_bits_indexed) {
                *function_pointer = (void *)&_vdp_cap_output_surface_put_bits_indexed;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4979
4980
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR:
Aaron Plattner's avatar
Aaron Plattner committed
4981
4982
4983
            if (_vdp_cap_data.vdp_output_surface_put_bits_y_cb_cr) {
                *function_pointer = (void *)&_vdp_cap_output_surface_put_bits_y_cb_cr;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4984
4985
            break;
        case VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
4986
4987
4988
            if (_vdp_cap_data.vdp_bitmap_surface_query_capabilities) {
                *function_pointer = (void *)&_vdp_cap_bitmap_surface_query_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4989
4990
            break;
        case VDP_FUNC_ID_BITMAP_SURFACE_CREATE:
Aaron Plattner's avatar
Aaron Plattner committed
4991
4992
4993
            if (_vdp_cap_data.vdp_bitmap_surface_create) {
                *function_pointer = (void *)&_vdp_cap_bitmap_surface_create;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4994
4995
            break;
        case VDP_FUNC_ID_BITMAP_SURFACE_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
4996
4997
4998
            if (_vdp_cap_data.vdp_bitmap_surface_destroy) {
                *function_pointer = (void *)&_vdp_cap_bitmap_surface_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
4999
5000
            break;
        case VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS:
Aaron Plattner's avatar
Aaron Plattner committed
5001
5002
5003
            if (_vdp_cap_data.vdp_bitmap_surface_get_parameters) {
                *function_pointer = (void *)&_vdp_cap_bitmap_surface_get_parameters;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5004
5005
            break;
        case VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE:
Aaron Plattner's avatar
Aaron Plattner committed
5006
5007
5008
            if (_vdp_cap_data.vdp_bitmap_surface_put_bits_native) {
                *function_pointer = (void *)&_vdp_cap_bitmap_surface_put_bits_native;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5009
5010
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE:
Aaron Plattner's avatar
Aaron Plattner committed
5011
5012
5013
            if (_vdp_cap_data.vdp_output_surface_render_output_surface) {
                *function_pointer = (void *)&_vdp_cap_output_surface_render_output_surface;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5014
5015
            break;
        case VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE:
Aaron Plattner's avatar
Aaron Plattner committed
5016
5017
5018
            if (_vdp_cap_data.vdp_output_surface_render_bitmap_surface) {
                *function_pointer = (void *)&_vdp_cap_output_surface_render_bitmap_surface;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5019
5020
            break;
        case VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES:
Aaron Plattner's avatar
Aaron Plattner committed
5021
5022
5023
            if (_vdp_cap_data.vdp_decoder_query_capabilities) {
                *function_pointer = (void *)&_vdp_cap_decoder_query_capabilities;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5024
5025
            break;
        case VDP_FUNC_ID_DECODER_CREATE:
Aaron Plattner's avatar
Aaron Plattner committed
5026
5027
5028
            if (_vdp_cap_data.vdp_decoder_create) {
                *function_pointer = (void *)&_vdp_cap_decoder_create;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5029
5030
            break;
        case VDP_FUNC_ID_DECODER_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
5031
5032
5033
            if (_vdp_cap_data.vdp_decoder_destroy) {
                *function_pointer = (void *)&_vdp_cap_decoder_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5034
5035
            break;
        case VDP_FUNC_ID_DECODER_GET_PARAMETERS:
Aaron Plattner's avatar
Aaron Plattner committed
5036
5037
5038
            if (_vdp_cap_data.vdp_decoder_get_parameters) {
                *function_pointer = (void *)&_vdp_cap_decoder_get_parameters;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5039
5040
            break;
        case VDP_FUNC_ID_DECODER_RENDER:
Aaron Plattner's avatar
Aaron Plattner committed
5041
5042
5043
            if (_vdp_cap_data.vdp_decoder_render) {
                *function_pointer = (void *)&_vdp_cap_decoder_render;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5044
5045
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT:
Aaron Plattner's avatar
Aaron Plattner committed
5046
5047
5048
            if (_vdp_cap_data.vdp_video_mixer_query_feature_support) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_query_feature_support;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5049
5050
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT:
Aaron Plattner's avatar
Aaron Plattner committed
5051
5052
5053
            if (_vdp_cap_data.vdp_video_mixer_query_parameter_support) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_query_parameter_support;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5054
5055
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT:
Aaron Plattner's avatar
Aaron Plattner committed
5056
5057
5058
            if (_vdp_cap_data.vdp_video_mixer_query_attribute_support) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_query_attribute_support;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5059
5060
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE:
Aaron Plattner's avatar
Aaron Plattner committed
5061
5062
5063
            if (_vdp_cap_data.vdp_video_mixer_query_parameter_value_range) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_query_parameter_value_range;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5064
5065
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE:
Aaron Plattner's avatar
Aaron Plattner committed
5066
5067
5068
            if (_vdp_cap_data.vdp_video_mixer_query_attribute_value_range) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_query_attribute_value_range;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5069
5070
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_CREATE:
Aaron Plattner's avatar
Aaron Plattner committed
5071
5072
5073
            if (_vdp_cap_data.vdp_video_mixer_create) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_create;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5074
5075
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES:
Aaron Plattner's avatar
Aaron Plattner committed
5076
5077
5078
            if (_vdp_cap_data.vdp_video_mixer_set_feature_enables) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_set_feature_enables;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5079
5080
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES:
Aaron Plattner's avatar
Aaron Plattner committed
5081
5082
5083
            if (_vdp_cap_data.vdp_video_mixer_set_attribute_values) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_set_attribute_values;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5084
5085
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT:
Aaron Plattner's avatar
Aaron Plattner committed
5086
5087
5088
            if (_vdp_cap_data.vdp_video_mixer_get_feature_support) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_get_feature_support;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5089
5090
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES:
Aaron Plattner's avatar
Aaron Plattner committed
5091
5092
5093
            if (_vdp_cap_data.vdp_video_mixer_get_feature_enables) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_get_feature_enables;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5094
5095
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES:
Aaron Plattner's avatar
Aaron Plattner committed
5096
5097
5098
            if (_vdp_cap_data.vdp_video_mixer_get_parameter_values) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_get_parameter_values;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5099
5100
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES:
Aaron Plattner's avatar
Aaron Plattner committed
5101
5102
5103
            if (_vdp_cap_data.vdp_video_mixer_get_attribute_values) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_get_attribute_values;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5104
5105
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
5106
5107
5108
            if (_vdp_cap_data.vdp_video_mixer_destroy) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5109
5110
            break;
        case VDP_FUNC_ID_VIDEO_MIXER_RENDER:
Aaron Plattner's avatar
Aaron Plattner committed
5111
5112
5113
            if (_vdp_cap_data.vdp_video_mixer_render) {
                *function_pointer = (void *)&_vdp_cap_video_mixer_render;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5114
5115
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
5116
5117
5118
            if (_vdp_cap_data.vdp_presentation_queue_target_destroy) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_target_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5119
5120
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE:
Aaron Plattner's avatar
Aaron Plattner committed
5121
5122
5123
            if (_vdp_cap_data.vdp_presentation_queue_create) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_create;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5124
5125
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY:
Aaron Plattner's avatar
Aaron Plattner committed
5126
5127
5128
            if (_vdp_cap_data.vdp_presentation_queue_destroy) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_destroy;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5129
5130
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR:
Aaron Plattner's avatar
Aaron Plattner committed
5131
5132
5133
            if (_vdp_cap_data.vdp_presentation_queue_set_background_color) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_set_background_color;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5134
5135
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR:
Aaron Plattner's avatar
Aaron Plattner committed
5136
5137
5138
            if (_vdp_cap_data.vdp_presentation_queue_get_background_color) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_get_background_color;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5139
5140
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME:
Aaron Plattner's avatar
Aaron Plattner committed
5141
5142
5143
            if (_vdp_cap_data.vdp_presentation_queue_get_time) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_get_time;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5144
5145
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY:
Aaron Plattner's avatar
Aaron Plattner committed
5146
5147
5148
            if (_vdp_cap_data.vdp_presentation_queue_display) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_display;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5149
5150
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE:
Aaron Plattner's avatar
Aaron Plattner committed
5151
5152
5153
            if (_vdp_cap_data.vdp_presentation_queue_block_until_surface_idle) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_block_until_surface_idle;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5154
5155
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS:
Aaron Plattner's avatar
Aaron Plattner committed
5156
5157
5158
            if (_vdp_cap_data.vdp_presentation_queue_query_surface_status) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_query_surface_status;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5159
5160
            break;
        case VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER:
Aaron Plattner's avatar
Aaron Plattner committed
5161
5162
5163
            if (_vdp_cap_data.vdp_preemption_callback_register) {
                *function_pointer = (void *)&_vdp_cap_preemption_callback_register;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5164
5165
            break;
        case VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11:
Aaron Plattner's avatar
Aaron Plattner committed
5166
5167
5168
            if (_vdp_cap_data.vdp_presentation_queue_target_create_x11) {
                *function_pointer = (void *)&_vdp_cap_presentation_queue_target_create_x11;
            }
Aaron Plattner's avatar
Aaron Plattner committed
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
            break;
        default:
            fprintf(
                _vdp_cap_data.fp,
                "VDPAU capture: Not able to proxy function %d",
                function_id
            );
            ret = _vdp_cap_data.vdp_get_proc_address(device, function_id, function_pointer);
            break;
        }

        if ((ret == VDP_STATUS_OK) && !*function_pointer) {
            ret = VDP_STATUS_INVALID_FUNC_ID;
        }
    }

    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", ret);
        if (ret == VDP_STATUS_OK) {
            fprintf(
                _vdp_cap_data.fp,
                ", %p",
                *function_pointer
            );
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return ret;
}

extern "C" void vdp_trace_set_backend_handle(
    void * driver_dll_handle
)
{
    _vdp_cap_data.dll = driver_dll_handle;
}

extern "C" VdpDeviceCreateX11 vdp_trace_device_create_x11;

VdpStatus vdp_trace_device_create_x11(
    Display *             display,
    int                   screen,
    /* output parameters follow */
    VdpDevice *           device,
    VdpGetProcAddress * * get_proc_address
)
{
    if (!device || !get_proc_address) {
        _VDP_TRACE_ERROR_BREAKPOINT();
        return VDP_STATUS_INVALID_POINTER;
    }

    // For now, the capture library only allows a single VdpDevice
    // This could probably be fixed by dynamically associating most of
    // _vdp_cap_data with a VdpDevice handle.
    if (_vdp_cap_data.fp) {
        fprintf(_vdp_cap_data.fp,
            "VDPAU trace: Multiple devices created; "
            "will return get_proc_address results from the latest only\n"
        );
    }
    else {
        _vdp_cap_data.level = 0;
5233
        char const * vdpau_trace = secure_getenv("VDPAU_TRACE");
Aaron Plattner's avatar
Aaron Plattner committed
5234
5235
5236
5237
5238
        if (vdpau_trace) {
            _vdp_cap_data.level = atoi(vdpau_trace);
        }

        _vdp_cap_data.fp = 0;
5239
        char const * vdpau_trace_file = secure_getenv("VDPAU_TRACE_FILE");
Aaron Plattner's avatar
Aaron Plattner committed
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
        if (vdpau_trace_file && strlen(vdpau_trace_file)) {
            if (vdpau_trace_file[0] == '&') {
                int fd = atoi(&vdpau_trace_file[1]);
                _vdp_cap_data.fp = fdopen(fd, "wt");
            }
            else {
                _vdp_cap_data.fp = fopen(vdpau_trace_file, "wt");
            }
            if (!_vdp_cap_data.fp) {
                fprintf(
                    stderr,
                    "VDPAU capture: ERROR: Can't open '%s' for writing, defaulting to stderr\n",
                    vdpau_trace_file
                );
            }
        }
        if (!_vdp_cap_data.fp) {
            _vdp_cap_data.fp = stderr;
        }
        fprintf(_vdp_cap_data.fp, "VDPAU capture: Enabled\n");
    }

    fprintf(_vdp_cap_data.fp, "vdp_imp_device_create_x11(");
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(
            _vdp_cap_data.fp,
5266
            "%p, %d, -, -",
Aaron Plattner's avatar
Aaron Plattner committed
5267
            display,
5268
            screen
Aaron Plattner's avatar
Aaron Plattner committed
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
        );
    }
    fputs(")\n", _vdp_cap_data.fp);

    VdpStatus vdp_st = VDP_STATUS_ERROR;

    VdpDeviceCreateX11 * vdp_imp_device_create_x11;
    vdp_imp_device_create_x11 = (VdpDeviceCreateX11*)dlsym(
        _vdp_cap_data.dll,
         "vdp_imp_device_create_x11"
    );
    if (!vdp_imp_device_create_x11) {
        _VDP_TRACE_ERROR_BREAKPOINT();
        vdp_st = VDP_STATUS_NO_IMPLEMENTATION;
        goto done;
    }

    vdp_st = vdp_imp_device_create_x11(
        display,
        screen,
        &_vdp_cap_data.vdp_device,
        &_vdp_cap_data.vdp_get_proc_address
    );
    if (vdp_st != VDP_STATUS_OK) {
        _VDP_TRACE_ERROR_BREAKPOINT();
        goto done;
    }

    *device = _vdp_cap_data.vdp_device;
    *get_proc_address = _vdp_cap_get_proc_address;

#define GET_POINTER(_id_, _var_) \
    vdp_st = _vdp_cap_data.vdp_get_proc_address( \
        _vdp_cap_data.vdp_device, \
        (_id_), \
        (void * *)&_vdp_cap_data._var_ \
    ); \
    if (vdp_st != VDP_STATUS_OK) { \
        _vdp_cap_data._var_ = 0; \
    }

    GET_POINTER(VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER,                          vdp_preemption_callback_register);
    GET_POINTER(VDP_FUNC_ID_GET_ERROR_STRING,                                      vdp_get_error_string);
    GET_POINTER(VDP_FUNC_ID_GET_API_VERSION,                                       vdp_get_api_version);
    GET_POINTER(VDP_FUNC_ID_GET_INFORMATION_STRING,                                vdp_get_information_string);
    GET_POINTER(VDP_FUNC_ID_DEVICE_DESTROY,                                        vdp_device_destroy);
    GET_POINTER(VDP_FUNC_ID_GENERATE_CSC_MATRIX,                                   vdp_generate_csc_matrix);
    GET_POINTER(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,                      vdp_video_surface_query_capabilities);
    GET_POINTER(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES, vdp_video_surface_query_get_put_bits_y_cb_cr_capabilities);
    GET_POINTER(VDP_FUNC_ID_VIDEO_SURFACE_CREATE,                                  vdp_video_surface_create);
    GET_POINTER(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY,                                 vdp_video_surface_destroy);
    GET_POINTER(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS,                          vdp_video_surface_get_parameters);
    GET_POINTER(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR,                        vdp_video_surface_get_bits_y_cb_cr);
    GET_POINTER(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR,                        vdp_video_surface_put_bits_y_cb_cr);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES,                     vdp_output_surface_query_capabilities);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES, vdp_output_surface_query_get_put_bits_native_capabilities);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES,    vdp_output_surface_query_put_bits_indexed_capabilities);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES,    vdp_output_surface_query_put_bits_y_cb_cr_capabilities);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE,                                 vdp_output_surface_create);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY,                                vdp_output_surface_destroy);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS,                         vdp_output_surface_get_parameters);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE,                        vdp_output_surface_get_bits_native);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE,                        vdp_output_surface_put_bits_native);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED,                       vdp_output_surface_put_bits_indexed);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR,                       vdp_output_surface_put_bits_y_cb_cr);
    GET_POINTER(VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES,                     vdp_bitmap_surface_query_capabilities);
    GET_POINTER(VDP_FUNC_ID_BITMAP_SURFACE_CREATE,                                 vdp_bitmap_surface_create);
    GET_POINTER(VDP_FUNC_ID_BITMAP_SURFACE_DESTROY,                                vdp_bitmap_surface_destroy);
    GET_POINTER(VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS,                         vdp_bitmap_surface_get_parameters);
    GET_POINTER(VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE,                        vdp_bitmap_surface_put_bits_native);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE,                  vdp_output_surface_render_output_surface);
    GET_POINTER(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE,                  vdp_output_surface_render_bitmap_surface);
    GET_POINTER(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,                            vdp_decoder_query_capabilities);
    GET_POINTER(VDP_FUNC_ID_DECODER_CREATE,                                        vdp_decoder_create);
    GET_POINTER(VDP_FUNC_ID_DECODER_DESTROY,                                       vdp_decoder_destroy);
    GET_POINTER(VDP_FUNC_ID_DECODER_GET_PARAMETERS,                                vdp_decoder_get_parameters);
    GET_POINTER(VDP_FUNC_ID_DECODER_RENDER,                                        vdp_decoder_render);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT,                     vdp_video_mixer_query_feature_support);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT,                   vdp_video_mixer_query_parameter_support);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT,                   vdp_video_mixer_query_attribute_support);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE,               vdp_video_mixer_query_parameter_value_range);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE,               vdp_video_mixer_query_attribute_value_range);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_CREATE,                                    vdp_video_mixer_create);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES,                       vdp_video_mixer_set_feature_enables);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES,                      vdp_video_mixer_set_attribute_values);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT,                       vdp_video_mixer_get_feature_support);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES,                       vdp_video_mixer_get_feature_enables);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES,                      vdp_video_mixer_get_parameter_values);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES,                      vdp_video_mixer_get_attribute_values);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_DESTROY,                                   vdp_video_mixer_destroy);
    GET_POINTER(VDP_FUNC_ID_VIDEO_MIXER_RENDER,                                    vdp_video_mixer_render);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY,                     vdp_presentation_queue_target_destroy);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE,                             vdp_presentation_queue_create);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY,                            vdp_presentation_queue_destroy);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR,               vdp_presentation_queue_set_background_color);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR,               vdp_presentation_queue_get_background_color);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME,                           vdp_presentation_queue_get_time);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY,                            vdp_presentation_queue_display);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE,           vdp_presentation_queue_block_until_surface_idle);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS,               vdp_presentation_queue_query_surface_status);
    GET_POINTER(VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER,                          vdp_preemption_callback_register);
    GET_POINTER(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11,                  vdp_presentation_queue_target_create_x11);

    vdp_st = VDP_STATUS_OK;

done:
    if (_vdp_cap_data.level >= LEVEL_PARAMS) {
        fprintf(_vdp_cap_data.fp, "    -> %d", vdp_st);
        if (vdp_st == VDP_STATUS_OK) {
            fprintf(
                _vdp_cap_data.fp,
                ", %x, %p",
                _vdp_cap_data.vdp_device,
                _vdp_cap_data.vdp_get_proc_address
            );
        }
        fputs("\n", _vdp_cap_data.fp);
    }

    return vdp_st;
}