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

Michael Niedermayer michaelni at gmx.at
Wed Apr 2 00:14:59 CEST 2014


On Tue, Apr 01, 2014 at 11:07:16PM +0200, Carl Eugen Hoyos wrote:
> On Tuesday 01 April 2014 10:16:40 pm Michael Niedermayer wrote:
> > 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
> 
> New patch attached.
> 
> Thank you, Carl Eugen

>  libavformat/gif.c  |   21 ++++++++++++++-------
>  tests/ref/lavf/gif |    2 +-
>  2 files changed, 15 insertions(+), 8 deletions(-)
> b08a7d1dc97f47b044324de6a047c4c42fa4ce6a  patchgifaspect.diff

should be ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- 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/20140402/e6949219/attachment.asc>


More information about the ffmpeg-devel mailing list