Logo Search packages:      
Sourcecode: librasterlite version File versions  Download package

local void split_set ( pixel_set set,
pixel_set part1,
pixel_set part2,
pixel_set part3,
pixel_set part4,
int  channel_size 
)

Split set

This function splits the set into pieces. Actual splitting rule is defined within SPECK algorithm.

Parameters:
setSet to split
part1First part
part2Second part
part3Third part
part4Fourth part
channel_sizeChannel size
Returns:
VOID

Definition at line 276 of file speck.c.

References pixel_set_tag::height, number_of_bits(), select_part_type(), pixel_set_tag::type, TYPE_EMPTY, TYPE_I, TYPE_S, validate_set(), pixel_set_tag::width, pixel_set_tag::x, and pixel_set_tag::y.

Referenced by speck_decode_I(), speck_decode_S(), speck_encode_I(), and speck_encode_S().

{
    int base_size = channel_size & (~1);

#ifdef ENABLE_SET_VALIDATION
    /* Ensure that the set is valid */
    assert(validate_set(set, channel_size));
#endif

    switch (set->type) {
        case TYPE_S:
        {
            /* Split parent set of type 'S' */
            part1->x = set->x;
            part1->y = set->y;
            part1->width = (set->width + 1) / 2;
            part1->height = (set->height + 1) / 2;
            select_part_type(part1);

            part2->x = set->x;
            part2->y = set->y + (set->width + 1) / 2;
            part2->width = set->width / 2;
            part2->height = (set->height + 1) / 2;
            select_part_type(part2);

            part3->x = set->x + (set->height + 1) / 2;
            part3->y = set->y;
            part3->width = (set->width + 1) / 2;
            part3->height = set->height / 2;
            select_part_type(part3);

            part4->x = set->x + (set->height + 1) / 2;
            part4->y = set->y + (set->width + 1) / 2;
            part4->width = set->width / 2;
            part4->height = set->height / 2;
            select_part_type(part4);

            break;
        }
        case TYPE_I:
        {
            /* Split parent set of type 'I' */
            int p0, p1;
            int scale;

            scale = number_of_bits(set->x - (channel_size != base_size));

            p0 = set->x;
            p1 = (1 << scale) + (channel_size != base_size);

            part1->x = part1->y = p1;
            part1->width = part1->height = channel_size - p1;
            part1->type = (p1 == channel_size) ? TYPE_EMPTY : TYPE_I;

            part2->x = 0;
            part2->y = p0;
            part2->width = p1 - p0;
            part2->height = p0;
            select_part_type(part2);

            part3->x = p0;
            part3->y = 0;
            part3->width = p0;
            part3->height = p1 - p0;
            select_part_type(part3);

            part4->x = part4->y = p0;
            part4->width = part4->height = p1 - p0;
            select_part_type(part4);

            break;
        }
        default:
        {
            assert(0);
            break;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index