[Ffmpeg-devel] JPEG-LS decoding issues

Michael Niedermayer michaelni
Sun Jan 15 19:15:22 CET 2006


Hi

On Sun, Jan 15, 2006 at 08:05:38PM +0200, Kostya wrote:
> I'm working on JPEG-LS baseline decoder and have stumbled upon one 
> serious issue: in draft and standard, annex C 1.2 states JPEG-LS 
> bitstream has escapes - if there is byte 0xFF then read one bit to 
> decide if it's JPEG marker (bit=1) or just part of bitstream(bit=0, 
> which must be then ignored by bitstream reader). What should I do to 
> implement correct handling of this situation?

allocate buffer
copy data over while removing these bits with something like:
for(...){
    int x= src[i];
    if(x==0xFF){
        x= src[++i];
        if(x&0x80) break;
        put_bits(&pb, 15, 0x7F80 + x);
    }
    else
        put_bits(&pb, 8, x);
}

yeah that escaping is the most silliest of all standards ever, not that
escaping itself ever was a good idea to begin with, but this one is really
bad design its comlicated and slow with almost no gain, the old jpeg variant
was more sane if you do have to do escaping for whatever reason
especially for a lossless (=high bitrate) codec its important that you dont
do timeconsuming things with the bitstream :(

[...]

-- 
Michael





More information about the ffmpeg-devel mailing list