<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"> I would like to share two tools that can help debugging libva applications and backend drivers. <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> The first one is a parameter logger which records video frame information (in plain text) send by application. Current implementation logs picture and slice parameters for all supported codec.
<o:p></o:p></p>
<p class="MsoNormal">These information are extremely helpful in narrowing down issues related to video file parsing. Selected libva APIs are instrumented with logging macros which can be controlled via compile and runtime flags.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Excerpt from log file for H264 decode:<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal"> ….<o:p></o:p></p>
<p class="MsoNormal">----------------<o:p></o:p></p>
<p class="MsoNormal">|Frame# 10 |<o:p></o:p></p>
<p class="MsoNormal">----------------<o:p></o:p></p>
<p class="MsoNormal">Picture Parameters:<o:p></o:p></p>
<p class="MsoNormal"> Current Picture: 11, frame_idx: 6, flags: 8, top_field_order_cnt: 20, bottom_field_order_cnt: 20<o:p></o:p></p>
<p class="MsoNormal"> Reference Pictures (Reported = 4):<o:p></o:p></p>
<p class="MsoNormal"> 1 - Reference Picture: 6, frame_idx: 3, flags: 8, top_field_order_cnt: 16, bottom_field_order_cnt: 16<o:p></o:p></p>
<p class="MsoNormal"> 2 - Reference Picture: 2, frame_idx: 1, flags: 8, top_field_order_cnt: 8, bottom_field_order_cnt: 8<o:p></o:p></p>
<p class="MsoNormal"> 3 - Reference Picture: 1, frame_idx: 0, flags: 8, top_field_order_cnt: 0, bottom_field_order_cnt: 0<o:p></o:p></p>
<p class="MsoNormal"> 4 - Reference Picture: 10, frame_idx: 5, flags: 8, top_field_order_cnt: 24, bottom_field_order_cnt: 24<o:p></o:p></p>
<p class="MsoNormal"> Picture Width (in mbs minus1) = 79, Picture Height (in mbs minus1) = 44, Bit Depth Luma minus8 = 0,
<o:p></o:p></p>
<p class="MsoNormal"> Sequence fields = 0x80d1, num_slice_groups_minus1 = 0, slice_group_map_type = 0<o:p></o:p></p>
<p class="MsoNormal"> slice_group_change_rate_minus1 = 0, pic_init_qp_minus26 = 0, pic_init_qs_minus26 = 0<o:p></o:p></p>
<p class="MsoNormal"> chroma_qp_index_offset = -6, second_chroma_qp_index_offset = -6, Picture field = 0x519<o:p></o:p></p>
<p class="MsoNormal"> Frame Number = 6 <o:p></o:p></p>
<p class="MsoNormal">Slice Parameters:<o:p></o:p></p>
<p class="MsoNormal"> slice_data_size = 33, slice_data_offset = 0, slice_data_flag = 0, slice_data_bit_offset = 52, first_mb_in_slice = 0,
<o:p></o:p></p>
<p class="MsoNormal"> slice_type = 1, direct_spatial_mv_pred_flag = 0, num_ref_idx_l0_active_minus1 = 2, num_ref_idx_l1_active_minus1 = 0,
<o:p></o:p></p>
<p class="MsoNormal"> cabac_init_idc = 0, slice_qp_delta = -3, disable_deblocking_filter_idc = 0, slice_alpha_c0_offset_div2 = 0, slice_beta_offset_div2 = 0,
<o:p></o:p></p>
<p class="MsoNormal"> Reference Picture List0:<o:p></o:p></p>
<p class="MsoNormal"> 1 - Reference Picture: 6, frame_idx: 3, flags: 8, top_field_order_cnt: 16, bottom_field_order_cnt: 16<o:p></o:p></p>
<p class="MsoNormal"> 2 - Reference Picture: 2, frame_idx: 1, flags: 8, top_field_order_cnt: 8, bottom_field_order_cnt: 8<o:p></o:p></p>
<p class="MsoNormal"> 3 - Reference Picture: 1, frame_idx: 0, flags: 8, top_field_order_cnt: 0, bottom_field_order_cnt: 0<o:p></o:p></p>
<p class="MsoNormal"> Reference Picture List1:<o:p></o:p></p>
<p class="MsoNormal"> 1 - Reference Picture: 10, frame_idx: 5, flags: 8, top_field_order_cnt: 24, bottom_field_order_cnt: 24<o:p></o:p></p>
<p class="MsoNormal"> slice_alpha_c0_offset_div2 = 0, luma_log2_weight_denom = 5, chroma_log2_weight_denom = 5, luma_weight_l0_flag = 0,
<o:p></o:p></p>
<p class="MsoNormal"> chroma_weight_l0_flag = 0, luma_weight_l1_flag = 0, chroma_weight_l1_flag = 0, <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">----------------<o:p></o:p></p>
<p class="MsoNormal">|Frame# 11 |<o:p></o:p></p>
<p class="MsoNormal">----------------<o:p></o:p></p>
<p class="MsoNormal"> ….<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Second one is a basic profiler implementation designed to understand underlying driver performance. Libva APIs are instrumented with profiling macros which can be controlled via compile and runtime env flags.<o:p></o:p></p>
<p class="MsoNormal">Upon termination, libva dumps profiling info to a text log file with useful data that can help to tune underline driver performance.
<o:p></o:p></p>
<p class="MsoNormal">I understand there are other tools such as Vtune, gprof to attain similar results but they require time to setup and hard to use in automation environment. The tool allows you to dump data into a comma delimited file which can be imported
by any spreadsheet for further analysis and comparison.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sample: <o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------- Performance Statistics ( Video) ---------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">Method [Calls] Minimum(mcs) Maximum(mcs) Mean(mcs) Shft Mean(mcs) Median(mcs) Total(mcs)<o:p></o:p></p>
<p class="MsoNormal">=======================================================================================================<o:p></o:p></p>
<p class="MsoNormal">vaBeginPicture [49] : 237.0000 4139.0000 2420.1633 1946.2414 2378.0000 118588.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaCreateBuffer [441] : 152.0000 58053.0000 4951.2562 1743.4583 2142.0000 2183504.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaCreateConfig [2] : 4.0000 6.0000 5.0000 5.0000 6.0000 10.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaCreateContext [2] : 111921.0000 311833.0000 211877.0000 211877.0000 311833.0000 423754.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaCreateImage [4] : 5478.0000 72662.0000 55048.0000 55048.0000 71712.0000 220192.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaCreateSubPicture [4] : 6139.0000 77766.0000 51107.7500 51107.7500 75679.0000 204431.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaCreateSurfaces [12] : 3004.0000 50602.0000 21716.8333 3162.0000 3312.0000 260602.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaDestroyBuffer [196] : 137.0000 5026.0000 1748.6888 1456.3846 1776.0000 342743.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaDestroyConfig [2] : 5.0000 59.0000 32.0000 32.0000 59.0000 64.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaDestroyContext [2] : 10435.0000 914915.0000 462675.0000 462675.0000 914915.0000 925350.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaDestroyImage [4] : 2561.0000 30449.0000 16464.0000 16464.0000 30271.0000 65856.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaDestroySubPicture [4] : 2953.0000 33722.0000 18146.5000 18146.5000 32840.0000 72586.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaDestroySurfaces [2] : 8768.0000 103504.0000 56136.0000 56136.0000 103504.0000 112272.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaInitialize [1] : 32574.0000 32574.0000 32574.0000 32574.0000 32574.0000 32574.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaEndPicture [49] : 160.0000 4036.0000 2232.2653 1559.2759 1868.0000 109381.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaGetConfigAttributes [2] : 3.0000 4.0000 3.5000 3.5000 4.0000 7.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaMapBuffer [49] : 3.0000 616.0000 54.0408 16.4138 59.0000 2648.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaPutSurface [49] : 2737.0000 100262.0000 6870.4898 3537.2069 3749.0000 336654.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaRenderPicture [98] : 666.0000 46726.0000 7246.3061 2008.7414 2513.0000 710138.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaTerminate [1] : 286426.0000 286426.0000 286426.0000 286426.0000 286426.0000 286426.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">vaUnMapBuffer [49] : 2.0000 587.0000 57.1429 16.7241 59.0000 2800.0000<o:p></o:p></p>
<p class="MsoNormal">--------------------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal">*out of indentation due to font<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The logger and profiler engine are implemented in a separate dynamic link library.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Currently they are provided as patch for libva official releases (1.0.12 & 1.0.15).
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Let me know if you want to try them and I will email you the package.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">-Arshad<o:p></o:p></p>
</div>
</body>
</html>