static void test_ash1_corruption2(void) { COMMON_AVI_HEADERS cah; char filename[MAX_PATH]; PAVIFILE pFile; int res; PAVISTREAM pStream1; AVISTREAMINFOA asi1; GetTempPathA(MAX_PATH, filename); strcpy(filename+strlen(filename), testfilename); /* Corrupt the block alignment in the audio format header */ init_test_struct(&cah); cah.pcmwf.wf.nBlockAlign = 0xdead; create_avi_file(&cah, filename); res = AVIFileOpenA(&pFile, filename, OF_SHARE_DENY_WRITE, 0L); ok(res == 0, "Unable to open file: error=%u\n", res); res = AVIFileGetStream(pFile, &pStream1, 0, 1); ok(res == 0, "Unable to open audio stream: error=%u\n", res); ok(AVIStreamInfoA(pStream1, &asi1, sizeof(asi1)) == 0, "Unable to read stream info\n"); /* The result will also be the corrupt value, as explained above. */ ok(asi1.dwSampleSize == 0xdead, "got 0x%x (expected 0xdead)\n", asi1.dwSampleSize); AVIStreamRelease(pStream1); AVIFileRelease(pFile); ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename); }
static void test_ash1_corruption(void) { COMMON_AVI_HEADERS cah; char filename[MAX_PATH]; PAVIFILE pFile; int res; PAVISTREAM pStream1; AVISTREAMINFOA asi1; GetTempPathA(MAX_PATH, filename); strcpy(filename+strlen(filename), testfilename); /* Corrupt the sample size in the audio stream header */ init_test_struct(&cah); cah.ash1.dwSampleSize = 0xdeadbeef; create_avi_file(&cah, filename); res = AVIFileOpenA(&pFile, filename, OF_SHARE_DENY_WRITE, 0L); ok(res == 0, "Unable to open file: error=%u\n", res); res = AVIFileGetStream(pFile, &pStream1, 0, 1); ok(res == 0, "Unable to open audio stream: error=%u\n", res); res = AVIStreamInfoA(pStream1, &asi1, sizeof(asi1)); ok(res == 0, "Unable to read stream info: error=%u\n", res); /* The result will still be 2, because the value is dynamically replaced with the nBlockAlign value from the stream format header. The next test will prove this */ ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize); AVIStreamRelease(pStream1); AVIFileRelease(pFile); ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename); }
/*********************************************************************** * AVIStreamInfo (AVIFILE.162) */ HRESULT WINAPI AVIStreamInfo16(PAVISTREAM pstream, LPAVISTREAMINFO16 asi16, LONG size) { AVISTREAMINFOA asi; HRESULT hr; if (!asi16) return AVIStreamInfoA(pstream, NULL, size); if (size < sizeof(AVISTREAMINFO16)) return AVIERR_BADSIZE; hr = AVIStreamInfoA(pstream, &asi, sizeof(asi)); if (SUCCEEDED(hr)) { asi16->fccType = asi.fccType; asi16->fccHandler = asi.fccHandler; asi16->dwFlags = asi.dwFlags; asi16->dwCaps = asi.dwCaps; asi16->wPriority = asi.wPriority; asi16->wLanguage = asi.wLanguage; asi16->dwScale = asi.dwScale; asi16->dwRate = asi.dwRate; asi16->dwStart = asi.dwStart; asi16->dwLength = asi.dwLength; asi16->dwInitialFrames = asi.dwInitialFrames; asi16->dwSuggestedBufferSize = asi.dwSuggestedBufferSize; asi16->dwQuality = asi.dwQuality; asi16->dwSampleSize = asi.dwSampleSize; asi16->rcFrame.left = asi.rcFrame.left; asi16->rcFrame.top = asi.rcFrame.top; asi16->rcFrame.right = asi.rcFrame.right; asi16->rcFrame.bottom = asi.rcFrame.bottom; asi16->dwEditCount = asi.dwEditCount; asi16->dwFormatChangeCount = asi.dwFormatChangeCount; memcpy(&asi16->szName, &asi.szName, sizeof(asi.szName)); } return hr; }
static void test_default_data(void) { COMMON_AVI_HEADERS cah; char filename[MAX_PATH]; PAVIFILE pFile; int res; LONG lSize; PAVISTREAM pStream0; PAVISTREAM pStream1; AVISTREAMINFOA asi0, asi1; WAVEFORMATEX wfx; GetTempPathA(MAX_PATH, filename); strcpy(filename+strlen(filename), testfilename); init_test_struct(&cah); create_avi_file(&cah, filename); res = AVIFileOpenA(&pFile, filename, OF_SHARE_DENY_WRITE, 0L); ok(res != AVIERR_BADFORMAT, "Unable to open file: error1=%u\n", AVIERR_BADFORMAT); ok(res != AVIERR_MEMORY, "Unable to open file: error2=%u\n", AVIERR_MEMORY); ok(res != AVIERR_FILEREAD, "Unable to open file: error3=%u\n", AVIERR_FILEREAD); ok(res != AVIERR_FILEOPEN, "Unable to open file: error4=%u\n", AVIERR_FILEOPEN); ok(res != REGDB_E_CLASSNOTREG, "Unable to open file: error5=%u\n", REGDB_E_CLASSNOTREG); ok(res == 0, "Unable to open file: error=%u\n", res); res = AVIFileGetStream(pFile, &pStream0, 0, 0); ok(res == 0, "Unable to open video stream: error=%u\n", res); res = AVIFileGetStream(pFile, &pStream1, 0, 1); ok(res == 0, "Unable to open audio stream: error=%u\n", res); res = AVIStreamInfoA(pStream0, &asi0, sizeof(asi0)); ok(res == 0, "Unable to read stream info: error=%u\n", res); res = AVIStreamInfoA(pStream1, &asi1, sizeof(asi1)); ok(res == 0, "Unable to read stream info: error=%u\n", res); res = AVIStreamReadFormat(pStream0, AVIStreamStart(pStream1), NULL, &lSize); ok(res == 0, "Unable to read format size: error=%u\n", res); res = AVIStreamReadFormat(pStream1, AVIStreamStart(pStream1), &wfx, &lSize); ok(res == 0, "Unable to read format: error=%u\n", res); ok(asi0.fccType == streamtypeVIDEO, "got 0x%x (expected streamtypeVIDEO)\n", asi0.fccType); ok(asi0.fccHandler == 0x30323449, "got 0x%x (expected 0x30323449)\n", asi0.fccHandler); ok(asi0.dwFlags == 0, "got %u (expected 0)\n", asi0.dwFlags); ok(asi0.wPriority == 0, "got %u (expected 0)\n", asi0.wPriority); ok(asi0.wLanguage == 0, "got %u (expected 0)\n", asi0.wLanguage); ok(asi0.dwScale == 1001, "got %u (expected 1001)\n", asi0.dwScale); ok(asi0.dwRate == 30000, "got %u (expected 30000)\n", asi0.dwRate); ok(asi0.dwStart == 0, "got %u (expected 0)\n", asi0.dwStart); ok(asi0.dwLength == 1, "got %u (expected 1)\n", asi0.dwLength); ok(asi0.dwInitialFrames == 0, "got %u (expected 0)\n", asi0.dwInitialFrames); ok(asi0.dwSuggestedBufferSize == 0, "got %u (expected 0)\n", asi0.dwSuggestedBufferSize); ok(asi0.dwQuality == 0xffffffff, "got 0x%x (expected 0xffffffff)\n", asi0.dwQuality); ok(asi0.dwSampleSize == 0, "got %u (expected 0)\n", asi0.dwSampleSize); ok(asi0.rcFrame.left == 0, "got %u (expected 0)\n", asi0.rcFrame.left); ok(asi0.rcFrame.top == 0, "got %u (expected 0)\n", asi0.rcFrame.top); ok(asi0.rcFrame.right == 8, "got %u (expected 8)\n", asi0.rcFrame.right); /* these are based on the values in the mah and not */ ok(asi0.rcFrame.bottom == 6, "got %u (expected 6)\n", asi0.rcFrame.bottom);/* on the ones in the ash which are 0 here */ ok(asi0.dwEditCount == 0, "got %u (expected 0)\n", asi0.dwEditCount); ok(asi0.dwFormatChangeCount == 0, "got %u (expected 0)\n", asi0.dwFormatChangeCount); ok(asi1.fccType == streamtypeAUDIO, "got 0x%x (expected streamtypeVIDEO)\n", asi1.fccType); ok(asi1.fccHandler == 0x1, "got 0x%x (expected 0x1)\n", asi1.fccHandler); ok(asi1.dwFlags == 0, "got %u (expected 0)\n", asi1.dwFlags); ok(asi1.wPriority == 0, "got %u (expected 0)\n", asi1.wPriority); ok(asi1.wLanguage == 0, "got %u (expected 0)\n", asi1.wLanguage); ok(asi1.dwScale == 1, "got %u (expected 1)\n", asi1.dwScale); ok(asi1.dwRate == 11025, "got %u (expected 11025)\n", asi1.dwRate); ok(asi1.dwStart == 0, "got %u (expected 0)\n", asi1.dwStart); ok(asi1.dwLength == 1637, "got %u (expected 1637)\n", asi1.dwLength); ok(asi1.dwInitialFrames == 0, "got %u (expected 0)\n", asi1.dwInitialFrames); ok(asi1.dwSuggestedBufferSize == 0, "got %u (expected 0)\n", asi1.dwSuggestedBufferSize); ok(asi1.dwQuality == 0xffffffff, "got 0x%x (expected 0xffffffff)\n", asi1.dwQuality); ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize); ok(asi1.rcFrame.left == 0, "got %u (expected 0)\n", asi1.rcFrame.left); ok(asi1.rcFrame.top == 0, "got %u (expected 0)\n", asi1.rcFrame.top); ok(asi1.rcFrame.right == 0, "got %u (expected 0)\n", asi1.rcFrame.right); ok(asi1.rcFrame.bottom == 0, "got %u (expected 0)\n", asi1.rcFrame.bottom); ok(asi1.dwEditCount == 0, "got %u (expected 0)\n", asi1.dwEditCount); ok(asi1.dwFormatChangeCount == 0, "got %u (expected 0)\n", asi1.dwFormatChangeCount); ok(wfx.wFormatTag == 1, "got %u (expected 1)\n",wfx.wFormatTag); ok(wfx.nChannels == 2, "got %u (expected 2)\n",wfx.nChannels); ok(wfx.wFormatTag == 1, "got %u (expected 1)\n",wfx.wFormatTag); ok(wfx.nSamplesPerSec == 11025, "got %u (expected 11025)\n",wfx.nSamplesPerSec); ok(wfx.nAvgBytesPerSec == 22050, "got %u (expected 22050)\n",wfx.nAvgBytesPerSec); ok(wfx.nBlockAlign == 2, "got %u (expected 2)\n",wfx.nBlockAlign); AVIStreamRelease(pStream0); AVIStreamRelease(pStream1); AVIFileRelease(pFile); ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename); }
static void test_EditStreamSetInfo(void) { PAVISTREAM stream = NULL; HRESULT hres; AVISTREAMINFOA info, info2; hres = CreateEditableStream(&stream, NULL); ok(hres == AVIERR_OK, "got 0x%08X, expected AVIERR_OK\n", hres); /* Size parameter is somehow checked (notice the crash with size=-1 below) */ hres = EditStreamSetInfoA(stream, NULL, 0); ok( hres == AVIERR_BADSIZE, "got 0x%08X, expected AVIERR_BADSIZE\n", hres); hres = EditStreamSetInfoA(stream, NULL, sizeof(AVISTREAMINFOA)-1 ); ok( hres == AVIERR_BADSIZE, "got 0x%08X, expected AVIERR_BADSIZE\n", hres); if(0) { /* Crashing - first parameter not checked */ EditStreamSetInfoA(NULL, &info, sizeof(info) ); /* Crashing - second parameter not checked */ EditStreamSetInfoA(stream, NULL, sizeof(AVISTREAMINFOA) ); EditStreamSetInfoA(stream, NULL, -1); } hres = AVIStreamInfoA(stream, &info, sizeof(info) ); ok( hres == 0, "got 0x%08X, expected 0\n", hres); /* Does the function check what's it's updating ? */ #define IS_INFO_UPDATED(m) do { \ hres = EditStreamSetInfoA(stream, &info, sizeof(info) ); \ ok( hres == 0, "got 0x%08X, expected 0\n", hres); \ hres = AVIStreamInfoA(stream, &info2, sizeof(info2) ); \ ok( hres == 0, "got 0x%08X, expected 0\n", hres); \ ok( info2.m == info.m, "EditStreamSetInfo did not update "#m" parameter\n" ); \ } while(0) info.dwStart++; IS_INFO_UPDATED(dwStart); info.dwStart = 0; IS_INFO_UPDATED(dwStart); info.wPriority++; IS_INFO_UPDATED(wPriority); info.wPriority = 0; IS_INFO_UPDATED(wPriority); info.wLanguage++; IS_INFO_UPDATED(wLanguage); info.wLanguage = 0; IS_INFO_UPDATED(wLanguage); info.dwScale++; IS_INFO_UPDATED(dwScale); info.dwScale = 0; IS_INFO_UPDATED(dwScale); info.dwRate++; IS_INFO_UPDATED(dwRate); info.dwRate = 0; IS_INFO_UPDATED(dwRate); info.dwQuality++; IS_INFO_UPDATED(dwQuality); info.dwQuality = 0; IS_INFO_UPDATED(dwQuality); info.dwQuality = -2; IS_INFO_UPDATED(dwQuality); info.dwQuality = ICQUALITY_HIGH+1; IS_INFO_UPDATED(dwQuality); info.rcFrame.left = 0; IS_INFO_UPDATED(rcFrame.left); info.rcFrame.top = 0; IS_INFO_UPDATED(rcFrame.top); info.rcFrame.right = 0; IS_INFO_UPDATED(rcFrame.right); info.rcFrame.bottom = 0; IS_INFO_UPDATED(rcFrame.bottom); info.rcFrame.left = -1; IS_INFO_UPDATED(rcFrame.left); info.rcFrame.top = -1; IS_INFO_UPDATED(rcFrame.top); info.rcFrame.right = -1; IS_INFO_UPDATED(rcFrame.right); info.rcFrame.bottom = -1; IS_INFO_UPDATED(rcFrame.bottom); AVIStreamRelease(stream); #undef IS_INFO_UPDATED }