[Libva] Libva parameter logger and profiler

Mehmood, Arshad arshad.mehmood at intel.com
Mon Oct 22 23:34:45 PDT 2012


Hi,
   I would like to share two tools that can help debugging libva applications and backend drivers.

   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.
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.

Excerpt from  log file for H264 decode:
--------------------------------------------------------------------------------------------
                ....
----------------
|Frame# 10   |
----------------
Picture Parameters:
                Current Picture: 11, frame_idx: 6, flags: 8, top_field_order_cnt: 20, bottom_field_order_cnt: 20
                Reference Pictures (Reported = 4):
                                  1 - Reference Picture:   6, frame_idx:   3, flags:   8,                   top_field_order_cnt:  16, bottom_field_order_cnt:  16
                                  2 - Reference Picture:   2, frame_idx:   1, flags:   8,                   top_field_order_cnt:   8, bottom_field_order_cnt:   8
                                  3 - Reference Picture:   1, frame_idx:   0, flags:   8,                   top_field_order_cnt:   0, bottom_field_order_cnt:   0
                                  4 - Reference Picture:  10, frame_idx:   5, flags:   8,                   top_field_order_cnt:  24, bottom_field_order_cnt:  24
                Picture Width (in mbs minus1) = 79, Picture Height (in mbs minus1) = 44, Bit Depth Luma minus8 = 0,
                Sequence fields = 0x80d1, num_slice_groups_minus1 = 0, slice_group_map_type = 0
                slice_group_change_rate_minus1 = 0, pic_init_qp_minus26 = 0, pic_init_qs_minus26 = 0
                chroma_qp_index_offset = -6, second_chroma_qp_index_offset = -6, Picture field = 0x519
                Frame Number = 6
Slice Parameters:
                slice_data_size = 33,       slice_data_offset = 0,    slice_data_flag = 0,         slice_data_bit_offset = 52,                 first_mb_in_slice = 0,
                slice_type = 1,   direct_spatial_mv_pred_flag = 0,             num_ref_idx_l0_active_minus1 = 2,                 num_ref_idx_l1_active_minus1 = 0,
                cabac_init_idc = 0,           slice_qp_delta = -3,        disable_deblocking_filter_idc = 0,            slice_alpha_c0_offset_div2 = 0,         slice_beta_offset_div2 = 0,
                Reference Picture List0:
                                  1 - Reference Picture:   6, frame_idx:   3, flags:   8,                     top_field_order_cnt:  16, bottom_field_order_cnt:  16
                                  2 - Reference Picture:   2, frame_idx:   1, flags:   8,                     top_field_order_cnt:   8, bottom_field_order_cnt:   8
                                  3 - Reference Picture:   1, frame_idx:   0, flags:   8,                     top_field_order_cnt:   0, bottom_field_order_cnt:   0
                Reference Picture List1:
                                  1 - Reference Picture:  10, frame_idx:   5, flags:   8,                    top_field_order_cnt:  24, bottom_field_order_cnt:  24
                slice_alpha_c0_offset_div2 = 0,                luma_log2_weight_denom = 5,                 chroma_log2_weight_denom = 5,                 luma_weight_l0_flag = 0,
                chroma_weight_l0_flag = 0,        luma_weight_l1_flag = 0,             chroma_weight_l1_flag = 0,

----------------
|Frame# 11   |
----------------
                ....
--------------------------------------------------------------------------------------------



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.
Upon termination, libva dumps profiling info to a text log file with useful data that can help to tune underline driver performance.
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.

Sample:
--------------------------------------------------------- Performance Statistics ( Video) ---------------------------------------------------------
Method                                  [Calls]         Minimum(mcs)    Maximum(mcs)      Mean(mcs)       Shft Mean(mcs)    Median(mcs)     Total(mcs)
=======================================================================================================
vaBeginPicture                           [49]     :       237.0000        4139.0000       2420.1633        1946.2414        2378.0000      118588.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaCreateBuffer                           [441]    :       152.0000       58053.0000       4951.2562        1743.4583        2142.0000     2183504.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaCreateConfig                           [2]      :         4.0000           6.0000          5.0000           5.0000           6.0000          10.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaCreateContext                          [2]      :    111921.0000      311833.0000     211877.0000      211877.0000      311833.0000      423754.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaCreateImage                            [4]      :      5478.0000       72662.0000      55048.0000       55048.0000       71712.0000      220192.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaCreateSubPicture                       [4]      :      6139.0000       77766.0000      51107.7500       51107.7500       75679.0000      204431.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaCreateSurfaces                         [12]     :      3004.0000       50602.0000      21716.8333        3162.0000        3312.0000      260602.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaDestroyBuffer                          [196]    :       137.0000        5026.0000       1748.6888        1456.3846        1776.0000      342743.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaDestroyConfig                          [2]      :         5.0000          59.0000         32.0000          32.0000          59.0000          64.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaDestroyContext                         [2]      :     10435.0000      914915.0000     462675.0000      462675.0000      914915.0000      925350.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaDestroyImage                           [4]      :      2561.0000       30449.0000      16464.0000       16464.0000       30271.0000       65856.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaDestroySubPicture                      [4]      :      2953.0000       33722.0000      18146.5000       18146.5000       32840.0000       72586.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaDestroySurfaces                        [2]      :      8768.0000      103504.0000      56136.0000       56136.0000      103504.0000      112272.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaInitialize                             [1]      :     32574.0000       32574.0000      32574.0000       32574.0000       32574.0000       32574.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaEndPicture                             [49]     :       160.0000        4036.0000       2232.2653        1559.2759        1868.0000      109381.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaGetConfigAttributes                    [2]      :         3.0000           4.0000          3.5000           3.5000           4.0000           7.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaMapBuffer                              [49]     :         3.0000         616.0000         54.0408          16.4138          59.0000        2648.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaPutSurface                             [49]     :      2737.0000      100262.0000       6870.4898        3537.2069        3749.0000      336654.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaRenderPicture                          [98]     :       666.0000       46726.0000       7246.3061        2008.7414        2513.0000      710138.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaTerminate                              [1]      :    286426.0000      286426.0000     286426.0000      286426.0000      286426.0000      286426.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
vaUnMapBuffer                            [49]     :         2.0000         587.0000         57.1429          16.7241          59.0000        2800.0000
--------------------------------------------------------------------------------------------------------------------------------------------------------
*out of indentation due to font

The logger and profiler engine are implemented in a separate dynamic link library.

Currently they are provided as patch for libva official releases (1.0.12 & 1.0.15).

Let me know if you want to try them and I will email you the package.

Thanks,
-Arshad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libva/attachments/20121023/ed9971b4/attachment-0001.html>


More information about the Libva mailing list