fixing jpegs on windows, adding some more assertions.

This commit is contained in:
pavlov%netscape.com 2001-03-20 23:06:29 +00:00
Родитель 3361e48529
Коммит fc77739bc6
3 изменённых файлов: 27 добавлений и 18 удалений

Просмотреть файл

@ -86,11 +86,12 @@ nsJPEGDecoder::nsJPEGDecoder()
mSamples = nsnull; mSamples = nsnull;
mSamples3 = nsnull; mSamples3 = nsnull;
mRGBPadRow = nsnull;
mRGBPadRowLength = 0;
mBytesToSkip = 0; mBytesToSkip = 0;
memset(&mInfo, 0, sizeof(jpeg_decompress_struct)); memset(&mInfo, 0, sizeof(jpeg_decompress_struct));
mRGBPadRow = nsnull;
mCompletedPasses = 0; mCompletedPasses = 0;
@ -108,6 +109,8 @@ nsJPEGDecoder::~nsJPEGDecoder()
PR_Free(mBuffer); PR_Free(mBuffer);
if (mBackBuffer) if (mBackBuffer)
PR_Free(mBackBuffer); PR_Free(mBackBuffer);
if (mRGBPadRow)
PR_Free(mRGBPadRow);
} }
@ -298,28 +301,30 @@ NS_IMETHODIMP nsJPEGDecoder::WriteFrom(nsIInputStream *inStr, PRUint32 count, PR
* jpeg_start_compress(). * jpeg_start_compress().
*/ */
int row_stride; int row_stride;
#ifdef XP_MAC
if(mInfo.output_components == 1) if(mInfo.output_components == 1)
row_stride = mInfo.output_width * 1; row_stride = mInfo.output_width;
else else
row_stride = mInfo.output_width * 4; row_stride = mInfo.output_width * 4; // use 4 instead of mInfo.output_components
#else // so we don't have to fuss with byte alignment.
row_stride = mInfo.output_width * mInfo.output_components; // Mac wants 4 anyways.
#endif
mSamples = (*mInfo.mem->alloc_sarray)((j_common_ptr) &mInfo, mSamples = (*mInfo.mem->alloc_sarray)((j_common_ptr) &mInfo,
JPOOL_IMAGE, JPOOL_IMAGE,
row_stride, 1); row_stride, 1);
mRGBPadRow = (PRUint8*) PR_MALLOC(row_stride); #if defined(XP_PC) || defined(XP_MAC)
memset(mRGBPadRow, 0, row_stride); // allocate buffer to do byte flipping if needed
if (mInfo.output_components == 3) {
mRGBPadRow = (PRUint8*) PR_MALLOC(row_stride);
mRGBPadRowLength = row_stride;
memset(mRGBPadRow, 0, mRGBPadRowLength);
}
#endif
/* Allocate RGB buffer for conversion from greyscale. */ /* Allocate RGB buffer for conversion from greyscale. */
if (mInfo.output_components != 3) { if (mInfo.output_components != 3) {
#ifdef XP_MAC
row_stride = mInfo.output_width * 4; row_stride = mInfo.output_width * 4;
#else
row_stride = mInfo.output_width * 3;
#endif
mSamples3 = (*mInfo.mem->alloc_sarray)((j_common_ptr) &mInfo, mSamples3 = (*mInfo.mem->alloc_sarray)((j_common_ptr) &mInfo,
JPOOL_IMAGE, JPOOL_IMAGE,
row_stride, 1); row_stride, 1);
@ -487,12 +492,10 @@ nsJPEGDecoder::OutputScanlines(int num_scanlines)
} else { } else {
/* 24-bit color image */ /* 24-bit color image */
#ifdef XP_PC #ifdef XP_PC
memset(mRGBPadRow, 0, mInfo.output_width * mInfo.output_components); memset(mRGBPadRow, 0, mInfo.output_width * 4);
PRUint8 *ptrOutputBuf = mRGBPadRow; PRUint8 *ptrOutputBuf = mRGBPadRow;
JSAMPLE *j1 = mSamples[0]; JSAMPLE *j1 = mSamples[0];
const JSAMPLE *j1end = j1 + (mInfo.output_width * mInfo.output_components);
for (PRUint32 i=0;i<mInfo.output_width;++i) { for (PRUint32 i=0;i<mInfo.output_width;++i) {
ptrOutputBuf[2] = *j1++; ptrOutputBuf[2] = *j1++;
ptrOutputBuf[1] = *j1++; ptrOutputBuf[1] = *j1++;
@ -500,7 +503,7 @@ nsJPEGDecoder::OutputScanlines(int num_scanlines)
ptrOutputBuf += 3; ptrOutputBuf += 3;
} }
samples = ptrOutputBuf; samples = mRGBPadRow;
#else #else
#ifdef XP_MAC #ifdef XP_MAC
memset(mRGBPadRow, 0, mInfo.output_width * 4); memset(mRGBPadRow, 0, mInfo.output_width * 4);

Просмотреть файл

@ -96,6 +96,7 @@ public:
JSAMPARRAY mSamples; JSAMPARRAY mSamples;
JSAMPARRAY mSamples3; JSAMPARRAY mSamples3;
PRUint8* mRGBPadRow; PRUint8* mRGBPadRow;
PRUint32 mRGBPadRowLength;
PRInt32 mCompletedPasses; PRInt32 mCompletedPasses;
PRInt32 mPasses; PRInt32 mPasses;

Просмотреть файл

@ -178,18 +178,21 @@ PRBool imgRequest::RemoveFromCache()
/* readonly attribute wstring name; */ /* readonly attribute wstring name; */
NS_IMETHODIMP imgRequest::GetName(PRUnichar * *aName) NS_IMETHODIMP imgRequest::GetName(PRUnichar * *aName)
{ {
NS_NOTYETIMPLEMENTED("imgRequest::GetName");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
/* boolean isPending (); */ /* boolean isPending (); */
NS_IMETHODIMP imgRequest::IsPending(PRBool *_retval) NS_IMETHODIMP imgRequest::IsPending(PRBool *_retval)
{ {
NS_NOTYETIMPLEMENTED("imgRequest::IsPending");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
/* readonly attribute nsresult status; */ /* readonly attribute nsresult status; */
NS_IMETHODIMP imgRequest::GetStatus(nsresult *aStatus) NS_IMETHODIMP imgRequest::GetStatus(nsresult *aStatus)
{ {
NS_NOTYETIMPLEMENTED("imgRequest::GetStatus");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -218,12 +221,14 @@ NS_IMETHODIMP imgRequest::Cancel(nsresult status)
/* void suspend (); */ /* void suspend (); */
NS_IMETHODIMP imgRequest::Suspend() NS_IMETHODIMP imgRequest::Suspend()
{ {
NS_NOTYETIMPLEMENTED("imgRequest::Suspend");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
/* void resume (); */ /* void resume (); */
NS_IMETHODIMP imgRequest::Resume() NS_IMETHODIMP imgRequest::Resume()
{ {
NS_NOTYETIMPLEMENTED("imgRequest::Resume");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }