- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
// The documentation sample has a couple minor typos ... here's the corrected version
/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2005-2008 Intel Corporation. All Rights Reserved.
//
*/
#include
#include
#include "ippdefs.h"
#include "ippcore.h"
#include "ipps.h"
#include "ippi.h"
#include "ippj.h"
#include "ippcc.h"
#include "vm_time.h"
#include "umc_defs.h"
#include "umc_structures.h"
#include "umc_data_reader.h"
#include "umc_splitter.h"
#include "umc_video_decoder.h"
#include "umc_video_data.h"
#include "umc_video_render.h"
#include "umc_file_reader.h"
#include "umc_fio_reader.h"
#include "umc_avi_splitter.h"
#include "umc_mjpeg_video_decoder.h"
#include "fw_video_render.h"
// Note: these are debug libs.
//#pragma comment(lib, "ippcvmerged.lib")
//#pragma comment(lib, "ippcvemerged.lib")
//#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "ippcorel.lib")
#pragma comment(lib, "ippsmerged.lib")
#pragma comment(lib, "ippsemerged.lib")
#pragma comment(lib, "ippvcmerged.lib")
#pragma comment(lib, "ippvcemerged.lib")
#pragma comment(lib, "ippimerged.lib")
#pragma comment(lib, "ippiemerged.lib")
#pragma comment(lib, "ippjmerged.lib")
#pragma comment(lib, "ippjemerged.lib")
#pragma comment(lib, "ippccmerged.lib")
#pragma comment(lib, "ippccemerged.lib")
// Create an environment varialbe IPPCODECLIBS to point to here ...
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/umc_io/umc_io.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/video_renders/video_renders.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/jpeg/jpeg.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/avi_spl/avi_spl.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/spl_common/spl_common.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/media_buffers/media_buffers.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/base_classes/base_classes.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/vm/vm.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/vm_plus/vm_plus.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/color_space_converter/color_space_converter.lib")
using namespace UMC;
static void copyright(void)
{
vm_string_printf(VM_STRING("\nIntel Media processing sample based on\n"));
vm_string_printf(VM_STRING(" UMC and Intel Integrated Performance Primitives\n"));
vm_string_printf(VM_STRING("Copyright(c) 2005-2008 Intel Corporation. All Rights Reserved.\n\n"));
return;
} // copyright()
static void ipp_version(void)
{
const IppLibraryVersion* version;
vm_string_printf(VM_STRING("Intel Integrated Performance Primitives\n"));
/* ippCore version info */
version = ippGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,version->BuildDate);
/* ippSP version info */
version = ippsGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
/* ippIP version info */
version = ippiGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
/* ippJP version info */
version = ippjGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
/* ippCC version info */
version = ippccGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
vm_string_printf(VM_STRING("\n"));
return;
} // ipp_version()
Status
InitDataReader(DataReader* pDataReader, vm_char* file_name)
{
FileReaderParams reader_params;
reader_params.m_portion_size = 0;
vm_string_strcpy(reader_params.m_file_name, file_name);
return pDataReader->Init(&reader_params);
} // InitDataReader()
Status
InitAVISplitter(Splitter* pAVISplitter, DataReader* pDataReader)
{
SplitterParams spl_params;
spl_params.m_lFlags = VIDEO_SPLITTER; // want to exctract only video
spl_params.m_pDataReader = pDataReader;
return pAVISplitter->Init(spl_params);
} // InitAVISplitter()
Status
InitMJPEGVideoDecoder(VideoDecoder* pVideoDecoder, VideoStreamInfo* video_info)
{
if ( video_info->stream_type != MJPEG_VIDEO )
return UMC_ERR_FAILED;
VideoDecoderParams dec_params;
dec_params.info = *video_info;
dec_params.lFlags = 0;
dec_params.numThreads = 1;
return pVideoDecoder->Init(&dec_params);
} // InitMJPEGVideoDecoder()
Status
InitVideoRender(VideoRender* pVideoRender, VideoStreamInfo* video_info)
{
VideoRenderParams render_params;
Status umcRes = render_params.out_data_template.Init(
video_info->clip_info.width,
video_info->clip_info.height,
video_info->color_format);
if ( UMC_OK != umcRes )
return umcRes;
return pVideoRender->Init(&render_params);
} // InitVideoRender()
Status
DecodeMJPEGVideo(vm_char* input_file)
{
Ipp32u track;
Ipp32s nframes;
vm_tick t0;
vm_tick t1;
vm_tick total;
vm_tick freq;
Ipp64f fps;
FIOReader src;
AVISplitter avi_spl;
SplitterInfo* spl_info;
VideoStreamInfo* video_info;
MJPEGVideoDecoder mjpeg_dec;
FWVideoRender dst;
MediaData in;
VideoData out;
Status umcRes;
// Initialize data reader component
umcRes = InitDataReader(&src, input_file);
if ( umcRes != UMC_OK )
return umcRes;
// Initialize splitter component
umcRes = InitAVISplitter(&avi_spl, &src);
if ( umcRes != UMC_OK )
return umcRes;
// get stream info
umcRes = avi_spl.GetInfo(&spl_info);
if ( umcRes != UMC_OK )
return umcRes;
// find required track
for ( track = 0; track < spl_info->m_nOfTracks; track++ )
if ( TRACK_MJPEG == spl_info->m_ppTrackInfo[track]->m_Type )
break;
// track of MJPEG type is not found
if ( track >= spl_info->m_nOfTracks )
return UMC_ERR_INVALID_STREAM;
// get VideoStreamInfo structure
video_info = (VideoStreamInfo*)spl_info->m_ppTrackInfo[track]->m_pStreamInfo;
video_info->color_format = YUY2;
vm_string_printf(VM_STRING("file: %s\n"),input_file);
vm_string_printf(VM_STRING(" video stream\n"));
//vm_string_printf(VM_STRING(" type :%s\n"),GetVideoTypeString(spl_info->m_video_info.stream_type));
//vm_string_printf(VM_STRING(" dims : %dx%d\n"),spl_info->m_video_info.clip_info.width,spl_info->m_video_info.clip_info.height);
//vm_string_printf(VM_STRING(" color : %s\n"),GetFormatTypeString(spl_info->m_video_info.color_format));
// Initialize video decoder component
umcRes = InitMJPEGVideoDecoder(&mjpeg_dec, video_info);
if ( umcRes != UMC_OK )
return umcRes;
// Initialize video render component
umcRes = InitVideoRender(&dst, video_info);
if ( umcRes != UMC_OK )
return umcRes;
freq = vm_time_get_frequency();
total = 0;
nframes = 0;
// decoding & rendering loop (frame by frame)
while ( umcRes == UMC_OK || umcRes == UMC_ERR_NOT_ENOUGH_DATA )
{
while ( UMC_ERR_NOT_ENOUGH_DATA == (umcRes = avi_spl.GetNextData(&in, track)) )
vm_time_sleep(5);
if ( umcRes != UMC_OK )
break;
umcRes = dst.LockInputBuffer(&out);
if ( umcRes != UMC_OK )
break;
t0 = vm_time_get_tick();
umcRes = mjpeg_dec.GetFrame(&in, &out);
if ( umcRes != UMC_OK )
break;
t1 = vm_time_get_tick();
total += (t1 - t0);
if ( umcRes != UMC_OK )
continue;
vm_string_printf(VM_STRING("frame# %d, FPS - %4.1f\r"), nframes, (Ipp64f)1.0 / ((t1 - t0) / (Ipp64f)freq));
if ( umcRes == UMC_OK )
{
umcRes = dst.UnLockInputBuffer(&out);
if ( umcRes != UMC_OK )
break;
Ipp64f time = -1;
while ( UMC_ERR_TIMEOUT == dst.GetRenderFrame(&time) );
umcRes = dst.RenderFrame();
if ( umcRes != UMC_OK )
break;
}
nframes++;
} // while()
fps = (Ipp64f)(freq / ((Ipp64f)total / nframes));
vm_string_printf(VM_STRING("processed %d frames, with avg performance %4.1f FPS\n"), nframes, fps);
return umcRes;
} // DecodeMJPEGVideo()
int main(Ipp32u argc, vm_char* argv[])
{
ippStaticInit();
copyright();
ipp_version();
if ( argc > 1 )
DecodeMJPEGVideo(argv[1]);
else
vm_string_printf(VM_STRING("expected AVI file name"));
return 0;
} // main()
/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2005-2008 Intel Corporation. All Rights Reserved.
//
*/
#include
#include
#include "ippdefs.h"
#include "ippcore.h"
#include "ipps.h"
#include "ippi.h"
#include "ippj.h"
#include "ippcc.h"
#include "vm_time.h"
#include "umc_defs.h"
#include "umc_structures.h"
#include "umc_data_reader.h"
#include "umc_splitter.h"
#include "umc_video_decoder.h"
#include "umc_video_data.h"
#include "umc_video_render.h"
#include "umc_file_reader.h"
#include "umc_fio_reader.h"
#include "umc_avi_splitter.h"
#include "umc_mjpeg_video_decoder.h"
#include "fw_video_render.h"
// Note: these are debug libs.
//#pragma comment(lib, "ippcvmerged.lib")
//#pragma comment(lib, "ippcvemerged.lib")
//#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "ippcorel.lib")
#pragma comment(lib, "ippsmerged.lib")
#pragma comment(lib, "ippsemerged.lib")
#pragma comment(lib, "ippvcmerged.lib")
#pragma comment(lib, "ippvcemerged.lib")
#pragma comment(lib, "ippimerged.lib")
#pragma comment(lib, "ippiemerged.lib")
#pragma comment(lib, "ippjmerged.lib")
#pragma comment(lib, "ippjemerged.lib")
#pragma comment(lib, "ippccmerged.lib")
#pragma comment(lib, "ippccemerged.lib")
// Create an environment varialbe IPPCODECLIBS to point to here ...
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/umc_io/umc_io.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/video_renders/video_renders.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/jpeg/jpeg.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/avi_spl/avi_spl.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/spl_common/spl_common.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/media_buffers/media_buffers.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/base_classes/base_classes.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/vm/vm.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/vm_plus/vm_plus.lib")
#pragma comment(lib, "D:/Work/ipp-samples/audio-video-codecs/_bin/Win32/debug_ascii/color_space_converter/color_space_converter.lib")
using namespace UMC;
static void copyright(void)
{
vm_string_printf(VM_STRING("\nIntel Media processing sample based on\n"));
vm_string_printf(VM_STRING(" UMC and Intel Integrated Performance Primitives\n"));
vm_string_printf(VM_STRING("Copyright(c) 2005-2008 Intel Corporation. All Rights Reserved.\n\n"));
return;
} // copyright()
static void ipp_version(void)
{
const IppLibraryVersion* version;
vm_string_printf(VM_STRING("Intel Integrated Performance Primitives\n"));
/* ippCore version info */
version = ippGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,version->BuildDate);
/* ippSP version info */
version = ippsGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
/* ippIP version info */
version = ippiGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
/* ippJP version info */
version = ippjGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),
version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
/* ippCC version info */
version = ippccGetLibVersion();
vm_string_printf(VM_STRING(" %s,\t%s {%d.%d.%d.%d},\tbuild date %s\n"),version->Name,
version->Version,
version->major,version->minor,version->majorBuild,version->build,
version->BuildDate);
vm_string_printf(VM_STRING("\n"));
return;
} // ipp_version()
Status
InitDataReader(DataReader* pDataReader, vm_char* file_name)
{
FileReaderParams reader_params;
reader_params.m_portion_size = 0;
vm_string_strcpy(reader_params.m_file_name, file_name);
return pDataReader->Init(&reader_params);
} // InitDataReader()
Status
InitAVISplitter(Splitter* pAVISplitter, DataReader* pDataReader)
{
SplitterParams spl_params;
spl_params.m_lFlags = VIDEO_SPLITTER; // want to exctract only video
spl_params.m_pDataReader = pDataReader;
return pAVISplitter->Init(spl_params);
} // InitAVISplitter()
Status
InitMJPEGVideoDecoder(VideoDecoder* pVideoDecoder, VideoStreamInfo* video_info)
{
if ( video_info->stream_type != MJPEG_VIDEO )
return UMC_ERR_FAILED;
VideoDecoderParams dec_params;
dec_params.info = *video_info;
dec_params.lFlags = 0;
dec_params.numThreads = 1;
return pVideoDecoder->Init(&dec_params);
} // InitMJPEGVideoDecoder()
Status
InitVideoRender(VideoRender* pVideoRender, VideoStreamInfo* video_info)
{
VideoRenderParams render_params;
Status umcRes = render_params.out_data_template.Init(
video_info->clip_info.width,
video_info->clip_info.height,
video_info->color_format);
if ( UMC_OK != umcRes )
return umcRes;
return pVideoRender->Init(&render_params);
} // InitVideoRender()
Status
DecodeMJPEGVideo(vm_char* input_file)
{
Ipp32u track;
Ipp32s nframes;
vm_tick t0;
vm_tick t1;
vm_tick total;
vm_tick freq;
Ipp64f fps;
FIOReader src;
AVISplitter avi_spl;
SplitterInfo* spl_info;
VideoStreamInfo* video_info;
MJPEGVideoDecoder mjpeg_dec;
FWVideoRender dst;
MediaData in;
VideoData out;
Status umcRes;
// Initialize data reader component
umcRes = InitDataReader(&src, input_file);
if ( umcRes != UMC_OK )
return umcRes;
// Initialize splitter component
umcRes = InitAVISplitter(&avi_spl, &src);
if ( umcRes != UMC_OK )
return umcRes;
// get stream info
umcRes = avi_spl.GetInfo(&spl_info);
if ( umcRes != UMC_OK )
return umcRes;
// find required track
for ( track = 0; track < spl_info->m_nOfTracks; track++ )
if ( TRACK_MJPEG == spl_info->m_ppTrackInfo[track]->m_Type )
break;
// track of MJPEG type is not found
if ( track >= spl_info->m_nOfTracks )
return UMC_ERR_INVALID_STREAM;
// get VideoStreamInfo structure
video_info = (VideoStreamInfo*)spl_info->m_ppTrackInfo[track]->m_pStreamInfo;
video_info->color_format = YUY2;
vm_string_printf(VM_STRING("file: %s\n"),input_file);
vm_string_printf(VM_STRING(" video stream\n"));
//vm_string_printf(VM_STRING(" type :%s\n"),GetVideoTypeString(spl_info->m_video_info.stream_type));
//vm_string_printf(VM_STRING(" dims : %dx%d\n"),spl_info->m_video_info.clip_info.width,spl_info->m_video_info.clip_info.height);
//vm_string_printf(VM_STRING(" color : %s\n"),GetFormatTypeString(spl_info->m_video_info.color_format));
// Initialize video decoder component
umcRes = InitMJPEGVideoDecoder(&mjpeg_dec, video_info);
if ( umcRes != UMC_OK )
return umcRes;
// Initialize video render component
umcRes = InitVideoRender(&dst, video_info);
if ( umcRes != UMC_OK )
return umcRes;
freq = vm_time_get_frequency();
total = 0;
nframes = 0;
// decoding & rendering loop (frame by frame)
while ( umcRes == UMC_OK || umcRes == UMC_ERR_NOT_ENOUGH_DATA )
{
while ( UMC_ERR_NOT_ENOUGH_DATA == (umcRes = avi_spl.GetNextData(&in, track)) )
vm_time_sleep(5);
if ( umcRes != UMC_OK )
break;
umcRes = dst.LockInputBuffer(&out);
if ( umcRes != UMC_OK )
break;
t0 = vm_time_get_tick();
umcRes = mjpeg_dec.GetFrame(&in, &out);
if ( umcRes != UMC_OK )
break;
t1 = vm_time_get_tick();
total += (t1 - t0);
if ( umcRes != UMC_OK )
continue;
vm_string_printf(VM_STRING("frame# %d, FPS - %4.1f\r"), nframes, (Ipp64f)1.0 / ((t1 - t0) / (Ipp64f)freq));
if ( umcRes == UMC_OK )
{
umcRes = dst.UnLockInputBuffer(&out);
if ( umcRes != UMC_OK )
break;
Ipp64f time = -1;
while ( UMC_ERR_TIMEOUT == dst.GetRenderFrame(&time) );
umcRes = dst.RenderFrame();
if ( umcRes != UMC_OK )
break;
}
nframes++;
} // while()
fps = (Ipp64f)(freq / ((Ipp64f)total / nframes));
vm_string_printf(VM_STRING("processed %d frames, with avg performance %4.1f FPS\n"), nframes, fps);
return umcRes;
} // DecodeMJPEGVideo()
int main(Ipp32u argc, vm_char* argv[])
{
ippStaticInit();
copyright();
ipp_version();
if ( argc > 1 )
DecodeMJPEGVideo(argv[1]);
else
vm_string_printf(VM_STRING("expected AVI file name"));
return 0;
} // main()
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page