[FFmpeg-devel] [PATCH]Read aspect ratio from tiff files
Michael Niedermayer
michaelni at gmx.at
Mon Apr 7 01:32:50 CEST 2014
On Mon, Apr 07, 2014 at 12:17:39AM +0200, Carl Eugen Hoyos wrote:
> Hi!
>
> Attached patch allows to read the aspect from tiff images.
>
> Please comment, Carl Eugen
> tiff.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
> 3a76fd6ed0577bf1422f1d90d4cb6cefbb969a82 patchtiffsar.diff
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index cbc526a..e5dafa5 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -58,6 +58,7 @@ typedef struct TiffContext {
> int fax_opts;
> int predictor;
> int fill_order;
> + uint32_t res[4];
>
> int strips, rps, sstype;
> int sot;
> @@ -566,9 +567,19 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
> return 0;
> }
>
> +static void set_sar(TiffContext *s, unsigned tag, unsigned num, unsigned den)
> +{
> + int offset = tag == TIFF_YRES ? 2 : 0;
> + s->res[offset++] = num;
> + s->res[offset] = den;
> + if (s->res[0] && s->res[1] && s->res[2] && s->res[3])
> + av_reduce(&s->avctx->sample_aspect_ratio.num, &s->avctx->sample_aspect_ratio.den,
> + s->res[2] * s->res[1], s->res[0] * s->res[3], INT32_MAX);
these need to be cast tp 64bit to avid overflows unless
something ensures they are not more than 16bit
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The educated differ from the uneducated as much as the living from the
dead. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140407/ae634312/attachment.asc>
More information about the ffmpeg-devel
mailing list