Changeset a35b458 in mainline for uspace/lib/draw/codec


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
uspace/lib/draw/codec
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/draw/codec/tga.c

    r3061bc1 ra35b458  
    4646        uint8_t cmap_type;
    4747        uint8_t img_type;
    48        
     48
    4949        uint16_t cmap_first_entry;
    5050        uint16_t cmap_entries;
    5151        uint8_t cmap_bpp;
    52        
     52
    5353        uint16_t startx;
    5454        uint16_t starty;
     
    7979        cmap_type_t cmap_type;
    8080        img_type_t img_type;
    81        
     81
    8282        uint16_t cmap_first_entry;
    8383        uint16_t cmap_entries;
    8484        uint8_t cmap_bpp;
    85        
     85
    8686        uint16_t startx;
    8787        uint16_t starty;
     
    9191        uint8_t img_alpha_bpp;
    9292        uint8_t img_alpha_dir;
    93        
     93
    9494        void *id_data;
    9595        size_t id_length;
    96        
     96
    9797        void *cmap_data;
    9898        size_t cmap_length;
    99        
     99
    100100        void *img_data;
    101101        size_t img_length;
     
    117117        if (size < sizeof(tga_header_t))
    118118                return false;
    119        
     119
    120120        tga_header_t *head = (tga_header_t *) data;
    121        
     121
    122122        /* Image ID field */
    123123        tga->id_data = data + sizeof(tga_header_t);
    124124        tga->id_length = head->id_length;
    125        
     125
    126126        if (size < sizeof(tga_header_t) + tga->id_length)
    127127                return false;
    128        
     128
    129129        /* Color map type */
    130130        tga->cmap_type = head->cmap_type;
    131        
     131
    132132        /* Image type */
    133133        tga->img_type = head->img_type;
    134        
     134
    135135        /* Color map specification */
    136136        tga->cmap_first_entry = uint16_t_le2host(head->cmap_first_entry);
     
    139139        tga->cmap_data = tga->id_data + tga->id_length;
    140140        tga->cmap_length = ALIGN_UP(tga->cmap_entries * tga->cmap_bpp, 8) >> 3;
    141        
     141
    142142        if (size < sizeof(tga_header_t) + tga->id_length +
    143143            tga->cmap_length)
    144144                return false;
    145        
     145
    146146        /* Image specification */
    147147        tga->startx = uint16_t_le2host(head->startx);
     
    154154        tga->img_data = tga->cmap_data + tga->cmap_length;
    155155        tga->img_length = ALIGN_UP(tga->width * tga->height * tga->img_bpp, 8) >> 3;
    156        
     156
    157157        if (size < sizeof(tga_header_t) + tga->id_length +
    158158            tga->cmap_length + tga->img_length)
    159159                return false;
    160        
     160
    161161        return true;
    162162}
     
    182182        if (!decode_tga_header(data, size, &tga))
    183183                return NULL;
    184        
     184
    185185        /*
    186186         * Check for unsupported features.
    187187         */
    188        
     188
    189189        switch (tga.cmap_type) {
    190190        case CMAP_NOT_PRESENT:
     
    194194                return NULL;
    195195        }
    196        
     196
    197197        switch (tga.img_type) {
    198198        case IMG_BGRA:
     
    208208                return NULL;
    209209        }
    210        
     210
    211211        if (tga.img_alpha_bpp != 0)
    212212                return NULL;
    213        
     213
    214214        sysarg_t twidth = tga.startx + tga.width;
    215215        sysarg_t theight = tga.starty + tga.height;
    216        
     216
    217217        surface_t *surface = surface_create(twidth, theight, NULL, flags);
    218218        if (surface == NULL)
    219219                return NULL;
    220        
     220
    221221        /*
    222222         * TGA is encoded in a bottom-up manner, the true-color
    223223         * variant is in BGR 8:8:8 encoding.
    224224         */
    225        
     225
    226226        switch (tga.img_type) {
    227227        case IMG_BGRA:
     
    230230                                size_t offset =
    231231                                    ((y - tga.starty) * tga.width + (x - tga.startx)) * 3;
    232                                
     232
    233233                                pixel_t pixel =
    234234                                    bgr_888_2pixel(((uint8_t *) tga.img_data) + offset);
     
    242242                                size_t offset =
    243243                                    (y - tga.starty) * tga.width + (x - tga.startx);
    244                                
     244
    245245                                pixel_t pixel =
    246246                                    gray_8_2pixel(((uint8_t *) tga.img_data) + offset);
     
    252252                break;
    253253        }
    254        
     254
    255255        return surface;
    256256}
  • uspace/lib/draw/codec/tga.gz.c

    r3061bc1 ra35b458  
    5858        void *data_expanded;
    5959        size_t size_expanded;
    60        
     60
    6161        errno_t ret = gzip_expand(data, size, &data_expanded, &size_expanded);
    6262        if (ret != EOK)
    6363                return NULL;
    64        
     64
    6565        surface_t *surface = decode_tga(data_expanded, size_expanded, flags);
    66        
     66
    6767        free(data_expanded);
    6868        return surface;
  • uspace/lib/draw/codec/webp.c

    r3061bc1 ra35b458  
    8484        bool alpha_used;
    8585        uint8_t version;
    86        
     86
    8787        uint8_t *src;     /**< Input buffer */
    8888        size_t srclen;    /**< Input buffer size */
    8989        size_t srccnt;    /**< Position in the input buffer */
    90        
     90
    9191        uint32_t bitbuf;  /**< Bit buffer */
    9292        size_t bitlen;    /**< Number of bits in the bit buffer */
    93        
     93
    9494        bool overrun;     /**< Overrun condition */
    9595} webp_t;
     
    107107        /* Bit accumulator for at least 36 bits */
    108108        uint64_t val = state->bitbuf;
    109        
     109
    110110        while (state->bitlen < cnt) {
    111111                if (state->srccnt == state->srclen) {
     
    113113                        return 0;
    114114                }
    115                
     115
    116116                /* Load 8 more bits */
    117117                val |= ((uint64_t) state->src[state->srccnt]) << state->bitlen;
     
    119119                state->bitlen += 8;
    120120        }
    121        
     121
    122122        /* Update bits in the buffer */
    123123        state->bitbuf = (uint32_t) (val >> cnt);
    124124        state->bitlen -= cnt;
    125        
     125
    126126        return ((uint32_t) (val & ((1 << cnt) - 1)));
    127127}
     
    143143            (size - sizeof(riff_header_t) < sizeof(webp_header_t)))
    144144                return false;
    145        
     145
    146146        riff_header_t *riff_header = (riff_header_t *) data;
    147147        if (riff_header->fourcc != FOURCC_RIFF)
    148148                return false;
    149        
     149
    150150        /* Check payload size */
    151151        size_t payload_size = uint32_t_le2host(riff_header->payload_size);
    152152        if (payload_size + sizeof(riff_header_t) > size)
    153153                return false;
    154        
     154
    155155        data += sizeof(riff_header_t);
    156156        webp_header_t *webp_header = (webp_header_t *) data;
    157157        if (webp_header->fourcc != FOURCC_WEBP)
    158158                return false;
    159        
     159
    160160        /* Only lossless encoding supported so far */
    161161        if (webp_header->encoding != FOURCC_WEBP_LOSSLESS)
    162162                return false;
    163        
     163
    164164        webp->stream_size = uint32_t_le2host(webp_header->stream_size);
    165165        if (webp->stream_size + sizeof(riff_header_t) +
    166166            sizeof(webp_header_t) > size)
    167167                return false;
    168        
     168
    169169        if (webp_header->signature != SIGNATURE_WEBP_LOSSLESS)
    170170                return false;
    171        
     171
    172172        data += sizeof(webp_header_t);
    173        
     173
    174174        /* Setup decoding state */
    175175        webp->src = (uint8_t *) data;
     
    179179        webp->bitlen = 0;
    180180        webp->overrun = false;
    181        
     181
    182182        /* Decode the rest of the metadata */
    183183        webp->width = get_bits(webp, 14) + 1;
    184184        CHECK_OVERRUN(*webp, false);
    185        
     185
    186186        webp->height = get_bits(webp, 14) + 1;
    187187        CHECK_OVERRUN(*webp, false);
    188        
     188
    189189        webp->alpha_used = get_bits(webp, 1);
    190190        CHECK_OVERRUN(*webp, false);
    191        
     191
    192192        webp->version = get_bits(webp, 3);
    193193        CHECK_OVERRUN(*webp, false);
    194        
     194
    195195        if (webp->version != 0)
    196196                return false;
    197        
     197
    198198        return true;
    199199}
     
    218218        if (!decode_webp_header(data, size, &webp))
    219219                return NULL;
    220        
     220
    221221        bool transform_present = false;
    222        
     222
    223223        do {
    224224                transform_present = get_bits(&webp, 1);
    225225                CHECK_OVERRUN(webp, NULL);
    226                
     226
    227227                if (transform_present) {
    228228                        webp_transform_t transform = get_bits(&webp, 2);
    229229                        CHECK_OVERRUN(webp, NULL);
    230                        
     230
    231231                        if (transform == TRANSFORM_PREDICTOR) {
    232232                                // FIXME TODO
    233233                        } else
    234234                                return NULL;
    235                        
     235
    236236                        // FIXME: decode other transforms
    237237                }
    238238        } while (transform_present);
    239        
     239
    240240        // FIXME: decode image data
    241        
     241
    242242        return NULL;
    243243}
Note: See TracChangeset for help on using the changeset viewer.