[FFmpeg-devel] 15-bit Westwood VQA3 decoding

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Sep 20 22:29:50 EEST 2021


Pekka Väänänen:
> 1. Is it possible to preserve the pixels of a frame for easy delta updates?
> In that 2009 patch set they used an old "FF_BUFFER_HINTS_PRESERVE" flag
> that doesn't exist anymore.
> 

You keep a reference to the earlier frame (use av_frame_ref()).

> 2. Is it problematic to dereference 16-bit values like this:
> 
>     uint16_t code = *(uint16_t*)stream;
>     stream += 2;
> 
> because the old code used
> 
>     code = bytestream_get_le16(&src);
> 
> instead. Endianess shouldn't be a problem since the bytes are just
> copied as-is. Does it make sense to create a 'bytestream' object just to
> read from a statically allocated array (s->decode_buffer)?
> 


Actually, endianess is a problem in your case. If the bytes at the
position stream are 0xFF and 0x00, then on a little endian system code
will be 0x00FF and type is zero; on a big endian system code will be
0xFF00 and type is 0x07. Alignment might also be a problem (I see that
you might consume a single byte from stream in the loop), so use
bytestream. This has no overhead at all, because there is no bytestream
object (all it does is manipulate the pointer you already have). This is
different from the bytestream2 API.

> 

> +            int count = 0;

> +            uint16_t code = *(uint16_t*)stream;

> +            int type;

> +

> +            stream += 2;

> +            type = code >> 13;

> +            code &= 0x1fff;

- Andreas


More information about the ffmpeg-devel mailing list