-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFrameInfoList.cpp
More file actions
149 lines (124 loc) · 3.84 KB
/
FrameInfoList.cpp
File metadata and controls
149 lines (124 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include "stdafx.h"
CFrameInfoList::CFrameInfoList() :
m_pFrameInfoList(NULL),
m_bitrateDisplayMode(BITRATE_DISPLAY_FRAMESIZE)
{
};
BOOL CFrameInfoList::Init(HWND hListCtrl)
{
SubclassWindow(hListCtrl);
if (IsWindow())
{
SetUnicodeFormat(TRUE);
SetViewType(LVS_REPORT);
DWORD dwExtStyle = GetExtendedListViewStyle();
dwExtStyle |= LVS_EX_FULLROWSELECT;
dwExtStyle &= ~LVS_EX_CHECKBOXES;
SetExtendedListViewStyle(dwExtStyle);
// Create list view columns
InsertColumn(0, _T("PTS"), LVCFMT_LEFT, 150, 0);
InsertColumn(1, _T("Time"), LVCFMT_RIGHT, 150, 1);
InsertColumn(2, _T("Bitrate"), LVCFMT_LEFT, 150, 2);
InsertColumn(3, _T("Key Frame"), LVCFMT_LEFT, 150, 3);
InsertColumn(4, _T("Frame Duration"), LVCFMT_LEFT, 150, 3);
return TRUE;
}
return FALSE;
}
BOOL CFrameInfoList::Uninit()
{
DeleteAllItems();
UnsubclassWindow();
return TRUE;
}
BOOL CFrameInfoList::AddListItem(StreamInfo *pStreamInfo, const std::vector<FrameBitrate > *pFrameInfoList)
{
m_streamInfo = *pStreamInfo;
m_pFrameInfoList = pFrameInfoList;
size_t count = (*m_pFrameInfoList).size();
if (count < 0)
{
return FALSE;
}
for (int i = count - 1; i >= 0; --i)
{
LVITEM lvItem;
ZeroMemory(&lvItem, sizeof(lvItem));
//fill in the TV_ITEM structure for this item
lvItem.mask = LVIF_PARAM | LVIF_TEXT;
lvItem.lParam = (LPARAM)i;
//text and images are done on a callback basis
lvItem.pszText = LPSTR_TEXTCALLBACK;
// insert list item
int iRet = InsertItem(&lvItem);
}
return TRUE;
}
LRESULT CFrameInfoList::OnGetDispInfo(int idCtrl, LPNMHDR pnmh, BOOL &bHandled)
{
NMLVDISPINFO *pdi = (NMLVDISPINFO*)pnmh;
LONG lItemIndex = (LONG)pdi->item.lParam;
TCHAR str[MAX_PATH] = {0};
if (pdi->item.mask & LVIF_TEXT)
{
switch (pdi->item.iSubItem)
{
case 0: //PTS
{
_stprintf_s(str, MAX_PATH, _T("%I64d"), (*m_pFrameInfoList)[lItemIndex].pts);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
break;
case 1: //Time
{
LONGLONG time = (LONGLONG)((av_q2d(m_streamInfo.time_base) * ((*m_pFrameInfoList)[lItemIndex].pts - (*m_pFrameInfoList)[0].pts)) * 10000000L);
_stprintf_s(str, MAX_PATH, _T("%I64d"), time);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
break;
case 2: //Bitrate
{
if (m_bitrateDisplayMode == BITRATE_DISPLAY_NORMAL)
{
int framerate = int((*m_pFrameInfoList)[lItemIndex].framesize * 8 * m_streamInfo.frame_rate);
_stprintf_s(str, MAX_PATH, _T("%d"), framerate);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
else if (m_bitrateDisplayMode == BITRATE_DISPLAY_FRAMESIZE)
{
_stprintf_s(str, MAX_PATH, _T("%d (%d byte)"), (*m_pFrameInfoList)[lItemIndex].framesize * 8, (*m_pFrameInfoList)[lItemIndex].framesize);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
else if (m_bitrateDisplayMode == BITRATE_DISPLAY_FRAMESIZE_BIT)
{
_stprintf_s(str, MAX_PATH, _T("%d"), (*m_pFrameInfoList)[lItemIndex].framesize * 8);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
else if (m_bitrateDisplayMode == BITRATE_DISPLAY_FRAMESIZE_BYTE)
{
_stprintf_s(str, MAX_PATH, _T("%d"), (*m_pFrameInfoList)[lItemIndex].framesize);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
}
break;
case 3: // Key Frame
{
_stprintf_s(str, MAX_PATH, _T("%d"), (*m_pFrameInfoList)[lItemIndex].keyframe);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
break;
case 4: // Frame Duration
{
LONGLONG time = (LONGLONG)((av_q2d(m_streamInfo.time_base) * (*m_pFrameInfoList)[lItemIndex].duration) * 10000000L);
_stprintf_s(str, MAX_PATH, _T("%I64d"), time);
lstrcpyn(pdi->item.pszText, str, pdi->item.cchTextMax);
}
break;
}
}
return S_OK;
}
LRESULT CFrameInfoList::OnDeleteItem(int idCtrl, LPNMHDR pnmh, BOOL &bHandled)
{
return S_OK;
}