static void decode_scaling_list(GetBitContext *gb, uint8_t *factors, int size,

                                const uint8_t *jvt_list,

                                const uint8_t *fallback_list)

{

    int i, last = 8, next = 8;

    const uint8_t *scan = size == 16 ? ff_zigzag_scan : ff_zigzag_direct;

    if (!get_bits1(gb)) 

        memcpy(factors, fallback_list, size * sizeof(uint8_t));

    else

        for (i = 0; i < size; i++) {

            if (next)

                next = (last + get_se_golomb(gb)) & 0xff;

            if (!i && !next) { 

                memcpy(factors, jvt_list, size * sizeof(uint8_t));

                break;

            }

            last = factors[scan[i]] = next ? next : last;

        }

}
