Re: JPEG YUV subsampling instream transcoding



John Williams schrieb:
Hello,

I have an JPEG encoding device that generates files with YUV
subsampling factors 2x2,1x2,1x2. Notionally I suppose this is a 4:2:2
subsampling.

I have a decoding device, which purports to handle 4:2:2, however it
breaks on images received from the above encoder. However, it does
handle subsampling factors 2x1,1x1,1x1 nicely. Is this also 4:2:2
( but a *different* 4:2:2)?

The subsampling of the components is identical, but the MCUs (the coding units)
are different. That is, the components are scanned, or rather interleaved,
in a different order. (Assuming that this is an interleaved JPEG).

Here's my question - is there a sensible, in-stream way to transcode
between these two subformats without going through a partial decode/
encode cycle (de-huff, de-quant, idct, resample, dct, quant, huff)?

Yes. You wouldn't have to run the DCT step to perform the transcoding,
but you had to decode the DCT blocks, un-do the DPCM coding of the
DC part of the coefficients - since those are difference-encoded in the
order the blocks are scanned - and then re-scan the DCT blocks in the
order implied by the new subsampling factors, and re-do the huffman
step to get the output.

The similarities are striking, which makes me wonder if there is an
algorithmic way to convert between these two variants without
decoding.

At least without full decoding. There is a lossless path to transcode
between the two which only requires to re-do the huffman and DPCM steps.


So long,
Thomas

.