Changeset a35b458 in mainline for uspace/lib/draw/codec/webp.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.