My HEVC stream Analytics tool MFC Small Notes: Tree control usage and window scaling

Source: Internet
Author: User

About 1.5 months ago, it published its own HEVC stream analysis tool. The version at that time showed the syntax element using the edit control. Many of the mainstream analysis tools use tree controls, which seem to be high-end, so after a day of tangled determination to implement the tree-like HEVC syntax display. After a long period of spare time, and finally finished, so there is this article.

The tree control expands and collapses content, whether it's a display or an appearance, compared to a normal edit box, so you eventually choose a tree control. At the beginning of the understanding, the online complete information is not many, also thought very complex, after finishing, actually not complex. More work is required because all of the syntax elements one by one are modified.

Drag a tree control to the interface in VS, and its properties can be set in the resource view or in code. In the resource view, set the value of "has Bottons", "Have Lines", "Lines at Root" to true.

Here is a small example:

#define ADDTREEITEM (item, buffer) M_ctree.insertitem (buffer,item) Htreeitem HItem = M_ctree.insertitem ("root node nal", Tvi_
    ROOT);///root CString strtemp;
    Strtemp.format ("NAL head node Nal_unit_header");

    Htreeitem Hsubitem = Addtreeitem (HItem, Strtemp.getbuffer ()); Strtemp.format ("Forbidden_zero_bit \t\t:0
    (1 bit) ");
    Addtreeitem (Hsubitem, Strtemp.getbuffer ());
    Strtemp.format ("Nal_unit_type \t\t:32 (6 bit)");
    Addtreeitem (Hsubitem, Strtemp.getbuffer ()); Strtemp.format ("NAL_REF_IDC \t\t:0
    (6 bit) ");
    Addtreeitem (Hsubitem, Strtemp.getbuffer ()); Strtemp.format ("Nuh_temporal_id_plus1 \t\t:0
    (3 bit) ");

    Addtreeitem (Hsubitem, Strtemp.getbuffer ());
    Strtemp.format ("VPS Node video_parameter_set_rbsp ()");

    Htreeitem hItem1 = Addtreeitem (HItem, Strtemp.getbuffer ());
    Strtemp.format ("header ()");
    Htreeitem hItem2 = Addtreeitem (HItem1, Strtemp.getbuffer ());
    Strtemp.format ("fist slice)");
    Addtreeitem (HITEM2, Strtemp.getbuffer ()); Strtemp.format ("No output ");

    Addtreeitem (HITEM2, Strtemp.getbuffer ());
    Strtemp.format ("Data ()"); Addtreeitem (HItem1, Strtemp.getbuffer ());
The code is very simple, the main call InsertItem function, the function has a number of overloaded functions, here is two parameters, the first to display the string, the second is to be inserted on which node, the value of the root node is tvi_root.

The following is an illustration of the above code in a different appearance style:

Visible, the following figure has obvious advantages.

In the article "My YUV Player MFC small notes: Set picture control background for black, window Zoom" simply records how to implement window scaling. This tool has a different point, which is to scale the controls using the zoom scale.

First get the main window coordinates in the dialog initialization:

main Window size
    getclientrect (&m_rectmainwnd);

In the response function onsize of window scaling, the x-axis ratio is computed by the width of the CX and main window, and the y-axis ratio is computed by CY and height:

    float fxratio = (float) CX/(float) (M_rectmainwnd.width ());
    float fyratio = (float) cy/(float) (M_rectmainwnd.height ());

In the actual test, it was found that only the coordinates and width of getclientrect were used to correspond with the parameters CX and CY of the OnSize function. In addition, GetWindowRect and screentoclient are used to determine the coordinates and size of the control. The function that really adjusts the position is MoveWindow. The following is an example of the list box control in the upper-left corner of the tool to show an example code:

    Gets the list box coordinates
    CRect rectlist;
    GetDlgItem (idc_h264_nallist)->getwindowrect (&rectlist);
    ScreenToClient (rectlist);
    
    Calculate the ratio of
    float fxratio = (float) CX/(float) (M_rectmainwnd.width ());
    float fyratio = (float) cy/(float) (M_rectmainwnd.height ());
    
    int nnewwidth = 0;
    int nnewheight = 0;

    Re-move the list box
    pWnd = GetDlgItem (idc_h264_nallist);
    Nnewwidth = (int) (Fxratio * (float) rectlist.width ());
    Nnewheight = (int) (Fyratio * (float) rectlist.height ());
    Pwnd->movewindow (Rectlist.left, Rectlist.top, Nnewwidth, nnewheight);
    Pwnd->invalidate ();
    Pwnd->updatedata ();
    Updated so that the following controls can refer to
    pwnd->getwindowrect (&rectlist);
    ScreenToClient (rectlist);


Specific code, you can refer to the Code warehouse: Https://github.com/latelee/H264BSAnalyzer


Li Yu 2015.11.18 Night

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.