📄 formatdata.cpp
字号:
/*+++ *******************************************************************\
*
* Copyright and Disclaimer:
*
* ---------------------------------------------------------------
* This software is provided "AS IS" without warranty of any kind,
* either expressed or implied, including but not limited to the
* implied warranties of noninfringement, merchantability and/or
* fitness for a particular purpose.
* ---------------------------------------------------------------
*
* Copyright (c) 2008 Conexant Systems, Inc.
* All rights reserved.
*
\******************************************************************* ---*/
#include "FormatData.h"
#include "debug.h"
#define FCC_VBI 0xf72a76e0L
FormatData::
FormatData():
_image_height( 0 ),
_image_width( 0 ),
_stride_in_bytes( 0 ),
_bit_count( 0 ),
_compression( 0 )
{
}
FormatData::
FormatData(
const KS_VIDEOINFOHEADER *p_info
)
{
_image_height = p_info->bmiHeader.biHeight;
_image_width = p_info->bmiHeader.biWidth;
_bit_count = p_info->bmiHeader.biBitCount;
_compression = p_info->bmiHeader.biCompression;
/****************************************************************
*
* This is a little tricky to handle DirectDraw stride issues.
* The rule from the DDK docs is as follows...
*
* Special rules apply when the output buffer is a
* DirectDraw surface. In this case, the biWidth
* member of the BITMAPINFOHEADER structure actually
* represents the 'stride' of the destination
* DirectDraw surface, which will typically be
* larger than the video image width. Therefore,
* to determine the requested image width, the
* following pseudocode should be used:
*
* if (IsRectEmpty(&pVideoInfoHdrRequested->rcTarget) {
* Width = pVideoInfoHdrRequested->bmiHeader.biWidth;
* Height = pVideoInfoHdrRequested->bmiHeader.biHeight;
* }
* else {
* Width = pVideoInfoHdrRequested->rcTarget.right -
* pVideoInfoHdrRequested->rcTarget.left;
* Height = pVideoInfoHdrRequested->rcTarget.bottom -
* pVideoInfoHdrRequested->rcTarget.top;
* }
*
* Note: It seems like the stride that gets stuffed into
* pVideoInfoHdrRequested->bmiHeader.biWidth is the
* stride in *pixels*, not bytes.
*
*****************************************************************/
_stride_in_bytes = p_info->bmiHeader.biWidth * _bit_count / 8;
_stride_in_bytes = ( _stride_in_bytes + 3 ) & ~3;
if( p_info->rcTarget.right > p_info->rcTarget.left )
_image_width = p_info->rcTarget.right - p_info->rcTarget.left;
}
FormatData::
FormatData(
const KS_VBIINFOHEADER *p_info
)
{
// Since Endline and StartLine are inclusive add 1
_image_height = p_info->EndLine - p_info->StartLine + 1;
_image_width = p_info->StrideInBytes;
_stride_in_bytes = p_info->StrideInBytes;
_bit_count = 8;
_compression = FCC_VBI;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -