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

local int speck_encode_S ( int **  channel,
int  channel_size,
pixel_set set,
linked_list **  LIS_slots,
linked_list LSP,
bit_buffer bb,
int  threshold 
)

Encode set of type 'S'

This function encodes set of type 'S'.

Parameters:
channelChannel
channel_sizeChannel size
setSet to encode
LIS_slotsArray of LIS slots
LSPList of Significant Pixels
bbBit-buffer
thresholdThreshold
Returns:
Either BIT_BUFFER_OK or BIT_BUFFER_OVERFLOW

Definition at line 411 of file speck.c.

References alloc_list_node(), append_list_node(), assign_set(), BIT_BUFFER_OK, prepend_list_node(), RETURN_IF_OVERFLOW, significance_test(), SLOT_INDEX, speck_encode_S(), split_set(), TYPE_EMPTY, TYPE_POINT, write_0, write_1, pixel_set_tag::x, and pixel_set_tag::y.

Referenced by speck_encode_S(), and speck_process_S().

{
    pixel_set new_sets[4];
    int result;
    int st[4];
    int flag;
    int i;

    /* Split parent set */
    split_set(set, &new_sets[0], &new_sets[1], &new_sets[2], &new_sets[3], channel_size);

    /* Test each set for significance skipping over empty sets */
    for (flag = 0, i = 3; i >= 0; i--) {
        if (new_sets[i].type == TYPE_EMPTY) {
            continue;
        }

        st[i] = significance_test(&new_sets[i], threshold, channel, channel_size);

        if (i) {
            flag |= st[i];
        }

        /* If parent set is significant, but first three
         * child sets are not, than undoubtedly fourth
         * child set is significant: there is no need
         * to code this explicitly. Using this trick
         * saves some bit-budget. */
        if (i || flag) {
            result = st[i] ? write_1(bb) : write_0(bb);
            RETURN_IF_OVERFLOW(result);
        }
    }

    /* Process non-empty sets using their significance information */
    for (i = 0; i < 4; i++) {
        if (new_sets[i].type == TYPE_EMPTY) {
            continue;
        }

        if (st[i]) {
            /* Significant set */
            if (new_sets[i].type == TYPE_POINT) {
                /* Single point */
                list_node *new_node;

                /* Encode coefficient sign */
                result = channel[new_sets[i].x][new_sets[i].y] > 0 ? write_0(bb) : write_1(bb);
                RETURN_IF_OVERFLOW(result);

                new_node = alloc_list_node(sizeof(pixel_set));
                assign_set(new_node, &new_sets[i]);
                append_list_node(LSP, new_node);
            } else {
                /* Encode set of type 'S' */
                result = speck_encode_S(channel, channel_size, &new_sets[i],
                                        LIS_slots, LSP, bb, threshold);
    
                RETURN_IF_OVERFLOW(result);
            }
        } else {
            /* Insignificant set */
            list_node *new_node = alloc_list_node(sizeof(pixel_set));
            assign_set(new_node, &new_sets[i]);
            prepend_list_node(LIS_slots[SLOT_INDEX((&new_sets[i]))], new_node);            
        }
    }

    return BIT_BUFFER_OK;
}

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