Skip to content

Commit

Permalink
video media type frame rate details; fixes #295
Browse files Browse the repository at this point in the history
  • Loading branch information
roman380 committed Sep 5, 2016
1 parent 280e413 commit c2aecbc
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/dsutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,12 +2174,22 @@ namespace DSUtil
CString formatDetails;
if (mediaType.pbFormat)
{
const VIDEOINFOHEADER* pVideoInfoHeader = NULL;
const VIDEOINFOHEADER2* pVideoInfoHeader2 = NULL;
const BITMAPINFOHEADER* bmi = NULL;
const LONGLONG* pnAverageFrameTime = NULL;
if(mediaType.formattype == FORMAT_VideoInfo && mediaType.cbFormat >= sizeof (VIDEOINFOHEADER))
bmi = &((const VIDEOINFOHEADER*) mediaType.pbFormat)->bmiHeader;
else
{
pVideoInfoHeader = (const VIDEOINFOHEADER*) mediaType.pbFormat;
bmi = &pVideoInfoHeader->bmiHeader;
pnAverageFrameTime = &pVideoInfoHeader->AvgTimePerFrame;
} else
if((mediaType.formattype == FORMAT_VideoInfo2 || mediaType.formattype == FORMAT_MPEG2_VIDEO) && mediaType.cbFormat >= sizeof (VIDEOINFOHEADER2))
bmi = &((const VIDEOINFOHEADER2*) mediaType.pbFormat)->bmiHeader;
{
pVideoInfoHeader2 = (const VIDEOINFOHEADER2*) mediaType.pbFormat;
bmi = &pVideoInfoHeader2->bmiHeader;
pnAverageFrameTime = &pVideoInfoHeader2->AvgTimePerFrame;
}
#if _WIN32_WINNT >= 0x0602 // _WIN32_WINNT_WIN8
else
if(mediaType.formattype == FORMAT_UVCH264Video && mediaType.cbFormat >= offsetof(KS_H264VIDEOINFO, bMaxCodecConfigDelay))
Expand All @@ -2200,6 +2210,8 @@ namespace DSUtil
const float averageBPP = pixels ? (8.0f * bmi->biSizeImage) / pixels : 0;
formatDetails.Format(_T("%4d x %4d, %3d bpp, %6.3f av"),
bmi->biWidth, bmi->biHeight, bmi->biBitCount, averageBPP);
if(pnAverageFrameTime && *pnAverageFrameTime > 0)
formatDetails.AppendFormat(_T(", %.3f fps"), 1E7 / *pnAverageFrameTime);
}
else if(mediaType.formattype == FORMAT_WaveFormatEx && mediaType.cbFormat >= sizeof(WAVEFORMATEX))
{
Expand Down

0 comments on commit c2aecbc

Please sign in to comment.