Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new branch for thread. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified H264BSAnalyzer/H264BSAnalyzer.aps
Binary file not shown.
67 changes: 65 additions & 2 deletions H264BSAnalyzer/H264BSAnalyzerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,23 @@ int CH264BSAnalyzerDlg::ShowNLInfo_1(NALU_t* nalu)
return TRUE;
}

HANDLE g_hSemaphore;
HANDLE g_hAdapterOne;

typedef struct
{
char* file;
vector<NALU_t>* vNalTypeVector;
int num;
}NALInfo_t;

NALInfo_t g_foo;

char* g_file = NULL;
int g_nMaxNalNum = 0;
vector<NALU_t> g_vNalTypeVector;

UINT ExecutingFunction(LPVOID pParam);
// CH264BSAnalyzerDlg message handlers

BOOL CH264BSAnalyzerDlg::OnInitDialog()
Expand Down Expand Up @@ -399,6 +416,18 @@ BOOL CH264BSAnalyzerDlg::OnInitDialog()
m_edHexInfo.SetOptions(1, 1, 1, 1);
m_edHexInfo.SetBPR(16); // 16�ֽ�

//
g_hSemaphore = CreateSemaphore(NULL, 0, 1, NULL);
if (g_hSemaphore == NULL)
{
return FALSE;
}
g_hAdapterOne = CreateSemaphore(NULL, 0, 1, NULL);

//g_hAdapterOne = OpenSemaphore(MUTEX_ALL_ACCESS, FALSE, "abc");

AfxBeginThread(ExecutingFunction, NULL);

return TRUE; // return TRUE unless you set the focus to a control
}

Expand Down Expand Up @@ -459,6 +488,28 @@ void CH264BSAnalyzerDlg::SystemClear()
m_nSliceIndex = 0;
}

UINT ExecutingFunction(LPVOID pParam)
{
//NALInfo_t* foo = (NALInfo_t *)pParam;
DWORD dwReturn;
while (1)
{
dwReturn = WaitForSingleObject(g_hSemaphore, 1000 * 60 * 10);
if(WAIT_OBJECT_0 == dwReturn)
{
//AfxMessageBox("abcd");

h264_nal_parse_1(g_file, g_vNalTypeVector, g_nMaxNalNum);
//h264_nal_parse_1(g_foo.file, *g_foo.vNalTypeVector, g_foo.num);
//AfxMessageBox("in ExecutingFunction");
//Sleep(10*1000);
ReleaseSemaphore(g_hAdapterOne, 1, NULL);
}
Sleep(100);
}
return 0;
}

// ��H264�����ļ�
void CH264BSAnalyzerDlg::OnBnClickedH264InputurlOpen()
{
Expand Down Expand Up @@ -507,9 +558,21 @@ void CH264BSAnalyzerDlg::OnBnClickedH264InputurlOpen()

strcpy(str_szFileUrl,m_strFileUrl.GetBuffer());

//NALInfo_t foo;
g_foo.file = str_szFileUrl;
g_foo.num = nMaxNalNum;
g_foo.vNalTypeVector = &m_vNalTypeVector;
g_file = str_szFileUrl;
g_nMaxNalNum = nMaxNalNum;
g_vNalTypeVector = m_vNalTypeVector;
ReleaseSemaphore(g_hSemaphore, 1, NULL);
//AfxBeginThread(ExecutingFunction, &foo);

//h264_nal_parse(this,str_szFileUrl);
h264_nal_parse_1(str_szFileUrl, m_vNalTypeVector, nMaxNalNum);
//h264_nal_parse_1(str_szFileUrl, m_vNalTypeVector, nMaxNalNum);

WaitForSingleObject(g_hAdapterOne, INFINITE);
m_vNalTypeVector = g_vNalTypeVector;
for (int i = 0; i < (int)m_vNalTypeVector.size(); i++)
{
// ����SPS
Expand All @@ -524,7 +587,7 @@ void CH264BSAnalyzerDlg::OnBnClickedH264InputurlOpen()
}
ShowNLInfo_1(&m_vNalTypeVector[i]);
}
//
// profile����
switch (sps.profile_idc)
{
case 66:
Expand Down