[FFmpeg-devel] Enable 16 bit tiff decoding and encoding

Baptiste Coudurier baptiste.coudurier at gmail.com
Fri Sep 23 22:21:12 CEST 2011


Hi Jean,

On 09/23/2011 04:37 AM, Jean First wrote:
> On Fri Sep 23 2011 10:26:07 GMT+0200 (CEST), Jean First wrote:
>> Decoding testet with following compressions for RGB48LE and RGB48BE:
>> LZW, RLE, DEFLATE, NONE
>> Encoding tested with RGB48LE: PACKBITS, LZW, RAW, DEFLATE
>> Encoding to RGB48BE is still not supported
>> Jean

Thanks a lot for the patch !

> Ah sorry, the patch didn't apply. New patch attached.
> jean
> 
> 0001-Enable-16-bit-encoding-and-decoding-for-tiff-files.patch
> 
> 
> From b89f691b0eb4f2b24e4b437b71befa534eedc3f6 Mon Sep 17 00:00:00 2001
> From: Jean First <jeanfirst at gmail.com>
> Date: Fri, 23 Sep 2011 02:04:11 +0200
> Subject: [PATCH 1/2] Enable 16-bit encoding and decoding for tiff files.
> 
> ---
>  libavcodec/tiff.c    |   15 +++++++++++++++
>  libavcodec/tiffenc.c |   19 +++++++++++++------
>  2 files changed, 28 insertions(+), 6 deletions(-)
> 
> [...]
>
> diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
> index eaa777a..760ae36 100644
> --- a/libavcodec/tiffenc.c
> +++ b/libavcodec/tiffenc.c
> @@ -44,6 +44,7 @@ static const uint8_t type_sizes2[6] = {
>  };
>  
>  typedef struct TiffEncoderContext {
> +    AVClass *avclass;
>      AVCodecContext *avctx;
>      AVFrame picture;

Did you add encoder specific options ? I don't see them.
Otherwise you don't need that yet.

> [...]
>  
> -    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->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1]; // round rps up

Is this change on purpose ? Could you please explain a little more ?

>      strips = (s->height - 1) / s->rps + 1;
> @@ -456,7 +462,8 @@ 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_RGB48LE, 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,

You should add the new PIX_FMT at the end of the list, the first entry
in that list is usually automatically picked up by applications (ffmpeg)
if the decoding pixel format is not in the list.

[...]

-- 
Baptiste COUDURIER
Key fingerprint          8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                           http://www.ffmpeg.org


More information about the ffmpeg-devel mailing list