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

Jean First jeanfirst at gmail.com
Fri Sep 23 23:00:00 CEST 2011


Hi Babtiste,

On Fri Sep 23 2011 22:21:12 GMT+0200 (CEST), Baptiste Coudurier wrote:
> 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 !
np
>> 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.
>
dpi
>> [...]
>>
>> -    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 ?
>
I discussed it with Justin Ruggles.
The spec from 1995 suggest: "If the entire image is one strip, the 
application may run out of memory. Recommendation: Set RowsPerStrip such 
that the size of each strip is about 8K bytes."
but that means for big tiff files the header gets really big mainly 
because of StripByteCounts and StripOffsets each holding the hight of 
the image entries. Btw. this only happend when encoding to TIFF_RAW. And 
setting the bit_buffer_size in the transcoding function in ffmpeg.c to 
6*width*height + 10000 was somehow too much overhead.
>>       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.
>
> [...]
>
ok new patch attached
Jean
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Enable-16-bit-encoding-and-decoding-for-tiff-files.patch
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110923/d53fd178/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0002-cosmetics-remove-unused-and-rename-variables-for-con.patch
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110923/d53fd178/attachment-0001.ksh>


More information about the ffmpeg-devel mailing list