Hello all,
I'm working on a jpeg decoder and I finally have something that can decode jpeg files loaded in memory and display them in a window. It will decode the most common types of jpeg (except progressive jpegs...)
There is a decoding library and a sample program. The interface of the decoder is very simple :
It is not super fast because I use floating point SSE for all calculations (IDCT, rgb conversion...) The benefit is that it should be precise and I will be able to extend it to support jpeg with 12-bit precision.
Bugs and limitations :
- requires SSE
- 12-bit precision not supported
- supports only jpeg with sampling factor 1x1, 2x2, 2x1, 1x2
If you find a problem with an image could you send it to manhattan95@wanadoo.fr please ? Thanks.
I'm working on a jpeg decoder and I finally have something that can decode jpeg files loaded in memory and display them in a window. It will decode the most common types of jpeg (except progressive jpegs...)
There is a decoding library and a sample program. The interface of the decoder is very simple :
include jpeg_dec.inc
.data
img dword ?
.code
; decode a jpeg
INVOKE JPEG_Decode OFFSET jpeg_buffer, jpeg_size, OFFSET img, 0
cmp eax, JPEG_SUCCESS
jne Error
mov eax, img
ASSUME eax:PTR JPEGIMAGE
; use the image :
; [eax].width : image width
; [eax].height : image height
; [eax].pRGB : pointer to rgb data
; free the image
INVOKE JPEG_Free img
It is not super fast because I use floating point SSE for all calculations (IDCT, rgb conversion...) The benefit is that it should be precise and I will be able to extend it to support jpeg with 12-bit precision.
Bugs and limitations :
- requires SSE
- 12-bit precision not supported
- supports only jpeg with sampling factor 1x1, 2x2, 2x1, 1x2
If you find a problem with an image could you send it to manhattan95@wanadoo.fr please ? Thanks.
Hi,
It works for me, just that it could not open one file (probably progressive jpg since it gave the error format not support). Keep up the good job, mate.
It works for me, just that it could not open one file (probably progressive jpg since it gave the error format not support). Keep up the good job, mate.
wow, i can call this very impressive (altough i don't know exact how jpg's work). great job!
Thank you for your comments. I found why some images were not decoded correctly. I uploaded a new version of the files. Thanks.
Very impressive indeed!
The only two pictures it would not open were due to their size, recieved "can't allocate graphic object" error. This is great work :!:
I can't check your work just now, but I would be glad if it isn't as buggy as the image library from the MASM package. Keep up the (good) work :)
/siddhartha
/siddhartha
Impressive :alright:
Also found several images that return "format not supported", but the viewer renders the supported images really quickly.
Also found several images that return "format not supported", but the viewer renders the supported images really quickly.
Thank you all. I've found bugs with some malformed jpeg files. I have also found a big memory leak when the window was closed with a file opened :oops:
I have uploaded a new version that fix these bugs. If you are interested, there is also a sourceforge project at http://sourceforge.net/projects/jpegdec
I have uploaded a new version that fix these bugs. If you are interested, there is also a sourceforge project at http://sourceforge.net/projects/jpegdec
Hi Dr.Manhattan,
The link above gives:
:?
The link above gives:
Invalid Project
:?
Just remove the dot after it, thus you get:
http://sourceforge.net/projects/jpegdec
:-D
http://sourceforge.net/projects/jpegdec
:-D
Funly.
but the sample is C code,I wanna the masm code,would you like paste it?
thanks.
but the sample is C code,I wanna the masm code,would you like paste it?
thanks.
Funly.
but the sample is C code,I wanna the masm code,would you like paste it?
thanks.
Are you sure that the code on http://sourceforge.net/projects/jpegdec is C code? :shock:
thank your reply.
The viewer code is true C,I link it use Vc6.0 .
for this code,why it exit with error!
.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive
include windows.inc
include kernel32.inc
include user32.inc
include Comctl32.inc
include shell32.inc
includelib kernel32.lib
includelib user32.lib
includelib Comctl32.lib
includelib shell32.lib
include macros.asm
include jpeg_dec.inc
includelib jpeg_dec.lib
.const
IDD_DIALOG1 equ 101
.data?
hInstance dd ?
hFile dd ?
dwFileSize dd ?
lpJpegMemory dd ?
jimg dd ?
.code
DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL @dwBytesRead
mov eax,uMsg
.if eax==WM_INITDIALOG
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax == IDOK
invoke CreateFile,CTXT("test.JPG"),GENERIC_READ,FILE_SHARE_READ or FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
mov hFile,eax
invoke GetFileSize,hFile,NULL
mov dwFileSize,eax
invoke GlobalAlloc,GPTR,dwFileSize
mov lpJpegMemory,eax
invoke ReadFile,hFile,lpJpegMemory,dwFileSize,addr @dwBytesRead,0
invoke JPEG_Decode,lpJpegMemory,dwFileSize,addr jimg,NULL
.if eax==JPEG_SUCCESS
invoke MessageBox,NULL,CTXT("OK"),NULL,MB_OK
.endif
invoke JPEG_Free,addr jimg
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0
end start
The viewer code is true C,I link it use Vc6.0 .
for this code,why it exit with error!
.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive
include windows.inc
include kernel32.inc
include user32.inc
include Comctl32.inc
include shell32.inc
includelib kernel32.lib
includelib user32.lib
includelib Comctl32.lib
includelib shell32.lib
include macros.asm
include jpeg_dec.inc
includelib jpeg_dec.lib
.const
IDD_DIALOG1 equ 101
.data?
hInstance dd ?
hFile dd ?
dwFileSize dd ?
lpJpegMemory dd ?
jimg dd ?
.code
DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL @dwBytesRead
mov eax,uMsg
.if eax==WM_INITDIALOG
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax == IDOK
invoke CreateFile,CTXT("test.JPG"),GENERIC_READ,FILE_SHARE_READ or FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
mov hFile,eax
invoke GetFileSize,hFile,NULL
mov dwFileSize,eax
invoke GlobalAlloc,GPTR,dwFileSize
mov lpJpegMemory,eax
invoke ReadFile,hFile,lpJpegMemory,dwFileSize,addr @dwBytesRead,0
invoke JPEG_Decode,lpJpegMemory,dwFileSize,addr jimg,NULL
.if eax==JPEG_SUCCESS
invoke MessageBox,NULL,CTXT("OK"),NULL,MB_OK
.endif
invoke JPEG_Free,addr jimg
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0
end start
What kind of error does it give you? Is the error rerlated to the jpeg_decoder?
hi!
someone write the masm32's code to change JPEG file to BMP file use this lib ?
please paste the code,please,thanks
someone write the masm32's code to change JPEG file to BMP file use this lib ?
please paste the code,please,thanks