Community
cancel
Showing results for 
Search instead for 
Did you mean: 
77 Views

JPEG save corrupted

Hello, I have a very simple program in linux.

cout << "HELLO!"< string image="/home/ferru001/gray_images/00000052.jpg";
CIppImage gray_image;
CStdFileInput in;
CStdFileOutput out;
in.Open(image.c_str());
PARAMS_JPEG m_param_jpeg;
JERRCODE jerr;
m_param_jpeg.nthreads=1;
m_param_jpeg.use_qdct=false;
m_param_jpeg.quality=100;
jerr = ReadImageJPEG(in,m_param_jpeg,gray_image);
in.Close();
if( JPEG_OK == jerr ) {
cout << "JPEG READ OK" << endl;
cout << "WRITING JPEG" << endl;
out.Open( "/home/ferru001/graytest.jpg" );
jerr = SaveImageJPEG ( gray_image, m_param_jpeg, out );
out.Close();
if( JPEG_OK == jerr ){
cout << "SAVE SUCCESS!" << endl;
}else{
cout << "SAVE FAILED"< }
}


the ReadImageJPEG and SaveImageJPEG are form UIC.

The outputted image comes out corrupt. Only a segment of it is written and when I open it in GIMP the following comes up:

Corrupt JPEG data: 15046 extraenous bytes after marker 0xd9 EXIF data will be ignored

Corrupt JPEG data: found marker 0xd9 instead of RST0

Corrupt JPEG data: premature of data segment.

Any ideas why this is happening? Am I forgetting to do something?

thanks!
0 Kudos
5 Replies
77 Views

By the way I'm using IPP 6.1 thanks.
Vladimir_Dudnik
Employee
77 Views

Can you try to reproduce these steps with UIC applications (either picnic or uic_transcoder_con)? Will you get corrupted image with these applications as well?

Regards,
Vladimir
77 Views

I tried picnic and the same thing does not happen. The image saved comes out fine.
77 Views

Hello,
I re-wrote my small program to include more JPEG_PARAMS:

params_jpeg.color = (nChannels == 1) ? JC_GRAY : (nChannels == 3) ? JC_YCBCR : JC_YCCK;
params_jpeg.comment_size = 0;
params_jpeg.huffman_opt = 0;
params_jpeg.mode = JPEG_BASELINE;
params_jpeg.point_transform = 0;
params_jpeg.predictor = 0;
params_jpeg.quality = 100;
params_jpeg.restart_interval = 0;
params_jpeg.sampling = JS_444;


now it works fine... not sure why not setting these params resulted in corrupt JPEG...

thank you Vlad for responding to me.
Vladimir_Dudnik
Employee
77 Views

You are welcome :)

I think if you left same parameters not initialized they may influence the codec behaviour.
For example, if JPEG comments control parameters are not zero then encoder will try to embedd comment string into encoded JPEG (and if these parameters not initialized properly comment will be taken from random memory address or comment string will have random length)

Regards,
Vladimir
Reply