[FFmpeg-devel] [PATCH]Write tiff aspect ratio by default instead of dpi

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Apr 3 08:25:51 CEST 2014


On 03.04.2014, at 05:29, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Tue, Apr 01, 2014 at 12:15:25PM +0200, Carl Eugen Hoyos wrote:
>> Hi!
>> 
>> Attached patch changes the tiff encoder to write the sample 
>> aspect ratio instead of the dpi by default, this is what other 
>> FFmpeg image decoders do.
>> Tested with xv.
>> 
>> Please comment, Carl Eugen
> 
>> Changelog            |    1 +
>> libavcodec/tiffenc.c |   11 ++++++-----
>> libavcodec/version.h |    2 +-
>> tests/ref/lavf/tiff  |    2 +-
>> 4 files changed, 9 insertions(+), 7 deletions(-)
>> 7ddb87691a1e76e7300bdd8d2276a281e8fe6941  patchtiffsar.diff
>> diff --git a/Changelog b/Changelog
>> index 0e38ec8..9d40e53 100644
>> --- a/Changelog
>> +++ b/Changelog
>> @@ -13,6 +13,7 @@ version <next>:
>> - QTKit input device
>> - improvments to OpenEXR image decoder
>> - support decoding 16-bit RLE SGI images
>> +- Write tiff aspect ratio instead of dpi by default
>> 
>> 
>> version 2.2:
>> diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
>> index 7b1e510..cccc4bc 100644
>> --- a/libavcodec/tiffenc.c
>> +++ b/libavcodec/tiffenc.c
>> @@ -233,7 +233,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>>     uint8_t *offset;
>>     uint32_t strips;
>>     int bytes_per_row;
>> -    uint32_t res[2] = { s->dpi, 1 };    // image resolution (72/1)
>> +    uint32_t resx[2] = { s->dpi ? s->dpi : avctx->sample_aspect_ratio.den, 1 };
>> +    uint32_t resy[2] = { s->dpi ? s->dpi : avctx->sample_aspect_ratio.num, 1 };
> 
> i think this is wrong
> shouldnt the dpi be adjusted when the aspect differs from 1:1
> i mean 1:2 sample aspect would imply that there are twice as many
> pixels in one direction thus dpi also being different for the two
> axis

Which also kind of leaves the question which to adjust (I'd suggest adjusting both isn't good)
I think scaling y is a bit more common, alternatively scaling so that DPI only decreases probably makes sense, too (which basically means aspect scaling is done by scaling up, not down).


More information about the ffmpeg-devel mailing list