Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.61 KB | None | 0 0
  1. HRESULT AddAviFrame(HAVI avi, DIBSECTION *dibs)
  2. {
  3.     if( avi == NULL ) return AVIERR_BADHANDLE;
  4.     TAviUtil *au = (TAviUtil*)avi;
  5.     if( au->iserr ) return AVIERR_ERROR;
  6.     //
  7.     if( au->ps == 0 ) // create the stream, if it wasn't there before
  8.     {
  9.         AVISTREAMINFO strhdr; ZeroMemory(&strhdr, sizeof(strhdr));
  10.         strhdr.fccType = streamtypeVIDEO;// stream type
  11.         strhdr.fccHandler = 0;
  12.         strhdr.dwScale = au->period;
  13.         strhdr.dwRate = 1000;
  14.         strhdr.dwSuggestedBufferSize = dibs->dsBmih.biSizeImage;
  15.         SetRect(&strhdr.rcFrame, 0, 0, dibs->dsBmih.biWidth, dibs->dsBmih.biHeight);
  16.         HRESULT hr = AVIFileCreateStream(au->pfile, &au->ps, &strhdr);
  17.         if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
  18.     }
  19.     //
  20.     // create an empty compression, if the user hasn't set any
  21.     if( au->psCompressed == 0 ) {
  22.         AVICOMPRESSOPTIONS opts; ZeroMemory(&opts, sizeof(opts));
  23.         opts.fccHandler = mmioFOURCC('D', 'I', 'B', ' ');
  24.         HRESULT hr = AVIMakeCompressedStream(&au->psCompressed, au->ps, &opts, NULL);
  25.         if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
  26.         hr = AVIStreamSetFormat(au->psCompressed, 0, &dibs->dsBmih, dibs->dsBmih.biSize + dibs->dsBmih.biClrUsed*sizeof(RGBQUAD));
  27.         if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
  28.     }
  29.     //
  30.     //Now we can add the frame
  31.     HRESULT hr = AVIStreamWrite(au->psCompressed, au->nframe, 1, dibs->dsBm.bmBits, dibs->dsBmih.biSizeImage, AVIIF_KEYFRAME, NULL, NULL);
  32.     if( hr != AVIERR_OK ) { au->iserr = true; return hr; }
  33.     au->nframe++; return S_OK;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement