[FFmpeg-devel] [PATCH 2/3] avcodec: add SGA Video decoder
Carl Eugen Hoyos
ceffmpeg at gmail.com
Sat Feb 27 11:27:41 EET 2021
Am Fr., 26. Feb. 2021 um 12:55 Uhr schrieb Paul B Mahol <onemda at gmail.com>:
> +static int decode_palette(GetByteContext *gb, uint32_t *pal)
> +{
> + GetBitContext gbit;
> +
> + if (bytestream2_get_bytes_left(gb) < 18)
> + return AVERROR_INVALIDDATA;
> +
> + memset(pal, 0, 16 * sizeof(*pal));
> + init_get_bits8(&gbit, gb->buffer, 18);
> +
> + for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
> + for (int index = 0; index < 16; index++) {
> + unsigned color = get_bits1(&gbit) << RGBIndex;
> + pal[15 - index] |= color << (5 + 16);
> + }
> + }
> +
> + for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
> + for (int index = 0; index < 16; index++) {
> + unsigned color = get_bits1(&gbit) << RGBIndex;
> + pal[15 - index] |= color << (5 + 8);
> + }
> + }
> +
> + for (int RGBIndex = 0; RGBIndex < 3; RGBIndex++) {
> + for (int index = 0; index < 16; index++) {
> + unsigned color = get_bits1(&gbit) << RGBIndex;
> + pal[15 - index] |= color << (5 + 0);
> + }
> + }
> +
> + for (int index = 0; index < 16; index++)
> + pal[index] = (0xFFU << 24) | pal[index] | (pal[index] >> 3);
Looks much better than what I suggested but please
also fill the last two bits of each component.
Carl Eugen
More information about the ffmpeg-devel
mailing list