On Fri, Sep 13, 2013 at 04:31:00PM -0400, Justin Ruggles wrote:
> ---
>  doc/general.texi  |    2 +-
>  libavcodec/webp.c | 1173 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 1164 insertions(+), 11 deletions(-)

See the new codecs checklist.

> --- a/libavcodec/webp.c
> +++ b/libavcodec/webp.c
> +enum ImageRole {
> +    /* Stores the actual pixels of the image. */
> +    IMAGE_ROLE_ARGB,
> +
> +    /* Stores the meta Huffman codes. The red and green components of a pixel
> +       define the meta Huffman code used in a particular block of the ARGB
> +       image. */
> +    IMAGE_ROLE_ENTROPY,
> +
> +    /* Stores the metadata for Predictor Transform. The green component of a
> +       pixel defines which of the 14 predictors is used within a particular
> +       block of the ARGB image. */
> +    IMAGE_ROLE_PREDICTOR,
> +
> +    /* It is created by ColorTransformElement values for different blocks of
> +       the image. Each ColorTransformElement is treated as a pixel whose 
> alpha
> +       component is 255, red component is cte.red_to_blue, green component is
> +       cte.green_to_blue and blue component is cte.green_to_red. */
> +    IMAGE_ROLE_COLOR_TRANSFORM,
> +
> +    /* Color indexing image: An array of of size color_table_size (up to 256
> +       ARGB values) storing the metadata for the Color Indexing Transform. 
> This
> +       is stored as an image of width color_table_size and height 1. */
> +    IMAGE_ROLE_COLOR_INDEXING,

nit: Add * to the beginning of comment lines, more below.

> +static void read_huffman_code_simple(WebPContext *s, HuffReader *hc)
> +{
> +    hc->nb_symbols = get_bits1(&s->gb) + 1;
> +
> +    if (get_bits1(&s->gb))
> +        hc->simple_symbols[0] = get_bits(&s->gb, 8);
> +    else
> +        hc->simple_symbols[0] = get_bits1(&s->gb);
> +
> +    if (hc->nb_symbols == 2) {
> +        hc->simple_symbols[1] = get_bits(&s->gb, 8);
> +    }

nit: Drop {}.

> +static int read_huffman_code_normal(WebPContext *s, HuffReader *hc,
> +                                    int alphabet_size)
> +{
> +    HuffReader code_len_hc;
> +    int *code_lengths = NULL;
> +    int code_length_code_lengths[NUM_CODE_LENGTH_CODES] = { 0 };
> +    int i, symbol, max_symbol, prev_code_len, ret = 0;
> +    int num_codes = 4 + get_bits(&s->gb, 4);
> +
> +    memset(&code_len_hc, 0, sizeof(code_len_hc));

Replace this by a zero initialization.

> +    ret = huff_reader_build_canonical(&code_len_hc, code_length_code_lengths,
> +                                      NUM_CODE_LENGTH_CODES);
> +    if (ret < 0)
> +        goto finish;
> +
> +    code_lengths = av_mallocz_array(alphabet_size, sizeof(*code_lengths));
> +    if (!code_lengths) {
> +        ret = AVERROR(ENOMEM);
> +        goto finish;
> +    }
> +
> +    if (get_bits1(&s->gb)) {
> +        int bits   = 2 + 2 * get_bits(&s->gb, 3);
> +        max_symbol = 2 + get_bits(&s->gb, bits);
> +        if (max_symbol > alphabet_size) {
> +            av_log(s->avctx, AV_LOG_ERROR, "max symbol %d > alphabet size 
> %d\n",
> +                   max_symbol, alphabet_size);
> +            ret = AVERROR_INVALIDDATA;
> +            goto finish;
> +        }
> +    } else {
> +        max_symbol = alphabet_size;
> +    }
> +
> +    prev_code_len = 8;
> +    symbol = 0;

nit: align

> +static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role);

You could avoid the forward declaration by reordering the functions.

> +static av_always_inline int color_transform_delta(int color_pred, int color)
> +{
> +    return (color_pred * color) >> 5;

pointless ()

> +static int apply_color_transform(WebPContext *s)
> +{
> +    ImageContext *img, *cimg;
> +    int x, y, cx, cy;
> +    uint8_t *p, *cp;
> +    int block_size = s->color_block_size;
> +
> +    img   = &s->image[IMAGE_ROLE_ARGB];
> +    cimg  = &s->image[IMAGE_ROLE_COLOR_TRANSFORM];

nit: double space

> +            if (prefix_code < 4) {
> +                length = prefix_code + 1;
> +            } else {
> +                int extra_bits = (prefix_code - 2) >> 1;
> +                int offset     = (2 + (prefix_code & 1)) << extra_bits;

pointless ()

> +            if (prefix_code < 4) {
> +                distance = prefix_code + 1;
> +            } else {
> +                int extra_bits = (prefix_code - 2) >> 1;
> +                int offset     = (2 + (prefix_code & 1)) << extra_bits;

same

Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to