0
votes

I am doing android native development using libjpeg9. The image data I get from android camera is compressed in jpeg format. Then the data is transferred to native c++ function as an unsigned char* array. As required by function jpeg_mem_src JPP((j_decompress_ptr cinfo,unsigned char * inbuffer,unsigned long insize)) of libjpeg9, the size of the array which is the 'inbuffer' parameter should be provided.

As far as I know, sizeof function cannot be used to get the size of the array because it is only a pointer. We also do not want to change the interface of our c++ function to transfer the size of the array.

So I want to get the size of the array from the header of jpeg. Does anyone know the position of the header where I can get the size of this jpeg image array size?

Any help will be appreciated!

1
Are you asking how to extract the size of the JPEG file (array) from within the JPEG file (array)? That information isn't likely to be present -- why would anyone store the length of a file inside the file? -- and consulting this seems to confirm that suspicion. - ikegami
Re "We also do not want to change the interface of our c++ function to transfer the size of the array", It makes no sense to pass an array to a function without passing its length too (unless the array is nul-terminated or similar, which isn't the case here). - ikegami
@ikegami ,thank you for your reply! The reason we do not want to change the interface of our c++ function is that we used opencv function imdecode to decompress the jpeg image we get from android camera. This does not required to provide the size of the array. However, we realize imdecode is too time consuming, so we want to use libjpeg to replace this function. Someone says imdecode also uses libjpeg. Is that true? - KleinXin

1 Answers

0
votes

Does anyone know the position of the header where I can get the size of this jpeg image array size?

There isn't one.

Any help will be appreciated!

Change the interface of your c++ function to transfer the size of the array.