On Sat, Sep 24, 2011 at 12:23:03AM +0200, Jean First wrote:
> ---
>  libavcodec/tiffenc.c |   24 +++++++++++++++---------
>  1 files changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
> index a141a47..cd85b05 100644
> --- a/libavcodec/tiffenc.c
> +++ b/libavcodec/tiffenc.c
> @@ -211,12 +211,13 @@ static int encode_frame(AVCodecContext * avctx, 
> unsigned char *buf,
>      uint32_t *strip_offsets = NULL;
>      int bytes_per_row;
>      uint32_t res[2] = { 72, 1 };        // image resolution (72/1)
> -    static const uint16_t bpp_tab[] = { 8, 8, 8, 8 };
> +    static uint16_t bpp_tab[] = { 8, 8, 8, 8 };

static should be dropped as well - otherwise TIFF encoders for RGB24 and RGB48
working in parallel will get their common bpp_tab[] messed up.

>      int ret = -1;
>      int is_yuv = 0;
>      uint8_t *yuv_line = NULL;
>      int shift_h, shift_v;
>  
> +    s->avctx = avctx;
>      s->buf_start = buf;
>      s->buf = &ptr;
>      s->buf_size = buf_size;

This change for avctx is in another patch too (and it would be better to be
done as a separate patch anyway).

> @@ -243,6 +244,14 @@ static int encode_frame(AVCodecContext * avctx, unsigned 
> char *buf,
>      s->subsampling[1] = 1;
>  
>      switch (avctx->pix_fmt) {
> +    case PIX_FMT_RGB48LE:
> +        s->bpp = 48;
> +        s->photometric_interpretation = 2;
> +        bpp_tab[0] = 16;
> +        bpp_tab[1] = 16;
> +        bpp_tab[2] = 16;
> +        bpp_tab[3] = 16;
> +        break;
>      case PIX_FMT_RGB24:
>          s->bpp = 24;
>          s->photometric_interpretation = 2;
> @@ -283,13 +292,9 @@ static int encode_frame(AVCodecContext * avctx, unsigned 
> char *buf,
>          return -1;
>      }
>      if (!is_yuv)
> -        s->bpp_tab_size = (s->bpp >> 3);
> +        s->bpp_tab_size = (s->bpp >= 48) ? (s->bpp >> 4) : (s->bpp >> 3);
>  
> -    if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || 
> s->compr == TIFF_LZW)
> -        //best choose for DEFLATE
> -        s->rps = s->height;
> -    else
> -        s->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);     // 
> suggest size of strip
> +    s->rps = s->height;
>      s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1]; // 
> round rps up
>  
>      strips = (s->height - 1) / s->rps + 1;
> @@ -450,11 +455,12 @@ AVCodec ff_tiff_encoder = {
>      .priv_data_size = sizeof(TiffEncoderContext),
>      .encode         = encode_frame,
>      .pix_fmts =
> -        (const enum PixelFormat[]) {PIX_FMT_RGB24, PIX_FMT_PAL8, 
> PIX_FMT_GRAY8,
> +        (const enum PixelFormat[]) {PIX_FMT_RGB24,
> +                              PIX_FMT_PAL8, PIX_FMT_GRAY8,
>                                PIX_FMT_MONOBLACK, PIX_FMT_MONOWHITE,
>                                PIX_FMT_YUV420P, PIX_FMT_YUV422P,
>                                PIX_FMT_YUV444P, PIX_FMT_YUV410P,
> -                              PIX_FMT_YUV411P,
> +                              PIX_FMT_YUV411P, PIX_FMT_RGB48LE,

No RBG48BE?

>                                PIX_FMT_NONE},
>      .long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
>  };
> -- 
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to