Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
6815 Discussions

I have some problems in writing avi file, can anybody help me?

chyhu
Beginner
649 Views

the encode func is ippiBGRToYCbCr420_8u_AC4P3R
here a part of my code, the question are below
// how to fill aviStreamInfo?
// how to fill aviCompressOptions?
//how to fill bitmapInfoHeader?
//////////////////////////////////////

#define FRAME_LOCKBUFFER( PTR_FRAME, PTR_FUNC, PTR_DATA )
do
{
umcSts = PTR_FRAME->PTR_FUNC( &PTR_DATA );
if ( ( UMC::UMC_NOT_ENOUGH_DATA == umcSts )
|| ( UMC::UMC_NOT_ENOUGH_BUFFER == umcSts ))
{
vm_time_sleep(5);
}

} while ( ( UMC::UMC_NOT_ENOUGH_DATA == umcSts )
|| ( UMC::UMC_NOT_ENOUGH_BUFFER == umcSts ));

if ( UMC::UMC_OK != umcSts )
{
break;
}


#define FRAME_UNLOCKBUFFER( PTR_FRAME, PTR_FUNC, PTR_DATA )
umcSts = PTR_FRAME->PTR_FUNC( &PTR_DATA );
if ( UMC::UMC_OK != umcSts )
{
break;
}

struct IPPSpec_Infos_t
{
// path info
TCHAR FileAvis[MAX_PATH];
TCHAR Paths[MAX_PATH];


// encoder info
UMC::VideoEncoder*pEncoder;
UMC::VideoEncoderParams*pParams;

UMC::SampleBufferVideoFrames[1];
UMC::SampleBufferCompressedFrames[1];


// encoder spec
UINTSpecFmt;
UINTSpecFilter;


// capture buffer spec: backbuffer
Ipp32sSnapPitch;
Ipp32sSnapInPitch;

boolSnapResize;
IppiSizeSnapDest;
IppiFactorSnapFactor;
IppiSizeSnapViewport;

//Ipp32sSnapByte;
//Ipp32sSnapPitch;
//IppiSizeSnapCanvas;

// thread info
vm_threadhTh rSave[1];
vm_threadhThrEncoder[1];

vm_eventhThrEtExit[1];
vm_eventhThrEtSave[1];
vm_eventhThrEtEncoder[1];


// frame info
floatnFrameRate;
floatnFrameWeight;

UINTnFrameCapture;
UINTnFrameRecord;

vm_ticknFrameTimes;
vm_ticknFrameFrequency;

UINTnFrameSave;
UINTnFrameEncoder;
UINTnFrameSampling;

};

unsigned int IPP_ThreadSaveing( void* Parameter )
{
// get spec info pointer
IPPSpec_Infos_t* pSpecInfo = ( IPPSpec_Infos_t* )( Parameter );
assert( pSpecInfo != NULL );


// init local info
UMC::VideoEncoder* pEncoder = pSpecInfo->pEncoder;
UMC::VideoEncoderParams* pParams = pSpecInfo->pParams;
UMC::VideoDatacompressed_data;
UMC::StatusumcSts = UMC::UMC_OK;
HRESULT hr = E_FAIL;

AVIFileInit();
AVISTREAMINFO aviStreamInfo;
PAVIFILE pAviFile = NULL;
PAVISTREAM pAviStream = NULL;
PAVISTREAM pAviCompressedStream = NULL;
AVICOMPRESSOPTIONS aviCompressOptions;
BITMAPINFOHEADER bitmapInfoHeader;

pSpecInfo->nFrameSave = 0;

hr = AVIFileOpen(&pAviFile, pSpecInfo->FileAvis, OF_WRITE | OF_CREATE,NULL);
if ( !pAviFile )
{
AVIFileExit();
return 0x1001;
}

// how to fill aviStreamInfo?

hr = AVIFileCreateStream(pAviFile, &pAviStream, &aviStreamInfo);

if (!pAviStream)
{
AVIFileClose(pAviFile);
AVIFileExit();
return 0x1001;
}

// how to fill aviCompressOptions?
hr = AVIMakeCompressedStream(&pAviCompressedStream, pAviStream, &aviCompressOptions, NULL);
if (!pAviCompressedStream)
{
AVIStreamClose(pAviStream);
AVIFileClose(pAviFile);
AVIFileExit();
return 0x1001;
}

//how to fill bitmapInfoHeader?
hr = AVIStreamSetFormat(pAviCompressedStream, pSpecInfo->nFrameSave, &bitmapInfoHeader,sizeof(bitmapInfoHeader));

// for
HANDLE hEventWait[] = { pSpecInfo->hThrEtSave[0].handle, pSpecInfo->hThrEtExit[0].handle };
DWORD hEventCount = 2;

while ( true )
{
DWORD hWait = ::WaitForMultipleObjects( hEventCount, &hEventWait[0], FALSE, INFINITE );
if ( hWait != WAIT_OBJECT_0 )
{
break ;
}

vm_event_reset( pSpecInfo->hThrEtSave );
while ( UMC::UMC_OK == umcSts )
{
// get source buffer
FRAME_LOCKBUFFER( pSpecInfo->CompressedFrames, LockOutputBuffer, compressed_data );


hr = AVIStreamWrite(pAviCompressedStream, // stream pointer
pSpecInfo->nFrameSave, // time of this frame
1, // number to write
compressed_data.GetDataPointer(),
(long)compressed_data.GetDataSize(), // size of this frame
AVIIF_KEYFRAME, NULL, NULL);

compressed_data.SetDataSize(0);
FRAME_UNLOCKBUFFER( pSpecInfo->CompressedFrames, UnLockOutputBuffer, compressed_data );
pSpecInfo->nFrameSave ++;
}

}

AVIStreamClose(pAviCompressedStream);
AVIStreamClose(pAviStream);
AVIFileClose(pAviFile);
AVIFileExit();
return UMC::UMC_OK;
}

0 Kudos
3 Replies
chyhu
Beginner
649 Views

thank you very much!

0 Kudos
chyhu
Beginner
649 Views
the problem has beenresolved, thank you for your attention!
0 Kudos
Vladimir_Dudnik
Employee
649 Views

Hello,

I'm glad you solve your issue :)

Regards,
Vladimir

0 Kudos
Reply