[FFmpeg-devel] [PATCH]Write aspect ratio to gif files

Michael Niedermayer michaelni at gmx.at
Tue Apr 1 22:16:40 CEST 2014


On Tue, Apr 01, 2014 at 01:38:51PM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch writes the sample aspect ratio to gif.
> Tested with xv and FFmpeg.
> 
> Please comment, Carl Eugen

>  libavformat/gif.c  |   21 ++++++++++++++-------
>  tests/ref/lavf/gif |    2 +-
>  2 files changed, 15 insertions(+), 8 deletions(-)
> b7060e85048dce022b89f41bf8da258211c88856  patchgifaspect.diff
> diff --git a/libavformat/gif.c b/libavformat/gif.c
> index e52498d..7eab31f 100644
> --- a/libavformat/gif.c
> +++ b/libavformat/gif.c
> @@ -28,10 +28,18 @@
>  #include "libavutil/log.h"
>  #include "libavutil/opt.h"
>  
> -static int gif_image_write_header(AVIOContext *pb, int width, int height,
> +static int gif_image_write_header(AVFormatContext *s, int width, int height,
>                                    int loop_count, uint32_t *palette)
>  {
> -    int i;
> +    AVIOContext *pb = s->pb;
> +    AVRational sar = s->streams[0]->codec->sample_aspect_ratio;
> +    int i, aspect = 0;
> +
> +    if (sar.den > 0) {

this should also check sar.num >0

> +        aspect = sar.num * 64 / sar.den - 15;
> +        if (aspect > 255)
> +            aspect = 0;

i suspect this needs a aspect < 0 check too

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- 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/20140401/38d8b8fc/attachment.asc>


More information about the ffmpeg-devel mailing list