zzxxpp1011239740 / webp

Automatically exported from code.google.com/p/webp
0 stars 0 forks source link

Decoding failure on WinCE #133

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to write an webp viewer on WinCE, but got problem when decoding.

What steps will reproduce the problem?
...
WebPGetInfo(pBuffer,dwFileSizeLow,&Owidth,&Oheight);
...
WebPDecoderConfig config;
WebPDecBuffer* const output_buffer = &config.output;
WebPBitstreamFeatures* const bitstream = &config.input;
if(!WebPInitDecoderConfig(&config))
    ...
if(WebPGetFeatures(pBuffer, dwFileSizeLow, bitstream) != VP8_STATUS_OK)
    ...
int stride = 0;
stride = (Owidth*4+3)&(!3);
stride = Dwidthbytes;
...
config.output.colorspace = MODE_BGRA;
config.output.u.RGBA.rgba = (uint8_t*)pBmpBuf;
config.output.u.RGBA.stride = Owidth*4;
config.output.u.RGBA.size = BmpBufLen;
config.output.is_external_memory = 1;
if(WebPDecode(pBuffer, dwFileSizeLow, &config) != VP8_STATUS_OK) 
    ...

What is the expected output? What do you see instead?
expected:Decode API return an value
see:program stopped working and quit.

What version of the product are you using? On what operating system?
ver: 2.1 and git cloned one today.
OS:windows embedded CE 6.0 (Build 3122)

Please provide any additional information below.
1:The images are encoded by libwebp-0.2.1-windows-x86 cwebp.exe
2:The images are able to be decoded by libwebp-0.2.1-windows-x86 dwebp.exe and 
Chrome(on windows)
3:The code works fine when decoding lossless image,problem occurs when decoding 
lossy image.
4:I don't know how to debug application on wince, but I located that the 
problem happened in tree.c→VP8ParseIntraMode→for loop

Not much information, hope it helps.

Original issue reported on code.google.com by wye.MIA....@gmail.com on 13 Jan 2013 at 4:47

GoogleCodeExporter commented 9 years ago
more information:
1.CPU:s3c2440(ARM9)
2.Locatoin:
i = kYModesIntra4[2 * i + VP8GetBit(br, prob[i])];//happened in VP8GetBit() 
function
3.when error occurs:
x=0 y=3 i=0 ymode=0 prob[i]=231

4.the webp file:

Original comment by wye.MIA....@gmail.com on 14 Jan 2013 at 9:03

Attachments:

GoogleCodeExporter commented 9 years ago
Some questions and suggestions for debugging:

1) Does the same behavior happen with the simpler: WebPDecodeBGRA()?
2) Can you extract your code to e.g., windows and attempt the decode there 
rather than with dwebp?
3) Similar to (2) does this only happen on the native device or within the 
emulator -- you should be able to debug either with visual studio.

> stride = (Owidth*4+3)&(!3);

I'm assuming this is a transcription error (should be ~3) otherwise this will 
always be 0.

Original comment by jz...@google.com on 15 Jan 2013 at 1:24

GoogleCodeExporter commented 9 years ago
1) Thank you for pointing out the stride calculation is wrong .
The decoding problem should not be caused by stride calculation,because the 
code above was modified for reporting use, !3 should be an mistake in 
modification (if not, WebPDecode will return VP8_STATUS_INVALID_PARAM and will 
not call VP8ParseIntraMode).

2) I found that the first report I made is wrong , I mistook for tested the git 
cloned library.
Here is the correction:
The git cloned library works fine on both lossless and lossy image.
But the libwebp-0.2.1 not working on lossy image.

#####You seems fixed the issue after ver 0.2.1#####

3) On windows , dwebp.exe from libwebp-0.2.1-windows-x86.zip works fine.

4) I didn't install the emulator, I have only tested on native device. My 
development environment seems incomplete, windows didn't recognize the device. 
That's why I don't know how to debug.

5) The code I use now:
#define DECMODE MODE_BGR
#define DWIDTHBYTES (Dwidth*kModeBpp[DECMODE])

.....

VP8StatusCode StatusCode = VP8_STATUS_OK;

SetWindowTextW(hInfoWnd,wszFileName);

hFile = 
CreateFileW(wszFileName,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
CheckErr(hFile == INVALID_HANDLE_VALUE);

HANDLE hMap = CreateFileMapping(hFile,0,PAGE_READONLY,0,0,NULL);
CheckErr(!hMap);

const PBYTE pBuffer = (PBYTE)MapViewOfFile(hMap,FILE_MAP_READ,0,0,0);
CheckErr(!pBuffer);

DWORD dwFileSizeLow = GetFileSize(hFile,0);
CheckErr(!dwFileSizeLow);

CheckErr(!WebPGetInfo(pBuffer,dwFileSizeLow,&Owidth,&Oheight));

EnterCriticalSection(&csBmpBufAccess);
bEnteredCS = TRUE;

BOOL bRotate = FALSE;
BOOL bScale = TRUE;
bScale = GetDecHW(Owidth,Oheight,&Dwidth,&Dheight,&bRotate);
WebPDecoderConfig config;

CheckErr(!WebPInitDecoderConfig(&config));

StatusCode = WebPGetFeatures(pBuffer, dwFileSizeLow, &config.input);
if(StatusCode != VP8_STATUS_OK)
{
    wcscpy_s(szErrMsg,sizeof(szErrMsg),L"WebPGetFeatures");
    break;
}

if (bScale)
{
    config.options.use_scaling = TRUE;
    config.options.scaled_height = Dheight;
    config.options.scaled_width = Dwidth;
}

int stride = 0;
if (!bRotate)
{
    stride = (DWIDTHBYTES+3)&(~3);
}
else stride = DWIDTHBYTES;

size_t BmpBufLen = stride*Dheight;
bEnteredCS = TRUE;
if(pBmpBuf)
{
    PVOID p = pBmpBuf;
    pBmpBuf = 0;
    HeapFree(GetProcessHeap(),0,p);
}
pBmpBuf = (PBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,BmpBufLen);

config.output.colorspace = DECMODE;
config.output.u.RGBA.rgba = (uint8_t*)pBmpBuf;
config.output.u.RGBA.stride = stride;
config.output.u.RGBA.size = BmpBufLen;
config.output.is_external_memory = 1;

SetWindowTextW(hPaintWnd,L"Begin decode...");

StatusCode = WebPDecode(pBuffer, dwFileSizeLow, &config);

Original comment by wye.MIA....@gmail.com on 15 Jan 2013 at 3:58

GoogleCodeExporter commented 9 years ago
> 
> 2) I found that the first report I made is wrong , I mistook for tested the 
git cloned library.
> Here is the correction:
> The git cloned library works fine on both lossless and lossy image.
> But the libwebp-0.2.1 not working on lossy image.
> 
> #####You seems fixed the issue after ver 0.2.1#####
> 
Maybe. I'd still like to get to the bottom of this, there haven't been many 
code changes to the decode since v0.2.1.

> 3) On windows , dwebp.exe from libwebp-0.2.1-windows-x86.zip works fine.
> 
> 4) I didn't install the emulator, I have only tested on native device. My 
development environment seems incomplete, windows didn't recognize the device. 
That's why I don't know how to debug.
> 
> 5) The code I use now:
>

What I'd like to do is 2 things.
1) move this code over to windows to check the behavior.
2) drop the scale/WebPDecode and try WebPDecodeBGRA as a sanity check.

Original comment by jz...@google.com on 15 Jan 2013 at 8:24

GoogleCodeExporter commented 9 years ago
1) Move to windows, libwebp 0.2.1, no error occurs, while scaling or not 
scaling.
2) Cannot test WebPDecodeBGRA, since I returned the testing device to my 
classmate.

Original comment by wye.MIA....@gmail.com on 22 Jan 2013 at 2:30

GoogleCodeExporter commented 9 years ago
OK thanks for the update.
I'll close this issue for now since it's working for you with the latest code, 
but if the issue comes back up and you have something reproducible on a 
specific device/emulator, feel free to reopen this.

Original comment by jz...@google.com on 22 Jan 2013 at 10:26