1/* 2 * Copyright © 2008 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 * 23 * Authors: 24 * Zhenyu Wang <zhenyu.z.wang@intel.com> 25 * 26 */ 27#include "intel_xvmc_private.h" 28 29#define DUMPFILE "./intel_xvmc_dump" 30 31static int xvmc_dump = 0; 32static FILE *fp = NULL; 33 34void intel_xvmc_dump_open(void) 35{ 36 char *d = NULL; 37 38 if (xvmc_dump) 39 return; 40 41 if ((d = getenv("INTEL_XVMC_DUMP"))) 42 xvmc_dump = 1; 43 44 if (xvmc_dump) { 45 fp = fopen(DUMPFILE, "a"); 46 if (!fp) 47 xvmc_dump = 0; 48 } 49} 50 51void intel_xvmc_dump_close(void) 52{ 53 if (xvmc_dump) { 54 fclose(fp); 55 xvmc_dump = 0; 56 } 57} 58 59void intel_xvmc_dump_render(XvMCContext * context, 60 unsigned int picture_structure, 61 XvMCSurface * target, XvMCSurface * past, 62 XvMCSurface * future, unsigned int flags, 63 unsigned int num_macroblocks, 64 unsigned int first_macroblock, 65 XvMCMacroBlockArray * macroblock_array, 66 XvMCBlockArray * blocks) 67{ 68 int i; 69 XvMCMacroBlock *mb; 70 71 if (!xvmc_dump) 72 return; 73 74 fprintf(fp, "========== new surface rendering ==========\n"); 75 fprintf(fp, 76 "Context (id:%d) (surface_type_id:%d) (width:%d) (height:%d)\n", 77 (int)context->context_id, context->surface_type_id, 78 context->width, context->height); 79 80 if (picture_structure == XVMC_FRAME_PICTURE) 81 fprintf(fp, "picture structure: frame picture\n"); 82 else if (picture_structure == XVMC_TOP_FIELD) 83 fprintf(fp, "picture structure: top field picture (%s)\n", 84 (flags == XVMC_SECOND_FIELD) ? "second" : "first"); 85 else if (picture_structure == XVMC_BOTTOM_FIELD) 86 fprintf(fp, "picture structure: bottom field picture (%s)\n", 87 (flags == XVMC_SECOND_FIELD) ? "second" : "first"); 88 89 if (!past && !future) 90 fprintf(fp, "picture type: I\n"); 91 else if (past && !future) 92 fprintf(fp, "picture type: P\n"); 93 else if (past && future) 94 fprintf(fp, "picture type: B\n"); 95 else 96 fprintf(fp, "picture type: Bad!\n"); 97 98 fprintf(fp, "target picture: id (%d) width (%d) height (%d)\n", 99 (int)target->surface_id, target->width, target->height); 100 if (past) 101 fprintf(fp, "past picture: id (%d) width (%d) height (%d)\n", 102 (int)past->surface_id, past->width, past->height); 103 if (future) 104 fprintf(fp, "future picture: id (%d) width (%d) height (%d)\n", 105 (int)future->surface_id, future->width, future->height); 106 107 fprintf(fp, "num macroblocks: %d, first macroblocks %d\n", 108 num_macroblocks, first_macroblock); 109 110 for (i = first_macroblock; i < (first_macroblock + num_macroblocks); 111 i++) { 112 mb = ¯oblock_array->macro_blocks[i]; 113 114 fprintf(fp, "- MB(%d): ", i); 115 fprintf(fp, "x (%d) y (%d) ", mb->x, mb->y); 116 fprintf(fp, "macroblock type ("); 117 if (mb->macroblock_type & XVMC_MB_TYPE_MOTION_FORWARD) 118 fprintf(fp, "motion_forward "); 119 if (mb->macroblock_type & XVMC_MB_TYPE_MOTION_BACKWARD) 120 fprintf(fp, "motion_backward "); 121 if (mb->macroblock_type & XVMC_MB_TYPE_PATTERN) 122 fprintf(fp, "pattern "); 123 if (mb->macroblock_type & XVMC_MB_TYPE_INTRA) 124 fprintf(fp, "intra "); 125 fprintf(fp, ") "); 126 fprintf(fp, "mc type "); 127 if (picture_structure == XVMC_FRAME_PICTURE) { 128 if (mb->motion_type & XVMC_PREDICTION_FIELD) 129 fprintf(fp, "(field) "); 130 else if (mb->motion_type & XVMC_PREDICTION_FRAME) 131 fprintf(fp, "(frame) "); 132 else if (mb->motion_type & XVMC_PREDICTION_DUAL_PRIME) 133 fprintf(fp, "(dual-prime) "); 134 else 135 fprintf(fp, "(unknown %d) ", mb->motion_type); 136 } else { /* field */ 137 if (mb->motion_type & XVMC_PREDICTION_FIELD) 138 fprintf(fp, "(field) "); 139 else if (mb->motion_type & XVMC_PREDICTION_DUAL_PRIME) 140 fprintf(fp, "(dual-prime) "); 141 else if (mb->motion_type & XVMC_PREDICTION_16x8) 142 fprintf(fp, "(16x8) "); 143 else 144 fprintf(fp, "(unknown %d) ", mb->motion_type); 145 } 146 147 if (mb->dct_type == XVMC_DCT_TYPE_FRAME) 148 fprintf(fp, "dct type (frame) "); 149 else if (mb->dct_type == XVMC_DCT_TYPE_FIELD) 150 fprintf(fp, "dct type (field) "); 151 152 fprintf(fp, "coded_block_pattern (0x%x)\n", 153 mb->coded_block_pattern); 154 155 /* XXX mv dump */ 156 } 157 158} 159