[FFmpeg-devel] [PATCH][RFC] Lagarith Decoder.

Måns Rullgård mans
Fri Aug 21 10:17:54 CEST 2009


Nathan Caldwell <saintdev at gmail.com> writes:

> Thanks again everyone. Here are the latest patches.
>
> -- 
> -Nathan Caldwell
>
> diff --git libavcodec/lagrange.c libavcodec/lagrange.c
> new file mode 100644
> index 0000000..8c6fa2d
> --- /dev/null
> +++ libavcodec/lagrange.c
> @@ -0,0 +1,55 @@
> +/*
> + * Lagarith range decoder
> + * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com>
> + * Copyright (c) 2009 David Conrad
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file libavcodec/lagrange.c

That filename makes it look like it has something to do with Lagrange,
which appears not to be the case, at least not directly.

> diff --git libavcodec/lagarith.c libavcodec/lagarith.c
> new file mode 100644
> index 0000000..51c5e11
> --- /dev/null
> +++ libavcodec/lagarith.c
> @@ -0,0 +1,512 @@
> +/*
> + * Lagarith lossless decoder
> + * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file libavcodec/lagarith.c
> + * Lagarith lossless decoder
> + * @author Nathan Caldwell
> + *
> + */
> +
> +#include "avcodec.h"
> +#include "get_bits.h"
> +#include "mathops.h"
> +#include "lagarith.h"
> +#include "lagrange.h"
> +
> +typedef struct LagarithContext {
> +    AVCodecContext *avctx;
> +    AVFrame picture;
> +    int zeros;                  /*!< Number of consecutave zero bytes encountered. */
> +    int zeros_rem;              /*!< Number of zero bytes remaining to output. */
> +} LagarithContext;
> +
> +static av_cold int lag_decode_init(AVCodecContext *avctx)
> +{
> +    LagarithContext *l = avctx->priv_data;
> +
> +    l->avctx = avctx;
> +
> +    return 0;
> +}
> +
> +static void lag_memset(uint8_t *s, uint8_t c, size_t n, int step)
> +{
> +    int i;
> +    if (step == 1) {
> +        memset(s, c, n);
> +        return;
> +    }
> +
> +    for (i = 0; i < n * step; i += step)
> +        s[i] = c;
> +}
> +
> +static uint8_t *lag_memcpy(uint8_t *dest, const uint8_t *src, size_t n,
> +                           int step)
> +{
> +    int i;
> +    if (step == 1)
> +        return memcpy(dest, src, n);
> +
> +    for (i = 0; i < n * step; i += step)
> +        dest[i] = src[i];
> +    return dest;
> +}

Those two functions look like they could be useful elsewhere.  They
should be placed in some common file for everybody to use.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list