// DimDetectorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DimDetector.h"
#include "DimDetectorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDimDetectorDlg dialog
CDimDetectorDlg::CDimDetectorDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDimDetectorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDimDetectorDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDimDetectorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDimDetectorDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDimDetectorDlg, CDialog)
//{{AFX_MSG_MAP(CDimDetectorDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDimDetectorDlg message handlers
BOOL CDimDetectorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CDimDetectorDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CDimDetectorDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void bs_init( bs_t *s, void *p_data, int i_data )
{
s->p_start = (uint8_t*)p_data;
s->p = (uint8_t*)p_data;
s->p_end = s->p + i_data;
s->i_left = 8;
}
int bs_pos( bs_t *s )
{
return( 8 * ( s->p - s->p_start ) + 8 - s->i_left );
}
int bs_eof( bs_t *s )
{
return( s->p >= s->p_end ? 1: 0 );
}
uint32_t bs_read( bs_t *s, int i_count )
{
static uint32_t i_mask[33] ={
0x00,
0x01, 0x03, 0x07, 0x0f,
0x1f, 0x3f, 0x7f, 0xff,
0x1ff, 0x3ff, 0x7ff, 0xfff,
0x1fff, 0x3fff, 0x7fff, 0xffff,
0x1ffff, 0x3ffff, 0x7ffff, 0xfffff,
0x1fffff, 0x3fffff, 0x7fffff, 0xffffff,
0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff,
0x1fffffff,0x3fffffff,0x7fffffff,0xffffffff
};
int i_shr;
uint32_t i_result = 0;
while( i_count > 0 )
{
if( s->p >= s->p_end )
{
break;
}
if( ( i_shr = s->i_left - i_count ) >= 0 )
{
/* more in the buffer than requested */
i_result |= ( *s->p >> i_shr )&i_mask[i_count];
s->i_left -= i_count;
if( s->i_left == 0 )
{
s->p++;
s->i_left = 8;
}
return( i_result );
}
else
{
// less in the buffer than requested
i_result |= (*s->p&i_mask[s->i_left]) << -i_shr;
i_count -= s->i_left;
s->p++;
s->i_left = 8;
}
}
return( i_result );
}
uint32_t bs_read1( bs_t *s )
{
if( s->p < s->p_end )
{
unsigned int i_result;
s->i_left--;
i_result = ( *s->p >> s->i_left )&0x01;
if( s->i_left == 0 )
{
s->p++;
s->i_left = 8;
}
return i_result;
}
return 0;
}
uint32_t bs_show( bs_t *s, int i_count )
{
if( s->p < s->p_end && i_count > 0 )
{
uint32_t i_cache = ((s->p[0] << 24)+(s->p[1] << 16)+(s->p[2] << 8)+s->p[3]) << (8-s->i_left);
return( i_cache >> ( 32 - i_count) );
}
return 0;
}
/* TODO optimize */
void bs_skip( bs_t *s, int i_count )
{
s->i_left -= i_count;
while( s->i_left <= 0 )
{
s->p++;
s->i_left += 8;
}
}
int bs_read_ue( bs_t *s )
{
int i = 0;
while( bs_read1( s ) == 0 && s->p < s->p_end && i < 32 )
{
i++;
}
return( ( 1 << i) - 1 + bs_read( s, i ) );
}
int bs_read_se( bs_t *s )
{
int val = bs_read_ue( s );
return val & 0x01 ? (val + 1) / 2 : -(val / 2);
}
int bs_read_te( bs_t *s, int x )
{
if( x == 1 )
{
return 1 - bs_read1( s );
}
else if( x > 1 )
{
return bs_read_ue( s );
}
return 0;
}
void bs_write( bs_t *s, int i_count, uint32_t i_bits )
{
if( s->p >= s->p_end - 4 )
{
return;
}
while( i_count > 0 )
{
if( i_count < 32 )
{
i_bits &= (1 << i_count) - 1;
}
if( i_count < s->i_left )
{
*s->p = (*s->p << i_count) | i_bits;
s->i_left -= i_count;
break;
}
else
{
*s->p = (*s->p << s->i_left) | (i_bits >> (i_count - s->i_left));
i_count -= s->i_left;
s->p++;
s->i_left = 8;
}
}
}
void bs_write1( bs_t *s, uint32_t i_bit )
{
if( s->p < s->p_end )
{
*s->p <<= 1;
*s->p |= i_bit;
s->i_left--;
if( s->i_left == 0 )
{
s->p++;
s->i_left = 8;
}
}
}
void bs_align_0( bs_t *s )
{
if( s->i_left != 8 )
{
*s->p <<= s->i_left;
s->i_left = 8;
s->p++;
}
}
void bs_align_1( bs_t *s )
{
if( s->i_left != 8 )
{
*s->p <<= s->i_left;
*s->p |= (1 << s->i_left) - 1;
s->i_left = 8;
s->p++;
}
}
void bs_align( bs_t *s )
{
bs_align_0( s );
}
/* golomb functions */
void bs_write_ue( bs_t *s, unsigned int val )
{
int i_size = 0;
static const int i_size0_255[256] =
{
1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
};
if( val == 0 )
{
bs_write1( s, 1 );
}
else
{
unsigned int tmp = ++val;
if( tmp >= 0x00010000 )
{
i_size += 16;
tmp >>= 16;
}
if( tmp >= 0x100 )
{
i_size += 8;
tmp >>= 8;
}
i_size += i_size0_255[tmp];
bs_write( s, 2 * i_size - 1, val );
}
}
void bs_write_se( bs_t *s, int val )
{
bs_write_ue( s, val <= 0 ? -val * 2 : val * 2 - 1);
}
void bs_write_te( bs_t *s, int x, int val )
{
if( x == 1 )
{
bs_write1( s, 1&~val );
}
else if( x > 1 )
{
bs_write_ue( s, val );
}
}
void bs_rbsp_trailing( bs_t *s )
{
bs_write1( s, 1 );
if( s->i_left != 8 )
{
H264画面尺寸探测
5星 · 超过95%的资源 需积分: 17 110 浏览量
2008-10-19
14:24:55
上传
评论
收藏 12KB RAR 举报
DoItFreely
- 粉丝: 6
- 资源: 6
最新资源
- 基于Python的PCA人脸识别算法的原理及实现代码详解+源码+详细代码解析+开发文档+数据(毕业设计&课程设计&项目开发)
- Decision tree20240105(1).ipynb
- zuoyezuoyezuoye
- zuoyezuoyezuoye
- 机械设计电机转子装配设备sw22非常好的设计图纸100%好用.zip
- 作业作业作业作业作业作业
- xdotool.c
- RLMD鲁棒性局部均值分解信号分量可视化(Matlab完整源码和数据)
- Screenshot_2024-04-26-17-17-26-36_9d26c6446fd7bb8e41d99b6262b17def.jpg
- 6.0版本超广角文件+教程使用MT管理器打-7.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈