[FFmpeg-devel] [PATCH] tiff: support lzw with inverted FillOrder

Paul B Mahol onemda at gmail.com
Wed Dec 19 20:11:35 CET 2012


On 12/19/12, Piotr Bandurski <ami_stuff at o2.pl> wrote:
> Hi,
>
> Is attached correct?
>
> Regards
>
>
>
>
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index 286cbc2..6ad113d 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -61,6 +61,9 @@ typedef struct TiffContext {
>      int sot;
>      int stripsizesoff, stripsize, stripoff, strippos;
>      LZWState *lzw;
> +
> +    uint8_t *src2;
> +    int src2_size;

Give it better name.

>
>      int geotag_count;
>      TiffGeoTag *geotags;
> @@ -449,6 +452,18 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
>      }
>  #endif
>      if (s->compr == TIFF_LZW) {
> +        if (s->fill_order) {
> +            int i;
> +            av_fast_padded_malloc(&s->src2, &s->src2_size, (unsigned)size);

no cast, please.
> +            if (!s->src2) {
> +                av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");

nit: I do not think that message is needed.

> +                return AVERROR(ENOMEM);
> +            }
> +            for (i = 0; i < size; i++)
> +                s->src2[i] = ff_reverse[src[i]];
> +            src = s->src2;
> +            ssrc = src;
> +        }
>          if (ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF) < 0) {
>              av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
>              return -1;
> @@ -1192,6 +1207,8 @@ static av_cold int tiff_end(AVCodecContext *avctx)
>      free_geotags(s);
>
>      ff_lzw_decode_close(&s->lzw);
> +    av_freep(&s->src2);
> +    s->src2_size = 0;

not needed.
>      if (s->picture.data[0])
>          avctx->release_buffer(avctx, &s->picture);
>      return 0;


More information about the ffmpeg-devel mailing list