[FFmpeg-devel] [PATCH] avcodec: add Argonaut Games Video decoder

James Almer jamrial at gmail.com
Thu Sep 24 16:07:55 EEST 2020


On 9/24/2020 8:59 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  libavcodec/Makefile     |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/argo.c       | 739 ++++++++++++++++++++++++++++++++++++++++
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/codec_id.h   |   1 +
>  libavformat/argo_brp.c  |  14 +-
>  6 files changed, 751 insertions(+), 12 deletions(-)
>  create mode 100644 libavcodec/argo.c

[...]

> +static int decode_alcd(AVCodecContext *avctx, AVFrame *frame)
> +{
> +    ArgoContext *s = avctx->priv_data;
> +    GetByteContext *gb = &s->gb;
> +    GetByteContext sb;
> +    const int l = frame->linesize[0];
> +    const uint8_t *map = gb->buffer;
> +    uint8_t *dst = frame->data[0];
> +    uint8_t codes = 0;
> +    int count = 0;
> +
> +    if (bytestream2_get_bytes_left(gb) < 1024 + (((frame->width / 2) * (frame->height / 2) + 7) >> 3))
> +        return AVERROR_INVALIDDATA;
> +
> +    bytestream2_skipu(gb, 1024);
> +    sb = *gb;
> +    bytestream2_skipu(gb, ((frame->width / 2) * (frame->height / 2) + 7) >> 3);
> +
> +    for (int y = 0; y < frame->height; y += 2) {
> +        for (int x = 0; x < frame->width; x += 2) {
> +            const uint8_t *block;
> +            int index;
> +
> +            if (count == 0) {
> +                codes = bytestream2_get_byteu(&sb);
> +                count = 8;
> +            }
> +
> +            if (codes & 0x80) {
> +                index = bytestream2_get_byte(gb);
> +                block = map + index * 4;
> +
> +                dst[x+0]   = block[0];
> +                dst[x+1]   = block[1];
> +                dst[x+l]   = block[2];
> +                dst[x+l+1] = block[3];
> +            }

This doesn't look right.


More information about the ffmpeg-devel mailing list