[Libav-user] AV_CODEC_TYPE_TIFF packet size problems

coordz at megaroms.co.uk coordz at megaroms.co.uk
Fri Nov 14 12:41:54 CET 2014


I'm using the AV_CODEC_TYPE_TIFF to work with a 5184x3456 pixel image with
R16G16B16, i.e. AV_PIX_FMT_RGB48. When I read the image in I get a packet
of a size of 107665156 bytes which tallies nicely with the 107495424 bytes
of uncompressed pixel data that should be in the packet. I then use
sws_scale() to add an alpha channel, i.e. go to AV_PIX_FMT_RGBA64.

When I write the image data out as AV_PIX_FMT_RGB48 (using sws_scale() to
remove previously added alpha channel), AV_CODEC_TYPE_TIFF generates a
packet of 108363208 bytes which, again, seems fine.

Now I try to write the file out as AV_PIX_FMT_RGBA64, I get an error

"[tiff @ 000000000F49A0A0] Invalid minimum required packet size 2293265920
(max allowed is 2147483631)"

My first worry with this is that for RGBA64 I should get a packet size of
about 143327232 bytes (the pixel data size) not 2293265920 bytes (about
5184 x 3456 x 3 channels x 2 bytes x 2 (unknown factor???)). What's going
on here? I don't believe this is correct so is this a bug with
AV_CODEC_TYPE_TIFF?

Also, looking up the code that generates this error (ff_alloc_packet2() in
utils.c) it looks like I'm restricted to images that fit in a packet of a
bit less than MAX_INT which is about a 30MPixel image. I'm assuming this
is a very difficult restriction to get around in the avcodec code?

To work around these issues I'm thinking of using the lossless compression
in TIFF to try to reduce the packet size. How do I instruct
AV_CODEC_TYPE_TIFF to do this compression?

Thanks!



More information about the Libav-user mailing list