On Sun, Mar 18, 2012 at 12:57:21PM -0400, Derek Buitenhuis wrote:
> An obscure Japanese lossless video codec, originally intended
> for use with a remote desktop application.
> 
> --- /dev/null
> +++ b/libavcodec/zerocodec.c
> @@ -0,0 +1,182 @@
> +/*
> + * ZeroCodec Decoder
> + *
> + * Copyright (c) 2012, Derek Buitenhuis
> + *
> + * This file is part of Libav.

This sentence forms part of the GPL license boilerplate, but it has no
place in the ISC license.

> +#include <zlib.h>
> +#include "avcodec.h"

Please separate system and local headers by an empty line.

> +    zstream->next_in   = avpkt->data;
> +    zstream->avail_in  = avpkt->size;

nit: stray double space

> +    if (avpkt->flags & AV_PKT_FLAG_KEY) {
> +
> +        pic->key_frame = 1;
> +        pic->pict_type = AV_PICTURE_TYPE_I;
> +
> +        for (i = 0; i < avctx->height; i++) {
> +
> +            zstream->next_out  = dst;
> +            zstream->avail_out = avctx->width << 1;
> +
> +            zret = inflate(zstream, Z_SYNC_FLUSH);
> +
> +            if (zret != Z_OK && zret != Z_STREAM_END) {
> +                av_log(avctx, AV_LOG_ERROR, "Inflate failed with return 
> code: %d\n", zret);
> +                return AVERROR(EINVAL);
> +            }
> +
> +            dst += pic->linesize[0];
> +        }
> +    } else {
> +
> +        pic->key_frame = 0;
> +        pic->pict_type = AV_PICTURE_TYPE_P;
> +
> +        for (i = 0; i < avctx->height; i++) {
> +
> +            zstream->next_out  = dst;
> +            zstream->avail_out = avctx->width << 1;
> +
> +            zret = inflate(zstream, Z_SYNC_FLUSH);
> +
> +            if (zret != Z_OK && zret != Z_STREAM_END) {
> +                av_log(avctx, AV_LOG_ERROR, "Inflate failed with return 
> code: %d\n", zret);
> +                return AVERROR(EINVAL);
> +            }
> +
> +            for (j = 0; j < avctx->width << 1; j++)
> +                dst[j] += prev[j] & -!dst[j];
> +
> +            prev += prev_pic->linesize[0];
> +            dst  += pic->linesize[0];
> +        }
> +    }

nit: We don't usually leave empty lines after if/for-blocks.

The av_log lines are long and can easily be shortened.

> +    *data_size = sizeof(AVFrame);
> +    *(AVFrame *)data = *pic;

nit: align

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

Reply via email to