title: android findJpegSize error?
body: <p>In the file
  <a href="https://android.googlesource.com/platform/frameworks/av/+/android-4.4w_r1/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp" rel="nofollow">https://android.googlesource.com/platform/frameworks/av/+/android-4.4w_r1/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp</a></p>
  
  <pre><code>// Return the size of the JPEG, 0 indicates failure
  size_t JpegProcessor::findJpegSize(uint8_t* jpegBuffer, size_t maxSize) {
  ...
  }
  </code></pre>
  
  <p>scans the jpegBuffer to find its size. 
  It looks for the length field after SOI (0xFFD8) but according to standard there is no length after SOI. In my case SOI is directly followed by APP0 (0xFFE0) which causes the FFE0 is taken as size of the segment. </p>
  
  <p>My JPEG also contains the SOS marker. The SOS marker is not followed by 2 bytes of length. There is length of the segment there but presented differently. </p>
  
  <p>Can this be a bug? </p>
  
  <p>Here is the jpeg structure. 
  <a href="http://en.wikipedia.org/wiki/JPEG#Syntax_and_structure" rel="nofollow">http://en.wikipedia.org/wiki/JPEG#Syntax_and_structure</a></p>