[FFmpeg-devel] [PATCH] avcodec: add Apple Pixlet decoder

Paul B Mahol onemda at gmail.com
Mon Dec 19 21:32:52 EET 2016


On 12/19/16, James Almer <jamrial at gmail.com> wrote:
> On 12/19/2016 11:18 AM, Paul B Mahol wrote:
>> +static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size)
>> +{
>> +    PixletContext *ctx = avctx->priv_data;
>> +    GetBitContext *b = &ctx->gbit;
>> +    unsigned value, cnt1, nbits, j, i = 0;
>> +    int rlen, flag = 0, escape;
>> +    int64_t rparam = 3;
>> +
>> +    while (i < size) {
>> +        nbits = FFMIN(ff_clz((rparam >> 8) + 3) ^ 0x1F, 14);
>> +
>> +        cnt1 = get_unary(b, 0, 8);
>> +        if (cnt1 < 8) {
>> +            value = show_bits(b, nbits);
>> +            if (value <= 1) {
>> +                skip_bits(b, nbits - 1);
>> +                escape = ((1 << nbits) - 1) * cnt1;
>> +            } else {
>> +                skip_bits(b, nbits);
>> +                escape = value + ((1 << nbits) - 1) * cnt1 - 1;
>> +            }
>> +        } else {
>> +            escape = get_bits(b, 16);
>> +        }
>> +
>> +        rlen = -((escape + flag) & 1) | 1;
>> +        dst[i++] = rlen * ((escape + flag + 1) >> 1);
>> +        rparam += 120 * (escape + flag) - (120 * rparam >> 8);
>> +        flag = 0;
>> +
>> +        if (rparam * 4 > 0xFF || i >= size)
>> +            continue;
>> +
>> +        nbits = ((rparam + 8) >> 5) + (rparam ? ff_clz(rparam) : 32) -
>> 24;
>> +        escape = 16383 & ((1 << nbits) - 1);
>
> escape = av_mod_uintp2(16383, nbits);
>

Changed locally. Thanks!


More information about the ffmpeg-devel mailing list