Re: Jpeg Encoder: YCC Clipping error



On May 26, 7:46 am, Jeff Vidal <jeffvi...@xxxxxxxxx> wrote:
Hello,

I'm a student and I have to write a Jpeg encoder using matlab.
I wrote it, for me it looks all good but the generated JPEG files are
wrong.

For instance, this is what I get:www.gvidal.fr/misc/out.jpg

The middle of the image seems good though...

I have used a tool called "JPEGsnoof" for analyzing my jpg file, and I
get some:
ERROR: YCC clipped

Can somebody see my Jpeg file and tell me, if possible, what is wrong
in my encoder code ?
This would be great.

I'm the author of the tool, "JPEGsnoop" ( http://www.impulseadventure.com/photo/jpeg-snoop.html
),
not "snoof"! :). When the JPEG image is decoded, the tool will write
this message if
it encounters a DC component that has exceeded the limits
(-1024..+1023)
after summing all of the deltas from prior MCUs.

In your example, the image is specified as having no chroma
subsampling, so the MCU
sequence should still be Y Cb Cr (or, more completely, Ydc Yac CBdc
CBac CRdc CRac Ydc Yac CBdc CBac...).

The error indicates that the second row of MCUs (X=0, Y=1) has an
underflow in the Y component.

Your huffman tables define the variable-length code for "0" or "End of
Block" as:
Y(dc) = 0
Y(ac) = 100
C(dc) = 0
C(ac) = 0

This makes it pretty easy to hand-decode your SOS (Start of Scan)
segment:

With no chroma subsampling, we would expect a "no-change" (no-delta)
MCU to be
represented by the bit-stream:

0 100 0 0 0 0

This fits nicely into one byte: 0x40

I can see that your encoded file does in fact repeat this byte (or bit-
shifted versions) for
much of the image content. In other words, it would imply that your
original image
had large sections of flat color / intensity. Is this correct? What
does your original
image look like in the top-left corner or top row? Of course you are
also using
quantization tables that would create very high compression, so these
flat sections
are going to be expected to a degree.

Since the DC components are calculated by keeping a running total
starting from
the top-left MCU, it is very easy to see how the cumulative value can
underflow
if something gets out of sync.

In particular, we would typically expect there to be some
discontinuities in the DC value at
the start of every row in the image. The fact that your underflow
occured at the start of
a row suggests that your encoder's bitstream is not getting out of
synch / corrupted --
there may be a different problem.

As cr88192 points out, there are many things that can go wrong with
the encoding.
The JPEG bitstream doesn't provide much redundancy or indicators that
help us
identify where things get out of synchronization, so starting from a
code / algorithm
examination may be a faster solution.

If you post a link to the original bitmap image, then it will be a lot
easier to figure
out what type of encoding problem you have.

Cal.

.



Relevant Pages

  • EncoderTransformation ignored, no errors produced.
    ... I would also like to use the EncoderTransformation encoder parameter ... and writes out two jpeg files: ... static int GetEncoderClsid ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Opinions on RAW vs JPG
    ... would get if you shoot RAW and then post process to get a JPEG. ... But neither of those JPEG files is really "as good as" the original ... The RAW file of course has that original data. ... >bought $1000 CD players which rendered *that sound*. ...
    (alt.photography)
  • Re: OT: Why? Using eeePC as digital photo frame with server push...
    ... I suspect at least one JPEG codec still has a quirk when faced with unusually encoded images. ... The PaintShopPro encoder from v8 onwards is actually terminally broken in chroma subsampling but hardly anyone has noticed. ... same size and screen filling on the target screen, ... predictable formats, keeps aspect right. ...
    (sci.electronics.design)
  • Re: OT: Why? Using eeePC as digital photo frame with server push...
    ... 24bit YCC encoded JPEG but gave a completely surreal random false colour ... The PaintShopPro encoder from v8 onwards is ... same size and screen filling on the target screen, ... In Linux the imagemagick program suite is pretty good for most picture ...
    (sci.electronics.design)
  • Re: PHOTOSHOP JPEGS RAW
    ... IS THIS NORMAL WITH PHOTOSHOP? ... You have to use your preferences setup in Bridge to open Jpeg and Tiff files ... In Bridge Preferences>Thumbnails>Prefer Adobe Camera raw, ... you can do a lot with jpeg files in ACR. ...
    (rec.photo.digital)