~ubuntu-branches/ubuntu/trusty/vdpau-video/trusty-proposed

« back to all changes in this revision

Viewing changes to src/vdpau_dump.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2010-02-12 14:58:28 UTC
  • Revision ID: james.westby@ubuntu.com-20100212145828-f0q1g7qzq03din26
Tags: upstream-0.6.3
ImportĀ upstreamĀ versionĀ 0.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  vdpau_dump.c - Dump utilities
 
3
 *
 
4
 *  vdpau-video (C) 2009-2010 Splitted-Desktop Systems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
19
 */
 
20
 
 
21
#include "sysdeps.h"
 
22
#include "vdpau_dump.h"
 
23
 
 
24
#define DEBUG 1
 
25
#include "debug.h"
 
26
 
 
27
 
 
28
// Returns string representation of FOURCC
 
29
const char *string_of_FOURCC(uint32_t fourcc)
 
30
{
 
31
    static char str[5];
 
32
    str[0] = fourcc;
 
33
    str[1] = fourcc >> 8;
 
34
    str[2] = fourcc >> 16;
 
35
    str[3] = fourcc >> 24;
 
36
    str[4] = '\0';
 
37
    return str;
 
38
}
 
39
 
 
40
// Returns string representation of VABufferType
 
41
const char *string_of_VABufferType(VABufferType type)
 
42
{
 
43
    const char *str = NULL;
 
44
    switch (type) {
 
45
#define _(X) case X: str = #X; break
 
46
        _(VAPictureParameterBufferType);
 
47
        _(VAIQMatrixBufferType);
 
48
        _(VABitPlaneBufferType);
 
49
        _(VASliceGroupMapBufferType);
 
50
        _(VASliceParameterBufferType);
 
51
        _(VASliceDataBufferType);
 
52
        _(VAMacroblockParameterBufferType);
 
53
        _(VAResidualDataBufferType);
 
54
        _(VADeblockingParameterBufferType);
 
55
        _(VAImageBufferType);
 
56
#if VA_CHECK_VERSION(0,30,0)
 
57
        _(VAProtectedSliceDataBufferType);
 
58
        _(VAEncCodedBufferType);
 
59
        _(VAEncSequenceParameterBufferType);
 
60
        _(VAEncPictureParameterBufferType);
 
61
        _(VAEncSliceParameterBufferType);
 
62
        _(VAEncH264VUIBufferType);
 
63
        _(VAEncH264SEIBufferType);
 
64
#endif
 
65
#undef _
 
66
    }
 
67
    return str;
 
68
}
 
69
 
 
70
// Returns string representation of VdpCodec
 
71
const char *string_of_VdpCodec(VdpCodec codec)
 
72
{
 
73
    const char *str = NULL;
 
74
    switch (codec) {
 
75
#define _(X) case VDP_CODEC_##X: str = #X; break
 
76
        _(MPEG1);
 
77
        _(MPEG2);
 
78
        _(MPEG4);
 
79
        _(H264);
 
80
        _(VC1);
 
81
#undef _
 
82
    }
 
83
    return str;
 
84
}
 
85
 
 
86
#if USE_TRACER
 
87
#define TRACE               trace_print
 
88
#define INDENT(INC)         trace_indent(INC)
 
89
#define DUMPi(S, M)         TRACE("." #M " = %d,\n", S->M)
 
90
#define DUMPx(S, M)         TRACE("." #M " = 0x%08x,\n", S->M)
 
91
#define DUMPp(S, M)         TRACE("." #M " = %p,\n", S->M)
 
92
#define DUMPm(S, M, I, J)   dump_matrix_NxM(#M, (uint8_t *)S->M, I, J, I * J)
 
93
#else
 
94
#define trace_enabled()     (0)
 
95
#define do_nothing()        do { } while (0)
 
96
#define TRACE(FORMAT,...)   do_nothing()
 
97
#define INDENT(INC)         do_nothing()
 
98
#define DUMPi(S, M)         do_nothing()
 
99
#define DUMPx(S, M)         do_nothing()
 
100
#define DUMPp(S, M)         do_nothing()
 
101
#define DUMPm(S, M, I, J)   do_nothing()
 
102
#endif
 
103
 
 
104
// Dumps matrix[N][M] = N rows x M columns (uint8_t)
 
105
static void
 
106
dump_matrix_NxM(const char *label, uint8_t *matrix, int N, int M, int L)
 
107
{
 
108
    int i, j, n = 0;
 
109
 
 
110
    TRACE(".%s = {\n", label);
 
111
    INDENT(1);
 
112
    for (j = 0; j < N; j++) {
 
113
        for (i = 0; i < M; i++, n++) {
 
114
            if (n >= L)
 
115
                break;
 
116
            if (i > 0)
 
117
                TRACE(", ");
 
118
            TRACE("0x%02x", matrix[n]);
 
119
        }
 
120
        if (j < (N - 1))
 
121
            TRACE(",");
 
122
        TRACE("\n");
 
123
        if (n >= L)
 
124
            break;
 
125
    }
 
126
    INDENT(-1);
 
127
    TRACE("}\n");
 
128
}
 
129
 
 
130
// Dumps VdpPictureInfoMPEG1Or2
 
131
void dump_VdpPictureInfoMPEG1Or2(VdpPictureInfoMPEG1Or2 *pic_info)
 
132
{
 
133
    INDENT(1);
 
134
    TRACE("VdpPictureInfoMPEG1Or2 = {\n");
 
135
    INDENT(1);
 
136
    DUMPx(pic_info, forward_reference);
 
137
    DUMPx(pic_info, backward_reference);
 
138
    DUMPi(pic_info, slice_count);
 
139
    DUMPi(pic_info, picture_structure);
 
140
    DUMPi(pic_info, picture_coding_type);
 
141
    DUMPi(pic_info, intra_dc_precision);
 
142
    DUMPi(pic_info, frame_pred_frame_dct);
 
143
    DUMPi(pic_info, concealment_motion_vectors);
 
144
    DUMPi(pic_info, intra_vlc_format);
 
145
    DUMPi(pic_info, alternate_scan);
 
146
    DUMPi(pic_info, q_scale_type);
 
147
    DUMPi(pic_info, top_field_first);
 
148
    DUMPi(pic_info, full_pel_forward_vector);
 
149
    DUMPi(pic_info, full_pel_backward_vector);
 
150
    TRACE(".f_code = { { %d, %d }, { %d, %d } };\n",
 
151
          pic_info->f_code[0][0], pic_info->f_code[0][1],
 
152
          pic_info->f_code[1][0], pic_info->f_code[1][1]);
 
153
    DUMPm(pic_info, intra_quantizer_matrix, 8, 8);
 
154
    DUMPm(pic_info, non_intra_quantizer_matrix, 8, 8);
 
155
    INDENT(-1);
 
156
    TRACE("};\n");
 
157
    INDENT(-1);
 
158
}
 
159
 
 
160
// Dumps VdpPictureInfoMPEG4Part2
 
161
#if HAVE_VDPAU_MPEG4
 
162
void dump_VdpPictureInfoMPEG4Part2(VdpPictureInfoMPEG4Part2 *pic_info)
 
163
{
 
164
    INDENT(1);
 
165
    TRACE("VdpPictureInfoMPEG4Part2 = {\n");
 
166
    INDENT(1);
 
167
    DUMPx(pic_info, forward_reference);
 
168
    DUMPx(pic_info, backward_reference);
 
169
    DUMPi(pic_info, vop_time_increment_resolution);
 
170
    DUMPi(pic_info, vop_coding_type);
 
171
    DUMPi(pic_info, vop_fcode_forward);
 
172
    DUMPi(pic_info, vop_fcode_backward);
 
173
    DUMPi(pic_info, resync_marker_disable);
 
174
    DUMPi(pic_info, interlaced);
 
175
    DUMPi(pic_info, quant_type);
 
176
    DUMPi(pic_info, quarter_sample);
 
177
    DUMPi(pic_info, short_video_header);
 
178
    DUMPi(pic_info, rounding_control);
 
179
    DUMPi(pic_info, alternate_vertical_scan_flag);
 
180
    DUMPi(pic_info, top_field_first);
 
181
    DUMPm(pic_info, intra_quantizer_matrix, 8, 8);
 
182
    DUMPm(pic_info, non_intra_quantizer_matrix, 8, 8);
 
183
    INDENT(-1);
 
184
    TRACE("};\n");
 
185
    INDENT(-1);
 
186
}
 
187
#endif
 
188
 
 
189
// Dumps VdpReferenceFrameH264
 
190
static void
 
191
dump_VdpReferenceFrameH264(VdpReferenceFrameH264 *rf, const char *label)
 
192
{
 
193
    TRACE(".%s = {\n", label);
 
194
    INDENT(1);
 
195
    DUMPx(rf, surface);
 
196
    DUMPi(rf, is_long_term);
 
197
    DUMPi(rf, top_is_reference);
 
198
    DUMPi(rf, bottom_is_reference);
 
199
    DUMPi(rf, field_order_cnt[0]);
 
200
    DUMPi(rf, field_order_cnt[1]);
 
201
    DUMPi(rf, frame_idx);
 
202
    INDENT(-1);
 
203
    TRACE("}\n");
 
204
}
 
205
 
 
206
// Dumps VdpPictureInfoH264
 
207
void dump_VdpPictureInfoH264(VdpPictureInfoH264 *pic_info)
 
208
{
 
209
    int i;
 
210
 
 
211
    INDENT(1);
 
212
    TRACE("VdpPictureInfoH264 = {\n");
 
213
    INDENT(1);
 
214
    DUMPi(pic_info, slice_count);
 
215
    DUMPi(pic_info, field_order_cnt[0]);
 
216
    DUMPi(pic_info, field_order_cnt[1]);
 
217
    DUMPi(pic_info, is_reference);
 
218
    DUMPi(pic_info, frame_num);
 
219
    DUMPi(pic_info, field_pic_flag);
 
220
    DUMPi(pic_info, bottom_field_flag);
 
221
    DUMPi(pic_info, num_ref_frames);
 
222
    DUMPi(pic_info, mb_adaptive_frame_field_flag);
 
223
    DUMPi(pic_info, constrained_intra_pred_flag);
 
224
    DUMPi(pic_info, weighted_pred_flag);
 
225
    DUMPi(pic_info, weighted_bipred_idc);
 
226
    DUMPi(pic_info, frame_mbs_only_flag);
 
227
    DUMPi(pic_info, transform_8x8_mode_flag);
 
228
    DUMPi(pic_info, chroma_qp_index_offset);
 
229
    DUMPi(pic_info, second_chroma_qp_index_offset);
 
230
    DUMPi(pic_info, pic_init_qp_minus26);
 
231
    DUMPi(pic_info, num_ref_idx_l0_active_minus1);
 
232
    DUMPi(pic_info, num_ref_idx_l1_active_minus1);
 
233
    DUMPi(pic_info, log2_max_frame_num_minus4);
 
234
    DUMPi(pic_info, pic_order_cnt_type);
 
235
    DUMPi(pic_info, log2_max_pic_order_cnt_lsb_minus4);
 
236
    DUMPi(pic_info, delta_pic_order_always_zero_flag);
 
237
    DUMPi(pic_info, direct_8x8_inference_flag);
 
238
    DUMPi(pic_info, entropy_coding_mode_flag);
 
239
    DUMPi(pic_info, pic_order_present_flag);
 
240
    DUMPi(pic_info, deblocking_filter_control_present_flag);
 
241
    DUMPi(pic_info, redundant_pic_cnt_present_flag);
 
242
    DUMPm(pic_info, scaling_lists_4x4, 6, 16);
 
243
    DUMPm(pic_info, scaling_lists_8x8[0], 8, 8);
 
244
    DUMPm(pic_info, scaling_lists_8x8[1], 8, 8);
 
245
    for (i = 0; i < 16; i++) {
 
246
        char label[100];
 
247
        sprintf(label, "referenceFrames[%d]", i);
 
248
        dump_VdpReferenceFrameH264(&pic_info->referenceFrames[i], label);
 
249
    }
 
250
    INDENT(-1);
 
251
    TRACE("};\n");
 
252
    INDENT(-1);
 
253
}
 
254
 
 
255
// Dumps VdpPictureInfoVC1
 
256
void dump_VdpPictureInfoVC1(VdpPictureInfoVC1 *pic_info)
 
257
{
 
258
    INDENT(1);
 
259
    TRACE("VdpPictureInfoVC1 = {\n");
 
260
    INDENT(1);
 
261
    DUMPx(pic_info, forward_reference);
 
262
    DUMPx(pic_info, backward_reference);
 
263
    DUMPi(pic_info, slice_count);
 
264
    DUMPi(pic_info, picture_type);
 
265
    DUMPi(pic_info, frame_coding_mode);
 
266
    DUMPi(pic_info, postprocflag);
 
267
    DUMPi(pic_info, pulldown);
 
268
    DUMPi(pic_info, interlace);
 
269
    DUMPi(pic_info, tfcntrflag);
 
270
    DUMPi(pic_info, finterpflag);
 
271
    DUMPi(pic_info, psf);
 
272
    DUMPi(pic_info, dquant);
 
273
    DUMPi(pic_info, panscan_flag);
 
274
    DUMPi(pic_info, refdist_flag);
 
275
    DUMPi(pic_info, quantizer);
 
276
    DUMPi(pic_info, extended_mv);
 
277
    DUMPi(pic_info, extended_dmv);
 
278
    DUMPi(pic_info, overlap);
 
279
    DUMPi(pic_info, vstransform);
 
280
    DUMPi(pic_info, loopfilter);
 
281
    DUMPi(pic_info, fastuvmc);
 
282
    DUMPi(pic_info, range_mapy_flag);
 
283
    DUMPi(pic_info, range_mapy);
 
284
    DUMPi(pic_info, range_mapuv_flag);
 
285
    DUMPi(pic_info, range_mapuv);
 
286
    DUMPi(pic_info, multires);
 
287
    DUMPi(pic_info, syncmarker);
 
288
    DUMPi(pic_info, rangered);
 
289
    DUMPi(pic_info, maxbframes);
 
290
    DUMPi(pic_info, deblockEnable);
 
291
    DUMPi(pic_info, pquant);
 
292
    INDENT(-1);
 
293
    TRACE("};\n");
 
294
    INDENT(-1);
 
295
}
 
296
 
 
297
// Dumps VdpBitstreamBuffer
 
298
void dump_VdpBitstreamBuffer(VdpBitstreamBuffer *bitstream_buffer)
 
299
{
 
300
    const uint8_t *buffer = bitstream_buffer->bitstream;
 
301
    const uint32_t size   = bitstream_buffer->bitstream_bytes;
 
302
 
 
303
    INDENT(1);
 
304
    TRACE("VdpBitstreamBuffer (%d bytes) = {\n", size);
 
305
    INDENT(1);
 
306
    dump_matrix_NxM("buffer", buffer, 10, 15, size);
 
307
    INDENT(-1);
 
308
    TRACE("};\n");
 
309
    INDENT(-1);
 
310
}